Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b4e433687 | ||
|
|
22c83ec7af | ||
|
|
2072b74153 | ||
|
|
66e5972c52 | ||
|
|
a149549d07 | ||
|
|
67acf2c753 | ||
|
|
29479ca7f5 | ||
|
|
b7a2dfb2da | ||
|
|
f4e26d174e | ||
|
|
2e4228f78e | ||
|
|
a016f00f14 | ||
|
|
76d61ec167 | ||
|
|
2a76b434fc | ||
|
|
1642e6a368 | ||
|
|
3116d2f7de | ||
|
|
4cc2462ed4 | ||
|
|
170607b6c9 | ||
|
|
636e76af23 | ||
|
|
220247172a | ||
|
|
d70c7f3c14 | ||
|
|
21f73f902f | ||
|
|
bf88d27adc | ||
|
|
2ad1de0ba6 | ||
|
|
d84849ec12 | ||
|
|
8d7402f470 | ||
|
|
daeab0518d | ||
|
|
090e2cf726 | ||
|
|
7a707670d6 | ||
|
|
f9217437ad | ||
|
|
fda622c0cd | ||
|
|
bccf2fa1c9 | ||
|
|
34de1a6706 | ||
|
|
946b2f4ace | ||
|
|
3bd12e3714 | ||
|
|
3459e4f432 | ||
|
|
20d93295c1 | ||
|
|
154136a7cb | ||
|
|
392c23c9c5 | ||
|
|
8e2a930714 | ||
|
|
9bfda9196b | ||
|
|
b00d0b9c8c | ||
|
|
637daa85c5 | ||
|
|
3d411188f6 | ||
|
|
d5b1c7c5bf | ||
|
|
ab53864de7 | ||
|
|
8deebeb904 | ||
|
|
544c56c036 | ||
|
|
9b1c868326 | ||
|
|
14d7c5de2a | ||
|
|
7a1b1ff5be | ||
|
|
461519cce7 | ||
|
|
0acca27ac7 | ||
|
|
86be3af75f | ||
|
|
0dcfa1d7f7 |
150
ChangeLog
150
ChangeLog
@@ -1,3 +1,153 @@
|
||||
2013-03-17 Chris Allegretta <chrisa@asty.org>
|
||||
* Revert r4547 as we should have a new release and the overlap code is not yet
|
||||
ready for public consumption.
|
||||
|
||||
2013-01-20 Chris Allegretta <chrisa@asty.org>
|
||||
* src/text.c (do_histify): Don't allow sigwinch to be received while justifying
|
||||
as that puts us into a wacky state. Fixess crash on justify by Joshua Rogers.
|
||||
* configure.ac: Added --with-wordbounds option to let cross compilers force
|
||||
whether their target system support GNU-style word boundaries or not.
|
||||
Originally reported by dave festing.
|
||||
* doc/man/nanorc.5: Fix typo in softwrap description, reported by
|
||||
cbart387@Savannah.
|
||||
|
||||
2013-01-19 Chris Allegretta <chrisa@asty.org>
|
||||
* configure.ac: Make ncurses checking to set $LIBS and check the ncursesw lib
|
||||
actually works before defaulting to it over ncurses! Shock!
|
||||
|
||||
2013-01-13 Chris Allegretta <chrisa@asty.org>
|
||||
* src/utils.c (parse_num): Initalize errno before calling strtol(). Fixes issue
|
||||
where trying to go to a line number too long will break legitimate goto-lines
|
||||
for the remainder of the editing session, reported by Joshua Rogers.
|
||||
|
||||
2013-01-09 Mike Frysinger <vapier@gentoo.org>
|
||||
* configure.ac: Check for ncursesw5-config and base $CPPFLAGS based on it.
|
||||
|
||||
2013-01-09 Fabian Groffen <grobian@Savannah>
|
||||
* configure.ac, src/nano.h: Make search for ncursesw more generalized.
|
||||
|
||||
2013-01-02 David Benjamin <davidben@Savannah>
|
||||
* src/search.c (parse_syntax): Fix blatantly and dangerously incorrect code for
|
||||
deleting old syntaxes.
|
||||
|
||||
2013-01-02 Mike Frysinger <vapier@gentoo.org>
|
||||
* src/files.c (cwd_tab_completion): Remove unnecessary variables
|
||||
* src/search.c (search_init): Fix gcc complaints on certain versions
|
||||
|
||||
2013-01-02 Eitan Adler <lists@eitanadler.com>
|
||||
* configure.ac: Remove unnecessary checks
|
||||
* src/nano.h, NEWS: Fix redundant wording
|
||||
|
||||
2012-12-31 Chris Allegretta <chrisa@asty.org>
|
||||
* src/*: Introduce (basic) vim-style file locks. Does not allow vim to recover
|
||||
our changes, and just lets a vim user know we're editing a file. Commands line "-G"
|
||||
or "--locking", nanorc option "locking". New functions
|
||||
src/files.c:do_lockfile(), write_lockfile(), and delete_lockfile().
|
||||
|
||||
2012-02-05 Chris Allegretta <chrisa@asty.org>
|
||||
* src/*: Fix overlapping strings highlighting each other. new variables in edit_draw
|
||||
(slmatcharray, pbegin, paintok), new logic (with repeated setting od values in the
|
||||
array but its BFI after all). FIXME: Need to create a new 'overlap'
|
||||
* src/*: Fix a silly issue with the argument to nregcomp, as it's confusing to the caller
|
||||
* src/nano.h: Change the color types to a compiler macro (COLORWIDTH), may not actually
|
||||
even be worth doing, but someday who knows how wide a color curses implementation might
|
||||
be, and maybe we'll even start checking for it in autoconf!
|
||||
|
||||
GNU nano 2.3.1 - 2011.05.10
|
||||
2011-05-10 Chris Allegretta <chrisa@asty.org>
|
||||
* text.c (do_enter): Only increment totsize by the auto-indented amount, size the previous line's size was
|
||||
already counted. Fixes bug reported by Robert Spanjaard.
|
||||
|
||||
2011-05-08 Chris Allegretta <chrisa@asty.org>
|
||||
* doc/syntax/Makefile.am: Finally get around to sorting the syntax file list
|
||||
|
||||
2011-05-08 Matthew Wild <mattj100@Savannah>
|
||||
* doc/syntax/spec.nanorc: New lua syntax highlighting config
|
||||
|
||||
2011-03-28 Asterios Dramis <asterios.dramis@gmail.com>
|
||||
* doc/syntax/spec.nanorc: New RPM spec file highlighting config
|
||||
|
||||
2011-03-12 Chris Allegretta <chrisa@asty.org>
|
||||
* po/*: Sync latest translation fixes, add an update_linguas.sh script. Rename
|
||||
existing update.pl to update_sources.pl to make it more specific.
|
||||
|
||||
2011-03-04 Chris Allegretta <chrisa@asty.org>
|
||||
* color.c (color_update): Add check for whether the file even exists
|
||||
before we try to run the magic check on it. Fixes error messages to stderr
|
||||
when reading in files that don't exist, reported by Mike Frysinger.
|
||||
|
||||
2011-03-03 Chris Allegretta <chrisa@asty.org>
|
||||
* color.c (color_update): Remove unneeded debugging message from
|
||||
libmagic commit. Fixed extra messages going to stderr reported by Mike Frysinger.
|
||||
|
||||
GNU nano 2.3.0 - 2011.02.26
|
||||
2011-02-26 Chris Allegretta <chrisa@asty.org>
|
||||
* Change RAW in function_type enum to RAWINPUT, to fix compilation on AIX,
|
||||
reported by Richard G Daniel <skunk@iskunk.org>.
|
||||
|
||||
2011-02-23 Chris Allegretta <chrisa@asty.org>
|
||||
* Fix some more severe warnings from 'g++ -pedantic', from patch originally
|
||||
by Eitan Adler <lists@eitanadler.com>
|
||||
|
||||
2011-02-23 Kamil Dudka <kdudka@redhat.com>
|
||||
* doc/man/nanorc.5: Fix small typo
|
||||
|
||||
2011-02-22 Chris Allegretta <chrisa@asty.org>
|
||||
* color.c (nfreeregex): Fix that we were trying to set the pointer passed by value
|
||||
to NULL. Fixes crashes on file save reported by Ken Tyler and Matthieu Lejeune.
|
||||
|
||||
2011-02-18 Chris Allegretta <chrisa@asty.org>
|
||||
* New saved cursor position history option. Command line option -P or --poslog, rc file
|
||||
entry "poslog". Search history changes to ~/.nano/search_history, cursor position log
|
||||
is ~/.nano/filepos_history. Added checks to move the legacy .nano_history file to the new
|
||||
location. Several new functions to files.c: load_poshistory(), save_poshistory(),
|
||||
check_poshistory(), update_poshistory(), and reworking of histfilename(). New FAQ entry
|
||||
4.15 discussing the change and offering an interoperability workaround.
|
||||
* files.c (load_history): Set last_search to the last search value we loaded from history,
|
||||
so do_research will succeed without needing to manually load the last seach in. Fixes
|
||||
bug reported by Matthieu Lejeune.
|
||||
|
||||
2011-02-12 Chris Allegretta <chrisa@asty.org>
|
||||
* Initial libmagic implementation, adapted from Eitan Adler <eitanadlerlist@gmail.com>.
|
||||
New nanorc entry "magic" to enable this functionality, nanorc file and man page updates.
|
||||
|
||||
2011-02-06 Chris Allegretta <chrisa@asty.org>
|
||||
* src/*: Retire iso_me_harder_funcmap based on suggestion by <bernd.spaeth@gmx.net>
|
||||
This does add 20KB to nano's executable size but it gets rid of a lot of indirection
|
||||
that makes people stomach turn. There are several new stub functions and need of more
|
||||
tidying as a result of this.
|
||||
* files.c (write_file): Fix problems with writing the backup file (albeit interactively)
|
||||
with new function prompt_failed_backupwrite(), allows more secure handling of problems
|
||||
with failing to write the backup file compared to 'allow_insecure_backup'.
|
||||
* winio.c (edit_redraw): Removed unused variable
|
||||
|
||||
2010-11-15 Chris Allegretta <chrisa@asty.org>
|
||||
* Add a section to the FAQ about using nanorc on Win32 systems.
|
||||
|
||||
2010-11-12 Chris Allegretta <chrisa@asty.org>
|
||||
* Add check for RESTRICTED mode back to speller, suspend and insert file
|
||||
routines, since adding key bindings broke the fact that they should be
|
||||
disabled in restricted mode. Fixes Savannah bug 31625 reported by
|
||||
Charlie Somerville.
|
||||
|
||||
GNU nano 2.2.5 - 2010.08.05
|
||||
2010-08-04 Lauri Kasanen <curaga@operamail.comcuraga@operamail.com>
|
||||
* doc/syntax/mgp.nanorc: New Magicpoint syntax highlighting definition
|
||||
|
||||
2010-08-04 Peter <exodus@savannah>
|
||||
* doc/syntax/tex.nanorc: No longer highlight escaped comments
|
||||
|
||||
2010-06-20 Chris Allegretta <chrisa@asty.org>
|
||||
* New rc file option allow_insecure_backup, allows the previous security
|
||||
fixes for backup files to be overridden if you're really positive
|
||||
you want to. Fixes Savannah bug 29732 by Brian Szymanski <skibrianski>.
|
||||
|
||||
2010-05-23 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (write_file): Don't even try to chown() the backup
|
||||
file unless we're root, since it's probably going to fail if
|
||||
we're editing a file we don't own. Fixes Savannah bug
|
||||
29514: [nano 2.2.2] backup should ignore chown errors.
|
||||
|
||||
GNU nano 2.2.4 - 2010.04.15
|
||||
2010-04-07 Chris Allegretta <chrisa@asty.org>
|
||||
* doc/man/nano.1,nanorc.5: Remove the backup file warnings now
|
||||
|
||||
47
NEWS
47
NEWS
@@ -1,3 +1,44 @@
|
||||
2013.03.22 - GNU nano 2.3.2 "Annoy your coworkers for fun and profit" is
|
||||
released. This release introduces vim-style file locking
|
||||
(though not backup/restore), useful when using nano
|
||||
in a multi-editor environment. Feedback is welcome if
|
||||
you run into any issues with this new code. Other new
|
||||
features include additional support for word boundary
|
||||
checking when cross compiling, fixes for trying to go to
|
||||
an invalid line number, and the usual documentation
|
||||
tweaks.
|
||||
|
||||
2011.05.10 - GNU nano 2.3.1 "I'm in space" is released. This
|
||||
release includes some fixes for the new libmagic code, as
|
||||
well as a fix for improper character counts when using
|
||||
auto-indent. Also included are new syntax highlighting
|
||||
definitions for RPM spec and lua files. Thanks for
|
||||
using nano and keep circulating the tapes.
|
||||
|
||||
2011.02.26 - GNU nano 2.3.0 "Septic surprise" is released. This first
|
||||
release in the 2.3 unstable series bring several new
|
||||
features. First, libmagic support for syntax highlighting
|
||||
has been added on top of the existing file extension
|
||||
and header support already available. Secondly, cursor
|
||||
position can be saved between editing sessions with
|
||||
the -P or --poslog command line flags, or via "set poslog"
|
||||
in your .nanorc. Also included are some fixes for
|
||||
compilation with g++, and better handling of issues
|
||||
writing the backup file, which should reduce the need
|
||||
for the 'set allow_insecure_backup" nanorc option.
|
||||
Don't stop, get it get it, don't stop, get it get it.
|
||||
|
||||
2010.08.05 - GNU nano 2.2.5 "Inactivity timeout" is now available.
|
||||
This release includes slightly less restrictive checkng
|
||||
when writing files in strange environments (e.g.
|
||||
when being used out of crontab). For very strange situations
|
||||
(such as where you cannot change the permissions on the
|
||||
file you're writing, there is a new rc file option
|
||||
"allow_insecure_backup" to be even more permissive and
|
||||
allowing the write to proceed. Also included are
|
||||
some syntax highlighting updated, and that is about it.
|
||||
Keep fighting the good fight children.
|
||||
|
||||
2010.04.15 - GNU nano 2.2.4 is nobody's fool. First and foremost,
|
||||
this relase includes some security fixes due to
|
||||
an assessment of nano's vulnerability to symlink attacks
|
||||
@@ -714,10 +755,10 @@
|
||||
new option to ignore rc files (-I,--ignorercfiles),
|
||||
compatibility with -pedantic, handling null characters
|
||||
before EOF, a slightly sportier nanorc.sample and more.
|
||||
Fixes are included included for justification,
|
||||
Fixes are included for justification,
|
||||
the reading and writing file routines, resizing and fill
|
||||
length, millions of memory leaks, the usage screen was
|
||||
updated, and the the --quotestr and --regexp really work
|
||||
updated, and the --quotestr and --regexp really work
|
||||
now ;-) Enjoy :)
|
||||
|
||||
05/12/2002 - GNU nano 1.1.9 is released, happy Mother's Day! This
|
||||
@@ -1042,7 +1083,7 @@
|
||||
|
||||
08/03/2000 - Nano 0.9.15 is the "I can't think of a release description"
|
||||
release. There are the usual gala of display bugfixes,
|
||||
a fix for the the nasty bug in -k mode that could create
|
||||
a fix for the nasty bug in -k mode that could create
|
||||
a loop in the file being edited, and some other code
|
||||
cleanup. Also, the -T option should now work regardless
|
||||
of the curses library used. Yay.
|
||||
|
||||
1
TODO
1
TODO
@@ -28,6 +28,7 @@ For the future (no targeted version, catch-all)
|
||||
FFFD (Replacement Character) per sequence instead of one per byte.
|
||||
|
||||
For version 2.4:
|
||||
- New regression framework built on expect.
|
||||
- Allow text searches in the help browser.
|
||||
- Handle window resizes better. After we resize, we should stay
|
||||
wherever we were before we resized, as Pico does.
|
||||
|
||||
49
configure.ac
49
configure.ac
@@ -20,9 +20,9 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [2.2.4], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.3.2], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_TARGET([])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
@@ -49,8 +49,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
|
||||
|
||||
dnl Checks for header files.
|
||||
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(getopt.h libintl.h limits.h regex.h sys/param.h wchar.h wctype.h stdarg.h)
|
||||
AC_CHECK_HEADERS(getopt.h libintl.h limits.h regex.h sys/param.h wchar.h wctype.h stdarg.h magic.h)
|
||||
|
||||
dnl Checks for options.
|
||||
|
||||
@@ -442,7 +441,17 @@ if eval "test x$CURSES_LIB_NAME = x"; then
|
||||
AC_CHECK_HEADERS(ncurses.h)
|
||||
|
||||
if test x$enable_utf8 != xno; then
|
||||
AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB="-lncursesw" CPPFLAGS="-I/usr/include/ncursesw $CPPFLAGS" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
|
||||
OLDLIBS="$LIBS"
|
||||
AC_CHECK_TOOL(NCURSESW_CONFIG, ncursesw5-config, no)
|
||||
if test "x$NCURSESW_CONFIG" != xno; then
|
||||
CURSES_LIB=`$NCURSESW_CONFIG --libs`
|
||||
LIBS="$CURSES_LIB $LIBS"
|
||||
CPPFLAGS="`$NCURSESW_CONFIG --cflags` $CPPFLAGS"
|
||||
AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
|
||||
else
|
||||
AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
|
||||
fi
|
||||
LIBS="$OLDLIBS"
|
||||
fi
|
||||
|
||||
if eval "test x$CURSES_LIB_NAME = x"; then
|
||||
@@ -519,7 +528,22 @@ fi
|
||||
if test x$color_support = xyes; then
|
||||
# now check for the end of word boundary support (/< and />)
|
||||
AC_MSG_CHECKING([for GNU-style word boundary regex support])
|
||||
AC_TRY_RUN([
|
||||
|
||||
AC_ARG_WITH(wordbounds,
|
||||
[ --with-wordbounds Use GNU-style word boundary delimiters],
|
||||
[ case "$with_wordbounds" in
|
||||
no)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(yes)
|
||||
# We explicitly don't check if the user forced the option, because
|
||||
# this is needed for cross compilers and we cant test the target
|
||||
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
|
||||
;;
|
||||
esac
|
||||
], [
|
||||
AC_TRY_RUN([
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
@@ -536,11 +560,13 @@ int main(void)
|
||||
return 1;
|
||||
return 0;
|
||||
}],
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
|
||||
)
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
|
||||
)
|
||||
])
|
||||
|
||||
# if test x$CURSES_LIB_NAME = xcurses; then
|
||||
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
|
||||
AC_TRY_RUN([
|
||||
@@ -583,6 +609,7 @@ AC_MSG_RESULT(yes),
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
|
||||
|
||||
AC_CHECK_LIB(magic, magic_open)
|
||||
|
||||
# Check for groff html support
|
||||
AC_MSG_CHECKING([for HTML support in groff])
|
||||
|
||||
15
doc/faq.html
15
doc/faq.html
@@ -29,7 +29,8 @@
|
||||
<a href="#3.6">3.6. How can I make the executable smaller? This is too bloated!</a><br>
|
||||
<a href="#3.7">3.7. Tell me more about this multibuffer stuff!</a><br>
|
||||
<a href="#3.8">3.8. Tell me more about this verbatim input stuff!</a><br>
|
||||
<a href="#3.9">3.9. How do I make a .nanorc file that nano will read when I start it?</a></p></blockquote>
|
||||
<a href="#3.9">3.9. How do I make a .nanorc file that nano will read when I start it?</a></br>
|
||||
<a href="#3.9.1">3.9.1. How about in Win32?</a></p></blockquote>
|
||||
<h2><a href="#4">4. Running</a></h2>
|
||||
<blockquote><p><a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
|
||||
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
|
||||
@@ -45,7 +46,8 @@
|
||||
<a href="#4.11">4.11. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||
<a href="#4.12">4.12. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
|
||||
<a href="#4.13">4.13. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
|
||||
<a href="#4.14">4.14. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a></p></blockquote>
|
||||
<a href="#4.14">4.14. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
|
||||
<a href="#4.15">4.15. On startup I get a message that says "Detected a legacy nano history file". Now other nano versionc can't find my search history!</a></p></blockquote>
|
||||
<h2><a href="#5">5. Internationalization</a></h2>
|
||||
<blockquote><p><a href="#5.1">5.1. There's no translation for my language!</a><br>
|
||||
<a href="#5.2">5.2. I don't like the translation for <x> in my language. How can I fix it?</a><br>
|
||||
@@ -167,6 +169,10 @@
|
||||
<p>Alternatively, if you've enabled Unicode support (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code from 000000 to 10FFFF (case-insensitive), and the character with the corresponding value will be inserted instead. The prompt will change to "Unicode Input" when you do this.</p></blockquote>
|
||||
<h2><a name="3.9"></a>3.9. How do I make a .nanorc file that nano will read when I start it?</h2>
|
||||
<blockquote><p>It's not hard at all! But, your version of nano must have been compiled with <b>--enable-nanorc</b>, and again must be version 1.1.12 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, the syntax is simple. Flags are turned on and off by using the word <b>set</b> and the getopt_long flag for the feature, for example "set nowrap" or "set suspend".</p></blockquote>
|
||||
<h2><a name="3.9.1"></a>3.9. How about in Win32?</h2>
|
||||
<blockquote><p>If you're using the official nano .zip file and have extracted all the files, you should take the file nano.rc and place it somewhere on your Win32 system (for example if you have write permission to do so, at the top of C:\). Then you must create an Environment variable called HOME which points to the directory where you put nano.rc. In Windows XP, you can get to Environment variables by right-clicking "My Computer" either on the desktop or in the Start Menu, and selecting Properties. This should bring up the System Properties panel. Then click the Advanced Tab, and there should be a button called Environment Variables. Click that to bring up the Environment Variables section. Now, under User Variables you should be able to click the New button, and make a new Variables Name called HOME, with the Variable Value of whatever path you copied nano.rc into (just the directory name; don't add nano.rc onto the end).</p>
|
||||
<p>We're still working on documentatino for enabling synax highlighting on Win32; please bear with us</p>
|
||||
<p>Note that the nano.rc file must remain Unix formated in order for nano to unerstand it. In other words, you should use probably only use nano to edit its config file. Other programs like Wordpad and Notepad will either convert the file to DOS format when saving, and the latter does not even properly read Unix-formatted files to begin with.</p></blockquote>
|
||||
<hr width="100%">
|
||||
<h1><a name="4"></a>4. Running</h1>
|
||||
<h2><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h2>
|
||||
@@ -217,6 +223,11 @@
|
||||
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
|
||||
<h2><a name="4.14"></a>4.14. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
|
||||
<blockquote><p>You have the autoindent feature turned on. Hit Meta-I to turn it off, paste your text, and then hit Meta-I again to turn it back on.</p></blockquote>
|
||||
<h2><a name="4.15"></a>4.15. On startup I get a message that says "Detected a legacy nano history file". Now other nano versionc can't find my search history!</h2>
|
||||
<blockquote><p>In nano 2.3.0, cursor position history was introduced, and both files now reside under a .nano directory in your home. Nano was trying to move this file into the new location so it could continue to use it. This means that if you try and use an earlier version of nano, it will be unable to see your previous search history. To fix this, run the following commands:<br>
|
||||
mv ~/.nano/search_history ~/.nano_history<br>
|
||||
ln -sf ~/.nano_history ~/.nano/search_history<br>
|
||||
</p></blockquote>
|
||||
<hr width="100%">
|
||||
<h1><a name="5"></a>5. Internationalization</h1>
|
||||
<h2><a name="5.1"></a>5.1. There's no translation for my language!</h2>
|
||||
|
||||
@@ -77,6 +77,9 @@ Convert typed tabs to spaces.
|
||||
.B \-F (\-\-multibuffer)
|
||||
Enable multiple file buffers, if available.
|
||||
.TP
|
||||
.B \-G (\-\-locking)
|
||||
Enable vim-style file locking when editing files.
|
||||
.TP
|
||||
.B \-H (\-\-historylog)
|
||||
Log search and replace strings to \fI~/.nano_history\fP, so they can be
|
||||
retrieved in later sessions, if \fInanorc\fP support is available.
|
||||
|
||||
@@ -57,6 +57,11 @@ match \fI"\fP, \fI'\fP, \fI)\fP, \fI>\fP, \fI]\fP, and \fI}\fP.
|
||||
The supported commands and arguments are:
|
||||
|
||||
.TP 3
|
||||
.B set/unset allow_insecure_backup
|
||||
When backing up files, allow the backup to succeed even if its permissions
|
||||
can't be (re)set due to special OS considerations. You should
|
||||
NOT enable this option unless you are sure you need it.
|
||||
.TP
|
||||
.B set/unset autoindent
|
||||
Use auto-indentation.
|
||||
.TP
|
||||
@@ -97,6 +102,9 @@ default value is \-8.
|
||||
Enable \fI~/.nano_history\fP for saving and reading search/replace
|
||||
strings.
|
||||
.TP
|
||||
.B set/unset locking
|
||||
Enable vim-style lock-files for when editing files.
|
||||
.TP
|
||||
.B set matchbrackets "\fIstring\fP"
|
||||
Set the opening and closing brackets that can be found by bracket
|
||||
searches. They cannot contain blank characters. The former set must
|
||||
@@ -133,7 +141,7 @@ Don't wrap text at all.
|
||||
.B set operatingdir "\fIdirectory\fP"
|
||||
\fBnano\fP will only read and write files inside \fIdirectory\fP and its
|
||||
subdirectories. Also, the current directory is changed to here, so
|
||||
files are inserted from this diractory. By default, the operating
|
||||
files are inserted from this directory. By default, the operating
|
||||
directory feature is turned off.
|
||||
.TP
|
||||
.B set/unset preserve
|
||||
@@ -175,6 +183,9 @@ won't work properly with this option enabled.
|
||||
.B set/unset regexp
|
||||
Do extended regular expression searches by default.
|
||||
.TP
|
||||
.B set/unset poslog
|
||||
Save the cursor position of files between editing sessions.
|
||||
.TP
|
||||
.B set/unset smarthome
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
very beginning of non-whitespace characters on a line, the cursor will
|
||||
@@ -186,7 +197,7 @@ line.
|
||||
Use smooth scrolling by default.
|
||||
.TP
|
||||
.B set/unset softwrap
|
||||
Enable soft line wrapping for easier viewing of very long lones.
|
||||
Enable soft line wrapping for easier viewing of very long lines.
|
||||
.TP
|
||||
.B set speller "\fIspellprog\fP"
|
||||
Use spelling checker \fIspellprog\fP instead of the built-in one, which
|
||||
@@ -234,6 +245,13 @@ the same as not having a syntax at all. The \fIdefault\fP syntax is
|
||||
special: it takes no \fIfileregex\fP, and applies to files that don't
|
||||
match any other syntax's \fIfileregex\fP.
|
||||
.TP
|
||||
.B magic ["\fIregex\fP" ... ]
|
||||
For the currently defined syntax, add one or more regexes which
|
||||
will be compared against the \fBmagic\fP database when attempting
|
||||
to determine which highlighting rules to use for a given file. This
|
||||
functionality only works when \fBlibmagic\fP is installed on the
|
||||
system and will be silently ignored otherwise.
|
||||
.TP
|
||||
.B color \fIfgcolor\fP,\fIbgcolor\fP "\fIregex\fP" ...
|
||||
For the currently defined syntax, display all expressions matching
|
||||
the extended regular expression \fIregex\fP with foreground color
|
||||
|
||||
@@ -56,6 +56,11 @@
|
||||
## Enable ~/.nano_history for saving and reading search/replace strings.
|
||||
# set historylog
|
||||
|
||||
## Enable vim-style lock-files. This is just to let a vim user know you
|
||||
## are editing a file [s]he is trying to edit and vice versa. There are
|
||||
## no plans to implement vim-style undo state in these files
|
||||
# set locking
|
||||
|
||||
## The opening and closing brackets that can be found by bracket
|
||||
## searches. They cannot contain blank characters. The former set must
|
||||
## come before the latter set, and both must be in the same order.
|
||||
|
||||
@@ -1,29 +1,32 @@
|
||||
pkgdata_DATA = asm.nanorc \
|
||||
c.nanorc \
|
||||
awk.nanorc \
|
||||
cmake.nanorc \
|
||||
c.nanorc \
|
||||
css.nanorc \
|
||||
debian.nanorc \
|
||||
fortran.nanorc \
|
||||
gentoo.nanorc \
|
||||
groff.nanorc \
|
||||
html.nanorc \
|
||||
java.nanorc \
|
||||
lua.nanorc \
|
||||
makefile.nanorc \
|
||||
man.nanorc \
|
||||
mgp.nanorc \
|
||||
mutt.nanorc \
|
||||
nanorc.nanorc \
|
||||
objc.nanorc \
|
||||
ocaml.nanorc \
|
||||
patch.nanorc \
|
||||
perl.nanorc \
|
||||
php.nanorc \
|
||||
pov.nanorc \
|
||||
python.nanorc \
|
||||
ruby.nanorc \
|
||||
sh.nanorc \
|
||||
tex.nanorc \
|
||||
spec.nanorc \
|
||||
tcl.nanorc \
|
||||
php.nanorc \
|
||||
gentoo.nanorc \
|
||||
debian.nanorc \
|
||||
awk.nanorc \
|
||||
css.nanorc \
|
||||
xml.nanorc \
|
||||
ocaml.nanorc \
|
||||
objc.nanorc \
|
||||
fortran.nanorc \
|
||||
makefile.nanorc
|
||||
tex.nanorc \
|
||||
xml.nanorc
|
||||
|
||||
EXTRA_DIST = $(pkgdata_DATA)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for assembler.
|
||||
##
|
||||
syntax "asm" "\.(S|s|asm)$"
|
||||
magic "[Aa]ssembl(y|er)"
|
||||
color red "\<[A-Z_]{2,}\>"
|
||||
color brightgreen "\.(data|subsection|text)"
|
||||
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for awk.
|
||||
##
|
||||
syntax "awk" "\.awk$"
|
||||
magic "awk.*script text"
|
||||
## records
|
||||
icolor brightred "\$[0-9A-Z_!@#$*?-]+"
|
||||
## awk-set variables
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for C/C++.
|
||||
##
|
||||
syntax "c" "\.(c(c|pp|xx)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$"
|
||||
magic "ASCII C(\+\+)? program text"
|
||||
color brightred "\<[A-Z_][0-9A-Z_]+\>"
|
||||
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
|
||||
color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
## Here is a short example for HTML.
|
||||
##
|
||||
syntax "html" "\.html$"
|
||||
magic "HTML document text"
|
||||
color blue start="<" end=">"
|
||||
color red "&[^;[[:space:]]]*;"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for Java.
|
||||
##
|
||||
syntax "java" "\.java$"
|
||||
magic "Java "
|
||||
color green "\<(boolean|byte|char|double|float|int|long|new|short|this|transient|void)\>"
|
||||
color red "\<(break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while)\>"
|
||||
color cyan "\<(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\>"
|
||||
|
||||
76
doc/syntax/lua.nanorc
Normal file
76
doc/syntax/lua.nanorc
Normal file
@@ -0,0 +1,76 @@
|
||||
##############################################################################
|
||||
#
|
||||
# Lua syntax highlighting for Nano.
|
||||
#
|
||||
# Author: Matthew Wild <mwild1 (at) gmail.com>
|
||||
# License: GPL 3 or later
|
||||
#
|
||||
# Version: 2011-05-05
|
||||
#
|
||||
# Notes: Originally based on Ruby syntax rc by Josef 'Jupp' Schugt
|
||||
##############################################################################
|
||||
|
||||
|
||||
# Automatically use for '.lua' files
|
||||
syntax "lua" "\.lua$"
|
||||
|
||||
color brightwhite "\[\[.*\]\]"
|
||||
|
||||
# Operators
|
||||
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\<(not|and|or)\>"
|
||||
|
||||
# Statements
|
||||
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
|
||||
|
||||
# Keywords
|
||||
color brightyellow "\<(debug|string|math|table|io|coroutine|os)\>\."
|
||||
color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\s*\("
|
||||
|
||||
# Standard library
|
||||
color brightyellow "io\.\<(close|flush|input|lines|open|output|popen|read|tmpfile|type|write|stdin|stdout|stderr)\>"
|
||||
color brightyellow "math\.\<(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log|max|min|mod|modf|pi|pow|rad|random|randomseed|sinh|tan)\>"
|
||||
color brightyellow "os\.\<(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>"
|
||||
color brightyellow "package\.\<(cpath|loaded|loadlib|path|preload|seeall)\>"
|
||||
color brightyellow "string\.\<(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)\>"
|
||||
color brightyellow "table\.\<(concat|insert|maxn|remove|sort)\>"
|
||||
color brightyellow "coroutine\.\<(create|resume|running|status|wrap|yield)\>"
|
||||
color brightyellow "debug\.\<(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue|setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)\>"
|
||||
|
||||
# File handle methods
|
||||
color brightyellow "\:\<(close|flush|lines|read|seek|setvbuf|write)\>"
|
||||
|
||||
# false, nil, true
|
||||
color brightmagenta "\<(false|nil|true)\>"
|
||||
|
||||
# External files
|
||||
color brightgreen "\<(dofile|require)\>"
|
||||
|
||||
# Numbers
|
||||
color red "\<([0-9]+)\>"
|
||||
|
||||
# Symbols
|
||||
color brightmagenta "(\(|\)|\[|\]|\{|\})"
|
||||
|
||||
|
||||
# Shebang
|
||||
color brightcyan "^#!.*"
|
||||
|
||||
# Simple comments
|
||||
color green "\-\-.*$"
|
||||
|
||||
# Multiline comments
|
||||
color green start="\-\-\[\[" end="\]\]"
|
||||
|
||||
# Strings
|
||||
#color green "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'"
|
||||
|
||||
# Strings
|
||||
color red "\"(\\.|[^\\\"])*\"|'(\\.|[^\\'])*'"
|
||||
|
||||
# color red start="\[\[" end="\]\]"
|
||||
|
||||
|
||||
# Hex literals
|
||||
color red "0x[0-9a-fA-F]*"
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for manpages.
|
||||
##
|
||||
syntax "man" "\.[1-9]x?$"
|
||||
magic "troff or preprocessor input text"
|
||||
color green "\.(S|T)H.*$"
|
||||
color brightgreen "\.(S|T)H" "\.TP"
|
||||
color brightred "\.(BR?|I[PR]?).*$"
|
||||
|
||||
8
doc/syntax/mgp.nanorc
Normal file
8
doc/syntax/mgp.nanorc
Normal file
@@ -0,0 +1,8 @@
|
||||
## Here is an example for Magicpoint presentations
|
||||
##
|
||||
syntax "mgp" "\.mgp$"
|
||||
header "^%include.*"
|
||||
icolor green "^%[a-z].*$"
|
||||
color cyan "(^|[[:space:]])#.*$"
|
||||
color cyan "(^|[[:space:]])%%.*$"
|
||||
color ,green "[[:space:]]+$"
|
||||
@@ -4,8 +4,8 @@ syntax "nanorc" "\.?nanorc$"
|
||||
## Possible errors and parameters
|
||||
icolor brightwhite "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
|
||||
## Keywords
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|speller|suspend|suspendenable|tabsize|tabstospaces|tempfile|undo|view|whitespace|wordbounds)\>"
|
||||
icolor green "^[[:space:]]*(set|unset|include|syntax|header)\>"
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|poslog|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|speller|suspend|suspendenable|tabsize|tabstospaces|tempfile|undo|view|whitespace|wordbounds|locking)\>"
|
||||
icolor green "^[[:space:]]*(set|unset|include|syntax|header|magic)\>"
|
||||
## Colors
|
||||
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for patch files.
|
||||
##
|
||||
syntax "patch" "\.(patch|diff)$"
|
||||
magic "diff output text"
|
||||
color brightgreen "^\+.*"
|
||||
color green "^\+\+\+.*"
|
||||
color brightblue "^ .*"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for Perl.
|
||||
##
|
||||
syntax "perl" "\.p[lm]$"
|
||||
magic "perl.*script text"
|
||||
header "^#!.*/perl[-0-9._]*"
|
||||
color red "\<(accept|alarm|atan2|bin(d|mode)|c(aller|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))\>" "\<(get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)\>" "\<(keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek(dir)?)\>" "\<(se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr(y)?|truncate|umask)\>" "\<(un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\>"
|
||||
color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne|lt|gt|le|ge|cmp|x|my|sub|use|package|can|isa)\>"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for PHP
|
||||
##
|
||||
syntax "php" "\.php[2345s~]?$"
|
||||
magic "PHP script text"
|
||||
|
||||
## php markings
|
||||
color brightgreen "(<\?(php)?|\?>)"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for Bourne shell scripts.
|
||||
##
|
||||
syntax "sh" "\.sh$"
|
||||
magic "(POSIX|Bourne.*) shell script text"
|
||||
header "^#!.*/(ba|k|pdk)?sh[-0-9_]*"
|
||||
icolor brightgreen "^[0-9A-Z_]+\(\)"
|
||||
color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\>"
|
||||
|
||||
38
doc/syntax/spec.nanorc
Normal file
38
doc/syntax/spec.nanorc
Normal file
@@ -0,0 +1,38 @@
|
||||
# RPM spec files syntax highlighting
|
||||
# Parts taken from kate (KDE) syntax highlighting
|
||||
# Asterios Dramis
|
||||
syntax "spec" "\.(spec$|spec\.*)"
|
||||
# Main tags
|
||||
color brightblue "((Icon|ExclusiveOs|ExcludeOs)[[:space:]]*:)"
|
||||
color brightblue "((BuildArch|BuildArchitectures|ExclusiveArch|ExcludeArch)[[:space:]]*:)"
|
||||
color brightblue "((Conflicts|Obsoletes|Provides|Requires|Requires\(.*\)|Enhances|Suggests|BuildConflicts|BuildRequires|Recommends|PreReq|Supplements)[[:space:]]*:)"
|
||||
color brightblue "((Epoch|Serial|Nosource|Nopatch)[[:space:]]*:)"
|
||||
color brightblue "((AutoReq|AutoProv|AutoReqProv)[[:space:]]*:)"
|
||||
color brightblue "((Copyright|License|Summary|Summary\(.*\)|Distribution|Vendor|Packager|Group|Source\d*|Patch\d*|BuildRoot|Prefix)[[:space:]]*:)"
|
||||
color brightblue "((Name|Version|Release|Url|URL)[[:space:]]*:)"
|
||||
color brightblue start="^Source" end=":" start="^Patch" end=":"
|
||||
# Architectures
|
||||
color brightred "(i386|i486|i586|i686|athlon|ia64|alpha|alphaev5|alphaev56|alphapca56|alphaev6|alphaev67|sparc|sparcv9|sparc64armv3l|armv4b|armv4lm|ips|mipsel|ppc|ppc|iseries|ppcpseries|ppc64|m68k|m68kmint|Sgi|rs6000|i370|s390x|s390|noarch)"
|
||||
# Architectures conditionals
|
||||
color brightred "(ifarch|ifnarch)"
|
||||
# OS conditionals
|
||||
color brightred "(ifos|ifnos)"
|
||||
# %* strings
|
||||
color green "%([A-Z_a-z_0-9_]*)"
|
||||
color magenta "%_([A-Z_a-z_0-9_]*)"
|
||||
color yellow start="%__" end="\ "
|
||||
color magenta start="%\{" end="\}"
|
||||
color yellow start="%\{__" end="\}"
|
||||
# Sections
|
||||
color red "^%(build$|changelog|check$|clean$|description|files|install$|package|pre|prep$|preun|post|postun)"
|
||||
color red "^%(trigger|triggerin|triggerpostun|triggerun|verifyscript)"
|
||||
# Conditionals and Defines
|
||||
color brightred "%(if|else|endif|define|global|undefine)"
|
||||
# Comments
|
||||
color cyan "#.*$"
|
||||
# "# norootforbuild" is handled as main tag
|
||||
color brightblue "^# norootforbuild"
|
||||
# %changelog date entries
|
||||
color brightyellow "^\* .*\)$"
|
||||
# Trailing whitespace
|
||||
color ,green "[[:space:]]+$"
|
||||
@@ -3,4 +3,4 @@
|
||||
syntax "tex" "\.tex$"
|
||||
icolor green "\\.|\\[A-Z]*"
|
||||
color magenta "[{}]"
|
||||
color blue "%.*"
|
||||
color blue "(^|[^\])%.*"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## Here is an example for xml files.
|
||||
##
|
||||
syntax "xml" "\.([jrs]html?|sgml?|xml|xslt?)$"
|
||||
magic "XML.*document text"
|
||||
color green start="<" end=">"
|
||||
color cyan "<[^> ]+"
|
||||
color cyan ">"
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# List of available languages.
|
||||
bg ca cs da de es eu fi fr ga gl hu id it ms nb nl nn pl pt_BR ro ru rw sr sv tr uk vi zh_CN zh_TW
|
||||
bg ca cs da de eo es eu fi fr ga gl hu id it ja ms nb nl nn pl pt_BR ro ru rw sl sr sv tr uk vi zh_CN zh_TW
|
||||
|
||||
900
po/nano.pot
900
po/nano.pot
File diff suppressed because it is too large
Load Diff
876
po/pt_BR.po
876
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
21
po/update_linguas.sh
Executable file
21
po/update_linguas.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
echo "Updating translations via TP" && \
|
||||
rsync -Lrtvz translationproject.org::tp/latest/nano/ .
|
||||
#
|
||||
NEWSTUFF=`svn status | grep "^\? .*.po$" | awk '{ print $NF }'`
|
||||
if [ "x$NEWSTUFF" != "x" ]; then
|
||||
echo "Adding new languaes to SVN"
|
||||
svn add $NEWSTUFF
|
||||
fi
|
||||
#
|
||||
echo "Updating LINGUAS for all translations"
|
||||
FILE=LINGUAS
|
||||
echo "# List of available languages." >$FILE
|
||||
/bin/ls *.po | tr '\n' ' ' | sed 's/\.po//g' >>$FILE
|
||||
echo >> $FILE
|
||||
#
|
||||
if [ "x$NEWSTUFF" != "x" ]; then
|
||||
echo -n "New langs found, re-running configure and make at top level (silently)..."
|
||||
(cd .. && ./configure && make) >/dev/null
|
||||
echo "done"
|
||||
fi
|
||||
833
po/zh_CN.po
833
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
848
po/zh_TW.po
848
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -156,7 +156,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
* time, put back the Enter key so that it's
|
||||
* read in. */
|
||||
if (old_selected == selected)
|
||||
unget_kbinput(sc_seq_or(DO_ENTER, 0), FALSE, FALSE);
|
||||
unget_kbinput(sc_seq_or(do_enter_void, 0), FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
#endif /* !DISABLE_MOUSE */
|
||||
@@ -169,9 +169,9 @@ char *do_browser(char *path, DIR *dir)
|
||||
if (!f)
|
||||
break;
|
||||
|
||||
if (f->scfunc == TOTAL_REFRESH) {
|
||||
if (f->scfunc == total_refresh) {
|
||||
total_redraw();
|
||||
} else if (f->scfunc == DO_HELP_VOID) {
|
||||
} else if (f->scfunc == do_help_void) {
|
||||
#ifndef DISABLE_HELP
|
||||
do_browser_help();
|
||||
curs_set(0);
|
||||
@@ -179,33 +179,33 @@ char *do_browser(char *path, DIR *dir)
|
||||
nano_disabled_msg();
|
||||
#endif
|
||||
/* Search for a filename. */
|
||||
} else if (f->scfunc == DO_SEARCH) {
|
||||
} else if (f->scfunc == do_search) {
|
||||
curs_set(1);
|
||||
do_filesearch();
|
||||
curs_set(0);
|
||||
/* Search for another filename. */
|
||||
} else if (f->scfunc == DO_RESEARCH) {
|
||||
} else if (f->scfunc == do_research) {
|
||||
do_fileresearch();
|
||||
} else if (f->scfunc == DO_PAGE_UP) {
|
||||
} else if (f->scfunc == do_page_up) {
|
||||
if (selected >= (editwinrows + fileline % editwinrows) *
|
||||
width)
|
||||
selected -= (editwinrows + fileline % editwinrows) *
|
||||
width;
|
||||
else
|
||||
selected = 0;
|
||||
} else if (f->scfunc == DO_PAGE_DOWN) {
|
||||
} else if (f->scfunc == do_page_down) {
|
||||
selected += (editwinrows - fileline % editwinrows) *
|
||||
width;
|
||||
if (selected > filelist_len - 1)
|
||||
selected = filelist_len - 1;
|
||||
} else if (f->scfunc == FIRST_FILE_MSG) {
|
||||
} else if (f->scfunc == do_first_file) {
|
||||
if (meta_key)
|
||||
selected = 0;
|
||||
} else if (f->scfunc == LAST_FILE_MSG) {
|
||||
} else if (f->scfunc == do_last_file) {
|
||||
if (meta_key)
|
||||
selected = filelist_len - 1;
|
||||
/* Go to a specific directory. */
|
||||
} else if (f->scfunc == GOTO_DIR_MSG) {
|
||||
} else if (f->scfunc == goto_dir_void) {
|
||||
curs_set(1);
|
||||
|
||||
i = do_prompt(TRUE,
|
||||
@@ -238,7 +238,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
* answer in ans, so that the file list is displayed
|
||||
* again, the prompt is displayed again, and what we
|
||||
* typed before at the prompt is displayed again. */
|
||||
unget_kbinput(sc_seq_or(DO_GOTOLINECOLUMN_VOID, 0), FALSE, FALSE);
|
||||
unget_kbinput(sc_seq_or(do_gotolinecolumn_void, 0), FALSE, FALSE);
|
||||
ans = mallocstrcpy(ans, answer);
|
||||
continue;
|
||||
}
|
||||
@@ -285,19 +285,19 @@ char *do_browser(char *path, DIR *dir)
|
||||
free(path);
|
||||
path = new_path;
|
||||
goto change_browser_directory;
|
||||
} else if (f->scfunc == DO_UP_VOID) {
|
||||
} else if (f->scfunc == do_up_void) {
|
||||
if (selected >= width)
|
||||
selected -= width;
|
||||
} else if (f->scfunc == DO_LEFT) {
|
||||
} else if (f->scfunc == do_left) {
|
||||
if (selected > 0)
|
||||
selected--;
|
||||
} else if (f->scfunc == DO_DOWN_VOID) {
|
||||
} else if (f->scfunc == do_down_void) {
|
||||
if (selected + width <= filelist_len - 1)
|
||||
selected += width;
|
||||
} else if (f->scfunc == DO_RIGHT) {
|
||||
} else if (f->scfunc == do_right) {
|
||||
if (selected < filelist_len - 1)
|
||||
selected++;
|
||||
} else if (f->scfunc == DO_ENTER) {
|
||||
} else if (f->scfunc == do_enter_void) {
|
||||
/* We can't move up from "/". */
|
||||
if (strcmp(filelist[selected], "/..") == 0) {
|
||||
statusbar(_("Can't move up a directory"));
|
||||
@@ -355,7 +355,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
/* Start over again with the new path value. */
|
||||
goto change_browser_directory;
|
||||
/* Abort the file browser. */
|
||||
} else if (f->scfunc == DO_EXIT) {
|
||||
} else if (f->scfunc == do_exit) {
|
||||
abort = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -552,32 +552,32 @@ void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key)
|
||||
if (!*meta_key) {
|
||||
switch (*kbinput) {
|
||||
case ' ':
|
||||
*kbinput = sc_seq_or(DO_PAGE_DOWN, 0);
|
||||
*kbinput = sc_seq_or(do_page_down, 0);
|
||||
break;
|
||||
case '-':
|
||||
*kbinput = sc_seq_or(DO_PAGE_UP, 0);
|
||||
*kbinput = sc_seq_or(do_page_up, 0);
|
||||
break;
|
||||
case '?':
|
||||
#ifndef DISABLE_HELP
|
||||
*kbinput = sc_seq_or(DO_HELP_VOID, 0);
|
||||
*kbinput = sc_seq_or(do_help_void, 0);
|
||||
#endif
|
||||
break;
|
||||
/* Cancel equivalent to Exit here. */
|
||||
case 'E':
|
||||
case 'e':
|
||||
*kbinput = sc_seq_or(DO_EXIT, 0);
|
||||
*kbinput = sc_seq_or(do_exit, 0);
|
||||
break;
|
||||
case 'G':
|
||||
case 'g':
|
||||
*kbinput = sc_seq_or(GOTO_DIR_MSG, 0);
|
||||
*kbinput = sc_seq_or(goto_dir_void, 0);
|
||||
break;
|
||||
case 'S':
|
||||
case 's':
|
||||
*kbinput = sc_seq_or(DO_ENTER, 0);
|
||||
*kbinput = sc_seq_or(do_enter_void, 0);
|
||||
break;
|
||||
case 'W':
|
||||
case 'w':
|
||||
*kbinput = sc_seq_or(DO_SEARCH, 0);
|
||||
*kbinput = sc_seq_or(do_search, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -794,7 +794,7 @@ int filesearch_init(void)
|
||||
TRUE,
|
||||
#endif
|
||||
MWHEREISFILE, backupstring,
|
||||
&meta_key, &func_key,
|
||||
&meta_key, &func_key,
|
||||
#ifndef NANO_TINY
|
||||
&search_history,
|
||||
#endif
|
||||
@@ -841,18 +841,18 @@ int filesearch_init(void)
|
||||
#endif
|
||||
} else
|
||||
#ifndef NANO_TINY
|
||||
if (s && s->scfunc == CASE_SENS_MSG) {
|
||||
if (s && s->scfunc == case_sens_void) {
|
||||
TOGGLE(CASE_SENSITIVE);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
} else if (s && s->scfunc == BACKWARDS_MSG) {
|
||||
} else if (s && s->scfunc == backwards_void) {
|
||||
TOGGLE(BACKWARDS_SEARCH);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
} else
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (s && s->scfunc == REGEXP_MSG) {
|
||||
if (s && s->scfunc == regexp_void) {
|
||||
TOGGLE(USE_REGEXP);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
|
||||
10
src/chars.c
10
src/chars.c
@@ -79,12 +79,12 @@ bool is_byte(int c)
|
||||
return ((unsigned int)c == (unsigned char)c);
|
||||
}
|
||||
|
||||
static void mbtowc_reset(void)
|
||||
void mbtowc_reset(void)
|
||||
{
|
||||
IGNORE_CALL_RESULT(mbtowc(NULL, NULL, 0));
|
||||
}
|
||||
|
||||
static void wctomb_reset(void)
|
||||
void wctomb_reset(void)
|
||||
{
|
||||
IGNORE_CALL_RESULT(wctomb(NULL, 0));
|
||||
}
|
||||
@@ -630,7 +630,7 @@ char *mbstrcasestr(const char *haystack, const char *needle)
|
||||
return NULL;
|
||||
} else
|
||||
#endif
|
||||
return strcasestr(haystack, needle);
|
||||
return (char *) strcasestr(haystack, needle);
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) || !defined(DISABLE_TABCOMP)
|
||||
@@ -820,7 +820,7 @@ char *mbstrchr(const char *s, const char *c)
|
||||
return (char *)q;
|
||||
} else
|
||||
#endif
|
||||
return strchr(s, *c);
|
||||
return (char *) strchr(s, *c);
|
||||
}
|
||||
#endif /* !NANO_TINY || !DISABLE_JUSTIFY */
|
||||
|
||||
@@ -840,7 +840,7 @@ char *mbstrpbrk(const char *s, const char *accept)
|
||||
return NULL;
|
||||
} else
|
||||
#endif
|
||||
return strpbrk(s, accept);
|
||||
return (char *) strpbrk(s, accept);
|
||||
}
|
||||
|
||||
/* This function is equivalent to strpbrk(), except in that it scans the
|
||||
|
||||
103
src/color.c
103
src/color.c
@@ -25,6 +25,11 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_MAGIC_H
|
||||
#include <magic.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
|
||||
@@ -102,12 +107,33 @@ void color_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Cleanup a regex we previously compiled */
|
||||
void nfreeregex(regex_t **r)
|
||||
{
|
||||
assert(r != NULL);
|
||||
|
||||
regfree(*r);
|
||||
free(*r);
|
||||
*r = NULL;
|
||||
}
|
||||
|
||||
/* Update the color information based on the current filename. */
|
||||
void color_update(void)
|
||||
{
|
||||
syntaxtype *tmpsyntax;
|
||||
syntaxtype *defsyntax = NULL;
|
||||
colortype *tmpcolor, *defcolor = NULL;
|
||||
exttype *e;
|
||||
|
||||
/* libmagic structures */
|
||||
/* magicstring will be NULL if we fail to get magic result */
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
const char *magicstring = NULL;
|
||||
const char *magicerr = NULL;
|
||||
magic_t m;
|
||||
struct stat fileinfo;
|
||||
#endif /* HAVE_LIBMAGIC */
|
||||
|
||||
|
||||
assert(openfile != NULL);
|
||||
|
||||
@@ -133,13 +159,35 @@ void color_update(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
|
||||
if (strcmp(openfile->filename,"") && stat(openfile->filename, &fileinfo) == 0) {
|
||||
m = magic_open(MAGIC_SYMLINK |
|
||||
#ifdef DEBUG
|
||||
MAGIC_DEBUG | MAGIC_CHECK |
|
||||
#endif /* DEBUG */
|
||||
MAGIC_ERROR);
|
||||
if (m == NULL || magic_load(m, NULL) < 0)
|
||||
fprintf(stderr, "something went wrong: %s [%s]\n", strerror(errno), openfile->filename);
|
||||
else {
|
||||
magicstring = magic_file(m,openfile->filename);
|
||||
if (magicstring == NULL) {
|
||||
magicerr = magic_error(m);
|
||||
fprintf(stderr, "something went wrong: %s [%s]\n", magicerr, openfile->filename);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "magic string returned: %s\n", magicstring);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_LIBMAGIC */
|
||||
|
||||
/* If we didn't specify a syntax override string, or if we did and
|
||||
* there was no syntax by that name, get the syntax based on the
|
||||
* file extension, and then look in the header. */
|
||||
if (openfile->colorstrings == NULL) {
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
exttype *e;
|
||||
|
||||
/* If this is the default syntax, it has no associated
|
||||
* extensions, which we've checked for elsewhere. Skip over
|
||||
@@ -163,24 +211,51 @@ void color_update(void)
|
||||
|
||||
/* Set colorstrings if we matched the extension
|
||||
* regex. */
|
||||
if (regexec(e->ext, openfile->filename, 0, NULL,
|
||||
0) == 0) {
|
||||
if (regexec(e->ext, openfile->filename, 0, NULL, 0) == 0) {
|
||||
openfile->syntax = tmpsyntax;
|
||||
openfile->colorstrings = tmpsyntax->color;
|
||||
}
|
||||
|
||||
if (openfile->colorstrings != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Decompile e->ext_regex's specified regex if we aren't
|
||||
* going to use it. */
|
||||
if (not_compiled) {
|
||||
regfree(e->ext);
|
||||
free(e->ext);
|
||||
e->ext = NULL;
|
||||
if (not_compiled)
|
||||
nfreeregex(&e->ext);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check magic if we don't yet have an answer */
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
if (openfile->colorstrings == NULL) {
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "No match using extension, trying libmagic...\n");
|
||||
#endif /* DEBUG */
|
||||
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
for (e = tmpsyntax->magics; e != NULL; e = e->next) {
|
||||
bool not_compiled = (e->ext == NULL);
|
||||
if (not_compiled) {
|
||||
e->ext = (regex_t *)nmalloc(sizeof(regex_t));
|
||||
regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"Matching regex \"%s\" against \"%s\"\n",e->ext_regex, magicstring);
|
||||
#endif /* DEBUG */
|
||||
|
||||
if (magicstring && regexec(e->ext, magicstring, 0, NULL, 0) == 0) {
|
||||
openfile->syntax = tmpsyntax;
|
||||
openfile->colorstrings = tmpsyntax->color;
|
||||
break;
|
||||
}
|
||||
|
||||
if (not_compiled)
|
||||
nfreeregex(&e->ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_LIBMAGIC */
|
||||
|
||||
/* If we haven't matched anything yet, try the headers */
|
||||
if (openfile->colorstrings == NULL) {
|
||||
@@ -189,7 +264,6 @@ void color_update(void)
|
||||
#endif
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
exttype *e;
|
||||
|
||||
for (e = tmpsyntax->headers; e != NULL; e = e->next) {
|
||||
bool not_compiled = (e->ext == NULL);
|
||||
@@ -217,11 +291,8 @@ void color_update(void)
|
||||
|
||||
/* Decompile e->ext_regex's specified regex if we aren't
|
||||
* going to use it. */
|
||||
if (not_compiled) {
|
||||
regfree(e->ext);
|
||||
free(e->ext);
|
||||
e->ext = NULL;
|
||||
}
|
||||
if (not_compiled)
|
||||
nfreeregex(&e->ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
588
src/files.c
588
src/files.c
@@ -31,6 +31,7 @@
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <pwd.h>
|
||||
#include <libgen.h>
|
||||
|
||||
/* Add an entry to the openfile openfilestruct. This should only be
|
||||
* called from open_buffer(). */
|
||||
@@ -77,6 +78,7 @@ void initialize_buffer(void)
|
||||
openfile->current_stat = NULL;
|
||||
openfile->undotop = NULL;
|
||||
openfile->current_undo = NULL;
|
||||
openfile->lock_filename = NULL;
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
openfile->colorstrings = NULL;
|
||||
@@ -103,6 +105,207 @@ void initialize_buffer_text(void)
|
||||
openfile->totsize = 0;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Actyally write the lock file. This function will
|
||||
ALWAYS annihilate any previous version of the file.
|
||||
We'll borrow INSECURE_BACKUP here to decide about lock file
|
||||
paranoia here as well...
|
||||
Args:
|
||||
lockfilename: file name for lock
|
||||
origfilename: name of the file the lock is for
|
||||
modified: whether to set the modified bit in the file
|
||||
|
||||
Returns: 1 on success, 0 on failure (but continue loading), -1 on failure and abort
|
||||
*/
|
||||
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified)
|
||||
{
|
||||
int cflags, fd;
|
||||
FILE *filestream;
|
||||
pid_t mypid;
|
||||
uid_t myuid;
|
||||
struct passwd *mypwuid;
|
||||
char *lockdata = charalloc(1024);
|
||||
char myhostname[32];
|
||||
ssize_t lockdatalen = 1024;
|
||||
ssize_t wroteamt;
|
||||
|
||||
/* Run things which might fail first before we try and blow away
|
||||
the old state */
|
||||
myuid = geteuid();
|
||||
if ((mypwuid = getpwuid(myuid)) == NULL) {
|
||||
statusbar(_("Couldn't determine my identity for lock file (getpwuid() failed)"));
|
||||
return -1;
|
||||
}
|
||||
mypid = getpid();
|
||||
|
||||
if (gethostname(myhostname, 31) < 0) {
|
||||
statusbar(_("Couldn't determine hosttname for lock file: %s"), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (delete_lockfile(lockfilename) < 0)
|
||||
return -1;
|
||||
|
||||
if (ISSET(INSECURE_BACKUP))
|
||||
cflags = O_WRONLY | O_CREAT | O_APPEND;
|
||||
else
|
||||
cflags = O_WRONLY | O_CREAT | O_EXCL | O_APPEND;
|
||||
|
||||
fd = open(lockfilename, cflags,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
|
||||
/* Maybe we just don't have write access, don't stop us from
|
||||
opening the file at all, just don't set the lock_filename
|
||||
and return success */
|
||||
if (fd < 0 && errno == EACCES)
|
||||
return 1;
|
||||
|
||||
/* Now we've got a safe file stream. If the previous open()
|
||||
call failed, this will return NULL. */
|
||||
filestream = fdopen(fd, "wb");
|
||||
|
||||
if (fd < 0 || filestream == NULL) {
|
||||
statusbar(_("Error writing lock file %s: %s"), lockfilename,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Okay. so at the moment we're following this state for how
|
||||
to store the lock data:
|
||||
byte 0 - 0x62
|
||||
byte 1 - 0x30
|
||||
bytes 2-12 - program name which created the lock
|
||||
bytes 24,25 - little endian store of creator program's PID
|
||||
(b24 = 256^0 column, b25 = 256^1 column)
|
||||
bytes 28-44 - username of who created the lock
|
||||
bytes 68-100 - hostname of where the lock was created
|
||||
bytes 108-876 - filename the lock is for
|
||||
byte 1007 - 0x55 if file is modified
|
||||
|
||||
Looks like VIM also stores undo state in this file so we're
|
||||
gonna have to figure out how to slap a 'OMG don't use recover
|
||||
on our lockfile' message in here...
|
||||
|
||||
This is likely very wrong, so this is a WIP
|
||||
*/
|
||||
null_at(&lockdata, lockdatalen);
|
||||
lockdata[0] = 0x62;
|
||||
lockdata[1] = 0x30;
|
||||
lockdata[24] = mypid % 256;
|
||||
lockdata[25] = mypid / 256;
|
||||
snprintf(&lockdata[2], 10, "nano %s", VERSION);
|
||||
strncpy(&lockdata[28], mypwuid->pw_name, 16);
|
||||
strncpy(&lockdata[68], myhostname, 31);
|
||||
strncpy(&lockdata[108], origfilename, 768);
|
||||
if (modified == TRUE)
|
||||
lockdata[1007] = 0x55;
|
||||
|
||||
wroteamt = fwrite(lockdata, sizeof(char), lockdatalen, filestream);
|
||||
if (wroteamt < lockdatalen) {
|
||||
statusbar(_("Error writing lock file %s: %s"),
|
||||
lockfilename, ferror(filestream));
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "In write_lockfile(), write successful (wrote %d bytes)\n", wroteamt);
|
||||
#endif /* DEBUG */
|
||||
|
||||
if (fclose(filestream) == EOF) {
|
||||
statusbar(_("Error writing lock file %s: %s"),
|
||||
lockfilename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
openfile->lock_filename = lockfilename;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Less exciting, delete the lock file.
|
||||
Return -1 if successful and complain on the statusbar, 1 otherwite
|
||||
*/
|
||||
int delete_lockfile(const char *lockfilename)
|
||||
{
|
||||
if (unlink(lockfilename) < 0 && errno != ENOENT) {
|
||||
statusbar(_("Error deleting lock file %s: %s"), lockfilename,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Deal with lockfiles. Return -1 on refusing to override
|
||||
the lock file, and 1 on successfully created the lockfile, 0 means
|
||||
we were not successful on creating the lockfile but we should
|
||||
continue to load the file and complain to the user.
|
||||
*/
|
||||
int do_lockfile(const char *filename)
|
||||
{
|
||||
char *lockdir = dirname((char *) mallocstrcpy(NULL, filename));
|
||||
char *lockbase = basename((char *) mallocstrcpy(NULL, filename));
|
||||
ssize_t lockfilesize = (sizeof (char *) * (strlen(filename)
|
||||
+ strlen(locking_prefix) + strlen(locking_suffix) + 3));
|
||||
char *lockfilename = (char *) nmalloc(lockfilesize);
|
||||
char lockprog[12], lockuser[16];
|
||||
struct stat fileinfo;
|
||||
int lockfd, lockpid;
|
||||
|
||||
|
||||
snprintf(lockfilename, lockfilesize, "%s/%s%s%s", lockdir,
|
||||
locking_prefix, lockbase, locking_suffix);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "lock file name is %s\n", lockfilename);
|
||||
#endif /* DEBUG */
|
||||
if (stat(lockfilename, &fileinfo) != -1) {
|
||||
ssize_t readtot = 0;
|
||||
ssize_t readamt = 0;
|
||||
char *lockbuf = (char *) nmalloc(8192);
|
||||
char *promptstr = (char *) nmalloc(128);
|
||||
int ans;
|
||||
if ((lockfd = open(lockfilename, O_RDONLY)) < 0) {
|
||||
statusbar(_("Error opening lockfile %s: %s"),
|
||||
lockfilename, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
do {
|
||||
readamt = read(lockfd, &lockbuf[readtot], BUFSIZ);
|
||||
readtot += readamt;
|
||||
} while (readtot < 8192 && readamt > 0);
|
||||
|
||||
if (readtot < 48) {
|
||||
statusbar(_("Error reading lockfile %s: Not enough data read"),
|
||||
lockfilename);
|
||||
return -1;
|
||||
}
|
||||
strncpy(lockprog, &lockbuf[2], 10);
|
||||
lockpid = lockbuf[25] * 256 + lockbuf[24];
|
||||
strncpy(lockuser, &lockbuf[28], 16);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "lockpid = %d\n", lockpid);
|
||||
fprintf(stderr, "program name which created this lock file should be %s\n",
|
||||
lockprog);
|
||||
fprintf(stderr, "user which created this lock file should be %s\n",
|
||||
lockuser);
|
||||
#endif /* DEBUG */
|
||||
sprintf(promptstr, "File being edited (by %s, PID %d, user %s), continue?",
|
||||
lockprog, lockpid, lockuser);
|
||||
ans = do_yesno_prompt(FALSE, promptstr);
|
||||
if (ans < 1) {
|
||||
blank_statusbar();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return write_lockfile(lockfilename, filename, FALSE);
|
||||
}
|
||||
#endif /* NANO_TINY */
|
||||
|
||||
|
||||
/* If it's not "", filename is a file to open. We make a new buffer, if
|
||||
* necessary, and then open and read the file, if applicable. */
|
||||
void open_buffer(const char *filename, bool undoable)
|
||||
@@ -128,16 +331,16 @@ void open_buffer(const char *filename, bool undoable)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the filename isn't blank, open the file. Otherwise, treat it
|
||||
* as a new file. */
|
||||
rc = (filename[0] != '\0') ? open_file(filename, new_buffer, &f) :
|
||||
-2;
|
||||
|
||||
/* If we're loading into a new buffer, add a new entry to
|
||||
* openfile. */
|
||||
if (new_buffer)
|
||||
make_new_buffer();
|
||||
|
||||
/* If the filename isn't blank, open the file. Otherwise, treat it
|
||||
* as a new file. */
|
||||
rc = (filename[0] != '\0') ? open_file(filename, new_buffer, &f) :
|
||||
-2;
|
||||
|
||||
/* If we have a file, and we're loading into a new buffer, update
|
||||
* the filename. */
|
||||
if (rc != -1 && new_buffer)
|
||||
@@ -279,6 +482,10 @@ bool close_buffer(void)
|
||||
if (openfile == openfile->next)
|
||||
return FALSE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs()+1);
|
||||
#endif /* NANO_TINY */
|
||||
|
||||
/* Switch to the next file buffer. */
|
||||
switch_to_next_buffer_void();
|
||||
|
||||
@@ -674,7 +881,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
||||
* found".
|
||||
*
|
||||
* Return -2 if we say "New File", -1 if the file isn't opened, and the
|
||||
* fd opened otherwise. The file might still have an error while reading
|
||||
* fd opened otherwise. The file might still have an error while reading
|
||||
* with a 0 return value. *f is set to the opened file. */
|
||||
int open_file(const char *filename, bool newfie, FILE **f)
|
||||
{
|
||||
@@ -689,10 +896,17 @@ int open_file(const char *filename, bool newfie, FILE **f)
|
||||
|
||||
/* Okay, if we can't stat the path due to a component's
|
||||
permissions, just try the relative one */
|
||||
if (full_filename == NULL
|
||||
if (full_filename == NULL
|
||||
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
|
||||
full_filename = mallocstrcpy(NULL, filename);
|
||||
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING))
|
||||
if (do_lockfile(full_filename) < 0)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
if (stat(full_filename, &fileinfo) == -1) {
|
||||
/* Well, maybe we can open the file even if the OS
|
||||
says its not there */
|
||||
@@ -869,14 +1083,14 @@ void do_insertfile(
|
||||
#ifndef NANO_TINY
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
|
||||
if (s && s->scfunc == NEW_BUFFER_MSG) {
|
||||
if (s && s->scfunc == new_buffer_void) {
|
||||
/* Don't allow toggling if we're in view mode. */
|
||||
if (!ISSET(VIEW_MODE))
|
||||
TOGGLE(MULTIBUFFER);
|
||||
continue;
|
||||
} else
|
||||
#endif
|
||||
if (s && s->scfunc == EXT_CMD_MSG) {
|
||||
if (s && s->scfunc == ext_cmd_void) {
|
||||
execute = !execute;
|
||||
continue;
|
||||
}
|
||||
@@ -886,7 +1100,7 @@ void do_insertfile(
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
if (s && s->scfunc == TO_FILES_MSG) {
|
||||
if (s && s->scfunc == to_files_void) {
|
||||
char *tmp = do_browse_from(answer);
|
||||
|
||||
if (tmp == NULL)
|
||||
@@ -1066,6 +1280,12 @@ void do_insertfile(
|
||||
* allow inserting a file into a new buffer. */
|
||||
void do_insertfile_void(void)
|
||||
{
|
||||
|
||||
if (ISSET(RESTRICTED)) {
|
||||
nano_disabled_msg();
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (ISSET(VIEW_MODE) && !ISSET(MULTIBUFFER))
|
||||
statusbar(_("Key invalid in non-multibuffer mode"));
|
||||
@@ -1360,6 +1580,23 @@ bool check_operating_dir(const char *currpath, bool allow_tabcomp)
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Although this sucks, it sucks less than having a single 'my system is messed up
|
||||
* and I'm blanket allowing insecure file writing operations.
|
||||
*/
|
||||
|
||||
int prompt_failed_backupwrite(const char *filename)
|
||||
{
|
||||
static int i;
|
||||
static char *prevfile = NULL; /* What was the laast file we were paased so we don't keep asking this?
|
||||
though maybe we should.... */
|
||||
if (prevfile == NULL || strcmp(filename, prevfile)) {
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("Failed to write backup file, continue saving? (Say N if unsure) "));
|
||||
prevfile = mallocstrcpy(prevfile, filename);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void init_backup_dir(void)
|
||||
{
|
||||
char *full_backup_dir;
|
||||
@@ -1520,6 +1757,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
char *backupname;
|
||||
struct utimbuf filetime;
|
||||
int copy_status;
|
||||
int backup_cflags;
|
||||
|
||||
/* Save the original file's access and modification times. */
|
||||
filetime.actime = openfile->current_stat->st_atime;
|
||||
@@ -1592,14 +1830,21 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
/* First, unlink any existing backups. Next, open the backup
|
||||
file with O_CREAT and O_EXCL. If it succeeds, we
|
||||
have a file descriptor to a new backup file. */
|
||||
if (unlink(backupname) < 0 && errno != ENOENT) {
|
||||
if (unlink(backupname) < 0 && errno != ENOENT && !ISSET(INSECURE_BACKUP)) {
|
||||
if (prompt_failed_backupwrite(backupname))
|
||||
goto skip_backup;
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
free(backupname);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
backup_fd = open(backupname, O_WRONLY | O_CREAT | O_EXCL | O_APPEND,
|
||||
if (ISSET(INSECURE_BACKUP))
|
||||
backup_cflags = O_WRONLY | O_CREAT | O_APPEND;
|
||||
else
|
||||
backup_cflags = O_WRONLY | O_CREAT | O_EXCL | O_APPEND;
|
||||
|
||||
backup_fd = open(backupname, backup_cflags,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
/* Now we've got a safe file stream. If the previous open()
|
||||
call failed, this will return NULL. */
|
||||
@@ -1612,9 +1857,24 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1 ||
|
||||
fchown(backup_fd, openfile->current_stat->st_uid,
|
||||
openfile->current_stat->st_gid) == -1 ) {
|
||||
/* We shouldn't worry about chown()ing something if we're not
|
||||
root, since it's likely to fail! */
|
||||
if (geteuid() == NANO_ROOT_UID && fchown(backup_fd,
|
||||
openfile->current_stat->st_uid, openfile->current_stat->st_gid) == -1
|
||||
&& !ISSET(INSECURE_BACKUP)) {
|
||||
if (prompt_failed_backupwrite(backupname))
|
||||
goto skip_backup;
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
free(backupname);
|
||||
fclose(backup_file);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1
|
||||
&& !ISSET(INSECURE_BACKUP)) {
|
||||
if (prompt_failed_backupwrite(backupname))
|
||||
goto skip_backup;
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
free(backupname);
|
||||
@@ -1633,14 +1893,18 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
/* Copy the file. */
|
||||
copy_status = copy_file(f, backup_file);
|
||||
|
||||
/* And set its metadata. */
|
||||
if (copy_status != 0 || utime(backupname, &filetime) == -1) {
|
||||
if (copy_status == -1) {
|
||||
statusbar(_("Error reading %s: %s"), realname,
|
||||
if (copy_status != 0) {
|
||||
statusbar(_("Error reading %s: %s"), realname,
|
||||
strerror(errno));
|
||||
beep();
|
||||
} else
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
beep();
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
/* And set its metadata. */
|
||||
if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
|
||||
if (prompt_failed_backupwrite(backupname))
|
||||
goto skip_backup;
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
/* If we can't write to the backup, DONT go on, since
|
||||
whatever caused the backup file to fail (e.g. disk
|
||||
@@ -1936,6 +2200,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Write the current file to disk. If the mark is on, write the current
|
||||
@@ -2029,7 +2294,7 @@ bool do_writeout(bool exiting)
|
||||
s = get_shortcut(currmenu, &i, &meta_key, &func_key);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
if (s && s->scfunc == TO_FILES_MSG) {
|
||||
if (s && s->scfunc == to_files_void) {
|
||||
char *tmp = do_browse_from(answer);
|
||||
|
||||
if (tmp == NULL)
|
||||
@@ -2041,26 +2306,26 @@ bool do_writeout(bool exiting)
|
||||
} else
|
||||
#endif /* !DISABLE_BROWSER */
|
||||
#ifndef NANO_TINY
|
||||
if (s && s->scfunc == DOS_FORMAT_MSG) {
|
||||
if (s && s->scfunc == dos_format_void) {
|
||||
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE :
|
||||
DOS_FILE;
|
||||
continue;
|
||||
} else if (s && s->scfunc == MAC_FORMAT_MSG) {
|
||||
} else if (s && s->scfunc == mac_format_void) {
|
||||
openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE :
|
||||
MAC_FILE;
|
||||
continue;
|
||||
} else if (s && s->scfunc == BACKUP_FILE_MSG) {
|
||||
} else if (s && s->scfunc == backup_file_void) {
|
||||
TOGGLE(BACKUP_FILE);
|
||||
continue;
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
if (s && s->scfunc == PREPEND_MSG) {
|
||||
if (s && s->scfunc == prepend_void) {
|
||||
append = (append == PREPEND) ? OVERWRITE : PREPEND;
|
||||
continue;
|
||||
} else if (s && s->scfunc == APPEND_MSG) {
|
||||
} else if (s && s->scfunc == append_void) {
|
||||
append = (append == APPEND) ? OVERWRITE : APPEND;
|
||||
continue;
|
||||
} else if (s && s->scfunc == DO_HELP_VOID) {
|
||||
} else if (s && s->scfunc == do_help_void) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2348,9 +2613,6 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
|
||||
*num_matches, size_t buf_len)
|
||||
{
|
||||
char *dirname = mallocstrcpy(NULL, buf), *filename;
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
size_t dirnamelen;
|
||||
#endif
|
||||
size_t filenamelen;
|
||||
char **matches = NULL;
|
||||
DIR *dir;
|
||||
@@ -2389,9 +2651,6 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
dirnamelen = strlen(dirname);
|
||||
#endif
|
||||
filenamelen = strlen(filename);
|
||||
|
||||
while ((nextdir = readdir(dir)) != NULL) {
|
||||
@@ -2633,28 +2892,99 @@ const char *tail(const char *foo)
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
|
||||
/* Return $HOME/.nano_history, or NULL if we can't find the home
|
||||
/* Return the constructed dorfile path, or NULL if we can't find the home
|
||||
* directory. The string is dynamically allocated, and should be
|
||||
* freed. */
|
||||
char *histfilename(void)
|
||||
char *construct_filename(const char *str)
|
||||
{
|
||||
char *nanohist = NULL;
|
||||
char *newstr = NULL;
|
||||
|
||||
if (homedir != NULL) {
|
||||
size_t homelen = strlen(homedir);
|
||||
|
||||
nanohist = charalloc(homelen + 15);
|
||||
strcpy(nanohist, homedir);
|
||||
strcpy(nanohist + homelen, "/.nano_history");
|
||||
newstr = charalloc(homelen + strlen(str) + 1);
|
||||
strcpy(newstr, homedir);
|
||||
strcpy(newstr + homelen, str);
|
||||
}
|
||||
|
||||
return nanohist;
|
||||
return newstr;
|
||||
|
||||
}
|
||||
|
||||
char *histfilename(void)
|
||||
{
|
||||
return construct_filename("/.nano/search_history");
|
||||
}
|
||||
|
||||
/* Construct the legacy history filename
|
||||
* (Deprecate in 2.5, delete later
|
||||
*/
|
||||
char *legacyhistfilename(void)
|
||||
{
|
||||
return construct_filename("/.nano_history");
|
||||
}
|
||||
|
||||
char *poshistfilename(void)
|
||||
{
|
||||
return construct_filename("/.nano/filepos_history");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void history_error(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, msg);
|
||||
vfprintf(stderr, _(msg), ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(stderr, _("\nPress Enter to continue\n"));
|
||||
while (getchar() != '\n')
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
/* Now that we have more than one history file, let's just rely
|
||||
on a .nano dir for this stuff. Return 1 if the dir exists
|
||||
or was successfully created, and return 0 otherwise.
|
||||
*/
|
||||
int check_dotnano(void)
|
||||
{
|
||||
struct stat dirstat;
|
||||
char *nanodir = construct_filename("/.nano");
|
||||
|
||||
if (stat(nanodir, &dirstat) == -1) {
|
||||
if (mkdir(nanodir, S_IRWXU | S_IRWXG | S_IRWXO) == -1) {
|
||||
history_error(N_("Unable to create directory %s: %s\nIt is required for saving/loading search history or cursor position\n"),
|
||||
nanodir, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
} else if (!S_ISDIR(dirstat.st_mode)) {
|
||||
history_error(N_("Path %s is not a directory and needs to be.\nNano will be unable to load or save search or cursor position history\n"));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Load histories from ~/.nano_history. */
|
||||
void load_history(void)
|
||||
{
|
||||
char *nanohist = histfilename();
|
||||
char *legacyhist = legacyhistfilename();
|
||||
struct stat hstat;
|
||||
|
||||
|
||||
if (stat(legacyhist, &hstat) != -1 && stat(nanohist, &hstat) == -1) {
|
||||
if (rename(legacyhist, nanohist) == -1)
|
||||
history_error(N_("Detected a legacy nano history file (%s) which I tried to move\nto the preferred location (%s) but encountered an error: %s"),
|
||||
legacyhist, nanohist, strerror(errno));
|
||||
else
|
||||
history_error(N_("Detected a legacy nano history file (%s) which I moved\nto the preferred location (%s)\n(see the nano FAQ about this change)"),
|
||||
legacyhist, nanohist);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Assume do_rcfile() has reported a missing home directory. */
|
||||
if (nanohist != NULL) {
|
||||
@@ -2664,12 +2994,8 @@ void load_history(void)
|
||||
if (errno != ENOENT) {
|
||||
/* Don't save history when we quit. */
|
||||
UNSET(HISTORYLOG);
|
||||
rcfile_error(N_("Error reading %s: %s"), nanohist,
|
||||
history_error(N_("Error reading %s: %s"), nanohist,
|
||||
strerror(errno));
|
||||
fprintf(stderr,
|
||||
_("\nPress Enter to continue starting nano.\n"));
|
||||
while (getchar() != '\n')
|
||||
;
|
||||
}
|
||||
} else {
|
||||
/* Load a history list (first the search history, then the
|
||||
@@ -2694,8 +3020,11 @@ void load_history(void)
|
||||
|
||||
fclose(hist);
|
||||
free(line);
|
||||
if (search_history->prev != NULL)
|
||||
last_search = mallocstrcpy(NULL, search_history->prev->data);
|
||||
}
|
||||
free(nanohist);
|
||||
free(legacyhist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2721,7 +3050,7 @@ bool writehist(FILE *hist, filestruct *h)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Save histories to ~/.nano_history. */
|
||||
/* Save histories to ~/.nano/search_history. */
|
||||
void save_history(void)
|
||||
{
|
||||
char *nanohist;
|
||||
@@ -2737,7 +3066,7 @@ void save_history(void)
|
||||
FILE *hist = fopen(nanohist, "wb");
|
||||
|
||||
if (hist == NULL)
|
||||
rcfile_error(N_("Error writing %s: %s"), nanohist,
|
||||
history_error(N_("Error writing %s: %s"), nanohist,
|
||||
strerror(errno));
|
||||
else {
|
||||
/* Make sure no one else can read from or write to the
|
||||
@@ -2746,7 +3075,7 @@ void save_history(void)
|
||||
|
||||
if (!writehist(hist, searchage) || !writehist(hist,
|
||||
replaceage))
|
||||
rcfile_error(N_("Error writing %s: %s"), nanohist,
|
||||
history_error(N_("Error writing %s: %s"), nanohist,
|
||||
strerror(errno));
|
||||
|
||||
fclose(hist);
|
||||
@@ -2755,4 +3084,163 @@ void save_history(void)
|
||||
free(nanohist);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Analogs for the POS history */
|
||||
void save_poshistory(void)
|
||||
{
|
||||
char *poshist;
|
||||
char *statusstr = NULL;
|
||||
poshiststruct *posptr;
|
||||
|
||||
poshist = poshistfilename();
|
||||
|
||||
if (poshist != NULL) {
|
||||
FILE *hist = fopen(poshist, "wb");
|
||||
|
||||
if (hist == NULL)
|
||||
history_error(N_("Error writing %s: %s"), poshist,
|
||||
strerror(errno));
|
||||
else {
|
||||
/* Make sure no one else can read from or write to the
|
||||
* history file. */
|
||||
chmod(poshist, S_IRUSR | S_IWUSR);
|
||||
|
||||
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
|
||||
statusstr = charalloc(strlen(posptr->filename) + 2 * sizeof(ssize_t) + 4);
|
||||
sprintf(statusstr, "%s %d %d\n", posptr->filename, (int) posptr->lineno,
|
||||
(int) posptr->xno);
|
||||
if (fwrite(statusstr, sizeof(char), strlen(statusstr), hist) < strlen(statusstr))
|
||||
history_error(N_("Error writing %s: %s"), poshist,
|
||||
strerror(errno));
|
||||
free(statusstr);
|
||||
}
|
||||
fclose(hist);
|
||||
}
|
||||
free(poshist);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the POS history, given a filename line and column.
|
||||
* If no entry is found, add a new entry on the end
|
||||
*/
|
||||
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
|
||||
{
|
||||
poshiststruct *posptr, *posprev = NULL;
|
||||
char *fullpath = get_full_path(filename);
|
||||
|
||||
if (fullpath == NULL)
|
||||
return;
|
||||
|
||||
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
|
||||
if (!strcmp(posptr->filename, fullpath)) {
|
||||
posptr->lineno = lineno;
|
||||
posptr->xno = xpos;
|
||||
return;
|
||||
}
|
||||
posprev = posptr;
|
||||
}
|
||||
|
||||
/* Didn't find it, make a new node yo! */
|
||||
|
||||
posptr = (poshiststruct *) nmalloc(sizeof(poshiststruct));
|
||||
posptr->filename = mallocstrcpy(NULL, fullpath);
|
||||
posptr->lineno = lineno;
|
||||
posptr->xno = xpos;
|
||||
posptr->next = NULL;
|
||||
|
||||
if (!poshistory)
|
||||
poshistory = posptr;
|
||||
else
|
||||
posprev->next = posptr;
|
||||
|
||||
free(fullpath);
|
||||
}
|
||||
|
||||
|
||||
/* Check the POS history to see if file matches
|
||||
* an existing entry. If so return 1 and set line and column
|
||||
* to the right values Otherwise return 0
|
||||
*/
|
||||
int check_poshistory(const char *file, ssize_t *line, ssize_t *column)
|
||||
{
|
||||
poshiststruct *posptr;
|
||||
char *fullpath = get_full_path(file);
|
||||
|
||||
if (fullpath == NULL)
|
||||
return 0;
|
||||
|
||||
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
|
||||
if (!strcmp(posptr->filename, fullpath)) {
|
||||
*line = posptr->lineno;
|
||||
*column = posptr->xno;
|
||||
free(fullpath);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
free(fullpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Load histories from ~/.nano_history. */
|
||||
void load_poshistory(void)
|
||||
{
|
||||
char *nanohist = poshistfilename();
|
||||
|
||||
/* Assume do_rcfile() has reported a missing home directory. */
|
||||
if (nanohist != NULL) {
|
||||
FILE *hist = fopen(nanohist, "rb");
|
||||
|
||||
if (hist == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
/* Don't save history when we quit. */
|
||||
UNSET(HISTORYLOG);
|
||||
history_error(N_("Error reading %s: %s"), nanohist,
|
||||
strerror(errno));
|
||||
}
|
||||
} else {
|
||||
char *line = NULL, *lineptr, *xptr;
|
||||
size_t buf_len = 0;
|
||||
ssize_t read, lineno, xno;
|
||||
poshiststruct *posptr;
|
||||
|
||||
/* See if we can find the file we're currently editing */
|
||||
while ((read = getline(&line, &buf_len, hist)) >= 0) {
|
||||
if (read > 0 && line[read - 1] == '\n') {
|
||||
read--;
|
||||
line[read] = '\0';
|
||||
}
|
||||
if (read > 0) {
|
||||
unsunder(line, read);
|
||||
}
|
||||
lineptr = parse_next_word(line);
|
||||
xptr = parse_next_word(lineptr);
|
||||
lineno = atoi(lineptr);
|
||||
xno = atoi(xptr);
|
||||
if (poshistory == NULL) {
|
||||
poshistory = (poshiststruct *) nmalloc(sizeof(poshiststruct));
|
||||
poshistory->filename = mallocstrcpy(NULL, line);
|
||||
poshistory->lineno = lineno;
|
||||
poshistory->xno = xno;
|
||||
poshistory->next = NULL;
|
||||
} else {
|
||||
for (posptr = poshistory; posptr->next != NULL; posptr = posptr->next)
|
||||
;
|
||||
posptr->next = (poshiststruct *) nmalloc(sizeof(poshiststruct));
|
||||
posptr->next->filename = mallocstrcpy(NULL, line);
|
||||
posptr->next->lineno = lineno;
|
||||
posptr->next->xno = xno;
|
||||
posptr->next->next = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose(hist);
|
||||
free(line);
|
||||
}
|
||||
free(nanohist);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !NANO_TINY && ENABLE_NANORC */
|
||||
|
||||
843
src/global.c
843
src/global.c
File diff suppressed because it is too large
Load Diff
28
src/help.c
28
src/help.c
@@ -145,35 +145,35 @@ void do_help(void (*refresh_func)(void))
|
||||
if (!f)
|
||||
continue;
|
||||
|
||||
if (f->scfunc == TOTAL_REFRESH) {
|
||||
if (f->scfunc == total_refresh) {
|
||||
total_redraw();
|
||||
break;
|
||||
} else if (f->scfunc == DO_PAGE_UP) {
|
||||
} else if (f->scfunc == do_page_up) {
|
||||
if (line > editwinrows - 2)
|
||||
line -= editwinrows - 2;
|
||||
else
|
||||
line = 0;
|
||||
} else if (f->scfunc == DO_PAGE_DOWN) {
|
||||
} else if (f->scfunc == do_page_down) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line += editwinrows - 2;
|
||||
} else if (f->scfunc == DO_UP_VOID) {
|
||||
} else if (f->scfunc == do_up_void) {
|
||||
if (line > 0)
|
||||
line--;
|
||||
} else if (f->scfunc == DO_DOWN_VOID) {
|
||||
} else if (f->scfunc == do_down_void) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line++;
|
||||
} else if (f->scfunc == DO_FIRST_LINE) {
|
||||
} else if (f->scfunc == do_first_line) {
|
||||
if (meta_key)
|
||||
line = 0;
|
||||
break;
|
||||
} else if (f->scfunc == DO_LAST_LINE) {
|
||||
} else if (f->scfunc == do_last_line) {
|
||||
if (meta_key) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line = last_line - (editwinrows - 1);
|
||||
}
|
||||
break;
|
||||
/* Abort the help browser. */
|
||||
} else if (f->scfunc == DO_EXIT) {
|
||||
} else if (f->scfunc == do_exit) {
|
||||
abort = TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -407,7 +407,7 @@ void help_init(void)
|
||||
size_t endis_len = strlen(_("enable/disable"));
|
||||
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if (s->scfunc == DO_TOGGLE)
|
||||
if (s->scfunc == do_toggle_void)
|
||||
allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 9;
|
||||
|
||||
}
|
||||
@@ -446,7 +446,7 @@ void help_init(void)
|
||||
if (scsfound == 3)
|
||||
continue;
|
||||
|
||||
if (s->type == RAW)
|
||||
if (s->type == RAWINPUT)
|
||||
continue;
|
||||
|
||||
if ((s->menu & currmenu) == 0)
|
||||
@@ -478,7 +478,7 @@ void help_init(void)
|
||||
/* And the toggles... */
|
||||
if (currmenu == MMAIN)
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if (s->scfunc == DO_TOGGLE)
|
||||
if (s->scfunc == do_toggle_void)
|
||||
ptr += sprintf(ptr, "(%s)\t\t\t%s %s\n",
|
||||
s->keystr, _(flagtostr(s->toggle)), _("enable/disable"));
|
||||
|
||||
@@ -507,15 +507,15 @@ void parse_help_input(int *kbinput, bool *meta_key, bool *func_key)
|
||||
switch (*kbinput) {
|
||||
/* For consistency with the file browser. */
|
||||
case ' ':
|
||||
*kbinput = sc_seq_or(DO_PAGE_UP, 0);
|
||||
*kbinput = sc_seq_or(do_page_up, 0);
|
||||
break;
|
||||
case '-':
|
||||
*kbinput = sc_seq_or(DO_PAGE_DOWN, 0);;
|
||||
*kbinput = sc_seq_or(do_page_down, 0);;
|
||||
break;
|
||||
/* Cancel is equivalent to Exit here. */
|
||||
case 'E':
|
||||
case 'e':
|
||||
*kbinput = sc_seq_or(DO_EXIT, 0);;
|
||||
*kbinput = sc_seq_or(do_exit, 0);;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ void do_page_up(void)
|
||||
if (ISSET(SOFTWRAP) && openfile->current) {
|
||||
skipped += strlenpt(openfile->current->data) / COLS;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_up: i = %d, skipped = %d based on line %ld len %d\n", i, (unsigned long) skipped,
|
||||
fprintf(stderr, "do_page_up: i = %d, skipped = %d based on line %ld len %d\n", i, (unsigned long) skipped,
|
||||
openfile->current->lineno, strlenpt(openfile->current->data));
|
||||
#endif
|
||||
}
|
||||
|
||||
104
src/nano.c
104
src/nano.c
@@ -1,4 +1,4 @@
|
||||
/* $Id$ */
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* nano.c *
|
||||
* *
|
||||
@@ -520,6 +520,7 @@ openfilestruct *make_new_opennode(void)
|
||||
#ifndef NANO_TINY
|
||||
newnode->current_stat = NULL;
|
||||
newnode->last_action = OTHER;
|
||||
newnode->lock_filename = NULL;
|
||||
#endif
|
||||
|
||||
return newnode;
|
||||
@@ -605,6 +606,10 @@ void finish(void)
|
||||
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
|
||||
if (!no_rcfiles && ISSET(HISTORYLOG))
|
||||
save_history();
|
||||
if (!no_rcfiles && ISSET(POS_HISTORY)) {
|
||||
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs()+1);
|
||||
save_poshistory();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -841,6 +846,8 @@ void usage(void)
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-G", "--locking",
|
||||
N_("Use (vim-style) lock files"));
|
||||
print_opt("-H", "--historylog",
|
||||
N_("Log & read search/replace string history"));
|
||||
#endif
|
||||
@@ -856,6 +863,10 @@ void usage(void)
|
||||
N_("Don't convert files from DOS/Mac format"));
|
||||
#endif
|
||||
print_opt("-O", "--morespace", N_("Use one more line for editing"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-P", "--poslog",
|
||||
N_("Log & read location of cursor position"));
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
print_opt(_("-Q <str>"), _("--quotestr=<str>"),
|
||||
N_("Quoting string"));
|
||||
@@ -1050,6 +1061,12 @@ void do_exit(void)
|
||||
/* If the user chose not to save, or if the user chose to save and
|
||||
* the save succeeded, we're ready to exit. */
|
||||
if (i == 0 || (i == 1 && do_writeout(TRUE))) {
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING) && openfile->lock_filename)
|
||||
delete_lockfile(openfile->lock_filename);
|
||||
#endif /* NANO_TINY */
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* Exit only if there are no more open file buffers. */
|
||||
if (!close_buffer())
|
||||
@@ -1063,7 +1080,11 @@ void do_exit(void)
|
||||
display_main_list();
|
||||
}
|
||||
|
||||
|
||||
/* Another placeholder for function mapping */
|
||||
void do_cancel(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
static struct sigaction pager_oldaction, pager_newaction; /* Original and temporary handlers for SIGINT. */
|
||||
static bool pager_sig_failed = FALSE; /* Did sigaction() fail without changing the signal handlers? */
|
||||
@@ -1185,6 +1206,12 @@ RETSIGTYPE handle_hupterm(int signal)
|
||||
/* Handler for SIGTSTP (suspend). */
|
||||
RETSIGTYPE do_suspend(int signal)
|
||||
{
|
||||
|
||||
if (ISSET(RESTRICTED)) {
|
||||
nano_disabled_msg();
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
/* Turn mouse support off. */
|
||||
disable_mouse_support();
|
||||
@@ -1212,7 +1239,7 @@ RETSIGTYPE do_suspend(int signal)
|
||||
}
|
||||
|
||||
/* the subnfunc version */
|
||||
void do_suspend_void(void)
|
||||
void do_suspend_void(void)
|
||||
{
|
||||
if (ISSET(SUSPEND))
|
||||
do_suspend(0);
|
||||
@@ -1380,6 +1407,12 @@ void do_toggle(int flag)
|
||||
statusbar("%s %s", desc, enabled ? _("enabled") :
|
||||
_("disabled"));
|
||||
}
|
||||
|
||||
/* Bleh */
|
||||
void do_toggle_void(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Disable extended input and output processing in our terminal
|
||||
@@ -1575,7 +1608,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
||||
* for verbatim input, turn off prepending of wrapped
|
||||
* text. */
|
||||
if (have_shortcut && (!have_shortcut || s == NULL || s->scfunc !=
|
||||
DO_VERBATIM_INPUT))
|
||||
do_verbatim_input))
|
||||
wrap_reset();
|
||||
#endif
|
||||
|
||||
@@ -1610,10 +1643,10 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
||||
default:
|
||||
/* If the function associated with this shortcut is
|
||||
* cutting or copying text, indicate this. */
|
||||
if (s->scfunc == DO_CUT_TEXT_VOID
|
||||
if (s->scfunc == do_cut_text_void
|
||||
#ifndef NANO_TINY
|
||||
|| s->scfunc == DO_COPY_TEXT || s->scfunc ==
|
||||
DO_CUT_TILL_END
|
||||
|| s->scfunc == do_copy_text || s->scfunc ==
|
||||
do_cut_till_end
|
||||
#endif
|
||||
)
|
||||
cut_copy = TRUE;
|
||||
@@ -1625,13 +1658,13 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
||||
print_view_warning();
|
||||
else {
|
||||
#ifndef NANO_TINY
|
||||
if (s->scfunc == DO_TOGGLE)
|
||||
if (s->scfunc == do_toggle_void)
|
||||
do_toggle(s->toggle);
|
||||
else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
iso_me_harder_funcmap(s->scfunc);
|
||||
s->scfunc();
|
||||
#ifdef ENABLE_COLOR
|
||||
if (f && !f->viewok && openfile->syntax != NULL
|
||||
&& openfile->syntax->nmultis > 0) {
|
||||
@@ -1986,7 +2019,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Well we might also need a full refresh if we've changed the
|
||||
/* Well we might also need a full refresh if we've changed the
|
||||
line length to be a new multiple of COLS */
|
||||
if (ISSET(SOFTWRAP) && edit_refresh_needed == FALSE)
|
||||
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
|
||||
@@ -2074,8 +2107,10 @@ int main(int argc, char **argv)
|
||||
{"backup", 0, NULL, 'B'},
|
||||
{"backupdir", 1, NULL, 'C'},
|
||||
{"tabstospaces", 0, NULL, 'E'},
|
||||
{"locking", 0, NULL, 'G'},
|
||||
{"historylog", 0, NULL, 'H'},
|
||||
{"noconvert", 0, NULL, 'N'},
|
||||
{"poslog", 0, NULL, 'P'},
|
||||
{"smooth", 0, NULL, 'S'},
|
||||
{"quickblank", 0, NULL, 'U'},
|
||||
{"undo", 0, NULL, 'u'},
|
||||
@@ -2121,11 +2156,11 @@ int main(int argc, char **argv)
|
||||
while ((optchr =
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
getopt_long(argc, argv,
|
||||
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$",
|
||||
"h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$",
|
||||
long_options, NULL)
|
||||
#else
|
||||
getopt(argc, argv,
|
||||
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$")
|
||||
"h?ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$")
|
||||
#endif
|
||||
) != -1) {
|
||||
switch (optchr) {
|
||||
@@ -2163,6 +2198,9 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
#ifndef NANO_TINY
|
||||
case 'G':
|
||||
SET(LOCKING);
|
||||
break;
|
||||
case 'H':
|
||||
SET(HISTORYLOG);
|
||||
break;
|
||||
@@ -2185,6 +2223,11 @@ int main(int argc, char **argv)
|
||||
case 'O':
|
||||
SET(MORE_SPACE);
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case 'P':
|
||||
SET(POS_HISTORY);
|
||||
break;
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
case 'Q':
|
||||
quotestr = mallocstrcpy(quotestr, optarg);
|
||||
@@ -2419,7 +2462,7 @@ int main(int argc, char **argv)
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* Overwrite an rcfile "set nowrap" or --disable-wrapping-as-root
|
||||
if a --fill option was given on the command line. */
|
||||
if a --fill option was given on the command line. */
|
||||
if (fill_used)
|
||||
UNSET(NO_WRAP);
|
||||
#endif
|
||||
@@ -2433,10 +2476,20 @@ int main(int argc, char **argv)
|
||||
/* Set up the search/replace history. */
|
||||
history_init();
|
||||
#ifdef ENABLE_NANORC
|
||||
if (!no_rcfiles && ISSET(HISTORYLOG))
|
||||
load_history();
|
||||
#endif
|
||||
#endif
|
||||
if (!no_rcfiles) {
|
||||
if (ISSET(HISTORYLOG) || ISSET(POS_HISTORY)) {
|
||||
if (check_dotnano() == 0) {
|
||||
UNSET(HISTORYLOG);
|
||||
UNSET(POS_HISTORY);
|
||||
}
|
||||
}
|
||||
if (ISSET(HISTORYLOG))
|
||||
load_history();
|
||||
if (ISSET(POS_HISTORY))
|
||||
load_poshistory();
|
||||
}
|
||||
#endif /* ENABLE_NANORC */
|
||||
#endif /* NANO_TINY */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Set up the backup directory (unless we're using restricted mode,
|
||||
@@ -2595,6 +2648,15 @@ int main(int argc, char **argv)
|
||||
iline = 1;
|
||||
icol = 1;
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
else {
|
||||
/* See if we have a POS history to use if we haven't overridden it */
|
||||
ssize_t savedposline, savedposcol;
|
||||
if (check_poshistory(argv[i], &savedposline, &savedposcol))
|
||||
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE,
|
||||
FALSE);
|
||||
}
|
||||
#endif /* NANO_TINY */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2632,6 +2694,14 @@ int main(int argc, char **argv)
|
||||
if (startline > 1 || startcol > 1)
|
||||
do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE,
|
||||
FALSE);
|
||||
# ifndef NANO_TINY
|
||||
else {
|
||||
/* See if we have a POS history to use if we haven't overridden it */
|
||||
ssize_t savedposline, savedposcol;
|
||||
if (check_poshistory(argv[optind], &savedposline, &savedposcol))
|
||||
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE, FALSE);
|
||||
}
|
||||
#endif /* NANO_TINY */
|
||||
|
||||
display_main_list();
|
||||
|
||||
|
||||
190
src/nano.h
190
src/nano.h
@@ -85,6 +85,8 @@
|
||||
#define KEY_DC SL_KEY_DELETE
|
||||
#define KEY_IC SL_KEY_IC
|
||||
/* Ncurses support. */
|
||||
#elif defined(HAVE_NCURSESW_NCURSES_H)
|
||||
#include <ncursesw/ncurses.h>
|
||||
#elif defined(HAVE_NCURSES_H)
|
||||
#include <ncurses.h>
|
||||
#else
|
||||
@@ -182,7 +184,7 @@ typedef enum {
|
||||
} update_type;
|
||||
|
||||
typedef enum {
|
||||
CONTROL, META, FKEY, RAW
|
||||
CONTROL, META, FKEY, RAWINPUT
|
||||
} function_type;
|
||||
|
||||
typedef enum {
|
||||
@@ -232,6 +234,8 @@ typedef struct syntaxtype {
|
||||
/* The list of extensions that this syntax applies to. */
|
||||
exttype *headers;
|
||||
/* Regexes to match on the 'header' (1st line) of the file */
|
||||
exttype *magics;
|
||||
/* Regexes to match libmagic results */
|
||||
colortype *color;
|
||||
/* The colors used in this syntax. */
|
||||
int nmultis;
|
||||
@@ -320,6 +324,15 @@ typedef struct undo {
|
||||
} undo;
|
||||
|
||||
|
||||
typedef struct poshiststruct {
|
||||
char *filename;
|
||||
/* The file. */
|
||||
ssize_t lineno;
|
||||
/* Line number we left off on */
|
||||
ssize_t xno;
|
||||
/* x position in the file we left off on */
|
||||
struct poshiststruct *next;
|
||||
} poshiststruct;
|
||||
#endif /* NANO_TINY */
|
||||
|
||||
|
||||
@@ -361,6 +374,8 @@ typedef struct openfilestruct {
|
||||
undo *current_undo;
|
||||
/* The current (i.e. n ext) level of undo */
|
||||
undo_type last_action;
|
||||
const char *lock_filename;
|
||||
/* The path of the lockfile, if we created one */
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
syntaxtype *syntax;
|
||||
@@ -419,10 +434,10 @@ typedef struct sc {
|
||||
function_type type;
|
||||
/* What kind of function key is it for convenience later */
|
||||
int seq;
|
||||
/* The actual sequence to check on the the type is determined */
|
||||
/* The actual sequence to check on the type is determined */
|
||||
int menu;
|
||||
/* What list does this apply to */
|
||||
short scfunc;
|
||||
void (*scfunc)(void);
|
||||
/* The function we're going to run */
|
||||
int toggle;
|
||||
/* If a toggle, what we're toggling */
|
||||
@@ -434,7 +449,7 @@ typedef struct sc {
|
||||
} sc;
|
||||
|
||||
typedef struct subnfunc {
|
||||
short scfunc;
|
||||
void (*scfunc)(void);
|
||||
/* What function is this */
|
||||
int menus;
|
||||
/* In what menus does this function applu */
|
||||
@@ -456,7 +471,7 @@ typedef struct subnfunc {
|
||||
} subnfunc;
|
||||
|
||||
|
||||
/* Enumeration to be used in flags table. See FLAGBIT and FLAGOFF
|
||||
/* Enumeration to be used in flags table. See FLAGBIT and FLAGOFF
|
||||
* definitions. */
|
||||
enum
|
||||
{
|
||||
@@ -480,6 +495,7 @@ enum
|
||||
REBIND_KEYPAD,
|
||||
NO_CONVERT,
|
||||
BACKUP_FILE,
|
||||
INSECURE_BACKUP,
|
||||
NO_COLOR_SYNTAX,
|
||||
PRESERVE,
|
||||
HISTORYLOG,
|
||||
@@ -494,7 +510,9 @@ enum
|
||||
BOLD_TEXT,
|
||||
QUIET,
|
||||
UNDOABLE,
|
||||
SOFTWRAP
|
||||
SOFTWRAP,
|
||||
POS_HISTORY,
|
||||
LOCKING
|
||||
};
|
||||
|
||||
/* Flags for which menus in which a given function should be present */
|
||||
@@ -742,9 +760,9 @@ enum
|
||||
#define TOGGLE_MAC_KEY NANO_META_M
|
||||
|
||||
/* Extra bits for the undo function */
|
||||
#define UNDO_DEL_DEL (1<<0)
|
||||
#define UNDO_DEL_BACKSPACE (1<<1)
|
||||
#define UNDO_SPLIT_MADENEW (1<<2)
|
||||
#define UNdel_del (1<<0)
|
||||
#define UNdel_backspace (1<<1)
|
||||
#define UNsplit_madenew (1<<2)
|
||||
|
||||
/* Since in ISO C you can't pass around function pointers anymore,
|
||||
let's make some integer macros for function names, and then I
|
||||
@@ -753,160 +771,6 @@ enum
|
||||
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#define CASE_SENS_MSG 1
|
||||
#define BACKWARDS_MSG 2
|
||||
#define REGEXP_MSG 3
|
||||
#define WHEREIS_NEXT_MSG 4
|
||||
#define FIRST_FILE_MSG 5
|
||||
#define LAST_FILE_MSG 6
|
||||
#define GOTO_DIR_MSG 7
|
||||
#define TOTAL_REFRESH 8
|
||||
#define DO_HELP_VOID 9
|
||||
#define DO_SEARCH 10
|
||||
#define DO_PAGE_UP 11
|
||||
#define DO_PAGE_DOWN 12
|
||||
#define DO_UP_VOID 13
|
||||
#define DO_LEFT 14
|
||||
#define DO_DOWN_VOID 15
|
||||
#define DO_RIGHT 16
|
||||
#define DO_ENTER 17
|
||||
#define DO_EXIT 18
|
||||
#define NEW_BUFFER_MSG 19
|
||||
#define EXT_CMD_MSG 20
|
||||
#define TO_FILES_MSG 21
|
||||
#define DOS_FORMAT_MSG 23
|
||||
#define MAC_FORMAT_MSG 24
|
||||
#define BACKUP_FILE_MSG 25
|
||||
#define PREPEND_MSG 26
|
||||
#define APPEND_MSG 27
|
||||
#define DO_FIRST_LINE 28
|
||||
#define DO_LAST_LINE 29
|
||||
#define DO_TOGGLE 30
|
||||
#define GOTOTEXT_MSG 31
|
||||
#define NO_REPLACE_MSG 32
|
||||
#define DO_BACKSPACE 33
|
||||
#define DO_DELETE 34
|
||||
#define DO_TAB 35
|
||||
#define DO_VERBATIM_INPUT 36
|
||||
#define SWITCH_TO_NEXT_BUFFER_VOID 37
|
||||
#define SWITCH_TO_PREV_BUFFER_VOID 38
|
||||
#define DO_END 39
|
||||
#define DO_HOME 40
|
||||
#define NEXT_HISTORY_MSG 41
|
||||
#define PREV_HISTORY_MSG 42
|
||||
#define DO_REDO 43
|
||||
#define DO_UNDO 44
|
||||
#define DO_WORDLINECHAR_COUNT 45
|
||||
#define DO_FIND_BRACKET 46
|
||||
#define DO_PREV_WORD_VOID 47
|
||||
#define DO_SUSPEND_VOID 48
|
||||
#define CANCEL_MSG 49
|
||||
#define DO_WRITEOUT_VOID 50
|
||||
#define DO_INSERTFILE_VOID 51
|
||||
#define DO_CUT_TEXT_VOID 52
|
||||
#define DO_UNCUT_TEXT 53
|
||||
#define DO_CURSORPOS_VOID 54
|
||||
#define DO_GOTOLINECOLUMN_VOID 55
|
||||
#define DO_REPLACE 56
|
||||
#define DO_JUSTIFY_VOID 57
|
||||
#define DO_PARA_BEGIN_VOID 58
|
||||
#define DO_PARA_END_VOID 59
|
||||
#define DO_FULL_JUSTIFY 60
|
||||
#define DO_MARK 61
|
||||
#define DO_RESEARCH 62
|
||||
#define DO_COPY_TEXT 63
|
||||
#define DO_INDENT_VOID 64
|
||||
#define DO_UNINDENT 65
|
||||
#define DO_SCROLL_UP 66
|
||||
#define DO_SCROLL_DOWN 67
|
||||
#define DO_NEXT_WORD_VOID 68
|
||||
#define DO_CUT_TILL_END 69
|
||||
#define NANO_GOTODIR_MSG 70
|
||||
#define NANO_LASTFILE_MSG 71
|
||||
#define NANO_FIRSTFILE_MSG 72
|
||||
#define INSERT_FILE_MSG 73
|
||||
#define NANO_MULTIBUFFER_MSG 74
|
||||
#define NANO_EXECUTE_MSG 75
|
||||
#define NANO_BACKUP_MSG 76
|
||||
#define NANO_PREPEND_MSG 77
|
||||
#define NANO_APPEND_MSG 78
|
||||
#define NANO_MAC_MSG 79
|
||||
#define NANO_DOS_MSG 80
|
||||
#define NANO_TOFILES_MSG 81
|
||||
#define NANO_NEXT_HISTORY_MSG 82
|
||||
#define NANO_PREV_HISTORY_MSG 83
|
||||
#define NANO_REGEXP_MSG 84
|
||||
#define NANO_REVERSE_MSG 85
|
||||
#define NANO_CASE_MSG 86
|
||||
#define NANO_SUSPEND_MSG 87
|
||||
#define SUSPEND_MSG 88
|
||||
#define NANO_REFRESH_MSG 89
|
||||
#define REFRESH_MSG 90
|
||||
#define NANO_WORDCOUNT_MSG 91
|
||||
#define NANO_FULLJUSTIFY_MSG 92
|
||||
#define FULLJSTIFY_MSG 93
|
||||
#define XOFF_COMPLAINT 94
|
||||
#define XON_COMPLAINT 95
|
||||
#define NANO_CUT_TILL_END_MSG 96
|
||||
#define NANO_BACKSPACE_MSG 97
|
||||
#define NANO_DELETE_MSG 98
|
||||
#define NANO_ENTER_MSG 99
|
||||
#define NANO_TAB_MSG 100
|
||||
#define NANO_VERBATIM_MSG 101
|
||||
#define NANO_NEXTFILE_MSG 102
|
||||
#define NANO_PREVFILE_MSG 103
|
||||
#define NANO_SCROLLDOWN_MSG 104
|
||||
#define NANO_SCROLLUP_MSG 105
|
||||
#define NANO_BRACKET_MSG 106
|
||||
#define NANO_PARAEND_MSG 107
|
||||
#define END_OF_PAR_MSG 108
|
||||
#define NANO_PARABEGIN_MSG 109
|
||||
#define BEG_OF_PAR_MSG 110
|
||||
#define NANO_END_MSG 111
|
||||
#define NANO_HOME_MSG 112
|
||||
#define NANO_NEXTLINE_MSG 113
|
||||
#define NANO_PREVLINE_MSG 114
|
||||
#define NANO_PREVWORD_MSG 115
|
||||
#define NANO_NEXTWORD_MSG 116
|
||||
#define NANO_BACK_MSG 117
|
||||
#define NANO_FORWARD_MSG 118
|
||||
#define NANO_REDO_MSG 119
|
||||
#define NANO_UNDO_MSG 120
|
||||
#define NANO_UNINDENT_MSG 121
|
||||
#define NANO_INDENT_MSG 122
|
||||
#define NANO_COPY_MSG 123
|
||||
#define NANO_WHEREIS_NEXT_MSG 124
|
||||
#define NANO_MARK_MSG 125
|
||||
#define NANO_REPLACE_MSG 126
|
||||
#define REPLACE_MSG 127
|
||||
#define NANO_GOTOLINE_MSG 128
|
||||
#define NANO_LASTLINE_MSG 129
|
||||
#define NANO_FIRSTLINE_MSG 130
|
||||
#define NANO_SPELL_MSG 131
|
||||
#define DO_SPELL 132
|
||||
#define NANO_CURSORPOS_MSG 133
|
||||
#define NANO_UNCUT_MSG 134
|
||||
#define GET_HELP_MSG 135
|
||||
#define NANO_HELP_MSG 136
|
||||
#define NANO_CANCEL_MSG 137
|
||||
#define NANO_EXIT_MSG 138
|
||||
#define EXIT_MSG 139
|
||||
#define NANO_EXITBROWSER_MSG 140
|
||||
#define NANO_WRITEOUT_MSG 141
|
||||
#define NANO_DISABLED_MSG 142
|
||||
#define NANO_INSERT_MSG 143
|
||||
#define WHEREIS_MSG 144
|
||||
#define NANO_WHEREIS_MSG 145
|
||||
#define NANO_PREVPAGE_MSG 146
|
||||
#define NANO_NEXTPAGE_MSG 147
|
||||
#define NANO_CUT_MSG 148
|
||||
#define DO_CUT_TEXT 149
|
||||
#define DO_NEXT_WORD 150
|
||||
#define DO_PREV_WORD 151
|
||||
|
||||
|
||||
|
||||
|
||||
#define VIEW TRUE
|
||||
#define NOVIEW FALSE
|
||||
|
||||
|
||||
56
src/prompt.c
56
src/prompt.c
@@ -152,38 +152,38 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
}
|
||||
|
||||
if (*have_shortcut) {
|
||||
if (s->scfunc == DO_TAB || s->scfunc == DO_ENTER)
|
||||
if (s->scfunc == do_tab || s->scfunc == do_enter_void)
|
||||
;
|
||||
else if (s->scfunc == TOTAL_REFRESH)
|
||||
else if (s->scfunc == total_refresh)
|
||||
total_statusbar_refresh(refresh_func);
|
||||
else if (s->scfunc == DO_CUT_TEXT) {
|
||||
else if (s->scfunc == do_cut_text_void) {
|
||||
/* If we're using restricted mode, the filename
|
||||
* isn't blank, and we're at the "Write File"
|
||||
* prompt, disable Cut. */
|
||||
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
|
||||
'\0' || currmenu != MWRITEFILE)
|
||||
do_statusbar_cut_text();
|
||||
} else if (s->scfunc == DO_RIGHT)
|
||||
} else if (s->scfunc == do_right)
|
||||
do_statusbar_right();
|
||||
else if (s->scfunc == DO_LEFT)
|
||||
else if (s->scfunc == do_left)
|
||||
do_statusbar_left();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
else if (s->scfunc == DO_NEXT_WORD)
|
||||
else if (s->scfunc == do_next_word_void)
|
||||
do_statusbar_next_word(FALSE);
|
||||
else if (s->scfunc == DO_PREV_WORD)
|
||||
else if (s->scfunc == do_prev_word_void)
|
||||
do_statusbar_prev_word(FALSE);
|
||||
#endif
|
||||
else if (s->scfunc == DO_HOME)
|
||||
else if (s->scfunc == do_home)
|
||||
do_statusbar_home();
|
||||
else if (s->scfunc == DO_END)
|
||||
else if (s->scfunc == do_end)
|
||||
do_statusbar_end();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
else if (s->scfunc == DO_FIND_BRACKET)
|
||||
else if (s->scfunc == do_find_bracket)
|
||||
do_statusbar_find_bracket();
|
||||
#endif
|
||||
else if (s->scfunc == DO_VERBATIM_INPUT) {
|
||||
else if (s->scfunc == do_verbatim_input) {
|
||||
/* If we're using restricted mode, the filename
|
||||
* isn't blank, and we're at the "Write File"
|
||||
* prompt, disable verbatim input. */
|
||||
@@ -201,18 +201,18 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
* to indicate that we're done. */
|
||||
if (got_enter) {
|
||||
get_input(NULL, 1);
|
||||
input = sc_seq_or(DO_ENTER, 0);
|
||||
input = sc_seq_or(do_enter_void, 0);
|
||||
*finished = TRUE;
|
||||
}
|
||||
}
|
||||
} else if (s->scfunc == DO_DELETE) {
|
||||
} else if (s->scfunc == do_delete) {
|
||||
/* If we're using restricted mode, the filename
|
||||
* isn't blank, and we're at the "Write File"
|
||||
* prompt, disable Delete. */
|
||||
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
|
||||
'\0' || currmenu != MWRITEFILE)
|
||||
do_statusbar_delete();
|
||||
} else if (s->scfunc == DO_BACKSPACE) {
|
||||
} else if (s->scfunc == do_backspace) {
|
||||
/* If we're using restricted mode, the filename
|
||||
* isn't blank, and we're at the "Write File"
|
||||
* prompt, disable Backspace. */
|
||||
@@ -230,7 +230,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
if (s->scfunc != 0 && s->execute == TRUE) {
|
||||
*ran_func = TRUE;
|
||||
if (f && (!ISSET(VIEW_MODE) || (f->viewok)))
|
||||
iso_me_harder_funcmap(f->scfunc);
|
||||
f->scfunc();
|
||||
}
|
||||
*finished = TRUE;
|
||||
}
|
||||
@@ -979,19 +979,19 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
s = get_shortcut(currmenu, &kbinput, meta_key, func_key);
|
||||
|
||||
if (s)
|
||||
if (s->scfunc == CANCEL_MSG || s->scfunc == DO_ENTER)
|
||||
if (s->scfunc == do_cancel || s->scfunc == do_enter_void)
|
||||
break;
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
if (s && s->scfunc != DO_TAB)
|
||||
if (s && s->scfunc != do_tab)
|
||||
tabbed = FALSE;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
#ifndef NANO_TINY
|
||||
if (s && s->scfunc == DO_TAB) {
|
||||
if (s && s->scfunc == do_tab) {
|
||||
if (history_list != NULL) {
|
||||
if (last_kbinput != sc_seq_or(DO_TAB, NANO_CONTROL_I))
|
||||
if (last_kbinput != sc_seq_or(do_tab, NANO_CONTROL_I))
|
||||
complete_len = strlen(answer);
|
||||
|
||||
if (complete_len > 0) {
|
||||
@@ -1007,10 +1007,10 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
&statusbar_x, &tabbed, refresh_func, list);
|
||||
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
} else
|
||||
} else
|
||||
#endif /* !DISABLE_TABCOMP */
|
||||
#ifndef NANO_TINY
|
||||
if (s && s->scfunc == PREV_HISTORY_MSG) {
|
||||
if (s && s->scfunc == get_history_older_void) {
|
||||
if (history_list != NULL) {
|
||||
/* If we're scrolling up at the bottom of the
|
||||
* history list and answer isn't blank, save answer
|
||||
@@ -1038,7 +1038,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
* statusbar prompt. */
|
||||
finished = FALSE;
|
||||
}
|
||||
} else if (s && s->scfunc == NEXT_HISTORY_MSG) {
|
||||
} else if (s && s->scfunc == get_history_newer_void) {
|
||||
if (history_list != NULL) {
|
||||
/* Get the newer search from the history list and
|
||||
* save it in answer. If there is no newer search,
|
||||
@@ -1070,7 +1070,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
}
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
if (s && s->scfunc == DO_HELP_VOID) {
|
||||
if (s && s->scfunc == do_help_void) {
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
|
||||
/* This key has a shortcut list entry when it's used to
|
||||
@@ -1114,7 +1114,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
* we've finished putting in an answer, reset the statusbar cursor
|
||||
* position too. */
|
||||
if (s) {
|
||||
if (s->scfunc == CANCEL_MSG || s->scfunc == DO_ENTER ||
|
||||
if (s->scfunc == do_cancel || s->scfunc == do_enter_void ||
|
||||
ran_func) {
|
||||
statusbar_x = old_statusbar_x;
|
||||
statusbar_pww = old_pww;
|
||||
@@ -1201,9 +1201,9 @@ int do_prompt(bool allow_tabs,
|
||||
|
||||
/* If we left the prompt via Cancel or Enter, set the return value
|
||||
* properly. */
|
||||
if (s && s->scfunc == CANCEL_MSG)
|
||||
if (s && s->scfunc == do_cancel)
|
||||
retval = -1;
|
||||
else if (s && s->scfunc == DO_ENTER)
|
||||
else if (s && s->scfunc == do_enter_void)
|
||||
retval = (*answer == '\0') ? -2 : 0;
|
||||
|
||||
blank_statusbar();
|
||||
@@ -1311,7 +1311,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
kbinput = get_kbinput(bottomwin, &meta_key, &func_key);
|
||||
s = get_shortcut(currmenu, &kbinput, &meta_key, &func_key);
|
||||
|
||||
if (s && s->scfunc == CANCEL_MSG)
|
||||
if (s && s->scfunc == do_cancel)
|
||||
ok = -1;
|
||||
#ifndef DISABLE_MOUSE
|
||||
else if (kbinput == KEY_MOUSE) {
|
||||
@@ -1343,7 +1343,7 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
}
|
||||
}
|
||||
#endif /* !DISABLE_MOUSE */
|
||||
else if (s && s->scfunc == TOTAL_REFRESH) {
|
||||
else if (s && s->scfunc == total_refresh) {
|
||||
total_redraw();
|
||||
continue;
|
||||
} else {
|
||||
|
||||
39
src/proto.h
39
src/proto.h
@@ -85,6 +85,8 @@ extern ssize_t tabsize;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
extern char *backup_dir;
|
||||
extern const char *locking_prefix;
|
||||
extern const char *locking_suffix;
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
extern char *operating_dir;
|
||||
@@ -113,6 +115,8 @@ extern filestruct *searchbot;
|
||||
extern filestruct *replace_history;
|
||||
extern filestruct *replaceage;
|
||||
extern filestruct *replacebot;
|
||||
extern poshiststruct *poshistory;
|
||||
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
@@ -251,6 +255,7 @@ void do_cut_text_void(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_copy_text(void);
|
||||
void do_cut_till_end(void);
|
||||
|
||||
#endif
|
||||
void do_uncut_text(void);
|
||||
|
||||
@@ -291,6 +296,8 @@ bool check_operating_dir(const char *currpath, bool allow_tabcomp);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void init_backup_dir(void);
|
||||
int delete_lockfile(const char *lockfilename);
|
||||
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified);
|
||||
#endif
|
||||
int copy_file(FILE *inn, FILE *out);
|
||||
bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
@@ -321,6 +328,10 @@ char *histfilename(void);
|
||||
void load_history(void);
|
||||
bool writehist(FILE *hist, filestruct *histhead);
|
||||
void save_history(void);
|
||||
int check_dotnano(void);
|
||||
void load_poshistory(void);
|
||||
void save_poshistory(void);
|
||||
int check_poshistory(const char *file, ssize_t *line, ssize_t *column);
|
||||
#endif
|
||||
|
||||
/* All functions in global.c. */
|
||||
@@ -460,6 +471,7 @@ void allow_pending_sigwinch(bool allow);
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
void do_toggle(int flag);
|
||||
void do_toggle_void(void);
|
||||
#endif
|
||||
void disable_extended_io(void);
|
||||
#ifdef USE_SLANG
|
||||
@@ -546,6 +558,7 @@ char *parse_argument(char *ptr);
|
||||
char *parse_next_regex(char *ptr);
|
||||
bool nregcomp(const char *regex, int eflags);
|
||||
void parse_syntax(char *ptr);
|
||||
void parse_magic_syntax(char *ptr);
|
||||
void parse_include(char *ptr);
|
||||
short color_to_short(const char *colorname, bool *bright);
|
||||
void parse_colors(char *ptr, bool icase);
|
||||
@@ -611,6 +624,8 @@ filestruct *find_history(const filestruct *h_start, const filestruct
|
||||
void update_history(filestruct **h, const char *s);
|
||||
char *get_history_older(filestruct **h);
|
||||
char *get_history_newer(filestruct **h);
|
||||
void get_history_older_void(void);
|
||||
void get_history_newer_void(void);
|
||||
#ifndef DISABLE_TABCOMP
|
||||
char *get_history_completion(filestruct **h, const char *s, size_t len);
|
||||
#endif
|
||||
@@ -631,6 +646,7 @@ void do_undo(void);
|
||||
void do_redo(void);
|
||||
#endif
|
||||
void do_enter(bool undoing);
|
||||
void do_enter_void(void);
|
||||
#ifndef NANO_TINY
|
||||
RETSIGTYPE cancel_command(int signal);
|
||||
bool execute_command(const char *command);
|
||||
@@ -752,7 +768,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
|
||||
#endif
|
||||
const sc *get_shortcut(int menu, int *kbinput, bool
|
||||
*meta_key, bool *func_key);
|
||||
const sc *first_sc_for(int menu, short func);
|
||||
const sc *first_sc_for(int menu, void (*func)(void));
|
||||
void blank_line(WINDOW *win, int y, int x, int n);
|
||||
void blank_titlebar(void);
|
||||
void blank_topbar(void);
|
||||
@@ -793,7 +809,7 @@ int strtomenu(char *input);
|
||||
void assign_keyinfo(sc *s);
|
||||
void xon_complaint(void);
|
||||
void xoff_complaint(void);
|
||||
int sc_seq_or (short func, int defaultval);
|
||||
int sc_seq_or (void (*func)(void), int defaultval);
|
||||
void do_suspend_void(void);
|
||||
|
||||
extern const char *cancel_msg;
|
||||
@@ -820,7 +836,6 @@ extern const char *backup_file_msg;
|
||||
extern const char *gototext_msg;
|
||||
extern const char *new_buffer_msg;
|
||||
|
||||
void iso_me_harder_funcmap(short func);
|
||||
void enable_nodelay(void);
|
||||
void disable_nodelay(void);
|
||||
|
||||
@@ -832,4 +847,22 @@ extern const char *regexp_msg;
|
||||
void do_credits(void);
|
||||
#endif
|
||||
|
||||
/* May as just throw these here since they are just placeholders */
|
||||
void do_cancel(void);
|
||||
void case_sens_void(void);
|
||||
void regexp_void(void);
|
||||
void gototext_void(void);
|
||||
void to_files_void(void);
|
||||
void dos_format_void(void);
|
||||
void mac_format_void(void);
|
||||
void append_void(void);
|
||||
void prepend_void(void);
|
||||
void backup_file_void(void);
|
||||
void new_buffer_void(void);
|
||||
void backwards_void(void);
|
||||
void goto_dir_void(void);
|
||||
void no_replace_void(void);
|
||||
void ext_cmd_void(void);
|
||||
|
||||
|
||||
#endif /* !PROTO_H */
|
||||
|
||||
98
src/rcfile.c
98
src/rcfile.c
@@ -41,6 +41,9 @@ static const rcoption rcopts[] = {
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
{"fill", 0},
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
{"locking", LOCKING},
|
||||
#endif
|
||||
#ifndef DISABLE_MOUSE
|
||||
{"mouse", USE_MOUSE},
|
||||
#endif
|
||||
@@ -77,6 +80,7 @@ static const rcoption rcopts[] = {
|
||||
#ifndef NANO_TINY
|
||||
{"autoindent", AUTOINDENT},
|
||||
{"backup", BACKUP_FILE},
|
||||
{"allow_insecure_backup", INSECURE_BACKUP},
|
||||
{"backupdir", 0},
|
||||
{"backwards", BACKWARDS_SEARCH},
|
||||
{"casesensitive", CASE_SENSITIVE},
|
||||
@@ -84,6 +88,7 @@ static const rcoption rcopts[] = {
|
||||
{"historylog", HISTORYLOG},
|
||||
{"matchbrackets", 0},
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"poslog", POS_HISTORY},
|
||||
{"quiet", QUIET},
|
||||
{"quickblank", QUICK_BLANK},
|
||||
{"smarthome", SMART_HOME},
|
||||
@@ -247,7 +252,7 @@ bool nregcomp(const char *regex, int eflags)
|
||||
void parse_syntax(char *ptr)
|
||||
{
|
||||
const char *fileregptr = NULL, *nameptr = NULL;
|
||||
syntaxtype *tmpsyntax;
|
||||
syntaxtype *tmpsyntax, *prev_syntax;
|
||||
exttype *endext = NULL;
|
||||
/* The end of the extensions list for this syntax. */
|
||||
|
||||
@@ -274,15 +279,26 @@ void parse_syntax(char *ptr)
|
||||
|
||||
/* Search for a duplicate syntax name. If we find one, free it, so
|
||||
* that we always use the last syntax with a given name. */
|
||||
prev_syntax = NULL;
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
if (strcmp(nameptr, tmpsyntax->desc) == 0) {
|
||||
syntaxtype *prev_syntax = tmpsyntax;
|
||||
syntaxtype *old_syntax = tmpsyntax;
|
||||
|
||||
if (endsyntax == tmpsyntax)
|
||||
endsyntax = prev_syntax;
|
||||
|
||||
tmpsyntax = tmpsyntax->next;
|
||||
free(prev_syntax);
|
||||
if (prev_syntax != NULL)
|
||||
prev_syntax->next = tmpsyntax;
|
||||
else
|
||||
syntaxes = tmpsyntax;
|
||||
|
||||
free(old_syntax->desc);
|
||||
free(old_syntax);
|
||||
break;
|
||||
}
|
||||
prev_syntax = tmpsyntax;
|
||||
}
|
||||
|
||||
if (syntaxes == NULL) {
|
||||
@@ -302,6 +318,7 @@ void parse_syntax(char *ptr)
|
||||
endheader = NULL;
|
||||
endsyntax->extensions = NULL;
|
||||
endsyntax->headers = NULL;
|
||||
endsyntax->magics = NULL;
|
||||
endsyntax->next = NULL;
|
||||
endsyntax->nmultis = 0;
|
||||
|
||||
@@ -357,6 +374,76 @@ void parse_syntax(char *ptr)
|
||||
} else
|
||||
free(newext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Parse the next syntax string from the line at ptr, and add it to the
|
||||
* global list of color syntaxes. */
|
||||
void parse_magictype(char *ptr)
|
||||
{
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
const char *fileregptr = NULL;
|
||||
exttype *endext = NULL;
|
||||
|
||||
assert(ptr != NULL);
|
||||
|
||||
if (syntaxes == NULL) {
|
||||
rcfile_error(
|
||||
N_("Cannot add a magic string regex without a syntax command"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (*ptr == '\0') {
|
||||
rcfile_error(N_("Missing magic string name"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (*ptr != '"') {
|
||||
rcfile_error(
|
||||
N_("Regex strings must begin and end with a \" character"));
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Starting a magic type: \"%s\"\n", ptr);
|
||||
#endif
|
||||
|
||||
/* Now load the extensions into their part of the struct. */
|
||||
while (*ptr != '\0') {
|
||||
exttype *newext;
|
||||
/* The new extension structure. */
|
||||
|
||||
while (*ptr != '"' && *ptr != '\0')
|
||||
ptr++;
|
||||
|
||||
if (*ptr == '\0')
|
||||
return;
|
||||
|
||||
ptr++;
|
||||
|
||||
fileregptr = ptr;
|
||||
ptr = parse_next_regex(ptr);
|
||||
if (ptr == NULL)
|
||||
break;
|
||||
|
||||
newext = (exttype *)nmalloc(sizeof(exttype));
|
||||
|
||||
/* Save the regex if it's valid. */
|
||||
if (nregcomp(fileregptr, REG_NOSUB)) {
|
||||
newext->ext_regex = mallocstrcpy(NULL, fileregptr);
|
||||
newext->ext = NULL;
|
||||
|
||||
if (endext == NULL)
|
||||
endsyntax->magics = newext;
|
||||
else
|
||||
endext->next = newext;
|
||||
endext = newext;
|
||||
endext->next = NULL;
|
||||
} else
|
||||
free(newext);
|
||||
}
|
||||
#endif /* HAVE_LIBMAGIC */
|
||||
}
|
||||
|
||||
int check_bad_binding(sc *s)
|
||||
@@ -862,7 +949,7 @@ static void check_vitals_mapped(void)
|
||||
subnfunc *f;
|
||||
int v;
|
||||
#define VITALS 5
|
||||
short vitals[VITALS] = { DO_EXIT, DO_EXIT, CANCEL_MSG, CANCEL_MSG, CANCEL_MSG };
|
||||
void (*vitals[VITALS])(void) = { do_exit, do_exit, do_cancel, do_cancel, do_cancel };
|
||||
int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE };
|
||||
|
||||
for (v = 0; v < VITALS; v++) {
|
||||
@@ -950,6 +1037,9 @@ void parse_rcfile(FILE *rcstream
|
||||
rcfile_error(N_("Syntax \"%s\" has no color commands"),
|
||||
endsyntax->desc);
|
||||
parse_syntax(ptr);
|
||||
}
|
||||
else if (strcasecmp(keyword, "magic") == 0) {
|
||||
parse_magictype(ptr);
|
||||
} else if (strcasecmp(keyword, "header") == 0)
|
||||
parse_headers(ptr);
|
||||
else if (strcasecmp(keyword, "color") == 0)
|
||||
|
||||
28
src/search.c
28
src/search.c
@@ -138,7 +138,6 @@ int search_init(bool replacing, bool use_answer)
|
||||
int i = 0;
|
||||
char *buf;
|
||||
sc *s;
|
||||
char func = 0;
|
||||
bool meta_key = FALSE, func_key = FALSE;
|
||||
static char *backupstring = NULL;
|
||||
/* The search string we'll be using. */
|
||||
@@ -220,6 +219,8 @@ int search_init(bool replacing, bool use_answer)
|
||||
statusbar(_("Cancelled"));
|
||||
return -1;
|
||||
} else {
|
||||
void (*func)(void);
|
||||
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if ((s->menu & currmenu) && i == s->seq) {
|
||||
func = s->scfunc;
|
||||
@@ -236,26 +237,25 @@ int search_init(bool replacing, bool use_answer)
|
||||
#endif
|
||||
;
|
||||
#ifndef NANO_TINY
|
||||
} else if (func == CASE_SENS_MSG) {
|
||||
} else if (func == case_sens_void) {
|
||||
TOGGLE(CASE_SENSITIVE);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
} else if (func == BACKWARDS_MSG) {
|
||||
} else if (func == backwards_void) {
|
||||
TOGGLE(BACKWARDS_SEARCH);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
} else if (func == REGEXP_MSG) {
|
||||
} else if (func == regexp_void) {
|
||||
TOGGLE(USE_REGEXP);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
#endif
|
||||
} else if (func == DO_REPLACE ||
|
||||
func == NO_REPLACE_MSG) {
|
||||
} else if (func == do_replace || func == no_replace_void) {
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return -2; /* Call the opposite search function. */
|
||||
} else if (func == DO_GOTOLINECOLUMN_VOID) {
|
||||
} else if (func == do_gotolinecolumn_void) {
|
||||
do_gotolinecolumn(openfile->current->lineno,
|
||||
openfile->placewewant + 1, TRUE, TRUE, FALSE,
|
||||
TRUE);
|
||||
@@ -310,7 +310,7 @@ bool findnextstr(
|
||||
if (time(NULL) - lastkbcheck > 1) {
|
||||
lastkbcheck = time(NULL);
|
||||
f = getfuncfromkey(edit);
|
||||
if (f && f->scfunc == CANCEL_MSG) {
|
||||
if (f && f->scfunc == do_cancel) {
|
||||
statusbar(_("Cancelled"));
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1044,7 +1044,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
|
||||
|
||||
s = get_shortcut(currmenu, &i, &meta_key, &func_key);
|
||||
if (s && s->scfunc == GOTOTEXT_MSG) {
|
||||
if (s && s->scfunc == gototext_void) {
|
||||
/* Keep answer up on the statusbar. */
|
||||
search_init(TRUE, TRUE);
|
||||
|
||||
@@ -1431,6 +1431,16 @@ char *get_history_newer(filestruct **h)
|
||||
return (*h)->data;
|
||||
}
|
||||
|
||||
/* More placeholders */
|
||||
void get_history_newer_void(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
void get_history_older_void(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
/* Move h to the next string that's a tab completion of the string s,
|
||||
* looking at only the first len characters of s, and return that
|
||||
|
||||
37
src/text.c
37
src/text.c
@@ -1,4 +1,4 @@
|
||||
/* $Id$ */
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* text.c *
|
||||
* *
|
||||
@@ -481,7 +481,7 @@ void do_undo(void)
|
||||
strcpy(&data[u->begin + strlen(u->strdata)], &f->data[u->begin]);
|
||||
free(f->data);
|
||||
f->data = data;
|
||||
if (u->xflags == UNDO_DEL_BACKSPACE)
|
||||
if (u->xflags == UNdel_backspace)
|
||||
openfile->current_x += strlen(u->strdata);
|
||||
break;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
@@ -626,7 +626,7 @@ void do_redo(void)
|
||||
#ifndef DISABLE_WRAPPING
|
||||
case SPLIT:
|
||||
undidmsg = _("line wrap");
|
||||
if (u->xflags & UNDO_SPLIT_MADENEW)
|
||||
if (u->xflags & UNsplit_madenew)
|
||||
prepend_wrap = TRUE;
|
||||
do_wrap(f, TRUE);
|
||||
renumber(f);
|
||||
@@ -711,7 +711,7 @@ void do_enter(bool undoing)
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
strncpy(newnode->data, openfile->current->data, extra);
|
||||
openfile->totsize += mbstrlen(newnode->data);
|
||||
openfile->totsize += extra;
|
||||
}
|
||||
#endif
|
||||
null_at(&openfile->current->data, openfile->current_x);
|
||||
@@ -741,6 +741,11 @@ void do_enter(bool undoing)
|
||||
edit_refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
/* Need this again... */
|
||||
void do_enter_void(void) {
|
||||
do_enter(FALSE);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Send a SIGKILL (unconditional kill) to the forked process in
|
||||
* execute_command(). */
|
||||
@@ -850,7 +855,7 @@ void add_undo(undo_type current_action)
|
||||
/* Ugh, if we were called while cutting not-to-end, non-marked and on the same lineno,
|
||||
we need to abort here */
|
||||
u = fs->current_undo;
|
||||
if (current_action == CUT && u && u->type == CUT
|
||||
if (current_action == CUT && u && u->type == CUT
|
||||
&& !u->mark_set && u->lineno == fs->current->lineno)
|
||||
return;
|
||||
|
||||
@@ -1016,8 +1021,8 @@ void update_undo(undo_type action)
|
||||
if (fs->current_x == u->begin) {
|
||||
/* They're deleting */
|
||||
if (!u->xflags)
|
||||
u->xflags = UNDO_DEL_DEL;
|
||||
else if (u->xflags != UNDO_DEL_DEL) {
|
||||
u->xflags = UNdel_del;
|
||||
else if (u->xflags != UNdel_del) {
|
||||
add_undo(action);
|
||||
return;
|
||||
}
|
||||
@@ -1030,8 +1035,8 @@ void update_undo(undo_type action)
|
||||
} else if (fs->current_x == u->begin - 1) {
|
||||
/* They're backspacing */
|
||||
if (!u->xflags)
|
||||
u->xflags = UNDO_DEL_BACKSPACE;
|
||||
else if (u->xflags != UNDO_DEL_BACKSPACE) {
|
||||
u->xflags = UNdel_backspace;
|
||||
else if (u->xflags != UNdel_backspace) {
|
||||
add_undo(action);
|
||||
return;
|
||||
}
|
||||
@@ -1071,7 +1076,7 @@ void update_undo(undo_type action)
|
||||
case SPLIT:
|
||||
/* This will only be called if we made a completely new line,
|
||||
and as such we should note that so we can destroy it later */
|
||||
u->xflags = UNDO_SPLIT_MADENEW;
|
||||
u->xflags = UNsplit_madenew;
|
||||
break;
|
||||
#endif /* DISABLE_WRAPPING */
|
||||
case UNSPLIT:
|
||||
@@ -1974,6 +1979,8 @@ void do_justify(bool full_justify)
|
||||
if (full_justify)
|
||||
openfile->current = openfile->fileage;
|
||||
|
||||
allow_pending_sigwinch(FALSE);
|
||||
|
||||
while (TRUE) {
|
||||
size_t i;
|
||||
/* Generic loop variable. */
|
||||
@@ -2281,7 +2288,7 @@ void do_justify(bool full_justify)
|
||||
&finished, FALSE);
|
||||
s = get_shortcut(currmenu, &kbinput, &meta_key, &func_key);
|
||||
|
||||
if (s && s->scfunc == DO_UNCUT_TEXT) {
|
||||
if (s && s->scfunc == do_uncut_text) {
|
||||
/* Splice the justify buffer back into the file, but only if we
|
||||
* actually justified something. */
|
||||
if (first_par_line != NULL) {
|
||||
@@ -2344,6 +2351,9 @@ void do_justify(bool full_justify)
|
||||
/* Display the shortcut list with UnCut. */
|
||||
shortcut_init(FALSE);
|
||||
display_main_list();
|
||||
|
||||
allow_pending_sigwinch(TRUE);
|
||||
|
||||
}
|
||||
|
||||
/* Justify the current paragraph. */
|
||||
@@ -2920,6 +2930,11 @@ void do_spell(void)
|
||||
char *temp = safe_tempfile(&temp_file);
|
||||
const char *spell_msg;
|
||||
|
||||
if (ISSET(RESTRICTED)) {
|
||||
nano_disabled_msg();
|
||||
return;
|
||||
}
|
||||
|
||||
if (temp == NULL) {
|
||||
statusbar(_("Error writing temp file: %s"), strerror(errno));
|
||||
return;
|
||||
|
||||
@@ -72,6 +72,10 @@ bool parse_num(const char *str, ssize_t *val)
|
||||
|
||||
assert(str != NULL);
|
||||
|
||||
/* Man page for strtol() says this is required, and
|
||||
it looks like it is! */
|
||||
errno = 0;
|
||||
|
||||
j = (ssize_t)strtol(str, &first_error, 10);
|
||||
|
||||
if (errno == ERANGE || *str == '\0' || *first_error != '\0')
|
||||
|
||||
124
src/winio.c
124
src/winio.c
@@ -497,36 +497,36 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
if (retval != ERR) {
|
||||
switch (retval) {
|
||||
case NANO_CONTROL_8:
|
||||
retval = ISSET(REBIND_DELETE) ? sc_seq_or(DO_DELETE, 0) :
|
||||
sc_seq_or(DO_BACKSPACE, 0);
|
||||
retval = ISSET(REBIND_DELETE) ? sc_seq_or(do_delete, 0) :
|
||||
sc_seq_or(do_backspace, 0);
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
#ifdef KEY_SDOWN
|
||||
/* ncurses and Slang don't support KEY_SDOWN. */
|
||||
case KEY_SDOWN:
|
||||
#endif
|
||||
retval = sc_seq_or(DO_DOWN_VOID, *kbinput);
|
||||
retval = sc_seq_or(do_down_void, *kbinput);
|
||||
break;
|
||||
case KEY_UP:
|
||||
#ifdef KEY_SUP
|
||||
/* ncurses and Slang don't support KEY_SUP. */
|
||||
case KEY_SUP:
|
||||
#endif
|
||||
retval = sc_seq_or(DO_UP_VOID, *kbinput);
|
||||
retval = sc_seq_or(do_up_void, *kbinput);
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
#ifdef KEY_SLEFT
|
||||
/* Slang doesn't support KEY_SLEFT. */
|
||||
case KEY_SLEFT:
|
||||
#endif
|
||||
retval = sc_seq_or(DO_LEFT, *kbinput);
|
||||
retval = sc_seq_or(do_left, *kbinput);
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
#ifdef KEY_SRIGHT
|
||||
/* Slang doesn't support KEY_SRIGHT. */
|
||||
case KEY_SRIGHT:
|
||||
#endif
|
||||
retval = sc_seq_or(DO_RIGHT, *kbinput);
|
||||
retval = sc_seq_or(do_right, *kbinput);
|
||||
break;
|
||||
#ifdef KEY_SHOME
|
||||
/* HP-UX 10-11 and Slang don't support KEY_SHOME. */
|
||||
@@ -534,36 +534,36 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
#endif
|
||||
case KEY_A1: /* Home (7) on numeric keypad with
|
||||
* NumLock off. */
|
||||
retval = sc_seq_or(DO_HOME, *kbinput);
|
||||
retval = sc_seq_or(do_home, *kbinput);
|
||||
break;
|
||||
case KEY_BACKSPACE:
|
||||
retval = sc_seq_or(DO_BACKSPACE, *kbinput);
|
||||
retval = sc_seq_or(do_backspace, *kbinput);
|
||||
break;
|
||||
#ifdef KEY_SDC
|
||||
/* Slang doesn't support KEY_SDC. */
|
||||
case KEY_SDC:
|
||||
if (ISSET(REBIND_DELETE))
|
||||
retval = sc_seq_or(DO_DELETE, *kbinput);
|
||||
retval = sc_seq_or(do_delete, *kbinput);
|
||||
else
|
||||
retval = sc_seq_or(DO_BACKSPACE, *kbinput);
|
||||
retval = sc_seq_or(do_backspace, *kbinput);
|
||||
break;
|
||||
#endif
|
||||
#ifdef KEY_SIC
|
||||
/* Slang doesn't support KEY_SIC. */
|
||||
case KEY_SIC:
|
||||
retval = sc_seq_or(DO_INSERTFILE_VOID, *kbinput);
|
||||
retval = sc_seq_or(do_insertfile_void, *kbinput);
|
||||
break;
|
||||
#endif
|
||||
case KEY_C3: /* PageDown (4) on numeric keypad with
|
||||
* NumLock off. */
|
||||
retval = sc_seq_or(DO_PAGE_DOWN, *kbinput);
|
||||
retval = sc_seq_or(do_page_down, *kbinput);
|
||||
break;
|
||||
case KEY_A3: /* PageUp (9) on numeric keypad with
|
||||
* NumLock off. */
|
||||
retval = sc_seq_or(DO_PAGE_UP, *kbinput);
|
||||
retval = sc_seq_or(do_page_up, *kbinput);
|
||||
break;
|
||||
case KEY_ENTER:
|
||||
retval = sc_seq_or(DO_ENTER, *kbinput);
|
||||
retval = sc_seq_or(do_enter_void, *kbinput);
|
||||
break;
|
||||
case KEY_B2: /* Center (5) on numeric keypad with
|
||||
* NumLock off. */
|
||||
@@ -575,7 +575,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
/* HP-UX 10-11 and Slang don't support KEY_SEND. */
|
||||
case KEY_SEND:
|
||||
#endif
|
||||
retval = sc_seq_or(DO_END, *kbinput);
|
||||
retval = sc_seq_or(do_end, *kbinput);
|
||||
break;
|
||||
#ifdef KEY_BEG
|
||||
/* Slang doesn't support KEY_BEG. */
|
||||
@@ -591,7 +591,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
/* Slang doesn't support KEY_SCANCEL. */
|
||||
case KEY_SCANCEL:
|
||||
#endif
|
||||
retval = first_sc_for(currmenu, CANCEL_MSG)->seq;
|
||||
retval = first_sc_for(currmenu, do_cancel)->seq;
|
||||
break;
|
||||
#endif
|
||||
#ifdef KEY_SBEG
|
||||
@@ -604,13 +604,13 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
#ifdef KEY_SSUSPEND
|
||||
/* Slang doesn't support KEY_SSUSPEND. */
|
||||
case KEY_SSUSPEND:
|
||||
retval = sc_seq_or(DO_SUSPEND_VOID, 0);
|
||||
retval = sc_seq_or(do_suspend_void, 0);
|
||||
break;
|
||||
#endif
|
||||
#ifdef KEY_SUSPEND
|
||||
/* Slang doesn't support KEY_SUSPEND. */
|
||||
case KEY_SUSPEND:
|
||||
retval = sc_seq_or(DO_SUSPEND_VOID, 0);
|
||||
retval = sc_seq_or(do_suspend_void, 0);
|
||||
break;
|
||||
#endif
|
||||
#ifdef PDCURSES
|
||||
@@ -758,15 +758,15 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
retval = KEY_B2;
|
||||
break;
|
||||
case 'F': /* Esc O F == End on xterm/Terminal. */
|
||||
retval = sc_seq_or(DO_END, 0);
|
||||
retval = sc_seq_or(do_end, 0);
|
||||
break;
|
||||
case 'H': /* Esc O H == Home on xterm/Terminal. */
|
||||
retval = sc_seq_or(DO_HOME, 0);;
|
||||
retval = sc_seq_or(do_home, 0);;
|
||||
break;
|
||||
case 'M': /* Esc O M == Enter on numeric keypad with
|
||||
* NumLock off on VT100/VT220/VT320/xterm/
|
||||
* rxvt/Eterm. */
|
||||
retval = sc_seq_or(DO_HOME, 0);;
|
||||
retval = sc_seq_or(do_home, 0);;
|
||||
break;
|
||||
case 'P': /* Esc O P == F1 on VT100/VT220/VT320/Mach
|
||||
* console. */
|
||||
@@ -831,7 +831,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case 'n': /* Esc O n == Delete (.) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
* xterm/rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_DELETE, 0);;
|
||||
retval = sc_seq_or(do_delete, 0);;
|
||||
break;
|
||||
case 'o': /* Esc O o == '/' on numeric keypad with
|
||||
* NumLock off on VT100/VT220/VT320/xterm/
|
||||
@@ -841,27 +841,27 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case 'p': /* Esc O p == Insert (0) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
* rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_INSERTFILE_VOID, 0);;
|
||||
retval = sc_seq_or(do_insertfile_void, 0);;
|
||||
break;
|
||||
case 'q': /* Esc O q == End (1) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
* rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_END, 0);;
|
||||
retval = sc_seq_or(do_end, 0);;
|
||||
break;
|
||||
case 'r': /* Esc O r == Down (2) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
* rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_DOWN_VOID, 0);;
|
||||
retval = sc_seq_or(do_down_void, 0);;
|
||||
break;
|
||||
case 's': /* Esc O s == PageDown (3) on numeric
|
||||
* keypad with NumLock off on VT100/VT220/
|
||||
* VT320/rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_PAGE_DOWN, 0);;
|
||||
retval = sc_seq_or(do_page_down, 0);;
|
||||
break;
|
||||
case 't': /* Esc O t == Left (4) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
* rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_LEFT, 0);;
|
||||
retval = sc_seq_or(do_left, 0);;
|
||||
break;
|
||||
case 'u': /* Esc O u == Center (5) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
@@ -871,22 +871,22 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
case 'v': /* Esc O v == Right (6) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
* rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_RIGHT, 0);
|
||||
retval = sc_seq_or(do_right, 0);
|
||||
break;
|
||||
case 'w': /* Esc O w == Home (7) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
* rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_HOME, 0);
|
||||
retval = sc_seq_or(do_home, 0);
|
||||
break;
|
||||
case 'x': /* Esc O x == Up (8) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
* rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_UP_VOID, 0);
|
||||
retval = sc_seq_or(do_up_void, 0);
|
||||
break;
|
||||
case 'y': /* Esc O y == PageUp (9) on numeric keypad
|
||||
* with NumLock off on VT100/VT220/VT320/
|
||||
* rxvt/Eterm/Terminal. */
|
||||
retval = sc_seq_or(DO_PAGE_UP, 0);
|
||||
retval = sc_seq_or(do_page_up, 0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -980,7 +980,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
break;
|
||||
default: /* Esc [ 1 ~ == Home on
|
||||
* VT320/Linux console. */
|
||||
retval = sc_seq_or(DO_HOME, 0);;
|
||||
retval = sc_seq_or(do_home, 0);;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1031,40 +1031,40 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
default: /* Esc [ 2 ~ == Insert on
|
||||
* VT220/VT320/Linux console/
|
||||
* xterm/Terminal. */
|
||||
retval = sc_seq_or(DO_INSERTFILE_VOID, 0);;
|
||||
retval = sc_seq_or(do_insertfile_void, 0);;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '3': /* Esc [ 3 ~ == Delete on VT220/VT320/
|
||||
* Linux console/xterm/Terminal. */
|
||||
retval = sc_seq_or(DO_DELETE, 0);;
|
||||
retval = sc_seq_or(do_delete, 0);;
|
||||
break;
|
||||
case '4': /* Esc [ 4 ~ == End on VT220/VT320/Linux
|
||||
* console/xterm. */
|
||||
retval = sc_seq_or(DO_END, 0);;
|
||||
retval = sc_seq_or(do_end, 0);;
|
||||
break;
|
||||
case '5': /* Esc [ 5 ~ == PageUp on VT220/VT320/
|
||||
* Linux console/xterm/Terminal;
|
||||
* Esc [ 5 ^ == PageUp on Eterm. */
|
||||
retval = sc_seq_or(DO_PAGE_UP, 0);;
|
||||
retval = sc_seq_or(do_page_up, 0);;
|
||||
break;
|
||||
case '6': /* Esc [ 6 ~ == PageDown on VT220/VT320/
|
||||
* Linux console/xterm/Terminal;
|
||||
* Esc [ 6 ^ == PageDown on Eterm. */
|
||||
retval = sc_seq_or(DO_PAGE_DOWN, 0);;
|
||||
retval = sc_seq_or(do_page_down, 0);;
|
||||
break;
|
||||
case '7': /* Esc [ 7 ~ == Home on rxvt. */
|
||||
retval = sc_seq_or(DO_HOME, 0);
|
||||
retval = sc_seq_or(do_home, 0);
|
||||
break;
|
||||
case '8': /* Esc [ 8 ~ == End on rxvt. */
|
||||
retval = sc_seq_or(DO_END, 0);
|
||||
retval = sc_seq_or(do_end, 0);
|
||||
break;
|
||||
case '9': /* Esc [ 9 == Delete on Mach console. */
|
||||
retval = sc_seq_or(DO_DELETE, 0);;
|
||||
retval = sc_seq_or(do_delete, 0);;
|
||||
break;
|
||||
case '@': /* Esc [ @ == Insert on Mach console. */
|
||||
retval = sc_seq_or(DO_INSERTFILE_VOID, 0);;
|
||||
retval = sc_seq_or(do_insertfile_void, 0);;
|
||||
break;
|
||||
case 'A': /* Esc [ A == Up on ANSI/VT220/Linux
|
||||
* console/FreeBSD console/Mach console/
|
||||
@@ -1087,23 +1087,23 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
break;
|
||||
case 'F': /* Esc [ F == End on FreeBSD
|
||||
* console/Eterm. */
|
||||
retval = sc_seq_or(DO_END, 0);
|
||||
retval = sc_seq_or(do_end, 0);
|
||||
break;
|
||||
case 'G': /* Esc [ G == PageDown on FreeBSD
|
||||
* console. */
|
||||
retval = sc_seq_or(DO_PAGE_DOWN, 0);
|
||||
retval = sc_seq_or(do_page_down, 0);
|
||||
break;
|
||||
case 'H': /* Esc [ H == Home on ANSI/VT220/FreeBSD
|
||||
* console/Mach console/Eterm. */
|
||||
retval = sc_seq_or(DO_HOME, 0);
|
||||
retval = sc_seq_or(do_home, 0);
|
||||
break;
|
||||
case 'I': /* Esc [ I == PageUp on FreeBSD
|
||||
* console. */
|
||||
retval = sc_seq_or(DO_PAGE_UP, 0);
|
||||
retval = sc_seq_or(do_page_up, 0);
|
||||
break;
|
||||
case 'L': /* Esc [ L == Insert on ANSI/FreeBSD
|
||||
* console. */
|
||||
retval = sc_seq_or(DO_INSERTFILE_VOID, 0);
|
||||
retval = sc_seq_or(do_insertfile_void, 0);
|
||||
break;
|
||||
case 'M': /* Esc [ M == F1 on FreeBSD console. */
|
||||
retval = KEY_F(1);
|
||||
@@ -1151,10 +1151,10 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
retval = KEY_F(8);
|
||||
break;
|
||||
case 'U': /* Esc [ U == PageDown on Mach console. */
|
||||
retval = sc_seq_or(DO_PAGE_DOWN, 0);
|
||||
retval = sc_seq_or(do_page_down, 0);
|
||||
break;
|
||||
case 'V': /* Esc [ V == PageUp on Mach console. */
|
||||
retval = sc_seq_or(DO_PAGE_UP, 0);
|
||||
retval = sc_seq_or(do_page_up, 0);
|
||||
break;
|
||||
case 'W': /* Esc [ W == F11 on FreeBSD console. */
|
||||
retval = KEY_F(11);
|
||||
@@ -1163,7 +1163,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
retval = KEY_F(12);
|
||||
break;
|
||||
case 'Y': /* Esc [ Y == End on Mach console. */
|
||||
retval = sc_seq_or(DO_END, 0);
|
||||
retval = sc_seq_or(do_end, 0);
|
||||
break;
|
||||
case 'Z': /* Esc [ Z == F14 on FreeBSD console. */
|
||||
retval = KEY_F(14);
|
||||
@@ -1220,13 +1220,13 @@ int get_escape_seq_abcd(int kbinput)
|
||||
{
|
||||
switch (tolower(kbinput)) {
|
||||
case 'a':
|
||||
return sc_seq_or(DO_UP_VOID, 0);;
|
||||
return sc_seq_or(do_up_void, 0);;
|
||||
case 'b':
|
||||
return sc_seq_or(DO_DOWN_VOID, 0);;
|
||||
return sc_seq_or(do_down_void, 0);;
|
||||
case 'c':
|
||||
return sc_seq_or(DO_RIGHT, 0);;
|
||||
return sc_seq_or(do_right, 0);;
|
||||
case 'd':
|
||||
return sc_seq_or(DO_LEFT, 0);;
|
||||
return sc_seq_or(do_left, 0);;
|
||||
default:
|
||||
return ERR;
|
||||
}
|
||||
@@ -1746,7 +1746,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||
* wheel is equivalent to moving down three lines. */
|
||||
for (i = 0; i < 3; i++)
|
||||
unget_kbinput((mevent.bstate & BUTTON4_PRESSED) ?
|
||||
sc_seq_or(DO_UP_VOID, 0) : sc_seq_or(DO_DOWN_VOID, 0), FALSE,
|
||||
sc_seq_or(up_void, 0) : sc_seq_or(DO_DOWN_VOID, 0), FALSE,
|
||||
FALSE);
|
||||
|
||||
return 1;
|
||||
@@ -1800,7 +1800,7 @@ const sc *get_shortcut(int menu, int *kbinput, bool
|
||||
|
||||
|
||||
/* Try to get a function back from a window. Just a wrapper so
|
||||
functions to need to create function_key meta_key blah blah
|
||||
functions to need to create function_key meta_key blah blah
|
||||
mmenu - what menu name to look through for valid funcs */
|
||||
const subnfunc *getfuncfromkey(WINDOW *win)
|
||||
{
|
||||
@@ -2258,6 +2258,17 @@ void set_modified(void)
|
||||
if (!openfile->modified) {
|
||||
openfile->modified = TRUE;
|
||||
titlebar(NULL);
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING)) {
|
||||
if (openfile->lock_filename == NULL) {
|
||||
/* Translators: Try to keep this at most 80 characters. */
|
||||
statusbar(_("Warning: Modifying a file which is not locked, check directory permission?"));
|
||||
} else {
|
||||
write_lockfile(openfile->lock_filename,
|
||||
get_full_path(openfile->filename), TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3124,8 +3135,6 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
fprintf(stderr, "edit_redraw(): line %lu was offscreen, oldcurrent = %lu edittop = %lu", openfile->current->lineno,
|
||||
old_current->lineno, openfile->edittop->lineno);
|
||||
#endif
|
||||
filestruct *old_edittop = openfile->edittop;
|
||||
ssize_t nlines;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the mark is on, update all the lines between old_current
|
||||
@@ -3133,6 +3142,7 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
* whether we've scrolled up or down) of the edit window. */
|
||||
if (openfile->mark_set) {
|
||||
ssize_t old_lineno;
|
||||
filestruct *old_edittop = openfile->edittop;
|
||||
|
||||
if (old_edittop->lineno < openfile->edittop->lineno)
|
||||
old_lineno = old_edittop->lineno;
|
||||
|
||||
Reference in New Issue
Block a user