Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97489d211f | ||
|
|
46c1b9e344 | ||
|
|
d4fa0d3904 | ||
|
|
46e3118e9d | ||
|
|
87435d9223 | ||
|
|
a3322fd65d | ||
|
|
459c03d3fc | ||
|
|
6324530ec8 | ||
|
|
7a053fc431 | ||
|
|
fd0fe7ef15 | ||
|
|
40639ddc0c | ||
|
|
309aa50fda | ||
|
|
d76ca2bc9f | ||
|
|
e4f940dbaa | ||
|
|
5f87021c08 | ||
|
|
6f746000c0 | ||
|
|
99ed9dc9fe | ||
|
|
6235a7d6d5 | ||
|
|
2d698b7132 | ||
|
|
f5de33a6ef | ||
|
|
bbcac936a0 | ||
|
|
f821db9b1f | ||
|
|
3c5653d83e | ||
|
|
48b06708ff | ||
|
|
3a6d70dfb6 | ||
|
|
2ce9205823 | ||
|
|
62d2171745 | ||
|
|
ff8a68c258 | ||
|
|
bc72e366d2 | ||
|
|
7e65d2f5ad | ||
|
|
9caa193fe1 | ||
|
|
a8c225787b | ||
|
|
025a42c67f | ||
|
|
e46d43d299 | ||
|
|
507c361bcf | ||
|
|
a824a9af9d | ||
|
|
f27c69703d | ||
|
|
7eccc7991c | ||
|
|
40b85e7aca | ||
|
|
b3b28c19b5 | ||
|
|
8bfd3114be | ||
|
|
94def068ef | ||
|
|
3d8e759a4c | ||
|
|
db3dc57a7e | ||
|
|
a039b57d05 | ||
|
|
02f3394917 | ||
|
|
8dbfb5c2ce | ||
|
|
8636f7b66a | ||
|
|
3c597d0b91 | ||
|
|
2440a5199c | ||
|
|
9c34a167d8 | ||
|
|
14b3ca94b7 | ||
|
|
83ffefbfdd | ||
|
|
121b9b99f9 |
3
BUGS
3
BUGS
@@ -129,7 +129,8 @@
|
||||
Ramsey, fixed by David Lawrence Ramsey & Chris) (66) [FIXED].
|
||||
- ^C does not work after a suspend in tcsh (discovered by
|
||||
Trevor Cordes) (68) [FIXED].
|
||||
|
||||
- Home and End control keys (^A, ^E) do not always work in filename
|
||||
prompt (bug found by Ian Turner) (69) [1.0 series only] [FIXED].
|
||||
** Open BUGS **
|
||||
|
||||
$Id$
|
||||
|
||||
120
ChangeLog
120
ChangeLog
@@ -1,3 +1,123 @@
|
||||
GNU nano 1.1.7 - 03/05/2002
|
||||
- General
|
||||
- malloc->calloc, etc cleanups (DLR).
|
||||
- New option, noconvert (-N, --noconvert) to completely stop
|
||||
the translation of files from DOS or Mac format (DLR).
|
||||
- New functions wheck_writable_directory() and safe_tempnam()
|
||||
to get around the tempnam warning. More improvements (DLR)
|
||||
Still needs testing.
|
||||
- Added DOS and Mac format options to write file routine.
|
||||
Changes to shortcut_init() and do_writeout().
|
||||
- Removed stupid static definitions of toggles and shortcut
|
||||
lists. Many changes to shortcut_init(), toggle_init(),
|
||||
statusq(), nanogetstr(), main(), and many other places.
|
||||
- Multibuffer mode now allows multiple empty filenames.
|
||||
Changes to add_open_files(), removed open_file_dup_search(),
|
||||
open_file_dup_fix(), etc (DLR).
|
||||
- New code to handle multiple .save files. Changes to
|
||||
die_save_file(), new function files.c:get_next_filename()
|
||||
and utils.c:num_of_digits(). (Dwayne Rightler, DLR & Chris)
|
||||
- Many malloc() cleanups and files.c tweaks by Steven Kneizys,
|
||||
new functions utils.c:free_shortcutage() (got to love that
|
||||
name!) & free_toggles(), and big cleanup program
|
||||
thanks_for_all_the_fish() (originally
|
||||
thanks_for_the_memories()). Mods to shortcut_init() by Chris.
|
||||
- Preliminary quoting support for justify. New arg -Q, --quotestr,
|
||||
changes to do_justify(), global variable quotestr().
|
||||
- Makefile.am:
|
||||
- Add SYSCONFDIR to DEFS, so we can have an /etc/nanorc.
|
||||
- Change localedir line to 1.0's version.
|
||||
- Moved m4/ stuff to its own m4/Makefile.am.
|
||||
- m4/aclocal_inc.m4:
|
||||
- New macro AM_ACLOCAL_INCLUDE, tells configure.ac where to look for
|
||||
macros (Gergely Nagy).
|
||||
- configure.in:
|
||||
- Renamed to configure.ac.
|
||||
- configure.ac:
|
||||
- Moved to autoconf 2.52 (Jeff Bailey).
|
||||
- Added call to AM_ACLOCAL_INCLUDE.
|
||||
- files.c:
|
||||
read_byte()
|
||||
- Added check for conrol characters (indicative of a binary
|
||||
file), set NO_CONVERT if found (fixes by DLR).
|
||||
do_insertfile()
|
||||
- Added support for -o in prompt (Steven Kneizys).
|
||||
- global.c:
|
||||
- Move openprev and opennext functions to shortcuts, they really
|
||||
aren't toggles (DLR).
|
||||
- rcfile.c:
|
||||
parse_next_regex()
|
||||
- Allow " symbol to be in regex without leading \ by checking
|
||||
for *ptr+1 is not the end of the regex.
|
||||
do_rcfile()
|
||||
- Parse rcfile in $SYSCONFDIR as well (Dwayne Rightler).
|
||||
- nano.1:
|
||||
- Added Noconvert option to man page (DLR).
|
||||
- nano.c:
|
||||
justify_format(), do_justify()
|
||||
- Various fixes for starting blank spaces, spaces after
|
||||
punctuation, & segfault with quoting strings (David Benbennick).
|
||||
do_justify()
|
||||
- Don't continue to justify string if it's indented more
|
||||
(quoting wise) than the beginning of the justification.
|
||||
help_init()
|
||||
- Added message re: having multiple blank buffers (DLR).
|
||||
main()
|
||||
- Add 407 as equiv of 26, this seems to be sent when using
|
||||
^Z in linux console with keypad() enabled.
|
||||
- rcfile.c:
|
||||
- Get rid of unneeded relativechars from rcopts (DLR).
|
||||
- search.c
|
||||
do_replace(), findnextstr()
|
||||
- Fixes for various search issues (Ken Tyler)
|
||||
- winio.c:
|
||||
do_cursorpos()
|
||||
- Rewritten to show col place as well as charcter place, without
|
||||
needing an entirely separate flag.
|
||||
bottombars(), onekey()
|
||||
- Make bottom list dynamic with screen size (Guus Sliepen & Chris).
|
||||
- More cleanups w/width of shortcut.
|
||||
- utils.c:
|
||||
strcasestr(),revstrcasestr()
|
||||
- Renamed to stristr and revstristr since strcasestr has not
|
||||
been confirmed to be detected properly on various Linux
|
||||
systems.
|
||||
strstrwrapper()
|
||||
- NANO_SMALL test was backwards (Ken Tyler).
|
||||
- winio.c:
|
||||
strlenpt()
|
||||
- Changed main function to strnlenpt() for new justify changes,
|
||||
original function now just a stub.
|
||||
- nanorc.sample
|
||||
- Mention unset in the sample nanorc.
|
||||
- po/ca.po, po/es.po:
|
||||
- Catalan and Spanish translation updates (Jordi).
|
||||
- po/sv.po:
|
||||
- Swedish translation updates (Christian Rose).
|
||||
- po/fr.po:
|
||||
- French translation updates (Jean-Philippe Guérard).
|
||||
- po/nn.po:
|
||||
- Norwegian nynorsk translation updates (Kjetil Torgrim Homme).
|
||||
- po/de.po:
|
||||
- German translation updates (Michael Piefel).
|
||||
- po/it.po:
|
||||
- Italian translation updates (Marco Colombo).
|
||||
- po/cs.po:
|
||||
- Partial Czech translation updates (Vaclav Haisman).
|
||||
- po/hu.po:
|
||||
- Hungarian translation updates, or to be precise, rewrite
|
||||
(Gergely Nagy).
|
||||
- po/uk.po, po/ru.po:
|
||||
- Russian and Ukrainian translation updates (Sergey A. Ribalchenko).
|
||||
- po/da.po:
|
||||
- Danish translation updates (Keld Simonsen).
|
||||
- po/nb.po:
|
||||
- Norwegian bokmål translation updates (Stig E Sandoe).
|
||||
- po/nl.po:
|
||||
- Dutch translation updates (Guus Sliepen).
|
||||
- po/pl.po:
|
||||
- Polish translation updates (Wojciech Kotwica).
|
||||
|
||||
nano-1.1.6 - 01/25/2002
|
||||
- General
|
||||
- Add Meta-A as alternate keyystroke for ^^ for people with
|
||||
|
||||
16
Makefile.am
16
Makefile.am
@@ -1,10 +1,7 @@
|
||||
## $Id$
|
||||
AUTOMAKE_OPTIONS = gnu no-dependencies
|
||||
M4DIR = $(srcdir)/m4
|
||||
ACLOCAL_AMFLAGS = -I $(M4DIR)
|
||||
ACINCLUDE_INPUTS = $(M4DIR)/gettext.m4 $(M4DIR)/largefile.m4 \
|
||||
$(M4DIR)/progtest.m4 $(M4DIR)/lcmessage.m4 $(M4DIR)/iconv.m4 \
|
||||
$(M4DIR)/codeset.m4 $(M4DIR)/glibc21.m4
|
||||
|
||||
DEFS= -DSYSCONFDIR=\"$(sysconfdir)\"
|
||||
|
||||
bin_PROGRAMS = nano
|
||||
nano_SOURCES = color.c \
|
||||
@@ -28,12 +25,9 @@ MAKEINFO = makeinfo --no-split
|
||||
|
||||
EXTRA_DIST = ABOUT-NLS AUTHORS BUGS COPYING ChangeLog INSTALL NEWS \
|
||||
README THANKS TODO install-sh missing mkinstalldirs \
|
||||
nano.1 nano.1.html faq.html nanorc.sample $(ACINCLUDE_INPUTS)
|
||||
nano.1 nano.1.html faq.html nanorc.sample
|
||||
|
||||
SUBDIRS = po intl
|
||||
SUBDIRS = po intl m4
|
||||
|
||||
localedir = @LOCALE_DIR@
|
||||
localedir = $(datadir)/locale
|
||||
INCLUDES = -Iintl -DLOCALEDIR=\"$(localedir)\" -I@includedir@
|
||||
|
||||
$(srcdir)/acinclude.m4: $(ACINCLUDE_INPUTS)
|
||||
cat $(ACINCLUDE_INPUTS) > $@
|
||||
|
||||
19
NEWS
19
NEWS
@@ -1,3 +1,22 @@
|
||||
03/05/2002 - GNU nano 1.1.7 "lets change everything and see what breaks"
|
||||
is released. New features include new flags
|
||||
-N,--noconvert to stop any file format conversion and
|
||||
-Q, --quotestr for the new quoted text justification,
|
||||
a new tempnam() implementation to avoid silly warnings,
|
||||
DOS and Mac file options in the Write File dialog,
|
||||
multiple save files (file.1) for abnormal exits, ^C
|
||||
now shows column as well as character position, and
|
||||
multibuffer allows duplicate files, even unnamed ones.
|
||||
Also, the static shortcut and toggle lengths are
|
||||
history, nano now reads $SYSCONFDIR/nanorc if rc file
|
||||
support is enabled, and nano is now built with (and
|
||||
requires for rebuilding) autoconf 2.5.
|
||||
This release also includes fixes for some memory
|
||||
leaks, detecting DOS and mac file format, justification,
|
||||
suspending keys, search & replace under various
|
||||
conditions, variable width for shortcuts, and the usual
|
||||
ton of translation updates.
|
||||
|
||||
01/25/2002 - GNU nano 1.1.6 is released. Lots of new features in this
|
||||
release. New Meta-keys were added as alternates for
|
||||
control sequences: Meta-A for the marker key (^^), and
|
||||
|
||||
11
README
11
README
@@ -38,14 +38,17 @@ Web Page
|
||||
|
||||
Mailing List and Bug Reports
|
||||
|
||||
SourceForge hosts all the nano-related mailing-lists.
|
||||
+ nano-announce@lists.sourceforge.net is a very low traffic list
|
||||
Savannah hosts all the nano-related mailing-lists.
|
||||
+ info-nano@gnu.org is a very low traffic list
|
||||
used to announce new Nano versions or other important information
|
||||
about the project.
|
||||
+ nano-devel@lists.sourceforge.net is the list used by the people
|
||||
+ help-nano@gnu.org is for those seeking to get help without
|
||||
wanting to hear about the technical details of its
|
||||
development.
|
||||
+ nano-devel@gnu.org is the list used by the people
|
||||
that make Nano and a general development discussion list, with
|
||||
moderate traffic.
|
||||
To subscribe, send email to nano-<name>-request@lists.sourceforge.net
|
||||
To subscribe, send email to nano-<name>-request@gnu.org
|
||||
with a subject of "subscribe", where <name> is the list you want to
|
||||
subscribe to.
|
||||
For general bug reports, send a description of the problem to
|
||||
|
||||
17
README.CVS
17
README.CVS
@@ -7,8 +7,8 @@ more care than the official stable and unstable tarballs.
|
||||
To succesfully compile GNU nano from CVS, you'll need the
|
||||
following packages:
|
||||
|
||||
- autoconf (versions 2.13 or >= 2.50)
|
||||
- automake (version 1.4-pl4 recommended)
|
||||
- autoconf (version >= 2.52)
|
||||
- automake (version 1.4-pl5 recommended)
|
||||
- autoheader
|
||||
- gettext (version 0.10.40)
|
||||
- texinfo
|
||||
@@ -18,13 +18,15 @@ These should be available on your GNU mirror.
|
||||
|
||||
|
||||
To download the CVS tree, execute the following command:
|
||||
$ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nano login
|
||||
$ cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/nano login
|
||||
and press enter at the password prompt.
|
||||
Then, do
|
||||
$ cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/nano checkout src
|
||||
[FIXME for Savannah] and the nano tree will download.
|
||||
$ cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/nano checkout nano
|
||||
and the nano tree will download.
|
||||
If you want to checkout the stable CVS branch, append -r nano_1_0_branch:
|
||||
$ cvs -z3 -d:pserver:anonymous@subversions.gnu.org:/cvsroot/nano checkout -r nano_1_0_branch nano
|
||||
|
||||
One you have the sources in the "src" directory, cd into it, and execute
|
||||
One you have the sources in the "nano" directory, cd into it, and execute
|
||||
the "autogen.sh" script in the top dir. This will setup a configure script
|
||||
and Makefile.in, and you will be ready to compile with
|
||||
$ ./configure [--add-options-here] && make
|
||||
@@ -33,5 +35,4 @@ $ make install
|
||||
should put the required files in their respective directories.
|
||||
|
||||
|
||||
Please submit any bugs in the CVS branch to nano-devel@lists.sourceforge.net.
|
||||
[FIXME needs change for Savannah too]
|
||||
Please submit any bugs in the CVS branch to nano-devel@gnu.org.
|
||||
|
||||
1
THANKS
1
THANKS
@@ -13,6 +13,7 @@ Eivind Kj
|
||||
Florian König <floki@bigfoot.com> German Translator
|
||||
Wojciech Kotwica <wkotwica@post.pl> Polish Translator
|
||||
Clement Laforet <clem_laf@wanadoo.fr> French Translator
|
||||
Gergely Nagy <algernon@debian.org> Hungarian Translator
|
||||
Michael Piefel <piefel@informatik.hu-berlin.de> German Translator
|
||||
Sergey A. Ribalchenko <fisher@obu.ck.ua> Russian, Ukrainian Translator
|
||||
Michel Robitaille <robitail@IRO.UMontreal.CA> French Translator
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Generate configure & friends for CVS users.
|
||||
|
||||
autoheader
|
||||
aclocal -I ./m4
|
||||
autoheader
|
||||
automake --add-missing
|
||||
autoconf
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
# $Id$
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(nano.c)
|
||||
AM_INIT_AUTOMAKE(nano, 1.1.6)
|
||||
AC_INIT
|
||||
AC_CONFIG_SRCDIR([nano.c])
|
||||
AC_PREREQ(2.52)
|
||||
AM_INIT_AUTOMAKE(nano, 1.1.7)
|
||||
AM_CONFIG_HEADER(config.h:config.h.in)
|
||||
AM_ACLOCAL_INCLUDE(m4)
|
||||
ALL_LINGUAS="es de fr it id fi hu ca cs gl uk ru sv nn nl da pl nb"
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_ISC_POSIX
|
||||
NANO_AC_SYS_LARGEFILE
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
@@ -306,4 +309,5 @@ fi
|
||||
dnl i18n stuff - pretty incomplete for now
|
||||
NANO_AM_GNU_GETTEXT
|
||||
|
||||
AC_OUTPUT([Makefile intl/Makefile po/Makefile.in])
|
||||
AC_CONFIG_FILES([Makefile intl/Makefile m4/Makefile po/Makefile.in])
|
||||
AC_OUTPUT
|
||||
2
cut.c
2
cut.c
@@ -232,7 +232,7 @@ int do_cut_text(void)
|
||||
|
||||
junk = NULL;
|
||||
junk = make_new_node(current);
|
||||
junk->data = nmalloc(1 * sizeof (char));
|
||||
junk->data = charalloc(1);
|
||||
junk->data[0] = 0;
|
||||
|
||||
add_to_cutbuffer(junk);
|
||||
|
||||
36
faq.html
36
faq.html
@@ -203,7 +203,7 @@ nano was developed).</font></blockquote>
|
||||
of nano?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">The current version of nano *should*
|
||||
be 1.1.6. Of course you should always check the nano homepage to
|
||||
be 1.1.7. Of course you should always check the nano homepage to
|
||||
see what the latest and greatest version is.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -289,7 +289,7 @@ tracking unstable, you probably have the newest version already.</font></blockqu
|
||||
of nano, you can use CVS to download the current source code. <b>Note:</b>
|
||||
believe it or not, by downloading code that has not yet stabilized into
|
||||
an official release, there could quite possibly be bugs, in fact the code
|
||||
may not even compile! Anyway, see <a href="https://sourceforge.net/cvs/?group_id=1304">the
|
||||
may not even compile! Anyway, see <a href="http://savannah.gnu.org/cvs/?group_id=1025">the
|
||||
nano CVS page</a> for info on anonymous CVS access to the nano source.</font></blockquote>
|
||||
|
||||
<hr WIDTH="100%">
|
||||
@@ -394,7 +394,7 @@ try:
|
||||
3.7. Tell me more about this multibuffer stuff!</font></h2>
|
||||
|
||||
<blockquote><font color="#330000"> To use multiple file buffers, you must
|
||||
be using nano 1.1.6 or newer, and you must have configured nano with
|
||||
be using nano 1.1.7 or newer, and you must have configured nano with
|
||||
<b>--enable-multibuffer</b> or <b>--enable-extra</b> (use nano -V to check).
|
||||
Then when you want to enable inserting a file into its own buffer instead of
|
||||
into the current file, just hit <b>Meta-F</b>, then insert the file as normal
|
||||
@@ -414,7 +414,7 @@ buffer is open.
|
||||
|
||||
<blockquote><font color="#330000"> It's not hard at all! But, your version
|
||||
of nano must have beem compiled with <b>--enable-nanorc</b>, and again must
|
||||
be version 1.1.6 or newer (use nano -V to check your version and compiled
|
||||
be version 1.1.7 or newer (use nano -V to check your version and compiled
|
||||
features). Then simply copy the <b>nanorc.sample</b>
|
||||
that came with the nano source or your nano package (most likely in
|
||||
/usr/doc/nano) to .nanorc in your home directory. If you didn't get one,
|
||||
@@ -441,7 +441,7 @@ keystroke here>!</font></h2>
|
||||
<blockquote><font color="#330000">If you aren't trying some bizarre keystroke
|
||||
combination with some bizarre $TERM entry, chances are you have found a
|
||||
bug. You are welcome to submit it to the
|
||||
<a href="mailto:nano-devel@lists.sourceforge.net">nano-devel</a> list or
|
||||
<a href="mailto:nano-devel@gnu.org">nano-devel</a> list or
|
||||
to <a href="mailto:nano@nano-editor.org">nano@nano-editor.org</a>.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -636,21 +636,33 @@ any changes in the past few years in a positive direction.</font></blockquote>
|
||||
<h2>
|
||||
<a NAME="7.1"></a><font color="#330000">7.1. Nano related mailing lists.</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">There are two mailing lists for nano
|
||||
hosted at <a href="http://www.sourceforge.net">SourceForge</a>, nano-announce
|
||||
<blockquote><font color="#330000">There are three mailing lists for nano
|
||||
hosted at <a href="http://savannah.gnu.org">Savannah</a>, info-nano, help-nano
|
||||
and nano-devel. Nano-announce is a very low traffic list where new
|
||||
versions of nano are announced (surprise!) Nano-devel is a normally
|
||||
low, sometimes high traffic list for discussing the present and future
|
||||
development of nano. Here are links to where you can sign up for
|
||||
development of nano. Help-nano is for getting help with the editor
|
||||
without needing to hear all of the development issues surrunding it.
|
||||
Here are links to where you can sign up for
|
||||
a given list:</font><font color="#330000"></font>
|
||||
<p><font color="#330000">nano-announce - <a href="http://lists.sourceforge.net/mailman/listinfo/nano-announce">http://lists.sourceforge.net/mailman/listinfo/nano-announce</a></font>
|
||||
<br><font color="#330000">nano-devel - <a href="http://lists.sourceforge.net/mailman/listinfo/nano-devel">http://lists.sourceforge.net/mailman/listinfo/nano-devel</a></font></blockquote>
|
||||
<p><font color="#330000">info-nano - <a href="
|
||||
http://mail.gnu.org/mailman/listinfo/info-nano">
|
||||
http://mail.gnu.org/mailman/listinfo/info-nano</a></font>
|
||||
<br>
|
||||
<font color="#330000">help-nano -
|
||||
<a href="http://mail.gnu.org/mailman/listinfo/help-nano">
|
||||
http://mail.gnu.org/mailman/listinfo/help-nano</a></font>
|
||||
<br>
|
||||
<font color="#330000">nano-devel -
|
||||
<a href="http://mail.gnu.org/mailman/listinfo/nano-devel">
|
||||
http://mail.gnu.org/mailman/listinfo/nano-devel</a></font>
|
||||
</blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="7.2"></a><font color="#330000">7.2. I want to send the development
|
||||
team a big load of cash (or just a thank you).</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">That's fine. Send it <a href="mailto:nano-devel@lists.sourceforge.net">our
|
||||
<blockquote><font color="#330000">That's fine. Send it <a href="mailto:nano-devel@gnu.org">our
|
||||
way</a>! Better yet, fix a <a href="http://www.nano-editor.org/dist/BUGS">bug</a>
|
||||
in the program or implement a <a href="http://www.nano-editor.org/dist/TODO">cool
|
||||
feature</a> and send us that instead (though cash is fine too).</font></blockquote>
|
||||
@@ -667,7 +679,7 @@ team?</font></h2>
|
||||
<blockquote><font color="#330000">The easiest way is to consistently send
|
||||
in good patches that add some needed functionality, fix a bug or two and/or
|
||||
make the program more optimized/efficient. Then ask nicely and you
|
||||
will probably be added to the SourceForge development list and be given
|
||||
will probably be added to the Savannah development list and be given
|
||||
CVS write after awhile. There is a lot of responsibility that goes
|
||||
along with being a team member, so don't think it's just something to add
|
||||
to your resume.</font></blockquote>
|
||||
|
||||
479
files.c
479
files.c
@@ -54,18 +54,10 @@ void load_file(int quiet)
|
||||
current = fileage;
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* if quiet is zero, add a new entry to the open_files structure, and
|
||||
do duplicate checking; otherwise, update the current entry and
|
||||
don't do duplicate checking (the latter is needed in the case of
|
||||
the alternate spell checker); if a duplicate entry was found,
|
||||
reload the currently open file (it may have been changed during
|
||||
duplicate handling) */
|
||||
if (quiet != 0)
|
||||
quiet = 1;
|
||||
if (add_open_file(quiet, 1 - quiet) == 2) {
|
||||
load_open_file();
|
||||
statusbar(_("File already loaded"));
|
||||
}
|
||||
/* if quiet is zero, add a new entry to the open_files structure;
|
||||
otherwise, update the current entry (the latter is needed in the
|
||||
case of the alternate spell checker) */
|
||||
add_open_file(quiet);
|
||||
#endif
|
||||
|
||||
wmove(edit, current_y, current_x);
|
||||
@@ -89,12 +81,11 @@ void new_file(void)
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* if there aren't any entries in open_files, create the entry for
|
||||
this new file, and, of course, don't bother checking for
|
||||
duplicates; without this, if nano is started without a filename on
|
||||
the command line, a new file will be created, but it will be given
|
||||
no open_files entry, leading to problems later on */
|
||||
this new file; without this, if nano is started without a filename
|
||||
on the command line, a new file will be created, but it will be
|
||||
given no open_files entry, leading to problems later on */
|
||||
if (!open_files) {
|
||||
add_open_file(0, 0);
|
||||
add_open_file(0);
|
||||
/* turn off view mode in this case; this is for consistency
|
||||
whether multibuffers are compiled in or not */
|
||||
UNSET(VIEW_MODE);
|
||||
@@ -108,7 +99,6 @@ void new_file(void)
|
||||
|
||||
}
|
||||
|
||||
|
||||
int read_byte(int fd, char *filename, char *input)
|
||||
{
|
||||
static char buf[BUFSIZ];
|
||||
@@ -141,8 +131,9 @@ filestruct *read_line(char *buf, filestruct * prev, int *line1ins)
|
||||
strcpy(fileptr->data, buf);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* If it's a DOS file (CRLF), strip out the CR part*/
|
||||
if (buf[strlen(buf) - 1] == '\r') {
|
||||
/* If it's a DOS file (CRLF), and file conversion isn't disabled,
|
||||
strip out the CR part */
|
||||
if (!ISSET(NO_CONVERT) && buf[strlen(buf) - 1] == '\r') {
|
||||
fileptr->data[strlen(buf) - 1] = 0;
|
||||
totsize--;
|
||||
|
||||
@@ -179,7 +170,6 @@ filestruct *read_line(char *buf, filestruct * prev, int *line1ins)
|
||||
return fileptr;
|
||||
}
|
||||
|
||||
|
||||
int read_file(int fd, char *filename, int quiet)
|
||||
{
|
||||
long size;
|
||||
@@ -211,8 +201,16 @@ int read_file(int fd, char *filename, int quiet)
|
||||
buf[0] = 0;
|
||||
i = 0;
|
||||
#ifndef NANO_SMALL
|
||||
/* If it's a Mac file (no LF just a CR), handle it! */
|
||||
} else if (i > 0 && buf[i-1] == '\r') {
|
||||
} else if (!ISSET(NO_CONVERT) && input[0] >= 0 && input[0] <= 31
|
||||
&& input[0] != '\t' && input[0] != '\r'
|
||||
&& input[0] != '\n')
|
||||
/* If the file has binary chars in it, don't stupidly
|
||||
assume it's a DOS or Mac formatted file! */
|
||||
SET(NO_CONVERT);
|
||||
|
||||
/* If it's a Mac file (no LF just a CR), and file conversion
|
||||
isn't disabled, handle it! */
|
||||
else if (!ISSET(NO_CONVERT) && i > 0 && buf[i-1] == '\r') {
|
||||
fileformat = 2;
|
||||
fileptr = read_line(buf, fileptr, &line1ins);
|
||||
num_lines++;
|
||||
@@ -289,9 +287,8 @@ int open_file(char *filename, int insert, int quiet)
|
||||
struct stat fileinfo;
|
||||
|
||||
if (!strcmp(filename, "") || stat(filename, &fileinfo) == -1) {
|
||||
if (insert) {
|
||||
if (!quiet)
|
||||
statusbar(_("\"%s\" not found"), filename);
|
||||
if (insert && !quiet) {
|
||||
statusbar(_("\"%s\" not found"), filename);
|
||||
return -1;
|
||||
} else {
|
||||
/* We have a new file */
|
||||
@@ -326,6 +323,38 @@ int open_file(char *filename, int insert, int quiet)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* This function will return the name of the first available extension
|
||||
of a filename (starting with the filename, then filename.1, etc).
|
||||
Memory is allocated for the return value. If no writable extension
|
||||
exists we return "" */
|
||||
char *get_next_filename(char *name)
|
||||
{
|
||||
int i = 0;
|
||||
char *buf = NULL;
|
||||
struct stat fs;
|
||||
|
||||
buf = charalloc(strlen(name) + num_of_digits(INT_MAX) + 2);
|
||||
strcpy(buf, name);
|
||||
|
||||
while(1) {
|
||||
|
||||
if (stat(buf, &fs) == -1)
|
||||
break;
|
||||
if (i == INT_MAX)
|
||||
break;
|
||||
|
||||
i++;
|
||||
strcpy(buf, name);
|
||||
sprintf(&buf[strlen(name)], ".%d", i);
|
||||
}
|
||||
|
||||
if (i == INT_MAX)
|
||||
buf[0] = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
int do_insertfile(int loading_file)
|
||||
{
|
||||
int i;
|
||||
@@ -335,11 +364,19 @@ int do_insertfile(int loading_file)
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
|
||||
currshortcut = insertfile_list;
|
||||
currslen = INSERTFILE_LIST_LEN;
|
||||
#endif
|
||||
|
||||
i = statusq(1, insertfile_list, INSERTFILE_LIST_LEN, "",
|
||||
_("File to insert [from ./] "));
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if ((operating_dir) && (strcmp(operating_dir,"."))){
|
||||
i = statusq(1, insertfile_list, "", _("File to insert [from %s] "),
|
||||
operating_dir);
|
||||
} else {
|
||||
#endif
|
||||
i = statusq(1, insertfile_list, "", _("File to insert [from ./] "));
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
}
|
||||
#endif
|
||||
|
||||
if (i != -1) {
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -358,7 +395,6 @@ int do_insertfile(int loading_file)
|
||||
char *tmp = do_browse_from(realname);
|
||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||
currshortcut = insertfile_list;
|
||||
currslen = INSERTFILE_LIST_LEN;
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_TABCOMP
|
||||
@@ -383,18 +419,15 @@ int do_insertfile(int loading_file)
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (loading_file) {
|
||||
|
||||
/* update the current entry in the open_files structure; we
|
||||
don't need to check for duplicate entries (the conditions
|
||||
that could create them are taken care of elsewhere) */
|
||||
add_open_file(1, 0);
|
||||
/* update the current entry in the open_files structure */
|
||||
add_open_file(1);
|
||||
|
||||
free_filestruct(fileage);
|
||||
new_file();
|
||||
UNSET(MODIFIED);
|
||||
}
|
||||
#endif
|
||||
|
||||
i = open_file(realname, 1, 0);
|
||||
i = open_file(realname, 1, loading_file);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (loading_file)
|
||||
@@ -468,25 +501,15 @@ int do_insertfile_void(void)
|
||||
/*
|
||||
* Add/update an entry to the open_files filestruct. If update is
|
||||
* zero, a new entry is created; otherwise, the current entry is updated.
|
||||
* If dup_fix is zero, checking for and handling duplicate entries is not
|
||||
* done; otherwise, it is. Return 0 on success, 1 on error, or 2 on
|
||||
* finding a duplicate entry.
|
||||
* Return 0 on success or 1 on error.
|
||||
*/
|
||||
int add_open_file(int update, int dup_fix)
|
||||
int add_open_file(int update)
|
||||
{
|
||||
filestruct *tmp;
|
||||
|
||||
if (!fileage || !current || !filename)
|
||||
return 1;
|
||||
|
||||
/* first, if duplicate checking is allowed, do it */
|
||||
if (dup_fix) {
|
||||
|
||||
/* if duplicates were found and handled, we're done */
|
||||
if (open_file_dup_fix(update))
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* if no entries, make the first one */
|
||||
if (!open_files) {
|
||||
open_files = make_new_node(NULL);
|
||||
@@ -494,6 +517,7 @@ int add_open_file(int update, int dup_fix)
|
||||
/* if open_files->file is NULL at the nrealloc() below, we get a
|
||||
segfault
|
||||
open_files->file = open_files; */
|
||||
open_files->file = NULL;
|
||||
}
|
||||
|
||||
else if (!update) {
|
||||
@@ -512,14 +536,12 @@ int add_open_file(int update, int dup_fix)
|
||||
/* if open_files->file is NULL at the nrealloc() below, we get a
|
||||
segfault
|
||||
open_files->file = open_files; */
|
||||
open_files->file = NULL;
|
||||
}
|
||||
|
||||
/* save current filename */
|
||||
open_files->data = mallocstrcpy(open_files->data, filename);
|
||||
|
||||
/* save the full path location */
|
||||
open_files->file_path = get_full_path(open_files->data);
|
||||
|
||||
/* save current total number of lines */
|
||||
open_files->file_totlines = totlines;
|
||||
|
||||
@@ -544,8 +566,7 @@ int add_open_file(int update, int dup_fix)
|
||||
if (!(ISSET(VIEW_MODE) && !update)) {
|
||||
/* save current filestruct and restore full file position
|
||||
afterward */
|
||||
open_files->file = nmalloc(sizeof(filestruct));
|
||||
open_files->file = copy_filestruct(fileage);
|
||||
open_files->file = fileage;
|
||||
do_gotopos(open_files->lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
|
||||
}
|
||||
|
||||
@@ -571,9 +592,6 @@ int open_file_change_name(void)
|
||||
/* save current filename */
|
||||
open_files->data = mallocstrcpy(open_files->data, filename);
|
||||
|
||||
/* save the full path location */
|
||||
open_files->file_path = get_full_path(open_files->data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -590,7 +608,7 @@ int load_open_file(void)
|
||||
/* set up the filename, the file buffer, the total number of lines in
|
||||
the file, and the total file size */
|
||||
filename = mallocstrcpy(filename, open_files->data);
|
||||
fileage = copy_filestruct(open_files->file);
|
||||
fileage = open_files->file;
|
||||
current = fileage;
|
||||
totlines = open_files->file_totlines;
|
||||
totsize = open_files->file_totsize;
|
||||
@@ -626,95 +644,6 @@ int load_open_file(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search the open_files structure for an entry with the same value for
|
||||
* the file_path member as the current entry (i. e. a duplicate entry).
|
||||
* If one is found, return a pointer to it; otherwise, return NULL.
|
||||
*
|
||||
* Note: This should only be called inside open_file_dup_fix().
|
||||
*/
|
||||
filestruct *open_file_dup_search(int update)
|
||||
{
|
||||
filestruct *tmp;
|
||||
char *path;
|
||||
|
||||
if (!open_files || !filename)
|
||||
return NULL;
|
||||
|
||||
tmp = open_files;
|
||||
path = get_full_path(filename);
|
||||
|
||||
/* if there's only one entry, handle it */
|
||||
if (!tmp->prev && !tmp->next) {
|
||||
if (!strcmp(tmp->file_path, path))
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* otherwise, go to the beginning */
|
||||
while (tmp->prev)
|
||||
tmp = tmp->prev;
|
||||
|
||||
/* and search the entries one by one */
|
||||
while (tmp) {
|
||||
|
||||
if (!strcmp(tmp->file_path, path)) {
|
||||
|
||||
if (!update)
|
||||
/* if we're making a new entry and there's an entry with
|
||||
the same full path, we've found a duplicate */
|
||||
return tmp;
|
||||
else {
|
||||
|
||||
/* if we're updating an existing entry and there's an
|
||||
entry with the same full path that isn't the current
|
||||
entry, we've found a duplicate */
|
||||
if (tmp != open_files)
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/* go to the next entry */
|
||||
tmp = tmp->next;
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for duplicate entries in the open_files structure using
|
||||
* open_file_dup_search(), and, if one is found, handle it properly.
|
||||
* Return 0 if no duplicates were found, and 1 otherwise.
|
||||
*/
|
||||
int open_file_dup_fix(int update)
|
||||
{
|
||||
filestruct *tmp = open_file_dup_search(update);
|
||||
|
||||
if (!tmp)
|
||||
return 0;
|
||||
|
||||
/* if there's only one entry, handle it */
|
||||
if (!tmp->prev && !tmp->next)
|
||||
return 1;
|
||||
|
||||
/* otherwise, if we're not updating, the user's trying to load a
|
||||
duplicate; switch to the original instead */
|
||||
if (!update) {
|
||||
open_files = tmp;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* if we are updating, the filename's been changed via a save; it's
|
||||
thus more recent than the original, so remove the original */
|
||||
else {
|
||||
unlink_node(tmp);
|
||||
free_filestruct(tmp->file);
|
||||
free(tmp->file_path);
|
||||
delete_node(tmp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open the previous entry in the open_files structure. If closing_file
|
||||
* is zero, update the current entry before switching from it.
|
||||
@@ -727,10 +656,9 @@ int open_prevfile(int closing_file)
|
||||
return 1;
|
||||
|
||||
/* if we're not about to close the current entry, update it before
|
||||
doing anything; since we're only switching, we don't need to check
|
||||
for duplicate entries */
|
||||
doing anything */
|
||||
if (!closing_file)
|
||||
add_open_file(1, 0);
|
||||
add_open_file(1);
|
||||
|
||||
if (!open_files->prev && !open_files->next) {
|
||||
|
||||
@@ -761,8 +689,12 @@ int open_prevfile(int closing_file)
|
||||
|
||||
}
|
||||
|
||||
/* free_filestruct(fileage); // delete this before reloading */
|
||||
load_open_file();
|
||||
|
||||
statusbar(_("Switched to %s"),
|
||||
((open_files->data[0] == '\0') ? "New Buffer" : open_files->data ));
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_buffer(current);
|
||||
#endif
|
||||
@@ -770,6 +702,13 @@ int open_prevfile(int closing_file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This function is used by the shortcut list. */
|
||||
int open_prevfile_void(void)
|
||||
{
|
||||
open_prevfile(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open the next entry in the open_files structure. If closing_file is
|
||||
* zero, update the current entry before switching from it. Otherwise, we
|
||||
@@ -782,10 +721,9 @@ int open_nextfile(int closing_file)
|
||||
return 1;
|
||||
|
||||
/* if we're not about to close the current entry, update it before
|
||||
doing anything; since we're only switching, we don't need to check
|
||||
for duplicate entries */
|
||||
doing anything */
|
||||
if (!closing_file)
|
||||
add_open_file(1, 0);
|
||||
add_open_file(1);
|
||||
|
||||
if (!open_files->prev && !open_files->next) {
|
||||
|
||||
@@ -818,6 +756,9 @@ int open_nextfile(int closing_file)
|
||||
|
||||
load_open_file();
|
||||
|
||||
statusbar(_("Switched to %s"),
|
||||
((open_files->data[0] == '\0') ? "New Buffer" : open_files->data ));
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_buffer(current);
|
||||
#endif
|
||||
@@ -825,6 +766,13 @@ int open_nextfile(int closing_file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This function is used by the shortcut list. */
|
||||
int open_nextfile_void(void)
|
||||
{
|
||||
open_nextfile(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete an entry from the open_files filestruct. After deletion of an
|
||||
* entry, the next or previous entry is opened, whichever is found first.
|
||||
@@ -845,16 +793,15 @@ int close_open_file(void)
|
||||
|
||||
unlink_node(tmp);
|
||||
free_filestruct(tmp->file);
|
||||
free(tmp->file_path);
|
||||
delete_node(tmp);
|
||||
|
||||
shortcut_init(0);
|
||||
display_main_list();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif /* MULTIBUFFER */
|
||||
|
||||
#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_OPERATINGDIR)
|
||||
#if !defined (DISABLE_SPELLER) || !defined (DISABLE_OPERATINGDIR)
|
||||
/*
|
||||
* When passed "[relative path]" or "[relative path][filename]" in
|
||||
* origpath, return "[full path]" or "[full path][filename]" on success,
|
||||
@@ -863,7 +810,7 @@ int close_open_file(void)
|
||||
* yet on disk); it is not done if the relative path doesn't exist (since
|
||||
* the first call to chdir() will fail then).
|
||||
*/
|
||||
char *get_full_path(char *origpath)
|
||||
char *get_full_path(const char *origpath)
|
||||
{
|
||||
char *newpath = NULL, *last_slash, *d_here, *d_there, *d_there_file, tmp;
|
||||
int path_only, last_slash_index;
|
||||
@@ -1003,7 +950,132 @@ char *get_full_path(char *origpath)
|
||||
|
||||
return newpath;
|
||||
}
|
||||
#endif /* ENABLE_MULTIBUFFER || !DISABLE_OPERATINGDIR */
|
||||
#endif /* !DISABLE_SPELLER || !DISABLE_OPERATINGDIR */
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
/*
|
||||
* This function accepts a path and returns the full path (via
|
||||
* get_full_path()). On error, if the path doesn't reference a
|
||||
* directory, or if the directory isn't writable, it returns NULL.
|
||||
*/
|
||||
char *check_writable_directory(const char *path) {
|
||||
|
||||
char *full_path = get_full_path(path);
|
||||
int writable;
|
||||
struct stat fileinfo;
|
||||
|
||||
/* if get_full_path() failed, return NULL */
|
||||
if (!full_path)
|
||||
return NULL;
|
||||
|
||||
/* otherwise, stat() the full path to see if it's writable by the
|
||||
user; set writable to 1 if it is, or 0 if it isn't */
|
||||
stat(path, &fileinfo);
|
||||
if (fileinfo.st_mode & S_IWUSR)
|
||||
writable = 1;
|
||||
else
|
||||
writable = 0;
|
||||
|
||||
/* if the full path doesn't end in a slash (meaning get_full_path()
|
||||
found that it isn't a directory) or isn't writable, free full_path
|
||||
and return NULL */
|
||||
if (full_path[strlen(full_path) - 1] != '/' || writable == 0) {
|
||||
free(full_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* otherwise, return the full path */
|
||||
return full_path;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function accepts a directory name and filename prefix the same
|
||||
* way that tempnam() does, determines the location for its temporary
|
||||
* file the same way that tempnam() does, safely creates the temporary
|
||||
* file there via mkstemp(), and returns the name of the temporary file
|
||||
* the same way that tempnam() does. It does not reference the value of
|
||||
* TMP_MAX because the total number of random filenames that it can
|
||||
* generate using one prefix is equal to 256**6, which is a sufficiently
|
||||
* large number to handle most cases. Since the behavior after tempnam()
|
||||
* generates TMP_MAX random filenames is implementation-defined, my
|
||||
* implementation is to go on generating random filenames regardless of
|
||||
* it.
|
||||
*/
|
||||
char *safe_tempnam(const char *dirname, const char *filename_prefix) {
|
||||
|
||||
char *buf, *tempdir = NULL, *full_tempdir = NULL;
|
||||
int filedesc;
|
||||
|
||||
/* if $TMPDIR is set and non-empty, set tempdir to it, run it through
|
||||
get_full_path(), and save the result in full_tempdir; otherwise,
|
||||
leave full_tempdir set to to NULL */
|
||||
if (getenv("TMPDIR") && strcmp(getenv("TMPDIR"),"")) {
|
||||
|
||||
/* store the value of $TMPDIR in tempdir, run its value through
|
||||
get_full_path(), and save the result in full_tempdir */
|
||||
tempdir = charalloc(strlen(getenv("TMPDIR")) + 1);
|
||||
sprintf(tempdir, "%s", getenv("TMPDIR"));
|
||||
full_tempdir = check_writable_directory(tempdir);
|
||||
|
||||
/* we don't need the value of tempdir anymore */
|
||||
free(tempdir);
|
||||
}
|
||||
|
||||
if (!full_tempdir) {
|
||||
|
||||
/* if $TMPDIR is blank or isn't set, or isn't a writable
|
||||
directory, and dirname isn't NULL, try it; otherwise, leave
|
||||
full_tempdir set to NULL */
|
||||
if (dirname) {
|
||||
tempdir = charalloc(strlen(dirname) + 1);
|
||||
strcpy(tempdir, dirname);
|
||||
full_tempdir = check_writable_directory(tempdir);
|
||||
|
||||
/* we don't need the value of tempdir anymore */
|
||||
free(tempdir);
|
||||
}
|
||||
}
|
||||
|
||||
/* if $TMPDIR is blank or isn't set, or if it isn't a writable
|
||||
directory, and dirname is NULL, try P_tmpdir instead */
|
||||
if (!full_tempdir) {
|
||||
tempdir = charalloc(strlen(P_tmpdir) + 1);
|
||||
strcpy(tempdir, P_tmpdir);
|
||||
full_tempdir = check_writable_directory(tempdir);
|
||||
|
||||
/* we don't need the value of tempdir anymore */
|
||||
free(tempdir);
|
||||
}
|
||||
|
||||
/* if P_tmpdir didn't work, use /tmp instead */
|
||||
if (!full_tempdir) {
|
||||
full_tempdir = charalloc(6);
|
||||
strcpy(full_tempdir, "/tmp/");
|
||||
}
|
||||
|
||||
buf = charalloc(strlen(full_tempdir) + 12);
|
||||
sprintf(buf, "%s", full_tempdir);
|
||||
|
||||
/* like tempnam(), use only the first 5 characters of the prefix */
|
||||
strncat(buf, filename_prefix, 5);
|
||||
|
||||
strcat(buf, "XXXXXX");
|
||||
filedesc = mkstemp(buf);
|
||||
|
||||
/* if mkstemp() failed, get out */
|
||||
if (filedesc == -1)
|
||||
return NULL;
|
||||
|
||||
/* otherwise, close the resulting file; afterwards, it'll be 0 bytes
|
||||
long, so delete it; finally, return the filename (all that's left
|
||||
of it) */
|
||||
else {
|
||||
close(filedesc);
|
||||
unlink(buf);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
#endif /* !DISABLE_SPELLER */
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
/*
|
||||
@@ -1014,10 +1086,10 @@ char *get_full_path(char *origpath)
|
||||
*/
|
||||
int check_operating_dir(char *currpath, int allow_tabcomp)
|
||||
{
|
||||
/* this is static so that we only need to get it the first time this
|
||||
function is called; also, a relative operating directory path will
|
||||
/* The char *full_operating_dir is global for mem cleanup, and
|
||||
therefore we only need to get it the first time this function
|
||||
is called; also, a relative operating directory path will
|
||||
only be handled properly if this is done */
|
||||
static char *full_operating_dir = NULL;
|
||||
|
||||
char *fullpath, *whereami1, *whereami2 = NULL;
|
||||
|
||||
@@ -1096,11 +1168,11 @@ int check_operating_dir(char *currpath, int allow_tabcomp)
|
||||
int write_file(char *name, int tmp, int append, int nonamechange)
|
||||
{
|
||||
long size, lineswritten = 0;
|
||||
static char *buf = NULL;
|
||||
char *buf = NULL;
|
||||
filestruct *fileptr;
|
||||
int fd, mask = 0, realexists, anyexists;
|
||||
struct stat st, lst;
|
||||
static char *realname = NULL;
|
||||
char *realname = NULL;
|
||||
|
||||
if (!strcmp(name, "")) {
|
||||
statusbar(_("Cancelled"));
|
||||
@@ -1308,6 +1380,7 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
||||
int do_writeout(char *path, int exiting, int append)
|
||||
{
|
||||
int i = 0;
|
||||
char *formatstr = NULL;
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
static int did_cred = 0;
|
||||
@@ -1315,7 +1388,6 @@ int do_writeout(char *path, int exiting, int append)
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
|
||||
currshortcut = writefile_list;
|
||||
currslen = WRITEFILE_LIST_LEN;
|
||||
#endif
|
||||
|
||||
answer = mallocstrcpy(answer, path);
|
||||
@@ -1336,24 +1408,32 @@ int do_writeout(char *path, int exiting, int append)
|
||||
|
||||
while (1) {
|
||||
|
||||
/* Be nice to the translation folks */
|
||||
#ifndef NANO_SMALL
|
||||
|
||||
if (ISSET(MAC_FILE))
|
||||
formatstr = _(" [Mac Format]");
|
||||
else if (ISSET(DOS_FILE))
|
||||
formatstr = _(" [DOS Format]");
|
||||
else
|
||||
formatstr = "";
|
||||
|
||||
/* Be nice to the translation folks */
|
||||
if (ISSET(MARK_ISSET) && !exiting) {
|
||||
if (append)
|
||||
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "",
|
||||
_("Append Selection to File"));
|
||||
i = statusq(1, writefile_list, "",
|
||||
"%s%s", _("Append Selection to File"), formatstr);
|
||||
else
|
||||
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "",
|
||||
_("Write Selection to File"));
|
||||
i = statusq(1, writefile_list, "",
|
||||
"%s%s", _("Write Selection to File"), formatstr);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (append)
|
||||
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, answer,
|
||||
_("File Name to Append"));
|
||||
i = statusq(1, writefile_list, answer,
|
||||
"%s%s", _("File Name to Append"), formatstr);
|
||||
else
|
||||
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, answer,
|
||||
_("File Name to Write"));
|
||||
i = statusq(1, writefile_list, answer,
|
||||
"%s%s", _("File Name to Write"), formatstr);
|
||||
|
||||
}
|
||||
|
||||
@@ -1366,7 +1446,6 @@ int do_writeout(char *path, int exiting, int append)
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
|
||||
currshortcut = writefile_list;
|
||||
currslen = WRITEFILE_LIST_LEN;
|
||||
#endif
|
||||
|
||||
if (tmp != NULL) {
|
||||
@@ -1375,7 +1454,15 @@ int do_writeout(char *path, int exiting, int append)
|
||||
return do_writeout(answer, exiting, append);
|
||||
} else
|
||||
#endif
|
||||
if (i == NANO_APPEND_KEY)
|
||||
if (i == TOGGLE_DOS_KEY) {
|
||||
UNSET(MAC_FILE);
|
||||
TOGGLE(DOS_FILE);
|
||||
return(do_writeout(answer, exiting, append));
|
||||
} else if (i == TOGGLE_MAC_KEY) {
|
||||
UNSET(DOS_FILE);
|
||||
TOGGLE(MAC_FILE);
|
||||
return(do_writeout(answer, exiting, append));
|
||||
} else if (i == NANO_APPEND_KEY)
|
||||
return(do_writeout(answer, exiting, 1 - append));
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -1445,18 +1532,16 @@ int do_writeout(char *path, int exiting, int append)
|
||||
if (!exiting) {
|
||||
|
||||
/* first, if the filename was changed during the save,
|
||||
update the filename and full path stored in the
|
||||
current entry, and then update the current entry,
|
||||
checking for duplicate entries */
|
||||
update the filename stored in the current entry, and
|
||||
then update the current entry */
|
||||
if (strcmp(open_files->data, filename)) {
|
||||
open_file_change_name();
|
||||
add_open_file(1, 1);
|
||||
add_open_file(1);
|
||||
}
|
||||
else {
|
||||
|
||||
/* otherwise, just update the current entry without
|
||||
checking for duplicate entries */
|
||||
add_open_file(1, 0);
|
||||
/* otherwise, just update the current entry */
|
||||
add_open_file(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1970,7 +2055,6 @@ int diralphasort(const void *va, const void *vb) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the browser code, including the list of files in *path */
|
||||
char **browser_init(char *path, int *longest, int *numents)
|
||||
{
|
||||
@@ -2021,7 +2105,7 @@ void free_charptrarray(char **array, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len - 1; i++)
|
||||
for (i = 0; i < len; i++)
|
||||
free(array[i]);
|
||||
free(array);
|
||||
}
|
||||
@@ -2060,7 +2144,10 @@ void striponedir(char *foo)
|
||||
if (tmp != foo)
|
||||
*tmp = 0;
|
||||
else
|
||||
{ /* SPK may need to make a 'default' path here */
|
||||
if (*tmp != '/') *(tmp) = '.';
|
||||
*(tmp+1) = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -2101,7 +2188,7 @@ char *do_browser(char *inpath)
|
||||
|
||||
kb = keypad_on(edit, 1);
|
||||
titlebar(path);
|
||||
bottombars(browser_list, BROWSER_LIST_LEN);
|
||||
bottombars(browser_list);
|
||||
curs_set(0);
|
||||
wmove(edit, 0, 0);
|
||||
i = 0;
|
||||
@@ -2116,7 +2203,6 @@ char *do_browser(char *inpath)
|
||||
|
||||
#if !defined DISABLE_HELP || !defined(DISABLE_MOUSE)
|
||||
currshortcut = browser_list;
|
||||
currslen = BROWSER_LIST_LEN;
|
||||
#endif
|
||||
|
||||
editline = 0;
|
||||
@@ -2255,6 +2341,17 @@ char *do_browser(char *inpath)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* SPK for '.' path, get the current path via getcwd */
|
||||
if (!strcmp(path, "./..")) {
|
||||
free(path);
|
||||
path = getcwd(NULL, 0);
|
||||
striponedir(path);
|
||||
align(&path);
|
||||
free_charptrarray(filelist, numents);
|
||||
free(foo);
|
||||
return do_browser(path);
|
||||
}
|
||||
|
||||
st = filestat(path);
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
if ((test_dir = opendir(path)) == NULL) {
|
||||
@@ -2275,6 +2372,8 @@ char *do_browser(char *inpath)
|
||||
}
|
||||
|
||||
/* Start over again with the new path value */
|
||||
free_charptrarray(filelist, numents);
|
||||
free(foo);
|
||||
return do_browser(path);
|
||||
} else {
|
||||
retval = path;
|
||||
@@ -2287,8 +2386,8 @@ char *do_browser(char *inpath)
|
||||
case NANO_GOTO_KEY:
|
||||
|
||||
curs_set(1);
|
||||
j = statusq(0, gotodir_list, GOTODIR_LIST_LEN, "", _("Goto Directory"));
|
||||
bottombars(browser_list, BROWSER_LIST_LEN);
|
||||
j = statusq(0, gotodir_list, "", _("Goto Directory"));
|
||||
bottombars(browser_list);
|
||||
curs_set(0);
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
@@ -2309,7 +2408,7 @@ char *do_browser(char *inpath)
|
||||
char *saveanswer = NULL;
|
||||
|
||||
saveanswer = mallocstrcpy(saveanswer, answer);
|
||||
answer = realloc(answer, strlen(path) + strlen(saveanswer) + 2);
|
||||
answer = nrealloc(answer, strlen(path) + strlen(saveanswer) + 2);
|
||||
sprintf(answer, "%s/%s", path, saveanswer);
|
||||
free(saveanswer);
|
||||
}
|
||||
@@ -2462,8 +2561,4 @@ char *do_browse_from(char *inpath)
|
||||
return do_browser(tmp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
511
global.c
511
global.c
@@ -35,6 +35,7 @@
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
|
||||
int flags = 0; /* Our new flag containing many options */
|
||||
WINDOW *edit; /* The file portion of the editor */
|
||||
WINDOW *topwin; /* Top line of screen */
|
||||
@@ -58,6 +59,10 @@ filestruct *cutbuffer = NULL; /* A place to store cut text */
|
||||
filestruct *open_files = NULL; /* The list of open files */
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
char *quotestr = "> "; /* Quote string */
|
||||
#endif
|
||||
|
||||
char *answer = NULL; /* Answer str to many questions */
|
||||
int totlines = 0; /* Total number of lines in the file */
|
||||
long totsize = 0; /* Total number of bytes in the file */
|
||||
@@ -76,26 +81,26 @@ filestruct *mark_beginbuf; /* the begin marker buffer */
|
||||
int mark_beginx; /* X value in the string to start */
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
char *operating_dir = NULL; /* Operating directory, which we can't go
|
||||
higher than */
|
||||
char *operating_dir = NULL; /* Operating directory, which we can't */
|
||||
char *full_operating_dir = NULL;/* go higher than */
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
char *alt_speller; /* Alternative spell command */
|
||||
#endif
|
||||
|
||||
shortcut main_list[MAIN_LIST_LEN];
|
||||
shortcut whereis_list[WHEREIS_LIST_LEN];
|
||||
shortcut replace_list[REPLACE_LIST_LEN];
|
||||
shortcut replace_list_2[REPLACE_LIST_LEN]; /* 2nd half of replace dialog */
|
||||
shortcut goto_list[GOTO_LIST_LEN];
|
||||
shortcut gotodir_list[GOTODIR_LIST_LEN];
|
||||
shortcut writefile_list[WRITEFILE_LIST_LEN];
|
||||
shortcut insertfile_list[INSERTFILE_LIST_LEN];
|
||||
shortcut help_list[HELP_LIST_LEN];
|
||||
shortcut spell_list[SPELL_LIST_LEN];
|
||||
shortcut *main_list = NULL;
|
||||
shortcut *whereis_list = NULL;
|
||||
shortcut *replace_list = NULL;
|
||||
shortcut *replace_list_2 = NULL; /* 2nd half of replace dialog */
|
||||
shortcut *goto_list = NULL;
|
||||
shortcut *gotodir_list = NULL;
|
||||
shortcut *writefile_list = NULL;
|
||||
shortcut *insertfile_list = NULL;
|
||||
shortcut *help_list = NULL;
|
||||
shortcut *spell_list = NULL;
|
||||
#ifndef DISABLE_BROWSER
|
||||
shortcut browser_list[BROWSER_LIST_LEN];
|
||||
shortcut *browser_list = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -104,12 +109,11 @@ shortcut browser_list[BROWSER_LIST_LEN];
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined (DISABLE_HELP)
|
||||
shortcut *currshortcut = main_list; /* Current shortcut list we're using */
|
||||
int currslen = MAIN_VISIBLE; /* Length of current shortcut list */
|
||||
shortcut *currshortcut; /* Current shortcut list we're using */
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
toggle toggles[TOGGLE_LEN];
|
||||
toggle *toggles = NULL;
|
||||
#endif
|
||||
|
||||
/* Regular expressions */
|
||||
@@ -120,10 +124,33 @@ regmatch_t regmatches[10]; /* Match positions for parenthetical
|
||||
subexpressions, max of 10 */
|
||||
#endif
|
||||
|
||||
int length_of_list(shortcut *s)
|
||||
{
|
||||
int i = 0;
|
||||
shortcut *t;
|
||||
|
||||
for (t = s; t != NULL; t = t->next)
|
||||
i++;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Initialize a struct *without* our lovely braces =( */
|
||||
void sc_init_one(shortcut * s, int key, char *desc, char *help, int alt,
|
||||
void sc_init_one(shortcut **shortcutage, int key, char *desc, char *help, int alt,
|
||||
int misc1, int misc2, int view, int (*func) (void))
|
||||
{
|
||||
shortcut *s;
|
||||
|
||||
if (*shortcutage == NULL) {
|
||||
*shortcutage = nmalloc(sizeof(shortcut));
|
||||
s = *shortcutage;
|
||||
} else {
|
||||
for (s = *shortcutage; s->next != NULL; s = s->next)
|
||||
;
|
||||
s->next = nmalloc(sizeof(shortcut));
|
||||
s = s->next;
|
||||
}
|
||||
|
||||
s->val = key;
|
||||
s->desc = desc;
|
||||
s->help = help;
|
||||
@@ -132,17 +159,29 @@ void sc_init_one(shortcut * s, int key, char *desc, char *help, int alt,
|
||||
s->misc2 = misc2;
|
||||
s->viewok = view;
|
||||
s->func = func;
|
||||
s->next = NULL;
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Initialize the toggles in the same manner */
|
||||
void toggle_init_one(toggle * t, int val, char *desc, int flag,
|
||||
char override_ch)
|
||||
void toggle_init_one(int val, char *desc, int flag)
|
||||
{
|
||||
t->val = val;
|
||||
t->desc = desc;
|
||||
t->flag = flag;
|
||||
t->override_ch = override_ch;
|
||||
toggle *u;
|
||||
|
||||
if (toggles == NULL) {
|
||||
toggles = nmalloc(sizeof(toggle));
|
||||
u = toggles;
|
||||
} else {
|
||||
for (u = toggles; u->next != NULL; u = u->next)
|
||||
;
|
||||
u->next = nmalloc(sizeof(toggle));
|
||||
u = u->next;
|
||||
}
|
||||
|
||||
u->val = val;
|
||||
u->desc = desc;
|
||||
u->flag = flag;
|
||||
u->next = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -152,17 +191,16 @@ void toggle_init(void)
|
||||
char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
|
||||
*toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg,
|
||||
*toggle_cuttoend_msg, *toggle_wrap_msg, *toggle_case_msg,
|
||||
*toggle_backwards_msg, *toggle_dos_msg, *toggle_mac_msg,
|
||||
*toggle_smooth_msg;
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
char *toggle_load_msg, *nano_openprev_msg, *nano_opennext_msg;
|
||||
#endif
|
||||
*toggle_backwards_msg, *toggle_noconvert_msg, *toggle_dos_msg,
|
||||
*toggle_mac_msg, *toggle_smooth_msg;
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
char *toggle_regexp_msg;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
char *toggle_load_msg;
|
||||
#endif
|
||||
|
||||
toggle_const_msg = _("Constant cursor position");
|
||||
toggle_autoindent_msg = _("Auto indent");
|
||||
@@ -173,62 +211,42 @@ void toggle_init(void)
|
||||
toggle_cuttoend_msg = _("Cut to end");
|
||||
toggle_backwards_msg = _("Backwards search");
|
||||
toggle_case_msg = _("Case sensitive search");
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
toggle_regexp_msg = _("Regular expression search");
|
||||
#endif
|
||||
|
||||
toggle_noconvert_msg = _("No conversion from DOS/Mac format");
|
||||
toggle_dos_msg = _("Writing file in DOS format");
|
||||
toggle_mac_msg = _("Writing file in Mac format");
|
||||
toggle_smooth_msg = _("Smooth scrolling");
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
toggle_regexp_msg = _("Regular expressions");
|
||||
#endif
|
||||
toggle_wrap_msg = _("Auto wrap");
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
toggle_load_msg = _("Multiple file buffers");
|
||||
nano_openprev_msg = _("Open previously loaded file");
|
||||
nano_opennext_msg = _("Open next loaded file");
|
||||
#endif
|
||||
|
||||
toggle_init_one(&toggles[0], TOGGLE_CONST_KEY, toggle_const_msg,
|
||||
CONSTUPDATE, 0);
|
||||
toggle_init_one(&toggles[1], TOGGLE_AUTOINDENT_KEY,
|
||||
toggle_autoindent_msg, AUTOINDENT, 0);
|
||||
toggle_init_one(&toggles[2], TOGGLE_SUSPEND_KEY, toggle_suspend_msg,
|
||||
SUSPEND, 0);
|
||||
toggle_init_one(&toggles[3], TOGGLE_NOHELP_KEY, toggle_nohelp_msg,
|
||||
NO_HELP, 0);
|
||||
toggle_init_one(&toggles[4], TOGGLE_PICOMODE_KEY, toggle_picomode_msg,
|
||||
PICO_MODE, 0);
|
||||
toggle_init_one(&toggles[5], TOGGLE_WRAP_KEY, toggle_wrap_msg,
|
||||
NO_WRAP, 0);
|
||||
toggle_init_one(&toggles[6], TOGGLE_MOUSE_KEY, toggle_mouse_msg,
|
||||
USE_MOUSE, 0);
|
||||
toggle_init_one(&toggles[7], TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg,
|
||||
CUT_TO_END, 0);
|
||||
toggle_init_one(&toggles[8], TOGGLE_BACKWARDS_KEY, toggle_backwards_msg,
|
||||
REVERSE_SEARCH, 0);
|
||||
toggle_init_one(&toggles[9], TOGGLE_CASE_KEY, toggle_case_msg,
|
||||
CASE_SENSITIVE, 0);
|
||||
toggle_init_one(&toggles[10], TOGGLE_DOS_KEY, toggle_dos_msg,
|
||||
DOS_FILE, 0);
|
||||
toggle_init_one(&toggles[11], TOGGLE_MAC_KEY, toggle_mac_msg,
|
||||
MAC_FILE, 0);
|
||||
toggle_init_one(&toggles[12], TOGGLE_SMOOTH_KEY, toggle_smooth_msg,
|
||||
SMOOTHSCROLL, 0);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
toggle_init_one(&toggles[13], TOGGLE_LOAD_KEY, toggle_load_msg,
|
||||
MULTIBUFFER, 0);
|
||||
toggle_init_one(&toggles[14], NANO_OPENPREV_KEY, nano_openprev_msg,
|
||||
0, '<');
|
||||
toggle_init_one(&toggles[15], NANO_OPENNEXT_KEY, nano_opennext_msg,
|
||||
0, '>');
|
||||
#endif
|
||||
|
||||
toggle_init_one(TOGGLE_CONST_KEY, toggle_const_msg, CONSTUPDATE);
|
||||
toggle_init_one(TOGGLE_AUTOINDENT_KEY, toggle_autoindent_msg, AUTOINDENT);
|
||||
toggle_init_one(TOGGLE_SUSPEND_KEY, toggle_suspend_msg, SUSPEND);
|
||||
toggle_init_one(TOGGLE_NOHELP_KEY, toggle_nohelp_msg, NO_HELP);
|
||||
toggle_init_one(TOGGLE_PICOMODE_KEY, toggle_picomode_msg, PICO_MODE);
|
||||
toggle_init_one(TOGGLE_WRAP_KEY, toggle_wrap_msg, NO_WRAP);
|
||||
toggle_init_one(TOGGLE_MOUSE_KEY, toggle_mouse_msg, USE_MOUSE);
|
||||
toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END);
|
||||
toggle_init_one(TOGGLE_BACKWARDS_KEY, toggle_backwards_msg, REVERSE_SEARCH);
|
||||
toggle_init_one(TOGGLE_CASE_KEY, toggle_case_msg, CASE_SENSITIVE);
|
||||
#ifdef HAVE_REGEX_H
|
||||
toggle_init_one(&toggles[TOGGLE_LEN - 1], TOGGLE_REGEXP_KEY,
|
||||
toggle_regexp_msg, USE_REGEXP, 0);
|
||||
toggle_init_one(TOGGLE_REGEXP_KEY, toggle_regexp_msg, USE_REGEXP);
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
toggle_init_one(TOGGLE_LOAD_KEY, toggle_load_msg, MULTIBUFFER);
|
||||
#endif
|
||||
toggle_init_one(TOGGLE_NOCONVERT_KEY, toggle_noconvert_msg, NO_CONVERT);
|
||||
toggle_init_one(TOGGLE_DOS_KEY, toggle_dos_msg, DOS_FILE);
|
||||
toggle_init_one(TOGGLE_MAC_KEY, toggle_mac_msg, MAC_FILE);
|
||||
toggle_init_one(TOGGLE_SMOOTH_KEY, toggle_smooth_msg, SMOOTHSCROLL);
|
||||
#endif /* !NANO_SMALL */
|
||||
}
|
||||
|
||||
void shortcut_init(int unjustify)
|
||||
@@ -245,14 +263,20 @@ void shortcut_init(int unjustify)
|
||||
"", *nano_mark_msg = "", *nano_delete_msg =
|
||||
"", *nano_backspace_msg = "", *nano_tab_msg =
|
||||
"", *nano_enter_msg = "", *nano_cancel_msg =
|
||||
"", *nano_unjustify_msg = "", *nano_append_msg = "";
|
||||
"", *nano_unjustify_msg = "", *nano_append_msg =
|
||||
"";
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
char *nano_tofiles_msg = "", *nano_gotodir_msg = "", *nano_case_msg =
|
||||
"", *nano_reverse_msg = "";
|
||||
char *nano_dos_msg = "", *nano_mac_msg = "";
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
char *nano_regexp_msg = "", *nano_bracket_msg = "";
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
char *nano_openprev_msg = "", *nano_opennext_msg = "";
|
||||
#endif
|
||||
|
||||
nano_help_msg = _("Invoke the help menu");
|
||||
nano_writeout_msg = _("Write the current file to disk");
|
||||
@@ -297,41 +321,50 @@ void shortcut_init(int unjustify)
|
||||
nano_cancel_msg = _("Cancel the current function");
|
||||
nano_append_msg = _("Append to the current file");
|
||||
nano_reverse_msg = _("Search backwards");
|
||||
nano_dos_msg = _("Write file out in DOS format");
|
||||
nano_mac_msg = _("Write file out in Mac format");
|
||||
#ifdef HAVE_REGEX_H
|
||||
nano_regexp_msg = _("Use Regular expressions");
|
||||
nano_bracket_msg = _("Find other bracket");
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
nano_openprev_msg = _("Open previously loaded file");
|
||||
nano_opennext_msg = _("Open next loaded file");
|
||||
#endif
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
sc_init_one(&main_list[0], NANO_HELP_KEY, _("Get Help"),
|
||||
if (main_list != NULL)
|
||||
free_shortcutage(&main_list);
|
||||
|
||||
sc_init_one(&main_list, NANO_HELP_KEY, _("Get Help"),
|
||||
nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (open_files != NULL && (open_files->prev || open_files->next))
|
||||
sc_init_one(&main_list[1], NANO_EXIT_KEY, _("Close"),
|
||||
sc_init_one(&main_list, NANO_EXIT_KEY, _("Close"),
|
||||
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
|
||||
else
|
||||
#endif
|
||||
sc_init_one(&main_list[1], NANO_EXIT_KEY, _("Exit"),
|
||||
sc_init_one(&main_list, NANO_EXIT_KEY, _("Exit"),
|
||||
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
|
||||
|
||||
sc_init_one(&main_list[2], NANO_WRITEOUT_KEY, _("WriteOut"),
|
||||
sc_init_one(&main_list, NANO_WRITEOUT_KEY, _("WriteOut"),
|
||||
nano_writeout_msg,
|
||||
0, NANO_WRITEOUT_FKEY, 0, NOVIEW, do_writeout_void);
|
||||
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[3], NANO_JUSTIFY_KEY, _("Justify"),
|
||||
sc_init_one(&main_list, NANO_JUSTIFY_KEY, _("Justify"),
|
||||
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
|
||||
NOVIEW, do_justify);
|
||||
else
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* this is so we can view multiple files */
|
||||
sc_init_one(&main_list[3], NANO_INSERTFILE_KEY, _("Read File"),
|
||||
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
|
||||
nano_insert_msg,
|
||||
0, NANO_INSERTFILE_FKEY, 0, VIEW, do_insertfile_void);
|
||||
#else
|
||||
sc_init_one(&main_list[3], NANO_INSERTFILE_KEY, _("Read File"),
|
||||
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
|
||||
nano_insert_msg,
|
||||
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
|
||||
#endif
|
||||
@@ -340,273 +373,437 @@ void shortcut_init(int unjustify)
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* this is so we can view multiple files */
|
||||
sc_init_one(&main_list[4], NANO_INSERTFILE_KEY, _("Read File"),
|
||||
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
|
||||
nano_insert_msg,
|
||||
0, NANO_INSERTFILE_FKEY, 0, VIEW, do_insertfile_void);
|
||||
#else
|
||||
sc_init_one(&main_list[4], NANO_INSERTFILE_KEY, _("Read File"),
|
||||
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
|
||||
nano_insert_msg,
|
||||
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
|
||||
#endif
|
||||
|
||||
else
|
||||
sc_init_one(&main_list[4], NANO_REPLACE_KEY, _("Replace"),
|
||||
sc_init_one(&main_list, NANO_REPLACE_KEY, _("Replace"),
|
||||
nano_replace_msg,
|
||||
NANO_ALT_REPLACE_KEY, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
|
||||
|
||||
sc_init_one(&main_list[5], NANO_WHEREIS_KEY, _("Where Is"),
|
||||
sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"),
|
||||
nano_whereis_msg,
|
||||
0, NANO_WHEREIS_FKEY, 0, VIEW, do_search);
|
||||
|
||||
sc_init_one(&main_list[6], NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
sc_init_one(&main_list, NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
nano_prevpage_msg,
|
||||
0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, do_page_up);
|
||||
|
||||
sc_init_one(&main_list[7], NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
sc_init_one(&main_list, NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
nano_nextpage_msg,
|
||||
0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, do_page_down);
|
||||
|
||||
sc_init_one(&main_list[8], NANO_CUT_KEY, _("Cut Text"),
|
||||
sc_init_one(&main_list, NANO_CUT_KEY, _("Cut Text"),
|
||||
nano_cut_msg, 0, NANO_CUT_FKEY, 0, NOVIEW, do_cut_text);
|
||||
|
||||
if (unjustify)
|
||||
sc_init_one(&main_list[9], NANO_UNJUSTIFY_KEY, _("UnJustify"),
|
||||
sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, _("UnJustify"),
|
||||
nano_unjustify_msg, 0, 0, 0, NOVIEW, do_uncut_text);
|
||||
else
|
||||
sc_init_one(&main_list[9], NANO_UNCUT_KEY, _("UnCut Txt"),
|
||||
sc_init_one(&main_list, NANO_UNCUT_KEY, _("UnCut Txt"),
|
||||
nano_uncut_msg,
|
||||
0, NANO_UNCUT_FKEY, 0, NOVIEW, do_uncut_text);
|
||||
|
||||
sc_init_one(&main_list[10], NANO_CURSORPOS_KEY, _("Cur Pos"),
|
||||
sc_init_one(&main_list, NANO_CURSORPOS_KEY, _("Cur Pos"),
|
||||
nano_cursorpos_msg,
|
||||
0, NANO_CURSORPOS_FKEY, 0, VIEW, do_cursorpos_void);
|
||||
|
||||
sc_init_one(&main_list[11], NANO_SPELL_KEY, _("To Spell"),
|
||||
sc_init_one(&main_list, NANO_SPELL_KEY, _("To Spell"),
|
||||
nano_spell_msg, 0, NANO_SPELL_FKEY, 0, NOVIEW, do_spell);
|
||||
|
||||
|
||||
sc_init_one(&main_list[12], NANO_UP_KEY, _("Up"),
|
||||
sc_init_one(&main_list, NANO_UP_KEY, _("Up"),
|
||||
nano_up_msg, 0, KEY_UP, 0, VIEW, do_up);
|
||||
|
||||
sc_init_one(&main_list[13], NANO_DOWN_KEY, _("Down"),
|
||||
sc_init_one(&main_list, NANO_DOWN_KEY, _("Down"),
|
||||
nano_down_msg, 0, KEY_DOWN, 0, VIEW, do_down);
|
||||
|
||||
sc_init_one(&main_list[14], NANO_FORWARD_KEY, _("Forward"),
|
||||
sc_init_one(&main_list, NANO_FORWARD_KEY, _("Forward"),
|
||||
nano_forward_msg, 0, KEY_RIGHT, 0, VIEW, do_right);
|
||||
|
||||
sc_init_one(&main_list[15], NANO_BACK_KEY, _("Back"),
|
||||
sc_init_one(&main_list, NANO_BACK_KEY, _("Back"),
|
||||
nano_back_msg, 0, KEY_LEFT, 0, VIEW, do_left);
|
||||
|
||||
sc_init_one(&main_list[16], NANO_HOME_KEY, _("Home"),
|
||||
sc_init_one(&main_list, NANO_HOME_KEY, _("Home"),
|
||||
nano_home_msg, 0, KEY_HOME, 362, VIEW, do_home);
|
||||
|
||||
sc_init_one(&main_list[17], NANO_END_KEY, _("End"),
|
||||
sc_init_one(&main_list, NANO_END_KEY, _("End"),
|
||||
nano_end_msg, 0, KEY_END, 385, VIEW, do_end);
|
||||
|
||||
sc_init_one(&main_list[18], NANO_REFRESH_KEY, _("Refresh"),
|
||||
sc_init_one(&main_list, NANO_REFRESH_KEY, _("Refresh"),
|
||||
nano_refresh_msg, 0, 0, 0, VIEW, total_refresh);
|
||||
|
||||
sc_init_one(&main_list[19], NANO_MARK_KEY, _("Mark Text"),
|
||||
sc_init_one(&main_list, NANO_MARK_KEY, _("Mark Text"),
|
||||
nano_mark_msg, NANO_ALT_MARK_KEY, 0, 0, NOVIEW, do_mark);
|
||||
|
||||
sc_init_one(&main_list[20], NANO_DELETE_KEY, _("Delete"),
|
||||
sc_init_one(&main_list, NANO_DELETE_KEY, _("Delete"),
|
||||
nano_delete_msg, 0, KEY_DC,
|
||||
NANO_CONTROL_D, NOVIEW, do_delete);
|
||||
|
||||
sc_init_one(&main_list[21], NANO_BACKSPACE_KEY, _("Backspace"),
|
||||
sc_init_one(&main_list, NANO_BACKSPACE_KEY, _("Backspace"),
|
||||
nano_backspace_msg, 0,
|
||||
KEY_BACKSPACE, 127, NOVIEW, do_backspace);
|
||||
|
||||
sc_init_one(&main_list[22], NANO_TAB_KEY, _("Tab"),
|
||||
sc_init_one(&main_list, NANO_TAB_KEY, _("Tab"),
|
||||
nano_tab_msg, 0, 0, 0, NOVIEW, do_tab);
|
||||
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[23], NANO_REPLACE_KEY, _("Replace"),
|
||||
sc_init_one(&main_list, NANO_REPLACE_KEY, _("Replace"),
|
||||
nano_replace_msg,
|
||||
NANO_ALT_REPLACE_KEY, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
|
||||
else
|
||||
sc_init_one(&main_list[23], NANO_JUSTIFY_KEY, _("Justify"),
|
||||
sc_init_one(&main_list, NANO_JUSTIFY_KEY, _("Justify"),
|
||||
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
|
||||
NOVIEW, do_justify);
|
||||
|
||||
sc_init_one(&main_list[24], NANO_ENTER_KEY, _("Enter"),
|
||||
sc_init_one(&main_list, NANO_ENTER_KEY, _("Enter"),
|
||||
nano_enter_msg,
|
||||
0, KEY_ENTER, NANO_CONTROL_M, NOVIEW, do_enter_void);
|
||||
|
||||
sc_init_one(&main_list[25], NANO_GOTO_KEY, _("Goto Line"),
|
||||
sc_init_one(&main_list, NANO_GOTO_KEY, _("Goto Line"),
|
||||
nano_goto_msg,
|
||||
NANO_ALT_GOTO_KEY, NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void);
|
||||
|
||||
#if (!defined NANO_SMALL) && (defined HAVE_REGEX_H)
|
||||
sc_init_one(&main_list[26], -9, _("Find Other Bracket"),
|
||||
sc_init_one(&main_list, -9, _("Find Other Bracket"),
|
||||
nano_bracket_msg,
|
||||
NANO_BRACKET_KEY, 0, 0, VIEW, do_find_bracket);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
sc_init_one(&main_list, -9, _("Previous File"),
|
||||
nano_openprev_msg,
|
||||
NANO_OPENPREV_KEY, 0, 0, VIEW, open_prevfile_void);
|
||||
sc_init_one(&main_list, -9, _("Next File"),
|
||||
nano_opennext_msg,
|
||||
NANO_OPENNEXT_KEY, 0, 0, VIEW, open_nextfile_void);
|
||||
#endif
|
||||
|
||||
sc_init_one(&whereis_list[0], NANO_HELP_KEY,
|
||||
if (whereis_list != NULL)
|
||||
free_shortcutage(&whereis_list);
|
||||
|
||||
sc_init_one(&whereis_list, NANO_HELP_KEY,
|
||||
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&whereis_list[1], NANO_CANCEL_KEY,
|
||||
sc_init_one(&whereis_list, NANO_CANCEL_KEY,
|
||||
_("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&whereis_list[2], NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
nano_firstline_msg, 0, 0, 0, VIEW, do_first_line);
|
||||
|
||||
sc_init_one(&whereis_list[3], NANO_LASTLINE_KEY, _("Last Line"),
|
||||
sc_init_one(&whereis_list, NANO_LASTLINE_KEY, _("Last Line"),
|
||||
nano_lastline_msg, 0, 0, 0, VIEW, do_last_line);
|
||||
|
||||
sc_init_one(&whereis_list[4], NANO_OTHERSEARCH_KEY, _("Replace"),
|
||||
sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, _("Replace"),
|
||||
nano_replace_msg, 0, 0, 0, VIEW, do_replace);
|
||||
|
||||
sc_init_one(&whereis_list[5], NANO_FROMSEARCHTOGOTO_KEY,
|
||||
sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY,
|
||||
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
|
||||
do_gotoline_void);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
sc_init_one(&whereis_list[6], TOGGLE_CASE_KEY, _("Case Sens"),
|
||||
sc_init_one(&whereis_list, TOGGLE_CASE_KEY, _("Case Sens"),
|
||||
nano_case_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&whereis_list[7], TOGGLE_BACKWARDS_KEY, _("Direction"),
|
||||
sc_init_one(&whereis_list, TOGGLE_BACKWARDS_KEY, _("Direction"),
|
||||
nano_reverse_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
sc_init_one(&whereis_list[REPLACE_LIST_LEN - 1], TOGGLE_REGEXP_KEY,
|
||||
sc_init_one(&whereis_list, TOGGLE_REGEXP_KEY,
|
||||
_("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0);
|
||||
#endif
|
||||
#endif /* NANO_SMALL */
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
if (replace_list != NULL)
|
||||
free_shortcutage(&replace_list);
|
||||
|
||||
sc_init_one(&replace_list[0], NANO_HELP_KEY,
|
||||
sc_init_one(&replace_list, NANO_HELP_KEY,
|
||||
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&replace_list[1], NANO_CANCEL_KEY,
|
||||
sc_init_one(&replace_list, NANO_CANCEL_KEY,
|
||||
_("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&replace_list[2], NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
nano_firstline_msg, 0, 0, 0, VIEW, do_first_line);
|
||||
|
||||
sc_init_one(&replace_list[3], NANO_LASTLINE_KEY, _("Last Line"),
|
||||
sc_init_one(&replace_list, NANO_LASTLINE_KEY, _("Last Line"),
|
||||
nano_lastline_msg, 0, 0, 0, VIEW, do_last_line);
|
||||
|
||||
sc_init_one(&replace_list[4], NANO_OTHERSEARCH_KEY, _("No Replace"),
|
||||
sc_init_one(&replace_list, NANO_OTHERSEARCH_KEY, _("No Replace"),
|
||||
nano_whereis_msg, 0, 0, 0, VIEW, do_search);
|
||||
|
||||
sc_init_one(&replace_list[5], NANO_FROMSEARCHTOGOTO_KEY,
|
||||
sc_init_one(&replace_list, NANO_FROMSEARCHTOGOTO_KEY,
|
||||
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
|
||||
do_gotoline_void);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
sc_init_one(&replace_list[6], TOGGLE_CASE_KEY, _("Case Sens"),
|
||||
sc_init_one(&replace_list, TOGGLE_CASE_KEY, _("Case Sens"),
|
||||
nano_case_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&replace_list[7], TOGGLE_BACKWARDS_KEY, _("Direction"),
|
||||
sc_init_one(&replace_list, TOGGLE_BACKWARDS_KEY, _("Direction"),
|
||||
nano_reverse_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
sc_init_one(&replace_list[REPLACE_LIST_LEN - 1], TOGGLE_REGEXP_KEY,
|
||||
sc_init_one(&replace_list, TOGGLE_REGEXP_KEY,
|
||||
_("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0);
|
||||
#endif
|
||||
#endif /* NANO_SMALL */
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
if (replace_list_2 != NULL)
|
||||
free_shortcutage(&replace_list_2);
|
||||
|
||||
sc_init_one(&replace_list_2[0], NANO_HELP_KEY,
|
||||
sc_init_one(&replace_list_2, NANO_HELP_KEY,
|
||||
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&replace_list_2[1], NANO_CANCEL_KEY,
|
||||
sc_init_one(&replace_list_2, NANO_CANCEL_KEY,
|
||||
_("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&replace_list_2[2], NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
nano_firstline_msg, 0, 0, 0, VIEW, do_first_line);
|
||||
|
||||
sc_init_one(&replace_list_2[3], NANO_LASTLINE_KEY, _("Last Line"),
|
||||
sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, _("Last Line"),
|
||||
nano_lastline_msg, 0, 0, 0, VIEW, do_last_line);
|
||||
|
||||
if (goto_list != NULL)
|
||||
free_shortcutage(&goto_list);
|
||||
|
||||
sc_init_one(&goto_list[0], NANO_HELP_KEY,
|
||||
sc_init_one(&goto_list, NANO_HELP_KEY,
|
||||
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&goto_list[1], NANO_CANCEL_KEY, _("Cancel"),
|
||||
sc_init_one(&goto_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&goto_list[2], NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
sc_init_one(&goto_list, NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
nano_firstline_msg, 0, 0, 0, VIEW, &do_first_line);
|
||||
|
||||
sc_init_one(&goto_list[3], NANO_LASTLINE_KEY, _("Last Line"),
|
||||
sc_init_one(&goto_list, NANO_LASTLINE_KEY, _("Last Line"),
|
||||
nano_lastline_msg, 0, 0, 0, VIEW, &do_last_line);
|
||||
|
||||
if (help_list != NULL)
|
||||
free_shortcutage(&help_list);
|
||||
|
||||
sc_init_one(&help_list[0], NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
sc_init_one(&help_list, NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
nano_prevpage_msg,
|
||||
0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, do_page_up);
|
||||
|
||||
sc_init_one(&help_list[1], NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
sc_init_one(&help_list, NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
nano_nextpage_msg,
|
||||
0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, do_page_down);
|
||||
|
||||
sc_init_one(&help_list[2], NANO_EXIT_KEY, _("Exit"),
|
||||
sc_init_one(&help_list, NANO_EXIT_KEY, _("Exit"),
|
||||
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
|
||||
|
||||
if (writefile_list != NULL)
|
||||
free_shortcutage(&writefile_list);
|
||||
|
||||
sc_init_one(&writefile_list[0], NANO_HELP_KEY,
|
||||
sc_init_one(&writefile_list, NANO_HELP_KEY,
|
||||
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&writefile_list[1], NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
sc_init_one(&writefile_list[2], NANO_TOFILES_KEY, _("To Files"),
|
||||
sc_init_one(&writefile_list, NANO_TOFILES_KEY, _("To Files"),
|
||||
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
sc_init_one(&writefile_list[WRITEFILE_LIST_LEN - 1], NANO_APPEND_KEY, _("Append"),
|
||||
#ifndef NANO_SMALL
|
||||
sc_init_one(&writefile_list, TOGGLE_DOS_KEY,
|
||||
_("DOS Format"), nano_dos_msg, 0, 0, 0, NOVIEW, 0);
|
||||
|
||||
sc_init_one(&writefile_list, TOGGLE_MAC_KEY,
|
||||
_("Mac Format"), nano_mac_msg, 0, 0, 0, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
sc_init_one(&writefile_list,
|
||||
NANO_APPEND_KEY, _("Append"),
|
||||
nano_append_msg, 0, 0, 0, NOVIEW, 0);
|
||||
|
||||
sc_init_one(&insertfile_list[0], NANO_HELP_KEY,
|
||||
sc_init_one(&writefile_list, NANO_CANCEL_KEY,
|
||||
_("Cancel"), nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
if (insertfile_list != NULL)
|
||||
free_shortcutage(&insertfile_list);
|
||||
|
||||
sc_init_one(&insertfile_list, NANO_HELP_KEY,
|
||||
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&insertfile_list[1], NANO_CANCEL_KEY, _("Cancel"),
|
||||
sc_init_one(&insertfile_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
sc_init_one(&insertfile_list[2], NANO_TOFILES_KEY, _("To Files"),
|
||||
sc_init_one(&insertfile_list, NANO_TOFILES_KEY, _("To Files"),
|
||||
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
sc_init_one(&spell_list[0], NANO_HELP_KEY,
|
||||
sc_init_one(&spell_list, NANO_HELP_KEY,
|
||||
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&spell_list[1], NANO_CANCEL_KEY, _("Cancel"),
|
||||
sc_init_one(&spell_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
sc_init_one(&browser_list[0], NANO_HELP_KEY,
|
||||
|
||||
if (browser_list != NULL)
|
||||
free_shortcutage(&browser_list);
|
||||
|
||||
sc_init_one(&browser_list, NANO_HELP_KEY,
|
||||
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&browser_list[1], NANO_EXIT_KEY, _("Exit"),
|
||||
sc_init_one(&browser_list, NANO_EXIT_KEY, _("Exit"),
|
||||
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&browser_list[2], NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
sc_init_one(&browser_list, NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
nano_prevpage_msg,
|
||||
0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, 0);
|
||||
|
||||
sc_init_one(&browser_list[3], NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
nano_nextpage_msg,
|
||||
0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, 0);
|
||||
|
||||
sc_init_one(&browser_list[4], NANO_GOTO_KEY, _("Goto"),
|
||||
sc_init_one(&browser_list, NANO_GOTO_KEY, _("Goto"),
|
||||
nano_gotodir_msg, NANO_ALT_GOTO_KEY, NANO_GOTO_FKEY, 0,
|
||||
VIEW, 0);
|
||||
|
||||
sc_init_one(&gotodir_list[0], NANO_HELP_KEY,
|
||||
if (gotodir_list != NULL)
|
||||
free_shortcutage(&gotodir_list);
|
||||
|
||||
sc_init_one(&gotodir_list, NANO_HELP_KEY,
|
||||
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&gotodir_list[1], NANO_CANCEL_KEY, _("Cancel"),
|
||||
sc_init_one(&gotodir_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined (DISABLE_HELP)
|
||||
currshortcut = main_list;
|
||||
#endif
|
||||
|
||||
toggle_init();
|
||||
}
|
||||
|
||||
/* delete the structure */
|
||||
void free_shortcutage(shortcut **shortcutage)
|
||||
{
|
||||
shortcut *s,*ps;
|
||||
|
||||
s = *shortcutage;
|
||||
if (s == NULL) {
|
||||
return;
|
||||
} else {
|
||||
s = *shortcutage;
|
||||
do {
|
||||
ps = s;
|
||||
s = s->next;
|
||||
free(ps);
|
||||
} while (s->next != NULL);
|
||||
free(s);
|
||||
*shortcutage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* clear the toggles */
|
||||
void free_toggles(void)
|
||||
{
|
||||
toggle *u,*lu;
|
||||
|
||||
if (toggles == NULL) {
|
||||
return;
|
||||
} else {
|
||||
lu = NULL;
|
||||
for (u = toggles; u->next != NULL; u = u->next) {
|
||||
if (lu != NULL) free(lu);
|
||||
lu = u;
|
||||
}
|
||||
if (lu != NULL) free(lu);
|
||||
if (u != NULL) free(u);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* added by SPK for memory cleanup, gracefully return our malloc()s */
|
||||
void thanks_for_all_the_fish(void)
|
||||
{
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
filestruct * current_open_file;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (operating_dir != NULL)
|
||||
free(operating_dir);
|
||||
if (full_operating_dir != NULL)
|
||||
free(full_operating_dir);
|
||||
#endif
|
||||
if (last_search != NULL)
|
||||
free(last_search);
|
||||
if (last_replace != NULL)
|
||||
free(last_replace);
|
||||
if (hblank != NULL)
|
||||
free(hblank);
|
||||
#ifndef DISABLE_SPELLER
|
||||
if (alt_speller != NULL)
|
||||
free(alt_speller);
|
||||
#endif
|
||||
if (help_text != NULL)
|
||||
free(help_text);
|
||||
if (filename != NULL)
|
||||
free(filename);
|
||||
if (answer != NULL)
|
||||
free(answer);
|
||||
if (cutbuffer != NULL)
|
||||
free_filestruct(cutbuffer);
|
||||
|
||||
free_shortcutage(&main_list);
|
||||
free_shortcutage(&whereis_list);
|
||||
free_shortcutage(&replace_list);
|
||||
free_shortcutage(&replace_list_2);
|
||||
free_shortcutage(&help_list);
|
||||
free_shortcutage(&writefile_list);
|
||||
free_shortcutage(&insertfile_list);
|
||||
free_shortcutage(&spell_list);
|
||||
#ifndef DISABLE_BROWSER
|
||||
free_shortcutage(&browser_list);
|
||||
#endif
|
||||
free_shortcutage(&gotodir_list);
|
||||
free_shortcutage(&goto_list);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
free_toggles();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* Cleanup of Multibuffers . . .
|
||||
Do not cleanup the current one, that is fileage . . . do the
|
||||
rest of them though! (should be none if all went well) */
|
||||
current_open_file = open_files;
|
||||
if (open_files != NULL){
|
||||
while (open_files->prev != NULL)
|
||||
open_files = open_files->prev;
|
||||
while (open_files->next != NULL) {
|
||||
/* cleanup of a multi buf . . . */
|
||||
if (open_files != current_open_file)
|
||||
free_filestruct(open_files->file);
|
||||
open_files = open_files->next;
|
||||
free_filestruct(open_files->prev);
|
||||
}
|
||||
/* cleanup of last multi buf . . . */
|
||||
if (open_files != current_open_file)
|
||||
free_filestruct(open_files->file);
|
||||
free_filestruct(open_files);
|
||||
}
|
||||
#endif
|
||||
/* starting the cleanup of fileage now . . . */
|
||||
|
||||
if (fileage != NULL)
|
||||
free_filestruct(fileage);
|
||||
|
||||
/* that is all for now */
|
||||
|
||||
}
|
||||
|
||||
2
m4/.cvsignore
Normal file
2
m4/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile.in
|
||||
Makefile
|
||||
2
m4/Makefile.am
Normal file
2
m4/Makefile.am
Normal file
@@ -0,0 +1,2 @@
|
||||
EXTRA_DIST = codeset.m4 glibc21.m4 progtest.m4 gettext.m4 iconv.m4 \
|
||||
lcmessage.m4
|
||||
6
m4/aclocal_inc.m4
Normal file
6
m4/aclocal_inc.m4
Normal file
@@ -0,0 +1,6 @@
|
||||
dnl AM_ACLOCAL_INCLUDE(macrodir)
|
||||
AC_DEFUN([AM_ACLOCAL_INCLUDE],
|
||||
[
|
||||
test -n "$ACLOCAL_FLAGS" && ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
|
||||
for k in $1 ; do ACLOCAL="$ACLOCAL -I $k" ; done
|
||||
])
|
||||
@@ -1,92 +0,0 @@
|
||||
#serial 19
|
||||
|
||||
dnl By default, many hosts won't let programs access large files;
|
||||
dnl one must use special compiler options to get large-file access to work.
|
||||
dnl For more details about this brain damage please see:
|
||||
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
|
||||
|
||||
dnl Written by Paul Eggert <eggert@twinsun.com>.
|
||||
|
||||
dnl Internal subroutine of AC_SYS_LARGEFILE.
|
||||
dnl AC_SYS_LARGEFILE_TEST_INCLUDES
|
||||
AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES,
|
||||
[[#include <sys/types.h>
|
||||
/* Check that off_t can represent 2**63 - 1 correctly.
|
||||
We can't simply "#define LARGE_OFF_T 9223372036854775807",
|
||||
since some C++ compilers masquerading as C compilers
|
||||
incorrectly reject 9223372036854775807. */
|
||||
# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
]])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_LARGEFILE.
|
||||
dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
|
||||
AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
|
||||
[AC_CACHE_CHECK([for $1 value needed for large files], $3,
|
||||
[$3=no
|
||||
AC_TRY_COMPILE([$5],
|
||||
[$6],
|
||||
,
|
||||
[AC_TRY_COMPILE([#define $1 $2]
|
||||
[$5]
|
||||
,
|
||||
[$6],
|
||||
[$3=$2])])])
|
||||
if test "[$]$3" != no; then
|
||||
AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
|
||||
fi])
|
||||
|
||||
AC_DEFUN(NANO_AC_SYS_LARGEFILE,
|
||||
[AC_REQUIRE([AC_PROG_CC])
|
||||
AC_ARG_ENABLE(largefile,
|
||||
[ --disable-largefile omit support for large files])
|
||||
if test "$enable_largefile" != no; then
|
||||
|
||||
AC_CACHE_CHECK([for special C compiler options needed for large files],
|
||||
ac_cv_sys_largefile_CC,
|
||||
[ac_cv_sys_largefile_CC=no
|
||||
if test "$GCC" != yes; then
|
||||
# IRIX 6.2 and later do not support large files by default,
|
||||
# so use the C compiler's -n32 option if that helps.
|
||||
AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
|
||||
[ac_save_CC="$CC"
|
||||
CC="$CC -n32"
|
||||
AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
|
||||
ac_cv_sys_largefile_CC=' -n32')
|
||||
CC="$ac_save_CC"])
|
||||
fi])
|
||||
if test "$ac_cv_sys_largefile_CC" != no; then
|
||||
CC="$CC$ac_cv_sys_largefile_CC"
|
||||
fi
|
||||
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
|
||||
ac_cv_sys_file_offset_bits,
|
||||
[Number of bits in a file offset, on hosts where this is settable.],
|
||||
AC_SYS_LARGEFILE_TEST_INCLUDES)
|
||||
AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
|
||||
ac_cv_sys_large_files,
|
||||
[Define for large files, on AIX-style hosts.],
|
||||
AC_SYS_LARGEFILE_TEST_INCLUDES)
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN(AC_FUNC_FSEEKO,
|
||||
[AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
|
||||
ac_cv_sys_largefile_source,
|
||||
[Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
|
||||
[#include <stdio.h>], [return !fseeko;])
|
||||
# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
|
||||
# in glibc 2.1.3, but that breaks too many other things.
|
||||
# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
|
||||
|
||||
AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
|
||||
[ac_cv_func_fseeko=no
|
||||
AC_TRY_LINK([#include <stdio.h>],
|
||||
[return fseeko && fseeko (stdin, 0, 0);],
|
||||
[ac_cv_func_fseeko=yes])])
|
||||
if test $ac_cv_func_fseeko != no; then
|
||||
AC_DEFINE(HAVE_FSEEKO, 1,
|
||||
[Define if fseeko (and presumably ftello) exists and is declared.])
|
||||
fi])
|
||||
10
nano.1
10
nano.1
@@ -45,6 +45,12 @@ under nano.
|
||||
.B \-M (\-\-mac)
|
||||
Write file in Mac format.
|
||||
.TP
|
||||
.B \-N (\-\-noconvert)
|
||||
Disable automatic conversion of files from DOS/Mac format.
|
||||
.TP
|
||||
.B \-Q [str] (\-\-quotestr=[str])
|
||||
Set the quoting string for justifying. The default is "> ".
|
||||
.TP
|
||||
.B \-R (\-\-regexp)
|
||||
Enable regular expression matching for search strings, as well as
|
||||
\\n subexpression replacement for replace strings, if available.
|
||||
@@ -131,8 +137,8 @@ Please send any comments or bug reports to
|
||||
.br
|
||||
The nano mailing list is available from
|
||||
.br
|
||||
.B nano-devel@lists.sourceforge.net.
|
||||
To subscribe, email to nano-devel-request@lists.sourceforge.net with a
|
||||
.B nano-devel@gnu.org.
|
||||
To subscribe, email to nano-devel-request@gnu.org with a
|
||||
subject of "subscribe".
|
||||
.SH HOMEPAGE
|
||||
http://www.nano-editor.org
|
||||
|
||||
14
nano.1.html
14
nano.1.html
@@ -62,6 +62,14 @@ under nano.
|
||||
|
||||
<DD>
|
||||
Write file in Mac format.
|
||||
<DT><B>-N (--noconvert)</B>
|
||||
|
||||
<DD>
|
||||
Disable automatic conversion of files from DOS/Mac format.
|
||||
<DT><B>-Q [str] (--quotestr=[str])</B>
|
||||
|
||||
<DD>
|
||||
Set the quoting string for justifying. The default is "> ".
|
||||
<DT><B>-R (--regexp)</B>
|
||||
|
||||
<DD>
|
||||
@@ -179,9 +187,9 @@ Please send any comments or bug reports to
|
||||
The nano mailing list is available from
|
||||
<BR>
|
||||
|
||||
<B><A HREF="mailto:nano-devel@lists.sourceforge.net">nano-devel@lists.sourceforge.net</A>.</B>
|
||||
<B><A HREF="mailto:nano-devel@gnu.org">nano-devel@gnu.org</A>.</B>
|
||||
|
||||
To subscribe, email to <A HREF="mailto:nano-devel-request@lists.sourceforge.net">nano-devel-request@lists.sourceforge.net</A> with a
|
||||
To subscribe, email to <A HREF="mailto:nano-devel-request@gnu.org">nano-devel-request@gnu.org</A> with a
|
||||
subject of "subscribe".
|
||||
<A NAME="lbAH"> </A>
|
||||
<H2>HOMEPAGE</H2>
|
||||
@@ -213,6 +221,6 @@ used by others).
|
||||
This document was created by
|
||||
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
|
||||
using the manual pages.<BR>
|
||||
Time: 04:02:51 GMT, January 05, 2002
|
||||
Time: 12:14:20 GMT, March 04, 2002
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
394
nano.c
394
nano.c
@@ -64,8 +64,8 @@
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
/* Former globals, now static */
|
||||
int fill = 0; /* Fill - where to wrap lines, basically */
|
||||
int wrap_at = 0; /* Right justified fill value, allows resize */
|
||||
int fill = 0;/* Fill - where to wrap lines, basically */
|
||||
int wrap_at = 0;/* Right justified fill value, allows resize */
|
||||
#endif
|
||||
|
||||
struct termios oldterm; /* The user's original term settings */
|
||||
@@ -100,6 +100,8 @@ RETSIGTYPE finish(int sigage)
|
||||
/* Restore the old term settings */
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
|
||||
thanks_for_all_the_fish();
|
||||
|
||||
exit(sigage);
|
||||
}
|
||||
|
||||
@@ -158,27 +160,34 @@ void die(char *msg, ...)
|
||||
|
||||
void die_save_file(char *die_filename)
|
||||
{
|
||||
char *name;
|
||||
int i;
|
||||
char *name, *ret;
|
||||
int i = -1;
|
||||
|
||||
/* if we can't save we have REAL bad problems,
|
||||
* but we might as well TRY. */
|
||||
if (die_filename[0] == '\0') {
|
||||
name = "nano.save";
|
||||
i = write_file(name, 1, 0, 0);
|
||||
} else {
|
||||
|
||||
ret = get_next_filename(name);
|
||||
if (strcmp(ret, ""))
|
||||
i = write_file(ret, 1, 0, 0);
|
||||
name = ret;
|
||||
}
|
||||
else {
|
||||
char *buf = charalloc(strlen(die_filename) + 6);
|
||||
strcpy(buf, die_filename);
|
||||
strcat(buf, ".save");
|
||||
i = write_file(buf, 1, 0, 0);
|
||||
name = buf;
|
||||
ret = get_next_filename(buf);
|
||||
if (strcmp(ret, ""))
|
||||
i = write_file(ret, 1, 0, 0);
|
||||
name = ret;
|
||||
}
|
||||
|
||||
if (i != -1)
|
||||
fprintf(stderr, _("\nBuffer written to %s\n"), name);
|
||||
else
|
||||
fprintf(stderr, _("\nNo %s written (file exists?)\n"), name);
|
||||
fprintf(stderr, _("\nNo %s written (too many backup files?)\n"), name);
|
||||
|
||||
free(ret);
|
||||
}
|
||||
|
||||
/* Die with an error message that the screen was too small if, well, the
|
||||
@@ -425,10 +434,14 @@ void usage(void)
|
||||
printf
|
||||
(_
|
||||
(" -M --mac Write file in Mac format\n"));
|
||||
printf
|
||||
(_
|
||||
(" -N --noconvert Don't convert files from DOS/Mac format\n"));
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
printf(_
|
||||
(" -R --regexp Use regular expressions for search\n"));
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
printf
|
||||
(_
|
||||
(" -Q [str] --quotestr [str] Quoting string, default \"> \"\n"));
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
printf(_
|
||||
@@ -498,6 +511,9 @@ void usage(void)
|
||||
printf(_(" -K Use alternate keypad routines\n"));
|
||||
#ifndef NANO_SMALL
|
||||
printf(_(" -M Write file in Mac format\n"));
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
printf(_(" -Q [str] Quoting string, default \"> \"\n"));
|
||||
#endif
|
||||
printf(_(" -R Use regular expressions for search\n"));
|
||||
#ifndef NANO_SMALL
|
||||
@@ -1488,8 +1504,7 @@ int do_int_spell_fix(char *word)
|
||||
do_replace_highlight(TRUE, prevanswer);
|
||||
|
||||
/* allow replace word to be corrected */
|
||||
i = statusq(0, spell_list, SPELL_LIST_LEN, last_replace,
|
||||
_("Edit a replacement"));
|
||||
i = statusq(0, spell_list, last_replace, _("Edit a replacement"));
|
||||
|
||||
do_replace_highlight(FALSE, prevanswer);
|
||||
|
||||
@@ -1732,7 +1747,7 @@ int do_spell(void)
|
||||
char *temp;
|
||||
int spell_res;
|
||||
|
||||
if ((temp = tempnam(0, "nano.")) == NULL) {
|
||||
if ((temp = safe_tempnam(0, "nano.")) == NULL) {
|
||||
statusbar(_("Could not create a temporary filename: %s"),
|
||||
strerror(errno));
|
||||
return 0;
|
||||
@@ -1746,9 +1761,8 @@ int do_spell(void)
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* update the current open_files entry before spell-checking, in case
|
||||
any problems occur; the case of there being no open_files entries
|
||||
is handled elsewhere (before we reach this point); no duplicate
|
||||
checking is needed here */
|
||||
add_open_file(1, 0);
|
||||
is handled elsewhere (before we reach this point) */
|
||||
add_open_file(1);
|
||||
#endif
|
||||
|
||||
if (alt_speller)
|
||||
@@ -1834,6 +1848,8 @@ void do_mouse(void)
|
||||
{
|
||||
MEVENT mevent;
|
||||
int foo = 0, tab_found = 0;
|
||||
int currslen;
|
||||
shortcut *s = currshortcut;
|
||||
|
||||
if (getmouse(&mevent) == ERR)
|
||||
return;
|
||||
@@ -1903,7 +1919,12 @@ void do_mouse(void)
|
||||
edit_refresh();
|
||||
} else if (wenclose(bottomwin, mevent.y, mevent.x) && !ISSET(NO_HELP)) {
|
||||
|
||||
int k, val = 0;
|
||||
int i, k;
|
||||
|
||||
if (currshortcut == main_list)
|
||||
currslen = MAIN_VISIBLE;
|
||||
else
|
||||
currslen = length_of_list(currshortcut);
|
||||
|
||||
if (currslen < 2)
|
||||
k = COLS / 6;
|
||||
@@ -1920,14 +1941,15 @@ void do_mouse(void)
|
||||
if (mevent.x / k >= currslen)
|
||||
return;
|
||||
|
||||
val = currshortcut[(mevent.x / k) * 2 + mevent.y].val;
|
||||
for (i = 0; i < (mevent.x / k) * 2 + mevent.y; i++)
|
||||
s = s->next;
|
||||
|
||||
/* And ungetch that value */
|
||||
ungetch(val);
|
||||
ungetch(s->val);
|
||||
|
||||
/* And if it's an alt-key sequence, we should probably send alt
|
||||
too ;-) */
|
||||
if (val >= 'a' && val <= 'z')
|
||||
if (s->val >= 'a' && s->val <= 'z')
|
||||
ungetch(27);
|
||||
}
|
||||
}
|
||||
@@ -2179,8 +2201,8 @@ void justify_format(char *data)
|
||||
int i = 0;
|
||||
int len = strlen(data);
|
||||
|
||||
/* Skip first character regardless and leading whitespace. */
|
||||
for (i = 1; i < len; i++) {
|
||||
/* Skip leading whitespace. */
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!isspace((int) data[i]))
|
||||
break;
|
||||
}
|
||||
@@ -2190,12 +2212,21 @@ void justify_format(char *data)
|
||||
/* No double spaces allowed unless following a period. Tabs -> space. No double tabs. */
|
||||
for (; i < len; i++) {
|
||||
if (isspace((int) data[i]) && isspace((int) data[i - 1])
|
||||
&& (data[i - 2] != '.')) {
|
||||
&& (data[i - 2] != '.')
|
||||
&& (data[i-2]!='!') && (data[i-2]!='?')) {
|
||||
memmove(data + i, data + i + 1, len - i);
|
||||
len--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
/* Skip trailing whitespace.
|
||||
* i<=len iff there was a non-space in the line. In that case, we
|
||||
* strip spaces from the end of the line. Note that "line" means the
|
||||
* whole paragraph. */
|
||||
if (i<=len) {
|
||||
for(i=len-1; i>0 && isspace((int) data[i]); i--);
|
||||
data[i+1] = '\0';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2208,8 +2239,14 @@ int do_justify(void)
|
||||
int slen = 0; /* length of combined lines on one line. */
|
||||
int initial_y, kbinput = 0, totbak;
|
||||
filestruct *initial = NULL, *tmpjust = NULL, *cutbak, *tmptop, *tmpbot;
|
||||
filestruct *samecheck = current;
|
||||
int qdepth = 0;
|
||||
|
||||
if (empty_line(current->data)) {
|
||||
/* Compute quote depth level */
|
||||
while (!strncmp(¤t->data[qdepth], quotestr, strlen(quotestr)))
|
||||
qdepth += strlen(quotestr);
|
||||
|
||||
if (empty_line(¤t->data[qdepth])) {
|
||||
/* Justify starting at first non-empty line. */
|
||||
do {
|
||||
if (!current->next)
|
||||
@@ -2218,14 +2255,23 @@ int do_justify(void)
|
||||
current = current->next;
|
||||
current_y++;
|
||||
}
|
||||
while (empty_line(current->data));
|
||||
while (strlen(current->data) >= qdepth
|
||||
&& !strncmp(current->data, samecheck->data, qdepth)
|
||||
&& empty_line(¤t->data[qdepth]));
|
||||
|
||||
} else {
|
||||
/* Search back for the beginning of the paragraph, where
|
||||
* Paragraph is 1) A line with leading whitespace
|
||||
* or 2) A line following an empty line.
|
||||
*/
|
||||
while (current->prev != NULL) {
|
||||
if (isspace((int) current->data[0]) || !current->data[0])
|
||||
if (strncmp(current->data, samecheck->data, qdepth)
|
||||
|
||||
/* Don't keep going back if the previous line is more
|
||||
intented quotestr-wise than samecheck */
|
||||
|| !strncmp(¤t->data[qdepth], quotestr, strlen(quotestr))
|
||||
|| isspace((int) current->data[qdepth])
|
||||
|| empty_line(¤t->data[qdepth]))
|
||||
break;
|
||||
|
||||
current = current->prev;
|
||||
@@ -2233,7 +2279,9 @@ int do_justify(void)
|
||||
}
|
||||
|
||||
/* First line with leading whitespace may be empty. */
|
||||
if (empty_line(current->data)) {
|
||||
if (strncmp(current->data, samecheck->data, qdepth)
|
||||
|| !strncmp(¤t->data[qdepth], quotestr, strlen(quotestr))
|
||||
|| empty_line(¤t->data[qdepth])) {
|
||||
if (current->next) {
|
||||
current = current->next;
|
||||
current_y++;
|
||||
@@ -2251,16 +2299,21 @@ int do_justify(void)
|
||||
|
||||
tmptop = current;
|
||||
tmpjust = copy_node(current);
|
||||
samecheck = tmpjust;
|
||||
|
||||
/* 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]) {
|
||||
&& !strncmp(current->next->data, samecheck->data, qdepth)
|
||||
|
||||
/* Don't continue if current->next is indented more! */
|
||||
&& strncmp(¤t->next->data[qdepth], quotestr, strlen(quotestr))
|
||||
&& !empty_line(¤t->next->data[qdepth])) {
|
||||
filestruct *tmpnode = current->next;
|
||||
int len = strlen(current->data);
|
||||
int len2 = strlen(current->next->data);
|
||||
int len2 = strlen(current->next->data) - qdepth;
|
||||
|
||||
tmpjust = NULL;
|
||||
tmpjust = copy_node(current->next);
|
||||
@@ -2274,7 +2327,7 @@ int do_justify(void)
|
||||
current->data[len++] = ' ';
|
||||
current->data[len] = '\0';
|
||||
|
||||
strncat(current->data, current->next->data, len2);
|
||||
strncat(current->data, ¤t->next->data[qdepth], len2);
|
||||
|
||||
unlink_node(tmpnode);
|
||||
delete_node(tmpnode);
|
||||
@@ -2288,36 +2341,49 @@ int do_justify(void)
|
||||
if ((strlenpt(current->data) > (fill))
|
||||
&& !no_spaces(current->data)) {
|
||||
do {
|
||||
int i = 0;
|
||||
int i = 0, j = 0;
|
||||
int len2 = 0;
|
||||
filestruct *tmpline = nmalloc(sizeof(filestruct));
|
||||
|
||||
/* Start at fill , unless line isn't that long (but it
|
||||
* appears at least fill long with tabs.
|
||||
*/
|
||||
if (slen > fill)
|
||||
i = fill;
|
||||
else
|
||||
i = slen;
|
||||
|
||||
for (; i > 0; i--) {
|
||||
if (isspace((int) current->data[i]) &&
|
||||
((strlenpt(current->data) - strlen(current->data + i))
|
||||
<= fill))
|
||||
break;
|
||||
}
|
||||
/* The following code maybe could be better. In particular, can we
|
||||
* merely increment instead of calling strnlenpt for each new character?
|
||||
* In fact, can we assume the only tabs are at the beginning of the line?
|
||||
*/
|
||||
/* Note that we CAN break before the first word, since that is how
|
||||
* pico does it. */
|
||||
int last_space = -1; /* index of the last breakpoint */
|
||||
int allowed_width;
|
||||
|
||||
if (!i)
|
||||
break;
|
||||
i = qdepth * strlen(quotestr); /* the line starts with
|
||||
indentation, so we must skip it! */
|
||||
allowed_width = fill - i; /* how wide can our lines be? */
|
||||
|
||||
for(; i<slen; i++) {
|
||||
if (isspace((int) current->data[i])) last_space = i;
|
||||
if (last_space!=-1 &&
|
||||
strnlenpt(current->data,i) >= allowed_width) {
|
||||
i = last_space;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Now data[i] is a space. We want to break at the LAST space in this
|
||||
* group. Probably, the only possibility is two in a row, but let's be
|
||||
* generic. Note that we actually replace this final space with \0. Is
|
||||
* this okay? It seems to work fine. */
|
||||
for(; i<slen-1 && isspace((int) current->data[i+1]); i++) ;
|
||||
|
||||
current->data[i] = '\0';
|
||||
|
||||
len2 = strlen(current->data + i + 1);
|
||||
tmpline->data = charalloc(len2 + 1);
|
||||
tmpline->data = charalloc(len2 + 1 + qdepth);
|
||||
|
||||
for (j = 0; j < qdepth; j += strlen(quotestr))
|
||||
strcpy(&tmpline->data[j], quotestr);
|
||||
|
||||
/* Skip the white space in current. */
|
||||
memcpy(tmpline->data, current->data + i + 1, len2);
|
||||
tmpline->data[len2] = '\0';
|
||||
memcpy(&tmpline->data[j], current->data + i + 1, len2);
|
||||
tmpline->data[len2 + qdepth] = '\0';
|
||||
|
||||
current->data = nrealloc(current->data, i + 1);
|
||||
|
||||
@@ -2410,14 +2476,13 @@ int do_justify(void)
|
||||
#ifndef DISABLE_HELP
|
||||
void help_init(void)
|
||||
{
|
||||
int i, sofar = 0, helplen;
|
||||
int i, sofar = 0, meta_shortcut = 0, helplen;
|
||||
long allocsize = 1; /* How much space we're gonna need for the help text */
|
||||
char buf[BUFSIZ] = "", *ptr = NULL;
|
||||
toggle *t;
|
||||
shortcut *s;
|
||||
|
||||
if (currslen == MAIN_VISIBLE)
|
||||
helplen = MAIN_LIST_LEN;
|
||||
else
|
||||
helplen = currslen;
|
||||
helplen = length_of_list(currshortcut);
|
||||
|
||||
/* First set up the initial help text for the current function */
|
||||
if (currshortcut == whereis_list || currshortcut == replace_list
|
||||
@@ -2451,7 +2516,10 @@ void help_init(void)
|
||||
"or --multibuffer command line flags, the Meta-F toggle or "
|
||||
"using a nanorc file, inserting a file will cause it to be "
|
||||
"loaded into a separate buffer (use Meta-< and > to switch "
|
||||
"between file buffers).\n\n The following function keys are "
|
||||
"between file buffers).\n\n If you need another blank "
|
||||
"buffer, just press Enter at the prompt without typing in a "
|
||||
"filename, or type in a nonexistent filename at the prompt "
|
||||
"and press Enter.\n\n The following function keys are "
|
||||
"available in Insert File mode:\n\n");
|
||||
else if (currshortcut == writefile_list)
|
||||
ptr = _("Write File Help Text\n\n "
|
||||
@@ -2498,21 +2566,22 @@ void help_init(void)
|
||||
|
||||
/* Compute the space needed for the shortcut lists - we add 15 to
|
||||
have room for the shortcut abbrev and its possible alternate keys */
|
||||
for (i = 0; i <= helplen - 1; i++)
|
||||
if (currshortcut[i].help != NULL)
|
||||
allocsize += strlen(currshortcut[i].help) + 15;
|
||||
s = currshortcut;
|
||||
for (i = 0; i <= helplen - 1; i++) {
|
||||
if (s->help != NULL)
|
||||
allocsize += strlen(s->help) + 15;
|
||||
s = s->next;
|
||||
}
|
||||
|
||||
/* If we're on the main list, we also allocate space for toggle help text. */
|
||||
if (currshortcut == main_list) {
|
||||
for (i = 0; i <= TOGGLE_LEN - 1; i++)
|
||||
if (toggles[i].desc != NULL)
|
||||
allocsize += strlen(toggles[i].desc) + 30;
|
||||
|
||||
for (t = toggles; t != NULL; t = t->next)
|
||||
if (t->desc != NULL)
|
||||
allocsize += strlen(t->desc) + 30;
|
||||
}
|
||||
|
||||
allocsize += strlen(ptr);
|
||||
|
||||
|
||||
if (help_text != NULL)
|
||||
free(help_text);
|
||||
|
||||
@@ -2523,59 +2592,71 @@ void help_init(void)
|
||||
strcpy(help_text, ptr);
|
||||
|
||||
/* Now add our shortcut info */
|
||||
s = currshortcut;
|
||||
for (i = 0; i <= helplen - 1; i++) {
|
||||
if (currshortcut[i].val > 0 && currshortcut[i].val < 'a')
|
||||
sofar = snprintf(buf, BUFSIZ, "^%c ", currshortcut[i].val + 64);
|
||||
else
|
||||
sofar = snprintf(buf, BUFSIZ, " ");
|
||||
if (s->val > 0 && s->val < 'a')
|
||||
sofar = snprintf(buf, BUFSIZ, "^%c ", s->val + 64);
|
||||
else {
|
||||
if (s->altval > 0) {
|
||||
sofar = 0;
|
||||
meta_shortcut = 1;
|
||||
}
|
||||
else
|
||||
sofar = snprintf(buf, BUFSIZ, " ");
|
||||
}
|
||||
|
||||
if (currshortcut[i].misc1 > KEY_F0 && currshortcut[i].misc1 <= KEY_F(64))
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(F%d) ",
|
||||
currshortcut[i].misc1 - KEY_F0);
|
||||
else
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
|
||||
if (!meta_shortcut) {
|
||||
if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64))
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(F%d) ",
|
||||
s->misc1 - KEY_F0);
|
||||
else
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
|
||||
}
|
||||
|
||||
if (currshortcut[i].altval > 0 && currshortcut[i].altval < 91)
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
|
||||
currshortcut[i].altval - 32);
|
||||
else if (currshortcut[i].altval > 0)
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
|
||||
currshortcut[i].altval);
|
||||
if (s->altval > 0 && s->altval < 91
|
||||
&& (s->altval - 32) > 32)
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
|
||||
(meta_shortcut ? "M-%c " : "(M-%c) "),
|
||||
s->altval - 32);
|
||||
else if (s->altval > 0)
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
|
||||
(meta_shortcut ? "M-%c " : "(M-%c) "),
|
||||
s->altval);
|
||||
/* Hack */
|
||||
else if (currshortcut[i].val >= 'a')
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
|
||||
currshortcut[i].val - 32);
|
||||
else if (s->val >= 'a')
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
|
||||
(meta_shortcut ? "(M-%c) " : "M-%c "),
|
||||
s->val - 32);
|
||||
else
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
|
||||
|
||||
if (meta_shortcut) {
|
||||
if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64))
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
|
||||
"(F%d) ", s->misc1 - KEY_F0);
|
||||
else
|
||||
sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
|
||||
" ");
|
||||
}
|
||||
|
||||
if (currshortcut[i].help != NULL)
|
||||
snprintf(&buf[sofar], BUFSIZ - sofar, "%s", currshortcut[i].help);
|
||||
|
||||
if (s->help != NULL)
|
||||
snprintf(&buf[sofar], BUFSIZ - sofar, "%s", s->help);
|
||||
|
||||
strcat(help_text, buf);
|
||||
strcat(help_text, "\n");
|
||||
|
||||
s = s->next;
|
||||
}
|
||||
|
||||
/* And the toggles... */
|
||||
if (currshortcut == main_list)
|
||||
for (i = 0; i <= TOGGLE_LEN - 1; i++) {
|
||||
if (toggles[i].override_ch != 0)
|
||||
for (t = toggles; t != NULL; t = t->next) {
|
||||
sofar = snprintf(buf, BUFSIZ,
|
||||
"M-%c ", toggles[i].override_ch);
|
||||
else
|
||||
sofar = snprintf(buf, BUFSIZ,
|
||||
"M-%c ", toggles[i].val - 32);
|
||||
|
||||
if (toggles[i].desc != NULL) {
|
||||
if (toggles[i].flag != 0)
|
||||
"M-%c ", t->val - 32);
|
||||
if (t->desc != NULL) {
|
||||
snprintf(&buf[sofar], BUFSIZ - sofar, _("%s enable/disable"),
|
||||
toggles[i].desc);
|
||||
else
|
||||
snprintf(&buf[sofar], BUFSIZ - sofar, "%s",
|
||||
toggles[i].desc);
|
||||
t->desc);
|
||||
}
|
||||
|
||||
strcat(help_text, buf);
|
||||
strcat(help_text, "\n");
|
||||
}
|
||||
@@ -2583,7 +2664,7 @@ void help_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
void do_toggle(int which)
|
||||
void do_toggle(toggle *which)
|
||||
{
|
||||
#ifdef NANO_SMALL
|
||||
nano_disabled_msg();
|
||||
@@ -2591,7 +2672,7 @@ void do_toggle(int which)
|
||||
char *enabled = _("enabled");
|
||||
char *disabled = _("disabled");
|
||||
|
||||
switch (toggles[which].val) {
|
||||
switch (which->val) {
|
||||
case TOGGLE_BACKWARDS_KEY:
|
||||
case TOGGLE_CASE_KEY:
|
||||
case TOGGLE_REGEXP_KEY:
|
||||
@@ -2599,9 +2680,9 @@ void do_toggle(int which)
|
||||
}
|
||||
|
||||
/* Even easier! */
|
||||
TOGGLE(toggles[which].flag);
|
||||
TOGGLE(which->flag);
|
||||
|
||||
switch (toggles[which].val) {
|
||||
switch (which->val) {
|
||||
case TOGGLE_PICOMODE_KEY:
|
||||
shortcut_init(0);
|
||||
SET(CLEAR_BACKUPSTRING);
|
||||
@@ -2629,18 +2710,18 @@ void do_toggle(int which)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ISSET(toggles[which].flag)) {
|
||||
if (toggles[which].val == TOGGLE_NOHELP_KEY ||
|
||||
toggles[which].val == TOGGLE_WRAP_KEY)
|
||||
statusbar("%s %s", toggles[which].desc, enabled);
|
||||
if (!ISSET(which->flag)) {
|
||||
if (which->val == TOGGLE_NOHELP_KEY ||
|
||||
which->val == TOGGLE_WRAP_KEY)
|
||||
statusbar("%s %s", which->desc, enabled);
|
||||
else
|
||||
statusbar("%s %s", toggles[which].desc, disabled);
|
||||
statusbar("%s %s", which->desc, disabled);
|
||||
} else {
|
||||
if (toggles[which].val == TOGGLE_NOHELP_KEY ||
|
||||
toggles[which].val == TOGGLE_WRAP_KEY)
|
||||
statusbar("%s %s", toggles[which].desc, disabled);
|
||||
if (which->val == TOGGLE_NOHELP_KEY ||
|
||||
which->val == TOGGLE_WRAP_KEY)
|
||||
statusbar("%s %s", which->desc, disabled);
|
||||
else
|
||||
statusbar("%s %s", toggles[which].desc, enabled);
|
||||
statusbar("%s %s", which->desc, enabled);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -2687,8 +2768,10 @@ int main(int argc, char *argv[])
|
||||
int kbinput; /* Input from keyboard */
|
||||
long startline = 0; /* Line to try and start at */
|
||||
int keyhandled; /* Have we handled the keystroke yet? */
|
||||
int i, modify_control_seq;
|
||||
int modify_control_seq;
|
||||
char *argv0;
|
||||
shortcut *s;
|
||||
toggle *t;
|
||||
|
||||
#ifdef _POSIX_VDISABLE
|
||||
struct termios term;
|
||||
@@ -2711,6 +2794,7 @@ int main(int argc, char *argv[])
|
||||
{"cut", 0, 0, 'k'},
|
||||
{"dos", 0, 0, 'D'},
|
||||
{"mac", 0, 0, 'M'},
|
||||
{"noconvert", 0, 0, 'N'},
|
||||
{"autoindent", 0, 0, 'i'},
|
||||
#endif
|
||||
{"tempfile", 0, 0, 't'},
|
||||
@@ -2736,7 +2820,6 @@ int main(int argc, char *argv[])
|
||||
{"smooth", 0, 0, 'S'},
|
||||
#endif
|
||||
{"keypad", 0, 0, 'K'},
|
||||
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
#endif
|
||||
@@ -2757,11 +2840,11 @@ int main(int argc, char *argv[])
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
while ((optchr = getopt_long(argc, argv, "h?DFKMRST:Vabcefgijklmo:pr:s:tvwxz",
|
||||
while ((optchr = getopt_long(argc, argv, "h?DFKMNQ:RST:Vabcefgijklmo:pr:s:tvwxz",
|
||||
long_options, &option_index)) != EOF) {
|
||||
#else
|
||||
while ((optchr =
|
||||
getopt(argc, argv, "h?DFKMRST:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
|
||||
getopt(argc, argv, "h?DFKMNQ:RST:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
|
||||
#endif
|
||||
|
||||
switch (optchr) {
|
||||
@@ -2783,14 +2866,18 @@ int main(int argc, char *argv[])
|
||||
case 'M':
|
||||
SET(MAC_FILE);
|
||||
break;
|
||||
#endif
|
||||
case 'T':
|
||||
tabsize = atoi(optarg);
|
||||
if (tabsize <= 0) {
|
||||
usage(); /* To stop bogus data for tab width */
|
||||
finish(1);
|
||||
}
|
||||
case 'N':
|
||||
SET(NO_CONVERT);
|
||||
break;
|
||||
#endif
|
||||
case 'Q':
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
quotestr = optarg;
|
||||
break;
|
||||
#else
|
||||
usage(); /* To stop bogus data for tab width */
|
||||
finish(1);
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
case 'R':
|
||||
SET(USE_REGEXP);
|
||||
@@ -2801,6 +2888,13 @@ int main(int argc, char *argv[])
|
||||
SET(SMOOTHSCROLL);
|
||||
break;
|
||||
#endif
|
||||
case 'T':
|
||||
tabsize = atoi(optarg);
|
||||
if (tabsize <= 0) {
|
||||
usage(); /* To stop bogus data for tab width */
|
||||
finish(1);
|
||||
}
|
||||
break;
|
||||
case 'V':
|
||||
version();
|
||||
exit(0);
|
||||
@@ -3005,7 +3099,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
currshortcut = main_list;
|
||||
currslen = MAIN_VISIBLE;
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_VDISABLE
|
||||
@@ -3171,6 +3264,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
case NANO_OPENPREV_KEY:
|
||||
case NANO_OPENPREV_ALTKEY:
|
||||
@@ -3183,21 +3277,29 @@ int main(int argc, char *argv[])
|
||||
keyhandled = 1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if !defined (NANO_SMALL) && defined (HAVE_REGEX_H)
|
||||
case NANO_BRACKET_KEY:
|
||||
do_find_bracket();
|
||||
keyhandled = 1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
/* Check for the altkey defs.... */
|
||||
for (i = 0; i <= MAIN_LIST_LEN - 1; i++)
|
||||
if (kbinput == main_list[i].altval ||
|
||||
kbinput == main_list[i].altval - 32) {
|
||||
kbinput = main_list[i].val;
|
||||
for (s = main_list; s != NULL; s = s->next)
|
||||
if (kbinput == s->altval ||
|
||||
kbinput == s->altval - 32) {
|
||||
kbinput = s->val;
|
||||
break;
|
||||
}
|
||||
#ifndef NANO_SMALL
|
||||
/* And for toggle switches */
|
||||
for (i = 0; i <= TOGGLE_LEN - 1 && !keyhandled; i++)
|
||||
if (kbinput == toggles[i].val ||
|
||||
(toggles[i].val > 'a' &&
|
||||
kbinput == toggles[i].val - 32)) {
|
||||
do_toggle(i);
|
||||
for (t = toggles; t != NULL && !keyhandled; t = t->next)
|
||||
if (kbinput == t->val ||
|
||||
(t->val > 'a' &&
|
||||
kbinput == t->val - 32)) {
|
||||
do_toggle(t);
|
||||
keyhandled = 1;
|
||||
break;
|
||||
}
|
||||
@@ -3223,14 +3325,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Look through the main shortcut list to see if we've hit a
|
||||
shortcut key */
|
||||
for (i = 0; i < MAIN_LIST_LEN && !keyhandled; i++) {
|
||||
if (kbinput == main_list[i].val ||
|
||||
(main_list[i].misc1 && kbinput == main_list[i].misc1) ||
|
||||
(main_list[i].misc2 && kbinput == main_list[i].misc2)) {
|
||||
if (ISSET(VIEW_MODE) && !main_list[i].viewok)
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE) || !defined (DISABLE_HELP)
|
||||
for (s = currshortcut; s != NULL && !keyhandled; s = s->next) {
|
||||
#else
|
||||
for (s = main_list; s != NULL && !keyhandled; s = s->next) {
|
||||
#endif
|
||||
if (kbinput == s->val ||
|
||||
(s->misc1 && kbinput == s->misc1) ||
|
||||
(s->misc2 && kbinput == s->misc2)) {
|
||||
if (ISSET(VIEW_MODE) && !s->viewok)
|
||||
print_view_warning();
|
||||
else
|
||||
main_list[i].func();
|
||||
s->func();
|
||||
keyhandled = 1;
|
||||
}
|
||||
}
|
||||
@@ -3239,8 +3346,9 @@ int main(int argc, char *argv[])
|
||||
if (kbinput == 17 || kbinput == 19)
|
||||
keyhandled = 1;
|
||||
|
||||
/* Catch ^Z by hand when triggered also */
|
||||
if (kbinput == 26) {
|
||||
/* Catch ^Z by hand when triggered also
|
||||
407 == ^Z in Linux console when keypad() is used? */
|
||||
if (kbinput == 26 || kbinput == 407) {
|
||||
if (ISSET(SUSPEND))
|
||||
do_suspend(0);
|
||||
keyhandled = 1;
|
||||
|
||||
58
nano.h
58
nano.h
@@ -79,7 +79,6 @@ typedef struct filestruct {
|
||||
int file_current_x; /* Current file's x-coordinate position */
|
||||
int file_current_y; /* Current file's y-coordinate position */
|
||||
int file_modified; /* Current file's modification status */
|
||||
char *file_path; /* Current file's full path location */
|
||||
int file_placewewant; /* Current file's place we want */
|
||||
int file_totlines; /* Current file's total number of lines */
|
||||
long file_totsize; /* Current file's total size */
|
||||
@@ -97,6 +96,7 @@ typedef struct shortcut {
|
||||
int (*func) (void); /* Function to call when we catch this key */
|
||||
char *desc; /* Description, e.g. "Page Up" */
|
||||
char *help; /* Help file entry text */
|
||||
struct shortcut *next;
|
||||
} shortcut;
|
||||
|
||||
typedef struct toggle {
|
||||
@@ -105,8 +105,7 @@ typedef struct toggle {
|
||||
e.g. "Pico Messages"; we'll append Enabled or
|
||||
Disabled */
|
||||
int flag; /* What flag actually gets toggled */
|
||||
char override_ch; /* The character to display on the help screen,
|
||||
if it isn't NULL */
|
||||
struct toggle *next;
|
||||
} toggle;
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
@@ -161,7 +160,8 @@ typedef struct colortype {
|
||||
#define MAC_FILE (1<<22)
|
||||
#define SMOOTHSCROLL (1<<23)
|
||||
#define DISABLE_CURPOS (1<<24) /* Damn, we still need it */
|
||||
#define ALT_KEYPAD (1<<25) /* Damn, we still need it */
|
||||
#define ALT_KEYPAD (1<<25)
|
||||
#define NO_CONVERT (1<<26)
|
||||
|
||||
/* Control key sequences, changing these would be very very bad */
|
||||
|
||||
@@ -305,57 +305,9 @@ know what you're doing */
|
||||
#define TOGGLE_DOS_KEY NANO_ALT_D
|
||||
#define TOGGLE_MAC_KEY NANO_ALT_O
|
||||
#define TOGGLE_SMOOTH_KEY NANO_ALT_S
|
||||
#define TOGGLE_NOCONVERT_KEY NANO_ALT_N
|
||||
|
||||
/* Toggle stuff, these static lengths need to go away RSN */
|
||||
|
||||
#ifndef HAVE_REGEX_H
|
||||
#define NO_REGEX 1
|
||||
#define SMALL_TOO 0
|
||||
#else
|
||||
#define NO_REGEX 0
|
||||
#ifdef NANO_SMALL
|
||||
#define SMALL_TOO 1
|
||||
#else
|
||||
#define SMALL_TOO 0
|
||||
#endif /* NANO_SMALL */
|
||||
#endif /* HAVE_REGEX_H */
|
||||
|
||||
#ifdef DISABLE_BROWSER
|
||||
#define NO_BROWSER 1
|
||||
#else
|
||||
#define NO_BROWSER 0
|
||||
#endif
|
||||
|
||||
#ifdef NANO_SMALL
|
||||
#ifdef HAVE_REGEX_H
|
||||
#define NO_TOGGLES 3
|
||||
#else
|
||||
#define NO_TOGGLES 2
|
||||
#endif /* HAVE_REGEX_H */
|
||||
#else
|
||||
#define NO_TOGGLES 0
|
||||
#endif /* NANO_SMALL */
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
#define MULTI_TOGGLES 3
|
||||
#else
|
||||
#define MULTI_TOGGLES 0
|
||||
#endif
|
||||
|
||||
#define WHEREIS_LIST_LEN (9 - NO_REGEX - NO_TOGGLES)
|
||||
#define REPLACE_LIST_LEN (9 - NO_REGEX - NO_TOGGLES)
|
||||
#define TOGGLE_LEN (14 - NO_REGEX + MULTI_TOGGLES)
|
||||
#define WRITEFILE_LIST_LEN (4 - NO_BROWSER)
|
||||
#define INSERTFILE_LIST_LEN (3 - NO_BROWSER)
|
||||
#define BROWSER_LIST_LEN 5
|
||||
#define MAIN_LIST_LEN (27 - NO_REGEX - SMALL_TOO)
|
||||
#define MAIN_VISIBLE 12
|
||||
#define REPLACE_LIST_2_LEN 4
|
||||
#define GOTO_LIST_LEN 4
|
||||
#define GOTODIR_LIST_LEN 2
|
||||
#define HELP_LIST_LEN 3
|
||||
#define SPELL_LIST_LEN 2
|
||||
|
||||
|
||||
#define VIEW 1
|
||||
#define NOVIEW 0
|
||||
|
||||
10
nano.texi
10
nano.texi
@@ -8,7 +8,7 @@
|
||||
@c Run `makeinfo' rather than `texinfo-format-buffer'.
|
||||
@smallbook
|
||||
@set EDITION 0.1
|
||||
@set VERSION 1.1.6
|
||||
@set VERSION 1.1.7
|
||||
@set UPDATED 4 Jan 2002
|
||||
|
||||
@dircategory Editors
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 1.1.6
|
||||
@subtitle version 1.1.7
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -122,6 +122,12 @@ under nano.
|
||||
@item -M, --mac
|
||||
Write file in Mac format.
|
||||
|
||||
@item -N, --noconvert
|
||||
Do not convert files from DOS/Mac format.
|
||||
|
||||
@item -Q [str], --quotestr [str]
|
||||
Set the quoting string for justifying. The default is "> ".
|
||||
|
||||
@item -R, --regexp
|
||||
Turns on regular expression search and search/replace.
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# Sample initialization file for GNU nano
|
||||
# Please note that you must have configured nano with
|
||||
# --enable-nanorc for this file to be read!
|
||||
#
|
||||
# To make sure a value is not enabled, use "unset <option>"
|
||||
|
||||
# Use regular expressions by default
|
||||
# set regexp
|
||||
@@ -8,6 +10,9 @@
|
||||
# Constantly update the cursor position
|
||||
# set const
|
||||
|
||||
# Show column position relative to the current line, not the whole file
|
||||
# set relative
|
||||
|
||||
# Use cut to end of line with ^K by default
|
||||
# set cut
|
||||
|
||||
@@ -50,12 +55,22 @@
|
||||
# Use smooth scrolling as the default
|
||||
# set smooth
|
||||
|
||||
# Use alternate keypad routines
|
||||
# set keypad
|
||||
|
||||
# Don't convert files from DOS/Mac format
|
||||
# set noconvert
|
||||
|
||||
# Allow multiple file buffers (using ^R inserts into separate buffer)
|
||||
# You must have configured with --enable-multibuffer or --enable-extra for
|
||||
# this to work
|
||||
#
|
||||
# set multibuffer
|
||||
|
||||
# Use this as the quoting string. You shouldn't need to change this,
|
||||
# but...... default "> "
|
||||
# set quotestr "// "
|
||||
|
||||
#
|
||||
# Color setup
|
||||
# Format: color foreground,background "regex" ["regex"...]
|
||||
|
||||
57
po/ChangeLog
57
po/ChangeLog
@@ -1,3 +1,60 @@
|
||||
2002-03-05 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* pl.po: Updated translation by Wojciech Kotwica.
|
||||
|
||||
2002-02-20 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* nl.po: Updated translation by Guus Sliepen.
|
||||
|
||||
2002-02-15 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* nb.po: Updated translation by Stig E Sandoe.
|
||||
|
||||
2002-02-15 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* nb.po: Updated translation by Stig E Sandoe.
|
||||
|
||||
2002-02-14 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* da.po: Updated translation by Keld Simonsen.
|
||||
|
||||
2002-02-10 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* hu.po: Updated translation by Gergely Nagy.
|
||||
|
||||
2002-02-07 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* uk.po, ru.po: Updated translations by Sergei A.
|
||||
Ribalchenko.
|
||||
|
||||
2002-02-06 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* hu.po: Updated translation by Gergely Nagy.
|
||||
|
||||
2002-02-06 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* cs.po: Incomplete update by Václav Haisman.
|
||||
|
||||
2002-01-27 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* it.po: Updated translation by Marco Colombo.
|
||||
|
||||
2002-01-26 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* nn.po: Updated translation by Kjetil Torgrim Homme.
|
||||
* de.po: Updated translation by Michael Piefel.
|
||||
|
||||
2002-01-25 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* sv.po: Updated translation by Christian Rose.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-01-25 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* ca.po: Updated.
|
||||
* es.po: Updated.
|
||||
|
||||
2002-01-23 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* ca.po: Updated.
|
||||
|
||||
53
proto.h
53
proto.h
@@ -39,6 +39,10 @@ extern int fill, wrap_at, flags,tabsize;
|
||||
extern int search_last_line;
|
||||
extern int currslen;
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
char *quotestr;
|
||||
#endif
|
||||
|
||||
extern WINDOW *edit, *topwin, *bottomwin;
|
||||
extern char *filename;
|
||||
extern char *answer;
|
||||
@@ -47,6 +51,7 @@ extern char *last_search;
|
||||
extern char *last_replace;
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
extern char *operating_dir;
|
||||
extern char *full_operating_dir;
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
extern char *alt_speller;
|
||||
@@ -64,13 +69,13 @@ colortype *colorstrings;
|
||||
#endif
|
||||
|
||||
extern shortcut *shortcut_list;
|
||||
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], insertfile_list[INSERTFILE_LIST_LEN];
|
||||
extern shortcut spell_list[SPELL_LIST_LEN], replace_list_2[REPLACE_LIST_LEN];
|
||||
extern shortcut help_list[HELP_LIST_LEN];
|
||||
extern shortcut *main_list, *whereis_list;
|
||||
extern shortcut *replace_list, *goto_list;
|
||||
extern shortcut *writefile_list, *insertfile_list;
|
||||
extern shortcut *spell_list, *replace_list_2;
|
||||
extern shortcut *help_list;
|
||||
#ifndef DISABLE_BROWSER
|
||||
extern shortcut browser_list[BROWSER_LIST_LEN], gotodir_list[GOTODIR_LIST_LEN];
|
||||
extern shortcut *browser_list, *gotodir_list;
|
||||
#endif
|
||||
extern shortcut *currshortcut;
|
||||
|
||||
@@ -80,13 +85,13 @@ extern regex_t search_regexp;
|
||||
extern regmatch_t regmatches[10];
|
||||
#endif
|
||||
|
||||
extern toggle toggles[TOGGLE_LEN];
|
||||
extern toggle *toggles;
|
||||
|
||||
/* Programs we want available */
|
||||
|
||||
char *revstrstr(char *haystack, char *needle, char *rev_start);
|
||||
char *strcasestr(char *haystack, char *needle);
|
||||
char *revstrcasestr(char *haystack, char *needle, char *rev_start);
|
||||
char *stristr(char *haystack, char *needle);
|
||||
char *revstristr(char *haystack, char *needle, char *rev_start);
|
||||
char *strstrwrapper(char *haystack, char *needle, char *rev_start);
|
||||
int search_init(int replacing);
|
||||
int renumber(filestruct * fileptr);
|
||||
@@ -94,8 +99,9 @@ int free_filestruct(filestruct * src);
|
||||
int xplustabs(void);
|
||||
int do_yesno(int all, int leavecursor, char *msg, ...);
|
||||
int actual_x(filestruct * fileptr, int xplus);
|
||||
int strnlenpt(char *buf, int size);
|
||||
int strlenpt(char *buf);
|
||||
int statusq(int allowtabs, shortcut s[], int slen, char *def, char *msg, ...);
|
||||
int statusq(int allowtabs, shortcut s[], char *def, char *msg, ...);
|
||||
int write_file(char *name, int tmpfile, int append, int nonamechange);
|
||||
int do_cut_text(void);
|
||||
int do_uncut_text(void);
|
||||
@@ -103,9 +109,11 @@ int no_help(void);
|
||||
int renumber_all(void);
|
||||
int open_file(char *filename, int insert, int quiet);
|
||||
int do_insertfile(int loading_file);
|
||||
int length_of_list(shortcut *s);
|
||||
int num_of_digits(int n);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
int add_open_file(int update, int dup_fix);
|
||||
int add_open_file(int update);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
@@ -155,7 +163,7 @@ void blank_statusbar(void);
|
||||
void titlebar(char *path);
|
||||
void previous_line(void);
|
||||
void center_cursor(void);
|
||||
void bottombars(shortcut s[], int slen);
|
||||
void bottombars(shortcut *s);
|
||||
void blank_statusbar_refresh(void);
|
||||
void *nmalloc (size_t howmuch);
|
||||
void *mallocstrcpy(char *dest, char *src);
|
||||
@@ -185,6 +193,8 @@ void print_view_warning(void);
|
||||
void unlink_node(filestruct * fileptr);
|
||||
void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
|
||||
int bot_x, int destructive);
|
||||
void free_shortcutage(shortcut **src);
|
||||
void thanks_for_all_the_fish(void);
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
void do_rcfile(void);
|
||||
@@ -194,7 +204,6 @@ void do_rcfile(void);
|
||||
void do_credits(void);
|
||||
#endif
|
||||
|
||||
|
||||
int do_writeout_void(void), do_exit(void), do_gotoline_void(void);
|
||||
int do_insertfile_void(void), do_search(void);
|
||||
|
||||
@@ -212,14 +221,20 @@ int do_replace(void), do_help(void), do_enter_void(void);
|
||||
int keypad_on(WINDOW * win, int newval);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
int open_file_dup_fix(int update);
|
||||
int open_prevfile(int closing_file), open_nextfile(int closing_file);
|
||||
int open_prevfile_void(void), open_nextfile_void(void);
|
||||
#endif
|
||||
|
||||
char *charalloc (size_t howmuch);
|
||||
char *get_next_filename(char *name);
|
||||
|
||||
#if defined (ENABLE_MULTIBUFFER) || !defined (ENABLE_OPERATINGDIR)
|
||||
char *get_full_path(char *origpath);
|
||||
#if !defined (DISABLE_SPELLER) || !defined (DISABLE_OPERATINGDIR)
|
||||
char *get_full_path(const char *origpath);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_SPELLER
|
||||
char *check_writable_directory(const char *path);
|
||||
char *safe_tempnam(const char *dirname, const char *filename_prefix);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
@@ -244,12 +259,6 @@ filestruct *make_new_node(filestruct * prevnode);
|
||||
filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin,
|
||||
int beginx, char *needle);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
filestruct *open_file_dup_search(int update);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
void help_init(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
52
rcfile.c
52
rcfile.c
@@ -40,14 +40,8 @@
|
||||
#define _(string) (string)
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
#define NUM_RCOPTS 19
|
||||
#else
|
||||
#define NUM_RCOPTS 18
|
||||
#endif
|
||||
|
||||
/* Static stuff for the nanorc file */
|
||||
rcoption rcopts[NUM_RCOPTS] = {
|
||||
rcoption rcopts[] = {
|
||||
{"regexp", USE_REGEXP},
|
||||
{"const", CONSTUPDATE},
|
||||
{"autoindent", AUTOINDENT},
|
||||
@@ -57,11 +51,7 @@ rcoption rcopts[NUM_RCOPTS] = {
|
||||
{"operatingdir", 0},
|
||||
{"pico", PICO_MODE},
|
||||
{"tabsize", 0},
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
{"fill", 0},
|
||||
#endif
|
||||
|
||||
{"speller", 0},
|
||||
{"tempfile", TEMP_OPT},
|
||||
{"view", VIEW_MODE},
|
||||
@@ -70,7 +60,10 @@ rcoption rcopts[NUM_RCOPTS] = {
|
||||
{"suspend", SUSPEND},
|
||||
{"multibuffer", MULTIBUFFER},
|
||||
{"smooth", SMOOTHSCROLL},
|
||||
{"keypad", ALT_KEYPAD}
|
||||
{"keypad", ALT_KEYPAD},
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"quotestr", 0},
|
||||
{"", 0}
|
||||
};
|
||||
|
||||
static int errors = 0;
|
||||
@@ -130,11 +123,9 @@ char *parse_next_word(char *ptr)
|
||||
|
||||
char *parse_next_regex(char *ptr)
|
||||
{
|
||||
char prev = ' ';
|
||||
while ((*ptr != '"' || prev == '\\') && *ptr != '\n' && *ptr != '\0') {
|
||||
prev = *ptr;
|
||||
while ((*ptr != '"' || (*(ptr+1) != ' ' && *(ptr+1) != '\n'))
|
||||
&& *ptr != '\n' && *ptr != '\0')
|
||||
ptr++;
|
||||
}
|
||||
|
||||
if (*ptr == '\0')
|
||||
return NULL;
|
||||
@@ -156,7 +147,7 @@ int colortoint(char *colorname, int *bright)
|
||||
if (colorname == NULL)
|
||||
return -1;
|
||||
|
||||
if (strcasestr(colorname, "bright")) {
|
||||
if (stristr(colorname, "bright")) {
|
||||
*bright = 1;
|
||||
colorname += 6;
|
||||
}
|
||||
@@ -358,7 +349,7 @@ void parse_rcfile(FILE * rcstream)
|
||||
/* We don't care if ptr == NULL, as it should if using proper syntax */
|
||||
|
||||
if (set != 0) {
|
||||
for (i = 0; i <= NUM_RCOPTS - 1; i++) {
|
||||
for (i = 0; rcopts[i].name != ""; i++) {
|
||||
if (!strcasecmp(option, rcopts[i].name)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("parse_rcfile: Parsing option %s\n"),
|
||||
@@ -370,6 +361,9 @@ void parse_rcfile(FILE * rcstream)
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
!strcasecmp(rcopts[i].name, "fill") ||
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
!strcasecmp(rcopts[i].name, "quotestr") ||
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
!strcasecmp(rcopts[i].name, "speller")
|
||||
#else
|
||||
@@ -405,6 +399,15 @@ void parse_rcfile(FILE * rcstream)
|
||||
} else {
|
||||
tabsize = i;
|
||||
}
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
} else
|
||||
if (!strcasecmp(rcopts[i].name, "quotestr"))
|
||||
{
|
||||
quotestr = NULL;
|
||||
quotestr =
|
||||
charalloc(strlen(option) + 1);
|
||||
strcpy(quotestr, option);
|
||||
#endif
|
||||
} else {
|
||||
#ifndef DISABLE_SPELLER
|
||||
alt_speller =
|
||||
@@ -443,10 +446,21 @@ void do_rcfile(void)
|
||||
struct stat fileinfo;
|
||||
FILE *rcstream;
|
||||
|
||||
|
||||
if (getenv("HOME") == NULL)
|
||||
return;
|
||||
|
||||
nanorc = charalloc(strlen(SYSCONFDIR) + 10);
|
||||
sprintf(nanorc, "%s/nanorc", SYSCONFDIR);
|
||||
|
||||
/* Try to open system nanorc */
|
||||
if (stat(nanorc, &fileinfo) != -1)
|
||||
if ((rcstream = fopen(nanorc, "r")) != NULL) {
|
||||
|
||||
/* Parse it! */
|
||||
parse_rcfile(rcstream);
|
||||
fclose(rcstream);
|
||||
}
|
||||
|
||||
nanorc = charalloc(strlen(getenv("HOME")) + 10);
|
||||
sprintf(nanorc, "%s/.nanorc", getenv("HOME"));
|
||||
|
||||
|
||||
78
search.c
78
search.c
@@ -76,7 +76,7 @@ int search_init(int replacing)
|
||||
char *buf;
|
||||
static char *backupstring = NULL;
|
||||
#ifndef NANO_SMALL
|
||||
int j;
|
||||
toggle *t;
|
||||
#endif
|
||||
|
||||
search_init_globals();
|
||||
@@ -126,8 +126,7 @@ int search_init(int replacing)
|
||||
strcpy(buf, "");
|
||||
|
||||
/* This is now one simple call. It just does a lot */
|
||||
i = statusq(0, replacing ? replace_list : whereis_list,
|
||||
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, backupstring,
|
||||
i = statusq(0, replacing ? replace_list : whereis_list, backupstring,
|
||||
"%s%s%s%s%s%s",
|
||||
_("Search"),
|
||||
|
||||
@@ -187,9 +186,9 @@ int search_init(int replacing)
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
for (j = 0; j <= TOGGLE_LEN - 1; j++)
|
||||
if (i == toggles[j].val)
|
||||
TOGGLE(toggles[j].flag);
|
||||
for (t = toggles; t != NULL; t = t->next)
|
||||
if (i == t->val)
|
||||
TOGGLE(t->flag);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -240,7 +239,7 @@ int is_whole_word(int curr_pos, filestruct *fileptr, char *searchword)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int past_editbuff; /* search is now looking through lines not displayed */
|
||||
int past_editbuff; /* findnextstr() is now searching lines not displayed */
|
||||
|
||||
filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beginx,
|
||||
char *needle)
|
||||
@@ -248,7 +247,6 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
||||
filestruct *fileptr;
|
||||
char *searchstr, *rev_start = NULL, *found = NULL;
|
||||
int current_x_find = 0;
|
||||
|
||||
fileptr = current;
|
||||
|
||||
past_editbuff = 0;
|
||||
@@ -316,13 +314,13 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
||||
else { /* reverse search */
|
||||
|
||||
current_x_find = current_x - 1;
|
||||
|
||||
#if 0
|
||||
/* Are we now back to the place where the search started) */
|
||||
if ((fileptr == begin) && (current_x_find > beginx))
|
||||
search_last_line = 1;
|
||||
|
||||
#endif
|
||||
/* Make sure we haven't passed the begining of the string */
|
||||
#if 1 /* Is this required here ? */
|
||||
#if 0 /* Is this required here ? */
|
||||
if (!(&fileptr->data[current_x_find] - fileptr->data))
|
||||
current_x_find++;
|
||||
#endif
|
||||
@@ -597,7 +595,8 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
||||
int wholewords, int *i)
|
||||
{
|
||||
int replaceall = 0, numreplaced = 0;
|
||||
filestruct *fileptr;
|
||||
|
||||
filestruct *fileptr = NULL;
|
||||
char *copy;
|
||||
|
||||
switch (*i) {
|
||||
@@ -625,7 +624,14 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
||||
while (1) {
|
||||
|
||||
/* Sweet optimization by Rocco here */
|
||||
#if 0
|
||||
fileptr = findnextstr(replaceall, FALSE, begin, *beginx, prevanswer);
|
||||
#else
|
||||
if (fileptr != 0)
|
||||
fileptr = findnextstr(1, FALSE, begin, *beginx, prevanswer);
|
||||
else
|
||||
fileptr = findnextstr(replaceall || (search_last_line ? 1 : 0), FALSE, begin, *beginx, prevanswer);
|
||||
#endif
|
||||
|
||||
/* No more matches. Done! */
|
||||
if (!fileptr)
|
||||
@@ -664,17 +670,29 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
||||
current->data = copy;
|
||||
totsize += strlen(current->data);
|
||||
|
||||
/* Stop bug where we replace a substring of the replacement text */
|
||||
current_x += strlen(last_replace) - 1;
|
||||
if (!ISSET(REVERSE_SEARCH)) {
|
||||
/* Stop bug where we replace a substring of the replacement text */
|
||||
current_x += strlen(last_replace) - 1;
|
||||
|
||||
/* Adjust the original cursor position - COULD BE IMPROVED */
|
||||
if (search_last_line) {
|
||||
*beginx += strlen(last_replace) - strlen(last_search);
|
||||
/* Adjust the original cursor position - COULD BE IMPROVED */
|
||||
if (search_last_line) {
|
||||
*beginx += strlen(last_replace) - strlen(last_search);
|
||||
|
||||
/* For strings that cross the search start/end boundary */
|
||||
/* Don't go outside of allocated memory */
|
||||
if (*beginx < 1)
|
||||
*beginx = 1;
|
||||
/* For strings that cross the search start/end boundary */
|
||||
/* Don't go outside of allocated memory */
|
||||
if (*beginx < 1)
|
||||
*beginx = 1;
|
||||
}
|
||||
} else {
|
||||
if (current_x > 1)
|
||||
current_x--;
|
||||
|
||||
if (search_last_line) {
|
||||
*beginx += strlen(last_replace) - strlen(last_search);
|
||||
|
||||
if (*beginx > strlen(current->data))
|
||||
*beginx = strlen(current->data);
|
||||
}
|
||||
}
|
||||
|
||||
edit_refresh();
|
||||
@@ -743,28 +761,36 @@ int do_replace(void)
|
||||
} else
|
||||
sprintf(buf, "%s", last_replace);
|
||||
|
||||
i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, "",
|
||||
i = statusq(0, replace_list_2, "",
|
||||
_("Replace with [%s]"), buf);
|
||||
}
|
||||
else
|
||||
i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, "",
|
||||
i = statusq(0, replace_list_2, "",
|
||||
_("Replace with"));
|
||||
}
|
||||
else
|
||||
i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, last_replace,
|
||||
i = statusq(0, replace_list_2, last_replace,
|
||||
_("Replace with"));
|
||||
|
||||
/* save where we are */
|
||||
begin = current;
|
||||
#if 0
|
||||
/* why + 1 ? isn't this taken care of in findnextstr() ? */
|
||||
beginx = current_x + 1;
|
||||
|
||||
#else
|
||||
beginx = current_x;
|
||||
#endif
|
||||
search_last_line = 0;
|
||||
|
||||
numreplaced = do_replace_loop(prevanswer, begin, &beginx, FALSE, &i);
|
||||
|
||||
/* restore where we were */
|
||||
current = begin;
|
||||
#if 0
|
||||
current_x = beginx - 1;
|
||||
#else
|
||||
current_x = beginx;
|
||||
#endif
|
||||
renumber_all();
|
||||
edit_update(current, CENTER);
|
||||
print_replaced(numreplaced);
|
||||
@@ -786,7 +812,7 @@ int do_gotoline(int line, int save_pos)
|
||||
|
||||
int j = 0;
|
||||
|
||||
j = statusq(0, goto_list, GOTO_LIST_LEN, "", _("Enter line number"));
|
||||
j = statusq(0, goto_list, "", _("Enter line number"));
|
||||
if (j != 0) {
|
||||
statusbar(_("Aborted"));
|
||||
goto_abort();
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
timestamp
|
||||
38
utils.c
38
utils.c
@@ -36,6 +36,21 @@
|
||||
#define _(string) (string)
|
||||
#endif
|
||||
|
||||
int num_of_digits(int n)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (n < 0)
|
||||
n = 0 - n;
|
||||
|
||||
while (n > 10) {
|
||||
n /= 10;
|
||||
i++;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Lower case a string - must be null terminated */
|
||||
void lowercase(char *src)
|
||||
{
|
||||
@@ -62,7 +77,7 @@ char *revstrstr(char *haystack, char *needle, char *rev_start)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *revstrcasestr(char *haystack, char *needle, char *rev_start)
|
||||
char *revstristr(char *haystack, char *needle, char *rev_start)
|
||||
{
|
||||
char *p, *q, *r;
|
||||
|
||||
@@ -77,7 +92,7 @@ char *revstrcasestr(char *haystack, char *needle, char *rev_start)
|
||||
|
||||
/* This is now mutt's version (called mutt_stristr) because it doesn't
|
||||
use memory allocation to do a simple search (yuck). */
|
||||
char *strcasestr(char *haystack, char *needle)
|
||||
char *stristr(char *haystack, char *needle)
|
||||
{
|
||||
const char *p, *q;
|
||||
|
||||
@@ -101,32 +116,29 @@ char *strstrwrapper(char *haystack, char *needle, char *rev_start)
|
||||
{
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
|
||||
int result;
|
||||
char *i, *j;
|
||||
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
#ifndef NANO_SMALL
|
||||
if (!ISSET(REVERSE_SEARCH)) {
|
||||
result = regexec(&search_regexp, haystack, 10, regmatches, 0);
|
||||
if (!result)
|
||||
return haystack + regmatches[0].rm_so;
|
||||
#ifndef NANO_SMALL
|
||||
} else {
|
||||
#endif
|
||||
/* do quick check first */
|
||||
char *i, *j;
|
||||
|
||||
/* do a quick search forward first */
|
||||
if (!(regexec(&search_regexp, haystack, 10, regmatches, 0))) {
|
||||
/* there is a match */
|
||||
/* there's a match somewhere in the line - now search for it backwards, much slower */
|
||||
for(i = rev_start ; i >= haystack ; --i)
|
||||
if (!(result = regexec(&search_regexp, i, 10, regmatches, 0))) {
|
||||
j = i + regmatches[0].rm_so;
|
||||
if (j <= rev_start)
|
||||
return j;
|
||||
}
|
||||
|
||||
}
|
||||
#ifndef NANO_SMALL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -139,10 +151,10 @@ char *strstrwrapper(char *haystack, char *needle, char *rev_start)
|
||||
|
||||
} else {
|
||||
if (ISSET(REVERSE_SEARCH))
|
||||
return revstrcasestr(haystack, needle, rev_start);
|
||||
return revstristr(haystack, needle, rev_start);
|
||||
else
|
||||
#endif
|
||||
return strcasestr(haystack, needle);
|
||||
return stristr(haystack, needle);
|
||||
#ifndef NANO_SMALL
|
||||
}
|
||||
#endif
|
||||
|
||||
152
winio.c
152
winio.c
@@ -134,14 +134,14 @@ int actual_x(filestruct * fileptr, int xplus)
|
||||
}
|
||||
|
||||
/* a strlen with tabs factored in, similar to xplustabs() */
|
||||
int strlenpt(char *buf)
|
||||
int strnlenpt(char *buf, int size)
|
||||
{
|
||||
int i, tabs = 0;
|
||||
|
||||
if (buf == NULL)
|
||||
return 0;
|
||||
|
||||
for (i = 0; buf[i] != 0; i++) {
|
||||
for (i = 0; i < size; i++) {
|
||||
tabs++;
|
||||
|
||||
if (buf[i] == NANO_CONTROL_I) {
|
||||
@@ -158,6 +158,11 @@ int strlenpt(char *buf)
|
||||
return tabs;
|
||||
}
|
||||
|
||||
int strlenpt(char *buf)
|
||||
{
|
||||
return strnlenpt(buf, strlen(buf));
|
||||
}
|
||||
|
||||
|
||||
/* resets current_y, based on the position of current, and puts the cursor at
|
||||
(current_y, current_x) */
|
||||
@@ -258,16 +263,18 @@ void nanoget_repaint(char *buf, char *inputbuf, int x)
|
||||
}
|
||||
|
||||
/* Get the input from the kb; this should only be called from statusq */
|
||||
int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
int nanogetstr(int allowtabs, char *buf, char *def, shortcut *s,
|
||||
int start_x, int list)
|
||||
{
|
||||
int kbinput = 0, j = 0, x = 0, xend;
|
||||
int kbinput = 0, x = 0, xend, slen;
|
||||
int x_left = 0, inputlen, tabbed = 0;
|
||||
char *inputbuf;
|
||||
shortcut *t;
|
||||
#ifndef DISABLE_TABCOMP
|
||||
int shift = 0;
|
||||
#endif
|
||||
|
||||
slen = length_of_list(s);
|
||||
inputbuf = charalloc(strlen(def) + 1);
|
||||
inputbuf[0] = 0;
|
||||
|
||||
@@ -276,7 +283,6 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
|
||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||
currshortcut = s;
|
||||
currslen = slen;
|
||||
#endif
|
||||
|
||||
/* Get the input! */
|
||||
@@ -289,12 +295,12 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
wrefresh(edit);
|
||||
|
||||
while ((kbinput = wgetch(bottomwin)) != 13) {
|
||||
for (j = 0; j <= slen - 1; j++) {
|
||||
for (t = s; t != NULL; t = t->next) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("Aha! \'%c\' (%d)\n"), kbinput, kbinput);
|
||||
#endif
|
||||
|
||||
if (kbinput == s[j].val && kbinput < 32) {
|
||||
if (kbinput == t->val && kbinput < 32) {
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
/* Have to do this here, it would be too late to do it in statusq */
|
||||
@@ -308,7 +314,7 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
we hit a keystroke, GEEZ! */
|
||||
answer = mallocstrcpy(answer, inputbuf);
|
||||
free(inputbuf);
|
||||
return s[j].val;
|
||||
return t->val;
|
||||
}
|
||||
}
|
||||
xend = strlen(buf) + strlen(inputbuf);
|
||||
@@ -459,19 +465,19 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
}
|
||||
default:
|
||||
|
||||
for (j = 0; j <= slen - 1; j++) {
|
||||
for (t = s; t != NULL; t = t->next) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("Aha! \'%c\' (%d)\n"), kbinput,
|
||||
kbinput);
|
||||
#endif
|
||||
if (kbinput == s[j].val || kbinput == s[j].val - 32) {
|
||||
if (kbinput == t->val || kbinput == t->val - 32) {
|
||||
|
||||
/* We hit an Alt key. Do like above. We don't
|
||||
just ungetch the letter and let it get caught
|
||||
above cause that screws the keypad... */
|
||||
answer = mallocstrcpy(answer, inputbuf);
|
||||
free(inputbuf);
|
||||
return s[j].val;
|
||||
return t->val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,15 +579,17 @@ void titlebar(char *path)
|
||||
reset_cursor();
|
||||
}
|
||||
|
||||
void onekey(char *keystroke, char *desc)
|
||||
void onekey(char *keystroke, char *desc, int len)
|
||||
{
|
||||
char description[80];
|
||||
int i;
|
||||
|
||||
snprintf(description, 12 - (strlen(keystroke) - 2), " %-10s", desc);
|
||||
wattron(bottomwin, A_REVERSE);
|
||||
waddstr(bottomwin, keystroke);
|
||||
wattroff(bottomwin, A_REVERSE);
|
||||
waddstr(bottomwin, description);
|
||||
waddch(bottomwin, ' ');
|
||||
waddnstr(bottomwin, desc, len - 3);
|
||||
for (i = strlen(desc); i < len - 3; i++)
|
||||
waddch(bottomwin, ' ');
|
||||
}
|
||||
|
||||
void clear_bottomwin(void)
|
||||
@@ -593,10 +601,17 @@ void clear_bottomwin(void)
|
||||
mvwaddstr(bottomwin, 2, 0, hblank);
|
||||
}
|
||||
|
||||
void bottombars(shortcut s[], int slen)
|
||||
void bottombars(shortcut *s)
|
||||
{
|
||||
int i, j, k;
|
||||
int i, j, numcols;
|
||||
char keystr[10];
|
||||
shortcut *t;
|
||||
int slen;
|
||||
|
||||
if (s == main_list)
|
||||
slen = MAIN_VISIBLE;
|
||||
else
|
||||
slen = length_of_list(s);
|
||||
|
||||
if (ISSET(NO_HELP))
|
||||
return;
|
||||
@@ -610,39 +625,30 @@ void bottombars(shortcut s[], int slen)
|
||||
|
||||
/* Determine how many extra spaces are needed to fill the bottom of the screen */
|
||||
if (slen < 2)
|
||||
k = COLS / 6 - 13;
|
||||
numcols = 6;
|
||||
else
|
||||
k = COLS / ((slen + (slen % 2)) / 2) - 13;
|
||||
|
||||
numcols = (slen + (slen % 2)) / 2;
|
||||
|
||||
clear_bottomwin();
|
||||
wmove(bottomwin, 1, 0);
|
||||
|
||||
for (i = 0; i <= slen - 1; i += 2) {
|
||||
t = s;
|
||||
for (i = 0; i < numcols; i++) {
|
||||
for (j = 0; j <= 1; j++) {
|
||||
|
||||
if (s[i].val < 97)
|
||||
snprintf(keystr, 10, "^%c", s[i].val + 64);
|
||||
else
|
||||
snprintf(keystr, 10, "M-%c", s[i].val - 32);
|
||||
wmove(bottomwin, 1 + j, i * ((COLS - 1) / numcols));
|
||||
|
||||
onekey(keystr, s[i].desc);
|
||||
if (t->val < 97)
|
||||
snprintf(keystr, 10, "^%c", t->val + 64);
|
||||
else
|
||||
snprintf(keystr, 10, "M-%c", t->val - 32);
|
||||
|
||||
for (j = 0; j < k; j++)
|
||||
waddch(bottomwin, ' ');
|
||||
}
|
||||
onekey(keystr, t->desc, (COLS - 1) / numcols);
|
||||
|
||||
wmove(bottomwin, 2, 0);
|
||||
for (i = 1; i <= slen - 1; i += 2) {
|
||||
|
||||
if (s[i].val < 97)
|
||||
snprintf(keystr, 10, "^%c", s[i].val + 64);
|
||||
else
|
||||
snprintf(keystr, 10, "M-%c", s[i].val - 32);
|
||||
|
||||
onekey(keystr, s[i].desc);
|
||||
|
||||
for (j = 0; j < k; j++)
|
||||
waddch(bottomwin, ' ');
|
||||
if (t->next == NULL)
|
||||
break;
|
||||
t = t->next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -1293,7 +1299,7 @@ void update_cursor(void)
|
||||
*
|
||||
* New arg tabs tells whether or not to allow tab completion.
|
||||
*/
|
||||
int statusq(int tabs, shortcut s[], int slen, char *def, char *msg, ...)
|
||||
int statusq(int tabs, shortcut *s, char *def, char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char foo[133];
|
||||
@@ -1303,7 +1309,7 @@ int statusq(int tabs, shortcut s[], int slen, char *def, char *msg, ...)
|
||||
int list = 0;
|
||||
#endif
|
||||
|
||||
bottombars(s, slen);
|
||||
bottombars(s);
|
||||
|
||||
va_start(ap, msg);
|
||||
vsnprintf(foo, 132, msg, ap);
|
||||
@@ -1318,11 +1324,11 @@ int statusq(int tabs, shortcut s[], int slen, char *def, char *msg, ...)
|
||||
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
ret = nanogetstr(tabs, foo, def, s, slen, (strlen(foo) + 3), list);
|
||||
ret = nanogetstr(tabs, foo, def, s, (strlen(foo) + 3), list);
|
||||
#else
|
||||
/* if we've disabled tab completion, the value of list won't be
|
||||
used at all, so it's safe to use 0 (NULL) as a placeholder */
|
||||
ret = nanogetstr(tabs, foo, def, s, slen, (strlen(foo) + 3), 0);
|
||||
ret = nanogetstr(tabs, foo, def, s, (strlen(foo) + 3), 0);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -1399,18 +1405,18 @@ int do_yesno(int all, int leavecursor, char *msg, ...)
|
||||
wmove(bottomwin, 1, 0);
|
||||
|
||||
snprintf(shortstr, 3, " %c", yesstr[0]);
|
||||
onekey(shortstr, _("Yes"));
|
||||
onekey(shortstr, _("Yes"), 16);
|
||||
|
||||
if (all) {
|
||||
snprintf(shortstr, 3, " %c", allstr[0]);
|
||||
onekey(shortstr, _("All"));
|
||||
onekey(shortstr, _("All"), 16);
|
||||
}
|
||||
wmove(bottomwin, 2, 0);
|
||||
|
||||
snprintf(shortstr, 3, " %c", nostr[0]);
|
||||
onekey(shortstr, _("No"));
|
||||
onekey(shortstr, _("No"), 16);
|
||||
|
||||
onekey("^C", _("Cancel"));
|
||||
onekey("^C", _("Cancel"), 16);
|
||||
}
|
||||
va_start(ap, msg);
|
||||
vsnprintf(foo, 132, msg, ap);
|
||||
@@ -1556,7 +1562,7 @@ void statusbar(char *msg, ...)
|
||||
|
||||
void display_main_list(void)
|
||||
{
|
||||
bottombars(main_list, MAIN_VISIBLE);
|
||||
bottombars(main_list);
|
||||
}
|
||||
|
||||
int total_refresh(void)
|
||||
@@ -1585,13 +1591,24 @@ void previous_line(void)
|
||||
int do_cursorpos(int constant)
|
||||
{
|
||||
filestruct *fileptr;
|
||||
float linepct = 0.0, bytepct = 0.0;
|
||||
long i = 0;
|
||||
float linepct = 0.0, bytepct = 0.0, colpct = 0.0;
|
||||
long i = 0, j = 0;
|
||||
static long old_i = -1, old_totsize = -1;
|
||||
|
||||
if (current == NULL || fileage == NULL)
|
||||
return 0;
|
||||
|
||||
if (old_i == -1)
|
||||
old_i = i;
|
||||
|
||||
if (old_totsize == -1)
|
||||
old_totsize = totsize;
|
||||
|
||||
if (strlen(current->data) == 0)
|
||||
colpct = 0;
|
||||
else
|
||||
colpct = 100 * xplustabs() / xpt(current, strlen(current->data));
|
||||
|
||||
for (fileptr = fileage; fileptr != current && fileptr != NULL;
|
||||
fileptr = fileptr->next)
|
||||
i += strlen(fileptr->data) + 1;
|
||||
@@ -1601,18 +1618,14 @@ int do_cursorpos(int constant)
|
||||
|
||||
i += current_x;
|
||||
|
||||
if (old_i == -1)
|
||||
old_i = i;
|
||||
|
||||
if (old_totsize == -1)
|
||||
old_totsize = totsize;
|
||||
|
||||
if (totlines > 0)
|
||||
linepct = 100 * current->lineno / totlines;
|
||||
j = totsize;
|
||||
|
||||
if (totsize > 0)
|
||||
bytepct = 100 * i / totsize;
|
||||
|
||||
if (totlines > 0)
|
||||
linepct = 100 * current->lineno / totlines;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("do_cursorpos: linepct = %f, bytepct = %f\n"),
|
||||
linepct, bytepct);
|
||||
@@ -1623,8 +1636,9 @@ int do_cursorpos(int constant)
|
||||
character values have changed */
|
||||
if (!constant || (old_i != i || old_totsize != totsize)) {
|
||||
statusbar(_
|
||||
("line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"),
|
||||
current->lineno, totlines, linepct, i, totsize, bytepct);
|
||||
("line %d/%d (%.0f%%), col %ld/%ld (%.0f%%), char %ld/%ld (%.0f%%)"),
|
||||
current->lineno, totlines, linepct, xplustabs(),
|
||||
xpt(current, strlen(current->data)), colpct, i, j, bytepct);
|
||||
}
|
||||
|
||||
old_i = i;
|
||||
@@ -1648,7 +1662,6 @@ int do_help(void)
|
||||
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0, kp, kp2;
|
||||
int no_help_flag = 0;
|
||||
shortcut *oldshortcut;
|
||||
int oldslen;
|
||||
|
||||
blank_edit();
|
||||
curs_set(0);
|
||||
@@ -1659,10 +1672,8 @@ int do_help(void)
|
||||
ptr = help_text;
|
||||
|
||||
oldshortcut = currshortcut;
|
||||
oldslen = currslen;
|
||||
|
||||
currshortcut = help_list;
|
||||
currslen = HELP_LIST_LEN;
|
||||
|
||||
kp = keypad_on(edit, 1);
|
||||
kp2 = keypad_on(bottomwin, 1);
|
||||
@@ -1674,10 +1685,10 @@ int do_help(void)
|
||||
no_help_flag = 1;
|
||||
UNSET(NO_HELP);
|
||||
window_init();
|
||||
bottombars(help_list, HELP_LIST_LEN);
|
||||
bottombars(help_list);
|
||||
|
||||
} else
|
||||
bottombars(help_list, HELP_LIST_LEN);
|
||||
bottombars(help_list);
|
||||
|
||||
do {
|
||||
ptr = help_text;
|
||||
@@ -1758,7 +1769,6 @@ int do_help(void)
|
||||
kbinput != NANO_EXIT_FKEY);
|
||||
|
||||
currshortcut = oldshortcut;
|
||||
currslen = oldslen;
|
||||
|
||||
if (no_help_flag) {
|
||||
blank_bottombars();
|
||||
@@ -1766,7 +1776,7 @@ int do_help(void)
|
||||
SET(NO_HELP);
|
||||
window_init();
|
||||
} else
|
||||
bottombars(currshortcut, currslen);
|
||||
bottombars(currshortcut);
|
||||
|
||||
curs_set(1);
|
||||
edit_refresh();
|
||||
@@ -1887,6 +1897,7 @@ void do_credits(void)
|
||||
"Adam Rogoyski",
|
||||
"Rob Siemborski",
|
||||
"Rocco Corsi",
|
||||
"David Lawrence Ramsey",
|
||||
"Ken Tyler",
|
||||
"Sven Guckes",
|
||||
"Florian König",
|
||||
@@ -1901,7 +1912,6 @@ void do_credits(void)
|
||||
"Joshua Jensen",
|
||||
"Ryan Krebs",
|
||||
"Albert Chin",
|
||||
"David Lawrence Ramsey",
|
||||
"",
|
||||
specialthx,
|
||||
"Plattsburgh State University",
|
||||
|
||||
Reference in New Issue
Block a user