Compare commits
147 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bfbda0fd7 | ||
|
|
7ab3e8fed7 | ||
|
|
0a24b595a6 | ||
|
|
35dac58a61 | ||
|
|
10ae4f11e0 | ||
|
|
55493c2052 | ||
|
|
4aa302fe4a | ||
|
|
e31677362b | ||
|
|
a0323de1f7 | ||
|
|
0d471de448 | ||
|
|
e76f06ba1c | ||
|
|
565f7d5558 | ||
|
|
2af3904099 | ||
|
|
0b33d8864a | ||
|
|
74bb31b15a | ||
|
|
94a78b8fb3 | ||
|
|
1e9183fe31 | ||
|
|
46055b2543 | ||
|
|
53712748ec | ||
|
|
67b14b1467 | ||
|
|
203ce15247 | ||
|
|
5b387d7527 | ||
|
|
9c9c5dab4c | ||
|
|
a4a222d1d7 | ||
|
|
a18d7978e2 | ||
|
|
a7b2ed0cac | ||
|
|
78aac9113d | ||
|
|
f4a986465a | ||
|
|
a57fcb044c | ||
|
|
ea620fe88b | ||
|
|
0d9109acf6 | ||
|
|
2d6f1bc896 | ||
|
|
6aec0d6363 | ||
|
|
82b182986b | ||
|
|
8119765cbd | ||
|
|
618f5d788c | ||
|
|
4ce8e3b863 | ||
|
|
35ac99d0d4 | ||
|
|
c46dd8123c | ||
|
|
9560bb51ab | ||
|
|
882e145ebb | ||
|
|
fb9cffe268 | ||
|
|
8546fa016e | ||
|
|
7e7bcf8a46 | ||
|
|
4de7b95511 | ||
|
|
1bf501c236 | ||
|
|
af6414ac37 | ||
|
|
4ed131510e | ||
|
|
8bc03b6fdc | ||
|
|
b55999ebcb | ||
|
|
3362cae2f6 | ||
|
|
af7fc3dbc1 | ||
|
|
00ae5dfa27 | ||
|
|
d096f68966 | ||
|
|
09f39cbec6 | ||
|
|
a8785e0793 | ||
|
|
37388ee91e | ||
|
|
de48b41b61 | ||
|
|
7c1fee7868 | ||
|
|
34318edba2 | ||
|
|
90e040455d | ||
|
|
4e90c40e72 | ||
|
|
08020889d3 | ||
|
|
e434b45148 | ||
|
|
221a46e271 | ||
|
|
169ee8498e | ||
|
|
12de5ca7cf | ||
|
|
a711f7e638 | ||
|
|
2c2c5f2156 | ||
|
|
e5e4d49316 | ||
|
|
0a06e07831 | ||
|
|
17276e506e | ||
|
|
d4ddd014a3 | ||
|
|
ee733e6d4c | ||
|
|
60cd6aa04f | ||
|
|
7f7ce56e4e | ||
|
|
e9a2d03497 | ||
|
|
9d6f3f3f60 | ||
|
|
f0b26df170 | ||
|
|
17dcb7212f | ||
|
|
8d9b11a847 | ||
|
|
0fc2b81df8 | ||
|
|
76745fbe5f | ||
|
|
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 |
@@ -1,8 +1,10 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
confdefs.h
|
||||
config.cache
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
nano
|
||||
stamp-h
|
||||
|
||||
30
BUGS
30
BUGS
@@ -1,3 +1,6 @@
|
||||
- Marked cutting sometimes leaves a newline in the file unintelligently,
|
||||
such as when all of a line is selected but the mark doesn't proceed to
|
||||
the new line. (8) [FIXED/IRRELEVANT]
|
||||
- Certains are not lined up properly when there are tabs in them at
|
||||
certain col values. (9) [FIXED]
|
||||
- edit_refresh() and update_line() do not handle selecting text when the
|
||||
@@ -49,6 +52,7 @@
|
||||
[FIXED]
|
||||
- Using nano -t, user can not exit until a filename is given via ^O. (30)
|
||||
[FIXED]
|
||||
- totsize problems still abound in do_justify (33) [FIXED]
|
||||
- Using -k cut text is not pasted properly. (34) [FIXED].
|
||||
- Using -k pasted text is not updated properly if it goes beyond editbot. (35)
|
||||
[FIXED]
|
||||
@@ -78,12 +82,28 @@
|
||||
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]
|
||||
- Resizing the window completely screws up the display if in any other
|
||||
mode than normal editing (help screen, search and replace, file
|
||||
browser..) (52) [FIXED]
|
||||
- Alt speller argument (-s, --speller) does not take a string argument of
|
||||
more than one word. (53) [FIXED].
|
||||
- Cut to end cutting (-k) causes segfaults (try cutting "- Backup making
|
||||
(filename~)?" line in TODO file) (discovered by
|
||||
higuita@cadernoverde.com) (54) [FIXED].
|
||||
- When using autoindent (-i), wrapped text does not get auto-indented
|
||||
(55, discovered by Mark Senior) [FIXED].
|
||||
- When using -R (regex) and -p (pico mode), subsequent searches after
|
||||
the first fail if no string is entered (56) [FIXED].
|
||||
- Page down on a file of editwinrows fails (again). Reported by Ryan
|
||||
Krebs (57) [FIXED].
|
||||
|
||||
** Open BUGS **
|
||||
|
||||
- Marked cutting sometimes leaves a newline in the file unintelligently,
|
||||
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).
|
||||
|
||||
$Id$
|
||||
|
||||
245
ChangeLog
245
ChangeLog
@@ -1,3 +1,248 @@
|
||||
nano-1.0.0 - 03/22/2001
|
||||
- General
|
||||
- Added void to functions declared as () args, nano.c:do_mark()
|
||||
and search.c:regexp_cleanup(). (Christian Weisgerber).
|
||||
- Changed internal variables called "new" to "newnode" to avoid
|
||||
the "new" C++ reserved word, even though there is likely no way
|
||||
nano will EVER be compilable with a C++ compiler. (suggested by
|
||||
Rocco Corsi).
|
||||
- aclocal.m4:
|
||||
- Minor patch for intl check (Christian Weisgerber)
|
||||
- ca.po, es.po:
|
||||
- Final tweaks for Nano 1.0.
|
||||
- cs.po:
|
||||
- Czech translation from Vaclav Haisman.
|
||||
- nano.info:
|
||||
- Added dir entry (Albert Chin).
|
||||
- winio.c:
|
||||
statusq()
|
||||
- Added NANO_BACK_KEY and NANO_FORWARD_KEY cases for left and right.
|
||||
|
||||
1.0-test prerelease - 03/17/2001
|
||||
- nano.c:
|
||||
do_wrap()
|
||||
- Added case for autoindenting text causing new line (Adam).
|
||||
- Added SAMELINE case to above. Added checks to cases 1b and
|
||||
2b for placement of cursor.
|
||||
- move.c:
|
||||
page_down()
|
||||
- Check for totlines < editwinrows in check for superflous
|
||||
edit update (fixed BUG #57).
|
||||
- search.c:
|
||||
print_replaced()
|
||||
- s/occurence/occurrence typos (Jordi).
|
||||
search_init()
|
||||
- If using Pico mode and regex and same answer is entered, use
|
||||
last_search string instead of answer (fixes BUG #56).
|
||||
- nano.texi:
|
||||
- Meta-Z correction and grammar in --enable-tiny desc (Neil Parks).
|
||||
|
||||
nano-0.9.99pre3 - 02/19/2001
|
||||
- General
|
||||
GNU compliance issues:
|
||||
- Reworked shortcut list, put "Get Help" into default list,
|
||||
removed "Goto Line", aligned "Read File" with "Write Out" and
|
||||
"Replace" with "Where is" for consistency.
|
||||
- Added texinfo manual nano.texi. Added texi options to
|
||||
Makefile.am.
|
||||
- configure.in:
|
||||
- Autoconf compatibility fixes (Pavel Roskin)
|
||||
- Added separate check for resizeterm().
|
||||
- ALL_LINGUAS: added hu and ca.
|
||||
- cut.c:
|
||||
do_cut_text()
|
||||
- marked text cut fixes (Rocco) (Fixes bug #54).
|
||||
- nano.c:
|
||||
do_delete()
|
||||
- Added check for current->next == fileptr, as we have a magic
|
||||
line code again, fixes sillyness at the end of the last line
|
||||
before the magic line (reported by J.A. Neitzel).
|
||||
do_justify()
|
||||
- If the keystroke after the justify is not the unjustify key,
|
||||
blank the statsubar (bug reported by Neil Parks).
|
||||
main()
|
||||
- Added ENABLE_NLS check around gettext stuff.
|
||||
- winio.c:
|
||||
do_yesno()
|
||||
- Added localized yes, no and all strings to function and rewrote
|
||||
handler for the new format.
|
||||
- de.po:
|
||||
- Translation updates by Florian König.
|
||||
- fi.po:
|
||||
- Translation updates by Pauli Virtanen.
|
||||
- hu.po:
|
||||
- Hungarian translation by Horvath Szabolcs.
|
||||
- id.po:
|
||||
- Translation updates by Tedi Heriyanto.
|
||||
- es.po:
|
||||
- Translation updates and grammatical/typo fixes (Jordi).
|
||||
- ca.po:
|
||||
- Catalan translation by Jordi Mallach :)
|
||||
- Miquel Vidal <miquel@sindominio.net> went over it and corrected
|
||||
many typos and completed bits that remained untranslated by error.
|
||||
|
||||
nano-0.9.99pre2 - 01/31/2001
|
||||
General
|
||||
- Removed center_x and center_y globals. center_y was
|
||||
completely unused and center_x was only used a few places,
|
||||
easily replaced with COLS / 2 (oops, not current_x & y (Rob)).
|
||||
- Deleted free_node, duplicate of delete_node, and changed all
|
||||
free_node calls to delete_node.
|
||||
- Fix for resizing the window in modes other than normal edit mode
|
||||
Changes to handle_sigwinch(), main(). Fixes bug #52 (Rocco).
|
||||
- files.c:
|
||||
write_file()
|
||||
- Don't free() realname on error, if it needs to be free()d later
|
||||
it will be (fixes crash on successful write after failed write,
|
||||
discovered by David Sobon).
|
||||
username_tab_completion()
|
||||
- Optimization and removal of useless vars (Rocco).
|
||||
- Rewritten using getpwent (suggested by Rocco).
|
||||
- Removed redundant conditional (Rocco).
|
||||
real_dir_from_tilde()
|
||||
- Rewritten using getpwent (suggested by Adam, much optimized by Rocco).
|
||||
- global.c:
|
||||
- Don't define toggles global or toggle_init_one if using --tiny.
|
||||
- nano.c:
|
||||
do_justify()
|
||||
- Added restoration of totsize after unjustify command.
|
||||
usage()
|
||||
- Add arg to -T help (Rocco).
|
||||
global_init(), handle_sigwinch()
|
||||
- Messy loops replaced with memset calls (Rocco).
|
||||
do_alt_speller()
|
||||
- Added code to parse multi-word alt_speller strings.
|
||||
- Fix initialization before fork() (Rocco).
|
||||
- proto.h:
|
||||
- Fix do_credits() proto (oops!)
|
||||
- winio.c:
|
||||
nanogetstr()
|
||||
- Sanity check for x overrunning the string buffer len.
|
||||
|
||||
nano 0.9.99pre1 - 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),
|
||||
|
||||
@@ -14,6 +14,9 @@ nano_SOURCES = cut.c \
|
||||
man_MANS = nano.1
|
||||
nano_LDADD = @INTLLIBS@
|
||||
|
||||
info_TEXINFOS = nano.texi
|
||||
MAKEINFO = makeinfo --no-split
|
||||
|
||||
EXTRA_DIST = AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README \
|
||||
TODO install-sh missing mkinstalldirs nano.1 nano.1.html \
|
||||
faq.html
|
||||
|
||||
161
Makefile.in
161
Makefile.in
@@ -75,7 +75,6 @@ INSTOBJEXT = @INSTOBJEXT@
|
||||
INTLDEPS = @INTLDEPS@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTLOBJS = @INTLOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
PACKAGE = @PACKAGE@
|
||||
@@ -94,6 +93,9 @@ nano_SOURCES = cut.c files.c global.c move.c nano.c nano.h proto.h
|
||||
man_MANS = nano.1
|
||||
nano_LDADD = @INTLLIBS@
|
||||
|
||||
info_TEXINFOS = nano.texi
|
||||
MAKEINFO = makeinfo --no-split
|
||||
|
||||
EXTRA_DIST = AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README TODO install-sh missing mkinstalldirs nano.1 nano.1.html faq.html
|
||||
|
||||
|
||||
@@ -120,13 +122,18 @@ CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
TEXI2DVI = texi2dvi
|
||||
INFO_DEPS = nano.info
|
||||
DVIS = nano.dvi
|
||||
TEXINFOS = nano.texi
|
||||
man1dir = $(mandir)/man1
|
||||
MANS = $(man_MANS)
|
||||
|
||||
NROFF = nroff
|
||||
DIST_COMMON = README ./stamp-h.in ABOUT-NLS AUTHORS COPYING ChangeLog \
|
||||
INSTALL Makefile.am Makefile.in NEWS TODO acconfig.h aclocal.m4 \
|
||||
config.h.in configure configure.in install-sh missing mkinstalldirs
|
||||
config.h.in configure configure.in install-sh missing mkinstalldirs \
|
||||
texinfo.tex
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
@@ -138,7 +145,7 @@ OBJECTS = $(nano_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .o .s
|
||||
.SUFFIXES: .S .c .dvi .info .o .ps .s .texi .texinfo .txi
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile
|
||||
|
||||
@@ -230,6 +237,122 @@ nano: $(nano_OBJECTS) $(nano_DEPENDENCIES)
|
||||
@rm -f nano
|
||||
$(LINK) $(nano_LDFLAGS) $(nano_OBJECTS) $(nano_LDADD) $(LIBS)
|
||||
|
||||
nano.info: nano.texi
|
||||
nano.dvi: nano.texi
|
||||
|
||||
|
||||
DVIPS = dvips
|
||||
|
||||
.texi.info:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texi.dvi:
|
||||
TEXINPUTS=.:$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
|
||||
.texi:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texinfo.info:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texinfo:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.texinfo.dvi:
|
||||
TEXINPUTS=.:$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
|
||||
.txi.info:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
|
||||
.txi.dvi:
|
||||
TEXINPUTS=.:$$TEXINPUTS \
|
||||
MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
|
||||
|
||||
.txi:
|
||||
@cd $(srcdir) && rm -f $@ $@-[0-9] $@-[0-9][0-9]
|
||||
cd $(srcdir) \
|
||||
&& $(MAKEINFO) `echo $< | sed 's,.*/,,'`
|
||||
.dvi.ps:
|
||||
$(DVIPS) $< -o $@
|
||||
|
||||
install-info-am: $(INFO_DEPS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(infodir)
|
||||
@list='$(INFO_DEPS)'; \
|
||||
for file in $$list; do \
|
||||
d=$(srcdir); \
|
||||
for ifile in `cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \
|
||||
if test -f $$d/$$ifile; then \
|
||||
echo " $(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; \
|
||||
$(INSTALL_DATA) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; \
|
||||
else : ; fi; \
|
||||
done; \
|
||||
done
|
||||
@$(POST_INSTALL)
|
||||
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
|
||||
list='$(INFO_DEPS)'; \
|
||||
for file in $$list; do \
|
||||
echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\
|
||||
install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file || :;\
|
||||
done; \
|
||||
else : ; fi
|
||||
|
||||
uninstall-info:
|
||||
$(PRE_UNINSTALL)
|
||||
@if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
|
||||
ii=yes; \
|
||||
else ii=; fi; \
|
||||
list='$(INFO_DEPS)'; \
|
||||
for file in $$list; do \
|
||||
test -z "$ii" \
|
||||
|| install-info --info-dir=$(DESTDIR)$(infodir) --remove $$file; \
|
||||
done
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(INFO_DEPS)'; \
|
||||
for file in $$list; do \
|
||||
(cd $(DESTDIR)$(infodir) && rm -f $$file $$file-[0-9] $$file-[0-9][0-9]); \
|
||||
done
|
||||
|
||||
dist-info: $(INFO_DEPS)
|
||||
list='$(INFO_DEPS)'; \
|
||||
for base in $$list; do \
|
||||
d=$(srcdir); \
|
||||
for file in `cd $$d && eval echo $$base*`; do \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file; \
|
||||
done; \
|
||||
done
|
||||
|
||||
mostlyclean-aminfo:
|
||||
-rm -f nano.aux nano.cp nano.cps nano.dvi nano.fn nano.fns nano.ky \
|
||||
nano.kys nano.ps nano.log nano.pg nano.toc nano.tp nano.tps \
|
||||
nano.vr nano.vrs nano.op nano.tr nano.cv nano.cn
|
||||
|
||||
clean-aminfo:
|
||||
|
||||
distclean-aminfo:
|
||||
|
||||
maintainer-clean-aminfo:
|
||||
cd $(srcdir) && for i in $(INFO_DEPS); do \
|
||||
rm -f $$i; \
|
||||
if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then \
|
||||
rm -f $$i-[0-9]*; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
install-man1:
|
||||
$(mkinstalldirs) $(DESTDIR)$(man1dir)
|
||||
@list='$(man1_MANS)'; \
|
||||
@@ -416,9 +539,10 @@ distdir: $(DISTFILES)
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
info-am:
|
||||
$(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-info
|
||||
info-am: $(INFO_DEPS)
|
||||
info: info-recursive
|
||||
dvi-am:
|
||||
dvi-am: $(DVIS)
|
||||
dvi: dvi-recursive
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
@@ -430,21 +554,22 @@ all-recursive-am: config.h
|
||||
install-exec-am: install-binPROGRAMS
|
||||
install-exec: install-exec-recursive
|
||||
|
||||
install-data-am: install-man
|
||||
install-data-am: install-info-am install-man
|
||||
install-data: install-data-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-recursive
|
||||
uninstall-am: uninstall-binPROGRAMS uninstall-man
|
||||
uninstall-am: uninstall-binPROGRAMS uninstall-info uninstall-man
|
||||
uninstall: uninstall-recursive
|
||||
all-am: Makefile $(PROGRAMS) $(MANS) config.h
|
||||
all-am: Makefile $(INFO_DEPS) $(PROGRAMS) $(MANS) config.h
|
||||
all-redirect: all-recursive-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
|
||||
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(infodir) \
|
||||
$(DESTDIR)$(mandir)/man1
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
@@ -457,25 +582,27 @@ distclean-generic:
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \
|
||||
mostlyclean-compile mostlyclean-tags \
|
||||
mostlyclean-compile mostlyclean-aminfo mostlyclean-tags \
|
||||
mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
clean-am: clean-hdr clean-binPROGRAMS clean-compile clean-tags \
|
||||
clean-generic mostlyclean-am
|
||||
clean-am: clean-hdr clean-binPROGRAMS clean-compile clean-aminfo \
|
||||
clean-tags clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-recursive
|
||||
|
||||
distclean-am: distclean-hdr distclean-binPROGRAMS distclean-compile \
|
||||
distclean-tags distclean-generic clean-am
|
||||
distclean-aminfo distclean-tags distclean-generic \
|
||||
clean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
-rm -f config.status
|
||||
|
||||
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-binPROGRAMS \
|
||||
maintainer-clean-compile maintainer-clean-tags \
|
||||
maintainer-clean-generic distclean-am
|
||||
maintainer-clean-compile maintainer-clean-aminfo \
|
||||
maintainer-clean-tags maintainer-clean-generic \
|
||||
distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
@@ -486,7 +613,9 @@ maintainer-clean: maintainer-clean-recursive
|
||||
mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
|
||||
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile install-man1 uninstall-man1 install-man \
|
||||
maintainer-clean-compile install-info-am uninstall-info \
|
||||
mostlyclean-aminfo distclean-aminfo clean-aminfo \
|
||||
maintainer-clean-aminfo install-man1 uninstall-man1 install-man \
|
||||
uninstall-man install-data-recursive uninstall-data-recursive \
|
||||
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
|
||||
uninstalldirs-recursive all-recursive check-recursive \
|
||||
|
||||
53
NEWS
53
NEWS
@@ -1,3 +1,56 @@
|
||||
03/22/2001 - GNU Nano 1.0 is released! The autoindent wrapping bug
|
||||
has been fixed, as well as strange bug when using Pico
|
||||
mode and regex search. There have also been some minor
|
||||
spelling and documentation updates. As stated on the
|
||||
website, there are currently no known bugs with nano, but
|
||||
some will pop up eventually and they will be addressed in
|
||||
subsequent releases. We hope you enjoy this first stable
|
||||
release of nano, and as always, feedback is welcome!
|
||||
nano@nano-editor.org.
|
||||
|
||||
02/19/2001 - Nano 0.9.99pre3 brings a lot of changes! The most important
|
||||
being that nano is now officially a GNU program. Some
|
||||
changes have been made for GNU compatibility (like the
|
||||
default list of shortcuts, "^G Get Help" is now Listed and
|
||||
"^_ Goto Line" is not). The Yes/No/All keys have
|
||||
finally been internationalized also. All in all, quite
|
||||
a few changes considering nano is supposed to be in a code
|
||||
freeze. But there are the usual helping of bugfixes, a
|
||||
nasty bug when cutting text in -k mode and some
|
||||
compatibility with older ncurses libraries have also been
|
||||
fixed. All in all, a lot to see.
|
||||
|
||||
01/31/2001 - Nano 0.9.99pre2 is released. Not surprisingly, all that is
|
||||
new is bugfixes, bugfixes, bugfixes. There were a few
|
||||
cleanups in unneeded global variables and duplicate
|
||||
functions, but most is just fixing. Specifically, there
|
||||
is now a preliminary (read: needs testing) fix for
|
||||
resizing the editor in any mode other than normal edit
|
||||
mode. Other fixes include some more tab completion
|
||||
segfaults, and an silly segfault that occurred when
|
||||
successfully writing a file on the 2nd try (i.e. after an
|
||||
initial write error). Slowly but surely, on toward 1.0 we
|
||||
travel.
|
||||
|
||||
01/17/2001 - Nano 0.9.99pre1 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
|
||||
|
||||
64
README
64
README
@@ -1,29 +1,24 @@
|
||||
|
||||
The nano editor (Nano's ANOther editor) by Chris Allegretta
|
||||
GNU nano - an 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.
|
||||
|
||||
The nano editor is now an official GNU package. For more information
|
||||
on GNU and the Free Software Foundation please see http://www.gnu.org.
|
||||
|
||||
How to compile and install nano
|
||||
|
||||
@@ -34,8 +29,8 @@ How to compile and install nano
|
||||
make
|
||||
make install
|
||||
|
||||
It's that simple. Use --prefix to override the default installation
|
||||
directory of /usr/local.
|
||||
It's that simple. Use --prefix with configutr to override the
|
||||
default installation directory of /usr/local.
|
||||
|
||||
Web Page
|
||||
|
||||
@@ -58,27 +53,12 @@ Mailing List and Bug Reports
|
||||
|
||||
Current Status
|
||||
|
||||
nano is currently at version 0.9.x, and it will probably remain there
|
||||
for awhile. This reflects the adage that the last 10% of a project
|
||||
takes 90% of the time. Version 1.0 will be released when there are
|
||||
no unresolved bugs, and not before. I am also currently looking for
|
||||
patches for all things listed in the TODO file. If you have a
|
||||
comment or suggestion, please let me know, all help is appreciated.
|
||||
GNU nano has finally reached its first stable release (1.0).
|
||||
The development tree will fork soon and it will be called 1.1.x,
|
||||
in the Linux kernel naming style. Many thanks to all of our
|
||||
bug reporters and contributors of code to get nano where it is
|
||||
today.
|
||||
|
||||
Warning: This program can and possibly will corrupt your data in
|
||||
its current form! It is beta software, so treat it as such!
|
||||
Thank you.
|
||||
|
||||
Note that the primary aim of nano is to emulate Pico while adding a
|
||||
few key "missing" features. I do NOT want just a GPL'ed Pico clone,
|
||||
nor do I want something that strays too far from the Pico design
|
||||
(simple and straightforward). If you don't like this, feel free to
|
||||
fork my code at any time, but please call your editor something
|
||||
else, believe it or not I struggled awhile before coming up with
|
||||
the name nano (and before that TIP), and it would be much easier for
|
||||
everyone if there weren't five versions of the same program. As you
|
||||
can guess, I'm not much of an emacs fan ;)
|
||||
|
||||
Chris Allegretta (chrisa@asty.org)
|
||||
|
||||
$Id$
|
||||
|
||||
4
TODO
4
TODO
@@ -20,8 +20,10 @@ 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~)?
|
||||
- Search (etc) string history [1.1]
|
||||
|
||||
$Id$
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
/* Define this if you have the wresize function in your ncurses-type library */
|
||||
#undef HAVE_WRESIZE
|
||||
|
||||
/* Define this if you have the resizeterm function in your ncurses-type library */
|
||||
#undef HAVE_RESIZETERM
|
||||
|
||||
/* Define this if your curses lib has the _use_keypad flag */
|
||||
#undef HAVE_USEKEYPAD
|
||||
|
||||
/* Define this if you have NLS */
|
||||
#undef ENABLE_NLS
|
||||
|
||||
@@ -39,3 +45,5 @@
|
||||
/* Define this to disable the ^G help menu */
|
||||
#undef DISABLE_HELP
|
||||
|
||||
/* Define this to disable the built-in (crappy) file browser */
|
||||
#undef DISABLE_BROWSER
|
||||
|
||||
@@ -55,6 +55,12 @@
|
||||
/* Define this if you have the wresize function in your ncurses-type library */
|
||||
#undef HAVE_WRESIZE
|
||||
|
||||
/* Define this if you have the resizeterm function in your ncurses-type library */
|
||||
#undef HAVE_RESIZETERM
|
||||
|
||||
/* Define this if your curses lib has the _use_keypad flag */
|
||||
#undef HAVE_USEKEYPAD
|
||||
|
||||
/* Define this if you have NLS */
|
||||
#undef ENABLE_NLS
|
||||
|
||||
@@ -91,6 +97,9 @@
|
||||
/* 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
|
||||
|
||||
|
||||
60
configure.in
60
configure.in
@@ -1,9 +1,9 @@
|
||||
# $Id$
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(nano.c)
|
||||
AM_INIT_AUTOMAKE(nano, 0.9.24)
|
||||
AM_INIT_AUTOMAKE(nano, 1.0.0)
|
||||
AM_CONFIG_HEADER(config.h:config.h.in)
|
||||
ALL_LINGUAS="es de fr it id fi"
|
||||
ALL_LINGUAS="es de fr it id fi hu ca cs"
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
@@ -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,
|
||||
@@ -51,7 +56,13 @@ AC_ARG_ENABLE(help,
|
||||
AC_DEFINE(DISABLE_HELP)
|
||||
fi])
|
||||
|
||||
AC_MSG_CHECKING(whether to use slang)
|
||||
AC_ARG_ENABLE(browser,
|
||||
[ --disable-browser Disables mini file browser],
|
||||
[if test x$enableval != xyes; then
|
||||
AC_DEFINE(DISABLE_BROWSER)
|
||||
fi])
|
||||
|
||||
AC_MSG_CHECKING([whether to use slang])
|
||||
CURSES_LIB_NAME=""
|
||||
AC_ARG_WITH(slang,
|
||||
[ --with-slang[=DIR] Use the slang library instead of curses],
|
||||
@@ -69,7 +80,7 @@ AC_ARG_WITH(slang,
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADER(slcurses.h,
|
||||
AC_MSG_CHECKING(for SLtt_initialize in -lslang)
|
||||
AC_MSG_CHECKING([for SLtt_initialize in -lslang])
|
||||
_libs=$LIBS
|
||||
LIBS="$LIBS -lslang"
|
||||
AC_TRY_RUN([
|
||||
@@ -88,11 +99,11 @@ int main () { SLtt_initialize (NULL); return 0; }],
|
||||
AC_MSG_RESULT(no)
|
||||
# We might need the term library
|
||||
for termlib in ncurses curses termcap terminfo termlib; do
|
||||
AC_CHECK_LIB(${termlib}, tputs, [tcap="-l$termlib"])
|
||||
AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
|
||||
test -n "$tcap" && break
|
||||
done
|
||||
|
||||
AC_MSG_CHECKING(for SLtt_initialize in -lslang $tcap)
|
||||
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
|
||||
LIBS="$LIBS $tcap"
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
@@ -109,7 +120,7 @@ int main () { SLtt_initialize (NULL); return 0; }],
|
||||
CURSES_LIB_NAME=slang], [
|
||||
AC_MSG_RESULT(no)
|
||||
# We might need the math library
|
||||
AC_MSG_CHECKING(for SLtt_initialize in -lslang $tcap -lm)
|
||||
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
|
||||
LIBS="$LIBS -lm"
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
@@ -141,17 +152,17 @@ AC_MSG_WARN([*** Can not use slang when cross-compiling])),
|
||||
LDFLAGS=${_ldflags}
|
||||
fi
|
||||
;;
|
||||
esac], AC_MSG_RESULT(no))
|
||||
esac], [AC_MSG_RESULT(no)])
|
||||
|
||||
dnl Checks for functions
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf)
|
||||
if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
|
||||
then
|
||||
AM_PATH_GLIB(1.2.4,,
|
||||
AC_MSG_ERROR([
|
||||
[AC_MSG_ERROR([
|
||||
*** snprintf() and/or vsnprintf() not found. GLIB not found either.
|
||||
*** You need both snprintf() and vsnprintf(). Alternatively you can
|
||||
*** install the GLIB library which can be found at ftp://ftp.gtk.org/.]),
|
||||
*** install the GLIB library which can be found at ftp://ftp.gtk.org/.])],
|
||||
glib)
|
||||
glib_cflags=`$GLIB_CONFIG --cflags glib`
|
||||
glib_libs=`$GLIB_CONFIG --libs glib`
|
||||
@@ -170,23 +181,23 @@ dnl Checks for libraries.
|
||||
if eval "test x$CURSES_LIB_NAME = x"
|
||||
then
|
||||
AC_CHECK_HEADERS(curses.h ncurses.h)
|
||||
AC_CHECK_LIB(ncurses, tgetent,CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses)
|
||||
AC_CHECK_LIB(ncurses, tgetent, [CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses])
|
||||
fi
|
||||
|
||||
if eval "test x$CURSES_LIB_NAME = x"
|
||||
then
|
||||
AC_CHECK_LIB(curses, tgetent, CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses)
|
||||
AC_CHECK_LIB(curses, tgetent, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
|
||||
fi
|
||||
|
||||
# Fallback for PDCurses and less useful curses libs...
|
||||
if eval "test x$CURSES_LIB_NAME = x"
|
||||
then
|
||||
AC_CHECK_LIB(curses, initscr, CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses)
|
||||
AC_CHECK_LIB(curses, initscr, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses])
|
||||
fi
|
||||
|
||||
if eval "test x$CURSES_LIB_NAME = x"
|
||||
then
|
||||
AC_CHECK_LIB(termcap, tgetent, CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap)
|
||||
AC_CHECK_LIB(termcap, tgetent, [CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap])
|
||||
fi
|
||||
|
||||
if eval "test x$CURSES_LIB_NAME = x"
|
||||
@@ -196,11 +207,28 @@ then
|
||||
*** distribution from ftp://ftp.gnu.org/pub/gnu/ncurses if you get
|
||||
*** errors compiling nano.])
|
||||
else
|
||||
AC_MSG_RESULT("Using $CURSES_LIB_NAME as the termcap library")
|
||||
AC_MSG_RESULT([Using $CURSES_LIB_NAME as the termcap library])
|
||||
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)])
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], resizeterm, [AC_DEFINE(HAVE_RESIZETERM)])
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
11
cut.c
11
cut.c
@@ -174,24 +174,23 @@ int do_cut_text(void)
|
||||
if (ISSET(MARK_ISSET)) {
|
||||
if (current->lineno == mark_beginbuf->lineno) {
|
||||
tmp = copy_node(current);
|
||||
newsize = abs(strlen(¤t->data[mark_beginx]) -
|
||||
strlen(¤t->data[current_x]));
|
||||
newsize = abs(mark_beginx - current_x) + 1;
|
||||
|
||||
tmpstr = nmalloc(newsize);
|
||||
tmpstr = nmalloc(newsize + 1);
|
||||
if (current_x < mark_beginx) {
|
||||
strncpy(tmpstr, ¤t->data[current_x], newsize);
|
||||
memmove(¤t->data[current_x],
|
||||
¤t->data[mark_beginx],
|
||||
strlen(¤t->data[mark_beginx] - newsize));
|
||||
strlen(¤t->data[mark_beginx]) + 1);
|
||||
} else {
|
||||
strncpy(tmpstr, ¤t->data[mark_beginx], newsize);
|
||||
memmove(¤t->data[mark_beginx],
|
||||
¤t->data[current_x],
|
||||
strlen(¤t->data[current_x] - newsize));
|
||||
strlen(¤t->data[current_x]) + 1);
|
||||
current_x = mark_beginx;
|
||||
update_cursor();
|
||||
}
|
||||
tmpstr[newsize] = 0;
|
||||
tmpstr[newsize - 1] = 0;
|
||||
tmp->data = tmpstr;
|
||||
add_to_cutbuffer(tmp);
|
||||
dump_buffer(cutbuffer);
|
||||
|
||||
137
faq.html
137
faq.html
@@ -1,5 +1,6 @@
|
||||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<title>The GNU 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]">
|
||||
@@ -16,7 +17,7 @@
|
||||
|
||||
<blockquote><font color="#330000"><a href="#1.1">1.1 About this FAQ.</a></font>
|
||||
<br><font color="#330000"><a href="#1.2">1.2. How do I contribute to it?</a></font>
|
||||
<br><font color="#330000"><a href="#1.3">1.3. What is nano?</a></font>
|
||||
<br><font color="#330000"><a href="#1.3">1.3. What is GNU nano?</a></font>
|
||||
<br><font color="#330000"><a href="#1.4">1.4. What is the history behind
|
||||
nano?</a></font>
|
||||
<br><font color="#330000"><a href="#1.5">1.5. Why the name change from
|
||||
@@ -27,7 +28,8 @@ of nano?</a></font>
|
||||
without having to download the program!</a></font></blockquote>
|
||||
|
||||
<h2>
|
||||
<font color="#330000"><a href="#2">2. Where to get nano</a></font></h2>
|
||||
<font color="#330000"><a href="#2">2. Where to get GNU
|
||||
nano</a></font></h2>
|
||||
|
||||
<blockquote><font color="#330000"><a href="#2.1">2.1. FTP and WWW sites
|
||||
that carry nano.</a></font>
|
||||
@@ -48,7 +50,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 +68,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>
|
||||
@@ -128,13 +135,13 @@ href="mailto:nano@nano-editor.org">nano@nano-editor.org</a> and if
|
||||
it is useful enough it will be included in future versions.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="1.3"></a><font color="#330000">1.3. What is nano?</font></h2>
|
||||
<a NAME="1.3"></a><font color="#330000">1.3. What is GNU nano?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">Nano is designed to be a free replacement
|
||||
for the Pico text editor, part of the PINE email suite from <a href="http://www.washington.edu/pine">The
|
||||
University of Washington</a>. It aims to "emulate Pico as closely
|
||||
as possible and perhaps include extra functionality WITHOUT breaking compatibility
|
||||
with Pico.</font></blockquote>
|
||||
<blockquote><font color="#330000">GNU Nano is designed to be a free
|
||||
replacement for the Pico text editor, part of the PINE email suite from <a
|
||||
href="http://www.washington.edu/pine">The University of
|
||||
Washington</a>. It aims to "emulate Pico as closely as possible and
|
||||
perhaps include extra functionality.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="1.4"></a><font color="#330000">1.4. What is the history behind
|
||||
@@ -146,7 +153,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>
|
||||
@@ -171,7 +178,11 @@ and hacked like a madman for many hours straight one weekend to make a
|
||||
The program could not be invoked without a filename, could not save files,
|
||||
had no help menu, spell checker, and so forth. But over time it improved,
|
||||
and with the help of a few great coders it matured to the almost stable
|
||||
state it is today.</font></blockquote>
|
||||
state it is today.
|
||||
<p><font color="#330000">In February 2001, nano has been declared an
|
||||
official GNU program by Richard Stallman. Nano is also nearing its 1.0
|
||||
release as of this writing (Valentine's Day 2001).
|
||||
</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="1.5"></a><font color="#330000">1.5. Why the name change from TIP?</font></h2>
|
||||
@@ -181,7 +192,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 +200,7 @@ nano was developed).</font></blockquote>
|
||||
of nano?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">The current version of nano *should*
|
||||
be 0.9.24. Of course you should always check the nano hompage to
|
||||
be 1.0.0. Of course you should always check the nano hompage to
|
||||
see what the latest and greatest version is.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -201,7 +212,7 @@ Okay, look <a href="http://www.nano-editor.org/dist/nano.1.html">here</a>.</font
|
||||
|
||||
<hr WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="2"></a><font color="#330000">2. Where to get nano</font></h1>
|
||||
<a NAME="2"></a><font color="#330000">2. Where to get GNU nano</font></h1>
|
||||
|
||||
<h2>
|
||||
<a NAME="2.1"></a><font color="#330000">2.1. FTP and WWW sites that carry
|
||||
@@ -294,7 +305,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 +321,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 +352,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 disables 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 +403,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
|
||||
@@ -396,7 +431,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="mailto: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
|
||||
@@ -467,34 +521,33 @@ of personal preference as to which editor you should use. If you're
|
||||
the type of person who likes using the original version of a program, then
|
||||
Pico is the editor for you. If you're looking for a few more
|
||||
features and a 'better' license as far as adding your own changes (sacrificing
|
||||
mailer integration and a little stability), nano is the way to go.</blockquote>
|
||||
mailer integration and a little stability), nano is the way to go.
|
||||
</blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="6.3"></a><font color="#330000">6.3. What is so bad about the PINE
|
||||
license?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">Technically there is nothing "wrong"
|
||||
with the U of W license for Pine and Pico. However, it is not
|
||||
considered truly "free" according to the <a href="http://www.debian.org/social_contract#guidelines">Debian
|
||||
Free Software Guidelines</a>. The only real problem as far as I'm
|
||||
aware as that there are limitations on the redistribution of programs based
|
||||
on the Pine and Pico source. So at a real nitty gritty level,
|
||||
these programs are not considered Free Software. This is why Pico
|
||||
isn't distributed in binary form in debian, and hence one of the main reasons
|
||||
nano was started.</font></blockquote>
|
||||
<blockquote><font color="#330000">The U of W license for Pine and
|
||||
Pico is not considered truly Free Software according to both the Free
|
||||
Software Foundation and the the <a
|
||||
href="http://www.debian.org/social_contract#guidelines">Debian
|
||||
Free Software Guidelines</a>. The main problem regards the
|
||||
limitations on distributing derived works: according to UW, you can
|
||||
distribute their software, and you can modfify it, but you can not do
|
||||
both, i.e. distribute modified binaries.</blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="6.4"></a><font color="#330000">6.4. Okay, well what mail program
|
||||
should I use then?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">Well, there is nothing stopping you from
|
||||
using Pine with nano (or Pine with Pico for that matter). But if
|
||||
you want to use programs that are considered Free Software, you may want
|
||||
to look into <a href="http://www.mutt.org">mutt</a>. It is a full-screen,
|
||||
console based mail program that actually has a lot more flexibility than
|
||||
Pine, but has a keymap included in the distribution that allows you to
|
||||
use the same keystrokes as Pine would to send and receive mail. It's
|
||||
also licensed under the GPL.</font></blockquote>
|
||||
<blockquote><font color="#330000"> If you are looking to use a Free
|
||||
Software program similar to PINE and emacs is not your things, you should
|
||||
definitely take a look at <a href="http://www.mutt.org">mutt</a>. It
|
||||
is a full-screen, console based mail program that actually has a lot more
|
||||
flexibility than Pine, but has a keymap included in the distribution that
|
||||
allows you to use the same keystrokes as Pine would to send and receive
|
||||
mail. It's also licensed under the GPL.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="6.5"></a><font color="#330000">6.5. Why doesn't UW simply change
|
||||
@@ -526,7 +579,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>
|
||||
|
||||
585
files.c
585
files.c
@@ -29,6 +29,7 @@
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "proto.h"
|
||||
@@ -271,6 +272,21 @@ int do_insertfile(void)
|
||||
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);
|
||||
free(realname);
|
||||
|
||||
@@ -318,7 +334,7 @@ int write_file(char *name, int tmp)
|
||||
statusbar(_("Cancelled"));
|
||||
return -1;
|
||||
}
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
fileptr = fileage;
|
||||
|
||||
if (realname != NULL)
|
||||
@@ -359,11 +375,10 @@ int write_file(char *name, int tmp)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -376,7 +391,7 @@ int write_file(char *name, int tmp)
|
||||
if ((fd = mkstemp(buf)) == -1) {
|
||||
if (ISSET(TEMP_OPT)) {
|
||||
UNSET(TEMP_OPT);
|
||||
return do_writeout(1);
|
||||
return do_writeout(filename, 1);
|
||||
}
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
@@ -475,19 +490,20 @@ int write_file(char *name, int tmp)
|
||||
filename = mallocstrcpy(filename, realname);
|
||||
statusbar(_("Wrote %d lines"), lineswritten);
|
||||
UNSET(MODIFIED);
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_writeout(int exiting)
|
||||
int do_writeout(char *path, int exiting)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
static int did_cred = 0;
|
||||
#endif
|
||||
|
||||
answer = mallocstrcpy(answer, filename);
|
||||
answer = mallocstrcpy(answer, path);
|
||||
|
||||
if ((exiting) && (ISSET(TEMP_OPT))) {
|
||||
if (filename[0]) {
|
||||
@@ -509,6 +525,18 @@ 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
|
||||
@@ -544,85 +572,62 @@ int do_writeout(int exiting)
|
||||
|
||||
int do_writeout_void(void)
|
||||
{
|
||||
return do_writeout(0);
|
||||
return do_writeout(filename, 0);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
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 *dirtmp = NULL, *line = NULL, byte[1], *lineptr;
|
||||
int fd, i, status, searchctr = 1;
|
||||
char *dirtmp = NULL, *find_user = NULL;
|
||||
int i = 1;
|
||||
struct passwd *userdata;
|
||||
|
||||
/* set a default value for dirtmp, in the case user home dir not found */
|
||||
dirtmp = mallocstrcpy(dirtmp, buf);
|
||||
|
||||
if (buf[0] == '~') {
|
||||
if (buf[1] == '~')
|
||||
goto abort; /* Handle ~~ without segfaulting =) */
|
||||
else if (buf[1] == '/') {
|
||||
if (buf[1] == 0 || buf[1] == '/') {
|
||||
if (getenv("HOME") != NULL) {
|
||||
|
||||
free(dirtmp);
|
||||
dirtmp = nmalloc(strlen(buf) + 2 + strlen(getenv("HOME")));
|
||||
|
||||
sprintf(dirtmp, "%s/%s", getenv("HOME"), &buf[2]);
|
||||
}
|
||||
} else if (buf[1] != 0) {
|
||||
sprintf(dirtmp, "%s%s", getenv("HOME"), &buf[1]);
|
||||
|
||||
if ((fd = open("/etc/passwd", O_RDONLY)) == -1)
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
/* Figure how how much of of the str we need to compare */
|
||||
for (searchctr = 1; buf[searchctr] != '/' &&
|
||||
buf[searchctr] != 0; searchctr++);
|
||||
for (i = 1; buf[i] != '/' && buf[i] != 0; i++)
|
||||
;
|
||||
|
||||
do {
|
||||
i = 0;
|
||||
line = nmalloc(1);
|
||||
while ((status = read(fd, byte, 1)) != 0
|
||||
&& byte[0] != '\n') {
|
||||
find_user = mallocstrcpy(find_user, &buf[1]);
|
||||
find_user[i - 1] = 0;
|
||||
|
||||
line[i] = byte[0];
|
||||
i++;
|
||||
line = nrealloc(line, i + 1);
|
||||
}
|
||||
line[i] = 0;
|
||||
for (userdata = getpwent(); userdata != NULL &&
|
||||
strcmp(userdata->pw_name, find_user);
|
||||
userdata = getpwent());
|
||||
|
||||
if (i == 0)
|
||||
goto abort;
|
||||
free(find_user);
|
||||
|
||||
line[i] = 0;
|
||||
lineptr = strtok(line, ":");
|
||||
if (userdata != NULL) { /* User found */
|
||||
|
||||
if (!strncmp(lineptr, &buf[1], searchctr - 1)) {
|
||||
free(dirtmp);
|
||||
dirtmp = nmalloc(strlen(buf) + 2 + strlen(userdata->pw_dir));
|
||||
sprintf(dirtmp, "%s%s", userdata->pw_dir, &buf[i]);
|
||||
|
||||
/* Okay, skip to the password portion now */
|
||||
for (i = 0; i <= 4 && lineptr != NULL; i++)
|
||||
lineptr = strtok(NULL, ":");
|
||||
}
|
||||
|
||||
if (lineptr == NULL)
|
||||
goto abort;
|
||||
|
||||
/* 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);
|
||||
endpwent();
|
||||
}
|
||||
} else
|
||||
dirtmp = mallocstrcpy(dirtmp, buf);
|
||||
}
|
||||
|
||||
return dirtmp;
|
||||
|
||||
abort:
|
||||
dirtmp = mallocstrcpy(dirtmp, buf);
|
||||
return dirtmp;
|
||||
}
|
||||
|
||||
/* Tack a slash onto the string we're completing if it's a directory */
|
||||
@@ -671,79 +676,35 @@ int append_slash_if_dir(char *buf, int *lastWasTab, int *place)
|
||||
|
||||
char **username_tab_completion(char *buf, int *num_matches)
|
||||
{
|
||||
char **matches = (char **) NULL, *line = NULL, *lineptr;
|
||||
char *matchline = NULL, *matchdir = NULL;
|
||||
char **matches = (char **) NULL;
|
||||
char *matchline = NULL;
|
||||
struct passwd *userdata;
|
||||
|
||||
int fd, i = 0, status = 1;
|
||||
char byte[1];
|
||||
*num_matches = 0;
|
||||
matches = nmalloc(BUFSIZ * sizeof(char *));
|
||||
|
||||
if ((fd = open("/etc/passwd", O_RDONLY)) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (homedirs != NULL) {
|
||||
for (i = 0; i < *num_matches; i++)
|
||||
free(homedirs[i]);
|
||||
free(homedirs);
|
||||
homedirs = (char **) NULL;
|
||||
*num_matches = 0;
|
||||
}
|
||||
matches = nmalloc(BUFSIZ);
|
||||
homedirs = nmalloc(BUFSIZ);
|
||||
strcat(buf, "*");
|
||||
do {
|
||||
i = 0;
|
||||
line = nmalloc(1);
|
||||
while ((status = read(fd, byte, 1)) != 0 && byte[0] != '\n') {
|
||||
|
||||
line[i] = byte[0];
|
||||
i++;
|
||||
line = nrealloc(line, i + 1);
|
||||
}
|
||||
while ((userdata = getpwent()) != NULL) {
|
||||
|
||||
if (i == 0)
|
||||
break;
|
||||
|
||||
line[i] = 0;
|
||||
lineptr = strtok(line, ":");
|
||||
|
||||
if (check_wildcard_match(line, &buf[1]) == TRUE) {
|
||||
|
||||
if (*num_matches == BUFSIZ)
|
||||
break;
|
||||
if (check_wildcard_match(userdata->pw_name, &buf[1]) == TRUE) {
|
||||
|
||||
/* Cool, found a match. Add it to the list
|
||||
* This makes a lot more sense to me (Chris) this way...
|
||||
*/
|
||||
matchline = nmalloc(strlen(line) + 2);
|
||||
sprintf(matchline, "~%s", line);
|
||||
|
||||
for (i = 0; i <= 4 && lineptr != NULL; i++)
|
||||
lineptr = strtok(NULL, ":");
|
||||
|
||||
if (lineptr == NULL)
|
||||
break;
|
||||
|
||||
matchdir = mallocstrcpy(matchdir, lineptr);
|
||||
homedirs[*num_matches] = matchdir;
|
||||
matchline = nmalloc(strlen(userdata->pw_name) + 2);
|
||||
sprintf(matchline, "~%s", userdata->pw_name);
|
||||
matches[*num_matches] = matchline;
|
||||
|
||||
++*num_matches;
|
||||
|
||||
/* If there's no more room, bail out */
|
||||
if (*num_matches == BUFSIZ)
|
||||
break;
|
||||
}
|
||||
}
|
||||
endpwent();
|
||||
|
||||
free(line);
|
||||
|
||||
} while (status != 0);
|
||||
|
||||
close(fd);
|
||||
return matches;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "\nin username_tab_completion\n");
|
||||
#endif
|
||||
return (matches);
|
||||
}
|
||||
|
||||
@@ -757,14 +718,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--;
|
||||
@@ -807,11 +768,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
|
||||
@@ -855,7 +811,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;
|
||||
@@ -1029,3 +986,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
|
||||
|
||||
|
||||
71
global.c
71
global.c
@@ -35,7 +35,6 @@
|
||||
* Global variables
|
||||
*/
|
||||
int flags = 0; /* Our new flag containig many options */
|
||||
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 */
|
||||
@@ -79,7 +78,13 @@ 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
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
toggle toggles[TOGGLE_LEN];
|
||||
#endif
|
||||
|
||||
/* Regular expressions */
|
||||
|
||||
@@ -103,6 +108,7 @@ void sc_init_one(shortcut * s, int key, char *desc, char *help, int alt,
|
||||
s->func = func;
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Initialize the toggles in the same manner */
|
||||
void toggle_init_one(toggle * t, int val, char *desc, int flag)
|
||||
{
|
||||
@@ -110,6 +116,7 @@ void toggle_init_one(toggle * t, int val, char *desc, int flag)
|
||||
t->desc = desc;
|
||||
t->flag = flag;
|
||||
}
|
||||
#endif
|
||||
|
||||
void toggle_init(void)
|
||||
{
|
||||
@@ -173,6 +180,8 @@ void shortcut_init(int unjustify)
|
||||
"", *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,42 +214,39 @@ 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
|
||||
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[0], NANO_HELP_KEY, _("Get Help"),
|
||||
nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help);
|
||||
else
|
||||
sc_init_one(&main_list[0], NANO_WRITEOUT_KEY, _("WriteOut"),
|
||||
nano_writeout_msg,
|
||||
0, NANO_WRITEOUT_FKEY, 0, NOVIEW, do_writeout_void);
|
||||
|
||||
sc_init_one(&main_list[1], NANO_EXIT_KEY, _("Exit"),
|
||||
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
|
||||
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[2], NANO_WRITEOUT_KEY, _("WriteOut"),
|
||||
sc_init_one(&main_list[2], NANO_WRITEOUT_KEY, _("WriteOut"),
|
||||
nano_writeout_msg,
|
||||
0, NANO_WRITEOUT_FKEY, 0, NOVIEW, do_writeout_void);
|
||||
else
|
||||
sc_init_one(&main_list[2], NANO_GOTO_KEY, _("Goto Line"),
|
||||
nano_goto_msg,
|
||||
NANO_ALT_G, NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void);
|
||||
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[3], NANO_JUSTIFY_KEY, _("Justify"),
|
||||
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
|
||||
NOVIEW, do_justify);
|
||||
else
|
||||
sc_init_one(&main_list[3], NANO_REPLACE_KEY, _("Replace"),
|
||||
nano_replace_msg,
|
||||
NANO_ALT_R, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
|
||||
|
||||
sc_init_one(&main_list[4], NANO_INSERTFILE_KEY, _("Read File"),
|
||||
sc_init_one(&main_list[3], NANO_INSERTFILE_KEY, _("Read File"),
|
||||
nano_insert_msg,
|
||||
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile);
|
||||
|
||||
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[4], NANO_INSERTFILE_KEY, _("Read File"),
|
||||
nano_insert_msg,
|
||||
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile);
|
||||
else
|
||||
sc_init_one(&main_list[4], NANO_REPLACE_KEY, _("Replace"),
|
||||
nano_replace_msg,
|
||||
NANO_ALT_R, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
|
||||
|
||||
sc_init_one(&main_list[5], NANO_WHEREIS_KEY, _("Where Is"),
|
||||
nano_whereis_msg,
|
||||
0, NANO_WHEREIS_FKEY, 0, VIEW, do_search);
|
||||
@@ -320,13 +326,10 @@ void shortcut_init(int unjustify)
|
||||
nano_enter_msg,
|
||||
0, KEY_ENTER, NANO_CONTROL_M, NOVIEW, do_enter_void);
|
||||
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[25], NANO_GOTO_KEY, _("Goto Line"),
|
||||
sc_init_one(&main_list[25], NANO_GOTO_KEY, _("Goto Line"),
|
||||
nano_goto_msg,
|
||||
NANO_ALT_G, NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void);
|
||||
else
|
||||
sc_init_one(&main_list[25], NANO_HELP_KEY, _("Get Help"),
|
||||
nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help);
|
||||
|
||||
|
||||
|
||||
sc_init_one(&whereis_list[0], NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
@@ -403,15 +406,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 && totlines < editwinrows) {
|
||||
current = editbot;
|
||||
reset_cursor();
|
||||
} else if (editbot != filebot || edittop == fileage) {
|
||||
current_y = 0;
|
||||
current = editbot;
|
||||
|
||||
|
||||
458
nano.c
458
nano.c
@@ -23,6 +23,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
@@ -62,11 +63,15 @@
|
||||
|
||||
/* 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 struct sigaction act; /* For all out fun signal handlers */
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
#ifndef DISABLE_HELP
|
||||
static char *help_text_init = ""; /* Initial message, not including shortcuts */
|
||||
#endif
|
||||
|
||||
@@ -74,25 +79,21 @@ 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);
|
||||
}
|
||||
static sigjmp_buf jmpbuf; /* Used to return to mainloop after SIGWINCH */
|
||||
|
||||
/* 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();
|
||||
|
||||
@@ -143,6 +144,16 @@ 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"));
|
||||
@@ -159,13 +170,12 @@ void clear_filename(void)
|
||||
/* Initialize global variables - no better way for now */
|
||||
void global_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
center_x = COLS / 2;
|
||||
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;
|
||||
@@ -173,21 +183,22 @@ void global_init(void)
|
||||
editbot = NULL;
|
||||
totlines = 0;
|
||||
placewewant = 0;
|
||||
if (!fill)
|
||||
fill = COLS - 8;
|
||||
hblank = nmalloc(COLS + 1);
|
||||
|
||||
/* Thanks BG for this bit... */
|
||||
for (i = 0; i <= COLS - 1; i++)
|
||||
hblank[i] = ' ';
|
||||
hblank[i] = 0;
|
||||
if (!fill)
|
||||
fill = COLS - CHARS_FROM_EOL;
|
||||
|
||||
if (fill < MIN_FILL_LENGTH)
|
||||
die_too_small();
|
||||
|
||||
hblank = nmalloc(COLS + 1);
|
||||
memset(hblank, ' ', COLS);
|
||||
hblank[COLS] = 0;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
void init_help_msg(void)
|
||||
{
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
|
||||
help_text_init =
|
||||
_(" nano help text\n\n "
|
||||
"The nano editor is designed to emulate the functionality and "
|
||||
@@ -206,9 +217,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)
|
||||
@@ -239,8 +250,11 @@ void unlink_node(filestruct * fileptr)
|
||||
|
||||
void delete_node(filestruct * fileptr)
|
||||
{
|
||||
if (fileptr == NULL)
|
||||
return;
|
||||
|
||||
if (fileptr->data != NULL)
|
||||
free(fileptr->data);
|
||||
free(fileptr->data);
|
||||
free(fileptr);
|
||||
}
|
||||
|
||||
@@ -268,18 +282,6 @@ filestruct *copy_filestruct(filestruct * src)
|
||||
return head;
|
||||
}
|
||||
|
||||
/* Free() a single node */
|
||||
int free_node(filestruct * src)
|
||||
{
|
||||
if (src == NULL)
|
||||
return 0;
|
||||
|
||||
if (src->next != NULL)
|
||||
free(src->data);
|
||||
free(src);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int free_filestruct(filestruct * src)
|
||||
{
|
||||
filestruct *fileptr = src;
|
||||
@@ -289,15 +291,15 @@ int free_filestruct(filestruct * src)
|
||||
|
||||
while (fileptr->next != NULL) {
|
||||
fileptr = fileptr->next;
|
||||
free_node(fileptr->prev);
|
||||
delete_node(fileptr->prev);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("free_node(): free'd a node, YAY!\n"));
|
||||
fprintf(stderr, _("delete_node(): free'd a node, YAY!\n"));
|
||||
#endif
|
||||
}
|
||||
free_node(fileptr);
|
||||
delete_node(fileptr);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("free_node(): free'd last node.\n"));
|
||||
fprintf(stderr, _("delete_node(): free'd last node.\n"));
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -355,7 +357,7 @@ void usage(void)
|
||||
printf(_("Usage: nano [GNU long option] [option] +LINE <file>\n\n"));
|
||||
printf(_("Option Long option Meaning\n"));
|
||||
printf(_
|
||||
(" -T --tabsize=[num] Set width of a tab to num\n"));
|
||||
(" -T [num] --tabsize=[num] Set width of a tab to num\n"));
|
||||
#ifdef HAVE_REGEX_H
|
||||
printf(_
|
||||
(" -R --regexp Use regular expressions for search\n"));
|
||||
@@ -367,12 +369,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
|
||||
@@ -380,13 +382,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(_
|
||||
@@ -407,10 +411,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
|
||||
@@ -418,10 +422,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"));
|
||||
@@ -434,30 +439,36 @@ void usage(void)
|
||||
|
||||
void version(void)
|
||||
{
|
||||
printf(_(" nano version %s by Chris Allegretta (compiled %s, %s)\n"),
|
||||
printf(_(" GNU nano version %s (compiled %s, %s)\n"),
|
||||
VERSION, __TIME__, __DATE__);
|
||||
printf(_
|
||||
(" 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
|
||||
#endif
|
||||
#ifdef DISABLE_SPELLER
|
||||
printf(" --disable-speller");
|
||||
#endif
|
||||
#ifdef DISABLE_HELP
|
||||
#endif
|
||||
#ifdef DISABLE_HELP
|
||||
printf(" --disable-help");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_SLANG
|
||||
printf(" --with-slang");
|
||||
#endif
|
||||
@@ -482,19 +493,19 @@ filestruct *make_new_node(filestruct * prevnode)
|
||||
}
|
||||
|
||||
/* Splice a node into an existing filestruct */
|
||||
void splice_node(filestruct * begin, filestruct * new, filestruct * end)
|
||||
void splice_node(filestruct * begin, filestruct * newnode, filestruct * end)
|
||||
{
|
||||
new->next = end;
|
||||
new->prev = begin;
|
||||
begin->next = new;
|
||||
newnode->next = end;
|
||||
newnode->prev = begin;
|
||||
begin->next = newnode;
|
||||
if (end != NULL)
|
||||
end->prev = new;
|
||||
end->prev = newnode;
|
||||
}
|
||||
|
||||
int do_mark()
|
||||
int do_mark(void)
|
||||
{
|
||||
#ifdef NANO_SMALL
|
||||
nano_small_msg();
|
||||
nano_disabled_msg();
|
||||
#else
|
||||
if (!ISSET(MARK_ISSET)) {
|
||||
statusbar(_("Mark Set"));
|
||||
@@ -522,13 +533,6 @@ 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_SPELLER) || defined(DISABLE_HELP)
|
||||
void nano_disabled_msg(void)
|
||||
{
|
||||
@@ -566,11 +570,11 @@ void do_char(char ch)
|
||||
/* Someone hits return *gasp!* */
|
||||
int do_enter(filestruct * inptr)
|
||||
{
|
||||
filestruct *new;
|
||||
filestruct *newnode;
|
||||
char *tmp, *spc;
|
||||
int extra = 0;
|
||||
|
||||
new = make_new_node(inptr);
|
||||
newnode = make_new_node(inptr);
|
||||
tmp = ¤t->data[current_x];
|
||||
current_x = 0;
|
||||
|
||||
@@ -582,26 +586,27 @@ int do_enter(filestruct * inptr)
|
||||
extra++;
|
||||
spc++;
|
||||
current_x++;
|
||||
totsize++;
|
||||
}
|
||||
new->data = nmalloc(strlen(tmp) + extra + 1);
|
||||
strncpy(new->data, current->data, extra);
|
||||
strcpy(&new->data[extra], tmp);
|
||||
newnode->data = nmalloc(strlen(tmp) + extra + 1);
|
||||
strncpy(newnode->data, current->data, extra);
|
||||
strcpy(&newnode->data[extra], tmp);
|
||||
}
|
||||
} else {
|
||||
new->data = nmalloc(strlen(tmp) + 1);
|
||||
strcpy(new->data, tmp);
|
||||
newnode->data = nmalloc(strlen(tmp) + 1);
|
||||
strcpy(newnode->data, tmp);
|
||||
}
|
||||
*tmp = 0;
|
||||
|
||||
if (inptr->next == NULL) {
|
||||
filebot = new;
|
||||
editbot = new;
|
||||
filebot = newnode;
|
||||
editbot = newnode;
|
||||
}
|
||||
splice_node(inptr, new, inptr->next);
|
||||
splice_node(inptr, newnode, inptr->next);
|
||||
|
||||
totsize++;
|
||||
renumber(current);
|
||||
current = new;
|
||||
current = newnode;
|
||||
align(¤t->data);
|
||||
|
||||
/* The logic here is as follows:
|
||||
@@ -800,6 +805,14 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
if (current_x >= current_word_start) {
|
||||
right = current_x - current_word_start;
|
||||
current_x = 0;
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
int i = 0;
|
||||
while ((inptr->next->data[i] == ' '
|
||||
|| inptr->next->data[i] == '\t')) {
|
||||
i++;
|
||||
right++;
|
||||
}
|
||||
}
|
||||
down = 1;
|
||||
}
|
||||
|
||||
@@ -813,7 +826,6 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
|
||||
/* Category 2: two or more words on the line. */
|
||||
else {
|
||||
|
||||
/* Case 2a: cursor before word at wrap point. */
|
||||
if (current_x < current_word_start) {
|
||||
temp->data =
|
||||
@@ -846,6 +858,15 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
down = 1;
|
||||
|
||||
right = current_x - current_word_start;
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
int i = 0;
|
||||
while ((inptr->next->data[i] == ' '
|
||||
|| inptr->next->data[i] == '\t')) {
|
||||
i++;
|
||||
right++;
|
||||
}
|
||||
}
|
||||
|
||||
i = current_word_start - 1;
|
||||
if (isspace((int) input_char)
|
||||
&& (current_x == current_word_start)) {
|
||||
@@ -887,14 +908,34 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
|
||||
/* We pre-pend wrapped part to next line. */
|
||||
if (ISSET(SAMELINEWRAP) && inptr->next) {
|
||||
/* Plus one for the space which concatenates the two lines together plus 1 for \0. */
|
||||
char *p =
|
||||
nmalloc(strlen(temp->data) + strlen(inptr->next->data) + 2);
|
||||
int old_x = current_x, old_y = current_y;
|
||||
|
||||
strcpy(p, temp->data);
|
||||
strcat(p, " ");
|
||||
strcat(p, inptr->next->data);
|
||||
/* Plus one for the space which concatenates the two lines together plus 1 for \0. */
|
||||
char *p = nmalloc((strlen(temp->data) + strlen(inptr->next->data) + 2)
|
||||
* sizeof(char));
|
||||
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
int non = 0;
|
||||
|
||||
/* Grab the beginning of the next line until it's not a
|
||||
space or tab, then null terminate it so we can strcat it
|
||||
to hell */
|
||||
while ((inptr->next->data[non] == ' '
|
||||
|| inptr->next->data[non] == '\t'))
|
||||
p[non] = inptr->next->data[non++];
|
||||
|
||||
p[non] = 0;
|
||||
strcat(p, temp->data);
|
||||
strcat(p, " ");
|
||||
|
||||
/* Now tack on the rest of the next line after the spaces and
|
||||
tabs */
|
||||
strcat(p, &inptr->next->data[non]);
|
||||
} else {
|
||||
strcpy(p, temp->data);
|
||||
strcat(p, " ");
|
||||
strcat(p, inptr->next->data);
|
||||
}
|
||||
|
||||
free(inptr->next->data);
|
||||
inptr->next->data = p;
|
||||
@@ -907,6 +948,7 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
}
|
||||
/* Else we start a new line. */
|
||||
else {
|
||||
|
||||
temp->prev = inptr;
|
||||
temp->next = inptr->next;
|
||||
|
||||
@@ -918,6 +960,24 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
filebot = temp;
|
||||
|
||||
SET(SAMELINEWRAP);
|
||||
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
char *spc = inptr->data;
|
||||
char *t = NULL;
|
||||
int extra = 0;
|
||||
if (spc) {
|
||||
while ((*spc == ' ') || (*spc == '\t')) {
|
||||
extra++;
|
||||
spc++;
|
||||
totsize++;
|
||||
}
|
||||
t = nmalloc(strlen(temp->data) + extra + 1);
|
||||
strncpy(t, inptr->data, extra);
|
||||
strcpy(t + extra, temp->data);
|
||||
free(temp->data);
|
||||
temp->data = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -925,7 +985,7 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
/* Everything about it makes me want this line here but it causes
|
||||
* totsize to be high by one for some reason. Sigh. (Rob) */
|
||||
/* totsize++; */
|
||||
|
||||
|
||||
renumber(inptr);
|
||||
edit_update(edittop, TOP);
|
||||
|
||||
@@ -1076,7 +1136,9 @@ int do_delete(void)
|
||||
|
||||
align(¤t->data);
|
||||
|
||||
} else if (current->next != NULL) {
|
||||
/* Now that we have a magic lnie again, we can check for both being
|
||||
on the line before filebot as well as at filebot */
|
||||
} else if (current->next != NULL && current->next != filebot) {
|
||||
current->data = nrealloc(current->data,
|
||||
strlen(current->data) +
|
||||
strlen(current->next->data) + 1);
|
||||
@@ -1092,7 +1154,7 @@ int do_delete(void)
|
||||
delete_node(foo);
|
||||
update_line(current, current_x);
|
||||
|
||||
/* Please see the comment in do_basckspace if you don't understand
|
||||
/* Please see the comment in do_backspace if you don't understand
|
||||
this test */
|
||||
if (current == filebot && strcmp(current->data, "")) {
|
||||
new_magicline();
|
||||
@@ -1116,7 +1178,7 @@ void wrap_reset(void)
|
||||
UNSET(SAMELINEWRAP);
|
||||
}
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_SPELLER)
|
||||
#ifndef DISABLE_SPELLER
|
||||
|
||||
int do_int_spell_fix(char *word)
|
||||
{
|
||||
@@ -1182,9 +1244,6 @@ int do_int_spell_fix(char *word)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_SPELLER)
|
||||
|
||||
/* Integrated spell checking using 'spell' program */
|
||||
int do_int_speller(char *tempfile_name)
|
||||
@@ -1312,24 +1371,37 @@ int do_int_speller(char *tempfile_name)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_SPELLER)
|
||||
|
||||
/* External spell checking */
|
||||
int do_alt_speller(char *file_name)
|
||||
{
|
||||
int alt_spell_status;
|
||||
pid_t pid_spell;
|
||||
char *ptr;
|
||||
static int arglen = 3;
|
||||
static char **spellargs = (char **) NULL;
|
||||
|
||||
endwin();
|
||||
|
||||
/* Start a new process for the alternate speller */
|
||||
/* Set up an argument list to pass the execvp function */
|
||||
if (spellargs == NULL) {
|
||||
spellargs = nmalloc(arglen * sizeof(char *));
|
||||
|
||||
spellargs[0] = strtok(alt_speller, " ");
|
||||
while ((ptr = strtok(NULL, " ")) != NULL) {
|
||||
arglen++;
|
||||
spellargs = nrealloc(spellargs, arglen * sizeof(char *));
|
||||
spellargs[arglen - 3] = ptr;
|
||||
}
|
||||
spellargs[arglen - 1] = NULL;
|
||||
}
|
||||
spellargs[arglen - 2] = file_name;
|
||||
|
||||
/* Start a new process for the alternate speller */
|
||||
if ( (pid_spell = fork()) == 0) {
|
||||
|
||||
/* Start alternate spell program, we are using the PATH here!?!? */
|
||||
execlp(alt_speller, alt_speller, file_name, NULL);
|
||||
execvp(spellargs[0], spellargs);
|
||||
|
||||
/* Should not be reached, if alternate speller is found!!! */
|
||||
|
||||
@@ -1366,10 +1438,7 @@ int do_alt_speller(char *file_name)
|
||||
int do_spell(void)
|
||||
{
|
||||
|
||||
#if defined(NANO_SMALL)
|
||||
nano_small_msg();
|
||||
return (TRUE);
|
||||
#elif defined(DISABLE_SPELLER)
|
||||
#ifdef DISABLE_SPELLER
|
||||
nano_disabled_msg();
|
||||
return (TRUE);
|
||||
#else
|
||||
@@ -1425,7 +1494,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);
|
||||
@@ -1546,7 +1615,6 @@ void handle_sigwinch(int s)
|
||||
char *tty = NULL;
|
||||
int fd = 0;
|
||||
int result = 0;
|
||||
int i = 0;
|
||||
struct winsize win;
|
||||
|
||||
tty = ttyname(0);
|
||||
@@ -1563,19 +1631,17 @@ void handle_sigwinch(int s)
|
||||
COLS = win.ws_col;
|
||||
LINES = win.ws_row;
|
||||
|
||||
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();
|
||||
|
||||
free(hblank);
|
||||
hblank = nmalloc(COLS + 1);
|
||||
if ((fill = COLS - CHARS_FROM_EOL) < MIN_FILL_LENGTH)
|
||||
die_too_small();
|
||||
|
||||
for (i = 0; i <= COLS - 1; i++)
|
||||
hblank[i] = ' ';
|
||||
hblank[i] = 0;
|
||||
hblank = nrealloc(hblank, COLS + 1);
|
||||
memset(hblank, ' ', COLS);
|
||||
hblank[COLS] = 0;
|
||||
|
||||
#ifdef HAVE_NCURSES_H
|
||||
#ifdef HAVE_RESIZETERM
|
||||
resizeterm(LINES, COLS);
|
||||
#ifdef HAVE_WRESIZE
|
||||
if (wresize(topwin, 2, COLS) == ERR)
|
||||
@@ -1591,7 +1657,7 @@ void handle_sigwinch(int s)
|
||||
if (mvwin(bottomwin, LINES - 3 + no_help(), 0) == ERR)
|
||||
die(_("Cannot move bottom win"));
|
||||
#endif /* HAVE_WRESIZE */
|
||||
#endif /* HAVE_NCURSES_H */
|
||||
#endif /* HAVE_RESIZETERM */
|
||||
|
||||
fix_editbot();
|
||||
|
||||
@@ -1602,10 +1668,18 @@ void handle_sigwinch(int s)
|
||||
|
||||
/* Do these b/c width may have changed... */
|
||||
refresh();
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
edit_refresh();
|
||||
display_main_list();
|
||||
blank_statusbar();
|
||||
total_refresh();
|
||||
|
||||
/* Turn cursor back on for sure */
|
||||
curs_set(1);
|
||||
|
||||
/* Jump back to mainloop */
|
||||
siglongjmp(jmpbuf, 1);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1639,7 +1713,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);
|
||||
@@ -1647,6 +1722,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)
|
||||
@@ -1654,15 +1737,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
|
||||
|
||||
@@ -1674,7 +1756,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) {
|
||||
@@ -1726,15 +1808,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, totbak;
|
||||
filestruct *initial = NULL, *tmpjust = NULL, *cutbak, *tmptop, *tmpbot;
|
||||
|
||||
if (empty_line(current->data)) {
|
||||
@@ -1774,11 +1853,15 @@ int do_justify(void)
|
||||
|
||||
set_modified();
|
||||
cutbak = cutbuffer; /* Got to like cutbak ;) */
|
||||
totbak = totsize;
|
||||
cutbuffer = NULL;
|
||||
|
||||
tmptop = current;
|
||||
tmpjust = copy_node(current);
|
||||
|
||||
/* This is annoying because it mucks with totsize */
|
||||
add_to_cutbuffer(tmpjust);
|
||||
|
||||
/* Put the whole paragraph into one big line. */
|
||||
while (current->next && !isspace((int) current->next->data[0])
|
||||
&& current->next->data[0]) {
|
||||
@@ -1790,6 +1873,9 @@ int do_justify(void)
|
||||
tmpjust = copy_node(current->next);
|
||||
add_to_cutbuffer(tmpjust);
|
||||
|
||||
/* Wiping out a newline */
|
||||
totsize--;
|
||||
|
||||
/* length of both strings plus space between strings and ending \0. */
|
||||
current->data = nrealloc(current->data, len + len2 + 2);
|
||||
current->data[len++] = ' ';
|
||||
@@ -1801,8 +1887,6 @@ int do_justify(void)
|
||||
delete_node(tmpnode);
|
||||
}
|
||||
|
||||
totsize -= strlen(current->data);
|
||||
|
||||
justify_format(current->data);
|
||||
|
||||
slen = strlen(current->data);
|
||||
@@ -1822,12 +1906,14 @@ int do_justify(void)
|
||||
i = fill;
|
||||
else
|
||||
i = slen;
|
||||
|
||||
for (; i > 0; i--) {
|
||||
if (isspace((int) current->data[i]) &&
|
||||
((strlenpt(current->data) - strlen(current->data + i))
|
||||
<= fill))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!i)
|
||||
break;
|
||||
|
||||
@@ -1885,9 +1971,10 @@ int do_justify(void)
|
||||
|
||||
/* Now get a keystroke and see if it's unjustify, if not unget the keytroke
|
||||
and return */
|
||||
if ((kbinput = wgetch(edit)) != NANO_UNJUSTIFY_KEY)
|
||||
if ((kbinput = wgetch(edit)) != NANO_UNJUSTIFY_KEY) {
|
||||
ungetch(kbinput);
|
||||
else {
|
||||
blank_statusbar_refresh();
|
||||
} else {
|
||||
/* Else restore the justify we just did (ungrateful user!) */
|
||||
if (tmptop->prev != NULL)
|
||||
tmptop->prev->next = tmpbot->next;
|
||||
@@ -1900,6 +1987,8 @@ int do_justify(void)
|
||||
if (tmptop->prev == NULL)
|
||||
edit_refresh();
|
||||
|
||||
/* Restore totsize from befure justify */
|
||||
totsize = totbak;
|
||||
free_filestruct(tmptop);
|
||||
blank_statusbar_refresh();
|
||||
}
|
||||
@@ -1912,7 +2001,7 @@ int do_justify(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
#ifndef DISABLE_HELP
|
||||
void help_init(void)
|
||||
{
|
||||
int i, sofar = 0;
|
||||
@@ -1984,7 +2073,9 @@ void help_init(void)
|
||||
|
||||
void do_toggle(int which)
|
||||
{
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef NANO_SMALL
|
||||
nano_disabled_msg();
|
||||
#else
|
||||
char *enabled = _("enabled");
|
||||
char *disabled = _("disabled");
|
||||
|
||||
@@ -2029,18 +2120,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, modify_control_seq = 0;
|
||||
int keyhandled; /* Have we handled the keystroke yet? */
|
||||
int i, modify_control_seq;
|
||||
char *argv0;
|
||||
#ifdef _POSIX_VDISABLE
|
||||
struct termios term;
|
||||
@@ -2064,7 +2184,9 @@ int main(int argc, char *argv[])
|
||||
#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'},
|
||||
@@ -2078,10 +2200,12 @@ int main(int argc, char *argv[])
|
||||
SET(FOLLOW_SYMLINKS);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef ENABLE_NLS
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
while ((optchr = getopt_long(argc, argv, "?T:RVbcefhiklmpr:s:tvwxz",
|
||||
@@ -2125,10 +2249,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);
|
||||
@@ -2146,10 +2266,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;
|
||||
@@ -2213,13 +2335,12 @@ 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();
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
help_init();
|
||||
#endif
|
||||
signal_init();
|
||||
@@ -2231,12 +2352,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
|
||||
@@ -2247,7 +2362,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... */
|
||||
@@ -2261,6 +2376,14 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
edit_update(fileage, CENTER);
|
||||
|
||||
/* return here after a sigwinch */
|
||||
sigsetjmp(jmpbuf,1);
|
||||
|
||||
/* Fix clobber-age */
|
||||
kbinput = 0;
|
||||
keyhandled = 0;
|
||||
modify_control_seq = 0;
|
||||
|
||||
edit_refresh();
|
||||
reset_cursor();
|
||||
|
||||
@@ -2272,12 +2395,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 {
|
||||
@@ -2294,7 +2424,6 @@ int main(int argc, char *argv[])
|
||||
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);
|
||||
@@ -2371,16 +2500,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;
|
||||
@@ -2472,6 +2595,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 */
|
||||
|
||||
23
nano.h
23
nano.h
@@ -61,7 +61,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define VERMSG "nano " VERSION
|
||||
#define VERMSG "GNU nano " VERSION
|
||||
|
||||
/* Structure types */
|
||||
typedef struct filestruct {
|
||||
@@ -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 */
|
||||
|
||||
401
nano.info
Normal file
401
nano.info
Normal file
@@ -0,0 +1,401 @@
|
||||
This is nano.info, produced by makeinfo version 4.0 from nano.texi.
|
||||
|
||||
INFO-DIR-SECTION Editors
|
||||
START-INFO-DIR-ENTRY
|
||||
* Nano: (nano). Small and friendly text editor.
|
||||
END-INFO-DIR-ENTRY
|
||||
|
||||
|
||||
File: nano.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir)
|
||||
|
||||
This manual documents GNU nano, a small and friendly text editor.
|
||||
|
||||
* Menu:
|
||||
|
||||
* Introduction::
|
||||
* Editor Basics::
|
||||
* Online Help::
|
||||
* Feature Toggles::
|
||||
* The File Browser::
|
||||
* Pico Compatibility::
|
||||
* Building and Configure Options::
|
||||
|
||||
|
||||
File: nano.info, Node: Introduction, Next: Editor Basics, Prev: Top, Up: Top
|
||||
|
||||
Introduction
|
||||
************
|
||||
|
||||
GNU `nano' is a small and friendly text editor. Besides basic text
|
||||
editing, `nano' offers many extra features like an interactive search
|
||||
and replace, goto line number, auto-indentation, feature toggles,
|
||||
internationalization support, and filename tab completion.
|
||||
|
||||
* Menu:
|
||||
|
||||
* Overview::
|
||||
* Command Line Options::
|
||||
|
||||
|
||||
File: nano.info, Node: Overview, Next: Command Line Options, Prev: Introduction, Up: Introduction
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
`nano' [GNU long option] [option] +LINE [ FILE ... ]
|
||||
|
||||
The original goal for `nano' was a complete bug-for-bug compatible
|
||||
emulation of Pico, but consistency is now a slightly higher priority.
|
||||
There is a flag to implement (nearly) complete Pico emulation, (option
|
||||
-p or GNU long option -pico). This can also be toggled from within
|
||||
`nano' by typing Meta-P. *Note Pico Compatibility::, for more info.
|
||||
|
||||
Email bug reports to <nano@nano-editor.org>.
|
||||
|
||||
|
||||
File: nano.info, Node: Command Line Options, Prev: Overview, Up: Introduction
|
||||
|
||||
Command Line Options
|
||||
====================
|
||||
|
||||
`nano' takes the following options from the command line:
|
||||
`-T [num, --tabsize=[num]'
|
||||
Set the displayed tab length to [num] columns.
|
||||
|
||||
`-R, --regexp'
|
||||
Turns on regular expression search and search/replace.
|
||||
|
||||
`-V, --version'
|
||||
Print the version number and copyright and quit.
|
||||
|
||||
`-c, --const'
|
||||
Constantly display the cursor posititon and line number on the
|
||||
statusbar.
|
||||
|
||||
`-h, --help'
|
||||
Print the usage and exit.
|
||||
|
||||
`-i, --autoindent'
|
||||
Automatically indent new lines to the same number of spaces and
|
||||
tabs as the previous line.
|
||||
|
||||
`-k, --cut'
|
||||
Makes ^K cut from the current cursor position to the end of the
|
||||
current line.
|
||||
|
||||
`-l, --nofollow'
|
||||
When writing files, if the given file is a symbolic link it is
|
||||
removed and a new file is created.
|
||||
|
||||
`-m, --mouse'
|
||||
Enables the use of the mouse to select text (currently only useful
|
||||
for running under the X window system).
|
||||
|
||||
`-p, --pico'
|
||||
Emulate Pico as closely as possible, sacrificing consistency for
|
||||
correct emulation. *Note Pico Compatibility::, for more info.
|
||||
|
||||
`-r [#cols], --fill=[#cols].'
|
||||
Wrap lines at column #cols. By default this is the width of the
|
||||
screen, less eight.
|
||||
|
||||
`-s [prog], --speller=[prog]'
|
||||
Invoke [prog] as the spell checker. By default, `nano' uses its
|
||||
own interactive spell checker that requires the `spell' program be
|
||||
installed on your system.
|
||||
|
||||
`-t, --tempfile'
|
||||
Do not ask whether or not to save the current contents of the file
|
||||
when exiting, assume yes. This is most useful when using `nano'
|
||||
as the composer of a mailer program.
|
||||
|
||||
`-x, --nohelp'
|
||||
In Expert Mode, the Shortcut Lists will not appear at the bottom
|
||||
of the screen. This affects the location of the statusbar as
|
||||
well, as in Expert Mode it is located at the very bottom of the
|
||||
editor.
|
||||
|
||||
Note: When accesing the help system, Expert Mode is temporarily
|
||||
disabled to display the help system navigation keys.
|
||||
|
||||
`-v, --view'
|
||||
Do not allow the contents of the file to be altered. Note that
|
||||
this flag should NOT be used in place of correct file permissions
|
||||
to implement a read-only file.
|
||||
|
||||
`-w, --nowrap'
|
||||
Do not wrap long lines at any length. This option overrides any
|
||||
value for -r.
|
||||
|
||||
`-z, --suspend'
|
||||
Enable suspend ability of `nano' using the system's suspend
|
||||
keystroke (usually ^Z).
|
||||
|
||||
`+LINE'
|
||||
Start at line number LINE instead of the default of line 1.
|
||||
|
||||
|
||||
File: nano.info, Node: Editor Basics, Next: Online Help, Prev: Introduction, Up: Top
|
||||
|
||||
Editor Basics
|
||||
*************
|
||||
|
||||
* Menu:
|
||||
|
||||
* Entering Text::
|
||||
* Special Functions::
|
||||
* The Titlebar::
|
||||
* The Statusbar::
|
||||
* Shortcut Lists::
|
||||
|
||||
|
||||
File: nano.info, Node: Entering Text, Next: Special Functions, Prev: Editor Basics, Up: Editor Basics
|
||||
|
||||
Entering Text
|
||||
=============
|
||||
|
||||
All key sequences in `nano' are entered using the keyboard. `nano'
|
||||
is a "modeless" editor, all keys with the exception of Control and Meta
|
||||
key sequences will enter text into the file being edited.
|
||||
|
||||
|
||||
File: nano.info, Node: Special Functions, Next: The Titlebar, Prev: Entering Text, Up: Editor Basics
|
||||
|
||||
Special Functions
|
||||
=================
|
||||
|
||||
Special functions use the Control key (displayed in the help and
|
||||
shotcut lists as ^) or the Meta key (displayed as M).
|
||||
|
||||
* Control key sequences are entered by holding down the Control key
|
||||
and pressing the desired letter.
|
||||
|
||||
* Meta key sequences can be entered in a number of possible ways:
|
||||
Pressing the Escape key, then releasing it and pressing the
|
||||
desired key, or holding down the Alt key while pressing the desired
|
||||
key. This varies from keyboard to keyboard, and certain commercial
|
||||
operating systems "swallow" the Alt key so that it never reaches
|
||||
the application. If your operating system does this, you should
|
||||
use the Escape key to generate Meta key sequences.
|
||||
|
||||
|
||||
File: nano.info, Node: The Titlebar, Next: The Statusbar, Prev: Special Functions, Up: Editor Basics
|
||||
|
||||
The Titlebar
|
||||
============
|
||||
|
||||
The titlebar is the line displayed at the top of the editor. There
|
||||
are three sections: left, center and right. The section on the left
|
||||
displays the version of `nano' being used. The center section displays
|
||||
the current file name, or "New Buffer" if the file has not yet been
|
||||
named. The section on the right will display "Modified" if the file
|
||||
has been modified since it ws last saved or opened.
|
||||
|
||||
Special modes: When nano is in "File browser" mode, the center
|
||||
section will display the current directory instead of the filename.
|
||||
*Note The File Browser::.
|
||||
|
||||
|
||||
File: nano.info, Node: The Statusbar, Next: Shortcut Lists, Prev: The Titlebar, Up: Editor Basics
|
||||
|
||||
The Statusbar
|
||||
=============
|
||||
|
||||
The statusbar is located three lines from the bottom of the screen
|
||||
(or the bottom line in Expert Mode. *Note Expert Mode::, for more info.
|
||||
|
||||
The Statusbar shows important and informational messages. Any error
|
||||
messages that occur from using the editor will appear on the statusbar.
|
||||
Any questions that are asked of the user will be asked on the statusbar,
|
||||
and any user input (serch strings, file names, etc) will be input on the
|
||||
statusbar.
|
||||
|
||||
|
||||
File: nano.info, Node: Shortcut Lists, Prev: The Statusbar, Up: Editor Basics
|
||||
|
||||
Shortcut Lists
|
||||
==============
|
||||
|
||||
The Shorcut Lists are the two lines at the bottom of the screen
|
||||
which show some of the more commonly used functions in the editor. The
|
||||
exact functions which are displayed depend on whether Pico
|
||||
Compatibility Mode mode is enabled. *Note Pico Compatibility::, for
|
||||
more info.
|
||||
|
||||
|
||||
File: nano.info, Node: Online Help, Next: Feature Toggles, Prev: Editor Basics, Up: Top
|
||||
|
||||
Online Help
|
||||
***********
|
||||
|
||||
The online help system in `nano' is available by pressing ^G. It is
|
||||
fairly self explanatory, documenting the various parts of the editor
|
||||
and available keystrokes. Navigation is via the ^Y (Page Up) and ^V
|
||||
(Page Down) keys. ^X exits the help system.
|
||||
|
||||
|
||||
File: nano.info, Node: Feature Toggles, Next: The File Browser, Prev: Online Help, Up: Top
|
||||
|
||||
Feature Toggles
|
||||
***************
|
||||
|
||||
Toggles allow you to change certain aspects of the editor that would
|
||||
normally be done via command line flags. They are invoked via certain
|
||||
Meta key sequenced. *Note Special Functions::, for more info. The
|
||||
following toggles are available:
|
||||
|
||||
`Constant Update Toggle (Meta-C)'
|
||||
toggles the -c (-const) command line flag.
|
||||
|
||||
`Regular Expressions Toggle (Meta-E)'
|
||||
toggles the -R (-regexp) command line flag.
|
||||
|
||||
`AutoIndent Toggle (Meta-I)'
|
||||
toggles the -i (-autoindent) command line flag.
|
||||
|
||||
`Cut To End Toggle (Meta-K)'
|
||||
toggles the -k (-cut) command line flag.
|
||||
|
||||
`Cut To End Toggle (Meta-M)'
|
||||
toggles the -m (-mouse) command line flag.
|
||||
|
||||
`Pico Mode Toggle (Meta-P)'
|
||||
toggles the -p (-pico) command line flag. *Note Pico
|
||||
Compatibility::, for more info.
|
||||
|
||||
`AutoWrap Toggle (Meta-W)'
|
||||
toggles the -w (-nowrap) command line flag.
|
||||
|
||||
`Expert/Nohelp Toggle (Meta-X)'
|
||||
toggles the -x (-nohelp) command line flag.
|
||||
|
||||
`Suspend Toggle (Meta-Z)'
|
||||
toggles the -z (-suspend) command line flag.
|
||||
|
||||
|
||||
File: nano.info, Node: The File Browser, Next: Pico Compatibility, Prev: Feature Toggles, Up: Top
|
||||
|
||||
The File Browser
|
||||
****************
|
||||
|
||||
When reading or writilg files, pressing ^T will invoke the file
|
||||
browser. Here, one can navigate directories in a graphical manner in
|
||||
order to find the desired file.
|
||||
|
||||
Basic movement in the file browser is accomplished with he arrow keys
|
||||
and page up/down. The behavior of the enter (or 's') key varies by what
|
||||
is currently selected. If the currently selected object is a directory,
|
||||
the file browser will enter and display the contects of the directory.
|
||||
If the object is a file, this filename and path are copied to the
|
||||
statusbar and the file browser is exited.
|
||||
|
||||
|
||||
File: nano.info, Node: Pico Compatibility, Next: Building and Configure Options, Prev: The File Browser, Up: Top
|
||||
|
||||
Pico Compatibility
|
||||
******************
|
||||
|
||||
Nano does not completely emulate Pico by default. The following
|
||||
differences apply to the default mode and Pico Compatibility mode:
|
||||
|
||||
`Displayed Shortcuts'
|
||||
By default, the following shortcuts are displayed in the Shortcut
|
||||
Lists:
|
||||
|
||||
^G ^O ^\ ^Y ^K ^C
|
||||
^X ^R ^W ^V ^U ^T
|
||||
|
||||
Related functions are listed above or below each other by default.
|
||||
The Justify function is not listed, instead the "Replace"
|
||||
function is displayed. Also, he "Read File" and "WriteOut"
|
||||
functions are aligned for consistency.
|
||||
|
||||
In Pico Compatibility mode, the default Pico shortcuts are
|
||||
displayed:
|
||||
|
||||
^G ^O ^R ^Y ^K ^C
|
||||
^X ^J ^W ^V ^U ^T
|
||||
|
||||
`Previous String Text'
|
||||
By default, previously entered string for a function (search
|
||||
string, file name) will be placed on the statusbar, and is
|
||||
editable. This is done so there is consistency across all
|
||||
functions. For example: even if there is a previous replace
|
||||
string, it can always be deleted if one wishes to perform an empty
|
||||
string replace.
|
||||
|
||||
In Pico Compatibility Mode, the previously entered text in a
|
||||
search or replace will appear in brackets, and is not editable.
|
||||
It is not a simple matter to do an empty string replace when a
|
||||
previous replace string exists, for example. When writing a file,
|
||||
the previous filename will be displayed in the editable text
|
||||
portion of the editor.
|
||||
|
||||
`Interactive Replace and Spell Checker'
|
||||
It is worth noting that the `nano' replace function is interactive,
|
||||
i.e. it does not stop after one search string is found and
|
||||
automatically replace it. The `nano' implementation will stop at
|
||||
each search string found and query whether to replace this
|
||||
instance or not. The internal spell checker operates similarly.
|
||||
Note that these is no way to force these functions to behave in
|
||||
the Pico fashion.
|
||||
|
||||
|
||||
File: nano.info, Node: Building and Configure Options, Prev: Pico Compatibility, Up: Top
|
||||
|
||||
Building and Configure Options
|
||||
******************************
|
||||
|
||||
Building nano from source is fairly straightforward if you are
|
||||
familiar with compiling programs with autoconf support:
|
||||
|
||||
tar xvfz nano-x.y.z.tar.gz (where x.y.z is the version of nano) cd
|
||||
nano-x.y.z/ ./configure make make install
|
||||
|
||||
if you are looking to optimize nano for size, you may want to
|
||||
consider the following command line options:
|
||||
|
||||
`--disable-tabcomp'
|
||||
Disable the tab completion code when reading or writing files.
|
||||
|
||||
`--disable-justify'
|
||||
Disable the justify (^J)/unjustify (^U) functions in the editor.
|
||||
|
||||
`--disable-speller'
|
||||
Disables spell checker abillity.
|
||||
|
||||
`--disable-help'
|
||||
Disables the help function (^G). Disabling this option maks the
|
||||
binary much smaller, but makes it difficult for new users to learn
|
||||
more than very basic things about using the editor.
|
||||
|
||||
`--disable-browser'
|
||||
Disables the mini file browser (^O) when reading or writing files.
|
||||
|
||||
`--enable-tiny'
|
||||
This options disables all the above. It also disables some of the
|
||||
larger internals of the editor, like the marker code (^^) and the
|
||||
cut to line (-k) option which it depends on to work properly. It
|
||||
also disables the function toggles and mouse support.
|
||||
|
||||
|
||||
|
||||
Tag Table:
|
||||
Node: Top199
|
||||
Node: Introduction507
|
||||
Node: Overview933
|
||||
Node: Command Line Options1513
|
||||
Ref: Expert Mode3236
|
||||
Node: Editor Basics4078
|
||||
Node: Entering Text4303
|
||||
Node: Special Functions4643
|
||||
Node: The Titlebar5497
|
||||
Node: The Statusbar6194
|
||||
Node: Shortcut Lists6774
|
||||
Node: Online Help7166
|
||||
Node: Feature Toggles7542
|
||||
Node: The File Browser8685
|
||||
Node: Pico Compatibility9394
|
||||
Node: Building and Configure Options11436
|
||||
|
||||
End Tag Table
|
||||
412
nano.texi
Normal file
412
nano.texi
Normal file
@@ -0,0 +1,412 @@
|
||||
\input texinfo @c -*-texinfo-*-
|
||||
@c %**start of header
|
||||
@setfilename nano.info
|
||||
@settitle nano Command Manual
|
||||
@c %**end of header
|
||||
|
||||
@c This file has the new style title page commands.
|
||||
@c Run `makeinfo' rather than `texinfo-format-buffer'.
|
||||
@smallbook
|
||||
@set EDITION 0.1
|
||||
@set VERSION 1.0.0
|
||||
@set UPDATED 12 Feb 2001
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
* Nano: (nano). Small and friendly text editor.
|
||||
@end direntry
|
||||
|
||||
@c tex
|
||||
@c \overfullrule=0pt
|
||||
@c end tex
|
||||
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 1.0.0
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
|
||||
This manual documents GNU @code{nano}, a small and friendly text
|
||||
editor.
|
||||
|
||||
This manual is part of the GNU @code{nano} distribution.@*
|
||||
@sp4
|
||||
Copyright (C) 1999, 2000, 2001 Chris Allegretta.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
are preserved on all copies.
|
||||
|
||||
@iftex
|
||||
Permission is granted to process this file through TeX and print the
|
||||
results, provided the printed document carries copying permission
|
||||
notice identical to this one except for the removal of this paragraph
|
||||
(this paragraph not being relevant to the printed manual).
|
||||
@end iftex
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided that the entire
|
||||
resulting derived work is distributed under the terms of a permission
|
||||
notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions,
|
||||
except that this permission notice may be stated in a translation approved
|
||||
by the Foundation.
|
||||
|
||||
You may contact the author by:
|
||||
e-mail: @email{chrisa@@asty.org}@*
|
||||
@end titlepage
|
||||
|
||||
@node Top, Introduction, (dir), (dir)
|
||||
|
||||
This manual documents GNU nano, a small and friendly text editor.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
* Editor Basics::
|
||||
* Online Help::
|
||||
* Feature Toggles::
|
||||
* The File Browser::
|
||||
* Pico Compatibility::
|
||||
* Building and Configure Options::
|
||||
@end menu
|
||||
|
||||
@node Introduction, Editor Basics, Top, Top
|
||||
@chapter Introduction
|
||||
|
||||
GNU @code{nano} is a small and friendly text editor. Besides basic
|
||||
text editing, @code{nano} offers many extra features like an
|
||||
interactive search and replace, goto line number, auto-indentation,
|
||||
feature toggles, internationalization support, and filename tab
|
||||
completion.
|
||||
|
||||
@menu
|
||||
* Overview::
|
||||
* Command Line Options::
|
||||
@end menu
|
||||
|
||||
@node Overview, Command Line Options, Introduction, Introduction
|
||||
@section Overview
|
||||
|
||||
@code{nano} [GNU long option] [option] +LINE [ @var{ file ...} ]
|
||||
|
||||
The original goal for @code{nano} was a complete bug-for-bug compatible
|
||||
emulation of Pico, but consistency is now a slightly higher priority.
|
||||
There is a flag to implement (nearly) complete Pico emulation, (option -p
|
||||
or GNU long option --pico). This can also be toggled from within
|
||||
@code{nano} by typing Meta-P. @xref{Pico Compatibility}, for more
|
||||
info.
|
||||
|
||||
Email bug reports to @email{nano@@nano-editor.org}.
|
||||
|
||||
@node Command Line Options, , Overview, Introduction
|
||||
@section Command Line Options
|
||||
|
||||
@code{nano} takes the following options from the command line:
|
||||
@table @code
|
||||
|
||||
@item -T [num, --tabsize=[num]
|
||||
Set the displayed tab length to [num] columns.
|
||||
|
||||
@item -R, --regexp
|
||||
Turns on regular expression search and search/replace.
|
||||
|
||||
@item -V, --version
|
||||
Print the version number and copyright and quit.
|
||||
|
||||
@item -c, --const
|
||||
Constantly display the cursor posititon and line number on the statusbar.
|
||||
|
||||
@item -h, --help
|
||||
Print the usage and exit.
|
||||
|
||||
@item -i, --autoindent
|
||||
Automatically indent new lines to the same number of spaces and tabs as
|
||||
the previous line.
|
||||
|
||||
@item -k, --cut
|
||||
Makes ^K cut from the current cursor position to the end of the current
|
||||
line.
|
||||
|
||||
@item -l, --nofollow
|
||||
When writing files, if the given file is a symbolic link it is removed
|
||||
and a new file is created.
|
||||
|
||||
@item -m, --mouse
|
||||
Enables the use of the mouse to select text (currently only useful for
|
||||
running under the X window system).
|
||||
|
||||
@item -p, --pico
|
||||
Emulate Pico as closely as possible, sacrificing consistency for correct
|
||||
emulation. @xref{Pico Compatibility}, for more info.
|
||||
|
||||
@item -r [#cols], --fill=[#cols].
|
||||
Wrap lines at column #cols. By default this is the width of the screen,
|
||||
less eight.
|
||||
|
||||
@item -s [prog], --speller=[prog]
|
||||
Invoke [prog] as the spell checker. By default, @code{nano} uses its
|
||||
own interactive spell checker that requires the @code{spell} program be
|
||||
installed on your system.
|
||||
|
||||
@item -t, --tempfile
|
||||
Do not ask whether or not to save the current contents of the file when
|
||||
exiting, assume yes. This is most useful when using @code{nano} as the
|
||||
composer of a mailer program.
|
||||
|
||||
@anchor{Expert Mode}
|
||||
@item -x, --nohelp
|
||||
In Expert Mode, the Shortcut Lists will not appear at the bottom of the
|
||||
screen. This affects the location of the statusbar as well, as in Expert
|
||||
Mode it is located at the very bottom of the editor.
|
||||
|
||||
Note: When accesing the help system, Expert Mode is temporarily disabled
|
||||
to display the help system navigation keys.
|
||||
|
||||
@item -v, --view
|
||||
Do not allow the contents of the file to be altered. Note that this
|
||||
flag should NOT be used in place of correct file permissions to implement
|
||||
a read-only file.
|
||||
|
||||
@item -w, --nowrap
|
||||
Do not wrap long lines at any length. This option overrides any value for
|
||||
-r.
|
||||
|
||||
@item -z, --suspend
|
||||
Enable suspend ability of @code{nano} using the system's suspend
|
||||
keystroke (usually ^Z).
|
||||
|
||||
@item +LINE
|
||||
Start at line number LINE instead of the default of line 1.
|
||||
@end table
|
||||
|
||||
@node Editor Basics, Online Help, Introduction, Top
|
||||
@chapter Editor Basics
|
||||
@menu
|
||||
* Entering Text::
|
||||
* Special Functions::
|
||||
* The Titlebar::
|
||||
* The Statusbar::
|
||||
* Shortcut Lists::
|
||||
@end menu
|
||||
|
||||
@node Entering Text, Special Functions, Editor Basics, Editor Basics
|
||||
@section Entering Text
|
||||
|
||||
All key sequences in @code{nano} are entered using the keyboard.
|
||||
@code{nano} is a "modeless" editor, all keys with the exception of
|
||||
Control and Meta key sequences will enter text into the file being
|
||||
edited.
|
||||
|
||||
@node Special Functions, The Titlebar, Entering Text, Editor Basics
|
||||
@section Special Functions
|
||||
|
||||
Special functions use the Control key (displayed in the help and
|
||||
shotcut lists as ^) or the Meta key (displayed as M).
|
||||
|
||||
@itemize @bullet
|
||||
|
||||
@item
|
||||
Control key sequences are entered by holding down the Control key and
|
||||
pressing the desired letter.
|
||||
@item
|
||||
Meta key sequences can be entered in a number of
|
||||
possible ways: Pressing the Escape key, then releasing it and pressing
|
||||
the desired key, or holding down the Alt key while pressing the desired
|
||||
key. This varies from keyboard to keyboard, and certain commercial
|
||||
operating systems "swallow" the Alt key so that it never reaches the
|
||||
application. If your operating system does this, you should use the
|
||||
Escape key to generate Meta key sequences.
|
||||
@end itemize
|
||||
|
||||
@node The Titlebar, The Statusbar, Special Functions, Editor Basics
|
||||
@section The Titlebar
|
||||
|
||||
The titlebar is the line displayed at the top of the editor. There are
|
||||
three sections: left, center and right. The section on the left displays
|
||||
the version of @code{nano} being used. The center section displays the
|
||||
current file name, or "New Buffer" if the file has not yet been named.
|
||||
The section on the right will display "Modified" if the file has been
|
||||
modified since it ws last saved or opened.
|
||||
|
||||
Special modes: When nano is in "File browser" mode, the center section
|
||||
will display the current directory instead of the filename.
|
||||
@xref{The File Browser}.
|
||||
|
||||
@node The Statusbar, Shortcut Lists, The Titlebar, Editor Basics
|
||||
@section The Statusbar
|
||||
|
||||
The statusbar is located three lines from the bottom of the screen (or the
|
||||
bottom line in Expert Mode. @xref{Expert Mode}, for more info.
|
||||
|
||||
The Statusbar shows important and informational messages. Any error
|
||||
messages that occur from using the editor will appear on the statusbar.
|
||||
Any questions that are asked of the user will be asked on the statusbar,
|
||||
and any user input (serch strings, file names, etc) will be input on the
|
||||
statusbar.
|
||||
|
||||
@node Shortcut Lists, , The Statusbar, Editor Basics
|
||||
@section Shortcut Lists
|
||||
|
||||
The Shorcut Lists are the two lines at the bottom of the screen which show
|
||||
some of the more commonly used functions in the editor. The exact
|
||||
functions which are displayed depend on whether Pico Compatibility Mode mode
|
||||
is enabled. @xref{Pico Compatibility}, for more info.
|
||||
|
||||
@node Online Help, Feature Toggles, Editor Basics, Top
|
||||
@chapter Online Help
|
||||
|
||||
The online help system in @code{nano} is available by pressing ^G.
|
||||
It is fairly self explanatory, documenting the various parts of the
|
||||
editor and available keystrokes. Navigation is via the ^Y (Page Up)
|
||||
and ^V (Page Down) keys. ^X exits the help system.
|
||||
|
||||
|
||||
@node Feature Toggles, The File Browser, Online Help, Top
|
||||
@chapter Feature Toggles
|
||||
|
||||
Toggles allow you to change certain aspects of the editor that
|
||||
would normally be done via command line flags. They are invoked via
|
||||
certain Meta key sequenced. @xref{Special Functions}, for more info.
|
||||
The following toggles are available:
|
||||
|
||||
@table @code
|
||||
|
||||
@item Constant Update Toggle (Meta-C)
|
||||
toggles the -c (--const) command line flag.
|
||||
|
||||
@item Regular Expressions Toggle (Meta-E)
|
||||
toggles the -R (--regexp) command line flag.
|
||||
|
||||
@item AutoIndent Toggle (Meta-I)
|
||||
toggles the -i (--autoindent) command line flag.
|
||||
|
||||
@item Cut To End Toggle (Meta-K)
|
||||
toggles the -k (--cut) command line flag.
|
||||
|
||||
@item Cut To End Toggle (Meta-M)
|
||||
toggles the -m (--mouse) command line flag.
|
||||
|
||||
@item Pico Mode Toggle (Meta-P)
|
||||
toggles the -p (--pico) command line flag.
|
||||
@xref{Pico Compatibility}, for more info.
|
||||
|
||||
@item AutoWrap Toggle (Meta-W)
|
||||
toggles the -w (--nowrap) command line flag.
|
||||
|
||||
@item Expert/Nohelp Toggle (Meta-X)
|
||||
toggles the -x (--nohelp) command line flag.
|
||||
|
||||
@item Suspend Toggle (Meta-Z)
|
||||
toggles the -z (--suspend) command line flag.
|
||||
|
||||
@end table
|
||||
|
||||
@node The File Browser, Pico Compatibility, Feature Toggles, Top
|
||||
@chapter The File Browser
|
||||
|
||||
When reading or writilg files, pressing ^T will invoke the file browser.
|
||||
Here, one can navigate directories in a graphical manner in order to find
|
||||
the desired file.
|
||||
|
||||
Basic movement in the file browser is accomplished with he arrow keys
|
||||
and page up/down. The behavior of the enter (or 's') key varies by what
|
||||
is currently selected. If the currently selected object is a directory,
|
||||
the file browser will enter and display the contects of the directory. If
|
||||
the object is a file, this filename and path are copied to the statusbar
|
||||
and the file browser is exited.
|
||||
|
||||
@node Pico Compatibility, Building and Configure Options, The File Browser, Top
|
||||
@chapter Pico Compatibility
|
||||
|
||||
Nano does not completely emulate Pico by default. The following differences
|
||||
apply to the default mode and Pico Compatibility mode:
|
||||
|
||||
@table @code
|
||||
@item Displayed Shortcuts
|
||||
By default, the following shortcuts are displayed in the Shortcut Lists:
|
||||
|
||||
^G ^O ^\ ^Y ^K ^C@*
|
||||
^X ^R ^W ^V ^U ^T
|
||||
|
||||
Related functions are listed above or below each other by default. The
|
||||
Justify function is not listed, instead the "Replace" function is
|
||||
displayed. Also, he "Read File" and "WriteOut" functions are aligned for
|
||||
consistency.
|
||||
|
||||
In Pico Compatibility mode, the default Pico shortcuts are displayed:
|
||||
|
||||
^G ^O ^R ^Y ^K ^C@*
|
||||
^X ^J ^W ^V ^U ^T
|
||||
|
||||
@item Previous String Text
|
||||
By default, previously entered string for a function (search string,
|
||||
file name) will be placed on the statusbar, and is editable. This is
|
||||
done so there is consistency across all functions. For example: even if
|
||||
there is a previous replace string, it can always be deleted if one
|
||||
wishes to perform an empty string replace.
|
||||
|
||||
In Pico Compatibility Mode, the previously entered text in a search or
|
||||
replace will appear in brackets, and is not editable. It is not a
|
||||
simple matter to do an empty string replace when a previous replace
|
||||
string exists, for example. When writing a file, the previous filename
|
||||
will be displayed in the editable text portion of the editor.
|
||||
|
||||
@item Interactive Replace and Spell Checker
|
||||
It is worth noting that the @code{nano} replace function is interactive,
|
||||
i.e. it does not stop after one search string is found and automatically
|
||||
replace it. The @code{nano} implementation will stop at each search
|
||||
string found and query whether to replace this instance or not. The
|
||||
internal spell checker operates similarly. Note that these is no way
|
||||
to force these functions to behave in the Pico fashion.
|
||||
@end table
|
||||
|
||||
@node Building and Configure Options, , Pico Compatibility, Top
|
||||
@chapter Building and Configure Options
|
||||
|
||||
Building nano from source is fairly straightforward if you are familiar
|
||||
with compiling programs with autoconf support:
|
||||
|
||||
tar xvfz nano-x.y.z.tar.gz (where x.y.z is the version of nano)
|
||||
cd nano-x.y.z/
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
if you are looking to optimize nano for size, you may want to consider
|
||||
the following command line options:
|
||||
|
||||
|
||||
@table @code
|
||||
|
||||
@item --disable-tabcomp
|
||||
Disable the tab completion code when reading or writing files.
|
||||
|
||||
@item --disable-justify
|
||||
Disable the justify (^J)/unjustify (^U) functions in the editor.
|
||||
|
||||
@item --disable-speller
|
||||
Disables spell checker abillity.
|
||||
|
||||
@item --disable-help
|
||||
Disables the help function (^G). Disabling this option maks the
|
||||
binary much smaller, but makes it difficult for new users
|
||||
to learn more than very basic things about using the editor.
|
||||
|
||||
@item --disable-browser
|
||||
Disables the mini file browser (^O) when reading or writing files.
|
||||
|
||||
@item --enable-tiny
|
||||
This options disables all the above. It also disables some of
|
||||
the larger internals of the editor, like the marker code (^^) and
|
||||
the cut to line (-k) option which it depends on to work properly.
|
||||
It also disables the function toggles and mouse support.
|
||||
@end table
|
||||
|
||||
@contents
|
||||
@bye
|
||||
|
||||
|
||||
25
proto.h
25
proto.h
@@ -29,7 +29,7 @@
|
||||
|
||||
#include "nano.h"
|
||||
|
||||
extern int center_x, center_y, editwinrows;
|
||||
extern int editwinrows;
|
||||
extern int current_x, current_y, posible_max, totlines;
|
||||
extern int placewewant;
|
||||
extern int mark_beginx, samelinewrap;
|
||||
@@ -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,13 +112,14 @@ 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);
|
||||
@@ -126,7 +130,7 @@ void *nrealloc(void *ptr, size_t howmuch);
|
||||
void die(char *msg, ...);
|
||||
void new_file(void);
|
||||
void new_magicline(void);
|
||||
void splice_node(filestruct *begin, filestruct *new, filestruct *end);
|
||||
void splice_node(filestruct *begin, filestruct *newnode, filestruct *end);
|
||||
void null_at(char *data, int index);
|
||||
void page_up_center(void);
|
||||
void blank_edit(void);
|
||||
@@ -134,8 +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 keypad_on(int yesno);
|
||||
void nano_disabled_msg(void);
|
||||
void window_init(void);
|
||||
#ifdef NANO_EXTRA
|
||||
void do_credits(void);
|
||||
#endif
|
||||
@@ -148,6 +152,15 @@ 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 newval);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
char *do_browser(char *path);
|
||||
struct stat filestat(const char *path);
|
||||
char *do_browse_from(char *inpath);
|
||||
#endif
|
||||
|
||||
RETSIGTYPE main_loop (int junk);
|
||||
|
||||
filestruct *copy_node(filestruct * src);
|
||||
filestruct *copy_filestruct(filestruct * src);
|
||||
|
||||
17
search.c
17
search.c
@@ -44,7 +44,7 @@ void regexp_init(const char *regexp)
|
||||
SET(REGEXP_COMPILED);
|
||||
}
|
||||
|
||||
void regexp_cleanup()
|
||||
void regexp_cleanup(void)
|
||||
{
|
||||
UNSET(REGEXP_COMPILED);
|
||||
regfree(&search_regexp);
|
||||
@@ -81,7 +81,6 @@ int search_init(int replacing)
|
||||
buf = nmalloc(strlen(last_search) + 5);
|
||||
buf[0] = 0;
|
||||
|
||||
|
||||
/* Okay, fun time. backupstring is our holder for what is being
|
||||
returned from the statusq call. Using answer for this would be tricky.
|
||||
Here, if we're using PICO_MODE, we only want nano to put the
|
||||
@@ -140,8 +139,14 @@ int search_init(int replacing)
|
||||
return -1;
|
||||
} else if (i == -2) { /* Same string */
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
regexp_init(answer);
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
|
||||
/* If we're in pico mode, answer is "", use last_search! */
|
||||
if (ISSET(PICO_MODE))
|
||||
regexp_init(last_search);
|
||||
else
|
||||
regexp_init(answer);
|
||||
}
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
@@ -340,9 +345,9 @@ int do_search(void)
|
||||
void print_replaced(int num)
|
||||
{
|
||||
if (num > 1)
|
||||
statusbar(_("Replaced %d occurences"), num);
|
||||
statusbar(_("Replaced %d occurrences"), num);
|
||||
else if (num == 1)
|
||||
statusbar(_("Replaced 1 occurence"));
|
||||
statusbar(_("Replaced 1 occurrence"));
|
||||
}
|
||||
|
||||
void replace_abort(void)
|
||||
|
||||
5992
texinfo.tex
Normal file
5992
texinfo.tex
Normal file
File diff suppressed because it is too large
Load Diff
6
utils.c
6
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);
|
||||
|
||||
|
||||
183
winio.c
183
winio.c
@@ -34,6 +34,8 @@
|
||||
#define _(string) (string)
|
||||
#endif
|
||||
|
||||
|
||||
/* winio.c statics */
|
||||
static int statblank = 0; /* Number of keystrokes left after
|
||||
we call statubar() before we
|
||||
actually blank the statusbar */
|
||||
@@ -308,6 +310,7 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
case NANO_FORWARD_KEY:
|
||||
|
||||
if (x < xend)
|
||||
x++;
|
||||
@@ -353,11 +356,14 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
inputbuf = input_tab(inputbuf, (x - x_left),
|
||||
&tabbed, &shift);
|
||||
x += shift;
|
||||
if (x - x_left > strlen(inputbuf))
|
||||
x = strlen(inputbuf) + x_left;
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case KEY_LEFT:
|
||||
case NANO_BACK_KEY:
|
||||
if (x > strlen(buf))
|
||||
x--;
|
||||
wmove(bottomwin, 0, x);
|
||||
@@ -463,9 +469,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 +483,23 @@ void titlebar(void)
|
||||
|
||||
space = COLS - strlen(VERMSG) - strlen(VERSION) - 21;
|
||||
|
||||
namelen = strlen(filename);
|
||||
namelen = strlen(what);
|
||||
|
||||
if (!strcmp(filename, ""))
|
||||
mvwaddstr(topwin, 0, center_x - 6, _("New Buffer"));
|
||||
if (!strcmp(what, ""))
|
||||
mvwaddstr(topwin, 0, COLS / 2 - 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, COLS / 2 - (namelen / 2 + 1), "File: ");
|
||||
else
|
||||
mvwaddstr(topwin, 0, COLS / 2 - (namelen / 2 + 1), " DIR: ");
|
||||
waddstr(topwin, what);
|
||||
}
|
||||
}
|
||||
if (ISSET(MODIFIED))
|
||||
@@ -552,7 +568,7 @@ void set_modified(void)
|
||||
{
|
||||
if (!ISSET(MODIFIED)) {
|
||||
SET(MODIFIED);
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
wrefresh(topwin);
|
||||
}
|
||||
}
|
||||
@@ -1009,7 +1025,18 @@ int do_yesno(int all, int leavecursor, char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char foo[133];
|
||||
int kbinput, ok = -1;
|
||||
int kbinput, ok = -1, i;
|
||||
char *yesstr; /* String of yes characters accepted */
|
||||
char *nostr; /* Same for no */
|
||||
char *allstr; /* And all, surprise! */
|
||||
char shortstr[5]; /* Temp string for above */
|
||||
|
||||
/* Yes, no and all are strings of any length. Each string consists of
|
||||
all characters accepted as a valid character for that value.
|
||||
The first value will be the one displayed in the shortcuts. */
|
||||
yesstr = _("Yy");
|
||||
nostr = _("Nn");
|
||||
allstr = _("Aa");
|
||||
|
||||
/* Write the bottom of the screen */
|
||||
clear_bottomwin();
|
||||
@@ -1020,11 +1047,19 @@ int do_yesno(int all, int leavecursor, char *msg, ...)
|
||||
/* Remove gettext call for keybindings until we clear the thing up */
|
||||
if (!ISSET(NO_HELP)) {
|
||||
wmove(bottomwin, 1, 0);
|
||||
onekey(" Y", _("Yes"));
|
||||
if (all)
|
||||
onekey(" A", _("All"));
|
||||
|
||||
snprintf(shortstr, 3, " %c", yesstr[0]);
|
||||
onekey(shortstr, _("Yes"));
|
||||
|
||||
if (all) {
|
||||
snprintf(shortstr, 3, " %c", allstr[0]);
|
||||
onekey(shortstr, _("All"));
|
||||
}
|
||||
wmove(bottomwin, 2, 0);
|
||||
onekey(" N", _("No"));
|
||||
|
||||
snprintf(shortstr, 3, " %c", nostr[0]);
|
||||
onekey(shortstr, _("No"));
|
||||
|
||||
onekey("^C", _("Cancel"));
|
||||
}
|
||||
va_start(ap, msg);
|
||||
@@ -1042,22 +1077,34 @@ int do_yesno(int all, int leavecursor, char *msg, ...)
|
||||
kbinput = wgetch(edit);
|
||||
|
||||
switch (kbinput) {
|
||||
case 'Y':
|
||||
case 'y':
|
||||
ok = 1;
|
||||
break;
|
||||
case 'N':
|
||||
case 'n':
|
||||
ok = 0;
|
||||
break;
|
||||
case 'A':
|
||||
case 'a':
|
||||
if (all)
|
||||
ok = 2;
|
||||
break;
|
||||
case NANO_CONTROL_C:
|
||||
ok = -2;
|
||||
break;
|
||||
default:
|
||||
|
||||
/* Look for the kbinput in the yes, no and (optinally) all str */
|
||||
for (i = 0; yesstr[i] != 0 && yesstr[i] != kbinput; i++)
|
||||
;
|
||||
if (yesstr[i] != 0) {
|
||||
ok = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; nostr[i] != 0 && nostr[i] != kbinput; i++)
|
||||
;
|
||||
if (nostr[i] != 0) {
|
||||
ok = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (all) {
|
||||
for (i = 0; allstr[i] != 0 && allstr[i] != kbinput; i++)
|
||||
;
|
||||
if (allstr[i] != 0) {
|
||||
ok = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1080,7 +1127,7 @@ void statusbar(char *msg, ...)
|
||||
vsnprintf(foo, 132, msg, ap);
|
||||
va_end(ap);
|
||||
|
||||
start_x = center_x - strlen(foo) / 2 - 1;
|
||||
start_x = COLS / 2 - strlen(foo) / 2 - 1;
|
||||
|
||||
/* Blank out line */
|
||||
blank_statusbar();
|
||||
@@ -1119,7 +1166,7 @@ int total_refresh(void)
|
||||
clearok(topwin, FALSE);
|
||||
clearok(bottomwin, FALSE);
|
||||
edit_refresh();
|
||||
titlebar();
|
||||
titlebar(NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1132,33 +1179,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,30 +1215,26 @@ int do_cursorpos(void)
|
||||
But hey, it's better than nothing, and it's dynamic! */
|
||||
int do_help(void)
|
||||
{
|
||||
#if !defined(NANO_SMALL) && !defined(DISABLE_HELP)
|
||||
#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;
|
||||
|
||||
|
||||
/* Oh well, they've asked for the help menu, if the keypad is not on now
|
||||
we're going to have to turn it on */
|
||||
keypad_on(TRUE);
|
||||
|
||||
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);
|
||||
|
||||
@@ -1274,20 +1310,17 @@ int do_help(void)
|
||||
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();
|
||||
#elif defined(NANO_SMALL)
|
||||
nano_small_msg();
|
||||
kp = keypad_on(edit, kp);
|
||||
|
||||
#elif defined(DISABLE_HELP)
|
||||
nano_disabled_msg();
|
||||
#endif
|
||||
@@ -1375,7 +1408,7 @@ void do_replace_highlight(int highlight_flag, char *word)
|
||||
}
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
#define CREDIT_LEN 45
|
||||
#define CREDIT_LEN 47
|
||||
void do_credits(void)
|
||||
{
|
||||
int i, j = 0, k, place = 0, start_x;
|
||||
@@ -1409,9 +1442,11 @@ void do_credits(void)
|
||||
"Tedi Heriyanto",
|
||||
"Bill Soudan",
|
||||
"Christian Weisgerber",
|
||||
"Erik Anderson",
|
||||
"Erik Andersen",
|
||||
"Big Gaute",
|
||||
"Joshua Jensen",
|
||||
"Ryan Krebs",
|
||||
"Albert Chin",
|
||||
"",
|
||||
specialthx,
|
||||
"Plattsburgh State University",
|
||||
@@ -1451,7 +1486,7 @@ void do_credits(void)
|
||||
else
|
||||
what = "";
|
||||
|
||||
start_x = center_x - strlen(what) / 2 - 1;
|
||||
start_x = COLS / 2 - strlen(what) / 2 - 1;
|
||||
mvwaddstr(edit, i * 2 - k, start_x, what);
|
||||
}
|
||||
usleep(700000);
|
||||
@@ -1472,3 +1507,23 @@ void do_credits(void)
|
||||
total_refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
int keypad_on(WINDOW * win, int newval)
|
||||
{
|
||||
|
||||
/* This is taken right from aumix. Don't sue me */
|
||||
#ifdef HAVE_USEKEYPAD
|
||||
int old;
|
||||
|
||||
old = win->_use_keypad;
|
||||
keypad(win, newval);
|
||||
return old;
|
||||
#else
|
||||
keypad(win, newval);
|
||||
return 1;
|
||||
#endif /* HAVE_USEKEYPAD */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user