Compare commits
93 Commits
v2.1.99pre
...
v2.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
a2c5172db3 | ||
|
|
29e2012267 | ||
|
|
c859049041 | ||
|
|
db9d983646 | ||
|
|
181c4a999b | ||
|
|
053fabd4e1 | ||
|
|
ad8476eb7d | ||
|
|
7f61a6cb79 | ||
|
|
dbbf9a052f | ||
|
|
83a0e9013e | ||
|
|
e68616b799 | ||
|
|
9e73aeb10f | ||
|
|
0d1381adf9 | ||
|
|
cdb5b16198 | ||
|
|
35b5976e69 | ||
|
|
fe2042da8a | ||
|
|
091d5f3b0a | ||
|
|
08273aa1b2 | ||
|
|
b5e7647028 | ||
|
|
42bd871af3 | ||
|
|
f81d6fe8d3 | ||
|
|
1456a10ace | ||
|
|
8ff7f33c52 | ||
|
|
3eacb857a1 | ||
|
|
2466d933c9 | ||
|
|
4e621b5f6b | ||
|
|
b916f5cd8b | ||
|
|
6cf05d487f | ||
|
|
1a7a91b779 | ||
|
|
df8c3debc8 | ||
|
|
374216fe22 | ||
|
|
fc6ef3e1e8 | ||
|
|
8d41fb8c3e | ||
|
|
3c7dda6e7e | ||
|
|
869aca4392 | ||
|
|
d9be86f45b | ||
|
|
9c0716a73a | ||
|
|
560a8cd0ec | ||
|
|
a8bc492b8a | ||
|
|
f387f33083 | ||
|
|
2c7b506fbc | ||
|
|
5b25e07744 | ||
|
|
b27b3a18a9 | ||
|
|
96466166f1 | ||
|
|
671b2d974c | ||
|
|
c9f0799791 | ||
|
|
42a390416e | ||
|
|
8a07a96eef | ||
|
|
a97cb819f2 | ||
|
|
cb9a5bed8e | ||
|
|
b43f6912f3 | ||
|
|
5a018f0d3a | ||
|
|
752830573a | ||
|
|
daaf468c93 | ||
|
|
dcf5cbbf6a | ||
|
|
3b830ee194 | ||
|
|
d753efdb55 | ||
|
|
c9199e9e9a | ||
|
|
e2df2c899d | ||
|
|
c82f038855 | ||
|
|
8b6f6fcc1b | ||
|
|
0bff84ef9c | ||
|
|
6277f59d24 |
2
BUGS
2
BUGS
@@ -1,5 +1,4 @@
|
||||
** Open BUGS **
|
||||
- Cutting the line at the top of the screen recenters to center (71)
|
||||
|
||||
** Fixed BUGS **
|
||||
- Marked cutting sometimes leaves a newline in the file unintelligently,
|
||||
@@ -156,6 +155,7 @@
|
||||
assigned to it (79 - may not be worth fixing) [FIXED]
|
||||
- Segfault editing at COLS presumably due to new color syntax
|
||||
highlighting (80) [FIXED]
|
||||
- Cutting the line at the top of the screen recenters to center (71) [FIXED]
|
||||
|
||||
|
||||
$Id$
|
||||
|
||||
306
ChangeLog
306
ChangeLog
@@ -1,3 +1,309 @@
|
||||
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
|
||||
that a sufficient security fix exists for the backup file code.
|
||||
|
||||
2010-04-14 Chris Allegretta <chrisa@asty.org>
|
||||
* text.c (do_alt_speller): Skip invoking the alt speller if the file size
|
||||
is 0 bytes. Fixes Savannah bug 29393 reported by Mike Frysinger.
|
||||
* files.c (wirte_file): Don't set current_stat when tmp == TRUE, check
|
||||
whether current_stat is set when trying to use it, and don't do the
|
||||
modification check if the filename changed, since we have no way
|
||||
of knowing about it in that case. Fixes Savannah bug 29392, reported
|
||||
by Mike Frysinger. [CVE-2010-1160]
|
||||
|
||||
2010-04-13 Felipe Bugno <necron@bol.com.br>
|
||||
* doc/syntax/cmake.nanorc: Added cmake syntax highlighting file.
|
||||
|
||||
2010-04-09 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (do_writeout): Better security fixes for backup file writing,
|
||||
mangled from submission by Dan Rosenberg <dan.j.rosenberg at gmail>
|
||||
[CVE-2010-1161]
|
||||
|
||||
2010-04-08 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (do_writeout): Previous fixes should not cause a crash
|
||||
when saving a new file. Discovered by Mike Frysinger <vapier@gentoo.org>.
|
||||
|
||||
2010-04-07 Chris Allegretta <chrisa@asty.org>
|
||||
* doc/man/nano.1,nanorc.5: Add warnings about using backup
|
||||
mode as root due to the Dan Rosenberg security analysis.
|
||||
|
||||
2010-04-02 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (do_writeout): Expand modification check to include both the
|
||||
original file's device ID and inode number as reasons to warn the
|
||||
user that the file has been modified. Also abort on writing a backup
|
||||
file when its owner doesn't match the edited file. Based on security
|
||||
analysis on nano by Dan Rosenberg. [CVE-2010-1160]
|
||||
|
||||
|
||||
2010-03-21 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (page_stdin et al): Don't attempt to reset/reopen the terminal
|
||||
settings when reading stdin if it was aborted with SIGINT. May fix Savannah
|
||||
bug 29114 reported by Mike Frysinger.
|
||||
|
||||
2010-03-21 Mike Frysinger <vapier@gentoo.org>
|
||||
* doc/syntax/c.nanorc: Add additional support for #include_next and #pragma
|
||||
|
||||
2010-03-21 Chris Allegretta <chrisa@asty.org>
|
||||
* move.c (do_page_up, do_page_down()): Explicitly set current_y to 0 when paging
|
||||
up when not in smooth scroll mode, as previous fixes would otherwise cause
|
||||
the cursor to not really be moved to the stop of the screen.
|
||||
|
||||
2010-03-07 Chris Allegretta <chrisa@asty.org>
|
||||
* configure.ac, nano.c (handle_sigwinch): Create check for whether LINES and
|
||||
COLS can safely be redefined. Fixes compilation issues with cygwin, and likely
|
||||
with newer versions of ncurses, fixes Savannah bug 28984 repoted by Andy Koppe
|
||||
and Eric Oliver via mailing list.
|
||||
* winio.c (get_mouseinput) - fix stray semicolon in code, also reported in
|
||||
bug 28984.
|
||||
|
||||
GNU nano 2.2.3 - 2010.02.11
|
||||
2010-01-28 Chris Allegretta <chrisa@asty.org>
|
||||
* move.c (do_page_up, do_page_down): Fix for smooth mode not preserving cusor
|
||||
position. Part one of fix for Savannah bug 21178 by Mike Frysinger.
|
||||
|
||||
GNU nano 2.2.2 - 2010.01.17
|
||||
2010-01-17 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (main), prompt.c (do_statusbar_input): Handle problems with an unmapped
|
||||
function due to key rebinding, fixes crashes on FreeBSD repoted by Eitan
|
||||
Adler <eitanadlerlist@gmail.com>.
|
||||
|
||||
2010-01-14 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (do_writeout): Fix for crash / incorrect external modification warning
|
||||
due to earlier fix in r4467.
|
||||
|
||||
2010-01-12 Chris Allegretta <chrisa@asty.org>
|
||||
* move.c (do_page_up, do_page_down): Fix issues with not enough scrolling down/up
|
||||
and cursor centering.
|
||||
* winio.c (edit_scroll): Remove lots of needless checking of line length for
|
||||
soft wrapping code.
|
||||
* winio.c (edit_update) - Remove extra code for when updating with old_current outside
|
||||
of the new buffer boundary and centering issues.
|
||||
|
||||
2010-01-05 Tito <farmatito@tiscali.it>
|
||||
* search.c (update_history): Fix bad length check causing search crash on armel platform.
|
||||
|
||||
2010-01-04 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c: edit_update, edit_redraw: Fix search not scrolling to the middle of the screen
|
||||
(reported by alpha@qzx.com) and places where we rely on maxrows but should not.
|
||||
|
||||
2009-12-26 Jordi Mallach <jordi@gnu.org>
|
||||
* doc/man/nano.1: Avoid a groff warning by prepending a zero-width
|
||||
space to a line starting with '.
|
||||
|
||||
2009-12-22 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (write_file): Fix compatibility with previous stat fix and tiny mode.
|
||||
|
||||
2009-12-22 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* global.c: Add new strings for forward/back in the file browser. New variables
|
||||
nano_forwardfile_msg and nano_backfile_msg.
|
||||
|
||||
2009-12-20 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (is_file_writable): remove assert check for f, since it's not
|
||||
initialized at the time. Fixes Savannah bug 28309, reported by Zoltan Kovacs.
|
||||
|
||||
2009-12-20 Brian Szymanski <skibrianski via Savannah>
|
||||
* src/files.c (write_file): Check stat struct exists, and if not use just obtained stat data.
|
||||
Fixes Ubuntu bug 471568, "reproducible crash in nano on trying to save to a file
|
||||
different than the one specified on the command line".
|
||||
|
||||
2009-12-15 Chris Allegretta <chrisa@asty.org>
|
||||
* doc/nanorc.sample.in - Remove erroneous 'set suspendenable' as it's actually a
|
||||
key binding (e.g. 'bind M-Z suspendenable all') and not a settable flag. Fixes
|
||||
Savannah bug 28299 reported by Mike Frysinger.
|
||||
|
||||
GNU nano 2.2.1 - 2009.12.12
|
||||
2009-12-12 Chris Allegretta <chrisa@asty.org>
|
||||
* text.c (do_delete), nano.c (do_output): Add check for length of current line
|
||||
before and after adding/deleting text, and do full refresh if it is now
|
||||
a different multiple of COLS. Also get rid of superfluous do_refresh
|
||||
vars now that we have edit_refresh_needed.
|
||||
|
||||
2009-12-09 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* global.c (shortcut_init), browser.c (do_browser): Fix M-W not being bound to
|
||||
research in either main menu or browser.
|
||||
|
||||
2009-12-09 Chris Allegretta <chrisa@asty.org>
|
||||
* files.c (read_file) - Add parameter for whether we should even try to check
|
||||
file writability, as the message is useless when we're inserting into an
|
||||
existing buffer. Fixes Savannah bug 28219.
|
||||
|
||||
2009-12-07 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* global.c (shortcut_init): Many fixes for keybindings code oversights, including
|
||||
restore page up/down and GotoDir to browser,
|
||||
* browser.c (do_browser): Fix breaking out of a submenu (e.g. gotodir) breaks out
|
||||
of browser altogether.
|
||||
* doc/nanorc.sample.in: Add missing entries for fortran/ObjC/OCaml entries.
|
||||
|
||||
2009-12-03 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* global.c (shortcut_init) - Remove help shortcut from help shortcut list :-) Tweaked
|
||||
to reorder exit shortcut to end of list to not mess up prev/next shortcut symmetry.
|
||||
|
||||
2009-12-03 Eitan Adler <eitanadlerlist@gmail.com>
|
||||
* doc/syntax/makefile.nanorc - Fix poor regex for all alpha characters which sometimes leads to
|
||||
error messages, reported by gibboris@gmail.com.
|
||||
|
||||
2009-12-02 Chris Allegretta <chrisa@asty.org>
|
||||
* text.c (add_undo, do_undo, do_redo) - Do not execute cases for SPLIT when DISABLE_WRAPPING
|
||||
is defined. Fixes Savannah bug 28151 (anon).
|
||||
|
||||
2009-12-02 Jordi Mallach <jordi@gnu.org>
|
||||
* doc/man/nano.1: Fix escaping of hyphens for the -$ option.
|
||||
|
||||
2009-12-01 Kamil Dudka <kdudka@redhat.com>
|
||||
* chars.c, file.c - Better handle unused results for things like mbtowc(), new
|
||||
macro IGNORE_CALL_RESULT.
|
||||
|
||||
2009-12-01 Chris Allegretta <chrisa@asty.org>
|
||||
* global.c (shortcut_init) - Remove redundant entries for ^Y/^V reported by
|
||||
Christian Weisgerber.
|
||||
* doc/man/nanorc.5 - Fix typo in Meta documentation, reported by gibboris@gmail.com.
|
||||
|
||||
2009-12-01 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* global.c (shortcut_init) - Add support for ^P and ^N in the help menu.
|
||||
* Update documentation for 2.2 features including sample nanorc file, texinfo
|
||||
file, man pages, UPGRADE file, and update copyright noticed for the current year.
|
||||
|
||||
GNU nano 2.2.0 - 2009.11.30
|
||||
2009-11-29 Chris Allegretta <chrisa@asty.org>
|
||||
* prompt.c (get_prompt_string) - Universally handle help key when is
|
||||
disabled. Fixes Savannah
|
||||
bug 28117 by David Lawrence Ramsey <pooka109@gmail.com>.
|
||||
* chars.c, files.c: Add junk vars to silence the compiler. Sigh.
|
||||
|
||||
2009-11-29 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* Change several *chars to const char, additional cleanups and casts to make compilers happier.
|
||||
* global.c: Fix replace and insert file initializations for proper compilation options.
|
||||
* nano.c (do_suspend): Update comments to reflect actual code path, bad Chris and thanks for
|
||||
noticing Jordi.
|
||||
* configure.ac: Fix typos
|
||||
|
||||
2009-11-27 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (do_suspend): Don't clear the screen but do move the cursor down to the last line
|
||||
first in an effort to not corrupt the screen, which contradicts Pico but is consistent
|
||||
with almost all other text editors. Fixes Savannah bug 28110/Debian bug 460510
|
||||
reported by Tim Connors <reportbug@rather.puzzling.org>.
|
||||
* doc/dyntax/makefile.nanorc - Sample Makefile highlighting based on wiki.linuxhelp.net version.
|
||||
|
||||
2009-11-26 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c (edit_scroll): Adjust for long lines when scrolling.
|
||||
* rcfile.c (parse_rcfile), initialize size argument to getline(), fixes crash on FreeBSD
|
||||
reported by Eitan Adler <eitanadlerlist@gmail.com>.
|
||||
|
||||
2009-11-26 Jordi Mallach <jordi@gnu.org>
|
||||
* doc/man/*: Update all man pages to escape unescaped hyphens.
|
||||
|
||||
2009-11-24 Chris Allegretta <chrisa@asty.org>
|
||||
* move.c (do_page_up, do_page_down): Make these functions work better with soft
|
||||
line wrapping.
|
||||
* winio.c (compute_maxrows): Make maxrows calculation more accurate when all lines are > COLS.
|
||||
|
||||
2009-11-22 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (main): Allow edit_refresh_needed to take effect when using --enable-tiny
|
||||
(fixes Savannah bug 28076 reported by David Lawrence Ramsey).
|
||||
|
||||
2009-11-22 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* nano.c (move_to_filestruct): Fix bug 71 (cut at top of line recenters)
|
||||
* Fix compilation with --enable-tiny
|
||||
|
||||
2009-11-22 Mike Frysinger <vapier@gentoo.org>
|
||||
* doc/syntax/gentoo.nanorc: Tweak comment highlighting.
|
||||
|
||||
GNU nano 2.1.99pre2 - 2009.11.21
|
||||
2009-11-21 Chris Allegretta <chrisa@asty.org>
|
||||
* rcfile.c: Add unbinding keyword, fixes Savannah bug 22852 reported by frankd.
|
||||
|
||||
107
NEWS
107
NEWS
@@ -1,3 +1,110 @@
|
||||
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
|
||||
on open files. The CVEs fixed with this release are
|
||||
CVE-2010-1160 and CVE-2010-1161. Also included are fixes
|
||||
for various crash modes when using the spell checker
|
||||
on new files in multibuffer mode (surely you've used
|
||||
that combination recently? No?) as well as a fixing
|
||||
the 'file was modified' message when saving to a
|
||||
new filename (since how would nano know?). And
|
||||
the list would not be complete without our
|
||||
third-times-the-charm fixes to page up/down due to
|
||||
the soft wrapping code. The lone new feature
|
||||
included is a new syntax higlighting definition for
|
||||
cmake-related files. Please do consider upgrading to
|
||||
this release if still using the 2.0 series since
|
||||
fixes for that version are still forthcoming.
|
||||
|
||||
|
||||
2010.02.11 - GNU nano 2.2.3 "fumbling toward stability" is released.
|
||||
This release contains a fix for only one bug, but a
|
||||
rather irritating one: when paging up/down with smooth
|
||||
scrolling, the cursor position was not being preserved
|
||||
due to a bug in 2.2.2. With such a targeted fix
|
||||
like this what could POSSIBLY go WRONG? Hahaha.
|
||||
Enjoy and if you find new bugs, as always please
|
||||
use Savannah's bug tracker.
|
||||
http://savannah.gnu.org/bugs/?func=additem&group=nano
|
||||
|
||||
2010.01.17 - GNU nano 2.2.2 is released for you, you, you. This
|
||||
release includes fixes for: crashed when writing
|
||||
backup files in certain conditions, improper
|
||||
screen centering when moving up/down in various
|
||||
combination of smooth scrolling and soft wrapping modes,
|
||||
a search crash on the armel arch, and issues with
|
||||
lots of keybinding customizations causing crashing
|
||||
particularly on FreeBSD. Also included are better
|
||||
help menu entries for forward/back in the file browser,
|
||||
some man page tweaks and one assert fix. As always,
|
||||
share and enjoy!
|
||||
|
||||
2009.12.12 - GNU nano 2.2.1 "DLR strikes back" is open for business.
|
||||
This release fixes many bugs, including: missing
|
||||
keybindings for page up/down and GotoDir in the browser,
|
||||
^P/^N in the help menu, and restoration of M-W as the
|
||||
default re-search binding. Other fixes include several
|
||||
issues with compiler warnings and configure options, and
|
||||
documentation updates, including the nano texinfo manual,
|
||||
nano and nanorc man pages, and UPGRADE file, and some
|
||||
missing syntax highliting entries for the saple nanorc.
|
||||
And no release would be complete without the latest round
|
||||
of 'final' soft wrapping fixes! Finally, nano will no
|
||||
longer print a warning when attempting to insert the
|
||||
contents of a read-only file into an existing buffer.
|
||||
Enjoy and Happy Hanukkah.
|
||||
|
||||
|
||||
2009.11.30 - GNU nano 2.2.0 "Doc Brown" is released! The culmination
|
||||
of almost two years of development and hot on the heels
|
||||
of nano's 10th birthday is available for all your
|
||||
editing needs! Bugs fixed since the last release
|
||||
include several fixes for tiny mode (involving both
|
||||
the help keys and replace menu text), more 'final'
|
||||
fixes for soft wrapping, and several typo and documentation
|
||||
updates including nanorc tweaks and a new syntax
|
||||
highlighting file for makefiles. Also included is a long
|
||||
standing fix for random crashing when using nanorc on
|
||||
FreeBSD, and nano will no longer clear the screen on
|
||||
suspend to maintain compatibility with other *nix editors.
|
||||
For those who haven't been playing along at home, please
|
||||
see the official web page for the summary of new
|
||||
features since 2.0. Special thanks to all who have
|
||||
submitted bug reports recently in support of our new
|
||||
stable release, and apologies for all those bugs we
|
||||
didn't yet find :-) Peace to all.
|
||||
|
||||
2009.11.21 - GNU nano 2.1.99pre2 is available for a special pre-Black
|
||||
Friday discount. Included are some (hopefully
|
||||
final) fixes for issues with last page display
|
||||
|
||||
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.
|
||||
|
||||
16
UPGRADE
16
UPGRADE
@@ -1,6 +1,22 @@
|
||||
GNU nano upgrading information
|
||||
==============================
|
||||
|
||||
Visible changes since 2.0
|
||||
-------------------------
|
||||
* Editor Features
|
||||
- The ability to rebind (reassign) keys using the nanorc.
|
||||
- The ability to read standard input like a pager ("nano -").
|
||||
- Color syntax highlighting can be set by the first line of a file.
|
||||
- The ability to silence nanorc error messages (-q).
|
||||
- Undo/redo operations (-u).
|
||||
- Soft wrapping of text (-$).
|
||||
|
||||
* File Handling
|
||||
- Better handling of backup files: if nano can't write a backup file,
|
||||
it won't try to write the original file afterward.
|
||||
- Emergency savefiles retain ownerships and permissions when possible.
|
||||
- Performance improvements in color syntax highlighting.
|
||||
|
||||
Visible changes since 1.2
|
||||
-------------------------
|
||||
* Editor Features
|
||||
|
||||
22
configure.ac
22
configure.ac
@@ -20,7 +20,7 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [2.1.99pre2], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.3.1], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_TARGET([])
|
||||
AM_INIT_AUTOMAKE
|
||||
@@ -50,7 +50,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.
|
||||
|
||||
@@ -191,7 +191,7 @@ fi],
|
||||
AC_ARG_ENABLE(all,
|
||||
[ --enable-all Enable ALL extra nano functionality (ignored for compatibility as all options default to on)],
|
||||
[if test x$enableval = xyes; then
|
||||
echo "--enable-all option no longer needed, ignoring for compatiblity"
|
||||
echo "--enable-all option no longer needed, ignoring for compatibility"
|
||||
fi])
|
||||
|
||||
AC_MSG_CHECKING([whether to enable UTF-8 support])
|
||||
@@ -569,6 +569,22 @@ int main(void)
|
||||
fi
|
||||
#fi
|
||||
|
||||
AC_MSG_CHECKING([whether LINES and COLS can be redefined])
|
||||
AC_TRY_RUN([
|
||||
#include <curses.h>
|
||||
int main(void)
|
||||
{
|
||||
LINES = 80;
|
||||
COLS = 25;
|
||||
return 0;
|
||||
}],
|
||||
AC_DEFINE(REDEFINIG_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug])
|
||||
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])
|
||||
groff -t -mandoc -Thtml </dev/null >/dev/null
|
||||
|
||||
31
doc/faq.html
31
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>
|
||||
@@ -83,9 +85,9 @@
|
||||
<h2><a name="1.5"></a>1.5. Why the name change from TIP?</h2>
|
||||
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program "establishes a full duplex terminal connection to a remote host", and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
|
||||
<h2><a name="1.6"></a>1.6. What is the current version of nano?</h2>
|
||||
<blockquote><p>The current version of nano *should* be 2.0.7. Of course, you should always check the nano homepage to see what the latest and greatest version is.</p></blockquote>
|
||||
<blockquote><p>The current version of nano *should* be 2.2.0. Of course, you should always check the nano homepage to see what the latest and greatest version is.</p></blockquote>
|
||||
<h2><a name="1.7"></a>1.7. I want to read the man page without having to download the program!</h2>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="http://www.nano-editor.org/dist/v2.0/nano.1.html">here</a>.</p></blockquote>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="http://www.nano-editor.org/dist/v2.2/nano.1.html">here</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
<h1><a name="2"></a>2. Where to get GNU nano.</h1>
|
||||
<h2><a name="2.1"></a>2.1. FTP and WWW sites that carry nano.</h2>
|
||||
@@ -99,8 +101,8 @@
|
||||
<h2><a name="2.2"></a>2.2. RedHat and derivatives (.rpm) packages.</h2>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li><a href="http://www.nano-editor.org/dist/v2.0/RPMS/">http://www.nano-editor.org/dist/v2.0/RPMS/</a></li>
|
||||
<li><a href="http://www.ewtoo.org/~astyanax/nano/dist/v2.0/RPMS/">http://www.ewtoo.org/~astyanax/nano/dist/v2.0/RPMS/</a></li>
|
||||
<li><a href="http://www.nano-editor.org/dist/v2.2/RPMS/">http://www.nano-editor.org/dist/v2.2/RPMS/</a></li>
|
||||
<li><a href="http://www.ewtoo.org/~astyanax/nano/dist/v2.2/RPMS/">http://www.ewtoo.org/~astyanax/nano/dist/v2.2/RPMS/</a></li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<h2><a name="2.3"></a>2.3. Debian (.deb) packages.</h2>
|
||||
@@ -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>
|
||||
@@ -246,7 +257,7 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
|
||||
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
|
||||
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
|
||||
<h2><a name="7.2"></a>7.2. I want to send the development team a big load of cash (or just a thank you).</h2>
|
||||
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="http://www.nano-editor.org/dist/v2.0/BUGS">bug</a> in the program or implement a <a href="http://www.nano-editor.org/dist/v2.0/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
|
||||
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="http://www.nano-editor.org/dist/v2.2/BUGS">bug</a> in the program or implement a <a href="http://www.nano-editor.org/dist/v2.2/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
|
||||
<h2><a name="7.3"></a>7.3. How do I submit a bug report or patch?</h2>
|
||||
<blockquote>
|
||||
<p>The best place to submit bugs is to the <A HREF="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</A> as you can check whether the bug you are submitting has already been submitted.
|
||||
@@ -256,8 +267,10 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
|
||||
<h2><a name="7.5"></a>7.5. Can I have write access to the subversion tree?</h2>
|
||||
<blockquote><p>Re-read Section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
|
||||
<h2><a name="8"></a>8. ChangeLog</h2>
|
||||
<blockquote><p>2007/12/21 - Update maintainer information. (DLR)<br>
|
||||
2008/03/16 - Update docs to refer to subversion instead of CVS, add more words about Apline, and refer to Savannah for bugs and patches. (chrisa)
|
||||
<blockquote><p>2009/11/30 - Update various bits for nano 2.2.x. (DLR)<br>
|
||||
2009/11/18 - Typo fix. (j.mader@gmail.com)<br>
|
||||
2008/03/16 - Update docs to refer to subversion instead of CVS, add more words about Alpine, and refer to Savannah for bugs and patches. (chrisa)<br>
|
||||
2007/12/21 - Update maintainer information. (DLR)<br>
|
||||
2007/12/09 - Add minor punctuation and wording fixes, and update various sections to account for Alpine. (DLR)<br>
|
||||
2007/08/26 - Update links to the Free Translation Project. (DLR)<br>
|
||||
2007/07/29 - Update RPM links for nano 2.0.x. (DLR)<br>
|
||||
|
||||
@@ -230,7 +230,7 @@ Passe automatiquement
|
||||
\fIcolonne\fR. Si la valeur indiquée est de 0 ou moins, le point de
|
||||
passage à la ligne aura lieu à la taille de l'écran moins \fIcolonne\fR.
|
||||
Cela permet de faire varier le point de passage à la ligne lorsque l'on
|
||||
change la taille de l'écran. La valeur par défaut est de -8.
|
||||
change la taille de l'écran. La valeur par défaut est de \-8.
|
||||
.TP
|
||||
.B \-s \fIprogramme\fP (\-\-speller=\fIprogramme\fP)
|
||||
Choix d'un correcteur orthographique de remplacement.
|
||||
|
||||
@@ -143,7 +143,7 @@ Passe automatiquement
|
||||
\fIn\fR. Si la valeur indiquée est de 0 ou moins, le point de passage à
|
||||
la ligne aura lieu à la taille de l'écran moins \fIn\fR. Cela permet de
|
||||
faire varier le point de passage à la ligne lorsque l'on change la
|
||||
taille de l'écran. La valeur par défaut est de -8.
|
||||
taille de l'écran. La valeur par défaut est de \-8.
|
||||
.TP
|
||||
.B set/unset historylog
|
||||
Active l'utilisation de
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.\" Hey, EMACS: -*- nroff -*-
|
||||
.\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
.\" Free Software Foundation, Inc.
|
||||
.\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||
.\" 2008, 2009 Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
.\" under the terms of either of the following licenses:
|
||||
@@ -19,7 +19,7 @@
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANO 1 "version 2.0.0" "August 23, 2007"
|
||||
.TH NANO 1 "version 2.2.0" "November 30, 2009"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
@@ -62,7 +62,7 @@ line.
|
||||
.TP
|
||||
.B \-B (\-\-backup)
|
||||
When saving a file, back up the previous version of it to the current
|
||||
filename suffixed with a ~.
|
||||
filename suffixed with a ~.
|
||||
.TP
|
||||
.B \-C \fIdir\fP (\-\-backupdir=\fIdir\fP)
|
||||
Set the directory where \fBnano\fP puts unique backup files if file
|
||||
@@ -79,11 +79,11 @@ Enable multiple file buffers, if available.
|
||||
.TP
|
||||
.B \-H (\-\-historylog)
|
||||
Log search and replace strings to \fI~/.nano_history\fP, so they can be
|
||||
retrieved in later sessions, if nanorc support is available.
|
||||
retrieved in later sessions, if \fInanorc\fP support is available.
|
||||
.TP
|
||||
.B \-I (\-\-ignorercfiles)
|
||||
Don't look at \fISYSCONFDIR/nanorc\fP or \fI~/.nanorc\fP, if nanorc
|
||||
support is available.
|
||||
Don't look at \fISYSCONFDIR/nanorc\fP or \fI~/.nanorc\fP, if
|
||||
\fInanorc\fP support is available.
|
||||
.TP
|
||||
.B \-K (\-\-rebindkeypad)
|
||||
Interpret the numeric keypad keys so that they all work properly. You
|
||||
@@ -107,10 +107,11 @@ Tab.
|
||||
.TP
|
||||
.B \-R (\-\-restricted)
|
||||
Restricted mode: don't read or write to any file not specified on the
|
||||
command line; read any nanorc files; allow suspending; allow a file
|
||||
to be appended to, prepended to, or saved under a different name if it
|
||||
already has one; or use backup files or spell checking. Also accessible
|
||||
by invoking \fBnano\fP with any name beginning with 'r' (e.g. "rnano").
|
||||
command line; read any \fInanorc\fP files; allow suspending; allow a
|
||||
file to be appended to, prepended to, or saved under a different name if
|
||||
it already has one; or use backup files or spell checking. Also
|
||||
accessible by invoking \fBnano\fP with any name beginning with 'r' (e.g.
|
||||
"rnano").
|
||||
.TP
|
||||
.B \-S (\-\-smooth)
|
||||
Enable smooth scrolling. Text will scroll line-by-line, instead of the
|
||||
@@ -173,14 +174,14 @@ Preserve the XON and XOFF sequences (^Q and ^S) so they will be caught
|
||||
by the terminal.
|
||||
.TP
|
||||
.B \-q (\-\-quiet)
|
||||
Do not report errors in the nanorc file and ask them to
|
||||
be acknowledged by pressing enter at startup.
|
||||
Do not report errors in the \fInanorc\fP file and ask them to be
|
||||
acknowledged by pressing Enter at startup.
|
||||
.TP
|
||||
.B \-r \fIcols\fP (\-\-fill=\fIcols\fP)
|
||||
Wrap lines at column \fIcols\fP. If this value is 0 or less, wrapping
|
||||
will occur at the width of the screen less \fIcols\fP columns, allowing
|
||||
the wrap point to vary along with the width of the screen if the screen
|
||||
is resized. The default value is -8.
|
||||
is resized. The default value is \-8.
|
||||
.TP
|
||||
.B \-s \fIprog\fP (\-\-speller=\fIprog\fP)
|
||||
Enable alternative spell checker command.
|
||||
@@ -206,11 +207,11 @@ Disable help screen at bottom of editor.
|
||||
Enable suspend ability.
|
||||
.TP
|
||||
.B \-$ (\-\-softwrap)
|
||||
Enable 'soft wrapping'. Nano will attempt to display lines the entire
|
||||
contents of a line, even if it is longer than the screen width.
|
||||
Since '$' normally refers to a variable in the Unix shell, you should
|
||||
specify this option last when using other options (e.g. 'nano -wS$')
|
||||
or pass it separately (e.g. 'nano -wS -$').
|
||||
Enable 'soft wrapping'. \fBnano\fP will attempt to display the entire
|
||||
contents of a line, even if it is longer than the screen width. Since
|
||||
\&'$' normally refers to a variable in the Unix shell, you should specify
|
||||
this option last when using other options (e.g. 'nano \-wS$') or pass it
|
||||
separately (e.g. 'nano \-wS \-$').
|
||||
.TP
|
||||
.B \-a, \-b, \-e, \-f, \-g, \-j
|
||||
Ignored, for compatibility with Pico.
|
||||
@@ -223,7 +224,7 @@ should be provided with \fBnano\fP.
|
||||
|
||||
.SH NOTES
|
||||
If no alternative spell checker command is specified on the command
|
||||
line or in one of the nanorc files, \fBnano\fP will check the
|
||||
line or in one of the \fInanorc\fP files, \fBnano\fP will check the
|
||||
\fBSPELL\fP environment variable for one.
|
||||
|
||||
In some cases \fBnano\fP will try to dump the buffer into an emergency
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.\" Hey, EMACS: -*- nroff -*-
|
||||
.\" Copyright (C) 2003, 2004, 2005, 2006, 2007
|
||||
.\" Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
||||
.\" Free Software Foundation, Inc.
|
||||
.\"
|
||||
.\" This document is dual-licensed. You may distribute and/or modify it
|
||||
@@ -45,9 +45,9 @@ the command line options. Additionally, the \fBsyntax\fP, \fBcolor\fP,
|
||||
and \fBicolor\fP keywords are used to define syntax highlighting rules
|
||||
for different text patterns. \fBnano\fP will read one command per line.
|
||||
|
||||
Options in nanorc files take precedence over nano's defaults, and
|
||||
command line options override nanorc settings. Also, options are unset
|
||||
by default, except for those that take arguments.
|
||||
Options in \fInanorc\fP files take precedence over nano's defaults, and
|
||||
command line options override \fInanorc\fP settings. Also, options are
|
||||
unset by default, except for those that take arguments.
|
||||
|
||||
Quotes inside string parameters don't have to be escaped with
|
||||
backslashes. The last double quote in the string will be treated as its
|
||||
@@ -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
|
||||
@@ -91,7 +96,7 @@ Use cut to end of line by default.
|
||||
.B set fill \fIn\fP
|
||||
Wrap lines at column number \fIn\fP. If \fIn\fP is 0 or less, the
|
||||
maximum line length will be the screen width less \fIn\fP columns. The
|
||||
default value is -8.
|
||||
default value is \-8.
|
||||
.TP
|
||||
.B set/unset historylog
|
||||
Enable \fI~/.nano_history\fP for saving and reading search/replace
|
||||
@@ -133,7 +138,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
|
||||
@@ -146,9 +151,9 @@ punctuation, optionally followed by closing brackets, can end sentences.
|
||||
The default value is "\fI!.?\fP".
|
||||
.TP
|
||||
.B set/unset quiet
|
||||
\fBnano\fP will not report errors in the nanorc file and ask them to
|
||||
be acknowledged by pressing enter at startup. If this is used it should
|
||||
be placed at the top of the file to be fully effective.
|
||||
\fBnano\fP will not report errors in the \fInanorc\fP file and ask them
|
||||
to be acknowledged by pressing enter at startup. If this is used it
|
||||
should be placed at the top of the file to be fully effective.
|
||||
.TP
|
||||
.B set/unset quickblank
|
||||
Do quick statusbar blanking. Statusbar messages will disappear after 1
|
||||
@@ -175,6 +180,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
|
||||
@@ -224,7 +232,7 @@ characters as parts of words.
|
||||
.TP
|
||||
.B syntax "\fIstr\fP" ["\fIfileregex\fP" ... ]
|
||||
Defines a syntax named \fIstr\fP which can be activated via the
|
||||
-Y/--syntax command line option, or will be automatically activated if
|
||||
\-Y/\-\-syntax command line option, or will be automatically activated if
|
||||
the current filename matches the extended regular expression
|
||||
\fIfileregex\fP. All following \fBcolor\fP and \fBicolor\fP statements
|
||||
will apply to \fIsyntax\fP until a new syntax is defined.
|
||||
@@ -234,6 +242,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
|
||||
@@ -276,7 +291,7 @@ followed by an alpha character or the word "Space".
|
||||
Example: ^C
|
||||
.TP
|
||||
.B M-
|
||||
followed by a prinable character or the word "Space".
|
||||
followed by a printable character or the word "Space".
|
||||
Example: M-C
|
||||
.TP
|
||||
.B F
|
||||
@@ -414,7 +429,7 @@ Refresh the screen.
|
||||
Undo the text action peformed (add text, delete text, etc).
|
||||
.TP
|
||||
.B redo
|
||||
"Re-do" the last undone action (i.e. undo an undo)
|
||||
Redo the last undone action (i.e., undo an undo).
|
||||
.TP
|
||||
.B suspend
|
||||
Suspend the editor (if the suspend function is enabled, see the
|
||||
@@ -451,7 +466,7 @@ When writing a file, append to the end instead of overwriting.
|
||||
When writing a file, 'prepend' (write at the beginning) instead of overwriting.
|
||||
.TP
|
||||
.B backup
|
||||
When writing a file, create a backup of the current file.
|
||||
When writing a file, create a backup of the current file.
|
||||
.TP
|
||||
.B firstfile
|
||||
Move to the first file when using the file browser (reading or writing files).
|
||||
|
||||
@@ -141,6 +141,9 @@
|
||||
## Use smooth scrolling as the default.
|
||||
# set smooth
|
||||
|
||||
## Enable soft line wrapping (AKA full line display).
|
||||
# set softwrap
|
||||
|
||||
## Use this spelling checker instead of the internal one. This option
|
||||
## does not properly have a default value.
|
||||
##
|
||||
@@ -158,6 +161,10 @@
|
||||
## Save automatically on exit, don't prompt.
|
||||
# set tempfile
|
||||
|
||||
## Enable the new (EXPERIMENTAL) generic undo code, not just for line
|
||||
## cuts.
|
||||
# set undo
|
||||
|
||||
## Disallow file modification. Why would you want this in an rcfile? ;)
|
||||
# set view
|
||||
|
||||
@@ -170,12 +177,6 @@
|
||||
## characters as parts of words.
|
||||
# set wordbounds
|
||||
|
||||
## Enable the new (EXPERIMENTAL) generic undo code, not just for line cuts
|
||||
# set undo
|
||||
|
||||
## Enable soft line wrapping (AKA full line display)
|
||||
# set softwrap
|
||||
|
||||
|
||||
## Color setup
|
||||
##
|
||||
@@ -238,6 +239,9 @@
|
||||
## C/C++
|
||||
# include "@PKGDATADIR@/c.nanorc"
|
||||
|
||||
## Makefiles
|
||||
# include "@PKGDATADIR@/makefile.nanorc"
|
||||
|
||||
## Cascading Style Sheets
|
||||
# include "@PKGDATADIR@/css.nanorc"
|
||||
|
||||
@@ -283,6 +287,15 @@
|
||||
## Java
|
||||
# include "@PKGDATADIR@/java.nanorc"
|
||||
|
||||
## Fortran
|
||||
# include "@PKGDATADIR@/fortran.nanorc"
|
||||
|
||||
## Objective-C
|
||||
# include "@PKGDATADIR@/objc.nanorc"
|
||||
|
||||
## OCaml
|
||||
# include "@PKGDATADIR@/ocaml.nanorc"
|
||||
|
||||
## AWK
|
||||
# include "@PKGDATADIR@/awk.nanorc"
|
||||
|
||||
|
||||
@@ -1,27 +1,32 @@
|
||||
pkgdata_DATA = asm.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
|
||||
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\>"
|
||||
@@ -8,7 +9,7 @@ color green "\<(class|namespace|template|public|protected|private|typename|this|
|
||||
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
|
||||
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
|
||||
color magenta "\<(goto|continue|break|return)\>"
|
||||
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
|
||||
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)"
|
||||
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
|
||||
##
|
||||
## GCC builtins
|
||||
|
||||
19
doc/syntax/cmake.nanorc
Normal file
19
doc/syntax/cmake.nanorc
Normal file
@@ -0,0 +1,19 @@
|
||||
## CMake syntax highlighter for GNU Nano
|
||||
##
|
||||
syntax "cmake" "(CMakeLists\.txt|\.cmake)$"
|
||||
|
||||
icolor green "^[[:space:]]*[A-Z0-9_]+"
|
||||
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
|
||||
|
||||
icolor brightgreen "^[[:space:]]*\<((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
|
||||
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)\>[[:space:]]"
|
||||
color brightgreen "[[:space:]]\<(OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))\>[[:space:]]"
|
||||
|
||||
icolor brightred "^[[:space:]]*\<((end)?(function|macro)|return)"
|
||||
|
||||
icolor cyan start="\$(\{|ENV\{)" end="\}"
|
||||
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
|
||||
|
||||
icolor brightblue "^([[:space:]]*)?#.*"
|
||||
icolor brightblue "[[:space:]]#.*"
|
||||
color ,green "[[:space:]]+$"
|
||||
@@ -27,7 +27,7 @@ color brightblue "\<(doc|ins|exe)?into\>" "\<(f|games)(owners|perms)\>" "\<(exe|
|
||||
## Highlight common commands used in ebuilds
|
||||
color blue "\<make\>" "\<(awk|cat|cd|chmod|chown|cp|echo|env|export|find|e?grep|ln|mkdir|mv|rm|sed|set|tar|touch|unset|xargs)\>"
|
||||
## Highlight comments (doesnt work that well)
|
||||
color yellow "#.*$"
|
||||
color yellow "(^|[[:space:]])#.*$"
|
||||
## Highlight strings (doesnt work that well)
|
||||
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
|
||||
## Trailing space is bad!
|
||||
|
||||
@@ -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]*"
|
||||
|
||||
|
||||
8
doc/syntax/makefile.nanorc
Normal file
8
doc/syntax/makefile.nanorc
Normal file
@@ -0,0 +1,8 @@
|
||||
# unattributed syntax highlighting example from wiki.linuxhelp.net/
|
||||
|
||||
syntax "makefile" "Makefile[^/]*$"
|
||||
color red "[:=]"
|
||||
color magenta "\<(if|ifeq|else|endif)\>"
|
||||
color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
|
||||
color brightblue "^[^ ]+:"
|
||||
color green "#.*$"
|
||||
@@ -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|speller|suspend|tabsize|tabstospaces|tempfile|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)\>"
|
||||
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 ">"
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
@c Run 'makeinfo' rather than 'texinfo-format-buffer'.
|
||||
@smallbook
|
||||
@set EDITION 0.1
|
||||
@set VERSION 2.0.0
|
||||
@set UPDATED 17 Dec 2007
|
||||
@set VERSION 2.2.0
|
||||
@set UPDATED 30 Nov 2009
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 2.0.0
|
||||
@subtitle version 2.2.0
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -33,8 +33,8 @@ editor.
|
||||
|
||||
This manual is part of the GNU @code{nano} distribution.@*
|
||||
@sp4
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||
2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This document is dual-licensed. You may distribute and/or modify it
|
||||
under the terms of either of the following licenses:
|
||||
@@ -249,6 +249,10 @@ a chroot.
|
||||
Preserve the ^Q (XON) and ^S (XOFF) sequences so data being sent to the
|
||||
editor can be can be stopped and started.
|
||||
|
||||
@item -q, --quiet
|
||||
Do not report errors in the nanorc file and ask them to be acknowledged
|
||||
by pressing Enter at startup.
|
||||
|
||||
@item -r <#cols>, --fill=<#cols>
|
||||
Wrap lines at column #cols. If this value is 0 or less, wrapping will
|
||||
occur at the width of the screen less #cols, allowing it to vary along
|
||||
@@ -266,6 +270,10 @@ Don't ask whether or not to save the current contents of the file when
|
||||
exiting, assume yes. This is most useful when using @code{nano} as the
|
||||
composer of a mailer program.
|
||||
|
||||
@item -u, --undo
|
||||
Enable experimental generic-purpose undo code. By default, the undo and
|
||||
redo shortcuts are Meta-U and Meta-E, respectively.
|
||||
|
||||
@item -v, --view
|
||||
Don't allow the contents of the file to be altered. Note that this
|
||||
option should NOT be used in place of correct file permissions to
|
||||
@@ -288,6 +296,13 @@ disabled to display the help system navigation keys.
|
||||
Enable @code{nano}'s suspend ability using the system's suspend
|
||||
keystroke (usually ^Z).
|
||||
|
||||
@item -$, --softwrap
|
||||
Enable 'soft wrapping'. @code{nano} will attempt to display the entire
|
||||
contents of a line, even if it is longer than the screen width. Since
|
||||
'$' normally refers to a variable in the Unix shell, you should specify
|
||||
this option last when using other options (e.g. 'nano -wS$') or pass it
|
||||
separately (e.g. 'nano -wS -$').
|
||||
|
||||
@item -a, -b, -e, -f, -g, -j
|
||||
Ignored, for compatibility with Pico.
|
||||
@end table
|
||||
@@ -447,6 +462,9 @@ nanorc. See @xref{Nanorc Files}, for more info.
|
||||
@item Suspend Toggle (Meta-Z)
|
||||
toggles the -z (@code{--suspend}) command line option.
|
||||
|
||||
@item Soft Wrapping Toggle (Meta-$)
|
||||
toggles the -$ (@code{--softwrap}) command line option.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -615,6 +633,9 @@ line.
|
||||
@item set/unset smooth
|
||||
Use smooth scrolling by default.
|
||||
|
||||
@item set/unset softwrap
|
||||
Use soft wrapping by default.
|
||||
|
||||
@item set speller "spellprog"
|
||||
Use spelling checker "spellprog" instead of the built-in one, which
|
||||
calls "spell".
|
||||
@@ -622,6 +643,10 @@ calls "spell".
|
||||
@item set/unset suspend
|
||||
Allow @code{nano} to be suspended.
|
||||
|
||||
@item set/unset suspendenable
|
||||
If @code{nano} is allowed to be suspended, allow the suspend key
|
||||
(usually ^Z) to actually suspend it.
|
||||
|
||||
@item set tabsize "n"
|
||||
Use a tab size of "n" columns. The value of "n" must be greater than 0.
|
||||
The default value is 8.
|
||||
@@ -632,6 +657,9 @@ Convert typed tabs to spaces.
|
||||
@item set/unset tempfile
|
||||
Save automatically on exit, don't prompt.
|
||||
|
||||
@item set/unset undo
|
||||
Enable experimental generic-purpose undo code.
|
||||
|
||||
@item set/unset view
|
||||
Disallow file modification.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ sub combinations {
|
||||
return @rest, map { [$first, @$_] } @rest;
|
||||
}
|
||||
|
||||
my @allargs=("--enable-debug", "--disable-justify", "--disable-extra", "--enable-tiny", "--disable-browser --disable-help --disable-mouse --disable-operatingdir --disable-speller", "--disable-multibuffer", "--disable-nanorc", "--with-slang");
|
||||
my @allargs=("--enable-debug", "--disable-wrapping", "--disable-justify", "--disable-extra", "--enable-tiny", "--disable-browser --disable-help --disable-mouse --disable-operatingdir --disable-speller", "--disable-multibuffer", "--disable-nanorc", "--with-slang");
|
||||
my @combos = combinations(@allargs);
|
||||
|
||||
my $i = 0;
|
||||
|
||||
@@ -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 ms nb nl nn pl pt_BR ro ru rw sr sv tr uk vi zh_CN zh_TW
|
||||
|
||||
841
po/nano.pot
841
po/nano.pot
File diff suppressed because it is too large
Load Diff
901
po/pt_BR.po
901
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
|
||||
868
po/zh_CN.po
868
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
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* browser.c *
|
||||
* *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
@@ -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 == WHEREIS_NEXT_MSG) {
|
||||
} 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,
|
||||
@@ -232,15 +232,15 @@ char *do_browser(char *path, DIR *dir)
|
||||
* blank out ans, since we're done with it. */
|
||||
statusbar(_("Cancelled"));
|
||||
ans = mallocstrcpy(ans, "");
|
||||
break;
|
||||
continue;
|
||||
} else if (i != 0) {
|
||||
/* Put back the "Go to Directory" key and save
|
||||
* 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);
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We have a directory. Blank out ans, since we're done
|
||||
@@ -266,7 +266,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
_("Can't go outside of %s in restricted mode"),
|
||||
operating_dir);
|
||||
free(new_path);
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -278,31 +278,31 @@ char *do_browser(char *path, DIR *dir)
|
||||
strerror(errno));
|
||||
beep();
|
||||
free(new_path);
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Start over again with the new path value. */
|
||||
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"));
|
||||
beep();
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
@@ -314,7 +314,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
_("Can't go outside of %s in restricted mode"),
|
||||
operating_dir);
|
||||
beep();
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -324,7 +324,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
statusbar(_("Error reading %s: %s"),
|
||||
filelist[selected], strerror(errno));
|
||||
beep();
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If we've successfully opened a file, we're done, so
|
||||
@@ -332,7 +332,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
retval = mallocstrcpy(NULL, filelist[selected]);
|
||||
abort = TRUE;
|
||||
break;
|
||||
continue;
|
||||
/* If we've successfully opened a directory, and it's
|
||||
* "..", save the current directory in prev_dir, so that
|
||||
* we can select it later. */
|
||||
@@ -347,7 +347,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
statusbar(_("Error reading %s: %s"),
|
||||
filelist[selected], strerror(errno));
|
||||
beep();
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
path = mallocstrcpy(path, filelist[selected]);
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
48
src/chars.c
48
src/chars.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* chars.c *
|
||||
* *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
@@ -79,6 +79,16 @@ bool is_byte(int c)
|
||||
return ((unsigned int)c == (unsigned char)c);
|
||||
}
|
||||
|
||||
static void mbtowc_reset(void)
|
||||
{
|
||||
IGNORE_CALL_RESULT(mbtowc(NULL, NULL, 0));
|
||||
}
|
||||
|
||||
static void wctomb_reset(void)
|
||||
{
|
||||
IGNORE_CALL_RESULT(wctomb(NULL, 0));
|
||||
}
|
||||
|
||||
/* This function is equivalent to isalnum() for multibyte characters. */
|
||||
bool is_alnum_mbchar(const char *c)
|
||||
{
|
||||
@@ -89,7 +99,7 @@ bool is_alnum_mbchar(const char *c)
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -109,7 +119,7 @@ bool is_blank_mbchar(const char *c)
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -156,7 +166,7 @@ bool is_cntrl_mbchar(const char *c)
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -177,7 +187,7 @@ bool is_punct_mbchar(const char *c)
|
||||
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
|
||||
|
||||
if (c_mb_len < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -243,14 +253,14 @@ char *control_mbrep(const char *c, char *crep, int *crep_len)
|
||||
wchar_t wc;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
*crep_len = bad_mbchar_len;
|
||||
strncpy(crep, bad_mbchar, *crep_len);
|
||||
} else {
|
||||
*crep_len = wctomb(crep, control_wrep(wc));
|
||||
|
||||
if (*crep_len < 0) {
|
||||
wctomb(NULL, 0);
|
||||
wctomb_reset();
|
||||
*crep_len = 0;
|
||||
}
|
||||
}
|
||||
@@ -278,14 +288,14 @@ char *mbrep(const char *c, char *crep, int *crep_len)
|
||||
|
||||
/* Reject invalid Unicode characters. */
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0 || !is_valid_unicode(wc)) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
*crep_len = bad_mbchar_len;
|
||||
strncpy(crep, bad_mbchar, *crep_len);
|
||||
} else {
|
||||
*crep_len = wctomb(crep, wc);
|
||||
|
||||
if (*crep_len < 0) {
|
||||
wctomb(NULL, 0);
|
||||
wctomb_reset();
|
||||
*crep_len = 0;
|
||||
}
|
||||
}
|
||||
@@ -311,7 +321,7 @@ int mbwidth(const char *c)
|
||||
int width;
|
||||
|
||||
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
wc = bad_wchar;
|
||||
}
|
||||
|
||||
@@ -356,7 +366,7 @@ char *make_mbchar(long chr, int *chr_mb_len)
|
||||
|
||||
/* Reject invalid Unicode characters. */
|
||||
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) {
|
||||
wctomb(NULL, 0);
|
||||
wctomb_reset();
|
||||
*chr_mb_len = 0;
|
||||
}
|
||||
} else {
|
||||
@@ -388,7 +398,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
|
||||
/* If buf contains an invalid multibyte character, only
|
||||
* interpret buf's first byte. */
|
||||
if (buf_mb_len < 0) {
|
||||
mblen(NULL, 0);
|
||||
IGNORE_CALL_RESULT(mblen(NULL, 0));
|
||||
buf_mb_len = 1;
|
||||
} else if (buf_mb_len == 0)
|
||||
buf_mb_len++;
|
||||
@@ -545,7 +555,7 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||
s1_mb_len = parse_mbchar(s1, s1_mb, NULL);
|
||||
|
||||
if (mbtowc(&ws1, s1_mb, s1_mb_len) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
ws1 = (unsigned char)*s1_mb;
|
||||
bad_s1_mb = TRUE;
|
||||
}
|
||||
@@ -553,7 +563,7 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||
s2_mb_len = parse_mbchar(s2, s2_mb, NULL);
|
||||
|
||||
if (mbtowc(&ws2, s2_mb, s2_mb_len) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
ws2 = (unsigned char)*s2_mb;
|
||||
bad_s2_mb = TRUE;
|
||||
}
|
||||
@@ -620,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)
|
||||
@@ -781,7 +791,7 @@ char *mbstrchr(const char *s, const char *c)
|
||||
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
|
||||
|
||||
if (c_mb_len < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
wc = (unsigned char)*c;
|
||||
bad_c_mb = TRUE;
|
||||
}
|
||||
@@ -790,7 +800,7 @@ char *mbstrchr(const char *s, const char *c)
|
||||
int s_mb_len = parse_mbchar(s, s_mb, NULL);
|
||||
|
||||
if (mbtowc(&ws, s_mb, s_mb_len) < 0) {
|
||||
mbtowc(NULL, NULL, 0);
|
||||
mbtowc_reset();
|
||||
ws = (unsigned char)*s;
|
||||
bad_s_mb = TRUE;
|
||||
}
|
||||
@@ -810,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 */
|
||||
|
||||
@@ -830,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
|
||||
|
||||
105
src/color.c
105
src/color.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* color.c *
|
||||
* *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* cut.c *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
|
||||
419
src/files.c
419
src/files.c
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* files.c *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -146,7 +146,7 @@ void open_buffer(const char *filename, bool undoable)
|
||||
/* If we have a non-new file, read it in. Then, if the buffer has
|
||||
* no stat, update the stat, if applicable. */
|
||||
if (rc > 0) {
|
||||
read_file(f, rc, filename, undoable);
|
||||
read_file(f, rc, filename, undoable, new_buffer);
|
||||
#ifndef NANO_TINY
|
||||
if (openfile->current_stat == NULL) {
|
||||
openfile->current_stat =
|
||||
@@ -196,7 +196,7 @@ void replace_buffer(const char *filename)
|
||||
|
||||
/* If we have a non-new file, read it in. */
|
||||
if (rc > 0)
|
||||
read_file(f, rc, filename, FALSE);
|
||||
read_file(f, rc, filename, FALSE, TRUE);
|
||||
|
||||
/* Move back to the beginning of the first line of the buffer. */
|
||||
openfile->current = openfile->fileage;
|
||||
@@ -279,6 +279,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();
|
||||
|
||||
@@ -309,7 +313,7 @@ int is_file_writable(const char *filename)
|
||||
if (ISSET(VIEW_MODE))
|
||||
return TRUE;
|
||||
|
||||
assert(filename != NULL && f != NULL);
|
||||
assert(filename != NULL);
|
||||
|
||||
/* Get the specified file's full path. */
|
||||
full_filename = get_full_path(filename);
|
||||
@@ -390,9 +394,9 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
|
||||
/* Read an open file into the current buffer. f should be set to the
|
||||
* open file, and filename should be set to the name of the file.
|
||||
* undoable means do we want to create undo records to try and undo this.
|
||||
* Will also attempt to check file writability if fd > 0
|
||||
* Will also attempt to check file writability if fd > 0 and checkwritable == TRUE
|
||||
*/
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable)
|
||||
{
|
||||
size_t num_lines = 0;
|
||||
/* The number of lines in the file. */
|
||||
@@ -514,7 +518,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
if (ferror(f))
|
||||
nperror(filename);
|
||||
fclose(f);
|
||||
if (fd > 0) {
|
||||
if (fd > 0 && checkwritable) {
|
||||
close(fd);
|
||||
writable = is_file_writable(filename);
|
||||
}
|
||||
@@ -869,14 +873,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 +890,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 +1070,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"));
|
||||
@@ -1190,7 +1200,7 @@ char *get_full_path(const char *origpath)
|
||||
/* Finally, go back to the path specified in d_here,
|
||||
* where we were before. We don't check for a chdir()
|
||||
* error, since we can do nothing if we get one. */
|
||||
chdir(d_here);
|
||||
IGNORE_CALL_RESULT(chdir(d_here));
|
||||
|
||||
/* Free d_here, since we're done using it. */
|
||||
free(d_here);
|
||||
@@ -1360,6 +1370,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;
|
||||
@@ -1458,6 +1485,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
/* The actual file, realname, we are writing to. */
|
||||
char *tempname = NULL;
|
||||
/* The temp file name we write to on prepend. */
|
||||
int backup_cflags;
|
||||
|
||||
assert(name != NULL);
|
||||
|
||||
@@ -1500,14 +1528,22 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
realexists = (stat(realname, &st) != -1);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* if we have not stat()d this file before (say, the user just
|
||||
* specified it interactively), stat and save the value
|
||||
* or else we will chase null pointers when we do
|
||||
* modtime checks, preserve file times, etc. during backup */
|
||||
if (openfile->current_stat == NULL && !tmp && realexists)
|
||||
stat(realname, openfile->current_stat);
|
||||
|
||||
/* We backup only if the backup toggle is set, the file isn't
|
||||
* temporary, and the file already exists. Furthermore, if we
|
||||
* aren't appending, prepending, or writing a selection, we backup
|
||||
* only if the file has not been modified by someone else since nano
|
||||
* opened it. */
|
||||
if (ISSET(BACKUP_FILE) && !tmp && realexists && ((append !=
|
||||
OVERWRITE || openfile->mark_set) ||
|
||||
openfile->current_stat->st_mtime == st.st_mtime)) {
|
||||
OVERWRITE || openfile->mark_set) || (openfile->current_stat &&
|
||||
openfile->current_stat->st_mtime == st.st_mtime))) {
|
||||
int backup_fd;
|
||||
FILE *backup_file;
|
||||
char *backupname;
|
||||
struct utimbuf filetime;
|
||||
@@ -1581,18 +1617,58 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
sprintf(backupname, "%s~", realname);
|
||||
}
|
||||
|
||||
/* Open the destination backup file. Before we write to it, we
|
||||
* set its permissions, so no unauthorized person can read it as
|
||||
* we write. */
|
||||
backup_file = fopen(backupname, "wb");
|
||||
/* 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 && !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;
|
||||
}
|
||||
|
||||
if (backup_file == NULL || chmod(backupname,
|
||||
openfile->current_stat->st_mode) == -1) {
|
||||
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. */
|
||||
backup_file = fdopen(backup_fd, "wb");
|
||||
|
||||
if (backup_fd < 0 || backup_file == NULL) {
|
||||
statusbar(_("Error writing backup file %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
free(backupname);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
if (backup_file != NULL)
|
||||
fclose(backup_file);
|
||||
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);
|
||||
fclose(backup_file);
|
||||
/* If we can't write to the backup, DONT go on, since
|
||||
whatever caused the backup file to fail (e.g. disk
|
||||
full may well cause the real file write to fail, which
|
||||
@@ -1607,17 +1683,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 || chown(backupname,
|
||||
openfile->current_stat->st_uid,
|
||||
openfile->current_stat->st_gid) == -1 ||
|
||||
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
|
||||
@@ -2006,7 +2083,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)
|
||||
@@ -2018,26 +2095,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;
|
||||
}
|
||||
|
||||
@@ -2118,7 +2195,10 @@ bool do_writeout(bool exiting)
|
||||
}
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
if (name_exists && openfile->current_stat && openfile->current_stat->st_mtime < st.st_mtime) {
|
||||
/* Complain if the file exists, the name hasn't changed, and the
|
||||
stat information we had before does not match what we have now */
|
||||
else if (name_exists && openfile->current_stat && (openfile->current_stat->st_mtime < st.st_mtime ||
|
||||
openfile->current_stat->st_dev != st.st_dev || openfile->current_stat->st_ino != st.st_ino)) {
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("File was modified since you opened it, continue saving ? "));
|
||||
if (i == 0 || i == -1)
|
||||
@@ -2607,28 +2687,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) {
|
||||
@@ -2638,12 +2789,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
|
||||
@@ -2668,8 +2815,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2695,7 +2845,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;
|
||||
@@ -2711,7 +2861,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
|
||||
@@ -2720,7 +2870,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);
|
||||
@@ -2729,4 +2879,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 */
|
||||
|
||||
880
src/global.c
880
src/global.c
File diff suppressed because it is too large
Load Diff
32
src/help.c
32
src/help.c
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* help.c *
|
||||
* *
|
||||
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, *
|
||||
* 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
60
src/move.c
60
src/move.c
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* move.c *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -50,36 +50,50 @@ void do_last_line(void)
|
||||
/* Move up one page. */
|
||||
void do_page_up(void)
|
||||
{
|
||||
int i;
|
||||
int i, skipped = 0;
|
||||
|
||||
/* If there's less than a page of text left on the screen, put the
|
||||
* cursor at the beginning of the first line of the file, and then
|
||||
* update the edit window. */
|
||||
if (openfile->current->lineno <= editwinrows - 2) {
|
||||
if (openfile->current->lineno == 1 || (!ISSET(SOFTWRAP) &&
|
||||
openfile->current->lineno <= editwinrows - 2)) {
|
||||
do_first_line();
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we're not in smooth scrolling mode, put the cursor at the
|
||||
* beginning of the top line of the edit window, as Pico does. */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
#endif
|
||||
openfile->current = openfile->edittop;
|
||||
openfile->placewewant = 0;
|
||||
openfile->placewewant = openfile->current_y = 0;
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = editwinrows - 2; i > 0 && openfile->current !=
|
||||
openfile->fileage; i--)
|
||||
for (i = editwinrows - 2; i - skipped > 0 && openfile->current !=
|
||||
openfile->fileage; i--) {
|
||||
openfile->current = openfile->current->prev;
|
||||
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,
|
||||
openfile->current->lineno, strlenpt(openfile->current->data));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
openfile->placewewant);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_up: openfile->current->lineno = %lu, skipped = %d\n", (unsigned long) openfile->current->lineno, skipped);
|
||||
#endif
|
||||
|
||||
/* Scroll the edit window up a page. */
|
||||
edit_scroll(UP_DIR, editwinrows - 2);
|
||||
edit_update(NONE);
|
||||
}
|
||||
|
||||
/* Move down one page. */
|
||||
@@ -102,20 +116,16 @@ void do_page_down(void)
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
#endif
|
||||
openfile->current = openfile->edittop;
|
||||
openfile->placewewant = 0;
|
||||
openfile->placewewant = openfile->current_y = 0;
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_down: maxrows = %d\n", maxrows);
|
||||
#endif
|
||||
|
||||
for (i = maxrows - 2; i > 0 && openfile->current !=
|
||||
openfile->filebot; i--) {
|
||||
openfile->current = openfile->current->next;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_down: moving to line %d\n", openfile->current->lineno);
|
||||
fprintf(stderr, "do_page_down: moving to line %lu\n", (unsigned long) openfile->current->lineno);
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -124,7 +134,7 @@ void do_page_down(void)
|
||||
openfile->placewewant);
|
||||
|
||||
/* Scroll the edit window down a page. */
|
||||
edit_scroll(DOWN_DIR, maxrows - 2);
|
||||
edit_update(NONE);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
@@ -512,7 +522,7 @@ void do_up(
|
||||
#ifndef NANO_TINY
|
||||
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
|
||||
#endif
|
||||
editwinrows / 2);
|
||||
editwinrows / 2 + 1);
|
||||
|
||||
/* If we're below the first line of the edit window, update the
|
||||
* line we were on before and the line we're on now. The former
|
||||
@@ -568,17 +578,7 @@ void do_down(
|
||||
openfile->placewewant);
|
||||
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *foo;
|
||||
ssize_t extracuzsoft = 0;
|
||||
|
||||
for (foo = openfile->edittop; foo
|
||||
&& foo->lineno - openfile->edittop->lineno + extracuzsoft < editwinrows;
|
||||
foo = foo->next) {
|
||||
extracuzsoft += strlenpt(foo->data) / (COLS - 1);
|
||||
if (foo == openfile->current)
|
||||
break;
|
||||
}
|
||||
if (foo && foo->lineno - openfile->edittop->lineno + extracuzsoft >= editwinrows)
|
||||
if (openfile->current->lineno - openfile->edittop->lineno >= maxrows)
|
||||
onlastline = TRUE;
|
||||
}
|
||||
|
||||
@@ -591,13 +591,15 @@ void do_down(
|
||||
#ifndef NANO_TINY
|
||||
|| scroll_only
|
||||
#endif
|
||||
)
|
||||
) {
|
||||
edit_scroll(DOWN_DIR,
|
||||
#ifndef NANO_TINY
|
||||
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
|
||||
#endif
|
||||
editwinrows / 2);
|
||||
editwinrows / 2 + 1);
|
||||
|
||||
edit_refresh_needed = TRUE;
|
||||
}
|
||||
/* If we're above the last line of the edit window, update the line
|
||||
* we were on before and the line we're on now. The former needs to
|
||||
* be redrawn if we're not on the first page, and the latter needs
|
||||
|
||||
180
src/nano.c
180
src/nano.c
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* nano.c *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -394,11 +394,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
|
||||
/* If the top of the edit window was inside the old partition, put
|
||||
* it in range of current. */
|
||||
if (edittop_inside)
|
||||
edit_update(
|
||||
#ifndef NANO_TINY
|
||||
ISSET(SMOOTH_SCROLL) ? NONE :
|
||||
#endif
|
||||
CENTER);
|
||||
edit_update(NONE);
|
||||
|
||||
/* Renumber starting with the beginning line of the old
|
||||
* partition. */
|
||||
@@ -522,6 +518,7 @@ openfilestruct *make_new_opennode(void)
|
||||
newnode->edittop = NULL;
|
||||
newnode->current = NULL;
|
||||
#ifndef NANO_TINY
|
||||
newnode->current_stat = NULL;
|
||||
newnode->last_action = OTHER;
|
||||
#endif
|
||||
|
||||
@@ -608,6 +605,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
|
||||
@@ -638,7 +639,11 @@ void die(const char *msg, ...)
|
||||
if (filepart != NULL)
|
||||
unpartition_filestruct(&filepart);
|
||||
|
||||
die_save_file(openfile->filename, openfile->current_stat);
|
||||
die_save_file(openfile->filename
|
||||
#ifndef NANO_TINY
|
||||
, openfile->current_stat
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
@@ -651,7 +656,11 @@ void die(const char *msg, ...)
|
||||
|
||||
/* Save the current file buffer if it's been modified. */
|
||||
if (openfile->modified)
|
||||
die_save_file(openfile->filename, openfile->current_stat);
|
||||
die_save_file(openfile->filename
|
||||
#ifndef NANO_TINY
|
||||
, openfile->current_stat
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -662,7 +671,11 @@ void die(const char *msg, ...)
|
||||
|
||||
/* Save the current file under the name spacified in die_filename, which
|
||||
* is modified to be unique if necessary. */
|
||||
void die_save_file(const char *die_filename, struct stat *die_stat)
|
||||
void die_save_file(const char *die_filename
|
||||
#ifndef NANO_TINY
|
||||
, struct stat *die_stat
|
||||
#endif
|
||||
)
|
||||
{
|
||||
char *retval;
|
||||
bool failed = TRUE;
|
||||
@@ -691,6 +704,7 @@ void die_save_file(const char *die_filename, struct stat *die_stat)
|
||||
fprintf(stderr, _("\nBuffer not written: %s\n"),
|
||||
_("Too many backup files?"));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Try and chmod/chown the save file to the values of the original file, but
|
||||
dont worry if it fails because we're supposed to be bailing as fast
|
||||
as possible. */
|
||||
@@ -699,6 +713,7 @@ void die_save_file(const char *die_filename, struct stat *die_stat)
|
||||
shush = chmod(retval, die_stat->st_mode);
|
||||
shush = chown(retval, die_stat->st_uid, die_stat->st_gid);
|
||||
}
|
||||
#endif
|
||||
|
||||
free(retval);
|
||||
}
|
||||
@@ -845,6 +860,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"));
|
||||
@@ -926,8 +945,8 @@ void version(void)
|
||||
{
|
||||
printf(_(" GNU nano version %s (compiled %s, %s)\n"), VERSION,
|
||||
__TIME__, __DATE__);
|
||||
printf(" (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007\n");
|
||||
printf(" Free Software Foundation, Inc.\n");
|
||||
printf(" (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,\n");
|
||||
printf(" 2008, 2009 Free Software Foundation, Inc.\n");
|
||||
printf(
|
||||
_(" Email: nano@nano-editor.org Web: http://www.nano-editor.org/"));
|
||||
printf(_("\n Compiled options:"));
|
||||
@@ -1052,10 +1071,16 @@ 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? */
|
||||
static bool pager_input_aborted = FALSE; /* Did someone invoke the pager and abort it via ^C? */
|
||||
|
||||
|
||||
/* Things which need to be run regardless of whether
|
||||
we finished the stdin pipe correctly or not */
|
||||
@@ -1069,14 +1094,15 @@ void finish_stdin_pager(void)
|
||||
if (f == NULL)
|
||||
nperror("fopen");
|
||||
|
||||
read_file(f, 0, "stdin", TRUE);
|
||||
read_file(f, 0, "stdin", TRUE, FALSE);
|
||||
ttystdin = open("/dev/tty", O_RDONLY);
|
||||
if (!ttystdin)
|
||||
die(_("Couldn't reopen stdin from keyboard, sorry\n"));
|
||||
|
||||
dup2(ttystdin,0);
|
||||
close(ttystdin);
|
||||
tcgetattr(0, &oldterm);
|
||||
if (!pager_input_aborted)
|
||||
tcgetattr(0, &oldterm);
|
||||
if (!pager_sig_failed && sigaction(SIGINT, &pager_oldaction, NULL) == -1)
|
||||
nperror("sigaction");
|
||||
terminal_init();
|
||||
@@ -1088,13 +1114,15 @@ void finish_stdin_pager(void)
|
||||
RETSIGTYPE cancel_stdin_pager(int signal)
|
||||
{
|
||||
/* Currently do nothing, just handle the intr silently */
|
||||
pager_input_aborted = TRUE;
|
||||
}
|
||||
|
||||
/* Let nano read stdin for the first file at least */
|
||||
void stdin_pager(void)
|
||||
{
|
||||
endwin();
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
if (!pager_input_aborted)
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
fprintf(stderr, _("Reading from stdin, ^C to abort\n"));
|
||||
|
||||
/* Set things up so that Ctrl-C will cancel the new process. */
|
||||
@@ -1114,7 +1142,7 @@ void stdin_pager(void)
|
||||
nperror("sigaction");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
open_buffer("", FALSE);
|
||||
finish_stdin_pager();
|
||||
}
|
||||
@@ -1169,16 +1197,20 @@ 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();
|
||||
#endif
|
||||
|
||||
/* Blank the screen, and move the cursor to the last line of the
|
||||
* screen. */
|
||||
erase();
|
||||
/* Move the cursor to the last line of the screen. */
|
||||
move(LINES - 1, 0);
|
||||
refresh();
|
||||
endwin();
|
||||
|
||||
/* Display our helpful message. */
|
||||
printf(_("Use \"fg\" to return to nano.\n"));
|
||||
@@ -1198,7 +1230,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);
|
||||
@@ -1254,8 +1286,10 @@ RETSIGTYPE handle_sigwinch(int signal)
|
||||
* otherwise. However, COLS and LINES are curses global variables,
|
||||
* and in some cases curses has already updated them. But not in
|
||||
* all cases. Argh. */
|
||||
#ifdef REDEFINIG_MACROS_OK
|
||||
COLS = win.ws_col;
|
||||
LINES = win.ws_row;
|
||||
#endif
|
||||
|
||||
/* If we've partitioned the filestruct, unpartition it now. */
|
||||
if (filepart != NULL)
|
||||
@@ -1364,6 +1398,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
|
||||
@@ -1559,7 +1599,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
|
||||
|
||||
@@ -1594,10 +1634,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;
|
||||
@@ -1609,18 +1649,19 @@ 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->viewok && openfile->syntax != NULL
|
||||
if (f && !f->viewok && openfile->syntax != NULL
|
||||
&& openfile->syntax->nmultis > 0) {
|
||||
reset_multis(openfile->current, FALSE);
|
||||
}
|
||||
#endif
|
||||
if (edit_refresh_needed) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "running edit_refresh() as edit_refresh_needed is true\n");
|
||||
@@ -1629,7 +1670,6 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
|
||||
edit_refresh_needed = FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1743,7 +1783,7 @@ int do_mouse(void)
|
||||
void alloc_multidata_if_needed(filestruct *fileptr)
|
||||
{
|
||||
if (!fileptr->multidata)
|
||||
fileptr->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
}
|
||||
|
||||
/* Precalculate the multi-line start and end regex info so we can speed up
|
||||
@@ -1885,17 +1925,15 @@ precalc_cleanup:
|
||||
* TRUE. */
|
||||
void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
{
|
||||
size_t current_len, i = 0;
|
||||
bool do_refresh = FALSE;
|
||||
/* Do we have to call edit_refresh(), or can we get away with
|
||||
* just update_line()? */
|
||||
|
||||
size_t current_len, orig_lenpt, i = 0;
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
int char_buf_len;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
current_len = strlen(openfile->current->data);
|
||||
if (ISSET(SOFTWRAP))
|
||||
orig_lenpt = strlenpt(openfile->current->data);
|
||||
|
||||
while (i < output_len) {
|
||||
/* If allow_cntrls is TRUE, convert nulls and newlines
|
||||
@@ -1959,26 +1997,25 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* If we're wrapping text, we need to call edit_refresh(). */
|
||||
if (!ISSET(NO_WRAP)) {
|
||||
bool do_refresh_save = do_refresh;
|
||||
|
||||
do_refresh = do_wrap(openfile->current, FALSE);
|
||||
|
||||
/* If we needed to call edit_refresh() before this, we'll
|
||||
* still need to after this. */
|
||||
if (do_refresh_save)
|
||||
do_refresh = TRUE;
|
||||
}
|
||||
if (!ISSET(NO_WRAP))
|
||||
if (do_wrap(openfile->current, FALSE))
|
||||
edit_refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* If color syntaxes are available and turned on, we need to
|
||||
* call edit_refresh(). */
|
||||
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
|
||||
do_refresh = TRUE;
|
||||
edit_refresh_needed = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 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)
|
||||
edit_refresh_needed = TRUE;
|
||||
|
||||
free(char_buf);
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
@@ -1987,7 +2024,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
#ifdef ENABLE_COLOR
|
||||
reset_multis(openfile->current, FALSE);
|
||||
#endif
|
||||
if (do_refresh) {
|
||||
if (edit_refresh_needed == TRUE) {
|
||||
edit_refresh();
|
||||
edit_refresh_needed = FALSE;
|
||||
} else
|
||||
@@ -2063,6 +2100,7 @@ int main(int argc, char **argv)
|
||||
{"tabstospaces", 0, NULL, 'E'},
|
||||
{"historylog", 0, NULL, 'H'},
|
||||
{"noconvert", 0, NULL, 'N'},
|
||||
{"poslog", 0, NULL, 'P'},
|
||||
{"smooth", 0, NULL, 'S'},
|
||||
{"quickblank", 0, NULL, 'U'},
|
||||
{"undo", 0, NULL, 'u'},
|
||||
@@ -2108,11 +2146,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:DEFHIKLNOPQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$",
|
||||
long_options, NULL)
|
||||
#else
|
||||
getopt(argc, argv,
|
||||
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$")
|
||||
"h?ABC:DEFHIKLNOPQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$")
|
||||
#endif
|
||||
) != -1) {
|
||||
switch (optchr) {
|
||||
@@ -2172,6 +2210,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);
|
||||
@@ -2404,10 +2447,12 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* Overwrite an rcfile "set nowrap" or --disable-wrapping-as-root
|
||||
if a --fill option was given on the command line. */
|
||||
if (fill_used)
|
||||
UNSET(NO_WRAP);
|
||||
#endif
|
||||
|
||||
/* If we're using bold text instead of reverse video text, set it up
|
||||
* now. */
|
||||
@@ -2418,10 +2463,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,
|
||||
@@ -2580,6 +2635,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 */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2617,6 +2681,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();
|
||||
|
||||
|
||||
188
src/nano.h
188
src/nano.h
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* nano.h *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -54,6 +54,9 @@
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
|
||||
/* Suppress warnings for __attribute__((warn_unused_result)) */
|
||||
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
|
||||
|
||||
/* Macros for flags. */
|
||||
#define FLAGOFF(flag) ((flag) / (sizeof(unsigned) * 8))
|
||||
#define FLAGMASK(flag) (1 << ((flag) % (sizeof(unsigned) * 8)))
|
||||
@@ -179,7 +182,7 @@ typedef enum {
|
||||
} update_type;
|
||||
|
||||
typedef enum {
|
||||
CONTROL, META, FKEY, RAW
|
||||
CONTROL, META, FKEY, RAWINPUT
|
||||
} function_type;
|
||||
|
||||
typedef enum {
|
||||
@@ -229,6 +232,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;
|
||||
@@ -317,6 +322,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 */
|
||||
|
||||
|
||||
@@ -419,7 +433,7 @@ typedef struct sc {
|
||||
/* The actual sequence to check on the 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 */
|
||||
@@ -431,7 +445,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 */
|
||||
@@ -477,6 +491,7 @@ enum
|
||||
REBIND_KEYPAD,
|
||||
NO_CONVERT,
|
||||
BACKUP_FILE,
|
||||
INSECURE_BACKUP,
|
||||
NO_COLOR_SYNTAX,
|
||||
PRESERVE,
|
||||
HISTORYLOG,
|
||||
@@ -491,7 +506,8 @@ enum
|
||||
BOLD_TEXT,
|
||||
QUIET,
|
||||
UNDOABLE,
|
||||
SOFTWRAP
|
||||
SOFTWRAP,
|
||||
POS_HISTORY
|
||||
};
|
||||
|
||||
/* Flags for which menus in which a given function should be present */
|
||||
@@ -739,9 +755,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
|
||||
@@ -750,160 +766,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
|
||||
|
||||
|
||||
64
src/prompt.c
64
src/prompt.c
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* prompt.c *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -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. */
|
||||
@@ -229,8 +229,8 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
f = sctofunc((sc *) s);
|
||||
if (s->scfunc != 0 && s->execute == TRUE) {
|
||||
*ran_func = TRUE;
|
||||
if (!ISSET(VIEW_MODE) || f->viewok)
|
||||
iso_me_harder_funcmap(f->scfunc);
|
||||
if (f && (!ISSET(VIEW_MODE) || (f->viewok)))
|
||||
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,8 +1070,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
}
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
#ifndef DISABLE_HELP
|
||||
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
|
||||
@@ -1082,7 +1081,6 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
* prompt. */
|
||||
finished = FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we have a shortcut with an associated function, break out
|
||||
* if we're finished after running or trying to run the
|
||||
@@ -1116,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;
|
||||
@@ -1203,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();
|
||||
@@ -1313,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) {
|
||||
@@ -1345,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 {
|
||||
|
||||
95
src/proto.h
95
src/proto.h
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* proto.h *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -113,6 +113,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
|
||||
@@ -271,7 +273,7 @@ bool close_buffer(void);
|
||||
#endif
|
||||
filestruct *read_line(char *buf, filestruct *prevnode, bool
|
||||
*first_line_ins, size_t buf_len);
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable);
|
||||
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable);
|
||||
int open_file(const char *filename, bool newfie, FILE **f);
|
||||
char *get_next_filename(const char *name, const char *suffix);
|
||||
void do_insertfile(
|
||||
@@ -321,6 +323,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. */
|
||||
@@ -428,7 +434,11 @@ void free_openfilestruct(openfilestruct *src);
|
||||
void print_view_warning(void);
|
||||
void finish(void);
|
||||
void die(const char *msg, ...);
|
||||
void die_save_file(const char *die_filename, struct stat *die_stat);
|
||||
void die_save_file(const char *die_filename
|
||||
#ifndef NANO_TINY
|
||||
, struct stat *die_stat
|
||||
#endif
|
||||
);
|
||||
void window_init(void);
|
||||
#ifndef DISABLE_MOUSE
|
||||
void disable_mouse_support(void);
|
||||
@@ -456,6 +466,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
|
||||
@@ -542,6 +553,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);
|
||||
@@ -607,6 +619,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
|
||||
@@ -627,6 +641,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);
|
||||
@@ -748,7 +763,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);
|
||||
@@ -779,52 +794,70 @@ void display_main_list(void);
|
||||
void do_cursorpos(bool constant);
|
||||
void do_cursorpos_void(void);
|
||||
void do_replace_highlight(bool highlight, const char *word);
|
||||
char *flagtostr(int flag);
|
||||
const char *flagtostr(int flag);
|
||||
const subnfunc *sctofunc(sc *s);
|
||||
const subnfunc *getfuncfromkey(WINDOW *win);
|
||||
void print_sclist(void);
|
||||
sc *strtosc(int menu, char *input);
|
||||
function_type strtokeytype(char *str);
|
||||
function_type strtokeytype(const char *str);
|
||||
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);
|
||||
|
||||
const char *cancel_msg;
|
||||
extern const char *cancel_msg;
|
||||
#ifndef NANO_TINY
|
||||
const char *case_sens_msg;
|
||||
const char *backwards_msg;
|
||||
const char *prev_history_msg;
|
||||
const char *next_history_msg;
|
||||
extern const char *case_sens_msg;
|
||||
extern const char *backwards_msg;
|
||||
extern const char *prev_history_msg;
|
||||
extern const char *next_history_msg;
|
||||
#endif
|
||||
const char *replace_msg;
|
||||
const char *no_replace_msg;
|
||||
const char *go_to_line_msg;
|
||||
const char *whereis_next_msg;
|
||||
const char *first_file_msg;
|
||||
const char *last_file_msg;
|
||||
const char *goto_dir_msg;
|
||||
const char *ext_cmd_msg;
|
||||
const char *to_files_msg;
|
||||
const char *dos_format_msg;
|
||||
const char *mac_format_msg;
|
||||
const char *append_msg;
|
||||
const char *prepend_msg;
|
||||
const char *backup_file_msg;
|
||||
const char *gototext_msg;
|
||||
const char *new_buffer_msg;
|
||||
void iso_me_harder_funcmap(short func);
|
||||
extern const char *replace_msg;
|
||||
extern const char *no_replace_msg;
|
||||
extern const char *go_to_line_msg;
|
||||
extern const char *whereis_next_msg;
|
||||
extern const char *first_file_msg;
|
||||
extern const char *last_file_msg;
|
||||
extern const char *goto_dir_msg;
|
||||
extern const char *ext_cmd_msg;
|
||||
extern const char *to_files_msg;
|
||||
extern const char *dos_format_msg;
|
||||
extern const char *mac_format_msg;
|
||||
extern const char *append_msg;
|
||||
extern const char *prepend_msg;
|
||||
extern const char *backup_file_msg;
|
||||
extern const char *gototext_msg;
|
||||
extern const char *new_buffer_msg;
|
||||
|
||||
void enable_nodelay(void);
|
||||
void disable_nodelay(void);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
const char *regexp_msg;
|
||||
extern const char *regexp_msg;
|
||||
#endif
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
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 */
|
||||
|
||||
82
src/rcfile.c
82
src/rcfile.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* rcfile.c *
|
||||
* *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
@@ -77,6 +77,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 +85,7 @@ static const rcoption rcopts[] = {
|
||||
{"historylog", HISTORYLOG},
|
||||
{"matchbrackets", 0},
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"poslog", POS_HISTORY},
|
||||
{"quiet", QUIET},
|
||||
{"quickblank", QUICK_BLANK},
|
||||
{"smarthome", SMART_HOME},
|
||||
@@ -302,6 +304,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 +360,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 +935,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++) {
|
||||
@@ -892,7 +965,7 @@ void parse_rcfile(FILE *rcstream
|
||||
{
|
||||
char *buf = NULL;
|
||||
ssize_t len;
|
||||
size_t n;
|
||||
size_t n = 0;
|
||||
|
||||
while ((len = getline(&buf, &n, rcstream)) > 0) {
|
||||
char *ptr, *keyword, *option;
|
||||
@@ -950,6 +1023,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)
|
||||
|
||||
33
src/search.c
33
src/search.c
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* search.c *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -138,7 +138,7 @@ int search_init(bool replacing, bool use_answer)
|
||||
int i = 0;
|
||||
char *buf;
|
||||
sc *s;
|
||||
char func = 0;
|
||||
void (*func)(void);
|
||||
bool meta_key = FALSE, func_key = FALSE;
|
||||
static char *backupstring = NULL;
|
||||
/* The search string we'll be using. */
|
||||
@@ -236,26 +236,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 +309,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 +1043,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);
|
||||
|
||||
@@ -1357,7 +1356,7 @@ void update_history(filestruct **h, const char *s)
|
||||
assert(hage != NULL && hbot != NULL);
|
||||
|
||||
/* If this string is already in the history, delete it. */
|
||||
p = find_history(*hage, *hbot, s, (size_t)-1);
|
||||
p = find_history(*hage, *hbot, s, strlen(s));
|
||||
|
||||
if (p != NULL) {
|
||||
filestruct *foo, *bar;
|
||||
@@ -1431,6 +1430,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
|
||||
|
||||
76
src/text.c
76
src/text.c
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* text.c *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -66,9 +66,7 @@ void do_mark(void)
|
||||
/* Delete the character under the cursor. */
|
||||
void do_delete(void)
|
||||
{
|
||||
bool do_refresh = FALSE;
|
||||
/* Do we have to call edit_refresh(), or can we get away with
|
||||
* just update_line()? */
|
||||
size_t orig_lenpt = 0;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
update_undo(DEL);
|
||||
@@ -86,6 +84,9 @@ void do_delete(void)
|
||||
|
||||
assert(openfile->current_x < strlen(openfile->current->data));
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
orig_lenpt = strlenpt(openfile->current->data);
|
||||
|
||||
/* Let's get dangerous. */
|
||||
charmove(&openfile->current->data[openfile->current_x],
|
||||
&openfile->current->data[openfile->current_x +
|
||||
@@ -108,7 +109,7 @@ void do_delete(void)
|
||||
/* If we're deleting at the end of a line, we need to call
|
||||
* edit_refresh(). */
|
||||
if (openfile->current->data[openfile->current_x] == '\0')
|
||||
do_refresh = TRUE;
|
||||
edit_refresh_needed = TRUE;
|
||||
|
||||
openfile->current->data = charealloc(openfile->current->data,
|
||||
openfile->current_x + strlen(foo->data) + 1);
|
||||
@@ -138,11 +139,13 @@ void do_delete(void)
|
||||
} else
|
||||
return;
|
||||
|
||||
if (ISSET(SOFTWRAP) && edit_refresh_needed == FALSE)
|
||||
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
|
||||
edit_refresh_needed = TRUE;
|
||||
|
||||
set_modified();
|
||||
|
||||
if (do_refresh)
|
||||
edit_refresh_needed = TRUE;
|
||||
else
|
||||
if (edit_refresh_needed == FALSE)
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
@@ -181,7 +184,7 @@ void do_tab(void)
|
||||
free(output);
|
||||
} else {
|
||||
#endif
|
||||
do_output("\t", 1, TRUE);
|
||||
do_output((char *) "\t", 1, TRUE);
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
#endif
|
||||
@@ -478,12 +481,13 @@ 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
|
||||
case SPLIT:
|
||||
undidmsg = _("line wrap");
|
||||
f->data = nrealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
|
||||
f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
|
||||
strcpy(&f->data[strlen(f->data) - 1], u->strdata);
|
||||
if (u->strdata2 != NULL)
|
||||
f->next->data = mallocstrcpy(f->next->data, u->strdata2);
|
||||
@@ -494,6 +498,7 @@ void do_undo(void)
|
||||
}
|
||||
renumber(f);
|
||||
break;
|
||||
#endif /* DISABLE_WRAPPING */
|
||||
case UNSPLIT:
|
||||
undidmsg = _("line join");
|
||||
t = make_new_node(f);
|
||||
@@ -517,7 +522,7 @@ void do_undo(void)
|
||||
undidmsg = _("line break");
|
||||
if (f->next) {
|
||||
filestruct *foo = f->next;
|
||||
f->data = nrealloc(f->data, strlen(f->data) + strlen(f->next->data) + 1);
|
||||
f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(f->next->data) + 1);
|
||||
strcat(f->data, f->next->data);
|
||||
unlink_node(foo);
|
||||
delete_node(foo);
|
||||
@@ -618,13 +623,15 @@ void do_redo(void)
|
||||
do_gotolinecolumn(u->lineno, u->begin+1, FALSE, FALSE, FALSE, FALSE);
|
||||
do_enter(TRUE);
|
||||
break;
|
||||
#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);
|
||||
break;
|
||||
#endif /* DISABLE_WRAPPING */
|
||||
case UNSPLIT:
|
||||
undidmsg = _("line join");
|
||||
len = strlen(f->data) + strlen(u->strdata + 1);
|
||||
@@ -704,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);
|
||||
@@ -734,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(). */
|
||||
@@ -765,7 +777,7 @@ bool execute_command(const char *command)
|
||||
* arguments. */
|
||||
shellenv = getenv("SHELL");
|
||||
if (shellenv == NULL)
|
||||
shellenv = "/bin/sh";
|
||||
shellenv = (char *) "/bin/sh";
|
||||
|
||||
/* Fork a child. */
|
||||
if ((pid = fork()) == 0) {
|
||||
@@ -812,7 +824,7 @@ bool execute_command(const char *command)
|
||||
if (f == NULL)
|
||||
nperror("fdopen");
|
||||
|
||||
read_file(f, 0, "stdin", TRUE);
|
||||
read_file(f, 0, "stdin", TRUE, FALSE);
|
||||
|
||||
if (wait(NULL) == -1)
|
||||
nperror("wait");
|
||||
@@ -859,7 +871,7 @@ void add_undo(undo_type current_action)
|
||||
}
|
||||
|
||||
/* Allocate and initialize a new undo type */
|
||||
u = nmalloc(sizeof(undo));
|
||||
u = (undo *) nmalloc(sizeof(undo));
|
||||
u->type = current_action;
|
||||
u->lineno = fs->current->lineno;
|
||||
u->begin = fs->current_x;
|
||||
@@ -900,6 +912,7 @@ void add_undo(undo_type current_action)
|
||||
u->strdata = data;
|
||||
}
|
||||
break;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
case SPLIT:
|
||||
wrap_loc = break_line(openfile->current->data, fill
|
||||
#ifndef DISABLE_HELP
|
||||
@@ -913,6 +926,7 @@ void add_undo(undo_type current_action)
|
||||
u->strdata2 = mallocstrcpy(NULL, fs->current->next->data);
|
||||
u->begin = wrap_loc;
|
||||
break;
|
||||
#endif /* DISABLE_WRAPPING */
|
||||
case INSERT:
|
||||
case REPLACE:
|
||||
data = mallocstrcpy(NULL, fs->current->data);
|
||||
@@ -993,7 +1007,7 @@ void update_undo(undo_type action)
|
||||
fs->current->data, (unsigned long) fs->current_x, u->begin);
|
||||
#endif
|
||||
len = strlen(u->strdata) + 2;
|
||||
data = nrealloc((void *) u->strdata, len * sizeof(char *));
|
||||
data = (char *) nrealloc((void *) u->strdata, len * sizeof(char *));
|
||||
data[len-2] = fs->current->data[fs->current_x];
|
||||
data[len-1] = '\0';
|
||||
u->strdata = (char *) data;
|
||||
@@ -1007,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;
|
||||
}
|
||||
@@ -1021,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;
|
||||
}
|
||||
@@ -1058,11 +1072,13 @@ void update_undo(undo_type action)
|
||||
case INSERT:
|
||||
u->mark_begin_lineno = openfile->current->lineno;
|
||||
break;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
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:
|
||||
/* These cases are handled by the earlier check for a new line and action */
|
||||
case ENTER:
|
||||
@@ -2270,7 +2286,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) {
|
||||
@@ -2741,6 +2757,11 @@ const char *do_alt_speller(char *tempfile_name)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (openfile->totsize == 0) {
|
||||
statusbar(_("Finished checking spelling"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
endwin();
|
||||
|
||||
/* Set up an argument list to pass execvp(). */
|
||||
@@ -2904,6 +2925,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;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* utils.c *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
|
||||
188
src/winio.c
188
src/winio.c
@@ -2,8 +2,8 @@
|
||||
/**************************************************************************
|
||||
* winio.c *
|
||||
* *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
|
||||
* Free Software Foundation, Inc. *
|
||||
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
|
||||
* 2008, 2009 Free Software Foundation, Inc. *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3, or (at your option) *
|
||||
@@ -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;
|
||||
@@ -2495,7 +2495,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
if (fileptr->multidata == NULL && openfile->syntax
|
||||
&& openfile->syntax->nmultis > 0) {
|
||||
int i;
|
||||
fileptr->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
for (i = 0; i < openfile->syntax->nmultis; i++)
|
||||
fileptr->multidata[i] = -1; /* Assue this applies until we know otherwise */
|
||||
}
|
||||
@@ -2935,7 +2935,7 @@ bool need_vertical_update(size_t pww_save)
|
||||
}
|
||||
|
||||
/* When edittop changes, try and figure out how many lines
|
||||
* we really have to work with (i.e. set maxrows)
|
||||
* we really have to work with (i.e. set maxrows)
|
||||
*/
|
||||
void compute_maxrows(void)
|
||||
{
|
||||
@@ -2949,7 +2949,8 @@ void compute_maxrows(void)
|
||||
|
||||
maxrows = 0;
|
||||
for (n = 0; n < editwinrows && foo; n++) {
|
||||
maxrows += 1 - strlenpt(foo->data) / COLS;
|
||||
maxrows ++;
|
||||
n += strlenpt(foo->data) / COLS;
|
||||
foo = foo->next;
|
||||
}
|
||||
|
||||
@@ -2987,12 +2988,9 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n");
|
||||
#endif
|
||||
for (i = editwinrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next) {
|
||||
ssize_t len = strlenpt(foo->data) / COLS;
|
||||
if (len > 0)
|
||||
do_redraw = TRUE;
|
||||
i -= len;
|
||||
}
|
||||
for (i = maxrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next)
|
||||
;
|
||||
|
||||
if (foo) {
|
||||
extracuzsoft += strlenpt(foo->data) / COLS;
|
||||
#ifdef DEBUG
|
||||
@@ -3000,7 +2998,6 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
(unsigned long) strlenpt(foo->data), (unsigned long) foo->lineno);
|
||||
#endif
|
||||
|
||||
|
||||
/* Now account for whether the edittop line itself is >COLS, if scrolling down */
|
||||
for (foo = openfile->edittop; foo && extracuzsoft > 0; nlines++) {
|
||||
extracuzsoft -= 1 + strlenpt(foo->data) / COLS;
|
||||
@@ -3012,13 +3009,6 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
foo = foo->next;
|
||||
}
|
||||
}
|
||||
} else if (ISSET(SOFTWRAP) && direction == UP_DIR) {
|
||||
for (foo = openfile->edittop, i = editwinrows; foo && i > 0; i--, foo = foo->prev) {
|
||||
if (strlenpt(foo->data) / COLS > 0) {
|
||||
do_redraw = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Part 1: nlines is the number of lines we're going to scroll the
|
||||
@@ -3037,9 +3027,15 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
break;
|
||||
openfile->edittop = openfile->edittop->next;
|
||||
}
|
||||
/* Don't over-scroll on long lines */
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
ssize_t len = strlenpt(openfile->edittop->data) / COLS;
|
||||
i -= len;
|
||||
if (len > 0)
|
||||
do_redraw = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
compute_maxrows();
|
||||
/* Limit nlines to the number of lines we could scroll. */
|
||||
nlines -= i;
|
||||
|
||||
@@ -3048,7 +3044,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
* call edit_refresh() beforehand if we need to. */
|
||||
if (nlines == 0 || do_redraw || nlines >= editwinrows) {
|
||||
if (do_redraw || nlines >= editwinrows)
|
||||
edit_refresh();
|
||||
edit_refresh_needed = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3124,8 +3120,11 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
openfile->edittop->lineno || openfile->current->lineno >=
|
||||
openfile->edittop->lineno + maxrows) {
|
||||
|
||||
#ifdef DEBUG
|
||||
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
|
||||
@@ -3156,28 +3155,13 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
/* Put edittop in range of current, get the difference in lines
|
||||
* between the original edittop and the current edittop, and
|
||||
* then restore the original edittop. */
|
||||
edit_update(
|
||||
#ifndef NANO_TINY
|
||||
ISSET(SMOOTH_SCROLL) ? NONE :
|
||||
#endif
|
||||
CENTER);
|
||||
|
||||
nlines = openfile->edittop->lineno - old_edittop->lineno;
|
||||
|
||||
openfile->edittop = old_edittop;
|
||||
edit_update(CENTER);
|
||||
|
||||
/* Update old_current if we're not on the same page as
|
||||
* before. */
|
||||
if (do_redraw)
|
||||
update_line(old_current, 0);
|
||||
|
||||
/* Scroll the edit window up or down until edittop is in range
|
||||
* of current. */
|
||||
if (nlines < 0)
|
||||
edit_scroll(UP_DIR, -nlines);
|
||||
else
|
||||
edit_scroll(DOWN_DIR, nlines);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the mark is on, update all the lines between the old first
|
||||
* line or old last line of the edit window (depending on
|
||||
@@ -3239,11 +3223,7 @@ void edit_refresh(void)
|
||||
|
||||
/* Put the top line of the edit window in range of the current
|
||||
* line. */
|
||||
edit_update(
|
||||
#ifndef NANO_TINY
|
||||
ISSET(SMOOTH_SCROLL) ? NONE :
|
||||
#endif
|
||||
CENTER);
|
||||
edit_update(CENTER);
|
||||
}
|
||||
|
||||
foo = openfile->edittop;
|
||||
@@ -3283,22 +3263,26 @@ void edit_update(update_type location)
|
||||
* screen as before, or at the top or bottom of the screen if
|
||||
* edittop is beyond either. */
|
||||
if (location == CENTER)
|
||||
goal = maxrows / 2;
|
||||
goal = editwinrows / 2;
|
||||
else {
|
||||
goal = openfile->current_y;
|
||||
|
||||
/* Limit goal to (editwinrows - 1) lines maximum. */
|
||||
if (goal > maxrows - 1)
|
||||
goal = maxrows - 1;
|
||||
if (goal > editwinrows - 1)
|
||||
goal = editwinrows - 1;
|
||||
}
|
||||
|
||||
for (; goal > 0 && foo->prev != NULL; goal--) {
|
||||
if (ISSET(SOFTWRAP))
|
||||
goal -= 1 + strlenpt(foo->data) / COLS;
|
||||
foo = foo->prev;
|
||||
if (ISSET(SOFTWRAP) && foo)
|
||||
goal -= strlenpt(foo->data) / COLS;
|
||||
}
|
||||
openfile->edittop = foo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_udpate(), setting edittop to lineno %d\n", openfile->edittop->lineno);
|
||||
#endif
|
||||
compute_maxrows();
|
||||
edit_refresh_needed = TRUE;
|
||||
}
|
||||
|
||||
/* Unconditionally redraw the entire screen. */
|
||||
|
||||
Reference in New Issue
Block a user