Compare commits
108 Commits
v0.9.22
...
v0.9.99pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9faa3f13e2 | ||
|
|
3c10ec016c | ||
|
|
c2eeb4e585 | ||
|
|
4058709e0b | ||
|
|
51dd32fb4e | ||
|
|
ae4318dab0 | ||
|
|
3693944492 | ||
|
|
4097379a26 | ||
|
|
b4c43683a5 | ||
|
|
a35ec048d7 | ||
|
|
2be96d00b9 | ||
|
|
e61e830010 | ||
|
|
201d9bf467 | ||
|
|
1748cd1d0f | ||
|
|
d9742c69c0 | ||
|
|
af5c302b48 | ||
|
|
4ee0b41b41 | ||
|
|
cd6f12d53e | ||
|
|
06aca1cc9e | ||
|
|
a4d6d1df37 | ||
|
|
7db63a5b65 | ||
|
|
2c4feca17f | ||
|
|
bbebec6871 | ||
|
|
8eac3b5069 | ||
|
|
bf69261597 | ||
|
|
7e08082ffe | ||
|
|
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 | ||
|
|
b29550e58d | ||
|
|
8816760ea1 | ||
|
|
da13f0b45c | ||
|
|
1bd0ce2832 | ||
|
|
7b36c52efc | ||
|
|
b5bb24c949 | ||
|
|
71e464034d | ||
|
|
21e3c28af2 | ||
|
|
fb62f73a9a | ||
|
|
928a7f535c | ||
|
|
fb2226a9ae | ||
|
|
37f627f2f8 | ||
|
|
07f9ee059f | ||
|
|
908805a2e8 | ||
|
|
20c131cf67 | ||
|
|
5982849325 | ||
|
|
4a938e137a |
@@ -1,8 +1,10 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
confdefs.h
|
||||
config.cache
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
nano
|
||||
stamp-h
|
||||
|
||||
13
BUGS
13
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 **
|
||||
|
||||
@@ -83,5 +92,9 @@
|
||||
such as when all of a line is selected but the mark doesn't proceed to
|
||||
the new line. (8) { Is this an issue? compare to pico 3.5 }
|
||||
- totsize problems still abound in do_justify (33).
|
||||
- Resizing the window completely screws up the display if in any other
|
||||
mode than normal editing (help screen, search and replace, file
|
||||
browser..) (52)
|
||||
|
||||
|
||||
$Id$
|
||||
|
||||
206
ChangeLog
206
ChangeLog
@@ -1,3 +1,209 @@
|
||||
nano 0.9.99-pre1 - 01/17/2001
|
||||
General
|
||||
- Changed #ifdefs to check for both DISABLE_TABCOMP and
|
||||
NANO_SMALL, makes tiny option leave out tab completion, which
|
||||
should be left out in that circumstance. Saves at least 5k.
|
||||
- Previous change to #ifdefs DISABLE_TABCOMP and NANO_SMALL rolled
|
||||
back. (Rocco)
|
||||
- Various #ifdef & #ifndef cleanups. (Rocco)
|
||||
- Added message for when keypad goes awry. Added code in main and
|
||||
function print_numlock_warning() to notify user, and added an
|
||||
apropriate section in the faq to refer to this brokenness.
|
||||
- Added macros in nano.h for magic values that might be unclear in
|
||||
nano.c:global_init(). (Rocco)
|
||||
- configure.in:
|
||||
- Fix for _use_keypad check breaking slang support (Christian
|
||||
Weisgerber).
|
||||
- Changed to automatically define the 5 DISABLE varibles when
|
||||
NANO_SMALL (enable-tiny) is requested at configure.
|
||||
- faq.html:
|
||||
- Added some info on making the binary smaller with the configure
|
||||
script.
|
||||
- Added section on keypad bugginess.
|
||||
- files.c:
|
||||
real_dir_from_tilde()
|
||||
- Oops, fix case where buf ="~", silly crash (bug discovered by
|
||||
Neil Parks).
|
||||
do_browser()
|
||||
- Added space and - keys to do page up and down.
|
||||
cwd_tab_completion(), input_tab()
|
||||
- Changed bare malloc/calloc calls to nmalloc (found by Rocco).
|
||||
- Added memset() to matchBuf to ensure sanity (Rocco, Adam).
|
||||
- nano.c:
|
||||
ABCD()
|
||||
- New function, figures out what kbinput to return given
|
||||
input common to several switch statements, allows us to
|
||||
support the default Konsole key settings.
|
||||
main()
|
||||
- Alternate speller option no longer valid if DISABLE_SPELLER is
|
||||
active. (Rocco)
|
||||
- Removed direct calls to usage() (#else) for -k (cut) or -s (speller)
|
||||
options when these have been disabled. (Rocco)
|
||||
- Initialized kbinput to get around stupid compiler warning.
|
||||
nano_small_msg()
|
||||
- This function has been removed. All references now call
|
||||
nano_disabled_msg. (Rocco)
|
||||
version()
|
||||
- When NANO_SMALL (enable-tiny) is defined, the 5 main DISABLE
|
||||
variables (SPELLER, HELP, JUSTIFY, BROWSER, TABCOMP) are not
|
||||
reported as enabled when Nano is called with -V (--version)
|
||||
command-line option. (Rocco)
|
||||
usage()
|
||||
- Alternate speller option no longer valid if DISABLE_SPELLER is
|
||||
active. (Rocco)
|
||||
window_init(), handle_sigwinch()
|
||||
- Added check for not having enough LINES to do anything useful,
|
||||
if so die with an error. (Rocco)
|
||||
die_too_small()
|
||||
- Function to print the window too small error message, avoids
|
||||
repeated string defs and globals.
|
||||
do_justify()
|
||||
- Small fix for totsize calculation (Rob)
|
||||
|
||||
- fi.po:
|
||||
- Update by Pauli Virtanen.
|
||||
|
||||
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
|
||||
"speller" for -s, so it should be --disable-speller.
|
||||
- files.c:
|
||||
write_file()
|
||||
- Added tmp check to TMP_OPT section (how apropriate).
|
||||
- Added new consistency checking code from securityfocus
|
||||
article by Oliver Friedrichs, and use O_EXCL if tmp == 1.
|
||||
- We now run check on result of lstat(), not stat(), to be
|
||||
safer. New variable anyexists, we use still use realexists
|
||||
later in the program.
|
||||
- OOPS, line up link/unlink/rename check if conditional with
|
||||
top if conditional. Option -l has been broken for 9 versions,
|
||||
no one noticed?!
|
||||
- Added saving perms at end of link so we can apply them to the
|
||||
new file if --nofollow is used.
|
||||
- winio.c:
|
||||
edit_add()
|
||||
- Off by one display error (fix by Rocco Corsi).
|
||||
do_replace_highlight()
|
||||
- New code to handle being past COLS (Roco Corsi).
|
||||
- Moved from search.c, as it's definitely a winio function now =)
|
||||
update_line()
|
||||
- More '$' display fixes (Rocco Corsi).
|
||||
|
||||
nano 0.9.22 - 12/02/2000
|
||||
- General
|
||||
- Username tab completion code, and cleaned up existing tabcomp
|
||||
|
||||
40
NEWS
40
NEWS
@@ -1,3 +1,43 @@
|
||||
01/17/2001 - Nano 0.9.99-pre1 is released. This is the first pre-1.0
|
||||
release of nano, and is also the first release since the
|
||||
code freeze for nano 1.0. Don't expect (or request) any
|
||||
new features between now and nano 1.0, only bugfixes,
|
||||
optimizations and doc/translation updates. For fixes, a
|
||||
nasty segfault when trying to insert one's home directory
|
||||
(~), some checks for the NumLock key making the keypad
|
||||
go awry, window size sanity checks, many autoconf fixes,
|
||||
and support for the KDE konsole keypad layout. Have fun.
|
||||
|
||||
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
|
||||
links. Hopefully this will fix the probelm permanently.
|
||||
The --nofollow option also works again for those who
|
||||
are real security nuts. There are also some display and
|
||||
search fixes, and the --disable-spell function was renamed
|
||||
to --disable-speller to be in line with nano and pico's
|
||||
"speller" term.
|
||||
|
||||
12/02/2000 - Nano 0.9.22 is released, with many more changes and
|
||||
additions than imaginable. The most important change is
|
||||
a fix for unsafe handling of symbolic links which could
|
||||
|
||||
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
|
||||
|
||||
@@ -34,6 +37,10 @@
|
||||
#undef DISABLE_JUSTIFY
|
||||
|
||||
/* Define this to disable the use(full|less) spelling functions */
|
||||
#undef DISABLE_SPELL
|
||||
#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
|
||||
|
||||
11
config.h.in
11
config.h.in
@@ -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
|
||||
|
||||
@@ -86,7 +89,13 @@
|
||||
#undef DISABLE_JUSTIFY
|
||||
|
||||
/* Define this to disable the use(full|less) spelling functions */
|
||||
#undef DISABLE_SPELL
|
||||
#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
|
||||
|
||||
41
configure.in
41
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.22)
|
||||
AM_INIT_AUTOMAKE(nano, 0.9.99pre1)
|
||||
AM_CONFIG_HEADER(config.h:config.h.in)
|
||||
ALL_LINGUAS="es de fr it id fi"
|
||||
|
||||
@@ -19,6 +19,11 @@ AC_ARG_ENABLE(tiny,
|
||||
(currently disables detailed help and i18n)],
|
||||
[if test x$enableval = xyes; then
|
||||
AC_DEFINE(NANO_SMALL) tiny_support=yes
|
||||
AC_DEFINE(DISABLE_TABCOMP)
|
||||
AC_DEFINE(DISABLE_SPELLER)
|
||||
AC_DEFINE(DISABLE_HELP)
|
||||
AC_DEFINE(DISABLE_JUSTIFY)
|
||||
AC_DEFINE(DISABLE_BROWSER)
|
||||
fi])
|
||||
|
||||
AC_ARG_ENABLE(extra,
|
||||
@@ -39,10 +44,22 @@ AC_ARG_ENABLE(justify,
|
||||
AC_DEFINE(DISABLE_JUSTIFY)
|
||||
fi])
|
||||
|
||||
AC_ARG_ENABLE(spell,
|
||||
AC_ARG_ENABLE(speller,
|
||||
[ --disable-speller Disables spell checker function],
|
||||
[if test x$enableval != xyes; then
|
||||
AC_DEFINE(DISABLE_SPELL)
|
||||
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)
|
||||
@@ -194,7 +211,23 @@ else
|
||||
fi
|
||||
|
||||
|
||||
AC_CHECK_LIB($CURSES_LIB_NAME, wresize, AC_DEFINE(HAVE_WRESIZE))
|
||||
if test x$slang_support != xyes; then
|
||||
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
|
||||
fi
|
||||
|
||||
dnl Parse any configure options
|
||||
|
||||
|
||||
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();
|
||||
|
||||
81
faq.html
81
faq.html
@@ -1,5 +1,6 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<title>The nano editor FAQ</title>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="GENERATOR" content="Mozilla/4.73 [en] (X11; U; Linux 2.2.16 i586) [Netscape]">
|
||||
@@ -21,7 +22,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>
|
||||
@@ -48,7 +49,9 @@ THE HECK DO I DO NOW?</a></font>
|
||||
<br><font color="#330000"><a href="#3.4">3.4. I get errors about 'bindtextdomain',
|
||||
'gettext' and/or 'gettextdomain'. What can I do about it?</a></font>
|
||||
<br><font color="#330000"><a href="#3.5">3.5. Nano should automatically
|
||||
run strip on the binary when installing it!</a></font></blockquote>
|
||||
run strip on the binary when installing it!</a></font>
|
||||
<br><font color="#330000"><a href="#3.6">3.6. How can I make the
|
||||
executable smaller? This is too bloated!</a></font></blockquote>
|
||||
|
||||
<h2>
|
||||
<font color="#330000"><a href="#4">4. Running</a></font></h2>
|
||||
@@ -64,8 +67,11 @@ my window. How can I fix that?</a></font>
|
||||
<br><font color="#330000"><a href="#4.5">4.5. When I type in a
|
||||
search string, the string I last searched for is already in front of
|
||||
my cursor! !What happened?!</a></font>
|
||||
<br><a href="#4.6">4.6 How do I make nano my default editor (in Pine,
|
||||
mutt, etc.)?</a></blockquote>
|
||||
<br><font color="#330000"><a href="#4.6">4.6. I get the message "NumLock
|
||||
glitch detected. Keypad will malfunction with NumLock off." What
|
||||
gives?</a></font>
|
||||
<br><font color="#330000"><a href="#4.7">4.7. How do I make nano my
|
||||
default editor (in Pine, mutt, etc.)?</a></font></blockquote>
|
||||
|
||||
<h2>
|
||||
<font color="#330000"><a href="#5">5. Internationalization</a></font></h2>
|
||||
@@ -146,7 +152,7 @@ nano?</font></h2>
|
||||
on a Unix system. The Pico text editor is the portion of the program
|
||||
one would use to compose his or her mail messages. Many beginners
|
||||
to Unix flocked to Pico and Pine because of their well organized, easy
|
||||
to use interfaces. With the proliferation of Linux in the mid to
|
||||
to use interfaces. With the proliferation of GNU/Linux in the mid to
|
||||
late 90's, many University students became intimately familiar with the
|
||||
strengths (and weaknesses) of Pine and Pico.</font>
|
||||
<p><b><font color="#330000">Then came debian...</font></b>
|
||||
@@ -181,7 +187,7 @@ renamed to nano because of a namespace conflict with another program called
|
||||
'tip'. The original 'tip' program "establishes a full duplex terminal
|
||||
connection to a remote host", and was included with many older Unix systems
|
||||
(and newer ones like Solaris). The conflict was not noticed at first because
|
||||
there is no 'tip' utility included with most Linux distributions (where
|
||||
there is no 'tip' utility included with most GNU/Linux distributions (where
|
||||
nano was developed).</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -189,7 +195,7 @@ nano was developed).</font></blockquote>
|
||||
of nano?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">The current version of nano *should*
|
||||
be 0.9.22. Of course you should always check the nano hompage to
|
||||
be 0.9.99pre1. Of course you should always check the nano hompage to
|
||||
see what the latest and greatest version is.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -294,7 +300,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>
|
||||
@@ -310,7 +316,8 @@ try this:</font>
|
||||
<p><font color="#330000">(again, where x.y.z is the version number in question).
|
||||
Then you need to run configure with any options you might want (if any).</font>
|
||||
<p><font color="#330000">The average case is this:</font>
|
||||
<p><b><font color="#330000">./configure</font></b>
|
||||
<p><b><font color="#330000">cd nano-x.y.z/</font></b>
|
||||
<br><b><font color="#330000">./configure</font></b>
|
||||
<br><b><font color="#330000">make</font></b>
|
||||
<br><font color="#330000"><b>make install </b>(as root, of course)</font></blockquote>
|
||||
|
||||
@@ -340,8 +347,31 @@ run strip on the binary when installing it!</font></h2>
|
||||
<b>make install-strip</b>. The default make install does not, and will
|
||||
not, run strip automatically.</font></blockquote>
|
||||
|
||||
<hr WIDTH="100%">
|
||||
<h1>
|
||||
<h2>
|
||||
<a NAME="3.6"></a><font color="#330000">
|
||||
3.6. How can I make the executable smaller? This is too
|
||||
bloated!</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">Actually, there are several parts of the
|
||||
editor that can be disabled. You can pass arguments to the
|
||||
<b>configure</b> script that disable certain features. Here's a brief
|
||||
list:
|
||||
<pre>
|
||||
<b>--disable-tabcomp</b> Disables tab completion code for a smaller binary
|
||||
<b>--disable-justify</b> Disable justify/unjustify function
|
||||
<b>--disable-speller</b> Disables spell checker function
|
||||
<b>--disable-help</b> Disables help function (^G)
|
||||
<b>--disable-browser</b> Disables mini file browser
|
||||
</pre><br>
|
||||
There's also the <b>--enable-tiny</b> option which disabled everything
|
||||
above, as well as some larger chunks of the program (like the marker code
|
||||
that you use Control-^ to select with). Also, if you know you aren't
|
||||
going to be using other languages you can use <b>--disable-nls</b> to
|
||||
disable internationalization and save a few K to a few dozen K depending
|
||||
on if you have locale support on your system. And finally there's always
|
||||
good old <b>strip</b> to strip all debugging code and code that exists in
|
||||
libraries on your system.
|
||||
</font></blockquote> <hr WIDTH="100%"> <h1>
|
||||
<a NAME="4"></a><font color="#330000">4. Running</font></h1>
|
||||
|
||||
<h2>
|
||||
@@ -368,8 +398,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
|
||||
@@ -386,7 +416,7 @@ will get the same shortcuts at the bottom as Pico.</font></blockquote>
|
||||
string, the string I last searched for is already in front of my
|
||||
cursor! !What happened?!</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">In nano version 0.9.22, the default is
|
||||
<blockquote><font color="#330000">In nano version 0.9.20, the default is
|
||||
to have a completely consistent user interface across all user input
|
||||
functions. This means that regardless of whether you're being asked for
|
||||
a filename to insert or write, or a string to search for, the
|
||||
@@ -396,7 +426,26 @@ Meta-P while in nano (see the ^G help text for more
|
||||
details).</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="4.6"></a>4.6. How do I make nano my default editor (in Pine,
|
||||
<a NAME="4.6"></a>I get the message "NumLock glitch detected. Keypad
|
||||
will malfunction with NumLock off." What gives?</h2>
|
||||
|
||||
<blockquote>
|
||||
Nano (actually almost all console editors do) has issues when cycling
|
||||
the NumLock key in certain X terminals (rxvt, aterm, wterm, etc...). When
|
||||
you switch NumLock on to off, you put the terminal into an "application
|
||||
mode" that changes what sequences are sent by the keypad. These sequences
|
||||
vary sufficiently from terminal to terminal that it is nearly impossible
|
||||
to work around them from within nano.
|
||||
<br><br>
|
||||
In a nutshell, if you want to be able to use the keypad with the arrow and
|
||||
page up/down functionality, you have to exit nano and reset your terminal
|
||||
(presumably with "reset" or "stty sane" or similar) and then run nano
|
||||
again with NumLock off. If you know an easier way to restore "normal
|
||||
mode", please mail <A href="nano@nano-editor.org">nano@nano-editor.org</A>.
|
||||
<br> </blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="4.7"></a>4.7. How do I make nano my default editor (in Pine,
|
||||
mutt, etc)?</h2>
|
||||
|
||||
<blockquote>You need to make nano your $EDITOR. If you want this
|
||||
@@ -526,7 +575,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>
|
||||
|
||||
643
files.c
643
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;
|
||||
@@ -257,9 +266,24 @@ int do_insertfile(void)
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
realname = real_dir_from_tilde(answer);
|
||||
realname = real_dir_from_tilde(answer);
|
||||
#else
|
||||
realname = mallocstrcpy(realname, answer);
|
||||
realname = mallocstrcpy(realname, answer);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
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);
|
||||
@@ -299,70 +323,75 @@ 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;
|
||||
struct stat st;
|
||||
int fd, mask = 0, realexists, anyexists;
|
||||
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
|
||||
realname = mallocstrcpy(realname, name);
|
||||
#endif
|
||||
|
||||
/* Save the state of file at the end of the symlink */
|
||||
/* Save the state of file at the end of the symlink (if there is one) */
|
||||
realexists = stat(realname, &st);
|
||||
|
||||
/* Check to see if the file is a regular file and FOLLOW_SYMLINKS is
|
||||
set. If so then don't do the delete and recreate code which would
|
||||
cause unexpected behavior */
|
||||
lstat(realname, &st);
|
||||
/* Stat the link itself for the check... */
|
||||
anyexists = lstat(realname, &lst);
|
||||
|
||||
/* New case: if the file exists, just give up. Easy way out of
|
||||
all security issues */
|
||||
if (tmp && realexists != -1)
|
||||
return -1;
|
||||
else if (ISSET(FOLLOW_SYMLINKS) || !S_ISLNK(st.st_mode)) {
|
||||
/* New case: if the file exists, just give up */
|
||||
if (tmp && anyexists != -1)
|
||||
return -1;
|
||||
/* NOTE: If you change this statement, you MUST CHANGE the if
|
||||
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. This is now copied from joe, because
|
||||
wiggy says so *shrug*. */
|
||||
if (tmp)
|
||||
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));
|
||||
|
||||
/* Open the file and truncate it. Trust the symlink. */
|
||||
if ((fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
|
||||
S_IWOTH)) == -1) {
|
||||
if (ISSET(TEMP_OPT)) {
|
||||
/* 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));
|
||||
free(realname);
|
||||
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));
|
||||
@@ -415,67 +444,66 @@ int write_file(char *name, int tmp)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ISSET(FOLLOW_SYMLINKS) || tmp) {
|
||||
if (realexists == -1) {
|
||||
/* Use default umask as file permisions if file is a new file. */
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
if (realexists == -1 || tmp ||
|
||||
(!ISSET(FOLLOW_SYMLINKS) && S_ISLNK(lst.st_mode))) {
|
||||
|
||||
if (tmp) /* We don't want anyone reading our temporary file! */
|
||||
mask = 0600;
|
||||
else
|
||||
mask = 0666 & ~mask;
|
||||
/* Use default umask as file permisions if file is a new file. */
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
|
||||
} else {
|
||||
/* Use permissions from file we are overwriting. */
|
||||
mask = st.st_mode;
|
||||
if (unlink(realname) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
realname, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tmp) /* We don't want anyone reading our temporary file! */
|
||||
mask = 0600;
|
||||
else
|
||||
mask = 0666 & ~mask;
|
||||
} else
|
||||
/* Use permissions from file we are overwriting. */
|
||||
mask = st.st_mode;
|
||||
|
||||
if (!tmp) {
|
||||
if (link(buf, realname) != -1)
|
||||
unlink(buf);
|
||||
else if (errno != EPERM) {
|
||||
if (!tmp && (!ISSET(FOLLOW_SYMLINKS) && S_ISLNK(lst.st_mode))) {
|
||||
if (unlink(realname) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
name, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
} else if (rename(buf, realname) == -1) { /* Try a rename?? */
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
realname, strerror(errno));
|
||||
realname, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (chmod(realname, mask) == -1)
|
||||
statusbar(_("Could not set permissions %o on %s: %s"),
|
||||
mask, realname, strerror(errno));
|
||||
|
||||
if (link(buf, realname) != -1)
|
||||
unlink(buf);
|
||||
else if (errno != EPERM) {
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
name, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
} else if (rename(buf, realname) == -1) { /* Try a rename?? */
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
realname, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (chmod(realname, mask) == -1)
|
||||
statusbar(_("Could not set permissions %o on %s: %s"),
|
||||
mask, realname, strerror(errno));
|
||||
|
||||
if (!tmp) {
|
||||
strncpy(filename, realname, 132);
|
||||
filename = mallocstrcpy(filename, realname);
|
||||
statusbar(_("Wrote %d lines"), lineswritten);
|
||||
UNSET(MODIFIED);
|
||||
titlebar();
|
||||
UNSET(MODIFIED);
|
||||
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]) {
|
||||
@@ -497,15 +525,28 @@ int do_writeout(int exiting)
|
||||
|
||||
if (i != -1) {
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
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
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
if (exiting && !ISSET(TEMP_OPT) && !strcasecmp(answer, "zzy") && !did_cred) {
|
||||
if (exiting && !ISSET(TEMP_OPT) && !strcasecmp(answer, "zzy")
|
||||
&& !did_cred) {
|
||||
do_credits();
|
||||
did_cred = 1;
|
||||
return - 1;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
if (strcmp(answer, filename)) {
|
||||
@@ -531,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
|
||||
@@ -540,7 +581,7 @@ static char **homedirs;
|
||||
/* Return a malloc()ed string containing the actual directory, used
|
||||
* to convert ~user and ~/ notation...
|
||||
*/
|
||||
char *real_dir_from_tilde (char *buf)
|
||||
char *real_dir_from_tilde(char *buf)
|
||||
{
|
||||
char *dirtmp = NULL, *line = NULL, byte[1], *lineptr;
|
||||
int fd, i, status, searchctr = 1;
|
||||
@@ -548,36 +589,39 @@ char *real_dir_from_tilde (char *buf)
|
||||
if (buf[0] == '~') {
|
||||
if (buf[1] == '~')
|
||||
goto abort; /* Handle ~~ without segfaulting =) */
|
||||
else if (buf[1] == '/') {
|
||||
else if (buf[1] == 0 || buf[1] == '/') {
|
||||
if (getenv("HOME") != NULL) {
|
||||
dirtmp = nmalloc(strlen(buf) + 2 + strlen(getenv("HOME")));
|
||||
|
||||
sprintf(dirtmp, "%s/%s", getenv("HOME"), &buf[2]);
|
||||
}
|
||||
}
|
||||
else if (buf[1] != 0) {
|
||||
if (strlen(buf) > 2)
|
||||
sprintf(dirtmp, "%s/%s", getenv("HOME"), &buf[2]);
|
||||
else
|
||||
sprintf(dirtmp, "%s/", getenv("HOME"));
|
||||
|
||||
if((fd = open("/etc/passwd", O_RDONLY)) == -1)
|
||||
}
|
||||
} else if (buf[1] != 0) {
|
||||
|
||||
if ((fd = open("/etc/passwd", O_RDONLY)) == -1)
|
||||
goto abort;
|
||||
|
||||
/* Figure how how much of of the str we need to compare */
|
||||
for (searchctr = 1; buf[searchctr] != '/' &&
|
||||
buf[searchctr] != 0; searchctr++)
|
||||
;
|
||||
buf[searchctr] != 0; searchctr++);
|
||||
|
||||
do {
|
||||
i = 0;
|
||||
line = nmalloc(1);
|
||||
while ((status = read(fd, byte, 1)) != 0 && byte[0] != '\n') {
|
||||
while ((status = read(fd, byte, 1)) != 0
|
||||
&& byte[0] != '\n') {
|
||||
|
||||
line[i] = byte[0];
|
||||
i++;
|
||||
line = nrealloc(line, i+1);
|
||||
line = nrealloc(line, i + 1);
|
||||
}
|
||||
line[i] = 0;
|
||||
|
||||
if (i == 0)
|
||||
goto abort;
|
||||
goto abort;
|
||||
|
||||
line[i] = 0;
|
||||
lineptr = strtok(line, ":");
|
||||
@@ -591,25 +635,24 @@ char *real_dir_from_tilde (char *buf)
|
||||
if (lineptr == NULL)
|
||||
goto abort;
|
||||
|
||||
/* Else copy the new string into the new buf */
|
||||
/* Else copy the new string into the new buf */
|
||||
dirtmp = nmalloc(strlen(buf) + 2 + strlen(lineptr));
|
||||
|
||||
sprintf(dirtmp, "%s%s", lineptr, &buf[searchctr]);
|
||||
free(line);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
free(line);
|
||||
|
||||
} while (status != 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
dirtmp = mallocstrcpy(dirtmp, buf);
|
||||
|
||||
return dirtmp;
|
||||
return dirtmp;
|
||||
|
||||
abort:
|
||||
abort:
|
||||
dirtmp = mallocstrcpy(dirtmp, buf);
|
||||
return dirtmp;
|
||||
}
|
||||
@@ -624,7 +667,7 @@ int append_slash_if_dir(char *buf, int *lastWasTab, int *place)
|
||||
dirptr = real_dir_from_tilde(buf);
|
||||
|
||||
if (stat(dirptr, &fileinfo) == -1)
|
||||
ret = 0;
|
||||
ret = 0;
|
||||
else if (S_ISDIR(fileinfo.st_mode)) {
|
||||
strncat(buf, "/", 1);
|
||||
*place += 1;
|
||||
@@ -634,7 +677,7 @@ int append_slash_if_dir(char *buf, int *lastWasTab, int *place)
|
||||
}
|
||||
|
||||
if (dirptr != buf)
|
||||
free(dirptr);
|
||||
free(dirptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -662,11 +705,11 @@ char **username_tab_completion(char *buf, int *num_matches)
|
||||
{
|
||||
char **matches = (char **) NULL, *line = NULL, *lineptr;
|
||||
char *matchline = NULL, *matchdir = NULL;
|
||||
|
||||
|
||||
int fd, i = 0, status = 1;
|
||||
char byte[1];
|
||||
|
||||
if((fd = open("/etc/passwd", O_RDONLY)) == -1) {
|
||||
if ((fd = open("/etc/passwd", O_RDONLY)) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -677,8 +720,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;
|
||||
@@ -687,7 +730,7 @@ char **username_tab_completion(char *buf, int *num_matches)
|
||||
|
||||
line[i] = byte[0];
|
||||
i++;
|
||||
line = nrealloc(line, i+1);
|
||||
line = nrealloc(line, i + 1);
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
@@ -746,14 +789,14 @@ 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, "*");
|
||||
|
||||
/* Okie, if there's a / in the buffer, strip out the directory part */
|
||||
if (strcmp(buf, "") && strstr(buf, "/")) {
|
||||
dirName = malloc(strlen(buf) + 1);
|
||||
dirName = nmalloc(strlen(buf) + 1);
|
||||
tmp = buf + strlen(buf);
|
||||
while (*tmp != '/' && tmp != buf)
|
||||
tmp--;
|
||||
@@ -796,11 +839,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
|
||||
@@ -844,7 +882,8 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
|
||||
|
||||
/* Make a local copy of the string -- up to the position of the
|
||||
cursor */
|
||||
matchBuf = (char *) calloc(strlen(buf) + 2, sizeof(char));
|
||||
matchBuf = (char *) nmalloc((strlen(buf) + 2) * sizeof(char));
|
||||
memset(matchBuf, '\0', (strlen(buf) + 2));
|
||||
|
||||
strncpy(matchBuf, buf, place);
|
||||
tmp = matchBuf;
|
||||
@@ -866,8 +905,8 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
|
||||
* then try completing this word as a username. */
|
||||
|
||||
/* FIXME -- this check is broken! */
|
||||
if (*tmp == '~' && !strchr(tmp, '/'))
|
||||
matches = username_tab_completion(tmp, &num_matches);
|
||||
if (*tmp == '~' && !strchr(tmp, '/'))
|
||||
matches = username_tab_completion(tmp, &num_matches);
|
||||
|
||||
/* Try to match everything in the current working directory that
|
||||
* matches. */
|
||||
@@ -1018,3 +1057,387 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
|
||||
/* 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:
|
||||
case '-':
|
||||
|
||||
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:
|
||||
case ' ':
|
||||
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];
|
||||
#ifndef DISABLE_BROWSER
|
||||
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);
|
||||
#ifndef DISABLE_BROWSER
|
||||
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);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
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>
|
||||
|
||||
307
nano.c
307
nano.c
@@ -62,35 +62,35 @@
|
||||
|
||||
/* Former globals, now static */
|
||||
int fill = 0; /* Fill - where to wrap lines, basically */
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
static char *alt_speller; /* Alternative spell command */
|
||||
#endif
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef 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();
|
||||
|
||||
@@ -141,11 +141,28 @@ void die(char *msg, ...)
|
||||
exit(1); /* We have a problem: exit w/ errorlevel(1) */
|
||||
}
|
||||
|
||||
/* Die with an error message that the screen was too small if, well, the
|
||||
screen is too small */
|
||||
void die_too_small(void)
|
||||
{
|
||||
char *too_small_msg = _("Window size is too small for Nano...");
|
||||
|
||||
die(too_small_msg);
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -156,7 +173,10 @@ void global_init(void)
|
||||
center_y = LINES / 2;
|
||||
current_x = 0;
|
||||
current_y = 0;
|
||||
editwinrows = LINES - 5 + no_help();
|
||||
|
||||
if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
|
||||
die_too_small();
|
||||
|
||||
fileage = NULL;
|
||||
cutbuffer = NULL;
|
||||
current = NULL;
|
||||
@@ -164,8 +184,13 @@ void global_init(void)
|
||||
editbot = NULL;
|
||||
totlines = 0;
|
||||
placewewant = 0;
|
||||
|
||||
if (!fill)
|
||||
fill = COLS - 8;
|
||||
fill = COLS - CHARS_FROM_EOL;
|
||||
|
||||
if (fill < MIN_FILL_LENGTH)
|
||||
die_too_small();
|
||||
|
||||
hblank = nmalloc(COLS + 1);
|
||||
|
||||
/* Thanks BG for this bit... */
|
||||
@@ -174,11 +199,10 @@ void global_init(void)
|
||||
hblank[i] = 0;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
void init_help_msg(void)
|
||||
{
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
|
||||
help_text_init =
|
||||
_(" nano help text\n\n "
|
||||
"The nano editor is designed to emulate the functionality and "
|
||||
@@ -197,9 +221,9 @@ void init_help_msg(void)
|
||||
"Esc, Alt or Meta key depending on your keyboard setup. The "
|
||||
"following keystrokes are available in the main editor window. "
|
||||
"Optional keys are shown in parentheses:\n\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make a copy of a node to a pointer (space will be malloc()ed) */
|
||||
filestruct *copy_node(filestruct * src)
|
||||
@@ -315,7 +339,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 +382,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,13 +395,15 @@ 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"));
|
||||
#ifndef DISABLE_SPELLER
|
||||
printf(_
|
||||
(" -s [prog] --speller=[prog] Enable alternate speller\n"));
|
||||
#endif
|
||||
printf(_
|
||||
(" -t --tempfile Auto save on exit, don't prompt\n"));
|
||||
printf(_
|
||||
@@ -395,10 +424,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 +435,11 @@ 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"));
|
||||
#ifndef DISABLE_SPELLER
|
||||
printf(_(" -s [prog] Enable alternate speller\n"));
|
||||
#endif
|
||||
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"));
|
||||
@@ -428,21 +458,30 @@ void version(void)
|
||||
(" Email: nano@nano-editor.org Web: http://www.nano-editor.org"));
|
||||
printf(_("\n Compiled options:"));
|
||||
|
||||
#ifdef NANO_SMALL
|
||||
printf(" --enable-tiny");
|
||||
#endif
|
||||
#ifdef NANO_EXTRA
|
||||
printf(" --enable-extra");
|
||||
#endif
|
||||
#ifdef DISABLE_TABCOMP
|
||||
|
||||
#ifdef NANO_SMALL
|
||||
printf(" --enable-tiny");
|
||||
#else
|
||||
#ifdef DISABLE_BROWSER
|
||||
printf(" --disable-browser");
|
||||
#endif
|
||||
#ifdef DISABLE_TABCOMP
|
||||
printf(" --disable-tabcomp");
|
||||
#endif
|
||||
#ifdef DISABLE_JUSTIFY
|
||||
#endif
|
||||
#ifdef DISABLE_JUSTIFY
|
||||
printf(" --disable-justify");
|
||||
#endif
|
||||
#ifdef DISABLE_SPELLER
|
||||
printf(" --disable-speller");
|
||||
#endif
|
||||
#ifdef DISABLE_HELP
|
||||
printf(" --disable-help");
|
||||
#endif
|
||||
#endif
|
||||
#ifdef DISABLE_SPELL
|
||||
printf(" --disable-spell");
|
||||
#endif
|
||||
|
||||
#ifdef USE_SLANG
|
||||
printf(" --with-slang");
|
||||
#endif
|
||||
@@ -479,7 +518,7 @@ void splice_node(filestruct * begin, filestruct * new, filestruct * end)
|
||||
int do_mark()
|
||||
{
|
||||
#ifdef NANO_SMALL
|
||||
nano_small_msg();
|
||||
nano_disabled_msg();
|
||||
#else
|
||||
if (!ISSET(MARK_ISSET)) {
|
||||
statusbar(_("Mark Set"));
|
||||
@@ -507,14 +546,7 @@ int no_help(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef NANO_SMALL
|
||||
void nano_small_msg(void)
|
||||
{
|
||||
statusbar("Sorry, this function not available with nano-tiny option");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELL)
|
||||
#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 +1062,6 @@ int do_backspace(void)
|
||||
if (strcmp(current->data, "")) {
|
||||
new_magicline();
|
||||
fix_editbot();
|
||||
totsize++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1102,7 +1133,7 @@ void wrap_reset(void)
|
||||
UNSET(SAMELINEWRAP);
|
||||
}
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_SPELL)
|
||||
#ifndef DISABLE_SPELLER
|
||||
|
||||
int do_int_spell_fix(char *word)
|
||||
{
|
||||
@@ -1168,9 +1199,6 @@ int do_int_spell_fix(char *word)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_SPELL)
|
||||
|
||||
/* Integrated spell checking using 'spell' program */
|
||||
int do_int_speller(char *tempfile_name)
|
||||
@@ -1298,9 +1326,6 @@ int do_int_speller(char *tempfile_name)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_SPELL)
|
||||
|
||||
/* External spell checking */
|
||||
int do_alt_speller(char *file_name)
|
||||
@@ -1352,10 +1377,7 @@ int do_alt_speller(char *file_name)
|
||||
int do_spell(void)
|
||||
{
|
||||
|
||||
#if defined(NANO_SMALL)
|
||||
nano_small_msg();
|
||||
return (TRUE);
|
||||
#elif defined(DISABLE_SPELL)
|
||||
#ifdef DISABLE_SPELLER
|
||||
nano_disabled_msg();
|
||||
return (TRUE);
|
||||
#else
|
||||
@@ -1411,7 +1433,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);
|
||||
@@ -1551,8 +1573,12 @@ void handle_sigwinch(int s)
|
||||
|
||||
center_x = COLS / 2;
|
||||
center_y = LINES / 2;
|
||||
editwinrows = LINES - 5 + no_help();
|
||||
fill = COLS - 8;
|
||||
|
||||
if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
|
||||
die_too_small();
|
||||
|
||||
if ((fill = COLS - CHARS_FROM_EOL) < MIN_FILL_LENGTH)
|
||||
die_too_small();
|
||||
|
||||
free(hblank);
|
||||
hblank = nmalloc(COLS + 1);
|
||||
@@ -1588,7 +1614,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();
|
||||
@@ -1625,7 +1651,8 @@ void signal_init(void)
|
||||
|
||||
void window_init(void)
|
||||
{
|
||||
editwinrows = LINES - 5 + no_help();
|
||||
if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
|
||||
die_too_small();
|
||||
|
||||
/* Setup up the main text window */
|
||||
edit = newwin(editwinrows, COLS, 2, 0);
|
||||
@@ -1633,6 +1660,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 +1675,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
|
||||
|
||||
@@ -1660,7 +1694,7 @@ int do_tab(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_JUSTIFY)
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
int empty_line(const char *data)
|
||||
{
|
||||
while (*data) {
|
||||
@@ -1712,15 +1746,12 @@ void justify_format(char *data)
|
||||
|
||||
int do_justify(void)
|
||||
{
|
||||
#ifdef NANO_SMALL
|
||||
nano_small_msg();
|
||||
return 1;
|
||||
#elif defined(DISABLE_JUSTIFY)
|
||||
#ifdef DISABLE_JUSTIFY
|
||||
nano_disabled_msg();
|
||||
return 1;
|
||||
#else
|
||||
int slen = 0; /* length of combined lines on one line. */
|
||||
int initial_y, kbinput;
|
||||
int initial_y, kbinput = 0;
|
||||
filestruct *initial = NULL, *tmpjust = NULL, *cutbak, *tmptop, *tmpbot;
|
||||
|
||||
if (empty_line(current->data)) {
|
||||
@@ -1787,8 +1818,6 @@ int do_justify(void)
|
||||
delete_node(tmpnode);
|
||||
}
|
||||
|
||||
totsize -= strlen(current->data);
|
||||
|
||||
justify_format(current->data);
|
||||
|
||||
slen = strlen(current->data);
|
||||
@@ -1898,16 +1927,16 @@ int do_justify(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef 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 +1957,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,10 +1995,13 @@ void help_init(void)
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void do_toggle(int which)
|
||||
{
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef NANO_SMALL
|
||||
nano_disabled_msg();
|
||||
#else
|
||||
char *enabled = _("enabled");
|
||||
char *disabled = _("disabled");
|
||||
|
||||
@@ -1993,6 +2025,7 @@ void do_toggle(int which)
|
||||
wclear(bottomwin);
|
||||
wrefresh(bottomwin);
|
||||
window_init();
|
||||
fix_editbot();
|
||||
edit_refresh();
|
||||
display_main_list();
|
||||
break;
|
||||
@@ -2013,18 +2046,47 @@ void do_toggle(int which)
|
||||
}
|
||||
SET(DISABLE_CURPOS);
|
||||
|
||||
#else
|
||||
nano_small_msg();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* If the NumLock key has made the keypad gone awry, print an error
|
||||
message, hopefully we can address it later. */
|
||||
void print_numlock_warning(void)
|
||||
{
|
||||
static int didmsg = 0;
|
||||
if (!didmsg) {
|
||||
statusbar(_("NumLock glitch detected. Keypad will malfunction with NumLock off"));
|
||||
didmsg = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function returns the correct keystroke, given the A,B,C or D
|
||||
input key. This is a common sequence of many terms which send
|
||||
Esc-O-[A-D] or Esc-[-[A-D]. */
|
||||
int ABCD(int input)
|
||||
{
|
||||
switch(input)
|
||||
{
|
||||
case 'A':
|
||||
return(KEY_UP);
|
||||
case 'B':
|
||||
return(KEY_DOWN);
|
||||
case 'C':
|
||||
return(KEY_RIGHT);
|
||||
case 'D':
|
||||
return(KEY_LEFT);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int optchr;
|
||||
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,12 +2104,15 @@ 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
|
||||
{"autoindent", 0, 0, 'i'},
|
||||
{"tempfile", 0, 0, 't'},
|
||||
#ifndef DISABLE_SPELLER
|
||||
{"speller", 1, 0, 's'},
|
||||
#endif
|
||||
{"fill", 1, 0, 'r'},
|
||||
{"mouse", 0, 0, 'm'},
|
||||
{"pico", 0, 0, 'p'},
|
||||
@@ -2067,10 +2132,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 +2154,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;
|
||||
@@ -2103,10 +2173,6 @@ int main(int argc, char *argv[])
|
||||
case 'k':
|
||||
SET(CUT_TO_END);
|
||||
break;
|
||||
#else
|
||||
case 'k':
|
||||
usage(); /* Oops! You dont really have that option */
|
||||
finish(1);
|
||||
#endif
|
||||
case 'l':
|
||||
UNSET(FOLLOW_SYMLINKS);
|
||||
@@ -2124,10 +2190,12 @@ int main(int argc, char *argv[])
|
||||
finish(1);
|
||||
}
|
||||
break;
|
||||
#ifndef DISABLE_SPELLER
|
||||
case 's':
|
||||
alt_speller = nmalloc(strlen(optarg) + 1);
|
||||
strcpy(alt_speller, optarg);
|
||||
break;
|
||||
#endif
|
||||
case 't':
|
||||
SET(TEMP_OPT);
|
||||
break;
|
||||
@@ -2158,19 +2226,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 +2259,14 @@ int main(int argc, char *argv[])
|
||||
nonl();
|
||||
cbreak();
|
||||
noecho();
|
||||
timeout(0);
|
||||
|
||||
/* Set up some global variables */
|
||||
global_init();
|
||||
shortcut_init(0);
|
||||
#ifndef DISABLE_HELP
|
||||
init_help_msg();
|
||||
help_init();
|
||||
#endif
|
||||
signal_init();
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -2207,12 +2276,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 +2286,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,12 +2311,19 @@ 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 ;) */
|
||||
case 79:
|
||||
kbinput = wgetch(edit);
|
||||
if (kbinput <= 'S' && kbinput >= 'P')
|
||||
if (kbinput <= 'D' && kbinput >= 'A')
|
||||
kbinput = ABCD(kbinput);
|
||||
else if (kbinput <= 'z' && kbinput >= 'j')
|
||||
print_numlock_warning();
|
||||
else if (kbinput <= 'S' && kbinput >= 'P')
|
||||
kbinput = KEY_F(kbinput - 79);
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
@@ -2263,8 +2333,13 @@ 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)) {
|
||||
case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */
|
||||
kbinput = wgetch(edit);
|
||||
@@ -2341,16 +2416,10 @@ int main(int argc, char *argv[])
|
||||
kbinput = KEY_F(kbinput - 64);
|
||||
break;
|
||||
case 'A':
|
||||
kbinput = KEY_UP;
|
||||
break;
|
||||
case 'B':
|
||||
kbinput = KEY_DOWN;
|
||||
break;
|
||||
case 'C':
|
||||
kbinput = KEY_RIGHT;
|
||||
break;
|
||||
case 'D':
|
||||
kbinput = KEY_LEFT;
|
||||
kbinput = ABCD(kbinput);
|
||||
break;
|
||||
case 'H':
|
||||
kbinput = KEY_HOME;
|
||||
@@ -2392,6 +2461,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 +2486,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 +2511,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 */
|
||||
|
||||
21
nano.h
21
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
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
#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
|
||||
@@ -259,4 +266,14 @@ know what you're doing */
|
||||
#define TOP 2
|
||||
#define CENTER 1
|
||||
#define BOTTOM 0
|
||||
#endif
|
||||
|
||||
/* Minimum editor window rows required for Nano to work correctly */
|
||||
#define MIN_EDITOR_ROWS 3
|
||||
|
||||
/* Default number of characters from end-of-line where text wrapping occurs */
|
||||
#define CHARS_FROM_EOL 8
|
||||
|
||||
/* Minimum fill length (space available for text before wrapping occurs) */
|
||||
#define MIN_FILL_LENGTH 10
|
||||
|
||||
#endif /* ifndef NANO_H */
|
||||
|
||||
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];
|
||||
#ifndef DISABLE_BROWSER
|
||||
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);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
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);
|
||||
|
||||
21
search.c
21
search.c
@@ -468,27 +468,6 @@ char *replace_line(void)
|
||||
return copy;
|
||||
}
|
||||
|
||||
/* highlight the current word being replaced or spell checked */
|
||||
void do_replace_highlight(int highlight_flag, char *word)
|
||||
{
|
||||
char *highlight_word = NULL;
|
||||
|
||||
highlight_word = mallocstrcpy(highlight_word, ¤t->data[current_x]);
|
||||
highlight_word[strlen(word)] = '\0';
|
||||
|
||||
reset_cursor();
|
||||
|
||||
if (highlight_flag)
|
||||
wattron(edit, A_REVERSE);
|
||||
|
||||
waddstr(edit, highlight_word);
|
||||
|
||||
if (highlight_flag)
|
||||
wattroff(edit, A_REVERSE);
|
||||
|
||||
free(highlight_word);
|
||||
}
|
||||
|
||||
/* step through each replace word and prompt user before replacing word */
|
||||
int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
||||
int wholewords, int *i)
|
||||
|
||||
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
|
||||
|
||||
139
winio.c
139
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);
|
||||
}
|
||||
}
|
||||
@@ -761,7 +771,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
|
||||
#endif
|
||||
/* Just paint the string (no mark on this line) */
|
||||
mvwaddnstr(edit, yval, 0, &fileptr->data[start],
|
||||
get_page_end_virtual(this_page) - start);
|
||||
get_page_end_virtual(this_page) - start + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -832,7 +842,7 @@ void update_line(filestruct * fileptr, int index)
|
||||
edit_add(filetmp, line, col, virt_cur_x, virt_mark_beginx, page);
|
||||
mvwaddch(edit, line, 0, '$');
|
||||
|
||||
if (strlenpt(fileptr->data) > get_page_end_virtual(page))
|
||||
if (strlenpt(fileptr->data) > get_page_end_virtual(page) + 1)
|
||||
mvwaddch(edit, line, COLS - 1, '$');
|
||||
} else {
|
||||
/* It's not the current line means that it's at x=0 and page=1 */
|
||||
@@ -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
|
||||
#ifndef 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,23 @@ 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
|
||||
nano_small_msg();
|
||||
kp = keypad_on(edit, kp);
|
||||
|
||||
#elif defined(DISABLE_HELP)
|
||||
nano_disabled_msg();
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -1331,6 +1336,40 @@ void fix_editbot(void)
|
||||
&& (editbot != filebot); i++, editbot = editbot->next);
|
||||
}
|
||||
|
||||
/* highlight the current word being replaced or spell checked */
|
||||
void do_replace_highlight(int highlight_flag, char *word)
|
||||
{
|
||||
char *highlight_word = NULL;
|
||||
int x, y;
|
||||
|
||||
highlight_word = mallocstrcpy(highlight_word, ¤t->data[current_x]);
|
||||
highlight_word[strlen(word)] = '\0';
|
||||
|
||||
/* adjust output when word extends beyond screen*/
|
||||
|
||||
x = xplustabs();
|
||||
y = get_page_end_virtual(get_page_from_virtual(x)) + 1;
|
||||
|
||||
if ((COLS - (y - x) + strlen(word)) > COLS) {
|
||||
highlight_word[y - x - 1] = '$';
|
||||
highlight_word[y - x] = '\0';
|
||||
}
|
||||
|
||||
/* OK display the output */
|
||||
|
||||
reset_cursor();
|
||||
|
||||
if (highlight_flag)
|
||||
wattron(edit, A_REVERSE);
|
||||
|
||||
waddstr(edit, highlight_word);
|
||||
|
||||
if (highlight_flag)
|
||||
wattroff(edit, A_REVERSE);
|
||||
|
||||
free(highlight_word);
|
||||
}
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
#define CREDIT_LEN 45
|
||||
void do_credits(void)
|
||||
@@ -1366,7 +1405,7 @@ void do_credits(void)
|
||||
"Tedi Heriyanto",
|
||||
"Bill Soudan",
|
||||
"Christian Weisgerber",
|
||||
"Erik Anderson",
|
||||
"Erik Andersen",
|
||||
"Big Gaute",
|
||||
"Joshua Jensen",
|
||||
"",
|
||||
@@ -1429,3 +1468,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