Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b1c868326 | ||
|
|
14d7c5de2a | ||
|
|
7a1b1ff5be | ||
|
|
461519cce7 | ||
|
|
0acca27ac7 | ||
|
|
86be3af75f | ||
|
|
0dcfa1d7f7 | ||
|
|
a2c5172db3 | ||
|
|
29e2012267 | ||
|
|
c859049041 | ||
|
|
db9d983646 | ||
|
|
181c4a999b | ||
|
|
053fabd4e1 | ||
|
|
ad8476eb7d | ||
|
|
7f61a6cb79 | ||
|
|
dbbf9a052f | ||
|
|
83a0e9013e | ||
|
|
e68616b799 | ||
|
|
9e73aeb10f | ||
|
|
0d1381adf9 | ||
|
|
cdb5b16198 | ||
|
|
35b5976e69 | ||
|
|
fe2042da8a | ||
|
|
091d5f3b0a | ||
|
|
08273aa1b2 | ||
|
|
b5e7647028 | ||
|
|
42bd871af3 | ||
|
|
f81d6fe8d3 | ||
|
|
1456a10ace | ||
|
|
8ff7f33c52 | ||
|
|
3eacb857a1 | ||
|
|
2466d933c9 | ||
|
|
4e621b5f6b | ||
|
|
b916f5cd8b | ||
|
|
6cf05d487f | ||
|
|
1a7a91b779 | ||
|
|
df8c3debc8 | ||
|
|
374216fe22 | ||
|
|
fc6ef3e1e8 | ||
|
|
8d41fb8c3e | ||
|
|
3c7dda6e7e | ||
|
|
869aca4392 | ||
|
|
d9be86f45b | ||
|
|
9c0716a73a |
132
ChangeLog
132
ChangeLog
@@ -1,3 +1,135 @@
|
||||
GNU nano 2.2.5 - 2010.08.05
|
||||
2010-08-04 Lauri Kasanen <curaga@operamail.comcuraga@operamail.com>
|
||||
* doc/syntax/mgp.nanorc: New Magicpoint syntax highlighting definition
|
||||
|
||||
2010-08-04 Peter <exodus@savannah>
|
||||
* doc/syntax/tex.nanorc: No longer highlight escaped comments
|
||||
|
||||
2010-06-20 Chris Allegretta <chrisa@asty.org>
|
||||
* New rc file option allow_insecure_backup, allows the previous security
|
||||
fixes for backup files to be overridden if you're really positive
|
||||
you want to. Fixes Savannah bug 29732 by Brian Szymanski <skibrianski>.
|
||||
|
||||
2010-05-23 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (write_file): Don't even try to chown() the backup
|
||||
file unless we're root, since it's probably going to fail if
|
||||
we're editing a file we don't own. Fixes Savannah bug
|
||||
29514: [nano 2.2.2] backup should ignore chown errors.
|
||||
|
||||
GNU nano 2.2.4 - 2010.04.15
|
||||
2010-04-07 Chris Allegretta <chrisa@asty.org>
|
||||
* doc/man/nano.1,nanorc.5: Remove the backup file warnings now
|
||||
that a sufficient security fix exists for the backup file code.
|
||||
|
||||
2010-04-14 Chris Allegretta <chrisa@asty.org>
|
||||
* text.c (do_alt_speller): Skip invoking the alt speller if the file size
|
||||
is 0 bytes. Fixes Savannah bug 29393 reported by Mike Frysinger.
|
||||
* files.c (wirte_file): Don't set current_stat when tmp == TRUE, check
|
||||
whether current_stat is set when trying to use it, and don't do the
|
||||
modification check if the filename changed, since we have no way
|
||||
of knowing about it in that case. Fixes Savannah bug 29392, reported
|
||||
by Mike Frysinger. [CVE-2010-1160]
|
||||
|
||||
2010-04-13 Felipe Bugno <necron@bol.com.br>
|
||||
* doc/syntax/cmake.nanorc: Added cmake syntax highlighting file.
|
||||
|
||||
2010-04-09 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (do_writeout): Better security fixes for backup file writing,
|
||||
mangled from submission by Dan Rosenberg <dan.j.rosenberg at gmail>
|
||||
[CVE-2010-1161]
|
||||
|
||||
2010-04-08 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (do_writeout): Previous fixes should not cause a crash
|
||||
when saving a new file. Discovered by Mike Frysinger <vapier@gentoo.org>.
|
||||
|
||||
2010-04-07 Chris Allegretta <chrisa@asty.org>
|
||||
* doc/man/nano.1,nanorc.5: Add warnings about using backup
|
||||
mode as root due to the Dan Rosenberg security analysis.
|
||||
|
||||
2010-04-02 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (do_writeout): Expand modification check to include both the
|
||||
original file's device ID and inode number as reasons to warn the
|
||||
user that the file has been modified. Also abort on writing a backup
|
||||
file when its owner doesn't match the edited file. Based on security
|
||||
analysis on nano by Dan Rosenberg. [CVE-2010-1160]
|
||||
|
||||
|
||||
2010-03-21 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (page_stdin et al): Don't attempt to reset/reopen the terminal
|
||||
settings when reading stdin if it was aborted with SIGINT. May fix Savannah
|
||||
bug 29114 reported by Mike Frysinger.
|
||||
|
||||
2010-03-21 Mike Frysinger <vapier@gentoo.org>
|
||||
* doc/syntax/c.nanorc: Add additional support for #include_next and #pragma
|
||||
|
||||
2010-03-21 Chris Allegretta <chrisa@asty.org>
|
||||
* move.c (do_page_up, do_page_down()): Explicitly set current_y to 0 when paging
|
||||
up when not in smooth scroll mode, as previous fixes would otherwise cause
|
||||
the cursor to not really be moved to the stop of the screen.
|
||||
|
||||
2010-03-07 Chris Allegretta <chrisa@asty.org>
|
||||
* configure.ac, nano.c (handle_sigwinch): Create check for whether LINES and
|
||||
COLS can safely be redefined. Fixes compilation issues with cygwin, and likely
|
||||
with newer versions of ncurses, fixes Savannah bug 28984 repoted by Andy Koppe
|
||||
and Eric Oliver via mailing list.
|
||||
* winio.c (get_mouseinput) - fix stray semicolon in code, also reported in
|
||||
bug 28984.
|
||||
|
||||
GNU nano 2.2.3 - 2010.02.11
|
||||
2010-01-28 Chris Allegretta <chrisa@asty.org>
|
||||
* move.c (do_page_up, do_page_down): Fix for smooth mode not preserving cusor
|
||||
position. Part one of fix for Savannah bug 21178 by Mike Frysinger.
|
||||
|
||||
GNU nano 2.2.2 - 2010.01.17
|
||||
2010-01-17 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (main), prompt.c (do_statusbar_input): Handle problems with an unmapped
|
||||
function due to key rebinding, fixes crashes on FreeBSD repoted by Eitan
|
||||
Adler <eitanadlerlist@gmail.com>.
|
||||
|
||||
2010-01-14 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (do_writeout): Fix for crash / incorrect external modification warning
|
||||
due to earlier fix in r4467.
|
||||
|
||||
2010-01-12 Chris Allegretta <chrisa@asty.org>
|
||||
* move.c (do_page_up, do_page_down): Fix issues with not enough scrolling down/up
|
||||
and cursor centering.
|
||||
* winio.c (edit_scroll): Remove lots of needless checking of line length for
|
||||
soft wrapping code.
|
||||
* winio.c (edit_update) - Remove extra code for when updating with old_current outside
|
||||
of the new buffer boundary and centering issues.
|
||||
|
||||
2010-01-05 Tito <farmatito@tiscali.it>
|
||||
* search.c (update_history): Fix bad length check causing search crash on armel platform.
|
||||
|
||||
2010-01-04 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c: edit_update, edit_redraw: Fix search not scrolling to the middle of the screen
|
||||
(reported by alpha@qzx.com) and places where we rely on maxrows but should not.
|
||||
|
||||
2009-12-26 Jordi Mallach <jordi@gnu.org>
|
||||
* doc/man/nano.1: Avoid a groff warning by prepending a zero-width
|
||||
space to a line starting with '.
|
||||
|
||||
2009-12-22 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (write_file): Fix compatibility with previous stat fix and tiny mode.
|
||||
|
||||
2009-12-22 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* global.c: Add new strings for forward/back in the file browser. New variables
|
||||
nano_forwardfile_msg and nano_backfile_msg.
|
||||
|
||||
2009-12-20 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (is_file_writable): remove assert check for f, since it's not
|
||||
initialized at the time. Fixes Savannah bug 28309, reported by Zoltan Kovacs.
|
||||
|
||||
2009-12-20 Brian Szymanski <skibrianski via Savannah>
|
||||
* src/files.c (write_file): Check stat struct exists, and if not use just obtained stat data.
|
||||
Fixes Ubuntu bug 471568, "reproducible crash in nano on trying to save to a file
|
||||
different than the one specified on the command line".
|
||||
|
||||
2009-12-15 Chris Allegretta <chrisa@asty.org>
|
||||
* doc/nanorc.sample.in - Remove erroneous 'set suspendenable' as it's actually a
|
||||
key binding (e.g. 'bind M-Z suspendenable all') and not a settable flag. Fixes
|
||||
Savannah bug 28299 reported by Mike Frysinger.
|
||||
|
||||
GNU nano 2.2.1 - 2009.12.12
|
||||
2009-12-12 Chris Allegretta <chrisa@asty.org>
|
||||
* text.c (do_delete), nano.c (do_output): Add check for length of current line
|
||||
|
||||
52
NEWS
52
NEWS
@@ -1,3 +1,55 @@
|
||||
2010.08.05 - GNU nano 2.2.5 "Inactivity timeout" is now available.
|
||||
This release includes slightly less restrictive checkng
|
||||
when writing files in strange environments (e.g.
|
||||
when being used out of crontab). For very strange situations
|
||||
(such as where you cannot change the permissions on the
|
||||
file you're writing, there is a new rc file option
|
||||
"allow_insecure_backup" to be even more permission and
|
||||
allowing the write to proceed. Also included are
|
||||
some syntax highlighting updated, and that is about it.
|
||||
Keep fighting the good fight children.
|
||||
|
||||
2010.04.15 - GNU nano 2.2.4 is nobody's fool. First and foremost,
|
||||
this relase includes some security fixes due to
|
||||
an assessment of nano's vulnerability to symlink attacks
|
||||
on open files. The CVEs fixed with this release are
|
||||
CVE-2010-1160 and CVE-2010-1161. Also included are fixes
|
||||
for various crash modes when using the spell checker
|
||||
on new files in multibuffer mode (surely you've used
|
||||
that combination recently? No?) as well as a fixing
|
||||
the 'file was modified' message when saving to a
|
||||
new filename (since how would nano know?). And
|
||||
the list would not be complete without our
|
||||
third-times-the-charm fixes to page up/down due to
|
||||
the soft wrapping code. The lone new feature
|
||||
included is a new syntax higlighting definition for
|
||||
cmake-related files. Please do consider upgrading to
|
||||
this release if still using the 2.0 series since
|
||||
fixes for that version are still forthcoming.
|
||||
|
||||
|
||||
2010.02.11 - GNU nano 2.2.3 "fumbling toward stability" is released.
|
||||
This release contains a fix for only one bug, but a
|
||||
rather irritating one: when paging up/down with smooth
|
||||
scrolling, the cursor position was not being preserved
|
||||
due to a bug in 2.2.2. With such a targeted fix
|
||||
like this what could POSSIBLY go WRONG? Hahaha.
|
||||
Enjoy and if you find new bugs, as always please
|
||||
use Savannah's bug tracker.
|
||||
http://savannah.gnu.org/bugs/?func=additem&group=nano
|
||||
|
||||
2010.01.17 - GNU nano 2.2.2 is released for you, you, you. This
|
||||
release includes fixes for: crashed when writing
|
||||
backup files in certain conditions, improper
|
||||
screen centering when moving up/down in various
|
||||
combination of smooth scrolling and soft wrapping modes,
|
||||
a search crash on the armel arch, and issues with
|
||||
lots of keybinding customizations causing crashing
|
||||
particularly on FreeBSD. Also included are better
|
||||
help menu entries for forward/back in the file browser,
|
||||
some man page tweaks and one assert fix. As always,
|
||||
share and enjoy!
|
||||
|
||||
2009.12.12 - GNU nano 2.2.1 "DLR strikes back" is open for business.
|
||||
This release fixes many bugs, including: missing
|
||||
keybindings for page up/down and GotoDir in the browser,
|
||||
|
||||
1
TODO
1
TODO
@@ -28,6 +28,7 @@ For the future (no targeted version, catch-all)
|
||||
FFFD (Replacement Character) per sequence instead of one per byte.
|
||||
|
||||
For version 2.4:
|
||||
- New regression framework built on expect.
|
||||
- Allow text searches in the help browser.
|
||||
- Handle window resizes better. After we resize, we should stay
|
||||
wherever we were before we resized, as Pico does.
|
||||
|
||||
17
configure.ac
17
configure.ac
@@ -20,7 +20,7 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [2.2.1], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.2.5], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_TARGET([])
|
||||
AM_INIT_AUTOMAKE
|
||||
@@ -569,6 +569,21 @@ int main(void)
|
||||
fi
|
||||
#fi
|
||||
|
||||
AC_MSG_CHECKING([whether LINES and COLS can be redefined])
|
||||
AC_TRY_RUN([
|
||||
#include <curses.h>
|
||||
int main(void)
|
||||
{
|
||||
LINES = 80;
|
||||
COLS = 25;
|
||||
return 0;
|
||||
}],
|
||||
AC_DEFINE(REDEFINIG_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug])
|
||||
AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
|
||||
|
||||
|
||||
# Check for groff html support
|
||||
AC_MSG_CHECKING([for HTML support in groff])
|
||||
groff -t -mandoc -Thtml </dev/null >/dev/null
|
||||
|
||||
@@ -62,7 +62,7 @@ line.
|
||||
.TP
|
||||
.B \-B (\-\-backup)
|
||||
When saving a file, back up the previous version of it to the current
|
||||
filename suffixed with a ~.
|
||||
filename suffixed with a ~.
|
||||
.TP
|
||||
.B \-C \fIdir\fP (\-\-backupdir=\fIdir\fP)
|
||||
Set the directory where \fBnano\fP puts unique backup files if file
|
||||
@@ -209,7 +209,7 @@ Enable suspend ability.
|
||||
.B \-$ (\-\-softwrap)
|
||||
Enable 'soft wrapping'. \fBnano\fP will attempt to display the entire
|
||||
contents of a line, even if it is longer than the screen width. Since
|
||||
'$' normally refers to a variable in the Unix shell, you should specify
|
||||
\&'$' normally refers to a variable in the Unix shell, you should specify
|
||||
this option last when using other options (e.g. 'nano \-wS$') or pass it
|
||||
separately (e.g. 'nano \-wS \-$').
|
||||
.TP
|
||||
|
||||
@@ -57,6 +57,11 @@ match \fI"\fP, \fI'\fP, \fI)\fP, \fI>\fP, \fI]\fP, and \fI}\fP.
|
||||
The supported commands and arguments are:
|
||||
|
||||
.TP 3
|
||||
.B set/unset allow_insecure_backup
|
||||
When backing up files, allow the backup to succeed even if its permissions
|
||||
can't be (re)set due to special OS considerations. You should
|
||||
NOT enable this option unless you are sure you need it.
|
||||
.TP
|
||||
.B set/unset autoindent
|
||||
Use auto-indentation.
|
||||
.TP
|
||||
@@ -451,7 +456,7 @@ When writing a file, append to the end instead of overwriting.
|
||||
When writing a file, 'prepend' (write at the beginning) instead of overwriting.
|
||||
.TP
|
||||
.B backup
|
||||
When writing a file, create a backup of the current file.
|
||||
When writing a file, create a backup of the current file.
|
||||
.TP
|
||||
.B firstfile
|
||||
Move to the first file when using the file browser (reading or writing files).
|
||||
|
||||
@@ -152,10 +152,6 @@
|
||||
## Allow nano to be suspended.
|
||||
# set suspend
|
||||
|
||||
## If nano is allowed to be suspended, allow the suspend key (usually
|
||||
## ^Z) to actually suspend it.
|
||||
# set suspendenable
|
||||
|
||||
## Use this tab size instead of the default; it must be greater than 0.
|
||||
# set tabsize 8
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
pkgdata_DATA = asm.nanorc \
|
||||
c.nanorc \
|
||||
cmake.nanorc \
|
||||
groff.nanorc \
|
||||
html.nanorc \
|
||||
java.nanorc \
|
||||
@@ -23,6 +24,7 @@ pkgdata_DATA = asm.nanorc \
|
||||
ocaml.nanorc \
|
||||
objc.nanorc \
|
||||
fortran.nanorc \
|
||||
makefile.nanorc
|
||||
makefile.nanorc \
|
||||
mgp.nanorc
|
||||
|
||||
EXTRA_DIST = $(pkgdata_DATA)
|
||||
|
||||
@@ -8,7 +8,7 @@ color green "\<(class|namespace|template|public|protected|private|typename|this|
|
||||
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
|
||||
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
|
||||
color magenta "\<(goto|continue|break|return)\>"
|
||||
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
|
||||
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)"
|
||||
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
|
||||
##
|
||||
## GCC builtins
|
||||
|
||||
19
doc/syntax/cmake.nanorc
Normal file
19
doc/syntax/cmake.nanorc
Normal file
@@ -0,0 +1,19 @@
|
||||
## CMake syntax highlighter for GNU Nano
|
||||
##
|
||||
syntax "cmake" "(CMakeLists\.txt|\.cmake)$"
|
||||
|
||||
icolor green "^[[:space:]]*[A-Z0-9_]+"
|
||||
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
|
||||
|
||||
icolor brightgreen "^[[:space:]]*\<((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
|
||||
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)\>[[:space:]]"
|
||||
color brightgreen "[[:space:]]\<(OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))\>[[:space:]]"
|
||||
|
||||
icolor brightred "^[[:space:]]*\<((end)?(function|macro)|return)"
|
||||
|
||||
icolor cyan start="\$(\{|ENV\{)" end="\}"
|
||||
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
|
||||
|
||||
icolor brightblue "^([[:space:]]*)?#.*"
|
||||
icolor brightblue "[[:space:]]#.*"
|
||||
color ,green "[[:space:]]+$"
|
||||
8
doc/syntax/mgp.nanorc
Normal file
8
doc/syntax/mgp.nanorc
Normal file
@@ -0,0 +1,8 @@
|
||||
## Here is an example for Magicpoint presentations
|
||||
##
|
||||
syntax "mgp" "\.mgp$"
|
||||
header "^%include.*"
|
||||
icolor green "^%[a-z].*$"
|
||||
color cyan "(^|[[:space:]])#.*$"
|
||||
color cyan "(^|[[:space:]])%%.*$"
|
||||
color ,green "[[:space:]]+$"
|
||||
@@ -4,7 +4,7 @@ syntax "nanorc" "\.?nanorc$"
|
||||
## Possible errors and parameters
|
||||
icolor brightwhite "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
|
||||
## Keywords
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|speller|suspend|suspendenable|tabsize|tabstospaces|tempfile|undo|view|whitespace|wordbounds)\>"
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|speller|suspend|suspendenable|tabsize|tabstospaces|tempfile|undo|view|whitespace|wordbounds)\>"
|
||||
icolor green "^[[:space:]]*(set|unset|include|syntax|header)\>"
|
||||
## Colors
|
||||
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
syntax "tex" "\.tex$"
|
||||
icolor green "\\.|\\[A-Z]*"
|
||||
color magenta "[{}]"
|
||||
color blue "%.*"
|
||||
color blue "(^|[^\])%.*"
|
||||
|
||||
443
po/nano.pot
443
po/nano.pot
File diff suppressed because it is too large
Load Diff
495
po/pt_BR.po
495
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
455
po/zh_CN.po
455
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
445
po/zh_TW.po
445
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
88
src/files.c
88
src/files.c
@@ -309,7 +309,7 @@ int is_file_writable(const char *filename)
|
||||
if (ISSET(VIEW_MODE))
|
||||
return TRUE;
|
||||
|
||||
assert(filename != NULL && f != NULL);
|
||||
assert(filename != NULL);
|
||||
|
||||
/* Get the specified file's full path. */
|
||||
full_filename = get_full_path(filename);
|
||||
@@ -1458,6 +1458,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
/* The actual file, realname, we are writing to. */
|
||||
char *tempname = NULL;
|
||||
/* The temp file name we write to on prepend. */
|
||||
int backup_cflags;
|
||||
|
||||
assert(name != NULL);
|
||||
|
||||
@@ -1500,14 +1501,22 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
realexists = (stat(realname, &st) != -1);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* if we have not stat()d this file before (say, the user just
|
||||
* specified it interactively), stat and save the value
|
||||
* or else we will chase null pointers when we do
|
||||
* modtime checks, preserve file times, etc. during backup */
|
||||
if (openfile->current_stat == NULL && !tmp && realexists)
|
||||
stat(realname, openfile->current_stat);
|
||||
|
||||
/* We backup only if the backup toggle is set, the file isn't
|
||||
* temporary, and the file already exists. Furthermore, if we
|
||||
* aren't appending, prepending, or writing a selection, we backup
|
||||
* only if the file has not been modified by someone else since nano
|
||||
* opened it. */
|
||||
if (ISSET(BACKUP_FILE) && !tmp && realexists && ((append !=
|
||||
OVERWRITE || openfile->mark_set) ||
|
||||
openfile->current_stat->st_mtime == st.st_mtime)) {
|
||||
OVERWRITE || openfile->mark_set) || (openfile->current_stat &&
|
||||
openfile->current_stat->st_mtime == st.st_mtime))) {
|
||||
int backup_fd;
|
||||
FILE *backup_file;
|
||||
char *backupname;
|
||||
struct utimbuf filetime;
|
||||
@@ -1581,18 +1590,51 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
sprintf(backupname, "%s~", realname);
|
||||
}
|
||||
|
||||
/* Open the destination backup file. Before we write to it, we
|
||||
* set its permissions, so no unauthorized person can read it as
|
||||
* we write. */
|
||||
backup_file = fopen(backupname, "wb");
|
||||
/* First, unlink any existing backups. Next, open the backup
|
||||
file with O_CREAT and O_EXCL. If it succeeds, we
|
||||
have a file descriptor to a new backup file. */
|
||||
if (unlink(backupname) < 0 && errno != ENOENT && !ISSET(INSECURE_BACKUP)) {
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
free(backupname);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
if (backup_file == NULL || chmod(backupname,
|
||||
openfile->current_stat->st_mode) == -1) {
|
||||
if (ISSET(INSECURE_BACKUP))
|
||||
backup_cflags = O_WRONLY | O_CREAT | O_APPEND;
|
||||
else
|
||||
backup_cflags = O_WRONLY | O_CREAT | O_EXCL | O_APPEND;
|
||||
|
||||
backup_fd = open(backupname, backup_cflags,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
/* Now we've got a safe file stream. If the previous open()
|
||||
call failed, this will return NULL. */
|
||||
backup_file = fdopen(backup_fd, "wb");
|
||||
|
||||
if (backup_fd < 0 || backup_file == NULL) {
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
free(backupname);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
/* We shouldn't worry about chown()ing something if we're not
|
||||
root, since it's likely to fail! */
|
||||
if (geteuid() == NANO_ROOT_UID && fchown(backup_fd,
|
||||
openfile->current_stat->st_uid, openfile->current_stat->st_gid) == -1
|
||||
&& !ISSET(INSECURE_BACKUP)) {
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
free(backupname);
|
||||
if (backup_file != NULL)
|
||||
fclose(backup_file);
|
||||
fclose(backup_file);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1 && !ISSET(INSECURE_BACKUP)) {
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
free(backupname);
|
||||
fclose(backup_file);
|
||||
/* If we can't write to the backup, DONT go on, since
|
||||
whatever caused the backup file to fail (e.g. disk
|
||||
full may well cause the real file write to fail, which
|
||||
@@ -1607,17 +1649,16 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
/* Copy the file. */
|
||||
copy_status = copy_file(f, backup_file);
|
||||
|
||||
/* And set its metadata. */
|
||||
if (copy_status != 0 || chown(backupname,
|
||||
openfile->current_stat->st_uid,
|
||||
openfile->current_stat->st_gid) == -1 ||
|
||||
utime(backupname, &filetime) == -1) {
|
||||
if (copy_status == -1) {
|
||||
statusbar(_("Error reading %s: %s"), realname,
|
||||
if (copy_status != 0) {
|
||||
statusbar(_("Error reading %s: %s"), realname,
|
||||
strerror(errno));
|
||||
beep();
|
||||
} else
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
beep();
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
/* And set its metadata. */
|
||||
if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
/* If we can't write to the backup, DONT go on, since
|
||||
whatever caused the backup file to fail (e.g. disk
|
||||
@@ -2118,7 +2159,10 @@ bool do_writeout(bool exiting)
|
||||
}
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
if (name_exists && openfile->current_stat && openfile->current_stat->st_mtime < st.st_mtime) {
|
||||
/* Complain if the file exists, the name hasn't changed, and the
|
||||
stat information we had before does not match what we have now */
|
||||
else if (name_exists && openfile->current_stat && (openfile->current_stat->st_mtime < st.st_mtime ||
|
||||
openfile->current_stat->st_dev != st.st_dev || openfile->current_stat->st_ino != st.st_ino)) {
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("File was modified since you opened it, continue saving ? "));
|
||||
if (i == 0 || i == -1)
|
||||
|
||||
19
src/global.c
19
src/global.c
@@ -638,8 +638,9 @@ void shortcut_init(bool unjustify)
|
||||
N_("Go to the first file in the list");
|
||||
const char *nano_lastfile_msg =
|
||||
N_("Go to the last file in the list");
|
||||
const char *nano_forwardfile_msg = N_("Go to the next file in the list");
|
||||
const char *nano_backfile_msg = N_("Go to the previous file in the list");
|
||||
const char *nano_gotodir_msg = N_("Go to directory");
|
||||
|
||||
#endif
|
||||
#endif /* !DISABLE_HELP */
|
||||
|
||||
@@ -792,12 +793,24 @@ void shortcut_init(bool unjustify)
|
||||
|
||||
#endif
|
||||
|
||||
add_to_funcs(DO_RIGHT, (MMAIN|MBROWSER), N_("Forward"), IFSCHELP(nano_forward_msg),
|
||||
add_to_funcs(DO_RIGHT, MMAIN, N_("Forward"), IFSCHELP(nano_forward_msg),
|
||||
FALSE, VIEW);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
add_to_funcs(DO_RIGHT, MBROWSER, N_("Forward"), IFSCHELP(nano_forwardfile_msg),
|
||||
FALSE, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(DO_RIGHT, MALL, "", "", FALSE, VIEW);
|
||||
|
||||
add_to_funcs(DO_LEFT, (MMAIN|MBROWSER), N_("Back"), IFSCHELP(nano_back_msg),
|
||||
add_to_funcs(DO_LEFT, MMAIN, N_("Back"), IFSCHELP(nano_back_msg),
|
||||
FALSE, VIEW);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
add_to_funcs(DO_LEFT, MBROWSER, N_("Back"), IFSCHELP(nano_backfile_msg),
|
||||
FALSE, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(DO_LEFT, MALL, "", "", FALSE, VIEW);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
|
||||
19
src/move.c
19
src/move.c
@@ -55,7 +55,8 @@ void do_page_up(void)
|
||||
/* 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 (!ISSET(SOFTWRAP) && openfile->current->lineno <= editwinrows - 2) {
|
||||
if (openfile->current->lineno == 1 || (!ISSET(SOFTWRAP) &&
|
||||
openfile->current->lineno <= editwinrows - 2)) {
|
||||
do_first_line();
|
||||
return;
|
||||
}
|
||||
@@ -67,7 +68,7 @@ void do_page_up(void)
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
#endif
|
||||
openfile->current = openfile->edittop;
|
||||
openfile->placewewant = 0;
|
||||
openfile->placewewant = openfile->current_y = 0;
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
#endif
|
||||
@@ -92,7 +93,7 @@ openfile->current->lineno, strlenpt(openfile->current->data));
|
||||
#endif
|
||||
|
||||
/* Scroll the edit window up a page. */
|
||||
edit_scroll(UP_DIR, editwinrows - skipped - 2);
|
||||
edit_update(NONE);
|
||||
}
|
||||
|
||||
/* Move down one page. */
|
||||
@@ -115,7 +116,7 @@ void do_page_down(void)
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
#endif
|
||||
openfile->current = openfile->edittop;
|
||||
openfile->placewewant = 0;
|
||||
openfile->placewewant = openfile->current_y = 0;
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
#endif
|
||||
@@ -133,7 +134,7 @@ void do_page_down(void)
|
||||
openfile->placewewant);
|
||||
|
||||
/* Scroll the edit window down a page. */
|
||||
edit_scroll(DOWN_DIR, editwinrows - 2);
|
||||
edit_update(NONE);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -521,7 +522,7 @@ void do_up(
|
||||
#ifndef NANO_TINY
|
||||
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
|
||||
#endif
|
||||
editwinrows / 2);
|
||||
editwinrows / 2 + 1);
|
||||
|
||||
/* If we're below the first line of the edit window, update the
|
||||
* line we were on before and the line we're on now. The former
|
||||
@@ -590,13 +591,15 @@ void do_down(
|
||||
#ifndef NANO_TINY
|
||||
|| scroll_only
|
||||
#endif
|
||||
)
|
||||
) {
|
||||
edit_scroll(DOWN_DIR,
|
||||
#ifndef NANO_TINY
|
||||
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
|
||||
#endif
|
||||
editwinrows / 2);
|
||||
editwinrows / 2 + 1);
|
||||
|
||||
edit_refresh_needed = TRUE;
|
||||
}
|
||||
/* If we're above the last line of the edit window, update the line
|
||||
* we were on before and the line we're on now. The former needs to
|
||||
* be redrawn if we're not on the first page, and the latter needs
|
||||
|
||||
16
src/nano.c
16
src/nano.c
@@ -518,6 +518,7 @@ openfilestruct *make_new_opennode(void)
|
||||
newnode->edittop = NULL;
|
||||
newnode->current = NULL;
|
||||
#ifndef NANO_TINY
|
||||
newnode->current_stat = NULL;
|
||||
newnode->last_action = OTHER;
|
||||
#endif
|
||||
|
||||
@@ -1066,6 +1067,8 @@ void do_exit(void)
|
||||
|
||||
static struct sigaction pager_oldaction, pager_newaction; /* Original and temporary handlers for SIGINT. */
|
||||
static bool pager_sig_failed = FALSE; /* Did sigaction() fail without changing the signal handlers? */
|
||||
static bool pager_input_aborted = FALSE; /* Did someone invoke the pager and abort it via ^C? */
|
||||
|
||||
|
||||
/* Things which need to be run regardless of whether
|
||||
we finished the stdin pipe correctly or not */
|
||||
@@ -1086,7 +1089,8 @@ void finish_stdin_pager(void)
|
||||
|
||||
dup2(ttystdin,0);
|
||||
close(ttystdin);
|
||||
tcgetattr(0, &oldterm);
|
||||
if (!pager_input_aborted)
|
||||
tcgetattr(0, &oldterm);
|
||||
if (!pager_sig_failed && sigaction(SIGINT, &pager_oldaction, NULL) == -1)
|
||||
nperror("sigaction");
|
||||
terminal_init();
|
||||
@@ -1098,13 +1102,15 @@ void finish_stdin_pager(void)
|
||||
RETSIGTYPE cancel_stdin_pager(int signal)
|
||||
{
|
||||
/* Currently do nothing, just handle the intr silently */
|
||||
pager_input_aborted = TRUE;
|
||||
}
|
||||
|
||||
/* Let nano read stdin for the first file at least */
|
||||
void stdin_pager(void)
|
||||
{
|
||||
endwin();
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
if (!pager_input_aborted)
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
fprintf(stderr, _("Reading from stdin, ^C to abort\n"));
|
||||
|
||||
/* Set things up so that Ctrl-C will cancel the new process. */
|
||||
@@ -1124,7 +1130,7 @@ void stdin_pager(void)
|
||||
nperror("sigaction");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
open_buffer("", FALSE);
|
||||
finish_stdin_pager();
|
||||
}
|
||||
@@ -1262,8 +1268,10 @@ RETSIGTYPE handle_sigwinch(int signal)
|
||||
* otherwise. However, COLS and LINES are curses global variables,
|
||||
* and in some cases curses has already updated them. But not in
|
||||
* all cases. Argh. */
|
||||
#ifdef REDEFINIG_MACROS_OK
|
||||
COLS = win.ws_col;
|
||||
LINES = win.ws_row;
|
||||
#endif
|
||||
|
||||
/* If we've partitioned the filestruct, unpartition it now. */
|
||||
if (filepart != NULL)
|
||||
@@ -1625,7 +1633,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
||||
#endif
|
||||
iso_me_harder_funcmap(s->scfunc);
|
||||
#ifdef ENABLE_COLOR
|
||||
if (!f->viewok && openfile->syntax != NULL
|
||||
if (f && !f->viewok && openfile->syntax != NULL
|
||||
&& openfile->syntax->nmultis > 0) {
|
||||
reset_multis(openfile->current, FALSE);
|
||||
}
|
||||
|
||||
@@ -480,6 +480,7 @@ enum
|
||||
REBIND_KEYPAD,
|
||||
NO_CONVERT,
|
||||
BACKUP_FILE,
|
||||
INSECURE_BACKUP,
|
||||
NO_COLOR_SYNTAX,
|
||||
PRESERVE,
|
||||
HISTORYLOG,
|
||||
|
||||
@@ -229,7 +229,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
f = sctofunc((sc *) s);
|
||||
if (s->scfunc != 0 && s->execute == TRUE) {
|
||||
*ran_func = TRUE;
|
||||
if (!ISSET(VIEW_MODE) || f->viewok)
|
||||
if (f && (!ISSET(VIEW_MODE) || (f->viewok)))
|
||||
iso_me_harder_funcmap(f->scfunc);
|
||||
}
|
||||
*finished = TRUE;
|
||||
|
||||
@@ -77,6 +77,7 @@ static const rcoption rcopts[] = {
|
||||
#ifndef NANO_TINY
|
||||
{"autoindent", AUTOINDENT},
|
||||
{"backup", BACKUP_FILE},
|
||||
{"allow_insecure_backup", INSECURE_BACKUP},
|
||||
{"backupdir", 0},
|
||||
{"backwards", BACKWARDS_SEARCH},
|
||||
{"casesensitive", CASE_SENSITIVE},
|
||||
|
||||
@@ -1357,7 +1357,7 @@ void update_history(filestruct **h, const char *s)
|
||||
assert(hage != NULL && hbot != NULL);
|
||||
|
||||
/* If this string is already in the history, delete it. */
|
||||
p = find_history(*hage, *hbot, s, (size_t)-1);
|
||||
p = find_history(*hage, *hbot, s, strlen(s));
|
||||
|
||||
if (p != NULL) {
|
||||
filestruct *foo, *bar;
|
||||
|
||||
@@ -2752,6 +2752,11 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (openfile->totsize == 0) {
|
||||
statusbar(_("Finished checking spelling"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
endwin();
|
||||
|
||||
/* Set up an argument list to pass execvp(). */
|
||||
|
||||
65
src/winio.c
65
src/winio.c
@@ -1746,7 +1746,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||
* wheel is equivalent to moving down three lines. */
|
||||
for (i = 0; i < 3; i++)
|
||||
unget_kbinput((mevent.bstate & BUTTON4_PRESSED) ?
|
||||
sc_seq_or(do_up_void, 0) : sc_seq_or(DO_DOWN_VOID, 0);, FALSE,
|
||||
sc_seq_or(DO_UP_VOID, 0) : sc_seq_or(DO_DOWN_VOID, 0), FALSE,
|
||||
FALSE);
|
||||
|
||||
return 1;
|
||||
@@ -2935,7 +2935,7 @@ bool need_vertical_update(size_t pww_save)
|
||||
}
|
||||
|
||||
/* When edittop changes, try and figure out how many lines
|
||||
* we really have to work with (i.e. set maxrows)
|
||||
* we really have to work with (i.e. set maxrows)
|
||||
*/
|
||||
void compute_maxrows(void)
|
||||
{
|
||||
@@ -2988,12 +2988,9 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
#ifdef DEBUG
|
||||
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;
|
||||
if (len > 0)
|
||||
do_redraw = TRUE;
|
||||
i -= len;
|
||||
}
|
||||
for (i = maxrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next)
|
||||
;
|
||||
|
||||
if (foo) {
|
||||
extracuzsoft += strlenpt(foo->data) / COLS;
|
||||
#ifdef DEBUG
|
||||
@@ -3001,7 +2998,6 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
(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 -= 1 + strlenpt(foo->data) / COLS;
|
||||
@@ -3013,13 +3009,6 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
foo = foo->next;
|
||||
}
|
||||
}
|
||||
} 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 > 0) {
|
||||
do_redraw = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Part 1: nlines is the number of lines we're going to scroll the
|
||||
@@ -3039,11 +3028,14 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
openfile->edittop = openfile->edittop->next;
|
||||
}
|
||||
/* Don't over-scroll on long lines */
|
||||
if (ISSET(SOFTWRAP))
|
||||
i -= strlenpt(openfile->edittop->data) / COLS;
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
ssize_t len = strlenpt(openfile->edittop->data) / COLS;
|
||||
i -= len;
|
||||
if (len > 0)
|
||||
do_redraw = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
compute_maxrows();
|
||||
/* Limit nlines to the number of lines we could scroll. */
|
||||
nlines -= i;
|
||||
|
||||
@@ -3052,7 +3044,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
* call edit_refresh() beforehand if we need to. */
|
||||
if (nlines == 0 || do_redraw || nlines >= editwinrows) {
|
||||
if (do_redraw || nlines >= editwinrows)
|
||||
edit_refresh();
|
||||
edit_refresh_needed = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3128,6 +3120,10 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
openfile->edittop->lineno || openfile->current->lineno >=
|
||||
openfile->edittop->lineno + maxrows) {
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_redraw(): line %lu was offscreen, oldcurrent = %lu edittop = %lu", openfile->current->lineno,
|
||||
old_current->lineno, openfile->edittop->lineno);
|
||||
#endif
|
||||
filestruct *old_edittop = openfile->edittop;
|
||||
ssize_t nlines;
|
||||
|
||||
@@ -3160,24 +3156,13 @@ 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(NONE);
|
||||
|
||||
nlines = openfile->edittop->lineno - old_edittop->lineno;
|
||||
|
||||
openfile->edittop = old_edittop;
|
||||
edit_update(CENTER);
|
||||
|
||||
/* Update old_current if we're not on the same page as
|
||||
* before. */
|
||||
if (do_redraw)
|
||||
update_line(old_current, 0);
|
||||
|
||||
/* Scroll the edit window up or down until edittop is in range
|
||||
* of current. */
|
||||
if (nlines < 0)
|
||||
edit_scroll(UP_DIR, -nlines);
|
||||
else
|
||||
edit_scroll(DOWN_DIR, nlines);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the mark is on, update all the lines between the old first
|
||||
* line or old last line of the edit window (depending on
|
||||
@@ -3239,7 +3224,7 @@ void edit_refresh(void)
|
||||
|
||||
/* Put the top line of the edit window in range of the current
|
||||
* line. */
|
||||
edit_update(NONE);
|
||||
edit_update(CENTER);
|
||||
}
|
||||
|
||||
foo = openfile->edittop;
|
||||
@@ -3279,22 +3264,26 @@ 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 = maxrows / 2;
|
||||
goal = editwinrows / 2;
|
||||
else {
|
||||
goal = openfile->current_y;
|
||||
|
||||
/* Limit goal to (editwinrows - 1) lines maximum. */
|
||||
if (goal > maxrows - 1)
|
||||
goal = maxrows - 1;
|
||||
if (goal > editwinrows - 1)
|
||||
goal = editwinrows - 1;
|
||||
}
|
||||
|
||||
for (; goal > 0 && foo->prev != NULL; goal--) {
|
||||
if (ISSET(SOFTWRAP))
|
||||
goal -= 1 + strlenpt(foo->data) / COLS;
|
||||
foo = foo->prev;
|
||||
if (ISSET(SOFTWRAP) && foo)
|
||||
goal -= strlenpt(foo->data) / COLS;
|
||||
}
|
||||
openfile->edittop = foo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_udpate(), setting edittop to lineno %d\n", openfile->edittop->lineno);
|
||||
#endif
|
||||
compute_maxrows();
|
||||
edit_refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
/* Unconditionally redraw the entire screen. */
|
||||
|
||||
Reference in New Issue
Block a user