Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ca160f784 | ||
|
|
155d620a14 | ||
|
|
2a2e2be0c4 | ||
|
|
7044489c76 | ||
|
|
1699144136 | ||
|
|
19b9e2be94 | ||
|
|
3f583165c4 | ||
|
|
e1ebaf3821 | ||
|
|
c08f50d9de | ||
|
|
816a165b4b | ||
|
|
150469a646 | ||
|
|
544347c08a | ||
|
|
6636dc3181 | ||
|
|
90661b2def | ||
|
|
123e5e66d3 | ||
|
|
f4f7e04c5b | ||
|
|
75ef81bc42 | ||
|
|
ba8edea860 | ||
|
|
b0f5282de2 | ||
|
|
fe41584102 | ||
|
|
0e9d3c6c28 | ||
|
|
6e82741931 | ||
|
|
f0999a18f0 | ||
|
|
63c8ab94fb | ||
|
|
85b444137b | ||
|
|
425a266a92 | ||
|
|
f4b9601c1b | ||
|
|
827b15fdc0 | ||
|
|
8b6cccc5cc | ||
|
|
ee289d7a2b | ||
|
|
1e6fb08d15 | ||
|
|
66795ecbe1 | ||
|
|
d55655f23a | ||
|
|
e34f96dec2 | ||
|
|
5b89a14514 | ||
|
|
56e6d72282 | ||
|
|
79ea7dd883 | ||
|
|
e47e4edf7f | ||
|
|
c7ccb873f1 | ||
|
|
66149e7aee | ||
|
|
07b9c2b90c | ||
|
|
651216388c | ||
|
|
b7d00efd6d | ||
|
|
d1627cffd0 | ||
|
|
7492cecc27 | ||
|
|
affeda817e | ||
|
|
92325e74b9 | ||
|
|
220ba692e6 | ||
|
|
51b3eec536 | ||
|
|
3a7c0bee6b | ||
|
|
1a6e904583 | ||
|
|
b04a98dc86 | ||
|
|
7960dcf919 | ||
|
|
544d9b0210 | ||
|
|
1cd506612d | ||
|
|
3bc8c72c8b | ||
|
|
c130297a79 | ||
|
|
321590a59d | ||
|
|
e51c95fa7b | ||
|
|
5146fec04c | ||
|
|
ef12311948 | ||
|
|
f597777323 | ||
|
|
d62614cbc4 | ||
|
|
33084397dd | ||
|
|
38552ee7a8 |
@@ -1,8 +1,10 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
confdefs.h
|
||||
config.cache
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
nano
|
||||
stamp-h
|
||||
|
||||
9
BUGS
9
BUGS
@@ -76,6 +76,15 @@
|
||||
- When typing in a string in serahc or replace and hitting CASE_SENSITVE
|
||||
or the other search string, the current string edit is blown away in
|
||||
favor of the last stored search (47) [FIXED]
|
||||
- If nano fails to open a file when it starts up,doing almost anything
|
||||
causes a segfault (discovered by Ben Roberts) (48). [FIXED]
|
||||
- In certain terminals, nano would not work properly with keypad().
|
||||
Turned out to be the silly timeout(0) call which is completely
|
||||
unneeded anyway. (49) [FIXED]
|
||||
- With less than a page of text, doing a page down will move the
|
||||
current line to the top of the screen, which it shouldn't do. (50)
|
||||
[FIXED]
|
||||
- with PDCURSES, running meta-X turns off the keypad. (51) [FIXED]
|
||||
|
||||
** Open BUGS **
|
||||
|
||||
|
||||
115
ChangeLog
115
ChangeLog
@@ -1,3 +1,118 @@
|
||||
nano 0.9.25 - 01/07/2001
|
||||
General -
|
||||
- New file browser code. New functions in files.c:do_browser(),
|
||||
helper functions browser_init(), tail(), striponedir(),
|
||||
filestat(). New shortcut list browser_list. Some new
|
||||
strings to translate. Added function do_browse_from().
|
||||
- Keypad code has been changed slightly. Now checks for
|
||||
_use_keypad flag in window to see whether or not to turn
|
||||
the keypad() back off when finished (taken from aumix). Moved
|
||||
to winio.c where it should probably be anyway. New confgure
|
||||
check for _use_keypad in window sstruct. This will have to do
|
||||
for now.
|
||||
- Moved keypad() calls for PDCURSES from main() to window_init()
|
||||
so the keypad continues to work after a Meta-X, for example.
|
||||
Fixed bug #51.
|
||||
- faq.html:
|
||||
- Fix typos and small mistakes (Jordi).
|
||||
- files.c:
|
||||
username_tab_completion()
|
||||
- Added the (char *) sizeof when allocating memory for the filename
|
||||
array (Rocco).
|
||||
cwd_tab_completion()
|
||||
- removed skipping . and .. when tabulating matches.
|
||||
- Added the (char *) sizeof when allocating memory for the filename
|
||||
array (Rocco).
|
||||
do_writeout()
|
||||
- Now takes an argument so the string typed in can be retained
|
||||
when calling the browser.
|
||||
do_browser()
|
||||
- Don't decrement longest by the length of path. Fixes crashes
|
||||
on entering various dirs (Rocco).
|
||||
- Don't ungetch() the exit key, unneeded, fixes inerting a file
|
||||
causes exit code.
|
||||
- move.c:
|
||||
page_down()
|
||||
- Don't do an edit_update when there is only one page of text
|
||||
(fileage == edittop && filebot == editbot). Fixes Bug #50.
|
||||
- nano.c:
|
||||
main()
|
||||
- Reorder the getopt options to be more or less alphabetical
|
||||
(suggested by Sven Guckes).
|
||||
- winio.c:
|
||||
do_cursorpos()
|
||||
- Optimizations and cleanups by Rocco Corsi.
|
||||
do_credits()
|
||||
- Spell Erik Andersen's name right.
|
||||
titlebar()
|
||||
- Now takes an arg, needed for browser function.
|
||||
do_help()
|
||||
- Changed way of temporarily bringing up shortcuts at the
|
||||
bottom in the help screen (actually works).
|
||||
- utils.c:
|
||||
mallocstrcpy()
|
||||
- Takes char pointers now instead of void (makes debugging a
|
||||
helluva lot easier)
|
||||
- Duh, don't do anything if src == dest!
|
||||
- es.po:
|
||||
- Updates for file browser (Jordi).
|
||||
|
||||
nano 0.9.24 - 12/18/2000
|
||||
General
|
||||
- Added --disable-help option, affects acconfig.h, configure(.in),
|
||||
winio.c:do_help, nano.c:help_init,help_text_init,version.
|
||||
- Changed filename to no longer use PATH_MAX, so it can work on the
|
||||
HURD. Changes in files.c:write_file(), new function
|
||||
nano.c:clear_filename(), many changed in main(), a few other
|
||||
places. Please test this!
|
||||
- Added -b, -e, and -f flags, which we ignore as nano provides
|
||||
their functionality already.
|
||||
- cut.c:
|
||||
do_uncut_text()
|
||||
- Fix renumbering bug when uncutting marked text at filebot.
|
||||
- Fix screen not being displayed when we are uncutting marked
|
||||
text at editbot (Bug discovered by Ken Tyler).
|
||||
- Fix magic line not getting created when (you guessed it)
|
||||
uncutting marked text at filebot (Ryan Krebs).
|
||||
- files.c:
|
||||
read_file()
|
||||
- If we encounter an error and insert is not set, run new_file().
|
||||
(bug discovered by Ben Roberts).
|
||||
write_file()
|
||||
- Change open call flags, basically copy joe's way of doing it so
|
||||
a more recent version will actually be included in (un)stable.
|
||||
- Remove useless fstat call.
|
||||
open_file()
|
||||
- Added check for S_ISBLK and S_ISCHR, don't open device files!
|
||||
- nano.c:
|
||||
renumber()
|
||||
- Dont stupidly assign the value of prev->lineno if prev == NULL!
|
||||
main()
|
||||
- Added code to check for Alt-Alt (27-27) keystrokes and set the
|
||||
next keystroke as a control sequence. New variable
|
||||
modify_control_key. Removed #ifdef _POSIX_VDISABLE check
|
||||
around Control-S,Q,Z handlers because we need it now for
|
||||
the Alt-Alt-x code.
|
||||
- Added --view option to getopt_long()call . Bug discovered
|
||||
by Rocco Corsi.
|
||||
help_init()
|
||||
- Fix off by one error that was making ^G help in normal mode and
|
||||
^_ in pico mode not be displayed in the help (bug discovered by
|
||||
Rocco Corsi).
|
||||
do_toggle()
|
||||
- Added fix_editbot() call to fix improper redisplay of edit
|
||||
window when using nohelp toggle (bug discovered by Rocco Corsi).
|
||||
- nano.1, nano.1.html:
|
||||
- Updated man page for -b, -e, -f and expanded explanation for -p.
|
||||
- winio.c
|
||||
do_help()
|
||||
- Force keypad on so F-keys and PageUp/Down will work properly.
|
||||
Added check for NANO_EXIT_FKEY to loop.
|
||||
- utils.c:
|
||||
new_magicline()
|
||||
- Increment totsize!! We decrement it when we've read a file,
|
||||
everywhere else it should automatically be incremented
|
||||
|
||||
nano 0.9.23 - 12/08/2000
|
||||
General
|
||||
- Changed --disable-spell to --disable speller. The term is
|
||||
|
||||
20
NEWS
20
NEWS
@@ -1,3 +1,23 @@
|
||||
01/07/2001 - Nano 0.9.25 is the "Just one more feature I swear!" release.
|
||||
It includes one new feature that Pico has had forever, a
|
||||
built-in file browser. Since not everyone may want this
|
||||
option, there is a --disable-browser option to the
|
||||
configure script as well. Other changes include slightly
|
||||
different keypad handling, and a bugfix for crashes when
|
||||
tab completion in certain instances. Have fun and Happy
|
||||
New Year!
|
||||
|
||||
12/18/2000 - Nano 0.9.24 is released. This versions contains the last of
|
||||
the security fixes for writing files, as well as for a
|
||||
nasty segfault when nano is unable to open a file for
|
||||
reading, among other fixes. Nano also now cowardly
|
||||
refuses to open device files, to stop silly things like
|
||||
trying to open /dev/zero. New features include being
|
||||
Able to use Meta-Meta-<key> as Control-<key>, better
|
||||
HURD support, and some new flags have been added for Pico
|
||||
compatibility. Upgrading to this version is highly
|
||||
recommended.
|
||||
|
||||
12/08/2000 - Nano 0.9.23 is the "race conditions bite" release. The
|
||||
main reason for this release is the less-than-optimal
|
||||
fix for the security issue in nano with following symbolic
|
||||
|
||||
32
README
32
README
@@ -1,26 +1,18 @@
|
||||
|
||||
The nano editor (Nano's ANOther editor) by Chris Allegretta
|
||||
nano - a GPLed, enhanced clone of the Pico text editor.
|
||||
|
||||
Manifesto
|
||||
Overview
|
||||
|
||||
The nano project was started because of a few "problems" with the
|
||||
wonderfully easy-to-use and friendly Pico text editor.
|
||||
|
||||
First and foremost is its license: the Pine suite does not use the
|
||||
GPL or a GPL-friendly license, and has unclear restrictions on
|
||||
redistribution. Because of this, Pine and Pico are not included with
|
||||
many GNU/Linux distributions. Also, other features (like goto line
|
||||
number or search and replace) were unavailable until recently or
|
||||
require a command-line flag. Yuck.
|
||||
|
||||
Nano is the editor formerly known as TIP (TIP Isn't Pico).
|
||||
The nano project was started because of three main problems with the
|
||||
wonderfully easy-to-use and friendly Pico text editor:
|
||||
|
||||
- It's license is not the GNU GPL, and hence some Linux
|
||||
distributions, including Debian (my favorite) don't always
|
||||
include it/don't include binaries. This is not necessarily a
|
||||
problem, but an issue nonetheless.
|
||||
|
||||
- Until recently, it had no ability to go to a line # from within
|
||||
the editor. There was the +number command line option, but who wants
|
||||
to exit a file to go to a specific line number? When I want to go to
|
||||
a line, since I have to exit anyway, I just call up vi temporarily.
|
||||
|
||||
- No search and replace feature. Well, apparently there is a flag
|
||||
that lets you do a search and replace (-b in newer versions) but,
|
||||
well, I still dont like it.
|
||||
|
||||
nano aims to solve these problems by emulating the functionality of
|
||||
Pico as closely as possible while adressing the problems above and
|
||||
perhaps providing other extra functionality.
|
||||
|
||||
3
TODO
3
TODO
@@ -20,8 +20,9 @@ Current Version:
|
||||
|
||||
For Next Version:
|
||||
- Undo/Redo key?
|
||||
- single line scroll up/down?
|
||||
- Single line scroll up/down?
|
||||
- Color syntax highlighting? (certainly seems like there's a demand for it.)
|
||||
- .nanorc ?????
|
||||
- Backup making (filename~)?
|
||||
|
||||
$Id$
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
/* Define this if you have the wresize function in your ncurses-type library */
|
||||
#undef HAVE_WRESIZE
|
||||
|
||||
/* Define this if your curses lib has the _use_keypad flag */
|
||||
#undef HAVE_USEKEYPAD
|
||||
|
||||
/* Define this if you have NLS */
|
||||
#undef ENABLE_NLS
|
||||
|
||||
@@ -36,4 +39,8 @@
|
||||
/* Define this to disable the use(full|less) spelling functions */
|
||||
#undef DISABLE_SPELLER
|
||||
|
||||
/* Define this to disable the ^G help menu */
|
||||
#undef DISABLE_HELP
|
||||
|
||||
/* Define this to disable the built-in (crappy) file browser */
|
||||
#undef DISABLE_BROWSER
|
||||
|
||||
@@ -55,6 +55,9 @@
|
||||
/* Define this if you have the wresize function in your ncurses-type library */
|
||||
#undef HAVE_WRESIZE
|
||||
|
||||
/* Define this if your curses lib has the _use_keypad flag */
|
||||
#undef HAVE_USEKEYPAD
|
||||
|
||||
/* Define this if you have NLS */
|
||||
#undef ENABLE_NLS
|
||||
|
||||
@@ -88,6 +91,12 @@
|
||||
/* Define this to disable the use(full|less) spelling functions */
|
||||
#undef DISABLE_SPELLER
|
||||
|
||||
/* Define this to disable the ^G help menu */
|
||||
#undef DISABLE_HELP
|
||||
|
||||
/* Define this to disable the built-in (crappy) file browser */
|
||||
#undef DISABLE_BROWSER
|
||||
|
||||
/* Define if you have the __argz_count function. */
|
||||
#undef HAVE___ARGZ_COUNT
|
||||
|
||||
|
||||
28
configure.in
28
configure.in
@@ -1,7 +1,7 @@
|
||||
# $Id$
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(nano.c)
|
||||
AM_INIT_AUTOMAKE(nano, 0.9.23)
|
||||
AM_INIT_AUTOMAKE(nano, 0.9.25)
|
||||
AM_CONFIG_HEADER(config.h:config.h.in)
|
||||
ALL_LINGUAS="es de fr it id fi"
|
||||
|
||||
@@ -45,6 +45,18 @@ AC_ARG_ENABLE(speller,
|
||||
AC_DEFINE(DISABLE_SPELLER)
|
||||
fi])
|
||||
|
||||
AC_ARG_ENABLE(help,
|
||||
[ --disable-help Disables help function (^G)],
|
||||
[if test x$enableval != xyes; then
|
||||
AC_DEFINE(DISABLE_HELP)
|
||||
fi])
|
||||
|
||||
AC_ARG_ENABLE(browser,
|
||||
[ --disable-browser Disables mini file browser],
|
||||
[if test x$enableval != xyes; then
|
||||
AC_DEFINE(DISABLE_BROWSER)
|
||||
fi])
|
||||
|
||||
AC_MSG_CHECKING(whether to use slang)
|
||||
CURSES_LIB_NAME=""
|
||||
AC_ARG_WITH(slang,
|
||||
@@ -196,6 +208,20 @@ fi
|
||||
|
||||
AC_CHECK_LIB($CURSES_LIB_NAME, wresize, AC_DEFINE(HAVE_WRESIZE))
|
||||
|
||||
# Taken from aumix (can't tell form the variable name?)
|
||||
AC_CACHE_CHECK(for private member _use_keypad in WINDOW,
|
||||
aumix_cv_struct_window_usekeypad,
|
||||
[AC_TRY_COMPILE([#ifdef HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif], [WINDOW w; w._use_keypad;],
|
||||
aumix_cv_struct_window_usekeypad=yes, aumix_cv_struct_window_usekeypad=no)])
|
||||
|
||||
if test $aumix_cv_struct_window_usekeypad = yes; then
|
||||
AC_DEFINE(HAVE_USEKEYPAD)
|
||||
fi
|
||||
|
||||
dnl Parse any configure options
|
||||
|
||||
LIBS="$LIBS $CURSES_LIB"
|
||||
|
||||
12
cut.c
12
cut.c
@@ -274,6 +274,7 @@ int do_uncut_text(void)
|
||||
filestruct *tmp = current, *fileptr = current, *newbuf, *newend;
|
||||
#ifndef NANO_SMALL
|
||||
char *tmpstr, *tmpstr2;
|
||||
filestruct *hold = current;
|
||||
#endif
|
||||
int i;
|
||||
|
||||
@@ -339,8 +340,13 @@ int do_uncut_text(void)
|
||||
|
||||
if (tmp != NULL)
|
||||
tmp->prev = newend;
|
||||
else
|
||||
else {
|
||||
/* Fix the editbot pointer too */
|
||||
if (editbot == filebot)
|
||||
editbot = newend;
|
||||
filebot = newend;
|
||||
new_magicline();
|
||||
}
|
||||
|
||||
/* Now why don't we update the totsize also */
|
||||
for (tmp = current->next; tmp != newend; tmp = tmp->next)
|
||||
@@ -368,7 +374,9 @@ int do_uncut_text(void)
|
||||
current_x = 0;
|
||||
placewewant = 0;
|
||||
}
|
||||
renumber(current->prev);
|
||||
/* Renumber from BEFORE where we pasted ;) */
|
||||
renumber(hold);
|
||||
|
||||
dump_buffer(fileage);
|
||||
dump_buffer(cutbuffer);
|
||||
set_modified();
|
||||
|
||||
12
faq.html
12
faq.html
@@ -21,7 +21,7 @@
|
||||
nano?</a></font>
|
||||
<br><font color="#330000"><a href="#1.5">1.5. Why the name change from
|
||||
TIP?</a></font>
|
||||
<br><font color="#330000"><a href="#1.6">1.6 What is the current version
|
||||
<br><font color="#330000"><a href="#1.6">1.6. What is the current version
|
||||
of nano?</a></font>
|
||||
<br><font color="#330000"><a href="#1.7">1.7. I want to read the man page
|
||||
without having to download the program!</a></font></blockquote>
|
||||
@@ -189,7 +189,7 @@ nano was developed).</font></blockquote>
|
||||
of nano?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">The current version of nano *should*
|
||||
be 0.9.23. Of course you should always check the nano hompage to
|
||||
be 0.9.25. Of course you should always check the nano hompage to
|
||||
see what the latest and greatest version is.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -294,7 +294,7 @@ DEB package?</font></h2>
|
||||
<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 programs,
|
||||
is the release of nano. There are other programs to install packages,
|
||||
and if you wish to use those, knock yourself out.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -368,8 +368,8 @@ to <a href="mailto:nano@nano-editor.org">nano@nano-editor.org</a>.</font></block
|
||||
my window. How can I fix that?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">Older versions of nano had this problem,
|
||||
please upgrade to a newer version (at least 0.9.9 would be great, 0.9.
|
||||
12 is recommended).</font></blockquote>
|
||||
please upgrade to a newer version (at least 0.9.9 would be great, 0.9.12
|
||||
is recommended).</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="4.4"></a><font color="#330000">4.4. Why does nano show ^\ and
|
||||
@@ -526,7 +526,7 @@ any changes in the past few years in a positive direction.</font></blockquote>
|
||||
<blockquote><font color="#330000">There are two mailing lists for nano
|
||||
hosted at <a href="http://www.sourceforge.net">SourceForge</a>, nano-announce
|
||||
and nano-devel. Nano-announce is a very low traffic list where new
|
||||
versions of nano are announced (surprise!) Nano-devel is a sometimes
|
||||
versions of nano are announced (surprise!) Nano-devel is a normally
|
||||
low, sometimes very high traffic list for dicussing the present and future
|
||||
development of nano. Here are links to where you can sign up for
|
||||
a given list:</font><font color="#330000"></font>
|
||||
|
||||
490
files.c
490
files.c
@@ -194,6 +194,7 @@ int read_file(int fd, char *filename)
|
||||
} else if (fileptr->next == NULL) {
|
||||
filebot = fileptr;
|
||||
new_magicline();
|
||||
totsize--;
|
||||
|
||||
/* Update the edit buffer */
|
||||
load_file();
|
||||
@@ -226,10 +227,18 @@ int open_file(char *filename, int insert, int quiet)
|
||||
} else if ((fd = open(filename, O_RDONLY)) == -1) {
|
||||
if (!quiet)
|
||||
statusbar("%s: %s", strerror(errno), filename);
|
||||
if (!insert)
|
||||
new_file();
|
||||
return -1;
|
||||
} else { /* File is A-OK */
|
||||
if (S_ISDIR(fileinfo.st_mode)) {
|
||||
statusbar(_("File \"%s\" is a directory"), filename);
|
||||
if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
|
||||
S_ISBLK(fileinfo.st_mode)) {
|
||||
if (S_ISDIR(fileinfo.st_mode))
|
||||
statusbar(_("File \"%s\" is a directory"), filename);
|
||||
else
|
||||
/* Don't open character or block files. Sorry, /dev/sndstat! */
|
||||
statusbar(_("File \"%s\" is a device file"), filename);
|
||||
|
||||
if (!insert)
|
||||
new_file();
|
||||
return -1;
|
||||
@@ -262,6 +271,21 @@ int do_insertfile(void)
|
||||
realname = mallocstrcpy(realname, answer);
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
|
||||
if (i == NANO_TOFILES_KEY) {
|
||||
|
||||
char *tmp = do_browse_from(realname);
|
||||
|
||||
#ifdef DISABLE_TABCOMP
|
||||
realname = NULL;
|
||||
#endif
|
||||
if (tmp != NULL)
|
||||
realname = mallocstrcpy(realname, tmp);
|
||||
else
|
||||
return do_insertfile();
|
||||
}
|
||||
#endif
|
||||
|
||||
i = open_file(realname, 1, 0);
|
||||
free(realname);
|
||||
|
||||
@@ -299,22 +323,25 @@ int do_insertfile(void)
|
||||
int write_file(char *name, int tmp)
|
||||
{
|
||||
long size, lineswritten = 0;
|
||||
char buf[PATH_MAX + 1];
|
||||
static char *buf = NULL;
|
||||
filestruct *fileptr;
|
||||
int fd, mask = 0, realexists, anyexists;
|
||||
struct stat st, lst, st2;
|
||||
struct stat st, lst;
|
||||
static char *realname = NULL;
|
||||
|
||||
if (!strcmp(name, "")) {
|
||||
statusbar(_("Cancelled"));
|
||||
return -1;
|
||||
}
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
fileptr = fileage;
|
||||
|
||||
if (realname != NULL)
|
||||
free(realname);
|
||||
|
||||
if (buf != NULL)
|
||||
free(buf);
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
realname = real_dir_from_tilde(name);
|
||||
#else
|
||||
@@ -331,25 +358,23 @@ int write_file(char *name, int tmp)
|
||||
if (tmp && anyexists != -1)
|
||||
return -1;
|
||||
/* NOTE: If you change this statement, you MUST CHANGE the if
|
||||
statement below (that starts "if ((!ISSET(FOLLOW_SYMLINKS)...")
|
||||
statement below (that says:
|
||||
if (realexists == -1 || tmp || (!ISSET(FOLLOW_SYMLINKS) &&
|
||||
S_ISLNK(lst.st_mode))) {
|
||||
to reflect whether or not to link/unlink/rename the file */
|
||||
else if (ISSET(FOLLOW_SYMLINKS) || !S_ISLNK(lst.st_mode) || tmp) {
|
||||
|
||||
/* Use O_EXCL if tmp == 1, I suppose */
|
||||
/* Use O_EXCL if tmp == 1. This is now copied from joe, because
|
||||
wiggy says so *shrug*. */
|
||||
if (tmp)
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
|
||||
S_IWOTH);
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_EXCL, (S_IRUSR|S_IWUSR));
|
||||
else
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
|
||||
S_IWOTH);
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC, (S_IRUSR|S_IWUSR));
|
||||
|
||||
/* First, just give up if we couldn't even open the file */
|
||||
if (fd == -1) {
|
||||
if (!tmp && ISSET(TEMP_OPT)) {
|
||||
UNSET(TEMP_OPT);
|
||||
return do_writeout(1);
|
||||
return do_writeout(filename, 1);
|
||||
}
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
@@ -357,29 +382,16 @@ int write_file(char *name, int tmp)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Now we fstat() the file, to make sure it's the same file still!
|
||||
Thanks to Oliver Friedrichs(?) for this code from securityfocus */
|
||||
|
||||
if (fstat(fd, &st2) != 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
/* Don't follow symlink. Create new file. */
|
||||
else {
|
||||
if (strlen(realname) > (PATH_MAX - 7)) {
|
||||
statusbar(_("Could not open file: Path length exceeded."));
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(buf, 0x00, PATH_MAX + 1);
|
||||
strcat(buf, realname);
|
||||
buf = nmalloc(strlen(realname) + 8);
|
||||
strncpy(buf, realname, strlen(realname)+1);
|
||||
strcat(buf, ".XXXXXX");
|
||||
if ((fd = mkstemp(buf)) == -1) {
|
||||
if (ISSET(TEMP_OPT)) {
|
||||
UNSET(TEMP_OPT);
|
||||
return do_writeout(1);
|
||||
return do_writeout(filename, 1);
|
||||
}
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
@@ -475,22 +487,23 @@ int write_file(char *name, int tmp)
|
||||
mask, realname, strerror(errno));
|
||||
|
||||
if (!tmp) {
|
||||
strncpy(filename, realname, 132);
|
||||
filename = mallocstrcpy(filename, realname);
|
||||
statusbar(_("Wrote %d lines"), lineswritten);
|
||||
UNSET(MODIFIED);
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_writeout(int exiting)
|
||||
int do_writeout(char *path, int exiting)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
static int did_cred = 0;
|
||||
#endif
|
||||
|
||||
answer = mallocstrcpy(answer, filename);
|
||||
answer = mallocstrcpy(answer, path);
|
||||
|
||||
if ((exiting) && (ISSET(TEMP_OPT))) {
|
||||
if (filename[0]) {
|
||||
@@ -512,6 +525,18 @@ int do_writeout(int exiting)
|
||||
|
||||
if (i != -1) {
|
||||
|
||||
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
|
||||
if (i == NANO_TOFILES_KEY) {
|
||||
|
||||
char *tmp = do_browse_from(answer);
|
||||
|
||||
if (tmp != NULL)
|
||||
answer = mallocstrcpy(answer, tmp);
|
||||
else
|
||||
return do_writeout(answer, exiting);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("filename is %s"), answer);
|
||||
#endif
|
||||
@@ -547,7 +572,7 @@ int do_writeout(int exiting)
|
||||
|
||||
int do_writeout_void(void)
|
||||
{
|
||||
return do_writeout(0);
|
||||
return do_writeout(filename, 0);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
@@ -691,8 +716,8 @@ char **username_tab_completion(char *buf, int *num_matches)
|
||||
homedirs = (char **) NULL;
|
||||
*num_matches = 0;
|
||||
}
|
||||
matches = nmalloc(BUFSIZ);
|
||||
homedirs = nmalloc(BUFSIZ);
|
||||
matches = nmalloc(BUFSIZ * sizeof(char *));
|
||||
homedirs = nmalloc(BUFSIZ * sizeof(char *));
|
||||
strcat(buf, "*");
|
||||
do {
|
||||
i = 0;
|
||||
@@ -760,7 +785,7 @@ char **cwd_tab_completion(char *buf, int *num_matches)
|
||||
DIR *dir;
|
||||
struct dirent *next;
|
||||
|
||||
matches = nmalloc(BUFSIZ);
|
||||
matches = nmalloc(BUFSIZ * sizeof(char *));
|
||||
|
||||
/* Stick a wildcard onto the buf, for later use */
|
||||
strcat(buf, "*");
|
||||
@@ -810,11 +835,6 @@ char **cwd_tab_completion(char *buf, int *num_matches)
|
||||
}
|
||||
while ((next = readdir(dir)) != NULL) {
|
||||
|
||||
/* Some quick sanity checks */
|
||||
if ((strcmp(next->d_name, "..") == 0)
|
||||
|| (strcmp(next->d_name, ".") == 0)) {
|
||||
continue;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Comparing \'%s\'\n", next->d_name);
|
||||
#endif
|
||||
@@ -1032,3 +1052,385 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
|
||||
|
||||
/* Return the stat of the file pointed to by path */
|
||||
struct stat filestat(const char *path) {
|
||||
struct stat st;
|
||||
|
||||
lstat(path, &st);
|
||||
return st;
|
||||
}
|
||||
|
||||
/* Our sort routine for file listings - sort directories before
|
||||
* files, and then alphabetically
|
||||
*/
|
||||
int diralphasort(const void *va, const void *vb) {
|
||||
struct stat file1info, file2info;
|
||||
char *a = *(char **)va, *b = *(char **)vb;
|
||||
int answer = 0;
|
||||
|
||||
if (stat(a, &file1info) == -1)
|
||||
answer = 1;
|
||||
else if (stat(b, &file2info) == -1)
|
||||
answer = 1;
|
||||
else {
|
||||
/* If is a is a dir and b isn't, return -1.
|
||||
Else if b is a dir and a isn't, return 0.
|
||||
Else return a < b */
|
||||
|
||||
if (S_ISDIR(file1info.st_mode) && !S_ISDIR(file2info.st_mode))
|
||||
return -1;
|
||||
else if (!S_ISDIR(file1info.st_mode) && S_ISDIR(file2info.st_mode))
|
||||
return 1;
|
||||
else
|
||||
answer = strcmp(a, b);
|
||||
}
|
||||
|
||||
return(answer);
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the browser code, including the list of files in *path */
|
||||
char **browser_init(char *path, int *longest, int *numents)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *next;
|
||||
char **filelist = (char **) NULL;
|
||||
int i = 0;
|
||||
|
||||
dir = opendir(path);
|
||||
if (!dir)
|
||||
return NULL;
|
||||
|
||||
*numents = 0;
|
||||
while ((next = readdir(dir)) != NULL) {
|
||||
if (!strcmp(next->d_name, "."))
|
||||
continue;
|
||||
(*numents)++;
|
||||
if (strlen(next->d_name) > *longest)
|
||||
*longest = strlen(next->d_name);
|
||||
}
|
||||
rewinddir(dir);
|
||||
*longest += 10;
|
||||
|
||||
filelist = nmalloc(*numents * sizeof (char *));
|
||||
|
||||
while ((next = readdir(dir)) != NULL) {
|
||||
if (!strcmp(next->d_name, "."))
|
||||
continue;
|
||||
filelist[i] = nmalloc(strlen(next->d_name) + strlen(path) + 2);
|
||||
|
||||
if (!strcmp(path, "/"))
|
||||
snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 1,
|
||||
"%s%s", path, next->d_name);
|
||||
else
|
||||
snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 2,
|
||||
"%s/%s", path, next->d_name);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (*longest > COLS - 1)
|
||||
*longest = COLS - 1;
|
||||
|
||||
return filelist;
|
||||
}
|
||||
|
||||
/* Free our malloced memory */
|
||||
void free_charptrarray(char **array, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len - 1; i++)
|
||||
free(array[i]);
|
||||
free(array);
|
||||
}
|
||||
|
||||
/* only print the last part of a path, isn't there a shell
|
||||
command for this? */
|
||||
char *tail(char *foo)
|
||||
{
|
||||
char *tmp = NULL;
|
||||
|
||||
tmp = foo + strlen(foo);
|
||||
while (*tmp != '/' && tmp != foo)
|
||||
tmp--;
|
||||
|
||||
tmp++;
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* Strip one dir from the end of a string */
|
||||
void striponedir(char *foo)
|
||||
{
|
||||
char *tmp = NULL;
|
||||
|
||||
/* Don't strip the root dir */
|
||||
if (!strcmp(foo, "/"))
|
||||
return;
|
||||
|
||||
tmp = foo + strlen(foo);
|
||||
if (*tmp == '/')
|
||||
tmp--;
|
||||
|
||||
while (*tmp != '/' && tmp != foo)
|
||||
tmp--;
|
||||
|
||||
if (tmp != foo)
|
||||
*tmp = 0;
|
||||
else
|
||||
*(tmp+1) = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Our browser function. inpath is the path to start browsing from */
|
||||
char *do_browser(char *inpath)
|
||||
{
|
||||
struct stat st;
|
||||
char *foo, *retval = NULL;
|
||||
static char *path = NULL;
|
||||
int numents = 0, i = 0, j = 0, kbinput = 0, longest = 0, abort = 0;
|
||||
int col = 0, selected = 0, editline = 0, width = 0, filecols = 0;
|
||||
int lineno = 0, kb;
|
||||
char **filelist = (char **) NULL;
|
||||
|
||||
/* If path isn't the same as inpath, we are being passed a new
|
||||
dir as an arg. We free it here so it will be copied from
|
||||
inpath below */
|
||||
if (path != NULL && strcmp(path, inpath)) {
|
||||
free(path);
|
||||
path = NULL;
|
||||
}
|
||||
|
||||
/* if path doesn't exist, make it so */
|
||||
if (path == NULL)
|
||||
path = mallocstrcpy(path, inpath);
|
||||
|
||||
filelist = browser_init(path, &longest, &numents);
|
||||
foo = nmalloc(longest + 8);
|
||||
|
||||
/* Sort the list by directory first then alphabetically */
|
||||
qsort(filelist, numents, sizeof(char *), diralphasort);
|
||||
|
||||
kb = keypad_on(edit, 1);
|
||||
titlebar(path);
|
||||
bottombars(browser_list, BROWSER_LIST_LEN);
|
||||
curs_set(0);
|
||||
wmove(edit, 0, 0);
|
||||
i = 0;
|
||||
width = 0;
|
||||
filecols = 0;
|
||||
|
||||
/* Loop invariant: Microsoft sucks. */
|
||||
do {
|
||||
blank_edit();
|
||||
blank_statusbar();
|
||||
editline = 0;
|
||||
col = 0;
|
||||
|
||||
/* Compute line number we're on now so we don't divide by zero later */
|
||||
if (width == 0)
|
||||
lineno = selected;
|
||||
else
|
||||
lineno = selected / width;
|
||||
|
||||
switch (kbinput) {
|
||||
case KEY_UP:
|
||||
case 'u':
|
||||
if (selected - width >= 0)
|
||||
selected -= width;
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
case 'l':
|
||||
if (selected > 0)
|
||||
selected--;
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
case 'd':
|
||||
if (selected + width <= numents - 1)
|
||||
selected += width;
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
case 'r':
|
||||
if (selected < numents - 1)
|
||||
selected++;
|
||||
break;
|
||||
case NANO_PREVPAGE_KEY:
|
||||
case NANO_PREVPAGE_FKEY:
|
||||
case KEY_PPAGE:
|
||||
|
||||
if (lineno % editwinrows == 0) {
|
||||
if (selected - (editwinrows * width) >= 0)
|
||||
selected -= editwinrows * width;
|
||||
else
|
||||
selected = 0;
|
||||
}
|
||||
else if (selected - (editwinrows +
|
||||
lineno % editwinrows) * width >= 0)
|
||||
|
||||
selected -= (editwinrows + lineno % editwinrows) * width;
|
||||
else
|
||||
selected = 0;
|
||||
break;
|
||||
case NANO_NEXTPAGE_KEY:
|
||||
case NANO_NEXTPAGE_FKEY:
|
||||
case KEY_NPAGE:
|
||||
if (lineno % editwinrows == 0) {
|
||||
if (selected + (editwinrows * width) <= numents - 1)
|
||||
selected += editwinrows * width;
|
||||
else
|
||||
selected = numents - 1;
|
||||
}
|
||||
else if (selected + (editwinrows -
|
||||
lineno % editwinrows) * width <= numents - 1)
|
||||
selected += (editwinrows - lineno % editwinrows) * width;
|
||||
else
|
||||
selected = numents - 1;
|
||||
break;
|
||||
case KEY_ENTER:
|
||||
case NANO_CONTROL_M:
|
||||
case 's': /* More Pico compatibility */
|
||||
case 'S':
|
||||
|
||||
/* You can't cd up from / */
|
||||
if (!strcmp(filelist[selected], "/..") && !strcmp(path, "/"))
|
||||
statusbar(_("Can't move up a directory"));
|
||||
else
|
||||
path = mallocstrcpy(path, filelist[selected]);
|
||||
|
||||
st = filestat(path);
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
if (opendir(path) == NULL) {
|
||||
/* We can't open this dir for some reason. Complain */
|
||||
statusbar(_("Can't open \"%s\": %s"), path, strerror(errno));
|
||||
striponedir(path);
|
||||
align(&path);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!strcmp("..", tail(path))) {
|
||||
/* They want to go up a level, so strip off .. and the
|
||||
current dir */
|
||||
striponedir(path);
|
||||
striponedir(path);
|
||||
align(&path);
|
||||
}
|
||||
|
||||
/* Start over again with the new path value */
|
||||
return do_browser(path);
|
||||
} else {
|
||||
retval = path;
|
||||
abort = 1;
|
||||
}
|
||||
break;
|
||||
/* Stuff we want to abort the browser */
|
||||
case 'q':
|
||||
case 'Q':
|
||||
case 'e': /* Pico compatibility, yeech */
|
||||
case 'E':
|
||||
case NANO_EXIT_FKEY:
|
||||
abort = 1;
|
||||
break;
|
||||
}
|
||||
if (abort)
|
||||
break;
|
||||
|
||||
if (width)
|
||||
i = width * editwinrows * ((selected / width) / editwinrows);
|
||||
else
|
||||
i = 0;
|
||||
|
||||
wmove(edit, 0, 0);
|
||||
for (j = i; j < numents && editline <= editwinrows - 1; j++) {
|
||||
filecols++;
|
||||
|
||||
strncpy(foo, tail(filelist[j]), strlen(tail(filelist[j])) + 1);
|
||||
while (strlen(foo) < longest)
|
||||
strcat(foo, " ");
|
||||
col += strlen(foo);
|
||||
|
||||
/* Put file info in the string also */
|
||||
st = filestat(filelist[j]);
|
||||
if (S_ISDIR(st.st_mode))
|
||||
strcpy(foo + longest - 5, "(dir)");
|
||||
else {
|
||||
if (S_ISLNK(st.st_mode))
|
||||
strcpy(foo + longest - 2, "--");
|
||||
else if (st.st_size < 1024) /* less than 1 K */
|
||||
sprintf(foo + longest - 7, "%4d B", (int) st.st_size);
|
||||
else if (st.st_size > 1073741824) /* at least 1 gig */
|
||||
sprintf(foo + longest - 7, "%4d GB", (int) st.st_size / 1073741824);
|
||||
else if (st.st_size > 1048576) /* at least 1 meg */
|
||||
sprintf(foo + longest - 7, "%4d MB", (int) st.st_size / 1048576);
|
||||
else /* Its more than 1 k and less than a meg */
|
||||
sprintf(foo + longest - 7, "%4d KB", (int) st.st_size / 1024);
|
||||
}
|
||||
|
||||
/* Hilight the currently selected file/dir */
|
||||
if (j == selected)
|
||||
wattron(edit, A_REVERSE);
|
||||
waddnstr(edit, foo, strlen(foo));
|
||||
if (j == selected)
|
||||
wattroff(edit, A_REVERSE);
|
||||
|
||||
/* And add some space between the cols */
|
||||
waddstr(edit, " ");
|
||||
col += 2;
|
||||
|
||||
/* And if the next entry isn't going to fit on the
|
||||
line, move to the next one */
|
||||
if (col > (COLS - longest)) {
|
||||
editline++;
|
||||
wmove(edit, editline, 0);
|
||||
col = 0;
|
||||
if (width == 0)
|
||||
width = filecols;
|
||||
}
|
||||
}
|
||||
wrefresh(edit);
|
||||
} while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY);
|
||||
curs_set(1);
|
||||
blank_edit();
|
||||
titlebar(NULL);
|
||||
edit_refresh();
|
||||
kb = keypad_on(edit, kb);
|
||||
|
||||
/* cleanup */
|
||||
free_charptrarray(filelist, numents);
|
||||
free(foo);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Browser fron't end, checks to see if inpath has a dir in it and if so
|
||||
starts do_browser from there, else from the current dir */
|
||||
char *do_browse_from(char *inpath)
|
||||
{
|
||||
struct stat st;
|
||||
char *tmp = NULL;
|
||||
|
||||
tmp = mallocstrcpy(tmp, inpath);
|
||||
|
||||
/* If there's no / in the string, we may was well start from . */
|
||||
if (tmp == NULL || !strstr(tmp, "/"))
|
||||
return do_browser(getcwd(NULL, 0));
|
||||
|
||||
/* If the string is a directory, pass do_browser that */
|
||||
st = filestat(tmp);
|
||||
if (S_ISDIR(st.st_mode))
|
||||
return do_browser(tmp);
|
||||
|
||||
/* Okay, there's a dir in there, but not at the end of the string...
|
||||
try stripping it off */
|
||||
striponedir(tmp);
|
||||
align(&tmp);
|
||||
return do_browser(tmp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
35
global.c
35
global.c
@@ -39,7 +39,7 @@ int center_x = 0, center_y = 0; /* Center of screen */
|
||||
WINDOW *edit; /* The file portion of the editor */
|
||||
WINDOW *topwin; /* Top line of screen */
|
||||
WINDOW *bottomwin; /* Bottom buffer */
|
||||
char filename[PATH_MAX]; /* Name of the file */
|
||||
char *filename = NULL; /* Name of the file */
|
||||
int editwinrows = 0; /* How many rows long is the edit
|
||||
window? */
|
||||
filestruct *current; /* Current buffer pointer */
|
||||
@@ -79,6 +79,10 @@ shortcut goto_list[GOTO_LIST_LEN];
|
||||
shortcut writefile_list[WRITEFILE_LIST_LEN];
|
||||
shortcut help_list[HELP_LIST_LEN];
|
||||
shortcut spell_list[SPELL_LIST_LEN];
|
||||
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
|
||||
shortcut browser_list[BROWSER_LIST_LEN];
|
||||
#endif
|
||||
|
||||
toggle toggles[TOGGLE_LEN];
|
||||
|
||||
/* Regular expressions */
|
||||
@@ -170,9 +174,11 @@ void shortcut_init(int unjustify)
|
||||
"", *nano_mark_msg = "", *nano_delete_msg =
|
||||
"", *nano_backspace_msg = "", *nano_tab_msg =
|
||||
"", *nano_enter_msg = "", *nano_case_msg =
|
||||
"", *nano_cancel_msg = "", *nano_unjustify_msg;
|
||||
"", *nano_cancel_msg = "", *nano_unjustify_msg = "";
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
char *nano_tofiles_msg = "";
|
||||
|
||||
nano_help_msg = _("Invoke the help menu");
|
||||
nano_writeout_msg = _("Write the current file to disk");
|
||||
nano_exit_msg = _("Exit from nano");
|
||||
@@ -205,6 +211,7 @@ void shortcut_init(int unjustify)
|
||||
nano_enter_msg = _("Insert a carriage return at the cursor position");
|
||||
nano_case_msg =
|
||||
_("Make the current search or replace case (in)sensitive");
|
||||
nano_tofiles_msg = _("Go to file browser");
|
||||
nano_cancel_msg = _("Cancel the current function");
|
||||
#endif
|
||||
|
||||
@@ -403,15 +410,31 @@ void shortcut_init(int unjustify)
|
||||
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
|
||||
|
||||
|
||||
sc_init_one(&writefile_list[0], NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
|
||||
sc_init_one(&writefile_list[0], NANO_TOFILES_KEY, _("To Files"),
|
||||
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
|
||||
sc_init_one(&writefile_list[0], NANO_CANCEL_KEY, _("Cancel"),
|
||||
sc_init_one(&writefile_list[WRITEFILE_LIST_LEN - 1], NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&spell_list[0], NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
|
||||
sc_init_one(&browser_list[0], NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
nano_prevpage_msg,
|
||||
0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, 0);
|
||||
|
||||
sc_init_one(&browser_list[1], NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
nano_nextpage_msg,
|
||||
0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, 0);
|
||||
|
||||
sc_init_one(&browser_list[2], NANO_EXIT_KEY, _("Exit"),
|
||||
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, 0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
toggle_init();
|
||||
}
|
||||
|
||||
7
move.c
7
move.c
@@ -55,7 +55,12 @@ int page_down(void)
|
||||
if (current == filebot)
|
||||
return 0;
|
||||
|
||||
if (editbot != filebot || edittop == fileage) {
|
||||
/* AHEM, if we only have a screen or less of text, DONT do an
|
||||
edit_update, just move the cursor to editbot! */
|
||||
if (edittop == fileage && editbot == filebot) {
|
||||
current = editbot;
|
||||
reset_cursor();
|
||||
} else if (editbot != filebot || edittop == fileage) {
|
||||
current_y = 0;
|
||||
current = editbot;
|
||||
|
||||
|
||||
7
nano.1
7
nano.1
@@ -64,7 +64,9 @@ a new file, do not follow it. Good for editing files in /tmp perhaps?
|
||||
Enable mouse support (if available for your system).
|
||||
.TP
|
||||
.B \-p (\-\-pico)
|
||||
Emulate Pico as closely as possible.
|
||||
Emulate Pico as closely as possible. This affects both the "shortcut list"
|
||||
at the bottom of the screen, as well as the display and entry of previous
|
||||
search and replace strings.
|
||||
.TP
|
||||
.B \-s (\-\-speller)
|
||||
Enable alternative spell checker command.
|
||||
@@ -84,6 +86,9 @@ Disable help screen at bottom of editor.
|
||||
.B \-z (\-\-suspend)
|
||||
Enable suspend ability.
|
||||
.TP
|
||||
.B \-b, \-e, \-f
|
||||
Ignored, for compatibility with Pico.
|
||||
.TP
|
||||
.B \+LINE
|
||||
Places cursor at LINE on startup.
|
||||
.SH NOTES
|
||||
|
||||
10
nano.1.html
10
nano.1.html
@@ -86,7 +86,9 @@ Enable mouse support (if available for your system).
|
||||
<DT><B>-p (--pico)</B>
|
||||
|
||||
<DD>
|
||||
Emulate Pico as closely as possible.
|
||||
Emulate Pico as closely as possible. This affects both the "shortcut list"
|
||||
at the bottom of the screen, as well as the display and entry of previous
|
||||
search and replace strings.
|
||||
<DT><B>-s (--speller)</B>
|
||||
|
||||
<DD>
|
||||
@@ -111,6 +113,10 @@ Disable help screen at bottom of editor.
|
||||
|
||||
<DD>
|
||||
Enable suspend ability.
|
||||
<DT><B>-b, -e, -f</B>
|
||||
|
||||
<DD>
|
||||
Ignored, for compatibility with Pico.
|
||||
<DT><B>+LINE</B>
|
||||
|
||||
<DD>
|
||||
@@ -171,6 +177,6 @@ used by others).
|
||||
This document was created by
|
||||
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
|
||||
using the manual pages.<BR>
|
||||
Time: 04:21:24 GMT, December 03, 2000
|
||||
Time: 02:16:52 GMT, December 18, 2000
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
149
nano.c
149
nano.c
@@ -64,33 +64,29 @@
|
||||
int fill = 0; /* Fill - where to wrap lines, basically */
|
||||
static char *alt_speller; /* Alternative spell command */
|
||||
struct termios oldterm; /* The user's original term settings */
|
||||
static char *help_text_init = "";
|
||||
/* Initial message, not including shortcuts */
|
||||
static struct sigaction act; /* For all out fun signal handlers */
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
static char *help_text_init = ""; /* Initial message, not including shortcuts */
|
||||
#endif
|
||||
|
||||
char *last_search = NULL; /* Last string we searched for */
|
||||
char *last_replace = NULL; /* Last replacement string */
|
||||
int search_last_line; /* Is this the last search line? */
|
||||
|
||||
void keypad_on(int yesno)
|
||||
{
|
||||
keypad(edit, yesno);
|
||||
keypad(bottomwin, yesno);
|
||||
}
|
||||
|
||||
/* What we do when we're all set to exit */
|
||||
RETSIGTYPE finish(int sigage)
|
||||
{
|
||||
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
|
||||
if (!ISSET(NO_HELP)) {
|
||||
mvwaddstr(bottomwin, 1, 0, hblank);
|
||||
mvwaddstr(bottomwin, 2, 0, hblank);
|
||||
} else
|
||||
mvwaddstr(bottomwin, 0, 0, hblank);
|
||||
|
||||
/* Apparently you REALLY can't get away with not calling keypad()
|
||||
or your window looks awful when it exits. so we just call it right
|
||||
before we exit, muhaha :-) */
|
||||
keypad_on(TRUE);
|
||||
wrefresh(bottomwin);
|
||||
endwin();
|
||||
|
||||
@@ -146,6 +142,13 @@ void print_view_warning(void)
|
||||
statusbar(_("Key illegal in VIEW mode"));
|
||||
}
|
||||
|
||||
void clear_filename(void)
|
||||
{
|
||||
if (filename != NULL)
|
||||
free(filename);
|
||||
filename = nmalloc(1);
|
||||
filename[0] = 0;
|
||||
}
|
||||
|
||||
/* Initialize global variables - no better way for now */
|
||||
void global_init(void)
|
||||
@@ -177,7 +180,7 @@ void global_init(void)
|
||||
void init_help_msg(void)
|
||||
{
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
|
||||
help_text_init =
|
||||
_(" nano help text\n\n "
|
||||
@@ -315,7 +318,10 @@ int renumber(filestruct * fileptr)
|
||||
return 0;
|
||||
}
|
||||
for (temp = fileptr; temp != NULL; temp = temp->next) {
|
||||
temp->lineno = temp->prev->lineno + 1;
|
||||
if (temp->prev != NULL)
|
||||
temp->lineno = temp->prev->lineno + 1;
|
||||
else
|
||||
temp->lineno = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -355,12 +361,12 @@ void usage(void)
|
||||
(" -c --const Constantly show cursor position\n"));
|
||||
printf(_
|
||||
(" -h --help Show this message\n"));
|
||||
printf(_
|
||||
(" -i --autoindent Automatically indent new lines\n"));
|
||||
#ifndef NANO_SMALL
|
||||
printf(_
|
||||
(" -k --cut Let ^K cut from cursor to end of line\n"));
|
||||
#endif
|
||||
printf(_
|
||||
(" -i --autoindent Automatically indent new lines\n"));
|
||||
printf(_
|
||||
(" -l --nofollow Don't follow symbolic links, overwrite\n"));
|
||||
#ifndef NANO_SMALL
|
||||
@@ -368,11 +374,11 @@ void usage(void)
|
||||
printf(_(" -m --mouse Enable mouse\n"));
|
||||
#endif
|
||||
#endif
|
||||
printf(_
|
||||
(" -p --pico Emulate Pico as closely as possible\n"));
|
||||
printf
|
||||
(_
|
||||
(" -r [#cols] --fill=[#cols] Set fill cols to (wrap lines at) #cols\n"));
|
||||
printf(_
|
||||
(" -p --pico Emulate Pico as closely as possible\n"));
|
||||
printf(_
|
||||
(" -s [prog] --speller=[prog] Enable alternate speller\n"));
|
||||
printf(_
|
||||
@@ -395,10 +401,10 @@ void usage(void)
|
||||
printf(_(" -V Print version information and exit\n"));
|
||||
printf(_(" -c Constantly show cursor position\n"));
|
||||
printf(_(" -h Show this message\n"));
|
||||
printf(_(" -i Automatically indent new lines\n"));
|
||||
#ifndef NANO_SMALL
|
||||
printf(_(" -k Let ^K cut from cursor to end of line\n"));
|
||||
#endif
|
||||
printf(_(" -i Automatically indent new lines\n"));
|
||||
printf(_
|
||||
(" -l Don't follow symbolic links, overwrite\n"));
|
||||
#ifndef NANO_SMALL
|
||||
@@ -406,10 +412,9 @@ void usage(void)
|
||||
printf(_(" -m Enable mouse\n"));
|
||||
#endif
|
||||
#endif
|
||||
printf(_
|
||||
(" -r [#cols] Set fill cols to (wrap lines at) #cols\n"));
|
||||
printf(_(" -s [prog] Enable alternate speller\n"));
|
||||
printf(_(" -p Emulate Pico as closely as possible\n"));
|
||||
printf(_(" -r [#cols] Set fill cols to (wrap lines at) #cols\n"));
|
||||
printf(_(" -s [prog] Enable alternate speller\n"));
|
||||
printf(_(" -t Auto save on exit, don't prompt\n"));
|
||||
printf(_(" -v View (read only) mode\n"));
|
||||
printf(_(" -w Don't wrap long lines\n"));
|
||||
@@ -434,6 +439,9 @@ void version(void)
|
||||
#ifdef NANO_EXTRA
|
||||
printf(" --enable-extra");
|
||||
#endif
|
||||
#ifdef DISABLE_BROWSER
|
||||
printf(" --disable-browser");
|
||||
#endif
|
||||
#ifdef DISABLE_TABCOMP
|
||||
printf(" --disable-tabcomp");
|
||||
#endif
|
||||
@@ -443,6 +451,9 @@ void version(void)
|
||||
#ifdef DISABLE_SPELLER
|
||||
printf(" --disable-speller");
|
||||
#endif
|
||||
#ifdef DISABLE_HELP
|
||||
printf(" --disable-help");
|
||||
#endif
|
||||
#ifdef USE_SLANG
|
||||
printf(" --with-slang");
|
||||
#endif
|
||||
@@ -514,7 +525,7 @@ void nano_small_msg(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER)
|
||||
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || defined(DISABLE_HELP)
|
||||
void nano_disabled_msg(void)
|
||||
{
|
||||
statusbar("Sorry, support for this function has been disabled");
|
||||
@@ -1030,7 +1041,6 @@ int do_backspace(void)
|
||||
if (strcmp(current->data, "")) {
|
||||
new_magicline();
|
||||
fix_editbot();
|
||||
totsize++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1411,7 +1421,7 @@ int do_exit(void)
|
||||
#endif
|
||||
|
||||
if (i == 1) {
|
||||
if (do_writeout(1) > 0)
|
||||
if (do_writeout(filename, 1) > 0)
|
||||
finish(0);
|
||||
} else if (i == 0)
|
||||
finish(0);
|
||||
@@ -1588,7 +1598,7 @@ void handle_sigwinch(int s)
|
||||
|
||||
/* Do these b/c width may have changed... */
|
||||
refresh();
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
edit_refresh();
|
||||
display_main_list();
|
||||
total_refresh();
|
||||
@@ -1633,6 +1643,14 @@ void window_init(void)
|
||||
/* And the other windows */
|
||||
topwin = newwin(2, COLS, 0, 0);
|
||||
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
|
||||
|
||||
#ifdef PDCURSES
|
||||
/* Oops, I guess we need this again.
|
||||
Moved here so the keypad still works after a Meta-X, for example */
|
||||
keypad(edit, TRUE);
|
||||
keypad(bottomwin, TRUE);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void mouse_init(void)
|
||||
@@ -1640,15 +1658,14 @@ void mouse_init(void)
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef NCURSES_MOUSE_VERSION
|
||||
if (ISSET(USE_MOUSE)) {
|
||||
keypad_on(TRUE);
|
||||
keypad_on(edit, 1);
|
||||
|
||||
mousemask(BUTTON1_RELEASED, NULL);
|
||||
mouseinterval(50);
|
||||
|
||||
} else {
|
||||
} else
|
||||
mousemask(0, NULL);
|
||||
keypad_on(FALSE);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1898,16 +1915,16 @@ int do_justify(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
void help_init(void)
|
||||
{
|
||||
int i, sofar = 0;
|
||||
long allocsize = 1; /* How much space we're gonna need for the help text */
|
||||
char buf[BUFSIZ];
|
||||
char buf[BUFSIZ] = "";
|
||||
|
||||
/* Compute the space needed for the shortcut lists - we add 15 to
|
||||
have room for the shortcut abbrev and its possible alternate keys */
|
||||
for (i = 0; i < MAIN_LIST_LEN; i++)
|
||||
for (i = 0; i <= MAIN_LIST_LEN - 1; i++)
|
||||
if (main_list[i].help != NULL)
|
||||
allocsize += strlen(main_list[i].help) + 15;
|
||||
|
||||
@@ -1928,7 +1945,7 @@ void help_init(void)
|
||||
strcpy(help_text, help_text_init);
|
||||
|
||||
/* Now add our shortcut info */
|
||||
for (i = 0; i < MAIN_LIST_LEN - 1; i++) {
|
||||
for (i = 0; i <= MAIN_LIST_LEN - 1; i++) {
|
||||
sofar = snprintf(buf, BUFSIZ, "^%c ", main_list[i].val + 64);
|
||||
|
||||
if (main_list[i].misc1 > KEY_F0 && main_list[i].misc1 <= KEY_F(64))
|
||||
@@ -1966,6 +1983,7 @@ void help_init(void)
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void do_toggle(int which)
|
||||
{
|
||||
@@ -1993,6 +2011,7 @@ void do_toggle(int which)
|
||||
wclear(bottomwin);
|
||||
wrefresh(bottomwin);
|
||||
window_init();
|
||||
fix_editbot();
|
||||
edit_refresh();
|
||||
display_main_list();
|
||||
break;
|
||||
@@ -2024,7 +2043,7 @@ int main(int argc, char *argv[])
|
||||
int kbinput; /* Input from keyboard */
|
||||
long startline = 0; /* Line to try and start at */
|
||||
int keyhandled = 0; /* Have we handled the keystroke yet? */
|
||||
int i;
|
||||
int i, modify_control_seq = 0;
|
||||
char *argv0;
|
||||
#ifdef _POSIX_VDISABLE
|
||||
struct termios term;
|
||||
@@ -2042,6 +2061,7 @@ int main(int argc, char *argv[])
|
||||
{"nowrap", 0, 0, 'w'},
|
||||
{"nohelp", 0, 0, 'x'},
|
||||
{"help", 0, 0, 'h'},
|
||||
{"view", 0, 0, 'v'},
|
||||
#ifndef NANO_SMALL
|
||||
{"cut", 0, 0, 'k'},
|
||||
#endif
|
||||
@@ -2067,10 +2087,10 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
while ((optchr = getopt_long(argc, argv, "?T:RVchiklmpr:s:tvwxz",
|
||||
while ((optchr = getopt_long(argc, argv, "?T:RVbcefhiklmpr:s:tvwxz",
|
||||
long_options, &option_index)) != EOF) {
|
||||
#else
|
||||
while ((optchr = getopt(argc, argv, "h?T:RVciklmpr:s:tvwxz")) != EOF) {
|
||||
while ((optchr = getopt(argc, argv, "h?T:RVbcefiklmpr:s:tvwxz")) != EOF) {
|
||||
#endif
|
||||
|
||||
switch (optchr) {
|
||||
@@ -2089,6 +2109,11 @@ int main(int argc, char *argv[])
|
||||
case 'V':
|
||||
version();
|
||||
exit(0);
|
||||
case 'b':
|
||||
case 'e':
|
||||
case 'f':
|
||||
/* Pico compatibility flags */
|
||||
break;
|
||||
case 'c':
|
||||
SET(CONSTUPDATE);
|
||||
break;
|
||||
@@ -2158,19 +2183,19 @@ int main(int argc, char *argv[])
|
||||
/* See if there's a non-option in argv (first non-option is the
|
||||
filename, if +LINE is not given) */
|
||||
if (argc == 1 || argc <= optind)
|
||||
strcpy(filename, "");
|
||||
clear_filename();
|
||||
else {
|
||||
/* Look for the +line flag... */
|
||||
if (argv[optind][0] == '+') {
|
||||
startline = atoi(&argv[optind][1]);
|
||||
optind++;
|
||||
if (argc == 1 || argc <= optind)
|
||||
strcpy(filename, "");
|
||||
clear_filename();
|
||||
else
|
||||
strncpy(filename, argv[optind], 132);
|
||||
} else
|
||||
strncpy(filename, argv[optind], 132);
|
||||
filename = mallocstrcpy(filename, argv[optind]);
|
||||
|
||||
} else
|
||||
filename = mallocstrcpy(filename, argv[optind]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2191,13 +2216,14 @@ int main(int argc, char *argv[])
|
||||
nonl();
|
||||
cbreak();
|
||||
noecho();
|
||||
timeout(0);
|
||||
|
||||
/* Set up some global variables */
|
||||
global_init();
|
||||
shortcut_init(0);
|
||||
init_help_msg();
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
help_init();
|
||||
#endif
|
||||
signal_init();
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -2207,12 +2233,6 @@ int main(int argc, char *argv[])
|
||||
window_init();
|
||||
mouse_init();
|
||||
|
||||
#ifdef PDCURSES
|
||||
/* Must have this for the arrow, et al, keys to even work in
|
||||
PDCurses+cygwin under Windows */
|
||||
keypad_on(TRUE);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("Main: bottom win\n"));
|
||||
#endif
|
||||
@@ -2223,7 +2243,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, _("Main: open file\n"));
|
||||
#endif
|
||||
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
|
||||
/* Now we check to see if argv[optind] is non-null to determine if
|
||||
we're dealing with a new file or not, not argc == 1... */
|
||||
@@ -2248,6 +2268,9 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
kbinput = wgetch(edit);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput);
|
||||
#endif
|
||||
if (kbinput == 27) { /* Grab Alt-key stuff first */
|
||||
switch (kbinput = wgetch(edit)) {
|
||||
/* Alt-O, suddenly very important ;) */
|
||||
@@ -2263,6 +2286,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 27:
|
||||
/* If we get Alt-Alt, the next keystroke should be the same as a
|
||||
control sequence */
|
||||
modify_control_seq = 1;
|
||||
keyhandled = 1;
|
||||
break;
|
||||
case 91:
|
||||
|
||||
switch (kbinput = wgetch(edit)) {
|
||||
@@ -2392,6 +2421,18 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* If the modify_control_seq is set, we received an Alt-Alt
|
||||
sequence before this, so we make this key a control sequence
|
||||
by subtracting 64 or 96, depending on its value. */
|
||||
if (!keyhandled && modify_control_seq) {
|
||||
if (kbinput >= 'A' && kbinput < 'a')
|
||||
kbinput -= 64;
|
||||
else if (kbinput >= 'a' && kbinput <= 'z')
|
||||
kbinput -= 96;
|
||||
|
||||
modify_control_seq = 0;
|
||||
}
|
||||
|
||||
/* Look through the main shortcut list to see if we've hit a
|
||||
shortcut key */
|
||||
for (i = 0; i < MAIN_LIST_LEN && !keyhandled; i++) {
|
||||
@@ -2405,18 +2446,17 @@ int main(int argc, char *argv[])
|
||||
keyhandled = 1;
|
||||
}
|
||||
}
|
||||
#ifndef _POSIX_VDISABLE
|
||||
/* Since we're in raw mode, we have to catch ^Q and ^S */
|
||||
/* If we're in raw mode or using Alt-Alt-x, we have to catch
|
||||
Control-S and Control-Q */
|
||||
if (kbinput == 17 || kbinput == 19)
|
||||
keyhandled = 1;
|
||||
|
||||
/* And catch ^Z by hand when triggered */
|
||||
/* Catch ^Z by hand when triggered also */
|
||||
if (kbinput == 26) {
|
||||
if (ISSET(SUSPEND))
|
||||
do_suspend(0);
|
||||
keyhandled = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Last gasp, stuff that's not in the main lists */
|
||||
if (!keyhandled)
|
||||
@@ -2431,6 +2471,7 @@ int main(int argc, char *argv[])
|
||||
case 0: /* Erg */
|
||||
do_next_word();
|
||||
break;
|
||||
|
||||
case 331: /* Stuff that we don't want to do squat */
|
||||
case -1:
|
||||
case 410: /* Must ignore this, it gets sent when we resize */
|
||||
|
||||
9
nano.h
9
nano.h
@@ -226,6 +226,7 @@ know what you're doing */
|
||||
#define NANO_SUSPEND_KEY NANO_CONTROL_Z
|
||||
#define NANO_ENTER_KEY NANO_CONTROL_M
|
||||
#define NANO_FROMSEARCHTOGOTO_KEY NANO_CONTROL_T
|
||||
#define NANO_TOFILES_KEY NANO_CONTROL_T
|
||||
|
||||
#define TOGGLE_CONST_KEY NANO_ALT_C
|
||||
#define TOGGLE_AUTOINDENT_KEY NANO_ALT_I
|
||||
@@ -243,10 +244,16 @@ know what you're doing */
|
||||
#define REPLACE_LIST_LEN 6
|
||||
#define REPLACE_LIST_2_LEN 3
|
||||
#define GOTO_LIST_LEN 3
|
||||
#define WRITEFILE_LIST_LEN 1
|
||||
#define HELP_LIST_LEN 3
|
||||
#define SPELL_LIST_LEN 1
|
||||
|
||||
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
|
||||
#define WRITEFILE_LIST_LEN 2
|
||||
#define BROWSER_LIST_LEN 3
|
||||
#else
|
||||
#define WRITEFILE_LIST_LEN 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
#define TOGGLE_LEN 9
|
||||
#else
|
||||
|
||||
23
proto.h
23
proto.h
@@ -38,7 +38,7 @@ extern int fill, flags,tabsize;
|
||||
extern int search_last_line;
|
||||
|
||||
extern WINDOW *edit, *topwin, *bottomwin;
|
||||
extern char filename[PATH_MAX];
|
||||
extern char *filename;
|
||||
extern char *answer;
|
||||
extern char *hblank, *help_text;
|
||||
extern char *last_search;
|
||||
@@ -51,6 +51,9 @@ extern shortcut main_list[MAIN_LIST_LEN], whereis_list[WHEREIS_LIST_LEN];
|
||||
extern shortcut replace_list[REPLACE_LIST_LEN], goto_list[GOTO_LIST_LEN];
|
||||
extern shortcut writefile_list[WRITEFILE_LIST_LEN], help_list[HELP_LIST_LEN];
|
||||
extern shortcut spell_list[SPELL_LIST_LEN], replace_list_2[REPLACE_LIST_LEN];
|
||||
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
|
||||
extern shortcut browser_list[BROWSER_LIST_LEN];
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
extern int use_regexp, regexp_compiled;
|
||||
@@ -78,7 +81,7 @@ int do_uncut_text(void);
|
||||
int no_help(void);
|
||||
int renumber_all(void);
|
||||
int open_file(char *filename, int insert, int quiet);
|
||||
int do_writeout(int exiting);
|
||||
int do_writeout(char *path, int exiting);
|
||||
int do_gotoline(long defline);
|
||||
int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
||||
int wholewords, int *i);
|
||||
@@ -109,16 +112,18 @@ void check_statblank(void);
|
||||
void update_line(filestruct * fileptr, int index);
|
||||
void fix_editbot(void);
|
||||
void statusbar(char *msg, ...);
|
||||
void titlebar(void);
|
||||
void blank_statusbar(void);
|
||||
void titlebar(char *path);
|
||||
void previous_line(void);
|
||||
void center_cursor(void);
|
||||
void bottombars(shortcut s[], int slen);
|
||||
void blank_statusbar_refresh(void);
|
||||
void *nmalloc (size_t howmuch);
|
||||
void *mallocstrcpy(void *dest, void *src);
|
||||
void *mallocstrcpy(char *dest, char *src);
|
||||
void wrap_reset(void);
|
||||
void display_main_list(void);
|
||||
void nano_small_msg(void);
|
||||
void nano_disable_msg(void);
|
||||
void do_early_abort(void);
|
||||
void *nmalloc(size_t howmuch);
|
||||
void *nrealloc(void *ptr, size_t howmuch);
|
||||
@@ -133,6 +138,8 @@ void search_init_globals(void);
|
||||
void replace_abort(void);
|
||||
void add_to_cutbuffer(filestruct * inptr);
|
||||
void do_replace_highlight(int highlight_flag, char *word);
|
||||
void nano_disabled_msg(void);
|
||||
void window_init(void);
|
||||
#ifdef NANO_EXTRA
|
||||
void do_credits(void);
|
||||
#endif
|
||||
@@ -145,6 +152,14 @@ int do_home(void), do_end(void), total_refresh(void), do_mark(void);
|
||||
int do_delete(void), do_backspace(void), do_tab(void), do_justify(void);
|
||||
int do_first_line(void), do_last_line(void);
|
||||
int do_replace(void), do_help(void), do_enter_void(void);
|
||||
int keypad_on(WINDOW * win, int new);
|
||||
|
||||
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
|
||||
char *do_browser(char *path);
|
||||
struct stat filestat(const char *path);
|
||||
char *do_browse_from(char *inpath);
|
||||
#endif
|
||||
|
||||
|
||||
filestruct *copy_node(filestruct * src);
|
||||
filestruct *copy_filestruct(filestruct * src);
|
||||
|
||||
7
utils.c
7
utils.c
@@ -123,9 +123,13 @@ void *nrealloc(void *ptr, size_t howmuch)
|
||||
|
||||
Should be used as dest = mallocstrcpy(dest, src);
|
||||
*/
|
||||
void *mallocstrcpy(void *dest, void *src)
|
||||
void *mallocstrcpy(char *dest, char *src)
|
||||
{
|
||||
|
||||
|
||||
if (src == dest)
|
||||
return src;
|
||||
|
||||
if (dest != NULL)
|
||||
free(dest);
|
||||
|
||||
@@ -152,6 +156,7 @@ void new_magicline(void)
|
||||
filebot->next->lineno = filebot->lineno + 1;
|
||||
filebot = filebot->next;
|
||||
totlines++;
|
||||
totsize++;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
|
||||
101
winio.c
101
winio.c
@@ -463,9 +463,13 @@ void horizbar(WINDOW * win, int y)
|
||||
wattroff(win, A_REVERSE);
|
||||
}
|
||||
|
||||
void titlebar(void)
|
||||
void titlebar(char *path)
|
||||
{
|
||||
int namelen, space;
|
||||
char *what = path;
|
||||
|
||||
if (path == NULL)
|
||||
what = filename;
|
||||
|
||||
horizbar(topwin, 0);
|
||||
wattron(topwin, A_REVERSE);
|
||||
@@ -473,17 +477,23 @@ void titlebar(void)
|
||||
|
||||
space = COLS - strlen(VERMSG) - strlen(VERSION) - 21;
|
||||
|
||||
namelen = strlen(filename);
|
||||
namelen = strlen(what);
|
||||
|
||||
if (!strcmp(filename, ""))
|
||||
if (!strcmp(what, ""))
|
||||
mvwaddstr(topwin, 0, center_x - 6, _("New Buffer"));
|
||||
else {
|
||||
if (namelen > space) {
|
||||
waddstr(topwin, _(" File: ..."));
|
||||
waddstr(topwin, &filename[namelen - space]);
|
||||
if (path == NULL)
|
||||
waddstr(topwin, _(" File: ..."));
|
||||
else
|
||||
waddstr(topwin, _(" DIR: ..."));
|
||||
waddstr(topwin, &what[namelen - space]);
|
||||
} else {
|
||||
mvwaddstr(topwin, 0, center_x - (namelen / 2 + 1), "File: ");
|
||||
waddstr(topwin, filename);
|
||||
if (path == NULL)
|
||||
mvwaddstr(topwin, 0, center_x - (namelen / 2 + 1), "File: ");
|
||||
else
|
||||
mvwaddstr(topwin, 0, center_x - (namelen / 2 + 1), " DIR: ");
|
||||
waddstr(topwin, what);
|
||||
}
|
||||
}
|
||||
if (ISSET(MODIFIED))
|
||||
@@ -552,7 +562,7 @@ void set_modified(void)
|
||||
{
|
||||
if (!ISSET(MODIFIED)) {
|
||||
SET(MODIFIED);
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
wrefresh(topwin);
|
||||
}
|
||||
}
|
||||
@@ -1119,7 +1129,7 @@ int total_refresh(void)
|
||||
clearok(topwin, FALSE);
|
||||
clearok(bottomwin, FALSE);
|
||||
edit_refresh();
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1132,33 +1142,26 @@ void previous_line(void)
|
||||
int do_cursorpos(void)
|
||||
{
|
||||
filestruct *fileptr;
|
||||
float linepct, bytepct;
|
||||
int i, tot = 0;
|
||||
float linepct = 0.0, bytepct = 0.0;
|
||||
int i = 0;
|
||||
|
||||
if (current == NULL || fileage == NULL)
|
||||
return 0;
|
||||
|
||||
for (fileptr = fileage; fileptr != current && fileptr != NULL;
|
||||
fileptr = fileptr->next)
|
||||
tot += strlen(fileptr->data) + 1;
|
||||
i += strlen(fileptr->data) + 1;
|
||||
|
||||
if (fileptr == NULL)
|
||||
return -1;
|
||||
|
||||
i = tot + current_x;;
|
||||
|
||||
for (fileptr = current->next; fileptr != NULL; fileptr = fileptr->next)
|
||||
tot += strlen(fileptr->data) + 1;
|
||||
i += current_x;
|
||||
|
||||
if (totlines > 0)
|
||||
linepct = 100 * current->lineno / totlines;
|
||||
else
|
||||
linepct = 0;
|
||||
|
||||
if (totsize > 0)
|
||||
bytepct = 100 * i / totsize;
|
||||
else
|
||||
bytepct = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("do_cursorpos: linepct = %f, bytepct = %f\n"),
|
||||
@@ -1175,25 +1178,26 @@ int do_cursorpos(void)
|
||||
But hey, it's better than nothing, and it's dynamic! */
|
||||
int do_help(void)
|
||||
{
|
||||
#ifndef NANO_SMALL
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
char *ptr = help_text, *end;
|
||||
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0;
|
||||
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0, kp;
|
||||
int no_help_flag = 0;
|
||||
|
||||
blank_edit();
|
||||
curs_set(0);
|
||||
blank_statusbar();
|
||||
|
||||
kp = keypad_on(edit, 1);
|
||||
|
||||
if (ISSET(NO_HELP)) {
|
||||
|
||||
/* Well if we're going to do this, we should at least
|
||||
do it the right way */
|
||||
no_help_flag = 1;
|
||||
delwin(bottomwin);
|
||||
bottomwin = newwin(3, COLS, LINES - 3, 0);
|
||||
keypad(bottomwin, TRUE);
|
||||
|
||||
editwinrows -= no_help();
|
||||
UNSET(NO_HELP);
|
||||
window_init();
|
||||
bottombars(help_list, HELP_LIST_LEN);
|
||||
|
||||
} else
|
||||
bottombars(help_list, HELP_LIST_LEN);
|
||||
|
||||
@@ -1265,22 +1269,25 @@ int do_help(void)
|
||||
no_more = 1;
|
||||
continue;
|
||||
}
|
||||
} while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY);
|
||||
} while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY &&
|
||||
kbinput != NANO_EXIT_FKEY);
|
||||
|
||||
if (no_help_flag) {
|
||||
werase(bottomwin);
|
||||
blank_bottombars();
|
||||
wrefresh(bottomwin);
|
||||
delwin(bottomwin);
|
||||
SET(NO_HELP);
|
||||
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
|
||||
keypad(bottomwin, TRUE);
|
||||
editwinrows += no_help();
|
||||
} else
|
||||
display_main_list();
|
||||
window_init();
|
||||
}
|
||||
display_main_list();
|
||||
|
||||
curs_set(1);
|
||||
edit_refresh();
|
||||
#else
|
||||
kp = keypad_on(edit, kp);
|
||||
|
||||
#elif defined(NANO_SMALL)
|
||||
nano_small_msg();
|
||||
#elif defined(DISABLE_HELP)
|
||||
nano_disabled_msg();
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -1400,7 +1407,7 @@ void do_credits(void)
|
||||
"Tedi Heriyanto",
|
||||
"Bill Soudan",
|
||||
"Christian Weisgerber",
|
||||
"Erik Anderson",
|
||||
"Erik Andersen",
|
||||
"Big Gaute",
|
||||
"Joshua Jensen",
|
||||
"",
|
||||
@@ -1463,3 +1470,23 @@ void do_credits(void)
|
||||
total_refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
int keypad_on(WINDOW * win, int new)
|
||||
{
|
||||
|
||||
/* This is taken right from aumix. Don't sue me */
|
||||
#ifdef HAVE_USEKEYPAD
|
||||
int old;
|
||||
|
||||
old = win->_use_keypad;
|
||||
keypad(win, new);
|
||||
return old;
|
||||
#else
|
||||
keypad(win, new);
|
||||
return 1;
|
||||
#endif /* HAVE_USEKEYPAD */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user