Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa1497b38f | ||
|
|
6481c3fb2d | ||
|
|
f28f50e6b5 | ||
|
|
f8ddf31bfb | ||
|
|
9e45a47054 | ||
|
|
9b5bd42978 | ||
|
|
47162bc428 | ||
|
|
e190ff30f2 | ||
|
|
afb75f22b2 | ||
|
|
32559294e8 | ||
|
|
c2946fbe09 | ||
|
|
2a4ab6d29d | ||
|
|
76c4b33ef4 | ||
|
|
8213850df6 | ||
|
|
f427694400 | ||
|
|
18394ac621 | ||
|
|
d29146040b | ||
|
|
a593f538dd | ||
|
|
45cfbece4c | ||
|
|
895e65ce1a | ||
|
|
4dca76f2e9 | ||
|
|
82a8f91392 | ||
|
|
bc503c80db | ||
|
|
a5d8e54ab9 | ||
|
|
10dd6c7714 | ||
|
|
4e25410680 | ||
|
|
637f6e50c0 | ||
|
|
7776ef9149 | ||
|
|
8fa1976796 | ||
|
|
7127857924 | ||
|
|
b7cb6a38c8 | ||
|
|
b78649b664 | ||
|
|
95114c1bc4 |
150
ChangeLog
150
ChangeLog
@@ -1,3 +1,153 @@
|
||||
GNU nano 1.3.1 - 2004.01.09
|
||||
- General:
|
||||
- Minor overhaul and abstraction of the lowest level of mouse
|
||||
input, mostly adapted from the code in do_mouse() that handles
|
||||
clicking on the shortcut list. New function do_mouseinput();
|
||||
changes to do_mouse(). (DLR) David Benbennick: Add a few
|
||||
efficiency/extensibility tweaks.
|
||||
- Modify the shortcut structure so that instead of having two
|
||||
miscellaneous key values (misc1 and misc2), there is one key
|
||||
value reserved for function keys (func_key) and one
|
||||
miscellaneous key value (misc), and tweak the
|
||||
shortcut-handling code to deal with this. These changes allow
|
||||
NANO_OPEN(PREV|NEXT)_ALTKEY to work properly when added to the
|
||||
shortcut entries for NANO_OPEN(PREV|NEXT)_KEY. Also remove
|
||||
the values in the shortcut list and elsewhere that were made
|
||||
redundant by the low-level input overhaul, use toupper()
|
||||
instead of subtracting 32 from values for greater code
|
||||
readability, and eliminate use of adding 32 to values when
|
||||
testing for toggles, as get_kbinput_accepted() converts toggle
|
||||
values to lowercase before returning them. (DLR)
|
||||
- Remove the workarounds for missing KEY_UP and KEY_DOWN, as
|
||||
they appear to be holdovers of the old way of denoting the
|
||||
search history shortcuts; if they aren't defined, KEY_LEFT and
|
||||
KEY_RIGHT probably shouldn't work either, and all four appear
|
||||
to be standard keys in termcap/terminfo in any case. Add new
|
||||
special sentinel key values NANO_NO_KEY (for no shortcut key)
|
||||
and NANO_HISTORY_KEY (for search history keys, both Up and
|
||||
Down), modify the shortcut list to use them, and modify the
|
||||
shortcut display routines to handle them. Also modify the
|
||||
shortcut list code to not treat non-control character values
|
||||
of val as Meta-sequences, and fix dependencies on that
|
||||
behavior. Also rename several variables: "alt" -> "meta",
|
||||
"altval" -> "metaval". (DLR)
|
||||
- Hook up the verbatim input functions so that verbatim input
|
||||
can be used in the edit window. New function
|
||||
do_verbatim_input(); changes to do_char(). (DLR) Additional
|
||||
minor tweaks to do_char() by David Benbennick.
|
||||
- Clarify the description of the --rebinddelete option. (DLR)
|
||||
- Miscellaneous comment tweaks, and copyright year updates in
|
||||
the comments and in do_credits(). (DLR)
|
||||
- cut.c:
|
||||
- Overhaul to increase efficiency and add various cleanups.
|
||||
Changes to add_to_cutbuffer(), cut_marked_segment(), and
|
||||
do_uncut_text(). (David Benbennick)
|
||||
- files.c:
|
||||
check_operating_dir()
|
||||
- Add an assert to ensure that full_operatingdir isn't NULL,
|
||||
a fix for reporting nonexistent (incomplete) directory names
|
||||
as being outside the operating directory when tab completion
|
||||
is being used, and cosmetic cleanups. (David Benbennick)
|
||||
copy_file()
|
||||
- New function containing part of the functionality formerly in
|
||||
do_writeout(). (David Benbennick)
|
||||
do_writeout()
|
||||
- Prompt the user if we're trying to save an existing file (and
|
||||
not just a selection of it) under a different name. (DLR;
|
||||
suggested by Jean-Philippe Guérard)
|
||||
open_prevfile(), open_nextfile()
|
||||
- For consistency with the rest of the multibuffer code, change
|
||||
"No more open files" to "No more open file buffers". (DLR)
|
||||
do_browser()
|
||||
- Allow '?' to open the help browser, and readd the ability of
|
||||
'G'/'g' to open the "Go to Directory" prompt (which was
|
||||
erroneously removed before), for compatibility with Pico.
|
||||
(DLR)
|
||||
- global.c:
|
||||
shortcut_init()
|
||||
- Allow WHEREIS_NEXT_KEY to be used in view mode. (DLR)
|
||||
- nano.c:
|
||||
do_int_spell_fix()
|
||||
- Add comment explaining why findnextstr() is called with
|
||||
bracket_mode set to TRUE even though we aren't doing a bracket
|
||||
search. (DLR)
|
||||
do_para_operation()
|
||||
- Convert to use the new low-level input functions. (DLR)
|
||||
main()
|
||||
- Remove unused variable option_index. (DLR)
|
||||
- Fix omission of NANO_NO_KEY in the shortcut list scanning
|
||||
code. (DLR)
|
||||
- Remove now-unnecessary initialization of kbinput. (DLR)
|
||||
- nano.h:
|
||||
- Comment additions and cosmetic tweaks. (DLR)
|
||||
- search.c:
|
||||
findnextstr(), do_replace_loop()
|
||||
- Fix potential infinite loops and other misbehavior when doing
|
||||
beginning-of-line or end-of-line regex replacements ("^", "$",
|
||||
and "^$"). Add a no_sameline parameter to findnextstr(), and
|
||||
set it in the calls in do_replace_loop() when such regexes are
|
||||
found, so that such regexes are only found once per line.
|
||||
Also change length_change from a long to an int; size_t is
|
||||
unsuitable due to its being unsigned. (DLR; found by Mike
|
||||
Frysinger and DLR) David Benbennick: Add a few minor cleanups
|
||||
to do_replace_loop().
|
||||
- winio.c:
|
||||
get_kbinput(), get_accepted_kbinput()
|
||||
- Don't pass in the value of the REBIND_DELETE flag anymore.
|
||||
Instead, handle it directly inside the functions. (DLR)
|
||||
get_accepted_kbinput()
|
||||
- Translate Ctrl-8 into NANO_DELETE_KEY (or NANO_BACKSPACE_KEY
|
||||
if REBIND_DELETE is set), since it apparently is generated
|
||||
sometimes even when keypad() is TRUE. (DLR)
|
||||
- Translate KEY_SLEFT into NANO_BACK_KEY and KEY_SRIGHT into
|
||||
NANO_FORWARD_KEY, since they are sometimes generated by
|
||||
Shift-Left and Shift-Right. (DLR)
|
||||
get_ascii_kbinput()
|
||||
- Tweak to make it slightly more readable. (DLR)
|
||||
get_verbatim_kbinput()
|
||||
- Modify to take an extra parameter indicating if we should
|
||||
interpret ASCII codes or not. (DLR)
|
||||
get_escape_seq_kbinput()
|
||||
- Expand to deal with more broken terminals that don't generate
|
||||
keypad values. Support the escape sequences for Insert,
|
||||
Delete, Home, End, PageUp, and PageDown, [arrow key],
|
||||
Ctrl-[arrow key], and Shift-[arrow key] when needed in the
|
||||
Linux console, the FreeBSD console, the Hurd console, xterm,
|
||||
rxvt, and Eterm. Also, use get_verbatim_kbinput(), with ASCII
|
||||
interpretation disabled, to read in the sequences. (DLR)
|
||||
get_skip_tilde_kbinput()
|
||||
- Removed, as it is unneeded due to the expansion of
|
||||
get_escape_seq_kbinput(). (DLR)
|
||||
get_mouseinput()
|
||||
- Modify to take an extra parameter indicating if we should
|
||||
ungetch() the key equivalents of shortcuts we click on or not.
|
||||
(DLR)
|
||||
nanogetstr()
|
||||
- Properly interpret the Meta key value in misc if we hit it at
|
||||
the statusbar prompt. (DLR)
|
||||
do_yesno()
|
||||
- Add a few efficiency/extensibility tweaks. (David Benbennick)
|
||||
- Convert to use the new low-level input functions, and remove
|
||||
two last hardcoded widths left after the above tweaks. (DLR)
|
||||
do_replace_highlight()
|
||||
- Display a highlighted space if the word length is zero, so
|
||||
that we can see zero-length regexes we're replacing. (DLR;
|
||||
suggested by Mike Frysinger)
|
||||
- configure.ac:
|
||||
- Check for glib 2.x and then 1.2.x if we need glib. (DLR)
|
||||
- faq.html:
|
||||
- Add question explaining how verbatim input works, as well as a
|
||||
few minor fixes. (DLR)
|
||||
- nano.1, nanorc.5:
|
||||
- Add nano version numbers (minus any "-cvs" suffixes). (DLR)
|
||||
- nano.spec.in:
|
||||
- Update for the 1.3 branch of nano. (DLR)
|
||||
- NEWS:
|
||||
- Reformat so all lines are limited to 72 columns, add a few
|
||||
typo fixes, and make a few minor cosmetic cleanups. (DLR)
|
||||
- THANKS:
|
||||
- Add Danilo Segan, for the Serbian translation.
|
||||
|
||||
GNU nano 1.3.0 - 2003.10.22
|
||||
- General:
|
||||
- Complete overhaul and abstraction of the lowest level of
|
||||
|
||||
1
THANKS
1
THANKS
@@ -28,6 +28,7 @@ Sergey A. Ribalchenko <fisher@obu.ck.ua> Russian, Ukrainian translator
|
||||
Michel Robitaille <robitail@IRO.UMontreal.CA> French translator
|
||||
Christian Rose <menthos@menthos.com> Swedish translator
|
||||
Stig E Sandoe <stig@ii.uib.no> Norwegian bokmål translator
|
||||
Danilo Segan <dsegan@gmx.net> Serbian translator
|
||||
Keld Simonsen <keld@dkuug.dk> Danish translator
|
||||
Guus Sliepen <guus@nl.linux.org> Dutch translator
|
||||
Cezary Sliwa <sliwa@cft.edu.pl> Polish translator
|
||||
|
||||
1
TODO
1
TODO
@@ -7,6 +7,7 @@ For version 1.4:
|
||||
- Undo/Redo key?
|
||||
- Rebindable keys?
|
||||
- Keystroke to implement "Add next sequence as raw" like vi's ^V.
|
||||
[DONE for edit window, needs to be done for statusbar prompt]
|
||||
- Spell check selected text only.
|
||||
- Make "To line" (^W^T) and "Read from Command" (^R^X) re-enter their
|
||||
parent menu when their keystroke is entered a second time (^W^T^T and
|
||||
|
||||
19
configure.ac
19
configure.ac
@@ -19,7 +19,7 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [1.3.0], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [1.3.1], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AM_INIT_AUTOMAKE
|
||||
AM_CONFIG_HEADER([config.h:config.h.in])
|
||||
@@ -273,14 +273,13 @@ dnl Checks for functions
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf strcasecmp strncasecmp)
|
||||
if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
|
||||
then
|
||||
AM_PATH_GLIB(1.2.4,,
|
||||
[AC_MSG_ERROR([
|
||||
AM_PATH_GLIB_2_0(2.0.0,,
|
||||
[AM_PATH_GLIB(1.2.4,,
|
||||
[AC_MSG_ERROR([
|
||||
*** snprintf() and/or vsnprintf() not found. GLIB not found either.
|
||||
*** You need both snprintf() and vsnprintf(). Alternatively you can
|
||||
*** install the GLIB library which can be found at ftp://ftp.gtk.org/.])],
|
||||
glib)
|
||||
glib_cflags=`$GLIB_CONFIG --cflags glib`
|
||||
glib_libs=`$GLIB_CONFIG --libs glib`
|
||||
glib)])
|
||||
fi
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
@@ -338,13 +337,13 @@ LIBS="$LIBS $CURSES_LIB"
|
||||
|
||||
AC_SUBST(CURSES_LIB)
|
||||
|
||||
if test "x$glib_cflags" != "x"
|
||||
if test "x$GLIB_CFLAGS" != "x"
|
||||
then
|
||||
CFLAGS="$CFLAGS $glib_cflags"
|
||||
CFLAGS="$CFLAGS $GLIB_CFLAGS"
|
||||
fi
|
||||
if test "x$glib_libs" != "x"
|
||||
if test "x$GLIB_LIBS" != "x"
|
||||
then
|
||||
LDFLAGS="$LDFLAGS $glib_libs"
|
||||
LDFLAGS="$LDFLAGS $GLIB_LIBS"
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
|
||||
20
doc/faq.html
20
doc/faq.html
@@ -29,7 +29,8 @@
|
||||
<a href="#3.5">3.5. Nano should automatically run strip on the binary when installing it!</a><br>
|
||||
<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. How do I make a .nanorc file that nano will read when I start it?</a></p></blockquote>
|
||||
<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>
|
||||
<h2><a href="#4">4. Running</a></h2>
|
||||
<blockquote><p><a href="#4.1">4.1. Ack! My backspace/delete/enter/double bucky/meta key doesn't seem to work! What can I do?</a><br>
|
||||
<a href="#4.2">4.2. Nano crashes when I type <insert keystroke here>!</a><br>
|
||||
@@ -78,7 +79,7 @@
|
||||
<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 1.3.0. 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 1.3.1. 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/v1.2/nano.1.html">here</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
@@ -157,10 +158,14 @@
|
||||
<b>--enable-multibuffer</b> Enables having multiple file buffers open
|
||||
<b>--enable-all</b> Enables all of the above features</pre></blockquote>
|
||||
<h2><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h2>
|
||||
<blockquote><p>To use multiple file buffers, you must be using nano 1.1.12 or newer, and you must have configured nano with <b>--enable-multibuffer</b> or <b>--enable-extra</b> (use nano -V to check). Then when you want to enable inserting a file into its own buffer instead of into the current file, just hit <b>Meta-F</b>, then insert the file as normal with <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano. </p>
|
||||
<blockquote><p>To use multiple file buffers, you must be using nano 1.1.12 or newer, and you must have configured nano with <b>--enable-multibuffer</b> or <b>--enable-extra</b> (use nano -V to check). Then when you want to enable inserting a file into its own buffer instead of into the current file, just hit <b>Meta-F</b>, then insert the file as normal with <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
|
||||
<p>You can move between the buffers you have open with the <b>Meta-<</b> and <b>Meta-></b> keys, or more easily with <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one file buffer open, the ^X shortcut will say "Close", instead of the normal "Exit" when only one buffer is open.</p></blockquote>
|
||||
<h2><a name="3.8"></a>3.8. How do I make a .nanorc file that nano will read when I start it?</h2>
|
||||
<blockquote>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 pico" or "set nowrap".</blockquote>
|
||||
<h2><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h2>
|
||||
<blockquote><p>To use verbatim input, you must be using nano 1.3.1 or newer. When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b>. (If you're not at a prompt, you'll get the message "Verbatim input".) Then press the key(s) that generate the character you want.</p>
|
||||
<p>Alternatively, you can press <b>Meta-V</b> and then type a three-digit ASCII code from 000 to 255, and the character with that ASCII code will be inserted instead.</p>
|
||||
<p><b>NOTE:</b> Verbatim input doesn't work at prompts right now. This will be fixed soon.</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>
|
||||
<hr width="100%">
|
||||
<h1><a name="4"></a>4. Running</h1>
|
||||
<h2><a name="4.1"></a>4.1. Ack! My backspace/delete/enter/double bucky/meta key doesn't seem to work! What can I do?</h2>
|
||||
@@ -195,7 +200,7 @@
|
||||
<p><b>my_hdr X-Composer: nano x.y.z</b></p>
|
||||
<p>Again, replace x.y.z with the version of nano you use.</p></blockquote>
|
||||
<h2><a name="4.8"></a>4.8. I've compiled nano with color support, but I don't see any color when I run it!</h2>
|
||||
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Some example configurations are in the <b>nanorc.sample</b> that comes with the nano source or your nano package. See Section <a href="#3.8">3.8</a>.</p></blockquote>
|
||||
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Some example configurations are in the <b>nanorc.sample</b> that comes with the nano source or your nano package. See Section <a href="#3.9">3.9</a>.</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>
|
||||
@@ -236,8 +241,9 @@
|
||||
<h2><a name="8"></a>8. ChangeLog</h2>
|
||||
<blockquote>
|
||||
<p>
|
||||
2003/12/31 - Added question about the new verbatim input function, and a few minor fixes. Removed reference to "set pico" (DLR).<br>
|
||||
2003/07/02 - Added question about nano's not showing color when it's compiled with color support (DLR; suggested by Jordi).<br>
|
||||
2003/02/23 - Updated RPM links for nano 1.2.x. (DLR).<br>
|
||||
2003/02/23 - Updated RPM links for nano 1.2.x (DLR).<br>
|
||||
2003/01/16 - Split section 4.5 into 4.5a and 4.5b for search string behavior. Added --enable-all docs.<br>
|
||||
2002/12/28 - More misc. fixes (David Benbennick, DLR).<br>
|
||||
2002/10/25 - Misc. fixes and link updates (DLR).<br>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
.\" Public License for copying conditions. There is NO warranty.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANO 1 "August 24, 2003"
|
||||
.TH NANO 1 "version 1.3.1" "January 09, 2004"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
.\" Public License for copying conditions. There is NO warranty.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANORC 5 "August 24, 2003"
|
||||
.TH NANORC 5 "version 1.3.1" "January 09, 2004"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.SH NAME
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
## You can get old nano quoted-justify behavior via:
|
||||
# set quotestr "(> )+"
|
||||
|
||||
## Fix Backspace if it acts like Delete
|
||||
## Fix Backspace/Delete confusion problem
|
||||
# set rebinddelete
|
||||
|
||||
## Do extended regular expression searches by default
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
@c Run `makeinfo' rather than `texinfo-format-buffer'.
|
||||
@smallbook
|
||||
@set EDITION 0.1
|
||||
@set VERSION 1.3.0
|
||||
@set UPDATED 22 Oct 2003
|
||||
@set VERSION 1.3.1
|
||||
@set UPDATED 09 Jan 2004
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 1.3.0
|
||||
@subtitle version 1.3.1
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
|
||||
@@ -9,7 +9,7 @@ Release : %{rel}
|
||||
Copyright : GPL
|
||||
Group : Console/Editors
|
||||
URL : http://www.nano-editor.org
|
||||
Source : http://www.nano-editor.org/dist/v1.2/%{name}-%{ver}.tar.gz
|
||||
Source : http://www.nano-editor.org/dist/v1.3/%{name}-%{ver}.tar.gz
|
||||
BuildRoot : /var/tmp/%{name}-buildroot
|
||||
Requires : ncurses
|
||||
|
||||
@@ -30,7 +30,7 @@ make DESTDIR="$RPM_BUILD_ROOT" install
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README THANKS TODO nanorc.sample
|
||||
%doc AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/nanorc.sample
|
||||
%{_bindir}/nano
|
||||
%{_mandir}/*/*
|
||||
%{_datadir}/locale/*/LC_MESSAGES/nano.mo
|
||||
|
||||
96
po/ChangeLog
96
po/ChangeLog
@@ -1,3 +1,19 @@
|
||||
2003-11-25 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* ro.po: Updated Romanian translation by Laurentiu Buzdugan.
|
||||
|
||||
2003-11-06 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* sr.po: Added Serbian translation by Danilo Segan <dsegan@gmx.net>.
|
||||
* LINGUAS: Added "sr" (Serbian), and alphabetize.
|
||||
* ChangeLog: Recoded as UTF-8.
|
||||
|
||||
2003-10-30 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* fi.po: Patch from Martin-Eric Racine <q-funk@pp.fishpool.fi>
|
||||
to accept "Yy" and "Nn" as well as the Finnish letters in Yes/No
|
||||
prompts.
|
||||
|
||||
2003-10-18 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* ca.po: Updated Catalan translation.
|
||||
@@ -8,7 +24,7 @@
|
||||
|
||||
2003-09-01 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
|
||||
2003-08-17 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
@@ -20,11 +36,11 @@
|
||||
|
||||
2003-06-11 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* nb.po: Updated Norwegian bokmål translation by Geir Helland.
|
||||
* nb.po: Updated Norwegian bokmål translation by Geir Helland.
|
||||
|
||||
2003-06-10 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
|
||||
2003-06-02 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
@@ -46,7 +62,7 @@
|
||||
|
||||
2003-04-04 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
|
||||
2003-03-17 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
@@ -68,7 +84,7 @@
|
||||
2003-02-19 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* fi.po: Updated Finnish translation by Kalle Olavi Niemitalo.
|
||||
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
|
||||
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
|
||||
Medina.
|
||||
|
||||
2003-02-17 Jordi Mallach <jordi@gnu.org>
|
||||
@@ -79,12 +95,12 @@
|
||||
|
||||
2003-02-16 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* gl.po: Updated Galician translation by Jacobo Tarrío.
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
* gl.po: Updated Galician translation by Jacobo Tarrío.
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
|
||||
2003-02-15 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
* nl.po: Updated Dutch translation by Guus Sliepen.
|
||||
* sv.po: Updated Swedish translation by Christian Rose.
|
||||
* ca.po: Updated Catalan translation.
|
||||
@@ -111,8 +127,8 @@
|
||||
2003-02-08 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* it.po: Updated Italian translation by Marco Colombo.
|
||||
* gl.po: Updated Galician translation by Jacobo Tarrío.
|
||||
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
|
||||
* gl.po: Updated Galician translation by Jacobo Tarrío.
|
||||
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
|
||||
Medina.
|
||||
|
||||
2003-02-06 Jordi Mallach <jordi@gnu.org>
|
||||
@@ -123,13 +139,13 @@
|
||||
2003-02-04 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* ca.po: Updated Catalan translation.
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated French translation by Jean-Philippe Guérard.
|
||||
* uk.po: Updated Ukrainian translation by Sergey A. Ribalchenko.
|
||||
* de.po: Updated German translation by Michael Piefel.
|
||||
|
||||
2003-01-27 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
|
||||
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
|
||||
|
||||
2002-01-26 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
@@ -137,7 +153,7 @@
|
||||
|
||||
2002-01-25 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
|
||||
2002-01-22 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
@@ -145,13 +161,13 @@
|
||||
|
||||
2003-01-21 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
|
||||
* uk.po: Updated translation by Sergey A. Ribalchenko.
|
||||
|
||||
2003-01-18 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* sv.po: Updated translation by Christian Rose.
|
||||
* nl.po: Updated translation by Guus Sliepen.
|
||||
* ca.po: Updated translation.
|
||||
@@ -175,7 +191,7 @@
|
||||
|
||||
2002-12-14 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* tr.po: New Turkish translation by Doruk Fisek.
|
||||
|
||||
2002-11-10 Jordi Mallach <jordi@sindominio.net>
|
||||
@@ -195,22 +211,22 @@
|
||||
2002-10-29 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* id.po: Updated translation by Tedi Heriyanto.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-10-27 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-10-26 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
|
||||
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
|
||||
|
||||
2002-10-26 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
* sv.po: Updated translation by Christian Rose.
|
||||
* de.po: Updated translation by Michael Piefel.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* ca.po: Updated translation.
|
||||
|
||||
2002-10-17 Jordi Mallach <jordi@sindominio.net>
|
||||
@@ -219,11 +235,11 @@
|
||||
|
||||
2002-10-14 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-10-13 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
|
||||
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
|
||||
|
||||
2002-10-08 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
@@ -241,7 +257,7 @@
|
||||
2002-10-07 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* sv.po: Updated translation by Christian Rose.
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
* pl.po: Updated translation by Wojciech Kotwica.
|
||||
|
||||
2002-09-08 Jordi Mallach <jordi@sindominio.net>
|
||||
@@ -250,7 +266,7 @@
|
||||
|
||||
2002-09-08 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* da.po: Updated translation by Keld Simonsen.
|
||||
|
||||
2002-08-19 Jordi Mallach <jordi@sindominio.net>
|
||||
@@ -260,15 +276,15 @@
|
||||
|
||||
2002-07-31 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
|
||||
2002-07-31 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
|
||||
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
|
||||
|
||||
2002-07-31 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-07-30 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
@@ -318,13 +334,13 @@
|
||||
|
||||
2002-05-13 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* de.po: Updated translation by Michael Piefel.
|
||||
|
||||
2002-05-13 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* it.po: Updated translation by Marco Colombo.
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
* gl.po: Updated translation by Jacobo Tarrío.
|
||||
* ca.po: Updated translation.
|
||||
* es.po: Updated translation.
|
||||
|
||||
@@ -361,7 +377,7 @@
|
||||
|
||||
* gl.po: Updated translation by Jacobo Tarrio.
|
||||
* de.po: Updated translation by Michael Piefel.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* ca.po: Updated.
|
||||
* es.po: Updated.
|
||||
|
||||
@@ -379,7 +395,7 @@
|
||||
|
||||
2002-03-17 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-03-15 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
@@ -402,7 +418,7 @@
|
||||
|
||||
2002-03-11 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-03-09 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
@@ -450,7 +466,7 @@
|
||||
|
||||
2002-02-06 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* cs.po: Incomplete update by Václav Haisman.
|
||||
* cs.po: Incomplete update by Václav Haisman.
|
||||
|
||||
2002-01-27 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
@@ -458,14 +474,14 @@
|
||||
|
||||
2002-01-26 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* nn.po: Updated translation by Kjetil Torgrim Homme.
|
||||
* de.po: Updated translation by Michael Piefel.
|
||||
|
||||
2002-01-25 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* sv.po: Updated translation by Christian Rose.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-01-25 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
@@ -496,21 +512,21 @@
|
||||
|
||||
* no.po: Removed, replaced by nn.po.
|
||||
* nn.po: Updated translation by Kjetil Torgrim Homme.
|
||||
* nb.po: New Norwegian bokmål translation by Stig E Sandoe.
|
||||
* nb.po: New Norwegian bokmål translation by Stig E Sandoe.
|
||||
|
||||
2002-01-12 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-01-10 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-01-08 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
* ru.po, uk.po: Updated translations by Sergey A.
|
||||
Ribalchenko.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
* fr.po: Updated translation by Jean-Philippe Guérard.
|
||||
|
||||
2002-01-07 Jordi Mallach <jordi@sindominio.net>
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# List of available languages.
|
||||
es de fr it id fi hu ca cs gl uk ru sv nn nl da pl nb ms pt_BR tr eu ro
|
||||
ca cs da de es eu fi fr gl hu id it ms nb nl nn pl pt_BR ro ru sr sv tr uk
|
||||
|
||||
4
po/fi.po
4
po/fi.po
@@ -1592,11 +1592,11 @@ msgstr "En hyv
|
||||
|
||||
#: winio.c:1297
|
||||
msgid "Yy"
|
||||
msgstr "Kk"
|
||||
msgstr "KkYy"
|
||||
|
||||
#: winio.c:1298
|
||||
msgid "Nn"
|
||||
msgstr "Ee"
|
||||
msgstr "EeNn"
|
||||
|
||||
#: winio.c:1299
|
||||
msgid "Aa"
|
||||
|
||||
265
po/ro.po
265
po/ro.po
@@ -6,10 +6,9 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: nano 1.2.1\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Project-Id-Version: nano 1.2.2\n"
|
||||
"POT-Creation-Date: 2003-08-11 21:49-0400\n"
|
||||
"PO-Revision-Date: 2003-04-22 23:00-0600\n"
|
||||
"PO-Revision-Date: 2003-11-24 12:00-0500\n"
|
||||
"Last-Translator: Laurentiu Buzdugan <buzdugan@voyager.net>\n"
|
||||
"Language-Team: Romanian <translation-team-ro@lists.sourceforge.net>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -423,8 +422,7 @@ msgstr "Insereaz
|
||||
|
||||
#: global.c:382
|
||||
msgid "Insert a carriage return at the cursor position"
|
||||
msgstr ""
|
||||
"Insereazã un caracter \"carriage return\" la poziþia curentã a cursorului"
|
||||
msgstr "Insereazã un caracter \"carriage return\" la poziþia curentã a cursorului"
|
||||
|
||||
#: global.c:384
|
||||
msgid "Make the current search or replace case (in)sensitive"
|
||||
@@ -736,26 +734,18 @@ msgstr "Tast
|
||||
msgid ""
|
||||
"Search Command Help Text\n"
|
||||
"\n"
|
||||
" Enter the words or characters you would like to search for, then hit "
|
||||
"enter. If there is a match for the text you entered, the screen will be "
|
||||
"updated to the location of the nearest match for the search string.\n"
|
||||
" Enter the words or characters you would like to search for, then hit enter. If there is a match for the text you entered, the screen will be updated to the location of the nearest match for the search string.\n"
|
||||
"\n"
|
||||
" The previous search string will be shown in brackets after the Search: "
|
||||
"prompt. Hitting Enter without entering any text will perform the previous "
|
||||
"search.\n"
|
||||
" The previous search string will be shown in brackets after the Search: prompt. Hitting Enter without entering any text will perform the previous search.\n"
|
||||
"\n"
|
||||
" The following function keys are available in Search mode:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
"Text de ajutor pentru comanda \"Cautã\"\n"
|
||||
"\n"
|
||||
"Introduceþi cuvântul sau caracterele pe care aþi dori sã le cãutaþi, apoi "
|
||||
"apãsaþi Enter. Dacã existã vreo potrivire pentru textul cãutat, ecranul va "
|
||||
"fi actualizat la locaþia cea mai apropiatã de locul unde aceastã potrivire a "
|
||||
"avut loc.\n"
|
||||
"Introduceþi cuvântul sau caracterele pe care aþi dori sã le cãutaþi, apoi apãsaþi Enter. Dacã existã vreo potrivire pentru textul cãutat, ecranul va fi actualizat la locaþia cea mai apropiatã de locul unde aceastã potrivire a avut loc.\n"
|
||||
"\n"
|
||||
"ªirul cãutat anterior va fi arãtat în paranteze dupã cuvântul Cautã: . "
|
||||
"Apãsând Enter fãrã a introduce vreun text va executa cãutarea anterioarã.\n"
|
||||
"ªirul cãutat anterior va fi arãtat în paranteze dupã cuvântul Cautã: . Apãsând Enter fãrã a introduce vreun text va executa cãutarea anterioarã.\n"
|
||||
"\n"
|
||||
"Urmãtoarele taste de funcþii sunt disponibile în modul \"Cautã\"\n"
|
||||
"\n"
|
||||
@@ -764,18 +754,14 @@ msgstr ""
|
||||
msgid ""
|
||||
"Go To Line Help Text\n"
|
||||
"\n"
|
||||
" Enter the line number that you wish to go to and hit Enter. If there are "
|
||||
"fewer lines of text than the number you entered, you will be brought to the "
|
||||
"last line of the file.\n"
|
||||
" Enter the line number that you wish to go to and hit Enter. If there are fewer lines of text than the number you entered, you will be brought to the last line of the file.\n"
|
||||
"\n"
|
||||
" The following function keys are available in Go To Line mode:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
"Textul de ajutor pentru \"Du-te la linia\"\n"
|
||||
"\n"
|
||||
" Introduceþi numãrul liniei unde doriþi sã mergeþi ºi apãsaþi Enter. Dacã "
|
||||
"existã mai puþine linii de text decât numãrul introdus veþi ajunge la ultima "
|
||||
"linie a fiºierului.\n"
|
||||
" Introduceþi numãrul liniei unde doriþi sã mergeþi ºi apãsaþi Enter. Dacã existã mai puþine linii de text decât numãrul introdus veþi ajunge la ultima linie a fiºierului.\n"
|
||||
"\n"
|
||||
" Urmãtoarele taste de funcþii sunt disponibile în modul \"Du-te la linia\" \n"
|
||||
|
||||
@@ -783,61 +769,41 @@ msgstr ""
|
||||
msgid ""
|
||||
"Insert File Help Text\n"
|
||||
"\n"
|
||||
" Type in the name of a file to be inserted into the current file buffer at "
|
||||
"the current cursor location.\n"
|
||||
" Type in the name of a file to be inserted into the current file buffer at the current cursor location.\n"
|
||||
"\n"
|
||||
" If you have compiled nano with multiple file buffer support, and enable "
|
||||
"multiple buffers with the -F or --multibuffer command line flags, the Meta-F "
|
||||
"toggle, or a nanorc file, inserting a file will cause it to be loaded into a "
|
||||
"separate buffer (use Meta-< and > to switch between file buffers).\n"
|
||||
" If you have compiled nano with multiple file buffer support, and enable multiple buffers with the -F or --multibuffer command line flags, the Meta-F toggle, or a nanorc file, inserting a file will cause it to be loaded into a separate buffer (use Meta-< and > to switch between file buffers).\n"
|
||||
"\n"
|
||||
" If you need another blank buffer, do not enter any filename, or type in a "
|
||||
"nonexistent filename at the prompt and press Enter.\n"
|
||||
" If you need another blank buffer, do not enter any filename, or type in a nonexistent filename at the prompt and press Enter.\n"
|
||||
"\n"
|
||||
" The following function keys are available in Insert File mode:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
"Textul de ajutor pentru \"Insereazã fiºier\"\n"
|
||||
"\n"
|
||||
" Tastaþi numele unui fiºier de introdus în buffer-ul pentru fiºierul curent "
|
||||
"la poziþia curentã a cursorului.\n"
|
||||
" Tastaþi numele unui fiºier de introdus în buffer-ul pentru fiºierul curent la poziþia curentã a cursorului.\n"
|
||||
"\n"
|
||||
" Dacã aþi compilat nano cu suport pentru multiple buffere ºi aþi activat "
|
||||
"acestã opþiune cu indicatorii de linie de comandã -F sau --multibuffer, "
|
||||
"comutatorul Meta-F, sau un fiºier nanorc, inserând un fiºier va face ca "
|
||||
"acesta sã fie încãrcat într-un alt buffer (folosiþi Meta-< ºi > pentru a "
|
||||
"comuta între buffere).\n"
|
||||
" Dacã aþi compilat nano cu suport pentru multiple buffere ºi aþi activat acestã opþiune cu indicatorii de linie de comandã -F sau --multibuffer, comutatorul Meta-F, sau un fiºier nanorc, inserând un fiºier va face ca acesta sã fie încãrcat într-un alt buffer (folosiþi Meta-< ºi > pentru a comuta între buffere).\n"
|
||||
"\n"
|
||||
"Dacã aveþi nevoie de un alt buffer liber, nu introduceþi nici un nume sau "
|
||||
"introduceþi un nume de fiºier ce nu existã ºi apãsaþi Enter.\n"
|
||||
"Dacã aveþi nevoie de un alt buffer liber, nu introduceþi nici un nume sau introduceþi un nume de fiºier ce nu existã ºi apãsaþi Enter.\n"
|
||||
"\n"
|
||||
" Urmãtoarele taste de funcþii sunt disponibile în modul \"Insereazã fiºier"
|
||||
"\" \n"
|
||||
" Urmãtoarele taste de funcþii sunt disponibile în modul \"Insereazã fiºier\" \n"
|
||||
|
||||
#: nano.c:310
|
||||
msgid ""
|
||||
"Write File Help Text\n"
|
||||
"\n"
|
||||
" Type the name that you wish to save the current file as and hit Enter to "
|
||||
"save the file.\n"
|
||||
" Type the name that you wish to save the current file as and hit Enter to save the file.\n"
|
||||
"\n"
|
||||
" If you have selected text with Ctrl-^, you will be prompted to save only "
|
||||
"the selected portion to a separate file. To reduce the chance of "
|
||||
"overwriting the current file with just a portion of it, the current filename "
|
||||
"is not the default in this mode.\n"
|
||||
" If you have selected text with Ctrl-^, you will be prompted to save only the selected portion to a separate file. To reduce the chance of overwriting the current file with just a portion of it, the current filename is not the default in this mode.\n"
|
||||
"\n"
|
||||
" The following function keys are available in Write File mode:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
"Textul de ajutor pentru \"Scrie fiºier\"\n"
|
||||
"\n"
|
||||
" Tastaþi numele sub care doriþi sã salvaþi fiºierul curent ºi apãsaþi Enter "
|
||||
"pentru a salva fiºierul.\n"
|
||||
" Tastaþi numele sub care doriþi sã salvaþi fiºierul curent ºi apãsaþi Enter pentru a salva fiºierul.\n"
|
||||
"\n"
|
||||
" Dacã aþi selectat text cu Ctrl-^, veþi fi interpolat sã salvaþi numai "
|
||||
"porþiunea selectatã într-un fiºier separat. Pentru a reduce ºansa de a "
|
||||
"suprascrie fiºierul curent cu doar o porþiune a sa, numele de fiºier curent "
|
||||
"nu este implicit în acest mod.\n"
|
||||
" Dacã aþi selectat text cu Ctrl-^, veþi fi interpolat sã salvaþi numai porþiunea selectatã într-un fiºier separat. Pentru a reduce ºansa de a suprascrie fiºierul curent cu doar o porþiune a sa, numele de fiºier curent nu este implicit în acest mod.\n"
|
||||
"\n"
|
||||
" Urmãtoarele taste de funcþii sunt disponibile în modul \"Scrie fiºier\"\n"
|
||||
"\n"
|
||||
@@ -846,23 +812,14 @@ msgstr ""
|
||||
msgid ""
|
||||
"File Browser Help Text\n"
|
||||
"\n"
|
||||
" The file browser is used to visually browse the directory structure to "
|
||||
"select a file for reading or writing. You may use the arrow keys or Page Up/"
|
||||
"Down to browse through the files, and S or Enter to choose the selected file "
|
||||
"or enter the selected directory. To move up one level, select the directory "
|
||||
"called \"..\" at the top of the file list.\n"
|
||||
" The file browser is used to visually browse the directory structure to select a file for reading or writing. You may use the arrow keys or Page Up/Down to browse through the files, and S or Enter to choose the selected file or enter the selected directory. To move up one level, select the directory called \"..\" at the top of the file list.\n"
|
||||
"\n"
|
||||
" The following function keys are available in the file browser:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
"Textul de ajutor pentru \"Navigator fiºiere\"\n"
|
||||
"\n"
|
||||
" Navigatorul de fiºiere este folosit pentru a naviga vizual structura de "
|
||||
"directoare ºi a selecta un fiºier pentru citire sau scriere. Puteþi folosi "
|
||||
"tastele cu sãgeþi sau Page Up/Down pentru a naviga prin fiºiere, ºi S sau "
|
||||
"Enter pentru a alege fiºierul selectat sau a intra într-un director "
|
||||
"selectat. Pentru a vã muta în sus un nivel, selectaþi directorul numit \".."
|
||||
"\" din capãtul de sus a listei de fiºiere.\n"
|
||||
" Navigatorul de fiºiere este folosit pentru a naviga vizual structura de directoare ºi a selecta un fiºier pentru citire sau scriere. Puteþi folosi tastele cu sãgeþi sau Page Up/Down pentru a naviga prin fiºiere, ºi S sau Enter pentru a alege fiºierul selectat sau a intra într-un director selectat. Pentru a vã muta în sus un nivel, selectaþi directorul numit \"..\" din capãtul de sus a listei de fiºiere.\n"
|
||||
"\n"
|
||||
" Urmãtoarele taste de funcþii sunt disponibile în \"Navigator fiºiere\":\n"
|
||||
"\n"
|
||||
@@ -873,8 +830,7 @@ msgid ""
|
||||
"\n"
|
||||
" Enter the name of the directory you would like to browse to.\n"
|
||||
"\n"
|
||||
" If tab completion has not been disabled, you can use the TAB key to "
|
||||
"(attempt to) automatically complete the directory name.\n"
|
||||
" If tab completion has not been disabled, you can use the TAB key to (attempt to) automatically complete the directory name.\n"
|
||||
"\n"
|
||||
" The following function keys are available in Browser Go To Directory mode:\n"
|
||||
"\n"
|
||||
@@ -883,51 +839,39 @@ msgstr ""
|
||||
"\n"
|
||||
" Introduceþi numele directorului pe care aþi dori sã-l navigaþi.\n"
|
||||
"\n"
|
||||
" Dacã completarea cu tab nu a fost deactivatã, puteþi folosi tasta TAB "
|
||||
"pentru a încerca sã completaþi automat numele directorului.\n"
|
||||
" Dacã completarea cu tab nu a fost deactivatã, puteþi folosi tasta TAB pentru a încerca sã completaþi automat numele directorului.\n"
|
||||
"\n"
|
||||
" Urmãtoarele taste de funcþii sunt disponibile în modul \"Navigator Du-te la "
|
||||
"Directorul\":\n"
|
||||
" Urmãtoarele taste de funcþii sunt disponibile în modul \"Navigator Du-te la Directorul\":\n"
|
||||
"\n"
|
||||
|
||||
#: nano.c:341
|
||||
msgid ""
|
||||
"Spell Check Help Text\n"
|
||||
"\n"
|
||||
" The spell checker checks the spelling of all text in the current file. "
|
||||
"When an unknown word is encountered, it is highlighted and a replacement can "
|
||||
"be edited. It will then prompt to replace every instance of the given "
|
||||
"misspelled word in the current file.\n"
|
||||
" The spell checker checks the spelling of all text in the current file. When an unknown word is encountered, it is highlighted and a replacement can be edited. It will then prompt to replace every instance of the given misspelled word in the current file.\n"
|
||||
"\n"
|
||||
" The following other functions are available in Spell Check mode:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
"Text de ajutor pentru \"Corector ortografic\"\n"
|
||||
"\n"
|
||||
" Corectorul ortografic verificã ortografierea întregului text din fiºierul "
|
||||
"curent. Când un cuvânt necunoscut este întâlnit, acesta este evidenþiat ºi "
|
||||
"un înlocuitor poate fi introdus/editat. Corectorul vã va întreba dacã "
|
||||
"doriþi sã înlocuiþi toate apariþiile cu aceeaºi greºealã în fiºierul "
|
||||
"curent.\n"
|
||||
" Corectorul ortografic verificã ortografierea întregului text din fiºierul curent. Când un cuvânt necunoscut este întâlnit, acesta este evidenþiat ºi un înlocuitor poate fi introdus/editat. Corectorul vã va întreba dacã doriþi sã înlocuiþi toate apariþiile cu aceeaºi greºealã în fiºierul curent.\n"
|
||||
"\n"
|
||||
" Urmãtoarele alte funcþii sunt disponibile în modul \"Corector ortografic"
|
||||
"\":\n"
|
||||
" Urmãtoarele alte funcþii sunt disponibile în modul \"Corector ortografic\":\n"
|
||||
"\n"
|
||||
|
||||
#: nano.c:352
|
||||
msgid ""
|
||||
"External Command Help Text\n"
|
||||
"\n"
|
||||
" This menu allows you to insert the output of a command run by the shell "
|
||||
"into the current buffer (or a new buffer in multibuffer mode).\n"
|
||||
" This menu allows you to insert the output of a command run by the shell into the current buffer (or a new buffer in multibuffer mode).\n"
|
||||
"\n"
|
||||
" The following keys are available in this mode:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
"Text de ajutor \"Comandã externã\"\n"
|
||||
"\n"
|
||||
" Acest meniu vã permite sã inseraþi ieºirea unei comenzi executate de shell "
|
||||
"în buffer-ul curent (sau într-un nou buffer în modul multibuffer).\n"
|
||||
" Acest meniu vã permite sã inseraþi ieºirea unei comenzi executate de shell în buffer-ul curent (sau într-un nou buffer în modul multibuffer).\n"
|
||||
"\n"
|
||||
" Urmãtoarele taste sunt disponibile în acest mod:\n"
|
||||
"\n"
|
||||
@@ -936,40 +880,16 @@ msgstr ""
|
||||
msgid ""
|
||||
" nano help text\n"
|
||||
"\n"
|
||||
" The nano editor is designed to emulate the functionality and ease-of-use of "
|
||||
"the UW Pico text editor. There are four main sections of the editor: The "
|
||||
"top line shows the program version, the current filename being edited, and "
|
||||
"whether or not the file has been modified. Next is the main editor window "
|
||||
"showing the file being edited. The status line is the third line from the "
|
||||
"bottom and shows important messages. The bottom two lines show the most "
|
||||
"commonly used shortcuts in the editor.\n"
|
||||
" The nano editor is designed to emulate the functionality and ease-of-use of the UW Pico text editor. There are four main sections of the editor: The top line shows the program version, the current filename being edited, and whether or not the file has been modified. Next is the main editor window showing the file being edited. The status line is the third line from the bottom and shows important messages. The bottom two lines show the most commonly used shortcuts in the editor.\n"
|
||||
"\n"
|
||||
" The notation for shortcuts is as follows: Control-key sequences are notated "
|
||||
"with a caret (^) symbol and are entered with the Control (Ctrl) key. Escape-"
|
||||
"key sequences are notated with the Meta (M) symbol and can be entered using "
|
||||
"either the Esc, Alt or Meta key depending on your keyboard setup. The "
|
||||
"following keystrokes are available in the main editor window. Alternative "
|
||||
"keys are shown in parentheses:\n"
|
||||
" The notation for shortcuts is as follows: Control-key sequences are notated with a caret (^) symbol and are entered with the Control (Ctrl) key. Escape-key sequences are notated with the Meta (M) symbol and can be entered using either the Esc, Alt or Meta key depending on your keyboard setup. The following keystrokes are available in the main editor window. Alternative keys are shown in parentheses:\n"
|
||||
"\n"
|
||||
msgstr ""
|
||||
" text ajutor pentru nano\n"
|
||||
"\n"
|
||||
" Editotul nano este proiectat sa emuleze funþionalitatea ºi uºurinþa de "
|
||||
"folosire a editorului de texte UW Pico. Existã patru secþiuni principale "
|
||||
"ale editorului: Linia de sus aratã versiunea programului, numele fiºierului "
|
||||
"curent ce este editat ºi dacã fiºierul a fost sau nu modificat. Urmãtoarea "
|
||||
"secþiune principalã este fereastra de editare ce aratã fiºierul ce este "
|
||||
"editat. Linia de stare este a treia linie de jos ºi aratã mesaje "
|
||||
"importante. Ultimele douã linii aratã cele mai frecvente scurtãturi "
|
||||
"folosite în editor.\n"
|
||||
" Editotul nano este proiectat sa emuleze funþionalitatea ºi uºurinþa de folosire a editorului de texte UW Pico. Existã patru secþiuni principale ale editorului: Linia de sus aratã versiunea programului, numele fiºierului curent ce este editat ºi dacã fiºierul a fost sau nu modificat. Urmãtoarea secþiune principalã este fereastra de editare ce aratã fiºierul ce este editat. Linia de stare este a treia linie de jos ºi aratã mesaje importante. Ultimele douã linii aratã cele mai frecvente scurtãturi folosite în editor.\n"
|
||||
"\n"
|
||||
" Notaþia pentru scurtãturi este dupã cum urmeazã: secvenþe Control-tastã "
|
||||
"sunt notate cu un simbol (^) ºi sunt introduse cu tasta Control (Ctrl). "
|
||||
"Secvenþele Escape-tastã sunt notate cu sombolul Meta (M) ºi pot fi introduse "
|
||||
"folosind oricare din tastele Esc, Alt sau Meta, în funcþie de setarea "
|
||||
"tastaturii d-voastrã. Urmãtoarele combinaþii de taste sunt disponibile în "
|
||||
"fereastra de editare principalã. Tastele alternative sunt arãtate în "
|
||||
"paranteze:\n"
|
||||
" Notaþia pentru scurtãturi este dupã cum urmeazã: secvenþe Control-tastã sunt notate cu un simbol (^) ºi sunt introduse cu tasta Control (Ctrl). Secvenþele Escape-tastã sunt notate cu sombolul Meta (M) ºi pot fi introduse folosind oricare din tastele Esc, Alt sau Meta, în funcþie de setarea tastaturii d-voastrã. Urmãtoarele combinaþii de taste sunt disponibile în fereastra de editare principalã. Tastele alternative sunt arãtate în paranteze:\n"
|
||||
"\n"
|
||||
|
||||
#: nano.c:388 nano.c:458
|
||||
@@ -1154,7 +1074,7 @@ msgstr "Permite corector ortografic alternativ"
|
||||
|
||||
#: nano.c:680
|
||||
msgid "Auto save on exit, don't prompt"
|
||||
msgstr "Saulveazã automat la ieºire, nu întreba"
|
||||
msgstr "Salveazã automat la ieºire, nu întreba"
|
||||
|
||||
#: nano.c:681
|
||||
msgid "View (read only) mode"
|
||||
@@ -1275,8 +1195,7 @@ msgstr "Nu pot De-Alinia!"
|
||||
|
||||
#: nano.c:2696
|
||||
msgid "Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "
|
||||
msgstr ""
|
||||
"Salvez buffer-ul modificat (RÃSPUNSUL \"Nu\" VA DISTRUGE SCHIMBÃRILE) ?"
|
||||
msgstr "Salvez buffer-ul modificat (RÃSPUNSUL \"Nu\" VA DISTRUGE SCHIMBÃRILE) ?"
|
||||
|
||||
#: nano.c:2796
|
||||
msgid "Received SIGHUP or SIGTERM\n"
|
||||
@@ -1312,9 +1231,7 @@ msgstr "Nu pot muta fereastra de jos"
|
||||
|
||||
#: nano.c:2919
|
||||
msgid "NumLock glitch detected. Keypad will malfunction with NumLock off"
|
||||
msgstr ""
|
||||
"Am detectat problema cu NumLock. Keypad-ul va funcþiona greºit cu NumLock "
|
||||
"deactivat"
|
||||
msgstr "Am detectat problema cu NumLock. Keypad-ul va funcþiona greºit cu NumLock deactivat"
|
||||
|
||||
#: nano.c:2968
|
||||
msgid "enabled"
|
||||
@@ -1569,8 +1486,7 @@ msgstr "Nu"
|
||||
#: winio.c:1499
|
||||
#, c-format
|
||||
msgid "line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%ld (%d%%)"
|
||||
msgstr ""
|
||||
"linia %ld/%ld (%d%%), coloana %lu/%lu (%d%%), caracterul %lu/%ld (%d%%)"
|
||||
msgstr "linia %ld/%ld (%d%%), coloana %lu/%lu (%d%%), caracterul %lu/%ld (%d%%)"
|
||||
|
||||
#: winio.c:1838
|
||||
msgid "The nano text editor"
|
||||
@@ -1603,108 +1519,3 @@ msgstr "
|
||||
#: winio.c:1845
|
||||
msgid "Thank you for using nano!\n"
|
||||
msgstr "Vã mulþumim cã folosiþi nano!\n"
|
||||
|
||||
#~ msgid "add_to_cutbuffer() called with inptr->data = %s\n"
|
||||
#~ msgstr "add_to_cutbuffer() chemat cu inptr->data = %s\n"
|
||||
|
||||
#~ msgid "Blew away cutbuffer =)\n"
|
||||
#~ msgstr "Am renunþat la conþinutul cutbuffer-ului =)\n"
|
||||
|
||||
#~ msgid "filename is %s\n"
|
||||
#~ msgstr "nume_fiºier este %s\n"
|
||||
|
||||
#~ msgid "%s: free'd a node, YAY!\n"
|
||||
#~ msgstr "%s: am eliberat un nod, URA!\n"
|
||||
|
||||
#~ msgid "%s: free'd last node.\n"
|
||||
#~ msgstr "%s: am eliberat ultimul nod.\n"
|
||||
|
||||
#~ msgid "Backing up %s to %s\n"
|
||||
#~ msgstr "Copiez pentru siguranþã (backup) %s în %s\n"
|
||||
|
||||
#~ msgid "Wrote >%s\n"
|
||||
#~ msgstr "Am scris >%s\n"
|
||||
|
||||
#~ msgid "current->data now = \"%s\"\n"
|
||||
#~ msgstr "current->data acum = \"%s\"\n"
|
||||
|
||||
#~ msgid "After, data = \"%s\"\n"
|
||||
#~ msgstr "Dupã, data = \"%s\"\n"
|
||||
|
||||
#~ msgid "Main: set up windows\n"
|
||||
#~ msgstr "Principal: seteazã ferestre\n"
|
||||
|
||||
#~ msgid "Main: bottom win\n"
|
||||
#~ msgstr "Principal: fereastra de jos\n"
|
||||
|
||||
#~ msgid "Main: open file\n"
|
||||
#~ msgstr "Principal: deschide fiºier\n"
|
||||
|
||||
#~ msgid "AHA! %c (%d)\n"
|
||||
#~ msgstr "AHA! %c (%d)\n"
|
||||
|
||||
#~ msgid "I got Alt-O-%c! (%d)\n"
|
||||
#~ msgstr "Am primit Alt-O-%c! (%d)\n"
|
||||
|
||||
#~ msgid "I got Alt-[-1-%c! (%d)\n"
|
||||
#~ msgstr "Am primit Alt-[-1-%c! (%d)\n"
|
||||
|
||||
#~ msgid "I got Alt-[-2-%c! (%d)\n"
|
||||
#~ msgstr "Am primit Alt-[-2-%c! (%d)\n"
|
||||
|
||||
#~ msgid "I got Alt-[-%c! (%d)\n"
|
||||
#~ msgstr "Am primit Alt-[-%c! (%d)\n"
|
||||
|
||||
#~ msgid "I got Alt-%c! (%d)\n"
|
||||
#~ msgstr "Am primit Alt-%c! (%d)\n"
|
||||
|
||||
#~ msgid "I got %c (%d)!\n"
|
||||
#~ msgstr "Am primit %c (%d)!\n"
|
||||
|
||||
#~ msgid "Adding new syntax after 1st\n"
|
||||
#~ msgstr "Adaug o nouã sintaxã dupã primul\n"
|
||||
|
||||
#~ msgid "Starting a new syntax type\n"
|
||||
#~ msgstr "Încep un nou tip de sintaxã\n"
|
||||
|
||||
#~ msgid "Starting a new colorstring for fg %d bg %d\n"
|
||||
#~ msgstr "Încep un nou ºir_culoare pentru fg %d bg %d\n"
|
||||
|
||||
#~ msgid "Adding new entry for fg %d bg %d\n"
|
||||
#~ msgstr "Adaug o nouã intrare pentru fg %d bg %d\n"
|
||||
|
||||
#~ msgid "%s: Read a comment\n"
|
||||
#~ msgstr "%s: Am citit un comentariu\n"
|
||||
|
||||
#~ msgid "%s: Parsing option %s\n"
|
||||
#~ msgstr "%s: Interpretare opþiune %s\n"
|
||||
|
||||
#~ msgid "set flag %d!\n"
|
||||
#~ msgstr "seteazã marcaj (flag) %d!\n"
|
||||
|
||||
#~ msgid "unset flag %d!\n"
|
||||
#~ msgstr "deseteazã marcaj (flag) %d!\n"
|
||||
|
||||
#~ msgid "actual_x for xplus=%d returns %d\n"
|
||||
#~ msgstr "actual_x pentru xplus=%d întoarce %d\n"
|
||||
|
||||
#~ msgid "Aha! '%c' (%d)\n"
|
||||
#~ msgstr "Aha! '%c' (%d)\n"
|
||||
|
||||
#~ msgid "input '%c' (%d)\n"
|
||||
#~ msgstr "intrare '%c' (%d)\n"
|
||||
|
||||
#~ msgid "Moved to (%d, %d) in edit buffer\n"
|
||||
#~ msgstr "Mutat la (%d, %d) în buffer-ul de editare\n"
|
||||
|
||||
#~ msgid "I got \"%s\"\n"
|
||||
#~ msgstr "Am primit \"%s\"\n"
|
||||
|
||||
#~ msgid "Dumping file buffer to stderr...\n"
|
||||
#~ msgstr "Scriu fiºierul buffer la stderr...\n"
|
||||
|
||||
#~ msgid "Dumping cutbuffer to stderr...\n"
|
||||
#~ msgstr "Scriu cutbuffer-ul la stderr...\n"
|
||||
|
||||
#~ msgid "Dumping a buffer to stderr...\n"
|
||||
#~ msgstr "Scriu un buffer la stderr...\n"
|
||||
|
||||
10
src/color.c
10
src/color.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* color.c *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -39,14 +39,14 @@ void set_colorpairs(void)
|
||||
{
|
||||
const syntaxtype *this_syntax = syntaxes;
|
||||
|
||||
for(; this_syntax != NULL; this_syntax = this_syntax->next) {
|
||||
for (; this_syntax != NULL; this_syntax = this_syntax->next) {
|
||||
colortype *this_color = this_syntax->color;
|
||||
int color_pair = 1;
|
||||
|
||||
for(; this_color != NULL; this_color = this_color->next) {
|
||||
for (; this_color != NULL; this_color = this_color->next) {
|
||||
const colortype *beforenow = this_syntax->color;
|
||||
|
||||
for(; beforenow != NULL && beforenow != this_color &&
|
||||
for (; beforenow != NULL && beforenow != this_color &&
|
||||
(beforenow->fg != this_color->fg ||
|
||||
beforenow->bg != this_color->bg ||
|
||||
beforenow->bright != this_color->bright);
|
||||
@@ -109,7 +109,7 @@ void update_color(void)
|
||||
|
||||
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
|
||||
/* Set colorstrings if we matched the extension regex */
|
||||
if (!regexec(&e->val, filename, 0, NULL, 0))
|
||||
if (regexec(&e->val, filename, 0, NULL, 0) == 0)
|
||||
colorstrings = tmpsyntax->color;
|
||||
|
||||
if (colorstrings != NULL)
|
||||
|
||||
319
src/cut.c
319
src/cut.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* cut.c *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -28,15 +28,17 @@
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
static int marked_cut; /* Is the cutbuffer from a mark? */
|
||||
static int marked_cut; /* Is the cutbuffer from a mark?
|
||||
* 0 means whole-line cut, 1 means mark,
|
||||
* 2 means cut-from-cursor. */
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
static int concatenate_cut; /* Should we add this cut string to the
|
||||
end of the last one? */
|
||||
* end of the last one? */
|
||||
#endif
|
||||
|
||||
static filestruct *cutbottom = NULL;
|
||||
/* Pointer to end of cutbuffer */
|
||||
/* Pointer to end of cutbuffer. */
|
||||
|
||||
filestruct *get_cutbottom(void)
|
||||
{
|
||||
@@ -46,29 +48,27 @@ filestruct *get_cutbottom(void)
|
||||
void add_to_cutbuffer(filestruct *inptr)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "add_to_cutbuffer() called with inptr->data = %s\n",
|
||||
inptr->data);
|
||||
fprintf(stderr, "add_to_cutbuffer(): inptr->data = %s\n", inptr->data);
|
||||
#endif
|
||||
|
||||
if (cutbuffer == NULL) {
|
||||
if (cutbuffer == NULL)
|
||||
cutbuffer = inptr;
|
||||
inptr->prev = NULL;
|
||||
#ifndef NANO_SMALL
|
||||
} else if (concatenate_cut && !ISSET(JUSTIFY_MODE)) {
|
||||
else if (concatenate_cut && !ISSET(JUSTIFY_MODE)) {
|
||||
/* Just tack the text in inptr onto the text in cutbottom,
|
||||
unless we're backing up lines while justifying text. */
|
||||
* unless we're backing up lines while justifying text. */
|
||||
cutbottom->data = charealloc(cutbottom->data,
|
||||
strlen(cutbottom->data) + strlen(inptr->data) + 1);
|
||||
strcat(cutbottom->data, inptr->data);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
else {
|
||||
cutbottom->next = inptr;
|
||||
inptr->prev = cutbottom;
|
||||
}
|
||||
|
||||
inptr->next = NULL;
|
||||
cutbottom = inptr;
|
||||
cutbottom->next = NULL;
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
@@ -78,112 +78,115 @@ void add_to_cutbuffer(filestruct *inptr)
|
||||
* last cut line has length bot_x. That is, if bot_x > 0 then we cut to
|
||||
* bot->data[bot_x - 1].
|
||||
*
|
||||
* destructive is whether to actually modify the file structure, if not
|
||||
* then just copy the buffer into cutbuffer and don't pull it from the
|
||||
* file.
|
||||
* We maintain totsize, totlines, filebot, the magicline, and line
|
||||
* numbers. Also, we set current and current_x so the cursor will be on
|
||||
* the first character after what was cut. We do not do any screen
|
||||
* updates.
|
||||
*
|
||||
* If destructive, then we maintain totsize, totlines, filebot, the
|
||||
* magic line, and line numbers. Also, we set current and current_x so
|
||||
* the cursor will be on the first character after what was cut. We do
|
||||
* not do any screen updates. */
|
||||
void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
|
||||
size_t bot_x, int destructive)
|
||||
* Note cutbuffer might not be NULL if cut to end is used. */
|
||||
void cut_marked_segment(void)
|
||||
{
|
||||
filestruct *tmp, *next;
|
||||
filestruct *top;
|
||||
filestruct *bot;
|
||||
filestruct *tmp;
|
||||
size_t top_x;
|
||||
size_t bot_x;
|
||||
size_t newsize;
|
||||
|
||||
if (top == bot && top_x == bot_x)
|
||||
/* If the mark doesn't cover any text, get out. */
|
||||
if (current == mark_beginbuf && current_x == mark_beginx)
|
||||
return;
|
||||
assert(top != NULL && bot != NULL);
|
||||
assert(current != NULL && mark_beginbuf != NULL);
|
||||
|
||||
/* Make top be no later than bot. */
|
||||
if (top->lineno > bot->lineno) {
|
||||
filestruct *swap = top;
|
||||
int swap2 = top_x;
|
||||
/* Set up the top and bottom lines and coordinates of the marked
|
||||
* text. */
|
||||
mark_order((const filestruct **)&top, &top_x,
|
||||
(const filestruct **)&bot, &bot_x);
|
||||
|
||||
top = bot;
|
||||
bot = swap;
|
||||
|
||||
top_x = bot_x;
|
||||
bot_x = swap2;
|
||||
} else if (top == bot && top_x > bot_x) {
|
||||
/* And bot_x can't be an earlier character than top_x. */
|
||||
int swap = top_x;
|
||||
|
||||
top_x = bot_x;
|
||||
bot_x = swap;
|
||||
}
|
||||
|
||||
/* Make the first cut line manually. */
|
||||
/* Make the first cut line manually. Move the cut part of the top
|
||||
* line into tmp, and set newsize to that partial line's length. */
|
||||
tmp = copy_node(top);
|
||||
newsize = (top == bot ? bot_x - top_x : strlen(top->data + top_x));
|
||||
charmove(tmp->data, top->data + top_x, newsize);
|
||||
charmove(tmp->data, tmp->data + top_x, newsize);
|
||||
null_at(&tmp->data, newsize);
|
||||
add_to_cutbuffer(tmp);
|
||||
|
||||
/* And make the remainder line manually too. */
|
||||
if (destructive) {
|
||||
current_x = top_x;
|
||||
totsize -= newsize;
|
||||
totlines -= bot->lineno - top->lineno;
|
||||
|
||||
newsize = top_x + strlen(bot->data + bot_x) + 1;
|
||||
if (top == bot) {
|
||||
/* In this case, the remainder line is shorter, so we must
|
||||
move text from the end forward first. */
|
||||
charmove(top->data + top_x, bot->data + bot_x,
|
||||
newsize - top_x);
|
||||
top->data = charealloc(top->data, newsize);
|
||||
} else {
|
||||
totsize -= bot_x + 1;
|
||||
|
||||
/* Here, the remainder line might get longer, so we
|
||||
realloc() it first. */
|
||||
top->data = charealloc(top->data, newsize);
|
||||
charmove(top->data + top_x, bot->data + bot_x,
|
||||
newsize - top_x);
|
||||
}
|
||||
/* Add the contents of tmp to the cutbuffer. Note that cutbuffer
|
||||
* might be non-NULL if we have cut to end enabled. */
|
||||
if (cutbuffer == NULL) {
|
||||
cutbuffer = tmp;
|
||||
cutbottom = tmp;
|
||||
} else {
|
||||
cutbottom->next = tmp;
|
||||
tmp->prev = cutbottom;
|
||||
cutbottom = tmp;
|
||||
}
|
||||
|
||||
/* And make the top remainder line manually too. Update current_x
|
||||
* and totlines to account for all the cut text, and update totsize
|
||||
* to account for the length of the cut part of the first line. */
|
||||
current_x = top_x;
|
||||
totsize -= newsize;
|
||||
totlines -= bot->lineno - top->lineno;
|
||||
|
||||
/* Now set newsize to be the length of the top remainder line plus
|
||||
* the bottom remainder line, plus one for the null terminator. */
|
||||
newsize = top_x + strlen(bot->data + bot_x) + 1;
|
||||
|
||||
if (top == bot) {
|
||||
/* In this case, we're only cutting one line or part of one
|
||||
* line, so the remainder line is shorter. This means that we
|
||||
* must move text from the end forward first. */
|
||||
charmove(top->data + top_x, bot->data + bot_x, newsize - top_x);
|
||||
top->data = charealloc(top->data, newsize);
|
||||
|
||||
cutbottom->next = NULL;
|
||||
#ifdef DEBUG
|
||||
dump_buffer(cutbuffer);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
tmp = top->next;
|
||||
while (tmp != bot) {
|
||||
next = tmp->next;
|
||||
if (!destructive)
|
||||
tmp = copy_node(tmp);
|
||||
else
|
||||
totsize -= strlen(tmp->data) + 1;
|
||||
add_to_cutbuffer(tmp);
|
||||
tmp = next;
|
||||
}
|
||||
/* Update totsize to account for the cut part of the last line. */
|
||||
totsize -= bot_x + 1;
|
||||
|
||||
/* Here, the top remainder line might get longer (if the bottom
|
||||
* remainder line is added to the end of it), so we realloc() it
|
||||
* first. */
|
||||
top->data = charealloc(top->data, newsize);
|
||||
charmove(top->data + top_x, bot->data + bot_x, newsize - top_x);
|
||||
|
||||
assert(cutbottom != NULL && cutbottom->next != NULL);
|
||||
/* We're cutting multiple lines, so in particular the next line is
|
||||
* cut too. */
|
||||
cutbottom->next->prev = cutbottom;
|
||||
|
||||
/* Update totsize to account for all the complete lines that have
|
||||
* been cut. After this, totsize is fully up to date. */
|
||||
for (tmp = top->next; tmp != bot; tmp = tmp->next)
|
||||
totsize -= strlen(tmp->data) + 1;
|
||||
|
||||
/* Make the last cut line manually. */
|
||||
tmp = copy_node(bot);
|
||||
null_at(&tmp->data, bot_x);
|
||||
add_to_cutbuffer(tmp);
|
||||
#ifdef DEBUG
|
||||
dump_buffer(cutbuffer);
|
||||
#endif
|
||||
null_at(&bot->data, bot_x);
|
||||
|
||||
if (destructive) {
|
||||
top->next = bot->next;
|
||||
if (top->next != NULL)
|
||||
top->next->prev = top;
|
||||
delete_node(bot);
|
||||
renumber(top);
|
||||
current = top;
|
||||
if (bot == filebot) {
|
||||
filebot = top;
|
||||
assert(bot_x == 0);
|
||||
if (top_x > 0)
|
||||
new_magicline();
|
||||
}
|
||||
/* Move the rest of the cut text (other than the cut part of the top
|
||||
* line) from the buffer to the end of the cutbuffer, and fix the
|
||||
* edit buffer to account for the cut text. */
|
||||
top->next = bot->next;
|
||||
cutbottom = bot;
|
||||
cutbottom->next = NULL;
|
||||
if (top->next != NULL)
|
||||
top->next->prev = top;
|
||||
renumber(top);
|
||||
current = top;
|
||||
|
||||
/* If the bottom line of the cut was the magicline, set filebot
|
||||
* properly, and add a new magicline if the top remainder line
|
||||
* (which is now the new bottom line) is non-blank. */
|
||||
if (bot == filebot) {
|
||||
filebot = top;
|
||||
assert(bot_x == 0);
|
||||
if (top_x > 0)
|
||||
new_magicline();
|
||||
}
|
||||
#ifdef DEBUG
|
||||
dump_buffer(cutbuffer);
|
||||
@@ -194,9 +197,6 @@ void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
|
||||
int do_cut_text(void)
|
||||
{
|
||||
filestruct *fileptr;
|
||||
#ifndef NANO_SMALL
|
||||
int dontupdate = 0;
|
||||
#endif
|
||||
|
||||
assert(current != NULL && current->data != NULL);
|
||||
|
||||
@@ -214,8 +214,8 @@ int do_cut_text(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* You can't cut the magic line except with the mark. But
|
||||
trying does clear the cutbuffer if KEEP_CUTBUFFER is not set. */
|
||||
/* You can't cut the magicline except with the mark. But trying
|
||||
* does clear the cutbuffer if KEEP_CUTBUFFER is not set. */
|
||||
if (current == filebot
|
||||
#ifndef NANO_SMALL
|
||||
&& !ISSET(MARK_ISSET)
|
||||
@@ -231,11 +231,12 @@ int do_cut_text(void)
|
||||
|
||||
if (current->data[current_x] == '\0') {
|
||||
/* If the line is empty and we didn't just cut a non-blank
|
||||
line, create a dummy line and add it to the cutbuffer */
|
||||
* line, create a dummy blank line and add it to the
|
||||
* cutbuffer. */
|
||||
if (marked_cut != 1 && current->next != filebot) {
|
||||
filestruct *junk = make_new_node(current);
|
||||
|
||||
junk->data = charalloc(1);
|
||||
junk->data = charalloc(1);
|
||||
junk->data[0] = '\0';
|
||||
add_to_cutbuffer(junk);
|
||||
#ifdef DEBUG
|
||||
@@ -251,33 +252,22 @@ int do_cut_text(void)
|
||||
|
||||
mark_beginx = strlen(current->data);
|
||||
mark_beginbuf = current;
|
||||
dontupdate = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ISSET(MARK_ISSET)) {
|
||||
/* Don't do_update() and move the screen position if the marked
|
||||
area lies entirely within the screen buffer */
|
||||
dontupdate |= current->lineno >= edittop->lineno &&
|
||||
current->lineno <= editbot->lineno &&
|
||||
mark_beginbuf->lineno >= edittop->lineno &&
|
||||
mark_beginbuf->lineno <= editbot->lineno;
|
||||
cut_marked_segment(current, current_x, mark_beginbuf,
|
||||
mark_beginx, 1);
|
||||
cut_marked_segment();
|
||||
|
||||
placewewant = xplustabs();
|
||||
UNSET(MARK_ISSET);
|
||||
|
||||
/* If we just did a marked cut of part of a line, we should add
|
||||
the first line of any cut done immediately afterward to the
|
||||
end of this cut, as Pico does. */
|
||||
* the first line of any cut done immediately afterward to the
|
||||
* end of this cut, as Pico does. */
|
||||
if (current == mark_beginbuf && current_x < strlen(current->data))
|
||||
concatenate_cut = 1;
|
||||
marked_cut = 1;
|
||||
if (dontupdate)
|
||||
edit_refresh();
|
||||
else
|
||||
edit_update(current, CENTER);
|
||||
edit_refresh();
|
||||
set_modified();
|
||||
|
||||
return 1;
|
||||
@@ -310,29 +300,26 @@ int do_cut_text(void)
|
||||
#ifndef NANO_SMALL
|
||||
concatenate_cut = 0;
|
||||
#endif
|
||||
placewewant = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_uncut_text(void)
|
||||
{
|
||||
filestruct *tmp = current, *fileptr = current;
|
||||
filestruct *newbuf = NULL, *newend = NULL;
|
||||
char *tmpstr, *tmpstr2;
|
||||
filestruct *hold = current;
|
||||
int i;
|
||||
filestruct *tmp = current;
|
||||
filestruct *newbuf = NULL;
|
||||
filestruct *newend = NULL;
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
#endif
|
||||
check_statblank();
|
||||
if (cutbuffer == NULL || fileptr == NULL)
|
||||
if (cutbuffer == NULL || current == NULL)
|
||||
return 0; /* AIEEEEEEEEEEEE */
|
||||
|
||||
/* If we're uncutting a previously non-marked block, uncut to end if
|
||||
we're not at the beginning of the line. If we are at the
|
||||
beginning of the line, set placewewant to 0. Pico does both of
|
||||
these. */
|
||||
* we're not at the beginning of the line. If we are at the
|
||||
* beginning of the line, set placewewant to 0. Pico does both of
|
||||
* these. */
|
||||
if (marked_cut == 0) {
|
||||
if (current_x != 0)
|
||||
marked_cut = 2;
|
||||
@@ -341,24 +328,22 @@ int do_uncut_text(void)
|
||||
}
|
||||
|
||||
/* If we're going to uncut on the magicline, always make a new
|
||||
magicline in advance. */
|
||||
* magicline in advance, as Pico does. */
|
||||
if (current->next == NULL)
|
||||
new_magicline();
|
||||
|
||||
if (marked_cut == 0 || cutbuffer->next != NULL)
|
||||
{
|
||||
if (marked_cut == 0 || cutbuffer->next != NULL) {
|
||||
newbuf = copy_filestruct(cutbuffer);
|
||||
for (newend = newbuf; newend->next != NULL && newend != NULL;
|
||||
newend = newend->next)
|
||||
totlines++;
|
||||
}
|
||||
|
||||
/* Hook newbuf into fileptr */
|
||||
/* Hook newbuf in at current. */
|
||||
if (marked_cut != 0) {
|
||||
int recenter_me = 0;
|
||||
/* Should we eventually use edit_update(CENTER)? */
|
||||
filestruct *hold = current;
|
||||
|
||||
/* If there's only one line in the cutbuffer */
|
||||
/* If there's only one line in the cutbuffer... */
|
||||
if (cutbuffer->next == NULL) {
|
||||
size_t buf_len = strlen(cutbuffer->data);
|
||||
size_t cur_len = strlen(current->data);
|
||||
@@ -367,22 +352,24 @@ int do_uncut_text(void)
|
||||
charmove(current->data + current_x + buf_len,
|
||||
current->data + current_x, cur_len - current_x + 1);
|
||||
strncpy(current->data + current_x, cutbuffer->data, buf_len);
|
||||
/* Use strncpy() to not copy the terminal '\0'. */
|
||||
/* Use strncpy() to not copy the null terminator. */
|
||||
|
||||
current_x += buf_len;
|
||||
totsize += buf_len;
|
||||
|
||||
placewewant = xplustabs();
|
||||
update_cursor();
|
||||
} else { /* yuck -- no kidding! */
|
||||
} else { /* Yuck -- no kidding! */
|
||||
char *tmpstr, *tmpstr2;
|
||||
|
||||
tmp = current->next;
|
||||
/* New beginning */
|
||||
|
||||
/* New beginning. */
|
||||
tmpstr = charalloc(current_x + strlen(newbuf->data) + 1);
|
||||
strncpy(tmpstr, current->data, current_x);
|
||||
strcpy(&tmpstr[current_x], newbuf->data);
|
||||
totsize += strlen(newbuf->data) + strlen(newend->data) + 1;
|
||||
|
||||
/* New end */
|
||||
/* New end. */
|
||||
tmpstr2 = charalloc(strlen(newend->data) +
|
||||
strlen(¤t->data[current_x]) + 1);
|
||||
strcpy(tmpstr2, newend->data);
|
||||
@@ -401,35 +388,28 @@ int do_uncut_text(void)
|
||||
|
||||
newend->next = tmp;
|
||||
|
||||
/* If tmp isn't null, we're in the middle: update the
|
||||
prev pointer. If it IS null, we're at the end; update
|
||||
the filebot pointer */
|
||||
|
||||
/* If tmp isn't NULL, we're in the middle: update the
|
||||
* prev pointer. If it IS NULL, we're at the end; update
|
||||
* the filebot pointer. */
|
||||
if (tmp != NULL)
|
||||
tmp->prev = newend;
|
||||
else {
|
||||
/* Fix the editbot pointer too */
|
||||
if (editbot == filebot)
|
||||
editbot = newend;
|
||||
filebot = newend;
|
||||
new_magicline();
|
||||
}
|
||||
|
||||
/* Now why don't we update the totsize also */
|
||||
/* Now why don't we update the totsize also? */
|
||||
for (tmp = current->next; tmp != newend; tmp = tmp->next)
|
||||
totsize += strlen(tmp->data) + 1;
|
||||
|
||||
current = newend;
|
||||
if (editbot->lineno < newend->lineno)
|
||||
recenter_me = 1;
|
||||
}
|
||||
|
||||
/* If marked cut == 2, that means that we're doing a cut to end
|
||||
and we don't want anything else on the line, so we have to
|
||||
screw up all the work we just did and separate the line.
|
||||
There must be a better way to do this, but not at 1AM on a
|
||||
work night. */
|
||||
|
||||
* and we don't want anything else on the line, so we have to
|
||||
* screw up all the work we just did and separate the line.
|
||||
* There must be a better way to do this, but not at 1 AM on a
|
||||
* work night. */
|
||||
if (marked_cut == 2) {
|
||||
tmp = make_new_node(current);
|
||||
tmp->data = mallocstrcpy(NULL, current->data + current_x);
|
||||
@@ -439,7 +419,7 @@ int do_uncut_text(void)
|
||||
current_x = 0;
|
||||
placewewant = 0;
|
||||
|
||||
/* Extra line added, update stuff */
|
||||
/* Extra line added; update stuff. */
|
||||
totlines++;
|
||||
totsize++;
|
||||
}
|
||||
@@ -451,41 +431,32 @@ int do_uncut_text(void)
|
||||
dump_buffer(cutbuffer);
|
||||
#endif
|
||||
set_modified();
|
||||
if (recenter_me)
|
||||
edit_update(current, CENTER);
|
||||
else
|
||||
edit_refresh();
|
||||
edit_refresh();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fileptr != fileage) {
|
||||
tmp = fileptr->prev;
|
||||
if (current != fileage) {
|
||||
tmp = current->prev;
|
||||
tmp->next = newbuf;
|
||||
newbuf->prev = tmp;
|
||||
} else
|
||||
fileage = newbuf;
|
||||
totlines++; /* Unmarked uncuts don't split lines */
|
||||
totlines++; /* Unmarked uncuts don't split lines. */
|
||||
|
||||
/* This is so uncutting at the top of the buffer will work => */
|
||||
if (current_y == 0)
|
||||
edittop = newbuf;
|
||||
|
||||
/* Connect the end of the buffer to the filestruct */
|
||||
newend->next = fileptr;
|
||||
fileptr->prev = newend;
|
||||
/* Connect the end of the buffer to the filestruct. */
|
||||
newend->next = current;
|
||||
current->prev = newend;
|
||||
|
||||
/* Recalculate size *sigh* */
|
||||
for (tmp = newbuf; tmp != fileptr; tmp = tmp->next)
|
||||
for (tmp = newbuf; tmp != current; tmp = tmp->next)
|
||||
totsize += strlen(tmp->data) + 1;
|
||||
|
||||
i = editbot->lineno;
|
||||
renumber(newbuf);
|
||||
/* Center the screen if we've moved beyond the line numbers of both
|
||||
the old and new editbots */
|
||||
if (i < newend->lineno && editbot->lineno < newend->lineno)
|
||||
edit_update(fileptr, CENTER);
|
||||
else
|
||||
edit_refresh();
|
||||
edit_refresh();
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_buffer_reverse();
|
||||
|
||||
640
src/files.c
640
src/files.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* files.c *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -48,7 +48,7 @@
|
||||
static int fileformat = 0; /* 0 = *nix, 1 = DOS, 2 = Mac */
|
||||
#endif
|
||||
|
||||
/* Load file into edit buffer - takes data from file struct. */
|
||||
/* Load file into edit buffer -- takes data from file struct. */
|
||||
void load_file(int update)
|
||||
{
|
||||
current = fileage;
|
||||
@@ -489,7 +489,7 @@ int do_insertfile(int loading_file)
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (i == TOGGLE_LOAD_KEY) {
|
||||
if (i == TOGGLE_MULTIBUFFER_KEY) {
|
||||
/* Don't allow toggling if we're in view mode. */
|
||||
if (!ISSET(VIEW_MODE))
|
||||
TOGGLE(MULTIBUFFER);
|
||||
@@ -522,7 +522,7 @@ int do_insertfile(int loading_file)
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if (i != NANO_EXTCMD_KEY && check_operating_dir(answer, FALSE)) {
|
||||
if (i != NANO_EXTCMD_KEY && check_operating_dir(answer, 0) != 0) {
|
||||
statusbar(_("Can't insert file from outside of %s"),
|
||||
operating_dir);
|
||||
return 0;
|
||||
@@ -878,7 +878,7 @@ int open_prevfile(int closing_file)
|
||||
|
||||
/* only one file open */
|
||||
if (!closing_file)
|
||||
statusbar(_("No more open files"));
|
||||
statusbar(_("No more open file buffers"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -941,7 +941,7 @@ int open_nextfile(int closing_file)
|
||||
|
||||
/* only one file open */
|
||||
if (!closing_file)
|
||||
statusbar(_("No more open files"));
|
||||
statusbar(_("No more open file buffers"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1272,410 +1272,376 @@ void init_operating_dir(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if we're inside the operating directory. Return 0 if we
|
||||
/* Check to see if we're inside the operating directory. Return 0 if we
|
||||
* are, or 1 otherwise. If allow_tabcomp is nonzero, allow incomplete
|
||||
* names that would be matches for the operating directory, so that tab
|
||||
* completion will work.
|
||||
*/
|
||||
* completion will work. */
|
||||
int check_operating_dir(const char *currpath, int allow_tabcomp)
|
||||
{
|
||||
/* The char *full_operating_dir is global for mem cleanup, and
|
||||
therefore we only need to get it the first time this function
|
||||
is called; also, a relative operating directory path will
|
||||
only be handled properly if this is done */
|
||||
/* The char *full_operating_dir is global for mem cleanup. It
|
||||
* should have already been initialized by init_operating_dir().
|
||||
* Also, a relative operating directory path will only be handled
|
||||
* properly if this is done. */
|
||||
|
||||
char *fullpath;
|
||||
int retval = 0;
|
||||
const char *whereami1, *whereami2 = NULL;
|
||||
|
||||
/* if no operating directory is set, don't bother doing anything */
|
||||
/* If no operating directory is set, don't bother doing anything. */
|
||||
if (operating_dir == NULL)
|
||||
return 0;
|
||||
assert(full_operating_dir != NULL);
|
||||
|
||||
fullpath = get_full_path(currpath);
|
||||
|
||||
/* fullpath == NULL means some directory in the path doesn't exist
|
||||
* or is unreadable. If allow_tabcomp is zero, then currpath is
|
||||
* what the user typed somewhere. We don't want to report a
|
||||
* non-existent directory as being outside the operating directory,
|
||||
* so we return 0. If allow_tabcomp is nonzero, then currpath
|
||||
* exists, but is not executable. So we say it isn't in the
|
||||
* operating directory. */
|
||||
if (fullpath == NULL)
|
||||
return 1;
|
||||
return allow_tabcomp;
|
||||
|
||||
whereami1 = strstr(fullpath, full_operating_dir);
|
||||
if (allow_tabcomp)
|
||||
whereami2 = strstr(full_operating_dir, fullpath);
|
||||
|
||||
/* if both searches failed, we're outside the operating directory */
|
||||
/* otherwise */
|
||||
/* check the search results; if the full operating directory path is
|
||||
not at the beginning of the full current path (for normal usage)
|
||||
and vice versa (for tab completion, if we're allowing it), we're
|
||||
outside the operating directory */
|
||||
/* If both searches failed, we're outside the operating directory.
|
||||
* Otherwise, check the search results; if the full operating
|
||||
* directory path is not at the beginning of the full current path
|
||||
* (for normal usage) and vice versa (for tab completion, if we're
|
||||
* allowing it), we're outside the operating directory. */
|
||||
if (whereami1 != fullpath && whereami2 != full_operating_dir)
|
||||
retval = 1;
|
||||
free(fullpath);
|
||||
/* otherwise, we're still inside it */
|
||||
|
||||
/* Otherwise, we're still inside it. */
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Write a file out. If tmp is nonzero, we set the umask to 0600,
|
||||
* we don't set the global variable filename to its name, and don't
|
||||
* print out how many lines we wrote on the statusbar.
|
||||
/* Read from inn, write to out. We assume inn is opened for reading,
|
||||
* and out for writing. We return 0 on success, -1 on read error, -2 on
|
||||
* write error. */
|
||||
int copy_file(FILE *inn, FILE *out)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
size_t charsread;
|
||||
int retval = 0;
|
||||
|
||||
assert(inn != NULL && out != NULL);
|
||||
do {
|
||||
charsread = fread(buf, sizeof(char), BUFSIZ, inn);
|
||||
if (charsread == 0 && ferror(inn)) {
|
||||
retval = -1;
|
||||
break;
|
||||
}
|
||||
if (fwrite(buf, sizeof(char), charsread, out) < charsread) {
|
||||
retval = -2;
|
||||
break;
|
||||
}
|
||||
} while (charsread > 0);
|
||||
if (fclose(inn) == EOF)
|
||||
retval = -1;
|
||||
if (fclose(out) == EOF)
|
||||
retval = -2;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Write a file out. If tmp is nonzero, we set the umask to disallow
|
||||
* anyone else from accessing the file, we don't set the global variable
|
||||
* filename to its name, and we don't print out how many lines we wrote
|
||||
* on the statusbar.
|
||||
*
|
||||
* tmp means we are writing a tmp file in a secure fashion. We use
|
||||
* it when spell checking or dumping the file on an error.
|
||||
* tmp means we are writing a temporary file in a secure fashion. We
|
||||
* use it when spell checking or dumping the file on an error.
|
||||
*
|
||||
* append == 1 means we are appending instead of overwriting.
|
||||
* append == 2 means we are prepending instead of overwriting.
|
||||
*
|
||||
* nonamechange means don't change the current filename, it is ignored
|
||||
* if tmp is nonzero or if we're appending/prepending.
|
||||
*/
|
||||
*
|
||||
* Return -1 on error, 1 on success. */
|
||||
int write_file(const char *name, int tmp, int append, int nonamechange)
|
||||
{
|
||||
int retval = -1;
|
||||
/* Instead of returning in this function, you should always
|
||||
* merely set retval then goto cleanup_and_exit. */
|
||||
long size;
|
||||
int lineswritten = 0;
|
||||
char *buf = NULL;
|
||||
const filestruct *fileptr;
|
||||
FILE *f;
|
||||
* merely set retval and then goto cleanup_and_exit. */
|
||||
size_t lineswritten = 0;
|
||||
const filestruct *fileptr = fileage;
|
||||
int fd;
|
||||
int mask = 0, realexists, anyexists;
|
||||
struct stat st, lst;
|
||||
char *realname = NULL;
|
||||
mode_t original_umask = 0;
|
||||
/* Our umask, from when nano started. */
|
||||
int realexists;
|
||||
/* The result of stat(). True if the file exists, false
|
||||
* otherwise. If name is a link that points nowhere, realexists
|
||||
* is false. */
|
||||
struct stat st;
|
||||
/* The status fields filled in by stat(). */
|
||||
int anyexists;
|
||||
/* Result of lstat(). Same as realexists unless name is a
|
||||
* link. */
|
||||
struct stat lst;
|
||||
/* The status fields filled in by lstat(). */
|
||||
char *realname;
|
||||
/* name after ~ expansion. */
|
||||
FILE *f;
|
||||
/* The actual file, realname, we are writing to. */
|
||||
char *tempname = NULL;
|
||||
/* The temp file name we write to on prepend. */
|
||||
|
||||
assert(name != NULL);
|
||||
if (name[0] == '\0') {
|
||||
statusbar(_("Cancelled"));
|
||||
return -1;
|
||||
}
|
||||
if (!tmp)
|
||||
titlebar(NULL);
|
||||
fileptr = fileage;
|
||||
|
||||
realname = real_dir_from_tilde(name);
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
/* If we're writing a temporary file, we're probably going outside
|
||||
the operating directory, so skip the operating directory test. */
|
||||
if (!tmp && operating_dir != NULL && check_operating_dir(realname, 0)) {
|
||||
* the operating directory, so skip the operating directory test. */
|
||||
if (!tmp && check_operating_dir(realname, 0) != 0) {
|
||||
statusbar(_("Can't write outside of %s"), operating_dir);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
#endif
|
||||
|
||||
anyexists = lstat(realname, &lst) != -1;
|
||||
/* New case: if the file exists, just give up. */
|
||||
if (tmp && anyexists)
|
||||
goto cleanup_and_exit;
|
||||
/* If NOFOLLOW_SYMLINKS is set, it doesn't make sense to prepend or
|
||||
* append to a symlink. Here we warn about the contradiction. */
|
||||
if (ISSET(NOFOLLOW_SYMLINKS) && anyexists && S_ISLNK(lst.st_mode)) {
|
||||
statusbar(_("Cannot prepend or append to a symlink with --nofollow set."));
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
/* Save the state of file at the end of the symlink (if there is
|
||||
one). */
|
||||
realexists = stat(realname, &st);
|
||||
* one). */
|
||||
realexists = stat(realname, &st) != -1;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* 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 == 0 &&
|
||||
(append != 0 || ISSET(MARK_ISSET) ||
|
||||
originalfilestat.st_mtime == st.st_mtime)) {
|
||||
FILE *backup_file;
|
||||
char *backupname = NULL;
|
||||
char backupbuf[COPYFILEBLOCKSIZE];
|
||||
size_t bytesread;
|
||||
struct utimbuf filetime;
|
||||
* 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 != 0 &&
|
||||
(append != 0 || ISSET(MARK_ISSET) ||
|
||||
originalfilestat.st_mtime == st.st_mtime)) {
|
||||
|
||||
/* save the original file's access and modification times */
|
||||
FILE *backup_file;
|
||||
char *backupname;
|
||||
struct utimbuf filetime;
|
||||
int copy_status;
|
||||
|
||||
/* Save the original file's access and modification times. */
|
||||
filetime.actime = originalfilestat.st_atime;
|
||||
filetime.modtime = originalfilestat.st_mtime;
|
||||
|
||||
/* open the original file to copy to the backup */
|
||||
/* Open the original file to copy to the backup. */
|
||||
f = fopen(realname, "rb");
|
||||
if (f == NULL) {
|
||||
statusbar(_("Could not read %s for backup: %s"), realname,
|
||||
statusbar(_("Error reading %s: %s"), realname,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
backupname = charalloc(strlen(realname) + 2);
|
||||
sprintf(backupname, "%s~", realname);
|
||||
|
||||
/* get a file descriptor for the destination backup file */
|
||||
/* 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");
|
||||
if (backup_file == NULL) {
|
||||
statusbar(_("Couldn't write backup: %s"), strerror(errno));
|
||||
if (backup_file == NULL ||
|
||||
chmod(backupname, originalfilestat.st_mode) == -1) {
|
||||
statusbar(_("Error writing %s: %s"), backupname, strerror(errno));
|
||||
free(backupname);
|
||||
return -1;
|
||||
if (backup_file != NULL)
|
||||
fclose(backup_file);
|
||||
fclose(f);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Backing up %s to %s\n", realname, backupname);
|
||||
#endif
|
||||
|
||||
/* copy the file */
|
||||
while ((bytesread = fread(backupbuf, sizeof(char),
|
||||
COPYFILEBLOCKSIZE, f)) > 0)
|
||||
if (fwrite(backupbuf, sizeof(char), bytesread, backup_file) <= 0)
|
||||
break;
|
||||
fclose(backup_file);
|
||||
fclose(f);
|
||||
|
||||
if (chmod(backupname, originalfilestat.st_mode) == -1)
|
||||
statusbar(_("Could not set permissions %o on backup %s: %s"),
|
||||
originalfilestat.st_mode, backupname,
|
||||
/* Copy the file. */
|
||||
copy_status = copy_file(f, backup_file);
|
||||
/* And set metadata. */
|
||||
if (copy_status != 0 || chown(backupname, originalfilestat.st_uid,
|
||||
originalfilestat.st_gid) == -1 ||
|
||||
utime(backupname, &filetime) == -1) {
|
||||
free(backupname);
|
||||
if (copy_status == -1)
|
||||
statusbar(_("Error reading %s: %s"), realname,
|
||||
strerror(errno));
|
||||
|
||||
if (chown(backupname, originalfilestat.st_uid,
|
||||
originalfilestat.st_gid) == -1)
|
||||
statusbar(_("Could not set owner %d/group %d on backup %s: %s"),
|
||||
originalfilestat.st_uid, originalfilestat.st_gid,
|
||||
backupname, strerror(errno));
|
||||
|
||||
if (utime(backupname, &filetime) == -1)
|
||||
statusbar(_("Could not set access/modification time on backup %s: %s"),
|
||||
backupname, strerror(errno));
|
||||
|
||||
else
|
||||
statusbar(_("Error writing %s: %s"), backupname,
|
||||
strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
free(backupname);
|
||||
}
|
||||
#endif
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
/* Stat the link itself for the check... */
|
||||
anyexists = lstat(realname, &lst);
|
||||
|
||||
/* New case: if the file exists, just give up */
|
||||
if (tmp && anyexists != -1)
|
||||
/* If NOFOLLOW_SYMLINKS and the file is a link, we aren't doing
|
||||
* prepend or append. So we delete the link first, and just
|
||||
* overwrite. */
|
||||
if (ISSET(NOFOLLOW_SYMLINKS) && anyexists && S_ISLNK(lst.st_mode) &&
|
||||
unlink(realname) == -1) {
|
||||
statusbar(_("Error writing %s: %s"), realname, strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
/* NOTE: If you change this statement, you MUST CHANGE the if
|
||||
statement below (that says:
|
||||
if (realexists == -1 || tmp || (ISSET(NOFOLLOW_SYMLINKS) &&
|
||||
S_ISLNK(lst.st_mode))) {
|
||||
to reflect whether or not to link/unlink/rename the file */
|
||||
else if (append != 2 && (!ISSET(NOFOLLOW_SYMLINKS) || !S_ISLNK(lst.st_mode)
|
||||
|| tmp)) {
|
||||
/* Use O_EXCL if tmp is nonzero. This is now copied from joe,
|
||||
because wiggy says so *shrug*. */
|
||||
if (append != 0)
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_APPEND, (S_IRUSR | S_IWUSR));
|
||||
else if (tmp)
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_EXCL, (S_IRUSR | S_IWUSR));
|
||||
else
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC, (S_IRUSR | S_IWUSR));
|
||||
}
|
||||
|
||||
/* First, just give up if we couldn't even open the file */
|
||||
if (fd == -1) {
|
||||
if (!tmp && ISSET(TEMP_OPT)) {
|
||||
UNSET(TEMP_OPT);
|
||||
retval = do_writeout(filename, 1, 0);
|
||||
} else
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
original_umask = umask(0);
|
||||
umask(original_umask);
|
||||
/* If we create a temp file, we don't let anyone else access it. We
|
||||
* create a temp file if tmp is nonzero or if we prepend. */
|
||||
if (tmp || append == 2)
|
||||
umask(S_IRWXG | S_IRWXO);
|
||||
|
||||
/* If we are prepending, copy the file to a temp file. */
|
||||
if (append == 2) {
|
||||
int fd_source;
|
||||
FILE *f_source = NULL;
|
||||
|
||||
tempname = charalloc(strlen(realname) + 8);
|
||||
strcpy(tempname, realname);
|
||||
strcat(tempname, ".XXXXXX");
|
||||
fd = mkstemp(tempname);
|
||||
f = NULL;
|
||||
if (fd != -1) {
|
||||
f = fdopen(fd, "wb");
|
||||
if (f == NULL)
|
||||
close(fd);
|
||||
}
|
||||
if (f == NULL) {
|
||||
statusbar(_("Error writing %s: %s"), tempname, strerror(errno));
|
||||
unlink(tempname);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
}
|
||||
/* Don't follow symlink. Create new file. */
|
||||
else {
|
||||
buf = charalloc(strlen(realname) + 8);
|
||||
strcpy(buf, realname);
|
||||
strcat(buf, ".XXXXXX");
|
||||
if ((fd = mkstemp(buf)) == -1) {
|
||||
if (ISSET(TEMP_OPT)) {
|
||||
UNSET(TEMP_OPT);
|
||||
retval = do_writeout(filename, 1, 0);
|
||||
} else
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
fd_source = open(realname, O_RDONLY | O_CREAT);
|
||||
if (fd_source != -1) {
|
||||
f_source = fdopen(fd_source, "rb");
|
||||
if (f_source == NULL)
|
||||
close(fd_source);
|
||||
}
|
||||
if (f_source == NULL) {
|
||||
statusbar(_("Error reading %s: %s"), realname, strerror(errno));
|
||||
fclose(f);
|
||||
unlink(tempname);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
if (copy_file(f_source, f) != 0) {
|
||||
statusbar(_("Error writing %s: %s"), tempname, strerror(errno));
|
||||
unlink(tempname);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_buffer(fileage);
|
||||
#endif
|
||||
/* Now open the file in place. Use O_EXCL if tmp is nonzero. This
|
||||
* is now copied from joe, because wiggy says so *shrug*. */
|
||||
fd = open(realname, O_WRONLY | O_CREAT |
|
||||
(append == 1 ? O_APPEND : (tmp ? O_EXCL : O_TRUNC)),
|
||||
S_IRUSR | S_IWUSR);
|
||||
|
||||
/* Put the umask back to the user's original value. */
|
||||
umask(original_umask);
|
||||
|
||||
/* First, just give up if we couldn't even open the file. */
|
||||
if (fd == -1) {
|
||||
statusbar(_("Error writing %s: %s"), realname, strerror(errno));
|
||||
unlink(tempname);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
f = fdopen(fd, append == 1 ? "ab" : "wb");
|
||||
if (f == NULL) {
|
||||
statusbar(_("Could not open file for writing: %s"), strerror(errno));
|
||||
statusbar(_("Error writing %s: %s"), realname, strerror(errno));
|
||||
close(fd);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
while (fileptr != NULL && fileptr->next != NULL) {
|
||||
int data_len;
|
||||
/* There might not be a magic line. There won't be when writing out
|
||||
* a selection. */
|
||||
assert(fileage != NULL && filebot != NULL);
|
||||
while (fileptr != filebot) {
|
||||
size_t data_len = strlen(fileptr->data);
|
||||
size_t size;
|
||||
|
||||
/* Next line is so we discount the "magic line" */
|
||||
if (filebot == fileptr && fileptr->data[0] == '\0')
|
||||
break;
|
||||
|
||||
data_len = strlen(fileptr->data);
|
||||
|
||||
/* newlines to nulls, just before we write to disk */
|
||||
/* Newlines to nulls, just before we write to disk. */
|
||||
sunder(fileptr->data);
|
||||
|
||||
size = fwrite(fileptr->data, 1, data_len, f);
|
||||
size = fwrite(fileptr->data, sizeof(char), data_len, f);
|
||||
|
||||
/* nulls to newlines; data_len is the string's real length here */
|
||||
/* Nulls to newlines; data_len is the string's real length. */
|
||||
unsunder(fileptr->data, data_len);
|
||||
|
||||
if (size < data_len) {
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
statusbar(_("Error writing %s: %s"), realname, strerror(errno));
|
||||
fclose(f);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else
|
||||
fprintf(stderr, "Wrote >%s\n", fileptr->data);
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(DOS_FILE) || ISSET(MAC_FILE))
|
||||
putc('\r', f);
|
||||
if (putc('\r', f) == EOF) {
|
||||
statusbar(_("Error writing %s: %s"), realname, strerror(errno));
|
||||
fclose(f);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
if (!ISSET(MAC_FILE))
|
||||
#endif
|
||||
putc('\n', f);
|
||||
if (putc('\n', f) == EOF) {
|
||||
statusbar(_("Error writing %s: %s"), realname, strerror(errno));
|
||||
fclose(f);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
fileptr = fileptr->next;
|
||||
lineswritten++;
|
||||
}
|
||||
|
||||
if (fileptr != NULL) {
|
||||
int data_len = strlen(fileptr->data);
|
||||
/* If we're prepending, open the temp file, and append it to f. */
|
||||
if (append == 2) {
|
||||
int fd_source;
|
||||
FILE *f_source = NULL;
|
||||
|
||||
/* newlines to nulls, just before we write to disk */
|
||||
sunder(fileptr->data);
|
||||
|
||||
size = fwrite(fileptr->data, 1, data_len, f);
|
||||
|
||||
/* nulls to newlines; data_len is the string's real length here */
|
||||
unsunder(fileptr->data, data_len);
|
||||
|
||||
if (size < data_len) {
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
} else if (data_len > 0) {
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(DOS_FILE) || ISSET(MAC_FILE)) {
|
||||
if (putc('\r', f) == EOF) {
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
fclose(f);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
lineswritten++;
|
||||
}
|
||||
|
||||
if (!ISSET(MAC_FILE))
|
||||
#endif
|
||||
{
|
||||
if (putc('\n', f) == EOF) {
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
fclose(f);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
lineswritten++;
|
||||
}
|
||||
fd_source = open(tempname, O_RDONLY | O_CREAT);
|
||||
if (fd_source != -1) {
|
||||
f_source = fdopen(fd_source, "rb");
|
||||
if (f_source == NULL)
|
||||
close(fd_source);
|
||||
}
|
||||
if (f_source == NULL) {
|
||||
statusbar(_("Error reading %s: %s"), tempname, strerror(errno));
|
||||
fclose(f);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (fclose(f) != 0) {
|
||||
statusbar(_("Could not close %s: %s"), realname, strerror(errno));
|
||||
unlink(buf);
|
||||
if (copy_file(f_source, f) == -1
|
||||
|| unlink(tempname) == -1) {
|
||||
statusbar(_("Error writing %s: %s"), realname, strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
} else if (fclose(f) == EOF) {
|
||||
statusbar(_("Error writing %s: %s"), realname, strerror(errno));
|
||||
unlink(tempname);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
/* if we're prepending, open the real file, and append it here */
|
||||
if (append == 2) {
|
||||
int fd_source, fd_dest;
|
||||
FILE *f_source, *f_dest;
|
||||
int prechar;
|
||||
|
||||
if ((fd_dest = open(buf, O_WRONLY | O_APPEND, (S_IRUSR | S_IWUSR))) == -1) {
|
||||
statusbar(_("Could not reopen %s: %s"), buf, strerror(errno));
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
f_dest = fdopen(fd_dest, "wb");
|
||||
if (f_dest == NULL) {
|
||||
statusbar(_("Could not reopen %s: %s"), buf, strerror(errno));
|
||||
close(fd_dest);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
if ((fd_source = open(realname, O_RDONLY | O_CREAT)) == -1) {
|
||||
statusbar(_("Could not open %s for prepend: %s"), realname, strerror(errno));
|
||||
fclose(f_dest);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
f_source = fdopen(fd_source, "rb");
|
||||
if (f_source == NULL) {
|
||||
statusbar(_("Could not open %s for prepend: %s"), realname, strerror(errno));
|
||||
fclose(f_dest);
|
||||
close(fd_source);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
/* Doing this in blocks is an exercise left to some other reader. */
|
||||
while ((prechar = getc(f_source)) != EOF) {
|
||||
if (putc(prechar, f_dest) == EOF) {
|
||||
statusbar(_("Could not open %s for prepend: %s"), realname, strerror(errno));
|
||||
fclose(f_source);
|
||||
fclose(f_dest);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(f_source)) {
|
||||
statusbar(_("Could not reopen %s: %s"), buf, strerror(errno));
|
||||
fclose(f_source);
|
||||
fclose(f_dest);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
fclose(f_source);
|
||||
fclose(f_dest);
|
||||
}
|
||||
|
||||
if (realexists == -1 || tmp ||
|
||||
(ISSET(NOFOLLOW_SYMLINKS) && S_ISLNK(lst.st_mode))) {
|
||||
|
||||
/* Use default umask as file permissions if file is a new file. */
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
|
||||
if (tmp) /* We don't want anyone reading our temporary file! */
|
||||
mask = S_IRUSR | S_IWUSR;
|
||||
else
|
||||
mask = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
|
||||
S_IWOTH) & ~mask;
|
||||
} else
|
||||
/* Use permissions from file we are overwriting. */
|
||||
mask = st.st_mode;
|
||||
|
||||
if (append == 2 ||
|
||||
(!tmp && (ISSET(NOFOLLOW_SYMLINKS) && S_ISLNK(lst.st_mode)))) {
|
||||
if (unlink(realname) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
realname, strerror(errno));
|
||||
unlink(buf);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
}
|
||||
if (link(buf, realname) != -1)
|
||||
unlink(buf);
|
||||
else if (errno != EPERM) {
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
name, strerror(errno));
|
||||
unlink(buf);
|
||||
goto cleanup_and_exit;
|
||||
} else if (rename(buf, realname) == -1) { /* Try a rename?? */
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
realname, strerror(errno));
|
||||
unlink(buf);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
}
|
||||
if (chmod(realname, mask) == -1)
|
||||
statusbar(_("Could not set permissions %o on %s: %s"),
|
||||
mask, realname, strerror(errno));
|
||||
|
||||
if (!tmp && append == 0) {
|
||||
if (!nonamechange) {
|
||||
filename = mallocstrcpy(filename, realname);
|
||||
@@ -1689,8 +1655,8 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
|
||||
/* Update originalfilestat to reference the file as it is now. */
|
||||
stat(filename, &originalfilestat);
|
||||
#endif
|
||||
statusbar(P_("Wrote %d line", "Wrote %d lines", lineswritten),
|
||||
lineswritten);
|
||||
statusbar(P_("Wrote %u line", "Wrote %u lines", lineswritten),
|
||||
lineswritten);
|
||||
UNSET(MODIFIED);
|
||||
titlebar(NULL);
|
||||
}
|
||||
@@ -1699,7 +1665,7 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
|
||||
|
||||
cleanup_and_exit:
|
||||
free(realname);
|
||||
free(buf);
|
||||
free(tempname);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1835,39 +1801,67 @@ int do_writeout(const char *path, int exiting, int append)
|
||||
struct stat st;
|
||||
|
||||
if (!stat(answer, &st)) {
|
||||
i = do_yesno(0, 0, _("File exists, OVERWRITE ?"));
|
||||
|
||||
i = do_yesno(0, _("File exists, OVERWRITE ?"));
|
||||
if (i == 0 || i == -1)
|
||||
continue;
|
||||
} else if (filename[0] != '\0'
|
||||
#ifndef NANO_SMALL
|
||||
&& (!ISSET(MARK_ISSET) || exiting)
|
||||
#endif
|
||||
) {
|
||||
i = do_yesno(0, _("Save file under DIFFERENT NAME ?"));
|
||||
if (i == 0 || i == -1)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Here's where we allow the selected text to be written to
|
||||
a separate file. */
|
||||
/* Here's where we allow the selected text to be written to
|
||||
* a separate file. */
|
||||
if (ISSET(MARK_ISSET) && !exiting) {
|
||||
filestruct *fileagebak = fileage;
|
||||
filestruct *filebotbak = filebot;
|
||||
filestruct *cutback = cutbuffer;
|
||||
int oldmod = ISSET(MODIFIED);
|
||||
/* write_file() unsets the MODIFIED flag. */
|
||||
size_t topx;
|
||||
/* The column of the beginning of the mark. */
|
||||
char origchar;
|
||||
/* We replace the character at the end of the mark with
|
||||
* '\0'. We save the original character, to restore
|
||||
* it. */
|
||||
char *origcharloc;
|
||||
/* The location of the character we nulled. */
|
||||
|
||||
cutbuffer = NULL;
|
||||
|
||||
/* Put the marked text in the cutbuffer without changing
|
||||
the open file. */
|
||||
cut_marked_segment(current, current_x, mark_beginbuf,
|
||||
mark_beginx, 0);
|
||||
|
||||
fileage = cutbuffer;
|
||||
filebot = get_cutbottom();
|
||||
/* Set fileage as the top of the mark, and filebot as the
|
||||
* bottom. */
|
||||
if (current->lineno > mark_beginbuf->lineno ||
|
||||
(current->lineno == mark_beginbuf->lineno &&
|
||||
current_x > mark_beginx)) {
|
||||
fileage = mark_beginbuf;
|
||||
topx = mark_beginx;
|
||||
filebot = current;
|
||||
origcharloc = current->data + current_x;
|
||||
} else {
|
||||
fileage = current;
|
||||
topx = current_x;
|
||||
filebot = mark_beginbuf;
|
||||
origcharloc = mark_beginbuf->data + mark_beginx;
|
||||
}
|
||||
origchar = *origcharloc;
|
||||
*origcharloc = '\0';
|
||||
fileage->data += topx;
|
||||
/* If the line at filebot is blank, treat it as the
|
||||
* magicline and hence the end of the file. Otherwise,
|
||||
* treat the line after filebot as the end of the file. */
|
||||
if (filebot->data[0] != '\0' && filebot->next != NULL)
|
||||
filebot = filebot->next;
|
||||
i = write_file(answer, 0, append, 1);
|
||||
|
||||
/* Now restore everything */
|
||||
free_filestruct(cutbuffer);
|
||||
/* Now restore everything. */
|
||||
fileage->data -= topx;
|
||||
*origcharloc = origchar;
|
||||
fileage = fileagebak;
|
||||
filebot = filebotbak;
|
||||
cutbuffer = cutback;
|
||||
if (oldmod)
|
||||
set_modified();
|
||||
} else
|
||||
@@ -2103,7 +2097,7 @@ char **cwd_tab_completion(char *buf, int *num_matches)
|
||||
strcpy(tmp2, dirname);
|
||||
strcat(tmp2, "/");
|
||||
strcat(tmp2, next->d_name);
|
||||
if (check_operating_dir(tmp2, 1)) {
|
||||
if (check_operating_dir(tmp2, 1) != 0) {
|
||||
free(tmp2);
|
||||
continue;
|
||||
}
|
||||
@@ -2355,7 +2349,7 @@ struct stat filestat(const char *path)
|
||||
return st;
|
||||
}
|
||||
|
||||
/* Our sort routine for file listings - sort directories before
|
||||
/* Our sort routine for file listings -- sort directories before
|
||||
* files, and then alphabetically. */
|
||||
int diralphasort(const void *va, const void *vb)
|
||||
{
|
||||
@@ -2592,7 +2586,7 @@ char *do_browser(const char *inpath)
|
||||
break;
|
||||
case NANO_PREVPAGE_KEY:
|
||||
case NANO_PREVPAGE_FKEY:
|
||||
case '-':
|
||||
case '-': /* Pico compatibility */
|
||||
if (selected >= (editwinrows + lineno % editwinrows) * width)
|
||||
selected -= (editwinrows + lineno % editwinrows) * width;
|
||||
else
|
||||
@@ -2600,18 +2594,19 @@ char *do_browser(const char *inpath)
|
||||
break;
|
||||
case NANO_NEXTPAGE_KEY:
|
||||
case NANO_NEXTPAGE_FKEY:
|
||||
case ' ':
|
||||
case ' ': /* Pico compatibility */
|
||||
selected += (editwinrows - lineno % editwinrows) * width;
|
||||
if (selected >= numents)
|
||||
selected = numents - 1;
|
||||
break;
|
||||
case NANO_HELP_KEY:
|
||||
case NANO_HELP_FKEY:
|
||||
case '?': /* Pico compatibility */
|
||||
do_help();
|
||||
break;
|
||||
case NANO_ENTER_KEY:
|
||||
case 's': /* More Pico compatibility */
|
||||
case 'S':
|
||||
case 'S': /* Pico compatibility */
|
||||
case 's':
|
||||
/* You can't cd up from / */
|
||||
if (!strcmp(filelist[selected], "/..") && !strcmp(path, "/")) {
|
||||
statusbar(_("Can't move up a directory"));
|
||||
@@ -2620,11 +2615,10 @@ char *do_browser(const char *inpath)
|
||||
}
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
/*
|
||||
* Note: the selected file can be outside the operating
|
||||
* directory if it is .. or if it is a symlink to a directory
|
||||
* outside the opdir. */
|
||||
if (check_operating_dir(filelist[selected], FALSE)) {
|
||||
/* Note: the selected file can be outside the operating
|
||||
* directory if it is .. or if it is a symlink to
|
||||
* directory outside the operating directory. */
|
||||
if (check_operating_dir(filelist[selected], 0) != 0) {
|
||||
statusbar(_("Can't go outside of %s in restricted mode"), operating_dir);
|
||||
beep();
|
||||
break;
|
||||
@@ -2673,6 +2667,8 @@ char *do_browser(const char *inpath)
|
||||
/* Goto a specific directory */
|
||||
case NANO_GOTO_KEY:
|
||||
case NANO_GOTO_FKEY:
|
||||
case 'G': /* Pico compatibility */
|
||||
case 'g':
|
||||
curs_set(1);
|
||||
j = statusq(0, gotodir_list, "",
|
||||
#ifndef NANO_SMALL
|
||||
@@ -2695,7 +2691,7 @@ char *do_browser(const char *inpath)
|
||||
}
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if (check_operating_dir(new_path, FALSE)) {
|
||||
if (check_operating_dir(new_path, 0) != 0) {
|
||||
statusbar(_("Can't go outside of %s in restricted mode"), operating_dir);
|
||||
free(new_path);
|
||||
break;
|
||||
@@ -2717,11 +2713,11 @@ char *do_browser(const char *inpath)
|
||||
return do_browser(path);
|
||||
|
||||
/* Stuff we want to abort the browser */
|
||||
case 'e': /* Pico compatibility, yeech */
|
||||
case 'E':
|
||||
case NANO_CANCEL_KEY:
|
||||
case NANO_EXIT_KEY:
|
||||
case NANO_EXIT_FKEY:
|
||||
case 'E': /* Pico compatibility */
|
||||
case 'e':
|
||||
abort = 1;
|
||||
break;
|
||||
}
|
||||
@@ -2796,7 +2792,7 @@ char *do_browser(const char *inpath)
|
||||
}
|
||||
}
|
||||
wrefresh(edit);
|
||||
} while ((kbinput = get_kbinput(edit, &meta, ISSET(REBIND_DELETE))) != NANO_EXIT_KEY && kbinput != NANO_EXIT_FKEY);
|
||||
} while ((kbinput = get_kbinput(edit, &meta)) != NANO_EXIT_KEY && kbinput != NANO_EXIT_FKEY);
|
||||
curs_set(1);
|
||||
blank_edit();
|
||||
titlebar(NULL);
|
||||
@@ -2838,7 +2834,7 @@ char *do_browse_from(const char *inpath)
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
/* If the resulting path isn't in the operating directory, use that. */
|
||||
if (check_operating_dir(path, FALSE))
|
||||
if (check_operating_dir(path, 0) != 0)
|
||||
path = mallocstrcpy(path, operating_dir);
|
||||
#endif
|
||||
|
||||
|
||||
443
src/global.c
443
src/global.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* global.c *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -92,7 +92,7 @@ char *help_text; /* The text in the help window */
|
||||
/* More stuff for the marker select */
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
filestruct *mark_beginbuf; /* the begin marker buffer */
|
||||
filestruct *mark_beginbuf; /* The begin marker buffer */
|
||||
int mark_beginx; /* X value in the string to start */
|
||||
#endif
|
||||
|
||||
@@ -172,7 +172,7 @@ void sc_init_one(shortcut **shortcutage, int key, const char *desc,
|
||||
#ifndef DISABLE_HELP
|
||||
const char *help,
|
||||
#endif
|
||||
int alt, int misc1, int misc2, int view, int (*func) (void))
|
||||
int meta, int func_key, int misc, int view, int (*func) (void))
|
||||
{
|
||||
shortcut *s;
|
||||
|
||||
@@ -191,9 +191,9 @@ void sc_init_one(shortcut **shortcutage, int key, const char *desc,
|
||||
#ifndef DISABLE_HELP
|
||||
s->help = help;
|
||||
#endif
|
||||
s->altval = alt;
|
||||
s->misc1 = misc1;
|
||||
s->misc2 = misc2;
|
||||
s->metaval = meta;
|
||||
s->func_key = func_key;
|
||||
s->misc = misc;
|
||||
s->viewok = view;
|
||||
s->func = func;
|
||||
s->next = NULL;
|
||||
@@ -235,7 +235,7 @@ void toggle_init(void)
|
||||
char *toggle_wrap_msg;
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
char *toggle_load_msg;
|
||||
char *toggle_multibuffer_msg;
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
char *toggle_syntax_msg;
|
||||
@@ -266,22 +266,22 @@ void toggle_init(void)
|
||||
toggle_wrap_msg = _("Auto line wrap");
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
toggle_load_msg = _("Multiple file buffers");
|
||||
toggle_multibuffer_msg = _("Multiple file buffers");
|
||||
#endif
|
||||
|
||||
toggle_init_one(TOGGLE_NOHELP_KEY, toggle_nohelp_msg, NO_HELP);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
toggle_init_one(TOGGLE_MULTIBUFFER_KEY, toggle_multibuffer_msg, MULTIBUFFER);
|
||||
#endif
|
||||
toggle_init_one(TOGGLE_CONST_KEY, toggle_const_msg, CONSTUPDATE);
|
||||
toggle_init_one(TOGGLE_AUTOINDENT_KEY, toggle_autoindent_msg, AUTOINDENT);
|
||||
toggle_init_one(TOGGLE_SUSPEND_KEY, toggle_suspend_msg, SUSPEND);
|
||||
toggle_init_one(TOGGLE_NOHELP_KEY, toggle_nohelp_msg, NO_HELP);
|
||||
#ifndef DISABLE_WRAPPING
|
||||
toggle_init_one(TOGGLE_WRAP_KEY, toggle_wrap_msg, NO_WRAP);
|
||||
#endif
|
||||
toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END);
|
||||
toggle_init_one(TOGGLE_SUSPEND_KEY, toggle_suspend_msg, SUSPEND);
|
||||
#ifndef DISABLE_MOUSE
|
||||
toggle_init_one(TOGGLE_MOUSE_KEY, toggle_mouse_msg, USE_MOUSE);
|
||||
#endif
|
||||
toggle_init_one(TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg, CUT_TO_END);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
toggle_init_one(TOGGLE_LOAD_KEY, toggle_load_msg, MULTIBUFFER);
|
||||
#endif
|
||||
toggle_init_one(TOGGLE_NOCONVERT_KEY, toggle_noconvert_msg, NO_CONVERT);
|
||||
toggle_init_one(TOGGLE_DOS_KEY, toggle_dos_msg, DOS_FILE);
|
||||
@@ -321,27 +321,30 @@ void free_shortcutage(shortcut **shortcutage)
|
||||
void shortcut_init(int unjustify)
|
||||
{
|
||||
#ifndef DISABLE_HELP
|
||||
const char *nano_help_msg = "", *nano_writeout_msg = "", *nano_exit_msg =
|
||||
"", *nano_goto_msg = "", *nano_justify_msg =
|
||||
"", *nano_replace_msg = "", *nano_insert_msg =
|
||||
"", *nano_whereis_msg = "", *nano_whereis_next_msg =
|
||||
"", *nano_prevpage_msg = "", *nano_nextpage_msg =
|
||||
"", *nano_cut_msg = "", *nano_uncut_msg =
|
||||
"", *nano_cursorpos_msg = "", *nano_spell_msg =
|
||||
"", *nano_up_msg = "", *nano_down_msg =
|
||||
"", *nano_forward_msg = "", *nano_back_msg = "", *nano_home_msg =
|
||||
const char *nano_help_msg = "", *nano_writeout_msg =
|
||||
"", *nano_exit_msg = "", *nano_goto_msg =
|
||||
"", *nano_justify_msg = "", *nano_replace_msg =
|
||||
"", *nano_insert_msg = "", *nano_whereis_msg =
|
||||
"", *nano_whereis_next_msg = "", *nano_prevpage_msg =
|
||||
"", *nano_nextpage_msg = "", *nano_cut_msg =
|
||||
"", *nano_uncut_msg = "", *nano_cursorpos_msg =
|
||||
"", *nano_spell_msg = "", *nano_up_msg =
|
||||
"", *nano_down_msg = "", *nano_forward_msg =
|
||||
"", *nano_back_msg = "", *nano_home_msg =
|
||||
"", *nano_end_msg = "", *nano_firstline_msg =
|
||||
"", *nano_lastline_msg = "", *nano_refresh_msg =
|
||||
"", *nano_mark_msg = "", *nano_delete_msg =
|
||||
"", *nano_backspace_msg = "", *nano_tab_msg =
|
||||
"", *nano_enter_msg = "", *nano_cancel_msg =
|
||||
"", *nano_unjustify_msg = "", *nano_append_msg =
|
||||
"", *nano_prepend_msg = "", *nano_tofiles_msg =
|
||||
"", *nano_gotodir_msg = "", *nano_case_msg =
|
||||
"", *nano_reverse_msg = "", *nano_execute_msg =
|
||||
"", *nano_dos_msg = "", *nano_mac_msg =
|
||||
"", *nano_backup_msg = "", *nano_editstr_msg =
|
||||
"", *nano_parabegin_msg = "", *nano_paraend_msg = "";
|
||||
"", *nano_enter_msg = "", *nano_prevword_msg =
|
||||
"", *nano_nextword_msg = "", *nano_verbatim_msg =
|
||||
"", *nano_cancel_msg = "", *nano_unjustify_msg =
|
||||
"", *nano_append_msg = "", *nano_prepend_msg =
|
||||
"", *nano_tofiles_msg = "", *nano_gotodir_msg =
|
||||
"", *nano_case_msg = "", *nano_reverse_msg =
|
||||
"", *nano_execute_msg = "", *nano_dos_msg =
|
||||
"", *nano_mac_msg = "", *nano_backup_msg =
|
||||
"", *nano_editstr_msg = "", *nano_parabegin_msg =
|
||||
"", *nano_paraend_msg = "";
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
const char *nano_openprev_msg = "", *nano_opennext_msg =
|
||||
@@ -386,6 +389,10 @@ void shortcut_init(int unjustify)
|
||||
_("Delete the character to the left of the cursor");
|
||||
nano_tab_msg = _("Insert a tab character");
|
||||
nano_enter_msg = _("Insert a carriage return at the cursor position");
|
||||
nano_prevword_msg = _("Move backward one word");
|
||||
nano_nextword_msg = _("Move forward one word");
|
||||
nano_verbatim_msg = _("Insert character(s) verbatim");
|
||||
nano_enter_msg = _("Insert a carriage return at the cursor position");
|
||||
nano_case_msg =
|
||||
_("Make the current search or replace case (in)sensitive");
|
||||
nano_tofiles_msg = _("Go to file browser");
|
||||
@@ -422,39 +429,41 @@ void shortcut_init(int unjustify)
|
||||
#else
|
||||
# define IFHELP(help, nextvar) help, nextvar
|
||||
#endif
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), NANO_HELP_FKEY, 0, VIEW,
|
||||
do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (open_files != NULL && (open_files->prev != NULL || open_files->next != NULL))
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_EXIT_KEY, _("Close"),
|
||||
IFHELP(nano_exit_msg, 0), NANO_EXIT_FKEY, 0, VIEW,
|
||||
do_exit);
|
||||
IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_exit);
|
||||
else
|
||||
#endif
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_EXIT_KEY, _("Exit"),
|
||||
IFHELP(nano_exit_msg, 0), NANO_EXIT_FKEY, 0, VIEW,
|
||||
do_exit);
|
||||
IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_exit);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_WRITEOUT_KEY, _("WriteOut"),
|
||||
IFHELP(nano_writeout_msg, 0),
|
||||
NANO_WRITEOUT_FKEY, 0, NOVIEW, do_writeout_void);
|
||||
IFHELP(nano_writeout_msg, NANO_NO_KEY), NANO_WRITEOUT_FKEY,
|
||||
NANO_NO_KEY, NOVIEW, do_writeout_void);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_JUSTIFY_KEY, _("Justify"),
|
||||
IFHELP(nano_justify_msg, 0), NANO_JUSTIFY_FKEY, 0,
|
||||
NOVIEW, do_justify);
|
||||
IFHELP(nano_justify_msg, NANO_NO_KEY),
|
||||
NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW, do_justify);
|
||||
|
||||
/* this is so we can view multiple files */
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
|
||||
IFHELP(nano_insert_msg, 0), NANO_INSERTFILE_FKEY, 0,
|
||||
IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
|
||||
NANO_NO_KEY,
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
VIEW
|
||||
#else
|
||||
@@ -464,183 +473,201 @@ void shortcut_init(int unjustify)
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"),
|
||||
IFHELP(nano_whereis_msg, 0),
|
||||
NANO_WHEREIS_FKEY, 0, VIEW, do_search);
|
||||
IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_WHEREIS_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_search);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
IFHELP(nano_prevpage_msg, 0),
|
||||
NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, do_page_up);
|
||||
IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_page_up);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
IFHELP(nano_nextpage_msg, 0),
|
||||
NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, do_page_down);
|
||||
IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_page_down);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_CUT_KEY, _("Cut Text"),
|
||||
IFHELP(nano_cut_msg, 0),
|
||||
NANO_CUT_FKEY, 0, NOVIEW, do_cut_text);
|
||||
IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY,
|
||||
NANO_NO_KEY, NOVIEW, do_cut_text);
|
||||
|
||||
if (unjustify)
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, _("UnJustify"),
|
||||
IFHELP(nano_unjustify_msg, 0),
|
||||
0, 0, NOVIEW, do_uncut_text);
|
||||
IFHELP(nano_unjustify_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, do_uncut_text);
|
||||
else
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_UNCUT_KEY, _("UnCut Txt"),
|
||||
IFHELP(nano_uncut_msg, 0),
|
||||
NANO_UNCUT_FKEY, 0, NOVIEW, do_uncut_text);
|
||||
IFHELP(nano_uncut_msg, NANO_NO_KEY), NANO_UNCUT_FKEY,
|
||||
NANO_NO_KEY, NOVIEW, do_uncut_text);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_CURSORPOS_KEY, _("Cur Pos"),
|
||||
IFHELP(nano_cursorpos_msg, 0),
|
||||
NANO_CURSORPOS_FKEY, 0, VIEW, do_cursorpos_void);
|
||||
IFHELP(nano_cursorpos_msg, NANO_NO_KEY), NANO_CURSORPOS_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_cursorpos_void);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_SPELL_KEY, _("To Spell"),
|
||||
IFHELP(nano_spell_msg, 0),
|
||||
NANO_SPELL_FKEY, 0, NOVIEW, do_spell);
|
||||
IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
|
||||
NANO_NO_KEY, NOVIEW, do_spell);
|
||||
|
||||
sc_init_one(&main_list, NANO_GOTO_KEY, _("Go To Line"),
|
||||
IFHELP(nano_goto_msg, NANO_ALT_GOTO_KEY), NANO_GOTO_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_gotoline_void);
|
||||
|
||||
sc_init_one(&main_list, NANO_REPLACE_KEY, _("Replace"),
|
||||
IFHELP(nano_replace_msg, NANO_ALT_REPLACE_KEY), NANO_REPLACE_FKEY,
|
||||
NANO_NO_KEY, NOVIEW, do_replace);
|
||||
|
||||
sc_init_one(&main_list, NANO_UP_KEY, _("Up"),
|
||||
IFHELP(nano_up_msg, 0),
|
||||
KEY_UP, 0, VIEW, do_up);
|
||||
IFHELP(nano_up_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_up);
|
||||
|
||||
sc_init_one(&main_list, NANO_DOWN_KEY, _("Down"),
|
||||
IFHELP(nano_down_msg, 0),
|
||||
KEY_DOWN, 0, VIEW, do_down);
|
||||
IFHELP(nano_down_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_down);
|
||||
|
||||
sc_init_one(&main_list, NANO_FORWARD_KEY, _("Forward"),
|
||||
IFHELP(nano_forward_msg, 0),
|
||||
KEY_RIGHT, 0, VIEW, do_right);
|
||||
IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_right);
|
||||
|
||||
sc_init_one(&main_list, NANO_BACK_KEY, _("Back"),
|
||||
IFHELP(nano_back_msg, 0),
|
||||
KEY_LEFT, 0, VIEW, do_left);
|
||||
IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_left);
|
||||
|
||||
sc_init_one(&main_list, NANO_HOME_KEY, _("Home"),
|
||||
IFHELP(nano_home_msg, 0),
|
||||
KEY_HOME, 362, VIEW, do_home);
|
||||
IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_home);
|
||||
|
||||
sc_init_one(&main_list, NANO_END_KEY, _("End"),
|
||||
IFHELP(nano_end_msg, 0),
|
||||
KEY_END, 385, VIEW, do_end);
|
||||
IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_end);
|
||||
|
||||
sc_init_one(&main_list, NANO_REFRESH_KEY, _("Refresh"),
|
||||
IFHELP(nano_refresh_msg, 0),
|
||||
0, 0, VIEW, total_refresh);
|
||||
IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, total_refresh);
|
||||
|
||||
sc_init_one(&main_list, NANO_MARK_KEY, _("Mark Text"),
|
||||
IFHELP(nano_mark_msg, NANO_ALT_MARK_KEY),
|
||||
0, 0, NOVIEW, do_mark);
|
||||
NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_mark);
|
||||
|
||||
sc_init_one(&main_list, NANO_DELETE_KEY, _("Delete"),
|
||||
IFHELP(nano_delete_msg, 0), KEY_DC,
|
||||
NANO_CONTROL_D, NOVIEW, do_delete);
|
||||
IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, do_delete);
|
||||
|
||||
sc_init_one(&main_list, NANO_BACKSPACE_KEY, _("Backspace"),
|
||||
IFHELP(nano_backspace_msg, 0),
|
||||
KEY_BACKSPACE, 127, NOVIEW, do_backspace);
|
||||
IFHELP(nano_backspace_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, do_backspace);
|
||||
|
||||
sc_init_one(&main_list, NANO_TAB_KEY, _("Tab"),
|
||||
IFHELP(nano_tab_msg, 0), 0, 0, NOVIEW, do_tab);
|
||||
|
||||
sc_init_one(&main_list, NANO_REPLACE_KEY, _("Replace"),
|
||||
IFHELP(nano_replace_msg, NANO_ALT_REPLACE_KEY),
|
||||
NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
|
||||
IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, do_tab);
|
||||
|
||||
sc_init_one(&main_list, NANO_ENTER_KEY, _("Enter"),
|
||||
IFHELP(nano_enter_msg, 0),
|
||||
KEY_ENTER, NANO_CONTROL_M, NOVIEW, do_enter);
|
||||
|
||||
sc_init_one(&main_list, NANO_GOTO_KEY, _("Go To Line"),
|
||||
IFHELP(nano_goto_msg, NANO_ALT_GOTO_KEY),
|
||||
NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void);
|
||||
IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, do_enter);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
sc_init_one(&main_list, NANO_NEXTWORD_KEY, _("Next Word"),
|
||||
IFHELP(_("Move forward one word"), 0),
|
||||
0, 0, VIEW, do_next_word);
|
||||
IFHELP(nano_nextword_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_next_word);
|
||||
|
||||
sc_init_one(&main_list, -9, _("Prev Word"),
|
||||
IFHELP(_("Move backward one word"), NANO_PREVWORD_KEY), 0, 0,
|
||||
VIEW, do_prev_word);
|
||||
#endif
|
||||
#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
|
||||
sc_init_one(&main_list, -9, _("Find Other Bracket"),
|
||||
IFHELP(nano_bracket_msg, NANO_BRACKET_KEY),
|
||||
0, 0, VIEW, do_find_bracket);
|
||||
sc_init_one(&main_list, NANO_NO_KEY, _("Prev Word"),
|
||||
IFHELP(nano_prevword_msg, NANO_PREVWORD_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_prev_word);
|
||||
#endif
|
||||
|
||||
sc_init_one(&main_list, -9, _("Where Is Next"),
|
||||
IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY), 0, 0,
|
||||
NOVIEW, do_research);
|
||||
sc_init_one(&main_list, NANO_NO_KEY, _("Verbatim Input"),
|
||||
IFHELP(nano_verbatim_msg, NANO_VERBATIM_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_verbatim_input);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
sc_init_one(&main_list, -9, _("Previous File"),
|
||||
IFHELP(nano_openprev_msg, NANO_OPENPREV_KEY),
|
||||
0, 0, VIEW, open_prevfile_void);
|
||||
sc_init_one(&main_list, -9, _("Next File"),
|
||||
IFHELP(nano_opennext_msg, NANO_OPENNEXT_KEY),
|
||||
0, 0, VIEW, open_nextfile_void);
|
||||
sc_init_one(&main_list, NANO_NO_KEY, _("Previous File"),
|
||||
IFHELP(nano_openprev_msg, NANO_OPENPREV_KEY), NANO_NO_KEY,
|
||||
NANO_OPENPREV_ALTKEY, VIEW, open_prevfile_void);
|
||||
|
||||
sc_init_one(&main_list, NANO_NO_KEY, _("Next File"),
|
||||
IFHELP(nano_opennext_msg, NANO_OPENNEXT_KEY), NANO_NO_KEY,
|
||||
NANO_OPENNEXT_ALTKEY, VIEW, open_nextfile_void);
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
|
||||
sc_init_one(&main_list, NANO_NO_KEY, _("Find Other Bracket"),
|
||||
IFHELP(nano_bracket_msg, NANO_BRACKET_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_find_bracket);
|
||||
#endif
|
||||
|
||||
sc_init_one(&main_list, NANO_NO_KEY, _("Where Is Next"),
|
||||
IFHELP(nano_whereis_next_msg, NANO_WHEREIS_NEXT_KEY),
|
||||
NANO_NO_KEY, NANO_NO_KEY, VIEW, do_research);
|
||||
|
||||
free_shortcutage(&whereis_list);
|
||||
|
||||
sc_init_one(&whereis_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
IFHELP(nano_firstline_msg, 0),
|
||||
0, 0, VIEW, do_first_line);
|
||||
IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_first_line);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, NANO_LASTLINE_KEY, _("Last Line"),
|
||||
IFHELP(nano_lastline_msg, 0), 0, 0, VIEW, do_last_line);
|
||||
IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_last_line);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, _("Replace"),
|
||||
IFHELP(nano_replace_msg, 0), 0, 0, VIEW, do_replace);
|
||||
IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_replace);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY, _("Go To Line"),
|
||||
IFHELP(nano_goto_msg, 0), 0, 0, VIEW, do_gotoline_void);
|
||||
IFHELP(nano_goto_msg, NANO_NO_KEY), NANO_GOTO_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_gotoline_void);
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, _("Beg of Par"),
|
||||
IFHELP(nano_parabegin_msg, 0), 0, 0, VIEW, do_para_begin);
|
||||
IFHELP(nano_parabegin_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_para_begin);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, NANO_PARAEND_KEY, _("End of Par"),
|
||||
IFHELP(nano_paraend_msg, 0), 0, 0, VIEW, do_para_end);
|
||||
IFHELP(nano_paraend_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_para_end);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, TOGGLE_CASE_KEY, _("Case Sens"),
|
||||
IFHELP(nano_case_msg, 0), 0, 0, VIEW, 0);
|
||||
sc_init_one(&whereis_list, NANO_NO_KEY, _("Case Sens"),
|
||||
IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, TOGGLE_BACKWARDS_KEY, _("Direction"),
|
||||
IFHELP(nano_reverse_msg, 0), 0, 0, VIEW, 0);
|
||||
sc_init_one(&whereis_list, NANO_NO_KEY, _("Direction"),
|
||||
IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, TOGGLE_REGEXP_KEY, _("Regexp"),
|
||||
IFHELP(nano_regexp_msg, 0), 0, 0, VIEW, 0);
|
||||
sc_init_one(&whereis_list, NANO_NO_KEY, _("Regexp"),
|
||||
IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, KEY_UP, _("History"),
|
||||
IFHELP(nano_editstr_msg, 0), NANO_UP_KEY, 0, VIEW, 0);
|
||||
sc_init_one(&whereis_list, NANO_HISTORY_KEY, _("History"),
|
||||
IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
#endif
|
||||
|
||||
#endif /* !NANO_SMALL */
|
||||
@@ -648,147 +675,181 @@ void shortcut_init(int unjustify)
|
||||
free_shortcutage(&replace_list);
|
||||
|
||||
sc_init_one(&replace_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
sc_init_one(&replace_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
IFHELP(nano_firstline_msg, 0), 0, 0, VIEW, do_first_line);
|
||||
IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_first_line);
|
||||
|
||||
sc_init_one(&replace_list, NANO_LASTLINE_KEY, _("Last Line"),
|
||||
IFHELP(nano_lastline_msg, 0), 0, 0, VIEW, do_last_line);
|
||||
IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_last_line);
|
||||
|
||||
/* Translators: try to keep this string under 12 characters long */
|
||||
sc_init_one(&replace_list, NANO_OTHERSEARCH_KEY, _("No Replace"),
|
||||
IFHELP(nano_whereis_msg, 0), 0, 0, VIEW, do_search);
|
||||
IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_search);
|
||||
|
||||
sc_init_one(&replace_list, NANO_FROMSEARCHTOGOTO_KEY, _("Go To Line"),
|
||||
IFHELP(nano_goto_msg, 0), 0, 0, VIEW, do_gotoline_void);
|
||||
IFHELP(nano_goto_msg, NANO_NO_KEY), NANO_GOTO_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_gotoline_void);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
sc_init_one(&replace_list, TOGGLE_CASE_KEY, _("Case Sens"),
|
||||
IFHELP(nano_case_msg, 0), 0, 0, VIEW, 0);
|
||||
sc_init_one(&replace_list, NANO_NO_KEY, _("Case Sens"),
|
||||
IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&replace_list, TOGGLE_BACKWARDS_KEY, _("Direction"),
|
||||
IFHELP(nano_reverse_msg, 0), 0, 0, VIEW, 0);
|
||||
sc_init_one(&replace_list, NANO_NO_KEY, _("Direction"),
|
||||
IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
sc_init_one(&replace_list, TOGGLE_REGEXP_KEY, _("Regexp"),
|
||||
IFHELP(nano_regexp_msg, 0), 0, 0, VIEW, 0);
|
||||
sc_init_one(&replace_list, NANO_NO_KEY, _("Regexp"),
|
||||
IFHELP(nano_regexp_msg, TOGGLE_REGEXP_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
#endif
|
||||
|
||||
sc_init_one(&replace_list, KEY_UP, _("History"),
|
||||
IFHELP(nano_editstr_msg, 0), NANO_UP_KEY, 0, VIEW, 0);
|
||||
sc_init_one(&replace_list, NANO_HISTORY_KEY, _("History"),
|
||||
IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_DOWN_KEY, VIEW, 0);
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
free_shortcutage(&replace_list_2);
|
||||
|
||||
sc_init_one(&replace_list_2, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
sc_init_one(&replace_list_2, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
IFHELP(nano_firstline_msg, 0), 0, 0, VIEW, do_first_line);
|
||||
IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_first_line);
|
||||
|
||||
sc_init_one(&replace_list_2, NANO_LASTLINE_KEY, _("Last Line"),
|
||||
IFHELP(nano_lastline_msg, 0), 0, 0, VIEW, do_last_line);
|
||||
IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_last_line);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
sc_init_one(&replace_list_2, KEY_UP, _("History"),
|
||||
IFHELP(nano_editstr_msg, 0), NANO_UP_KEY, 0, VIEW, 0);
|
||||
sc_init_one(&replace_list_2, NANO_UP_KEY, _("History"),
|
||||
IFHELP(nano_editstr_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_DOWN_KEY, VIEW, 0);
|
||||
#endif
|
||||
|
||||
free_shortcutage(&goto_list);
|
||||
|
||||
sc_init_one(&goto_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
sc_init_one(&goto_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&goto_list, NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
IFHELP(nano_firstline_msg, 0), 0, 0, VIEW, do_first_line);
|
||||
IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_first_line);
|
||||
|
||||
sc_init_one(&goto_list, NANO_LASTLINE_KEY, _("Last Line"),
|
||||
IFHELP(nano_lastline_msg, 0), 0, 0, VIEW, do_last_line);
|
||||
IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_last_line);
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
free_shortcutage(&help_list);
|
||||
|
||||
sc_init_one(&help_list, NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
IFHELP(nano_prevpage_msg, 0), NANO_PREVPAGE_FKEY,
|
||||
KEY_PPAGE, VIEW, do_page_up);
|
||||
IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_page_up);
|
||||
|
||||
sc_init_one(&help_list, NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
IFHELP(nano_nextpage_msg, 0),
|
||||
NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, do_page_down);
|
||||
IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_page_down);
|
||||
|
||||
sc_init_one(&help_list, NANO_EXIT_KEY, _("Exit"),
|
||||
IFHELP(nano_exit_msg, 0), NANO_EXIT_FKEY, 0, VIEW,
|
||||
do_exit);
|
||||
IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_exit);
|
||||
#endif
|
||||
|
||||
free_shortcutage(&writefile_list);
|
||||
|
||||
sc_init_one(&writefile_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
/* Translators: try to keep this string under 16 characters long */
|
||||
sc_init_one(&writefile_list, NANO_TOFILES_KEY, _("To Files"),
|
||||
IFHELP(nano_tofiles_msg, 0), 0, 0, NOVIEW, 0);
|
||||
IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Translators: try to keep this string under 16 characters long */
|
||||
sc_init_one(&writefile_list, TOGGLE_DOS_KEY, _("DOS Format"),
|
||||
IFHELP(nano_dos_msg, 0), 0, 0, NOVIEW, 0);
|
||||
sc_init_one(&writefile_list, NANO_NO_KEY, _("DOS Format"),
|
||||
IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
|
||||
/* Translators: try to keep this string under 16 characters long */
|
||||
sc_init_one(&writefile_list, TOGGLE_MAC_KEY, _("Mac Format"),
|
||||
IFHELP(nano_mac_msg, 0), 0, 0, NOVIEW, 0);
|
||||
sc_init_one(&writefile_list, NANO_NO_KEY, _("Mac Format"),
|
||||
IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
/* Translators: try to keep this string under 16 characters long */
|
||||
sc_init_one(&writefile_list, NANO_APPEND_KEY, _("Append"),
|
||||
IFHELP(nano_append_msg, 0), 0, 0, NOVIEW, 0);
|
||||
sc_init_one(&writefile_list, NANO_NO_KEY, _("Append"),
|
||||
IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
|
||||
/* Translators: try to keep this string under 16 characters long */
|
||||
sc_init_one(&writefile_list, NANO_PREPEND_KEY, _("Prepend"),
|
||||
IFHELP(nano_prepend_msg, 0), 0, 0, NOVIEW, 0);
|
||||
sc_init_one(&writefile_list, NANO_NO_KEY, _("Prepend"),
|
||||
IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Translators: try to keep this string under 16 characters long */
|
||||
sc_init_one(&writefile_list, TOGGLE_BACKUP_KEY, _("Backup File"),
|
||||
IFHELP(nano_backup_msg, 0), 0, 0, NOVIEW, 0);
|
||||
sc_init_one(&writefile_list, NANO_NO_KEY, _("Backup File"),
|
||||
IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
sc_init_one(&writefile_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
free_shortcutage(&insertfile_list);
|
||||
|
||||
sc_init_one(&insertfile_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
sc_init_one(&insertfile_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
sc_init_one(&insertfile_list, NANO_TOFILES_KEY, _("To Files"),
|
||||
IFHELP(nano_tofiles_msg, 0), 0, 0, NOVIEW, 0);
|
||||
IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Translators: try to keep this string under 22 characters long */
|
||||
sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, _("Execute Command"),
|
||||
IFHELP(nano_execute_msg, 0), 0, 0, NOVIEW, 0);
|
||||
IFHELP(nano_execute_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* Translators: try to keep this string under 22 characters long */
|
||||
sc_init_one(&insertfile_list, TOGGLE_LOAD_KEY, _("New Buffer"),
|
||||
IFHELP(nano_multibuffer_msg, 0), 0, 0, NOVIEW, 0);
|
||||
sc_init_one(&insertfile_list, NANO_NO_KEY, _("New Buffer"),
|
||||
IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -796,51 +857,59 @@ void shortcut_init(int unjustify)
|
||||
free_shortcutage(&spell_list);
|
||||
|
||||
sc_init_one(&spell_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
sc_init_one(&spell_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
free_shortcutage(&extcmd_list);
|
||||
|
||||
sc_init_one(&extcmd_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
sc_init_one(&extcmd_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
free_shortcutage(&browser_list);
|
||||
|
||||
sc_init_one(&browser_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
sc_init_one(&browser_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), NANO_EXIT_FKEY, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&browser_list, NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
IFHELP(nano_prevpage_msg, 0), NANO_PREVPAGE_FKEY,
|
||||
KEY_PPAGE, VIEW, 0);
|
||||
IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&browser_list, NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
IFHELP(nano_nextpage_msg, 0), NANO_NEXTPAGE_FKEY,
|
||||
KEY_NPAGE, VIEW, 0);
|
||||
IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
/* Translators: try to keep this string under 22 characters long */
|
||||
sc_init_one(&browser_list, NANO_GOTO_KEY, _("Go To Dir"),
|
||||
IFHELP(nano_gotodir_msg, NANO_ALT_GOTO_KEY),
|
||||
NANO_GOTO_FKEY, 0, VIEW, 0);
|
||||
IFHELP(nano_gotodir_msg, NANO_ALT_GOTO_KEY), NANO_GOTO_FKEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
free_shortcutage(&gotodir_list);
|
||||
|
||||
sc_init_one(&gotodir_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, 0), 0, 0, VIEW, do_help);
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
|
||||
sc_init_one(&gotodir_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, 0), 0, 0, VIEW, 0);
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* move.c *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -148,8 +148,8 @@ int do_up(void)
|
||||
current_x = actual_x(current->data, placewewant);
|
||||
if (current_y > 0) {
|
||||
update_line(current->next, 0);
|
||||
/* It was necessary to change current first, so the mark
|
||||
* display will change! */
|
||||
/* It was necessary to change current first, so that the
|
||||
* mark display will change! */
|
||||
update_line(current, current_x);
|
||||
} else
|
||||
#ifndef NANO_SMALL
|
||||
|
||||
446
src/nano.c
446
src/nano.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* nano.c *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -186,7 +186,7 @@ void print_view_warning(void)
|
||||
statusbar(_("Key illegal in VIEW mode"));
|
||||
}
|
||||
|
||||
/* Initialize global variables - no better way for now. If
|
||||
/* Initialize global variables -- no better way for now. If
|
||||
* save_cutbuffer is nonzero, don't set cutbuffer to NULL. */
|
||||
void global_init(int save_cutbuffer)
|
||||
{
|
||||
@@ -403,43 +403,43 @@ void help_init(void)
|
||||
|
||||
/* Now add our shortcut info */
|
||||
for (s = currshortcut; s != NULL; s = s->next) {
|
||||
/* true if the character in s->altval is shown in first column */
|
||||
/* true if the character in s->metaval is shown in first column */
|
||||
int meta_shortcut = 0;
|
||||
|
||||
if (s->val > 0 && s->val < 32)
|
||||
ptr += sprintf(ptr, "^%c", s->val + 64);
|
||||
if (s->val != NANO_NO_KEY) {
|
||||
#ifndef NANO_SMALL
|
||||
else if (s->val == NANO_CONTROL_SPACE)
|
||||
ptr += sprintf(ptr, "^%.6s", _("Space"));
|
||||
else if (s->altval == NANO_ALT_SPACE) {
|
||||
meta_shortcut = 1;
|
||||
ptr += sprintf(ptr, "M-%.5s", _("Space"));
|
||||
} else if (s->val == KEY_UP)
|
||||
ptr += sprintf(ptr, "%.2s", _("Up"));
|
||||
if (s->val == NANO_HISTORY_KEY)
|
||||
ptr += sprintf(ptr, "%.2s", _("Up"));
|
||||
else
|
||||
#endif
|
||||
else if (s->altval > 0) {
|
||||
meta_shortcut = 1;
|
||||
ptr += sprintf(ptr, "M-%c", s->altval -
|
||||
(('A' <= s->altval && s->altval <= 'Z') ||
|
||||
'a' <= s->altval ? 32 : 0));
|
||||
if (s->val == NANO_CONTROL_SPACE)
|
||||
ptr += sprintf(ptr, "^%.5s", _("Space"));
|
||||
else if (s->val == NANO_CONTROL_8)
|
||||
ptr += sprintf(ptr, "^?");
|
||||
else
|
||||
ptr += sprintf(ptr, "^%c", s->val + 64);
|
||||
}
|
||||
/* Hack */
|
||||
else if (s->val >= 'a') {
|
||||
#ifndef NANO_SMALL
|
||||
else if (s->metaval != NANO_NO_KEY) {
|
||||
meta_shortcut = 1;
|
||||
ptr += sprintf(ptr, "M-%c", s->val - 32);
|
||||
if (s->metaval == NANO_ALT_SPACE)
|
||||
ptr += snprintf(ptr, 8, "M-%.5s", _("Space"));
|
||||
else
|
||||
ptr += sprintf(ptr, "M-%c", toupper(s->metaval));
|
||||
}
|
||||
#endif
|
||||
|
||||
*(ptr++) = '\t';
|
||||
|
||||
if (s->misc1 > KEY_F0 && s->misc1 <= KEY_F(64))
|
||||
ptr += sprintf(ptr, "(F%d)", s->misc1 - KEY_F0);
|
||||
if (s->func_key != NANO_NO_KEY)
|
||||
ptr += sprintf(ptr, "(F%d)", s->func_key - KEY_F0);
|
||||
|
||||
*(ptr++) = '\t';
|
||||
|
||||
if (!meta_shortcut && s->altval > 0)
|
||||
ptr += sprintf(ptr, "(M-%c)", s->altval -
|
||||
(('A' <= s->altval && s->altval <= 'Z') || 'a' <= s->altval
|
||||
? 32 : 0));
|
||||
if (!meta_shortcut && s->metaval != NANO_NO_KEY)
|
||||
ptr += sprintf(ptr, "(M-%c)", toupper(s->metaval));
|
||||
else if (meta_shortcut && s->misc != NANO_NO_KEY)
|
||||
ptr += sprintf(ptr, "(M-%c)", toupper(s->misc));
|
||||
|
||||
*(ptr++) = '\t';
|
||||
|
||||
@@ -452,7 +452,7 @@ void help_init(void)
|
||||
if (currshortcut == main_list)
|
||||
for (t = toggles; t != NULL; t = t->next) {
|
||||
assert(t->desc != NULL);
|
||||
ptr += sprintf(ptr, "M-%c\t\t\t%s %s\n", t->val - 32, t->desc,
|
||||
ptr += sprintf(ptr, "M-%c\t\t\t%s %s\n", toupper(t->val), t->desc,
|
||||
_("enable/disable"));
|
||||
}
|
||||
#endif /* !NANO_SMALL */
|
||||
@@ -659,7 +659,7 @@ void usage(void)
|
||||
#endif
|
||||
print1opt("-c", "--const", _("Constantly show cursor position"));
|
||||
#ifndef NANO_SMALL
|
||||
print1opt("-d", "--rebinddelete", _("Fix Backspace if it acts like Delete"));
|
||||
print1opt("-d", "--rebinddelete", _("Fix Backspace/Delete confusion problem"));
|
||||
print1opt("-i", "--autoindent", _("Automatically indent new lines"));
|
||||
print1opt("-k", "--cut", _("Let ^K cut from cursor to end of line"));
|
||||
#endif
|
||||
@@ -774,7 +774,7 @@ void nano_disabled_msg(void)
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
static int pid; /* This is the PID of the newly forked process
|
||||
static int pid; /* This is the PID of the newly forked process
|
||||
* below. It must be global since the signal
|
||||
* handler needs it. */
|
||||
RETSIGTYPE cancel_fork(int signal)
|
||||
@@ -890,87 +890,56 @@ int open_pipe(const char *command)
|
||||
#ifndef DISABLE_MOUSE
|
||||
void do_mouse(void)
|
||||
{
|
||||
MEVENT mevent;
|
||||
int currslen;
|
||||
const shortcut *s = currshortcut;
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
if (getmouse(&mevent) == ERR)
|
||||
return;
|
||||
if (get_mouseinput(&mouse_x, &mouse_y, 1) == 0) {
|
||||
|
||||
/* If mouse not in edit or bottom window, return */
|
||||
if (wenclose(edit, mevent.y, mevent.x) && currshortcut == main_list) {
|
||||
int sameline;
|
||||
/* Did they click on the line with the cursor? If they
|
||||
clicked on the cursor, we set the mark. */
|
||||
size_t xcur;
|
||||
/* The character they clicked on. */
|
||||
/* Click in the edit window to move the cursor, but only when
|
||||
we're not in a subfunction. */
|
||||
if (wenclose(edit, mouse_y, mouse_x) && currshortcut == main_list) {
|
||||
int sameline;
|
||||
/* Did they click on the line with the cursor? If they
|
||||
clicked on the cursor, we set the mark. */
|
||||
size_t xcur;
|
||||
/* The character they clicked on. */
|
||||
|
||||
/* Subtract out size of topwin. Perhaps we need a constant
|
||||
* somewhere? */
|
||||
mevent.y -= 2;
|
||||
/* Subtract out size of topwin. Perhaps we need a constant
|
||||
somewhere? */
|
||||
mouse_y -= 2;
|
||||
|
||||
sameline = mevent.y == current_y;
|
||||
sameline = (mouse_y == current_y);
|
||||
|
||||
/* Move to where the click occurred. */
|
||||
for(; current_y < mevent.y && current->next != NULL; current_y++)
|
||||
current = current->next;
|
||||
for(; current_y > mevent.y && current->prev != NULL; current_y--)
|
||||
current = current->prev;
|
||||
/* Move to where the click occurred. */
|
||||
for (; current_y < mouse_y && current->next != NULL; current_y++)
|
||||
current = current->next;
|
||||
for (; current_y > mouse_y && current->prev != NULL; current_y--)
|
||||
current = current->prev;
|
||||
|
||||
xcur = actual_x(current->data, get_page_start(xplustabs()) + mevent.x);
|
||||
xcur = actual_x(current->data, get_page_start(xplustabs()) +
|
||||
mouse_x);
|
||||
|
||||
/* Selecting where the cursor is toggles the mark. As does
|
||||
selecting beyond the line length with the cursor at the end of
|
||||
the line. */
|
||||
if (sameline && xcur == current_x) {
|
||||
if (ISSET(VIEW_MODE)) {
|
||||
print_view_warning();
|
||||
return;
|
||||
/* Selecting where the cursor is toggles the mark. As does
|
||||
selecting beyond the line length with the cursor at the
|
||||
end of the line. */
|
||||
if (sameline && xcur == current_x) {
|
||||
if (ISSET(VIEW_MODE)) {
|
||||
print_view_warning();
|
||||
return;
|
||||
}
|
||||
do_mark();
|
||||
}
|
||||
do_mark();
|
||||
|
||||
current_x = xcur;
|
||||
placewewant = xplustabs();
|
||||
edit_refresh();
|
||||
}
|
||||
|
||||
current_x = xcur;
|
||||
placewewant = xplustabs();
|
||||
edit_refresh();
|
||||
} else if (wenclose(bottomwin, mevent.y, mevent.x) && !ISSET(NO_HELP)) {
|
||||
int i, k;
|
||||
|
||||
if (currshortcut == main_list)
|
||||
currslen = MAIN_VISIBLE;
|
||||
else
|
||||
currslen = length_of_list(currshortcut);
|
||||
|
||||
if (currslen < 2)
|
||||
k = COLS / 6;
|
||||
else
|
||||
k = COLS / ((currslen + (currslen %2)) / 2);
|
||||
|
||||
/* Determine what shortcut list was clicked */
|
||||
mevent.y -= (editwinrows + 3);
|
||||
|
||||
if (mevent.y < 0) /* They clicked on the statusbar */
|
||||
return;
|
||||
|
||||
/* Don't select stuff beyond list length */
|
||||
if (mevent.x / k >= currslen)
|
||||
return;
|
||||
|
||||
for (i = 0; i < (mevent.x / k) * 2 + mevent.y; i++)
|
||||
s = s->next;
|
||||
|
||||
/* And ungetch that value */
|
||||
ungetch(s->val);
|
||||
|
||||
/* And if it's an alt-key sequence, we should probably send alt
|
||||
too ;-) */
|
||||
if (s->val >= 'a' && s->val <= 'z')
|
||||
ungetch(27);
|
||||
}
|
||||
/* FIXME: If we clicked on a location in the statusbar, the cursor
|
||||
should move to the location we clicked on. */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The user typed a printable character; add it to the edit buffer. */
|
||||
/* The user typed a character; add it to the edit buffer. */
|
||||
void do_char(char ch)
|
||||
{
|
||||
size_t current_len = strlen(current->data);
|
||||
@@ -980,25 +949,33 @@ void do_char(char ch)
|
||||
* update_line()? */
|
||||
#endif
|
||||
|
||||
/* magic-line: when a character is inserted on the current magic line,
|
||||
* it means we need a new one! */
|
||||
if (filebot == current && current->data[0] == '\0') {
|
||||
if (ch == '\0') /* Null to newline, if needed. */
|
||||
ch = '\n';
|
||||
else if (ch == '\n') { /* Newline to Enter, if needed. */
|
||||
do_enter();
|
||||
return;
|
||||
}
|
||||
|
||||
assert(current != NULL && current->data != NULL);
|
||||
|
||||
/* When a character is inserted on the current magicline, it means
|
||||
* we need a new one! */
|
||||
if (filebot == current) {
|
||||
new_magicline();
|
||||
fix_editbot();
|
||||
}
|
||||
|
||||
/* more dangerousness fun =) */
|
||||
/* More dangerousness fun =) */
|
||||
current->data = charealloc(current->data, current_len + 2);
|
||||
assert(current_x <= current_len);
|
||||
charmove(¤t->data[current_x + 1],
|
||||
¤t->data[current_x],
|
||||
current_len - current_x + 1);
|
||||
charmove(¤t->data[current_x + 1], ¤t->data[current_x],
|
||||
current_len - current_x + 1);
|
||||
current->data[current_x] = ch;
|
||||
totsize++;
|
||||
set_modified();
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* note that current_x has not yet been incremented */
|
||||
/* Note that current_x has not yet been incremented. */
|
||||
if (current == mark_beginbuf && current_x < mark_beginx)
|
||||
mark_beginx++;
|
||||
#endif
|
||||
@@ -1020,6 +997,48 @@ void do_char(char ch)
|
||||
#endif
|
||||
}
|
||||
|
||||
int do_verbatim_input(void)
|
||||
{
|
||||
char *verbatim_kbinput; /* Used to hold verbatim input */
|
||||
int verbatim_len; /* Length of verbatim input */
|
||||
int old_preserve = ISSET(PRESERVE), old_suspend = ISSET(SUSPEND);
|
||||
int i;
|
||||
|
||||
/* Turn off Ctrl-Q (XON), Ctrl-S (XOFF), and Ctrl-Z (suspend) if
|
||||
* they're on, so that we can use them to insert ^Q, ^S, and ^Z
|
||||
* verbatim. */
|
||||
if (old_preserve)
|
||||
UNSET(PRESERVE);
|
||||
if (old_suspend)
|
||||
UNSET(SUSPEND);
|
||||
if (old_preserve || old_suspend)
|
||||
signal_init();
|
||||
|
||||
statusbar(_("Verbatim input"));
|
||||
verbatim_kbinput = get_verbatim_kbinput(edit, &verbatim_len, 1);
|
||||
|
||||
/* Turn on DISABLE_CURPOS while inserting character(s) and turn it
|
||||
* off afterwards, so that if constant cursor position display is
|
||||
* on, it will be updated properly. */
|
||||
SET(DISABLE_CURPOS);
|
||||
for (i = 0; i < verbatim_len; i++)
|
||||
do_char(verbatim_kbinput[i]);
|
||||
UNSET(DISABLE_CURPOS);
|
||||
|
||||
free(verbatim_kbinput);
|
||||
|
||||
/* Turn Ctrl-Q, Ctrl-S, and Ctrl-Z back on if they were on
|
||||
* before. */
|
||||
if (old_preserve)
|
||||
SET(PRESERVE);
|
||||
if (old_suspend)
|
||||
SET(SUSPEND);
|
||||
if (old_preserve || old_suspend)
|
||||
signal_init();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_backspace(void)
|
||||
{
|
||||
if (current != fileage || current_x > 0) {
|
||||
@@ -1361,7 +1380,7 @@ int do_wrap(filestruct *inptr)
|
||||
i = indent_length(inptr->data);
|
||||
#endif
|
||||
wrap_line = inptr->data + i;
|
||||
for(; i < len; i++, wrap_line++) {
|
||||
for (; i < len; i++, wrap_line++) {
|
||||
/* record where the last word ended */
|
||||
if (*wrap_line != ' ' && *wrap_line != '\t')
|
||||
word_back = i;
|
||||
@@ -1547,8 +1566,10 @@ int do_int_spell_fix(const char *word)
|
||||
|
||||
search_last_line = FALSE;
|
||||
|
||||
/* We find the first whole-word occurrence of word. */
|
||||
while (findnextstr(TRUE, TRUE, fileage, -1, word))
|
||||
/* We find the first whole-word occurrence of word. We call
|
||||
findnextstr() with bracket_mode set to TRUE in order to disable
|
||||
search wrapping. */
|
||||
while (findnextstr(TRUE, TRUE, fileage, -1, word, 0))
|
||||
if (is_whole_word(current_x, current->data, word)) {
|
||||
edit_refresh();
|
||||
|
||||
@@ -2094,7 +2115,7 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len,
|
||||
|
||||
set_modified();
|
||||
cutbuffer = NULL;
|
||||
for(; par_len > 0; par_len--) {
|
||||
for (; par_len > 0; par_len--) {
|
||||
filestruct *bob = copy_node(alice);
|
||||
|
||||
if (alice == first_line)
|
||||
@@ -2121,7 +2142,7 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len,
|
||||
/* Is it possible to break line at or before goal? */
|
||||
int breakable(const char *line, int goal)
|
||||
{
|
||||
for(; *line != '\0' && goal >= 0; line++) {
|
||||
for (; *line != '\0' && goal >= 0; line++) {
|
||||
if (*line == ' ' || *line == '\t')
|
||||
return TRUE;
|
||||
|
||||
@@ -2151,7 +2172,7 @@ int break_line(const char *line, int goal, int force)
|
||||
/* Current index in line */
|
||||
|
||||
assert(line != NULL);
|
||||
for(; *line != '\0' && goal >= 0; line++, cur_loc++) {
|
||||
for (; *line != '\0' && goal >= 0; line++, cur_loc++) {
|
||||
if (*line == ' ')
|
||||
space_loc = cur_loc;
|
||||
assert(*line != '\t');
|
||||
@@ -2167,7 +2188,7 @@ int break_line(const char *line, int goal, int force)
|
||||
if (space_loc == -1) {
|
||||
/* No space found short enough. */
|
||||
if (force)
|
||||
for(; *line != '\0'; line++, cur_loc++)
|
||||
for (; *line != '\0'; line++, cur_loc++)
|
||||
if (*line == ' ' && *(line + 1) != ' ' && *(line + 1) != '\0')
|
||||
return cur_loc;
|
||||
return -1;
|
||||
@@ -2198,38 +2219,40 @@ int do_para_operation(int operation)
|
||||
* A line is "part of a paragraph" if it has a part not in the quote
|
||||
* part or the indentation.
|
||||
*
|
||||
* A line is "the beginning of a paragraph" if it is part of a paragraph
|
||||
* and
|
||||
* A line is "the beginning of a paragraph" if it is part of a
|
||||
* paragraph and
|
||||
* 1) it is the top line of the file, or
|
||||
* 2) the line above it is not part of a paragraph, or
|
||||
* 3) the line above it does not have precisely the same quote
|
||||
* part, or
|
||||
* 4) the indentation of this line is not an initial substring of the
|
||||
* indentation of the previous line, or
|
||||
* 4) the indentation of this line is not an initial substring of
|
||||
* the indentation of the previous line, or
|
||||
* 5) this line has no quote part and some indentation, and
|
||||
* AUTOINDENT is not set.
|
||||
* The reason for number 5) is that if AUTOINDENT is not set, then an
|
||||
* indented line is expected to start a paragraph, like in books. Thus,
|
||||
* nano can justify an indented paragraph only if AUTOINDENT is turned
|
||||
* on.
|
||||
* indented line is expected to start a paragraph, like in books.
|
||||
* Thus, nano can justify an indented paragraph only if AUTOINDENT is
|
||||
* turned on.
|
||||
*
|
||||
* A contiguous set of lines is a "paragraph" if each line is part of
|
||||
* a paragraph and only the first line is the beginning of a paragraph.
|
||||
*/
|
||||
* a paragraph and only the first line is the beginning of a
|
||||
* paragraph. */
|
||||
|
||||
size_t quote_len;
|
||||
/* Length of the initial quotation of the paragraph we justify. */
|
||||
/* Length of the initial quotation of the paragraph we
|
||||
* justify. */
|
||||
size_t par_len;
|
||||
/* Number of lines in that paragraph. */
|
||||
filestruct *first_mod_line = NULL;
|
||||
/* Will be the first line of the resulting justified paragraph
|
||||
* that differs from the original. For restoring after uncut. */
|
||||
* that differs from the original. For restoring after
|
||||
* uncut. */
|
||||
filestruct *last_par_line = current;
|
||||
/* Will be the last line of the result, also for uncut. */
|
||||
filestruct *cutbuffer_save = cutbuffer;
|
||||
/* When the paragraph gets modified, all lines from the changed
|
||||
* one down are stored in the cut buffer. We back up the original
|
||||
* to restore it later. */
|
||||
* one down are stored in the cut buffer. We back up the
|
||||
* original to restore it later. */
|
||||
|
||||
/* We save these global variables to be restored if the user
|
||||
* unjustifies. Note we don't need to save totlines. */
|
||||
@@ -2245,13 +2268,13 @@ int do_para_operation(int operation)
|
||||
int mark_beginx_save = mark_beginx;
|
||||
#endif
|
||||
|
||||
size_t indent_len; /* generic indentation length */
|
||||
filestruct *line; /* generic line of text */
|
||||
size_t i; /* generic loop variable */
|
||||
size_t indent_len; /* Generic indentation length. */
|
||||
filestruct *line; /* Generic line of text. */
|
||||
size_t i; /* Generic loop variable. */
|
||||
|
||||
static int no_restart = 0;
|
||||
/* whether we're blocking restarting when searching for the
|
||||
* beginning line of the paragraph */
|
||||
/* Whether we're blocking restarting when searching for the
|
||||
* beginning line of the paragraph. */
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
regex_t qreg; /* qreg is the compiled quotation regexp.
|
||||
@@ -2276,15 +2299,15 @@ int do_para_operation(int operation)
|
||||
|
||||
restart_bps:
|
||||
/* Here we find the first line of the paragraph to justify. If the
|
||||
* current line is in a paragraph, then we move back to the first line.
|
||||
* current line is in a paragraph, then we move back to the first line.
|
||||
* Otherwise we move down to the first line that is in a paragraph. */
|
||||
quote_len = quote_length(IFREG(current->data, &qreg));
|
||||
indent_len = indent_length(current->data + quote_len);
|
||||
|
||||
if (current->data[quote_len + indent_len] != '\0') {
|
||||
/* This line is part of a paragraph. So we must search back to
|
||||
* the first line of this paragraph. First we check items 1) and
|
||||
* 3) above. */
|
||||
* the first line of this paragraph. First we check items 1)
|
||||
* and 3) above. */
|
||||
while (current->prev != NULL && quotes_match(current->data,
|
||||
quote_len, IFREG(current->prev->data, &qreg))) {
|
||||
size_t temp_id_len =
|
||||
@@ -2396,7 +2419,7 @@ int do_para_operation(int operation)
|
||||
/* Next step, we loop through the lines of this paragraph, justifying
|
||||
* each one individually. */
|
||||
SET(JUSTIFY_MODE);
|
||||
for(; par_len > 0; current_y++, par_len--) {
|
||||
for (; par_len > 0; current_y++, par_len--) {
|
||||
size_t line_len;
|
||||
size_t display_len;
|
||||
/* The width of current in screen columns. */
|
||||
@@ -2432,8 +2455,8 @@ int do_para_operation(int operation)
|
||||
if (first_mod_line == NULL)
|
||||
first_mod_line = backup_lines(current, par_len, quote_len);
|
||||
if (par_len == 1) {
|
||||
/* There is no next line in this paragraph. We make a new
|
||||
* line and copy text after break_pos into it. */
|
||||
/* There is no next line in this paragraph. We make a
|
||||
* new line and copy text after break_pos into it. */
|
||||
splice_node(current, make_new_node(current),
|
||||
current->next);
|
||||
/* In a non-quoted paragraph, we copy the indent only if
|
||||
@@ -2490,8 +2513,8 @@ int do_para_operation(int operation)
|
||||
|
||||
indent_len = quote_len +
|
||||
indent_length(current->next->data + quote_len);
|
||||
/* If we can't pull a word from the next line up to this one,
|
||||
* just go on. */
|
||||
/* If we can't pull a word from the next line up to this
|
||||
* one, just go on. */
|
||||
if (!breakable(current->next->data + indent_len,
|
||||
fill - display_len - 1))
|
||||
goto continue_loc;
|
||||
@@ -2622,7 +2645,7 @@ int do_para_operation(int operation)
|
||||
edit_refresh();
|
||||
|
||||
statusbar(_("Can now UnJustify!"));
|
||||
/* Change the shortcut list to display the unjustify code */
|
||||
/* Change the shortcut list to display the unjustify code. */
|
||||
shortcut_init(1);
|
||||
display_main_list();
|
||||
reset_cursor();
|
||||
@@ -2630,16 +2653,22 @@ int do_para_operation(int operation)
|
||||
/* Now get a keystroke and see if it's unjustify; if not, unget the
|
||||
* keystroke and return. */
|
||||
|
||||
{
|
||||
int meta;
|
||||
i = get_kbinput(edit, &meta);
|
||||
#ifndef DISABLE_MOUSE
|
||||
/* If it was a mouse click, parse it with do_mouse() and it might
|
||||
* become the unjustify key. Else give it back to the input stream. */
|
||||
if ((i = wgetch(edit)) == KEY_MOUSE)
|
||||
do_mouse();
|
||||
else
|
||||
ungetch(i);
|
||||
/* If it was a mouse click, parse it with do_mouse() and it
|
||||
* might become the unjustify key. Else give it back to the
|
||||
* input stream. */
|
||||
if (i == KEY_MOUSE)
|
||||
do_mouse();
|
||||
else
|
||||
ungetch(i);
|
||||
i = get_kbinput(edit, &meta);
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((i = wgetch(edit)) != NANO_UNJUSTIFY_KEY) {
|
||||
if (i != NANO_UNJUSTIFY_KEY) {
|
||||
ungetch(i);
|
||||
/* Did we back up anything at all? */
|
||||
if (cutbuffer != cutbuffer_save)
|
||||
@@ -2734,14 +2763,11 @@ int do_exit(void)
|
||||
finish(0);
|
||||
}
|
||||
|
||||
if (ISSET(TEMP_OPT)) {
|
||||
if (ISSET(TEMP_OPT))
|
||||
i = 1;
|
||||
} else {
|
||||
i = do_yesno(0, 0,
|
||||
_
|
||||
("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
|
||||
}
|
||||
|
||||
else
|
||||
i = do_yesno(0, _("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_buffer(fileage);
|
||||
#endif
|
||||
@@ -2872,7 +2898,7 @@ RETSIGTYPE do_cont(int signal)
|
||||
doupdate();
|
||||
|
||||
/* The Hurd seems to need this, otherwise a ^Y after a ^Z will
|
||||
start suspending again. */
|
||||
start suspending again. */
|
||||
signal_init();
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
@@ -3029,7 +3055,7 @@ int main(int argc, char *argv[])
|
||||
int fill_flag_used = 0; /* Was the fill option used? */
|
||||
const shortcut *s;
|
||||
int keyhandled = 0; /* Have we handled the keystroke yet? */
|
||||
int kbinput = -1; /* Input from keyboard */
|
||||
int kbinput; /* Input from keyboard */
|
||||
int meta;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
@@ -3039,7 +3065,6 @@ int main(int argc, char *argv[])
|
||||
struct termios term;
|
||||
#endif
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
int option_index = 0;
|
||||
const struct option long_options[] = {
|
||||
{"help", 0, 0, 'h'},
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
@@ -3113,7 +3138,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
while ((optchr = getopt_long(argc, argv, "h?BDFHIMNQ:RST:VY:abcdefgijklmo:pr:s:tvwxz",
|
||||
long_options, &option_index)) != -1) {
|
||||
long_options, NULL)) != -1) {
|
||||
#else
|
||||
while ((optchr =
|
||||
getopt(argc, argv, "h?BDFHIMNQ:RST:VY:abcdefgijklmo:pr:s:tvwxz")) != -1) {
|
||||
@@ -3488,70 +3513,15 @@ int main(int argc, char *argv[])
|
||||
raw();
|
||||
#endif
|
||||
|
||||
kbinput = get_kbinput(edit, &meta, ISSET(REBIND_DELETE));
|
||||
kbinput = get_kbinput(edit, &meta);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput);
|
||||
#endif
|
||||
if (meta == 1) {
|
||||
switch (kbinput) {
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
case NANO_OPENPREV_KEY:
|
||||
case NANO_OPENPREV_ALTKEY:
|
||||
open_prevfile_void();
|
||||
keyhandled = 1;
|
||||
break;
|
||||
case NANO_OPENNEXT_KEY:
|
||||
case NANO_OPENNEXT_ALTKEY:
|
||||
open_nextfile_void();
|
||||
keyhandled = 1;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* Check for the altkey defs.... */
|
||||
for (s = main_list; s != NULL; s = s->next)
|
||||
if (kbinput == s->altval || (kbinput >= 'A' &&
|
||||
kbinput <= 'Z' && kbinput == s->altval - 32)) {
|
||||
if (ISSET(VIEW_MODE) && !s->viewok)
|
||||
print_view_warning();
|
||||
else {
|
||||
if (s->func != do_cut_text)
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
s->func();
|
||||
}
|
||||
keyhandled = 1;
|
||||
break;
|
||||
}
|
||||
#ifndef NANO_SMALL
|
||||
if (!keyhandled)
|
||||
/* And for toggle switches */
|
||||
for (t = toggles; t != NULL; t = t->next)
|
||||
if (kbinput == t->val || (t->val >= 'a' &&
|
||||
t->val <= 'z' && kbinput == t->val - 32)) {
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
do_toggle(t);
|
||||
keyhandled = 1;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "I got Alt-%c! (%d)\n", kbinput,
|
||||
kbinput);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* Look through the main shortcut list to see if we've hit a
|
||||
shortcut key */
|
||||
|
||||
if (!keyhandled)
|
||||
#if !defined(DISABLE_BROWSER) || !defined (DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||
for (s = currshortcut; s != NULL && !keyhandled; s = s->next) {
|
||||
#else
|
||||
for (s = main_list; s != NULL && !keyhandled; s = s->next) {
|
||||
#endif
|
||||
if (kbinput == s->val ||
|
||||
(s->misc1 && kbinput == s->misc1) ||
|
||||
(s->misc2 && kbinput == s->misc2)) {
|
||||
/* Check for the metaval and misc defs... */
|
||||
for (s = main_list; s != NULL; s = s->next)
|
||||
if ((s->metaval != NANO_NO_KEY && kbinput == s->metaval) ||
|
||||
(s->misc != NANO_NO_KEY && kbinput == s->misc)) {
|
||||
if (ISSET(VIEW_MODE) && !s->viewok)
|
||||
print_view_warning();
|
||||
else {
|
||||
@@ -3560,10 +3530,44 @@ int main(int argc, char *argv[])
|
||||
s->func();
|
||||
}
|
||||
keyhandled = 1;
|
||||
/* Rarely, the value of s can change after
|
||||
s->func(), leading to problems; get around this
|
||||
by breaking out explicitly once we successfully
|
||||
handle a shortcut */
|
||||
}
|
||||
#ifndef NANO_SMALL
|
||||
if (!keyhandled)
|
||||
/* And for toggle switches */
|
||||
for (t = toggles; t != NULL; t = t->next)
|
||||
if (kbinput == t->val) {
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
do_toggle(t);
|
||||
keyhandled = 1;
|
||||
}
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "I got Alt-%c! (%d)\n", kbinput,
|
||||
kbinput);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Look through the main shortcut list to see if we've hit a
|
||||
shortcut key or function key */
|
||||
|
||||
if (!keyhandled)
|
||||
#if !defined(DISABLE_BROWSER) || !defined (DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||
for (s = currshortcut; s != NULL && !keyhandled; s = s->next) {
|
||||
#else
|
||||
for (s = main_list; s != NULL && !keyhandled; s = s->next) {
|
||||
#endif
|
||||
if ((s->val != NANO_NO_KEY && kbinput == s->val) ||
|
||||
(s->func_key != NANO_NO_KEY && kbinput == s->func_key)) {
|
||||
if (ISSET(VIEW_MODE) && !s->viewok)
|
||||
print_view_warning();
|
||||
else {
|
||||
if (s->func != do_cut_text)
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
s->func();
|
||||
}
|
||||
keyhandled = 1;
|
||||
/* Break out explicitly once we successfully handle
|
||||
a shortcut */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
156
src/nano.h
156
src/nano.h
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* nano.h *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -46,13 +46,14 @@
|
||||
#endif
|
||||
|
||||
#ifdef USE_SLANG
|
||||
/* Slang support enabled */
|
||||
/* Slang support enabled. Work around Slang's not defining KEY_DC or
|
||||
* KEY_IC. */
|
||||
#include <slcurses.h>
|
||||
#define KEY_DC SL_KEY_DELETE
|
||||
#define KEY_IC SL_KEY_IC
|
||||
#elif defined(HAVE_NCURSES_H)
|
||||
#include <ncurses.h>
|
||||
#else /* Uh oh */
|
||||
#else /* Uh oh. */
|
||||
#include <curses.h>
|
||||
#endif /* CURSES_H */
|
||||
|
||||
@@ -71,16 +72,18 @@
|
||||
#include <sys/stat.h>
|
||||
#include "config.h"
|
||||
|
||||
/* If no snprintf()/vsnprintf(), use the versions from glib. */
|
||||
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF)
|
||||
#include <glib.h>
|
||||
# ifndef HAVE_SNPRINTF
|
||||
# define snprintf g_snprintf
|
||||
# define snprintf g_snprintf
|
||||
# endif
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define vsnprintf g_vsnprintf
|
||||
# define vsnprintf g_vsnprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If no strcasecmp()/strncasecmp(), use the versions we have. */
|
||||
#ifndef HAVE_STRCASECMP
|
||||
#define strcasecmp nstricmp
|
||||
#endif
|
||||
@@ -90,10 +93,11 @@
|
||||
#endif
|
||||
|
||||
/* Assume ERR is defined as -1. To avoid duplicate case values when
|
||||
some key definitions are missing, we have to set these all to
|
||||
different negative values other than -1. */
|
||||
* some key definitions are missing, we have to set all of these, and
|
||||
* all of the special sentinel values below, to different negative
|
||||
* values other than -1. */
|
||||
|
||||
/* HP-UX 10 & 11 do not seem to support KEY_HOME and KEY_END */
|
||||
/* HP-UX 10 & 11 do not seem to support KEY_HOME and KEY_END. */
|
||||
#ifndef KEY_HOME
|
||||
#define KEY_HOME -2
|
||||
#endif
|
||||
@@ -102,25 +106,29 @@
|
||||
#define KEY_END -3
|
||||
#endif
|
||||
|
||||
/* Slang and SunOS 5.7-5.9 do not seem to support KEY_RESIZE */
|
||||
/* Slang and SunOS 5.7-5.9 do not seem to support KEY_RESIZE. */
|
||||
#ifndef KEY_RESIZE
|
||||
#define KEY_RESIZE -4
|
||||
#endif
|
||||
|
||||
/* Slang does not seem to support KEY_SUSPEND */
|
||||
/* Slang does not seem to support KEY_SUSPEND, KEY_SLEFT, or
|
||||
* KEY_SRIGHT. */
|
||||
#ifndef KEY_SUSPEND
|
||||
#define KEY_SUSPEND -5
|
||||
#endif
|
||||
|
||||
/* Snatch these out of the ncurses defs, so we can use them in search
|
||||
history regardless of whether we're using ncurses or not */
|
||||
#if !defined(KEY_UP) || !defined(KEY_DOWN)
|
||||
#define KEY_UP 0403
|
||||
#define KEY_DOWN 0402
|
||||
#endif /* !KEY_UP || !KEY_DOWN */
|
||||
#ifndef KEY_SLEFT
|
||||
#define KEY_SLEFT -6
|
||||
#endif
|
||||
|
||||
#ifndef KEY_SRIGHT
|
||||
#define KEY_SRIGHT -7
|
||||
#endif
|
||||
|
||||
#define VERMSG "GNU nano " VERSION
|
||||
|
||||
/* If we aren't using ncurses, turn the mouse support off, as it's
|
||||
* ncurses-specific. */
|
||||
#ifndef NCURSES_MOUSE_VERSION
|
||||
#define DISABLE_MOUSE 1
|
||||
#endif
|
||||
@@ -129,12 +137,12 @@
|
||||
#define DISABLE_WRAPJUSTIFY 1
|
||||
#endif
|
||||
|
||||
/* Structure types */
|
||||
/* Structure types. */
|
||||
typedef struct filestruct {
|
||||
char *data;
|
||||
struct filestruct *next; /* Next node */
|
||||
struct filestruct *prev; /* Previous node */
|
||||
int lineno; /* The line number */
|
||||
struct filestruct *next; /* Next node. */
|
||||
struct filestruct *prev; /* Previous node. */
|
||||
int lineno; /* The line number. */
|
||||
} filestruct;
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
@@ -143,49 +151,56 @@ typedef struct openfilestruct {
|
||||
#ifndef NANO_SMALL
|
||||
struct stat originalfilestat;
|
||||
#endif
|
||||
struct openfilestruct *next; /* Next node */
|
||||
struct openfilestruct *prev; /* Previous node */
|
||||
struct filestruct *fileage; /* Current file */
|
||||
struct filestruct *filebot; /* Current file's last line */
|
||||
struct openfilestruct *next; /* Next node. */
|
||||
struct openfilestruct *prev; /* Previous node. */
|
||||
struct filestruct *fileage; /* Current file. */
|
||||
struct filestruct *filebot; /* Current file's last line. */
|
||||
#ifndef NANO_SMALL
|
||||
struct filestruct *file_mark_beginbuf;
|
||||
/* Current file's beginning marked line */
|
||||
int file_mark_beginx; /* Current file's beginning marked line's
|
||||
x-coordinate position */
|
||||
/* Current file's beginning marked
|
||||
* line. */
|
||||
int file_mark_beginx; /* Current file's beginning marked
|
||||
* line's x-coordinate position. */
|
||||
#endif
|
||||
int file_current_x; /* Current file's x-coordinate position */
|
||||
int file_current_y; /* Current file's y-coordinate position */
|
||||
int file_current_x; /* Current file's x-coordinate
|
||||
* position. */
|
||||
int file_current_y; /* Current file's y-coordinate
|
||||
* position. */
|
||||
int file_flags; /* Current file's flags: modification
|
||||
status (and marking status, if
|
||||
available) */
|
||||
int file_placewewant; /* Current file's place we want */
|
||||
int file_totlines; /* Current file's total number of lines */
|
||||
long file_totsize; /* Current file's total size */
|
||||
int file_lineno; /* Current file's line number */
|
||||
* status (and marking status, if
|
||||
* available). */
|
||||
int file_placewewant; /* Current file's place we want. */
|
||||
int file_totlines; /* Current file's total number of
|
||||
* lines. */
|
||||
long file_totsize; /* Current file's total size. */
|
||||
int file_lineno; /* Current file's line number. */
|
||||
} openfilestruct;
|
||||
#endif
|
||||
|
||||
typedef struct shortcut {
|
||||
int val; /* Actual sequence that generates the keystroke */
|
||||
int altval; /* Alt key # for this function, or 0 for none */
|
||||
int misc1; /* Other int functions we want bound */
|
||||
int misc2;
|
||||
int viewok; /* is this function legal in view mode? */
|
||||
int (*func) (void); /* Function to call when we catch this key */
|
||||
const char *desc; /* Description, e.g. "Page Up" */
|
||||
/* Key values that aren't used should be set to NANO_NO_KEY. */
|
||||
int val; /* Special sentinel key or control key we want
|
||||
* bound. */
|
||||
int metaval; /* Meta key we want bound. */
|
||||
int func_key; /* Function key we want bound. */
|
||||
int misc; /* Other Meta key we want bound. */
|
||||
int viewok; /* Is this function legal in view mode? */
|
||||
int (*func) (void); /* Function to call when we catch this key. */
|
||||
const char *desc; /* Description, e.g. "Page Up". */
|
||||
#ifndef DISABLE_HELP
|
||||
const char *help; /* Help file entry text */
|
||||
const char *help; /* Help file entry text. */
|
||||
#endif
|
||||
struct shortcut *next;
|
||||
struct shortcut *next;
|
||||
} shortcut;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
typedef struct toggle {
|
||||
int val; /* Sequence to toggle the key. Should only need 1 */
|
||||
int val; /* Sequence to toggle the key. Should only need
|
||||
* one. */
|
||||
const char *desc; /* Description for when toggle is, uh, toggled,
|
||||
e.g. "Pico Messages"; we'll append Enabled or
|
||||
Disabled */
|
||||
int flag; /* What flag actually gets toggled */
|
||||
* e.g. "Cut to end"; we'll append Enabled or
|
||||
* Disabled. */
|
||||
int flag; /* What flag actually gets toggled. */
|
||||
struct toggle *next;
|
||||
} toggle;
|
||||
#endif /* !NANO_SMALL */
|
||||
@@ -230,8 +245,10 @@ typedef struct historytype {
|
||||
char *data;
|
||||
} historytype;
|
||||
typedef struct historyheadtype {
|
||||
struct historytype *next; /* keep *next and *prev members together */
|
||||
struct historytype *prev; /* and in same order as in historytype */
|
||||
struct historytype *next; /* Keep *next and *prev members
|
||||
* together. */
|
||||
struct historytype *prev; /* And in same order as in
|
||||
* historytype. */
|
||||
struct historytype *tail;
|
||||
struct historytype *current;
|
||||
int count;
|
||||
@@ -239,8 +256,8 @@ typedef struct historyheadtype {
|
||||
} historyheadtype;
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
/* Bitwise flags so we can save space (or more correctly, not waste it) */
|
||||
|
||||
/* Bitwise flags so we can save space (or more correctly, not waste
|
||||
* it). */
|
||||
#define MODIFIED (1<<0)
|
||||
#define KEEP_CUTBUFFER (1<<1)
|
||||
#define CASE_SENSITIVE (1<<2)
|
||||
@@ -262,7 +279,7 @@ typedef struct historyheadtype {
|
||||
#define DOS_FILE (1<<18)
|
||||
#define MAC_FILE (1<<19)
|
||||
#define SMOOTHSCROLL (1<<20)
|
||||
#define DISABLE_CURPOS (1<<21) /* Damn, we still need it */
|
||||
#define DISABLE_CURPOS (1<<21) /* Damn, we still need it. */
|
||||
#define REBIND_DELETE (1<<22)
|
||||
#define NO_CONVERT (1<<23)
|
||||
#define BACKUP_FILE (1<<24)
|
||||
@@ -273,8 +290,7 @@ typedef struct historyheadtype {
|
||||
#define HISTORYLOG (1<<29)
|
||||
#define JUSTIFY_MODE (1<<30)
|
||||
|
||||
/* Control key sequences, changing these would be very very bad */
|
||||
|
||||
/* Control key sequences, changing these would be very very bad. */
|
||||
#define NANO_CONTROL_SPACE 0
|
||||
#define NANO_CONTROL_A 1
|
||||
#define NANO_CONTROL_B 2
|
||||
@@ -339,16 +355,23 @@ typedef struct historyheadtype {
|
||||
#define NANO_ALT_COMMA ','
|
||||
#define NANO_ALT_LCARAT '<'
|
||||
#define NANO_ALT_RCARAT '>'
|
||||
#define NANO_ALT_BRACKET ']'
|
||||
#define NANO_ALT_RBRACKET ']'
|
||||
#define NANO_ALT_SPACE ' '
|
||||
|
||||
/* Some semi-changeable keybindings; don't play with unless you're sure
|
||||
you know what you're doing */
|
||||
/* Some semi-changeable keybindings; don't play with these unless you're
|
||||
* sure you know what you're doing. */
|
||||
|
||||
/* No key at all. */
|
||||
#define NANO_NO_KEY -8
|
||||
|
||||
/* Special sentinel key used for search string history. */
|
||||
#define NANO_HISTORY_KEY -9
|
||||
|
||||
/* Normal keys. */
|
||||
#define NANO_INSERTFILE_KEY NANO_CONTROL_R
|
||||
#define NANO_INSERTFILE_FKEY KEY_F(5)
|
||||
#define NANO_EXIT_KEY NANO_CONTROL_X
|
||||
#define NANO_EXIT_FKEY KEY_F(2)
|
||||
#define NANO_EXIT_KEY NANO_CONTROL_X
|
||||
#define NANO_EXIT_FKEY KEY_F(2)
|
||||
#define NANO_WRITEOUT_KEY NANO_CONTROL_O
|
||||
#define NANO_WRITEOUT_FKEY KEY_F(3)
|
||||
#define NANO_GOTO_KEY NANO_CONTROL_7
|
||||
@@ -403,12 +426,13 @@ typedef struct historyheadtype {
|
||||
#define NANO_OPENNEXT_KEY NANO_ALT_RCARAT
|
||||
#define NANO_OPENPREV_ALTKEY NANO_ALT_COMMA
|
||||
#define NANO_OPENNEXT_ALTKEY NANO_ALT_PERIOD
|
||||
#define NANO_BRACKET_KEY NANO_ALT_BRACKET
|
||||
#define NANO_BRACKET_KEY NANO_ALT_RBRACKET
|
||||
#define NANO_EXTCMD_KEY NANO_CONTROL_X
|
||||
#define NANO_NEXTWORD_KEY NANO_CONTROL_SPACE
|
||||
#define NANO_PREVWORD_KEY NANO_ALT_SPACE
|
||||
#define NANO_PARABEGIN_KEY NANO_CONTROL_W
|
||||
#define NANO_PARAEND_KEY NANO_CONTROL_O
|
||||
#define NANO_VERBATIM_KEY NANO_ALT_V
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Toggles do not exist with NANO_SMALL. */
|
||||
@@ -422,7 +446,7 @@ typedef struct historyheadtype {
|
||||
#define TOGGLE_WRAP_KEY NANO_ALT_L
|
||||
#define TOGGLE_BACKWARDS_KEY NANO_ALT_B
|
||||
#define TOGGLE_CASE_KEY NANO_ALT_C
|
||||
#define TOGGLE_LOAD_KEY NANO_ALT_F
|
||||
#define TOGGLE_MULTIBUFFER_KEY NANO_ALT_F
|
||||
#define TOGGLE_DOS_KEY NANO_ALT_D
|
||||
#define TOGGLE_MAC_KEY NANO_ALT_O
|
||||
#define TOGGLE_SMOOTH_KEY NANO_ALT_S
|
||||
@@ -440,18 +464,18 @@ typedef enum {
|
||||
TOP, CENTER, NONE
|
||||
} topmidnone;
|
||||
|
||||
/* Minimum editor window rows required for nano to work correctly */
|
||||
/* Minimum editor window rows required for nano to work correctly. */
|
||||
#define MIN_EDITOR_ROWS 3
|
||||
|
||||
/* Minimum editor window cols required for nano to work correctly */
|
||||
/* Minimum editor window cols required for nano to work correctly. */
|
||||
#define MIN_EDITOR_COLS 10
|
||||
|
||||
/* Default number of characters from end-of-line where text wrapping
|
||||
occurs */
|
||||
* occurs. */
|
||||
#define CHARS_FROM_EOL 8
|
||||
|
||||
/* Maximum number of search history strings saved, same value used for
|
||||
replace history */
|
||||
* replace history. */
|
||||
#define MAX_SEARCH_HISTORY 100
|
||||
|
||||
#endif /* !NANO_H */
|
||||
|
||||
29
src/proto.h
29
src/proto.h
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* proto.h *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -19,7 +19,7 @@
|
||||
* *
|
||||
**************************************************************************/
|
||||
|
||||
/* Externs */
|
||||
/* Externs. */
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -128,7 +128,7 @@ extern historyheadtype replace_history;
|
||||
|
||||
extern int curses_ended;
|
||||
|
||||
/* Functions we want available */
|
||||
/* Functions we want available. */
|
||||
|
||||
/* Public functions in color.c */
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -140,8 +140,7 @@ void update_color(void);
|
||||
/* Public functions in cut.c */
|
||||
filestruct *get_cutbottom(void);
|
||||
void add_to_cutbuffer(filestruct *inptr);
|
||||
void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
|
||||
size_t bot_x, int destructive);
|
||||
void cut_marked_segment(void);
|
||||
int do_cut_text(void);
|
||||
int do_uncut_text(void);
|
||||
|
||||
@@ -207,7 +206,7 @@ void sc_init_one(shortcut **shortcutage, int key, const char *desc,
|
||||
#ifndef DISABLE_HELP
|
||||
const char *help,
|
||||
#endif
|
||||
int alt, int misc1, int misc2, int view, int (*func) (void));
|
||||
int meta, int func_key, int misc, int view, int (*func) (void));
|
||||
#ifndef NANO_SMALL
|
||||
void toggle_init_one(int val, const char *desc, int flag);
|
||||
void toggle_init(void);
|
||||
@@ -271,6 +270,7 @@ int open_pipe(const char *command);
|
||||
void do_mouse(void);
|
||||
#endif
|
||||
void do_char(char ch);
|
||||
int do_verbatim_input(void);
|
||||
int do_backspace(void);
|
||||
int do_delete(void);
|
||||
int do_tab(void);
|
||||
@@ -362,7 +362,7 @@ int search_init(int replacing);
|
||||
int is_whole_word(int curr_pos, const char *datastr, const char *searchword);
|
||||
filestruct *findnextstr(int quiet, int bracket_mode,
|
||||
const filestruct *begin, int beginx,
|
||||
const char *needle);
|
||||
const char *needle, int no_sameline);
|
||||
int do_search(void);
|
||||
int do_research(void);
|
||||
void replace_abort(void);
|
||||
@@ -435,14 +435,15 @@ int check_wildcard_match(const char *text, const char *pattern);
|
||||
#endif
|
||||
|
||||
/* Public functions in winio.c */
|
||||
int get_kbinput(WINDOW *win, int *meta, int rebind_delete);
|
||||
char *get_verbatim_kbinput(WINDOW *win, int *kbinput_len);
|
||||
int get_kbinput(WINDOW *win, int *meta);
|
||||
char *get_verbatim_kbinput(WINDOW *win, int *kbinput_len,
|
||||
int allow_ascii);
|
||||
int get_ignored_kbinput(WINDOW *win);
|
||||
int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta,
|
||||
int rebind_delete);
|
||||
int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta);
|
||||
int get_ascii_kbinput(WINDOW *win, int kbinput);
|
||||
int get_escape_seq_kbinput(WINDOW *win, int kbinput);
|
||||
int get_skip_tilde_kbinput(WINDOW *win, int errval, int retval);
|
||||
int get_escape_seq_kbinput(WINDOW *win, char *escape_seq, int
|
||||
escape_seq_len);
|
||||
int get_mouseinput(int *mouse_x, int *mouse_y, int shortcut);
|
||||
int do_first_line(void);
|
||||
int do_last_line(void);
|
||||
int xpt(const filestruct *fileptr, int index);
|
||||
@@ -491,7 +492,7 @@ int statusq(int tabs, const shortcut *s, const char *def,
|
||||
historyheadtype *history_list,
|
||||
#endif
|
||||
const char *msg, ...);
|
||||
int do_yesno(int all, int leavecursor, const char *msg, ...);
|
||||
int do_yesno(int all, const char *msg);
|
||||
int total_refresh(void);
|
||||
void display_main_list(void);
|
||||
void statusbar(const char *msg, ...);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* rcfile.c *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -233,7 +233,7 @@ char *parse_next_regex(char *ptr)
|
||||
if (*ptr == '\0')
|
||||
return NULL;
|
||||
|
||||
/* Null terminate and advance ptr */
|
||||
/* Null terminate and advance ptr. */
|
||||
*ptr++ = '\0';
|
||||
|
||||
while (*ptr == ' ' || *ptr == '\t')
|
||||
|
||||
123
src/search.c
123
src/search.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* search.c *
|
||||
* *
|
||||
* Copyright (C) 2000-2003 Chris Allegretta *
|
||||
* Copyright (C) 2000-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -247,7 +247,7 @@ int is_whole_word(int curr_pos, const char *datastr, const char *searchword)
|
||||
|
||||
filestruct *findnextstr(int quiet, int bracket_mode,
|
||||
const filestruct *begin, int beginx,
|
||||
const char *needle)
|
||||
const char *needle, int no_sameline)
|
||||
{
|
||||
filestruct *fileptr = current;
|
||||
const char *searchstr, *rev_start = NULL, *found = NULL;
|
||||
@@ -265,8 +265,12 @@ filestruct *findnextstr(int quiet, int bracket_mode,
|
||||
|
||||
searchstr = &fileptr->data[current_x_find];
|
||||
|
||||
/* Look for needle in searchstr */
|
||||
while ((found = strstrwrapper(searchstr, needle, rev_start, current_x_find)) == NULL) {
|
||||
/* Look for needle in searchstr. Keep going until we find it
|
||||
* and, if no_sameline is set, until it isn't on the current
|
||||
* line. If we don't find it, we'll end up at
|
||||
* current[current_x] regardless of whether no_sameline is
|
||||
* set. */
|
||||
while ((found = strstrwrapper(searchstr, needle, rev_start, current_x_find)) == NULL || (no_sameline && fileptr == current)) {
|
||||
|
||||
/* finished processing file, get out */
|
||||
if (search_last_line) {
|
||||
@@ -320,8 +324,13 @@ filestruct *findnextstr(int quiet, int bracket_mode,
|
||||
rev_start = &fileptr->data[current_x_find];
|
||||
searchstr = fileptr->data;
|
||||
|
||||
/* Look for needle in searchstr */
|
||||
while ((found = strstrwrapper(searchstr, needle, rev_start, current_x_find)) == NULL) {
|
||||
/* Look for needle in searchstr. Keep going until we find it
|
||||
* and, if no_sameline is set, until it isn't on the current
|
||||
* line. If we don't find it, we'll end up at
|
||||
* current[current_x] regardless of whether no_sameline is
|
||||
* set. */
|
||||
while ((found = strstrwrapper(searchstr, needle, rev_start, current_x_find)) == NULL || (no_sameline && fileptr == current)) {
|
||||
|
||||
/* finished processing file, get out */
|
||||
if (search_last_line) {
|
||||
if (!quiet)
|
||||
@@ -420,7 +429,7 @@ int do_search(void)
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
search_last_line = 0;
|
||||
didfind = findnextstr(FALSE, FALSE, current, current_x, answer);
|
||||
didfind = findnextstr(FALSE, FALSE, current, current_x, answer, 0);
|
||||
|
||||
if (fileptr == current && fileptr_x == current_x && didfind != NULL)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
@@ -459,7 +468,7 @@ int do_research(void)
|
||||
#endif
|
||||
|
||||
search_last_line = 0;
|
||||
didfind = findnextstr(FALSE, FALSE, current, current_x, last_search);
|
||||
didfind = findnextstr(FALSE, FALSE, current, current_x, last_search, 0);
|
||||
|
||||
if (fileptr == current && fileptr_x == current_x && didfind != NULL)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
@@ -608,22 +617,24 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||
int *beginx, int wholewords, int *i)
|
||||
{
|
||||
int replaceall = 0, numreplaced = -1;
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* The starting-line match and bol/eol regex flags. */
|
||||
int beginline = 0, bol_eol = 0;
|
||||
#endif
|
||||
filestruct *fileptr = NULL;
|
||||
char *copy;
|
||||
|
||||
switch (*i) {
|
||||
case -1: /* Aborted enter */
|
||||
if (last_replace[0] != '\0')
|
||||
answer = mallocstrcpy(answer, last_replace);
|
||||
statusbar(_("Replace Cancelled"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
case 0: /* They actually entered something */
|
||||
break;
|
||||
default:
|
||||
if (*i != -2) { /* First page, last page, for example, could
|
||||
get here */
|
||||
case -1: /* Aborted enter. */
|
||||
if (last_replace[0] != '\0')
|
||||
answer = mallocstrcpy(answer, last_replace);
|
||||
statusbar(_("Replace Cancelled"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
case 0: /* They actually entered something. */
|
||||
break;
|
||||
default:
|
||||
if (*i != -2) { /* First page, last page, for example, could
|
||||
* get here. */
|
||||
do_early_abort();
|
||||
replace_abort();
|
||||
return 0;
|
||||
@@ -634,9 +645,36 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||
while (1) {
|
||||
size_t match_len;
|
||||
|
||||
/* Sweet optimization by Rocco here */
|
||||
/* Sweet optimization by Rocco here. */
|
||||
fileptr = findnextstr(fileptr || replaceall || search_last_line,
|
||||
FALSE, begin, *beginx, prevanswer);
|
||||
FALSE, begin, *beginx, prevanswer,
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* We should find a bol and/or eol regex only once per
|
||||
* line. If the bol_eol flag is set, it means that the
|
||||
* last search found one on the beginning line, so we
|
||||
* should skip over the beginning line when doing this
|
||||
* search. */
|
||||
bol_eol
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* If the bol_eol flag is set, we've found a match on the
|
||||
* beginning line already, and we're still on the beginning line
|
||||
* after the search, it means that we've wrapped around, so
|
||||
* we're done. */
|
||||
if (bol_eol && beginline && fileptr == begin)
|
||||
fileptr = NULL;
|
||||
/* Otherwise, set the beginline flag if we've found a match on
|
||||
* the beginning line, reset the bol_eol flag, and continue. */
|
||||
else {
|
||||
if (fileptr == begin)
|
||||
beginline = 1;
|
||||
bol_eol = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (current->lineno <= edittop->lineno
|
||||
|| current->lineno >= editbot->lineno)
|
||||
@@ -646,11 +684,11 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||
if (fileptr == NULL)
|
||||
break;
|
||||
|
||||
/* Make sure only whole words are found */
|
||||
/* Make sure only whole words are found. */
|
||||
if (wholewords && !is_whole_word(current_x, fileptr->data, prevanswer))
|
||||
continue;
|
||||
|
||||
/* If we're here, we've found the search string */
|
||||
/* If we're here, we've found the search string. */
|
||||
if (numreplaced == -1)
|
||||
numreplaced = 0;
|
||||
|
||||
@@ -671,16 +709,26 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||
curs_set(0);
|
||||
do_replace_highlight(TRUE, exp_word);
|
||||
|
||||
*i = do_yesno(1, 1, _("Replace this instance?"));
|
||||
*i = do_yesno(1, _("Replace this instance?"));
|
||||
|
||||
do_replace_highlight(FALSE, exp_word);
|
||||
free(exp_word);
|
||||
curs_set(1);
|
||||
|
||||
if (*i == -1) /* We canceled the replace. */
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Set the bol_eol flag if we're doing a bol and/or eol regex
|
||||
* replace ("^", "$", or "^$"). */
|
||||
if (ISSET(USE_REGEXP) && regexec(&search_regexp, prevanswer, 1, NULL, REG_NOTBOL | REG_NOTEOL) == REG_NOMATCH)
|
||||
bol_eol = 1;
|
||||
#endif
|
||||
|
||||
if (*i > 0 || replaceall) { /* Yes, replace it!!!! */
|
||||
long length_change;
|
||||
size_t match_len;
|
||||
char *copy;
|
||||
int length_change;
|
||||
|
||||
if (*i == 2)
|
||||
replaceall = 1;
|
||||
@@ -694,13 +742,6 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||
|
||||
length_change = strlen(copy) - strlen(current->data);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||
else
|
||||
#endif
|
||||
match_len = strlen(prevanswer);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (current == mark_beginbuf && mark_beginx > current_x) {
|
||||
if (mark_beginx < current_x + match_len)
|
||||
@@ -718,14 +759,14 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||
}
|
||||
|
||||
/* Set the cursor at the last character of the replacement
|
||||
* text, so searching will resume after the replacement text.
|
||||
* Note that current_x might be set to -1 here. */
|
||||
* text, so searching will resume after the replacement
|
||||
* text. Note that current_x might be set to -1 here. */
|
||||
#ifndef NANO_SMALL
|
||||
if (!ISSET(REVERSE_SEARCH))
|
||||
#endif
|
||||
current_x += match_len + length_change - 1;
|
||||
|
||||
/* Cleanup */
|
||||
/* Cleanup. */
|
||||
totsize += length_change;
|
||||
free(current->data);
|
||||
current->data = copy;
|
||||
@@ -733,9 +774,7 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
|
||||
edit_refresh();
|
||||
set_modified();
|
||||
numreplaced++;
|
||||
} else if (*i == -1) /* Abort, else do nothing and continue
|
||||
loop */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If text has been added to the magicline, make a new magicline. */
|
||||
@@ -938,7 +977,7 @@ int do_find_bracket(void)
|
||||
|
||||
while (1) {
|
||||
search_last_line = 0;
|
||||
if (findnextstr(1, 1, current, current_x, regexp_pat) != NULL) {
|
||||
if (findnextstr(TRUE, TRUE, current, current_x, regexp_pat, 0) != NULL) {
|
||||
have_search_offscreen |= search_offscreen;
|
||||
|
||||
/* found identical bracket */
|
||||
|
||||
18
src/utils.c
18
src/utils.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* utils.c *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -84,7 +84,7 @@ void null_at(char **data, size_t index)
|
||||
void unsunder(char *str, size_t true_len)
|
||||
{
|
||||
assert(str != NULL);
|
||||
for(; true_len > 0; true_len--, str++)
|
||||
for (; true_len > 0; true_len--, str++)
|
||||
if (*str == '\0')
|
||||
*str = '\n';
|
||||
}
|
||||
@@ -94,7 +94,7 @@ void unsunder(char *str, size_t true_len)
|
||||
void sunder(char *str)
|
||||
{
|
||||
assert(str != NULL);
|
||||
for(; *str != '\0'; str++)
|
||||
for (; *str != '\0'; str++)
|
||||
if (*str == '\n')
|
||||
*str = '\0';
|
||||
}
|
||||
@@ -135,7 +135,7 @@ int nstrnicmp(const char *s1, const char *s2, size_t n)
|
||||
const char *revstrstr(const char *haystack, const char *needle,
|
||||
const char *rev_start)
|
||||
{
|
||||
for(; rev_start >= haystack ; rev_start--) {
|
||||
for (; rev_start >= haystack; rev_start--) {
|
||||
const char *r, *q;
|
||||
|
||||
for (r = rev_start, q = needle ; *q == *r && *q != '\0'; r++, q++)
|
||||
@@ -197,13 +197,13 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(REVERSE_SEARCH)) {
|
||||
/* When doing a backwards search, haystack is a whole line. */
|
||||
if (!regexec(&search_regexp, haystack, 1, regmatches, 0) &&
|
||||
if (regexec(&search_regexp, haystack, 1, regmatches, 0) == 0 &&
|
||||
haystack + regmatches[0].rm_so <= rev_start) {
|
||||
const char *retval = haystack + regmatches[0].rm_so;
|
||||
|
||||
/* Search forward until there is no more match. */
|
||||
while (!regexec(&search_regexp, retval + 1, 1, regmatches,
|
||||
REG_NOTBOL) &&
|
||||
while (regexec(&search_regexp, retval + 1, 1, regmatches,
|
||||
REG_NOTBOL) == 0 &&
|
||||
retval + 1 + regmatches[0].rm_so <= rev_start)
|
||||
retval += 1 + regmatches[0].rm_so;
|
||||
/* Finally, put the subexpression matches in global
|
||||
@@ -214,8 +214,8 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
}
|
||||
} else
|
||||
#endif /* !NANO_SMALL */
|
||||
if (!regexec(&search_regexp, haystack, 10, regmatches,
|
||||
line_pos > 0 ? REG_NOTBOL : 0)) {
|
||||
if (regexec(&search_regexp, haystack, 10, regmatches,
|
||||
line_pos > 0 ? REG_NOTBOL : 0) == 0) {
|
||||
const char *retval = haystack + regmatches[0].rm_so;
|
||||
|
||||
regexec(&search_regexp, retval, 10, regmatches, 0);
|
||||
|
||||
512
src/winio.c
512
src/winio.c
@@ -2,7 +2,7 @@
|
||||
/**************************************************************************
|
||||
* winio.c *
|
||||
* *
|
||||
* Copyright (C) 1999-2003 Chris Allegretta *
|
||||
* Copyright (C) 1999-2004 Chris Allegretta *
|
||||
* 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 2, or (at your option) *
|
||||
@@ -37,12 +37,12 @@ static int statblank = 0; /* Number of keystrokes left after
|
||||
/* Read in a single input character. If it's ignored, swallow it and go
|
||||
* on. Otherwise, try to translate it from ASCII and extended (keypad)
|
||||
* input. Assume nodelay(win) is FALSE. */
|
||||
int get_kbinput(WINDOW *win, int *meta, int rebind_delete)
|
||||
int get_kbinput(WINDOW *win, int *meta)
|
||||
{
|
||||
int kbinput, retval;
|
||||
|
||||
kbinput = get_ignored_kbinput(win);
|
||||
retval = get_accepted_kbinput(win, kbinput, meta, rebind_delete);
|
||||
retval = get_accepted_kbinput(win, kbinput, meta);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -50,7 +50,8 @@ int get_kbinput(WINDOW *win, int *meta, int rebind_delete)
|
||||
/* Read in a string of input characters (e. g. an escape sequence)
|
||||
* verbatim, and return the length of the string in kbinput_len. Assume
|
||||
* nodelay(win) is FALSE. */
|
||||
char *get_verbatim_kbinput(WINDOW *win, int *kbinput_len)
|
||||
char *get_verbatim_kbinput(WINDOW *win, int *kbinput_len,
|
||||
int allow_ascii)
|
||||
{
|
||||
char *verbatim_kbinput;
|
||||
int kbinput = wgetch(win);
|
||||
@@ -59,7 +60,7 @@ char *get_verbatim_kbinput(WINDOW *win, int *kbinput_len)
|
||||
verbatim_kbinput[0] = kbinput;
|
||||
*kbinput_len = 1;
|
||||
|
||||
if (kbinput >= '0' && kbinput <= '2')
|
||||
if (allow_ascii && kbinput >= '0' && kbinput <= '2')
|
||||
/* Entering a three-digit decimal ASCII code from 000-255 in
|
||||
* verbatim mode will produce the corresponding ASCII
|
||||
* character. */
|
||||
@@ -111,8 +112,7 @@ int get_ignored_kbinput(WINDOW *win)
|
||||
|
||||
/* Translate acceptable ASCII and extended (keypad) input. Set meta to
|
||||
* 1 if we get a Meta sequence. Assume nodelay(win) is FALSE. */
|
||||
int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta,
|
||||
int rebind_delete)
|
||||
int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta)
|
||||
{
|
||||
*meta = 0;
|
||||
|
||||
@@ -143,29 +143,44 @@ int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta,
|
||||
else if (kbinput >= 'a' && kbinput <= '~')
|
||||
kbinput -= 96;
|
||||
break;
|
||||
case 'O':
|
||||
case 'o':
|
||||
/* Terminal breakage, part 1: We shouldn't get an escape
|
||||
* sequence here for terminals that support Delete, but
|
||||
* we do sometimes on FreeBSD. Thank you, Wouter van
|
||||
* Hemel. */
|
||||
case '[':
|
||||
{
|
||||
int old_kbinput = kbinput, escape_seq_len;
|
||||
char *escape_seq;
|
||||
nodelay(win, TRUE);
|
||||
kbinput = wgetch(win);
|
||||
switch (kbinput) {
|
||||
case ERR:
|
||||
kbinput = '[';
|
||||
kbinput = tolower(old_kbinput);
|
||||
*meta = 1;
|
||||
break;
|
||||
default:
|
||||
kbinput = get_escape_seq_kbinput(win, kbinput);
|
||||
ungetch(kbinput);
|
||||
ungetch(old_kbinput);
|
||||
escape_seq = get_verbatim_kbinput(win, &escape_seq_len, 0);
|
||||
kbinput = get_escape_seq_kbinput(win, escape_seq, escape_seq_len);
|
||||
free(escape_seq);
|
||||
}
|
||||
nodelay(win, FALSE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* Esc [character] == Meta-[character] */
|
||||
kbinput = tolower(kbinput);
|
||||
*meta = 1;
|
||||
}
|
||||
break;
|
||||
case NANO_CONTROL_8:
|
||||
/* Terminal breakage, part 2: We shouldn't get Ctrl-8
|
||||
* (Ctrl-?) for Backspace or Delete, but we do sometimes. */
|
||||
kbinput = ISSET(REBIND_DELETE) ? NANO_DELETE_KEY : NANO_BACKSPACE_KEY;
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
kbinput = NANO_DOWN_KEY;
|
||||
break;
|
||||
@@ -185,10 +200,10 @@ int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta,
|
||||
kbinput = NANO_BACKSPACE_KEY;
|
||||
break;
|
||||
case KEY_DC:
|
||||
/* Terminal breakage, part 2: We should only get KEY_DC when
|
||||
/* Terminal breakage, part 3: We should only get KEY_DC when
|
||||
* hitting Delete, but we get it when hitting Backspace
|
||||
* sometimes on FreeBSD. Thank you, Lee Nelson. */
|
||||
kbinput = (rebind_delete) ? NANO_BACKSPACE_KEY : NANO_DELETE_KEY;
|
||||
kbinput = ISSET(REBIND_DELETE) ? NANO_BACKSPACE_KEY : NANO_DELETE_KEY;
|
||||
break;
|
||||
case KEY_IC:
|
||||
kbinput = NANO_INSERTFILE_KEY;
|
||||
@@ -208,6 +223,12 @@ int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta,
|
||||
case KEY_SUSPEND:
|
||||
kbinput = NANO_SUSPEND_KEY;
|
||||
break;
|
||||
case KEY_SLEFT:
|
||||
kbinput = NANO_BACK_KEY;
|
||||
break;
|
||||
case KEY_SRIGHT:
|
||||
kbinput = NANO_FORWARD_KEY;
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_accepted_kbinput(): kbinput = %d, meta = %d\n", kbinput, *meta);
|
||||
@@ -225,7 +246,7 @@ int get_ascii_kbinput(WINDOW *win, int kbinput)
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
retval = (kbinput - 48) * 100;
|
||||
retval = (kbinput - '0') * 100;
|
||||
break;
|
||||
default:
|
||||
return kbinput;
|
||||
@@ -239,14 +260,14 @@ int get_ascii_kbinput(WINDOW *win, int kbinput)
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
retval += (kbinput - 48) * 10;
|
||||
retval += (kbinput - '0') * 10;
|
||||
break;
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (retval < 200) {
|
||||
retval += (kbinput - 48) * 10;
|
||||
retval += (kbinput - '0') * 10;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -261,14 +282,14 @@ int get_ascii_kbinput(WINDOW *win, int kbinput)
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
retval += kbinput - 48;
|
||||
retval += kbinput - '0';
|
||||
break;
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (retval < 250) {
|
||||
retval += kbinput - 48;
|
||||
retval += kbinput - '0';
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -282,35 +303,316 @@ int get_ascii_kbinput(WINDOW *win, int kbinput)
|
||||
}
|
||||
|
||||
/* Translate common escape sequences for some keys. These are generated
|
||||
* when the terminal doesn't support those keys. Assume nodelay(win) is
|
||||
* TRUE. */
|
||||
int get_escape_seq_kbinput(WINDOW *win, int kbinput)
|
||||
* when the terminal doesn't support those keys. Assume that Escape has
|
||||
* already been read in, and that nodelay(win) is TRUE. */
|
||||
int get_escape_seq_kbinput(WINDOW *win, char *escape_seq, int
|
||||
escape_seq_len)
|
||||
{
|
||||
switch (kbinput) {
|
||||
case '3':
|
||||
/* Esc [ 3 ~ == kdch1 on many terminals. */
|
||||
kbinput = get_skip_tilde_kbinput(win, kbinput, NANO_DELETE_KEY);
|
||||
break;
|
||||
int kbinput = -1;
|
||||
|
||||
if (escape_seq_len > 1) {
|
||||
switch (escape_seq[0]) {
|
||||
case 'O':
|
||||
switch (escape_seq[1]) {
|
||||
case 'A': /* Esc O A == Up on xterm. */
|
||||
kbinput = NANO_UP_KEY;
|
||||
break;
|
||||
case 'B': /* Esc O B == Down on xterm. */
|
||||
kbinput = NANO_DOWN_KEY;
|
||||
break;
|
||||
case 'C': /* Esc O C == Right on xterm. */
|
||||
kbinput = NANO_FORWARD_KEY;
|
||||
break;
|
||||
case 'D': /* Esc O D == Left on xterm. */
|
||||
kbinput = NANO_BACK_KEY;
|
||||
break;
|
||||
case 'F': /* Esc O F == End on xterm. */
|
||||
kbinput = NANO_END_KEY;
|
||||
break;
|
||||
case 'H': /* Esc O H == Home on xterm. */
|
||||
kbinput = NANO_HOME_KEY;
|
||||
break;
|
||||
case 'a': /* Esc O a == Ctrl-Up on rxvt. */
|
||||
kbinput = NANO_UP_KEY;
|
||||
break;
|
||||
case 'b': /* Esc O b == Ctrl-Down on rxvt. */
|
||||
kbinput = NANO_DOWN_KEY;
|
||||
break;
|
||||
case 'c': /* Esc O c == Ctrl-Right on rxvt. */
|
||||
kbinput = NANO_FORWARD_KEY;
|
||||
break;
|
||||
case 'd': /* Esc O d == Ctrl-Left on rxvt. */
|
||||
kbinput = NANO_BACK_KEY;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
switch (escape_seq[1]) {
|
||||
case 'a': /* Esc o a == Ctrl-Up on Eterm. */
|
||||
kbinput = NANO_UP_KEY;
|
||||
break;
|
||||
case 'b': /* Esc o b == Ctrl-Down on Eterm. */
|
||||
kbinput = NANO_DOWN_KEY;
|
||||
break;
|
||||
case 'c': /* Esc o c == Ctrl-Right on Eterm. */
|
||||
kbinput = NANO_FORWARD_KEY;
|
||||
break;
|
||||
case 'd': /* Esc o d == Ctrl-Left on Eterm. */
|
||||
kbinput = NANO_BACK_KEY;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '[':
|
||||
switch (escape_seq[1]) {
|
||||
case '1':
|
||||
if (escape_seq_len >= 5) {
|
||||
if (!strncmp(escape_seq, "[1;2", 4)) {
|
||||
switch (escape_seq[4]) {
|
||||
case 'A':
|
||||
/* Esc [ 1 ; 2 A == Shift-Up on
|
||||
* xterm. */
|
||||
kbinput = NANO_UP_KEY;
|
||||
break;
|
||||
case 'B':
|
||||
/* Esc [ 1 ; 2 B == Shift-Down
|
||||
* on xterm. */
|
||||
kbinput = NANO_DOWN_KEY;
|
||||
break;
|
||||
case 'C':
|
||||
/* Esc [ 1 ; 2 C == Shift-Right
|
||||
* on xterm. */
|
||||
kbinput = NANO_FORWARD_KEY;
|
||||
break;
|
||||
case 'D':
|
||||
/* Esc [ 1 ; 2 D == Shift-Left
|
||||
* on xterm. */
|
||||
kbinput = NANO_BACK_KEY;
|
||||
break;
|
||||
}
|
||||
} else if (!strncmp(escape_seq, "[1;5", 4)) {
|
||||
switch (escape_seq[4]) {
|
||||
case 'A':
|
||||
/* Esc [ 1 ; 5 A == Ctrl-Up on
|
||||
* xterm. */
|
||||
kbinput = NANO_UP_KEY;
|
||||
break;
|
||||
case 'B':
|
||||
/* Esc [ 1 ; 5 B == Ctrl-Down on
|
||||
* xterm. */
|
||||
kbinput = NANO_DOWN_KEY;
|
||||
break;
|
||||
case 'C':
|
||||
/* Esc [ 1 ; 5 C == Ctrl-Right
|
||||
* on xterm. */
|
||||
kbinput = NANO_FORWARD_KEY;
|
||||
break;
|
||||
case 'D':
|
||||
/* Esc [ 1 ; 5 D == Ctrl-Left on
|
||||
* xterm. */
|
||||
kbinput = NANO_BACK_KEY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
/* Esc [ 1 ~ == Home on Linux console. */
|
||||
kbinput = NANO_HOME_KEY;
|
||||
break;
|
||||
}
|
||||
case '2': /* Esc [ 2 ~ == Insert on Linux
|
||||
* console/xterm. */
|
||||
kbinput = NANO_INSERTFILE_KEY;
|
||||
break;
|
||||
case '3': /* Esc [ 3 ~ == Delete on Linux
|
||||
* console/xterm. */
|
||||
kbinput = NANO_DELETE_KEY;
|
||||
break;
|
||||
case '4': /* Esc [ 4 ~ == End on Linux
|
||||
* console/xterm. */
|
||||
kbinput = NANO_END_KEY;
|
||||
break;
|
||||
case '5': /* Esc [ 5 ~ == PageUp on Linux
|
||||
* console/xterm, Esc [ 5 ^ == PageUp on
|
||||
* Eterm. */
|
||||
kbinput = NANO_PREVPAGE_KEY;
|
||||
break;
|
||||
case '6': /* Esc [ 6 ~ == PageDown on Linux
|
||||
* console/xterm, Esc [ 6 ^ == PageDown on
|
||||
* Eterm. */
|
||||
kbinput = NANO_NEXTPAGE_KEY;
|
||||
break;
|
||||
case '7': /* Esc [ 7 ~ == Home on rxvt. */
|
||||
kbinput = NANO_HOME_KEY;
|
||||
break;
|
||||
case '8': /* Esc [ 8 ~ == End on rxvt. */
|
||||
kbinput = NANO_END_KEY;
|
||||
break;
|
||||
case '9': /* Esc [ 9 == Delete on Hurd console. */
|
||||
kbinput = NANO_DELETE_KEY;
|
||||
break;
|
||||
case '@': /* Esc [ @ == Insert on Hurd console. */
|
||||
kbinput = NANO_INSERTFILE_KEY;
|
||||
break;
|
||||
case 'A': /* Esc [ A == Up on Linux console/FreeBSD
|
||||
* console/Hurd console/rxvt/Eterm. */
|
||||
kbinput = NANO_UP_KEY;
|
||||
break;
|
||||
case 'B': /* Esc [ B == Down on Linux
|
||||
* console/FreeBSD console/Hurd
|
||||
* console/rxvt/Eterm. */
|
||||
kbinput = NANO_DOWN_KEY;
|
||||
break;
|
||||
case 'C': /* Esc [ C == Right on Linux
|
||||
* console/FreeBSD console/Hurd
|
||||
* console/rxvt/Eterm. */
|
||||
kbinput = NANO_FORWARD_KEY;
|
||||
break;
|
||||
case 'D': /* Esc [ D == Left on Linux
|
||||
* console/FreeBSD console/Hurd
|
||||
* console/rxvt/Eterm. */
|
||||
kbinput = NANO_BACK_KEY;
|
||||
break;
|
||||
case 'F': /* Esc [ F == End on FreeBSD
|
||||
* console/Eterm. */
|
||||
kbinput = NANO_END_KEY;
|
||||
break;
|
||||
case 'G': /* Esc [ G == PageDown on FreeBSD
|
||||
* console. */
|
||||
kbinput = NANO_NEXTPAGE_KEY;
|
||||
break;
|
||||
case 'H': /* Esc [ H == Home on FreeBSD
|
||||
* console/Hurd console/Eterm. */
|
||||
kbinput = NANO_HOME_KEY;
|
||||
break;
|
||||
case 'I': /* Esc [ I == PageUp on FreeBSD
|
||||
* console. */
|
||||
kbinput = NANO_PREVPAGE_KEY;
|
||||
break;
|
||||
case 'L': /* Esc [ L == Insert on FreeBSD
|
||||
* console. */
|
||||
kbinput = NANO_INSERTFILE_KEY;
|
||||
break;
|
||||
case 'U': /* Esc [ U == PageDown on Hurd console. */
|
||||
kbinput = NANO_NEXTPAGE_KEY;
|
||||
break;
|
||||
case 'V': /* Esc [ V == PageUp on Hurd console. */
|
||||
kbinput = NANO_PREVPAGE_KEY;
|
||||
break;
|
||||
case 'Y': /* Esc [ Y == End on Hurd console. */
|
||||
kbinput = NANO_END_KEY;
|
||||
break;
|
||||
case 'a': /* Esc [ a == Shift-Up on rxvt/Eterm. */
|
||||
kbinput = NANO_UP_KEY;
|
||||
break;
|
||||
case 'b': /* Esc [ b == Shift-Down on rxvt/Eterm. */
|
||||
kbinput = NANO_DOWN_KEY;
|
||||
break;
|
||||
case 'c': /* Esc [ c == Shift-Right on
|
||||
* rxvt/Eterm. */
|
||||
kbinput = NANO_FORWARD_KEY;
|
||||
break;
|
||||
case 'd': /* Esc [ d == Shift-Left on rxvt/Eterm. */
|
||||
kbinput = NANO_BACK_KEY;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (kbinput == -1) {
|
||||
/* This escape sequence is unrecognized; send it back. */
|
||||
for (; escape_seq_len > 1; escape_seq_len--)
|
||||
ungetch(escape_seq[escape_seq_len - 1]);
|
||||
kbinput = escape_seq[0];
|
||||
}
|
||||
|
||||
return kbinput;
|
||||
}
|
||||
|
||||
/* If there is no next character, return the passed-in error value. If
|
||||
* the next character's a tilde, eat it and return the passed-in
|
||||
* return value. Otherwise, return the next character. Assume
|
||||
* nodelay(win) is TRUE. */
|
||||
int get_skip_tilde_kbinput(WINDOW *win, int errval, int retval)
|
||||
#ifndef DISABLE_MOUSE
|
||||
/* Check for a mouse event, and if one's taken place, save the
|
||||
* coordinates where it took place in mouse_x and mouse_y. After that,
|
||||
* if allow_shortcuts is zero, return 0. Otherwise, if the mouse event
|
||||
* took place on the shortcut list on the bottom two lines of the screen
|
||||
* (assuming that the shortcut list is visible), figure out which
|
||||
* shortcut was clicked and ungetch() the equivalent keystroke(s).
|
||||
* Return 0 if no keystrokes were ungetch()ed, or 1 if at least one was.
|
||||
* Assume that KEY_MOUSE has already been read in. */
|
||||
int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||
{
|
||||
int kbinput = wgetch(win);
|
||||
switch (kbinput) {
|
||||
case ERR:
|
||||
return errval;
|
||||
case '~':
|
||||
return retval;
|
||||
default:
|
||||
return kbinput;
|
||||
MEVENT mevent;
|
||||
|
||||
*mouse_x = -1;
|
||||
*mouse_y = -1;
|
||||
|
||||
/* First, get the actual mouse event. */
|
||||
if (getmouse(&mevent) == ERR)
|
||||
return 0;
|
||||
|
||||
/* Save the screen coordinates where the mouse event took place. */
|
||||
*mouse_x = mevent.x;
|
||||
*mouse_y = mevent.y;
|
||||
|
||||
/* If we're not allowing shortcuts' we're done now. */
|
||||
if (!allow_shortcuts)
|
||||
return 0;
|
||||
|
||||
/* Otherwise, if the current shortcut list is being displayed on the
|
||||
* last two lines of the screen and the mouse event took place
|
||||
* inside it, we need to figure out which shortcut was clicked and
|
||||
* ungetch() the equivalent keystroke(s) for it. */
|
||||
if (!ISSET(NO_HELP) && wenclose(bottomwin, *mouse_y, *mouse_x)) {
|
||||
int i, j;
|
||||
int currslen;
|
||||
/* The number of shortcuts in the current shortcut list. */
|
||||
const shortcut *s = currshortcut;
|
||||
/* The actual shortcut we clicked on, starting at the first
|
||||
* one in the current shortcut list. */
|
||||
|
||||
/* Get the shortcut lists' length. */
|
||||
if (currshortcut == main_list)
|
||||
currslen = MAIN_VISIBLE;
|
||||
else
|
||||
currslen = length_of_list(currshortcut);
|
||||
|
||||
/* Calculate the width of each shortcut in the list (it's the
|
||||
* same for all of them). */
|
||||
if (currslen < 2)
|
||||
i = COLS / 6;
|
||||
else
|
||||
i = COLS / ((currslen / 2) + (currslen % 2));
|
||||
|
||||
/* Calculate the y-coordinates relative to the beginning of
|
||||
* bottomwin, i.e, the bottom three lines of the screen. */
|
||||
j = *mouse_y - (editwinrows + 3);
|
||||
|
||||
/* If we're on the statusbar, beyond the end of the shortcut
|
||||
* list, or beyond the end of a shortcut on the right side of
|
||||
* the screen, don't do anything. */
|
||||
if (j < 0 || (*mouse_x / i) >= currslen)
|
||||
return 0;
|
||||
j = (*mouse_x / i) * 2 + j;
|
||||
if (j >= currslen)
|
||||
return 0;
|
||||
|
||||
/* Go through the shortcut list to determine which shortcut was
|
||||
* clicked. */
|
||||
for (; j > 0; j--)
|
||||
s = s->next;
|
||||
|
||||
/* And ungetch() the equivalent keystroke. */
|
||||
ungetch(s->val);
|
||||
|
||||
/* If it's not a control character, assume it's a Meta key
|
||||
* sequence, in which case we need to ungetch() Escape too. */
|
||||
if (!is_cntrl_char(s->val))
|
||||
ungetch(NANO_CONTROL_3);
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int do_first_line(void)
|
||||
{
|
||||
@@ -594,13 +896,13 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
input */
|
||||
wrefresh(edit);
|
||||
|
||||
while ((kbinput = get_kbinput(bottomwin, &meta, ISSET(REBIND_DELETE))) != NANO_ENTER_KEY) {
|
||||
while ((kbinput = get_kbinput(bottomwin, &meta)) != NANO_ENTER_KEY) {
|
||||
for (t = s; t != NULL; t = t->next) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Aha! \'%c\' (%d)\n", kbinput, kbinput);
|
||||
#endif
|
||||
|
||||
if (kbinput == t->val && (kbinput < 32 || kbinput == 127)) {
|
||||
if (kbinput == t->val && is_cntrl_char(kbinput)) {
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
/* Have to do this here, it would be too late to do it
|
||||
@@ -610,6 +912,11 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
/* Have to handle these here too, for the time being */
|
||||
if (kbinput == NANO_UP_KEY || kbinput == NANO_DOWN_KEY)
|
||||
break;
|
||||
#endif
|
||||
|
||||
return t->val;
|
||||
}
|
||||
@@ -782,15 +1089,15 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
fprintf(stderr, "Aha! \'%c\' (%d)\n", kbinput,
|
||||
kbinput);
|
||||
#endif
|
||||
if (meta == 1 && (kbinput == t->val || kbinput == t->val - 32))
|
||||
/* We hit an Alt key. Do like above. We don't
|
||||
just ungetch() the letter and let it get
|
||||
caught above cause that screws the
|
||||
keypad... */
|
||||
return t->val;
|
||||
if (meta == 1 && (kbinput == t->metaval || kbinput == t->misc))
|
||||
/* We hit a Meta key. Do like above. We don't
|
||||
* just ungetch() the letter and let it get
|
||||
* caught above cause that screws the
|
||||
* keypad... */
|
||||
return kbinput;
|
||||
}
|
||||
|
||||
if (kbinput < 32 || kbinput == 127)
|
||||
if (is_cntrl_char(kbinput))
|
||||
break;
|
||||
answer = charealloc(answer, xend + 2);
|
||||
charmove(answer + x + 1, answer + x, xend - x + 1);
|
||||
@@ -903,19 +1210,20 @@ void bottombars(const shortcut *s)
|
||||
wmove(bottomwin, 1 + j, i * (COLS / numcols));
|
||||
|
||||
/* Yucky sentinel values we can't handle a better way */
|
||||
if (s->val == NANO_CONTROL_SPACE)
|
||||
strcpy(keystr, "^ ");
|
||||
if (s->val != NANO_NO_KEY) {
|
||||
#ifndef NANO_SMALL
|
||||
else if (s->val == KEY_UP)
|
||||
strncpy(keystr, _("Up"), 8);
|
||||
#endif /* NANO_SMALL */
|
||||
else if (s->val > 0) {
|
||||
if (s->val < 64)
|
||||
sprintf(keystr, "^%c", s->val + 64);
|
||||
if (s->val == NANO_HISTORY_KEY)
|
||||
strncpy(keystr, _("Up"), 8);
|
||||
else
|
||||
sprintf(keystr, "M-%c", s->val - 32);
|
||||
} else if (s->altval > 0)
|
||||
sprintf(keystr, "M-%c", s->altval);
|
||||
#endif
|
||||
if (s->val == NANO_CONTROL_SPACE)
|
||||
strcpy(keystr, "^ ");
|
||||
else if (s->val == NANO_CONTROL_8)
|
||||
strcpy(keystr, "^?");
|
||||
else
|
||||
sprintf(keystr, "^%c", s->val + 64);
|
||||
} else if (s->metaval != NANO_NO_KEY)
|
||||
sprintf(keystr, "M-%c", toupper(s->metaval));
|
||||
|
||||
onekey(keystr, s->desc, COLS / numcols);
|
||||
|
||||
@@ -1542,11 +1850,9 @@ int statusq(int tabs, const shortcut *s, const char *def,
|
||||
/* Ask a simple yes/no question on the statusbar. Returns 1 for Y, 0
|
||||
* for N, 2 for All (if all is nonzero when passed in) and -1 for abort
|
||||
* (^C). */
|
||||
int do_yesno(int all, int leavecursor, const char *msg, ...)
|
||||
int do_yesno(int all, const char *msg)
|
||||
{
|
||||
va_list ap;
|
||||
char *foo;
|
||||
int ok = -2;
|
||||
int ok = -2, width = 16;
|
||||
const char *yesstr; /* String of yes characters accepted */
|
||||
const char *nostr; /* Same for no */
|
||||
const char *allstr; /* And all, surprise! */
|
||||
@@ -1563,70 +1869,75 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
|
||||
if (!ISSET(NO_HELP)) {
|
||||
char shortstr[3]; /* Temp string for Y, N, A. */
|
||||
|
||||
if (COLS < 32)
|
||||
width = COLS / 2;
|
||||
|
||||
/* Write the bottom of the screen. */
|
||||
blank_bottombars();
|
||||
|
||||
sprintf(shortstr, " %c", yesstr[0]);
|
||||
wmove(bottomwin, 1, 0);
|
||||
onekey(shortstr, _("Yes"), 16);
|
||||
onekey(shortstr, _("Yes"), width);
|
||||
|
||||
if (all) {
|
||||
wmove(bottomwin, 1, 16);
|
||||
wmove(bottomwin, 1, width);
|
||||
shortstr[1] = allstr[0];
|
||||
onekey(shortstr, _("All"), 16);
|
||||
onekey(shortstr, _("All"), width);
|
||||
}
|
||||
|
||||
wmove(bottomwin, 2, 0);
|
||||
shortstr[1] = nostr[0];
|
||||
onekey(shortstr, _("No"), 16);
|
||||
onekey(shortstr, _("No"), width);
|
||||
|
||||
wmove(bottomwin, 2, 16);
|
||||
onekey("^C", _("Cancel"), 16);
|
||||
onekey("^C", _("Cancel"), width);
|
||||
}
|
||||
|
||||
foo = charalloc(COLS);
|
||||
va_start(ap, msg);
|
||||
vsnprintf(foo, COLS, msg, ap);
|
||||
va_end(ap);
|
||||
foo[COLS - 1] = '\0';
|
||||
|
||||
wattron(bottomwin, A_REVERSE);
|
||||
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, foo);
|
||||
free(foo);
|
||||
mvwaddnstr(bottomwin, 0, 0, msg, COLS - 1);
|
||||
|
||||
wattroff(bottomwin, A_REVERSE);
|
||||
|
||||
wrefresh(bottomwin);
|
||||
|
||||
do {
|
||||
int kbinput = wgetch(edit);
|
||||
int kbinput;
|
||||
int meta;
|
||||
#ifndef DISABLE_MOUSE
|
||||
MEVENT mevent;
|
||||
int mouse_x, mouse_y;
|
||||
#endif
|
||||
|
||||
if (kbinput == NANO_CONTROL_C)
|
||||
kbinput = get_kbinput(edit, &meta);
|
||||
|
||||
if (kbinput == NANO_CANCEL_KEY)
|
||||
ok = -1;
|
||||
#ifndef DISABLE_MOUSE
|
||||
/* Look ma! We get to duplicate lots of code from do_mouse!! */
|
||||
else if (kbinput == KEY_MOUSE && getmouse(&mevent) != ERR &&
|
||||
wenclose(bottomwin, mevent.y, mevent.x) &&
|
||||
!ISSET(NO_HELP) && mevent.x < 32 &&
|
||||
mevent.y >= editwinrows + 3) {
|
||||
int x = mevent.x /= 16;
|
||||
/* Did we click in the first column of shortcuts, or the
|
||||
* second? */
|
||||
int y = mevent.y - editwinrows - 3;
|
||||
/* Did we click in the first row of shortcuts? */
|
||||
/* Look ma! We get to duplicate lots of code from
|
||||
* do_mouse()!! */
|
||||
else if (kbinput == KEY_MOUSE) {
|
||||
kbinput = get_mouseinput(&mouse_x, &mouse_y, 0);
|
||||
|
||||
assert(0 <= x && x <= 1 && 0 <= y && y <= 1);
|
||||
/* x = 0 means they clicked Yes or No.
|
||||
* y = 0 means Yes or All. */
|
||||
ok = -2 * x * y + x - y + 1;
|
||||
if (mouse_x != -1 && mouse_y != -1 && !ISSET(NO_HELP) &&
|
||||
wenclose(bottomwin, mouse_y, mouse_x) && mouse_x <
|
||||
(width * 2) && mouse_y >= editwinrows + 3) {
|
||||
|
||||
if (ok == 2 && !all)
|
||||
ok = -2;
|
||||
int x = mouse_x / width;
|
||||
/* Did we click in the first column of shortcuts, or
|
||||
* the second? */
|
||||
int y = mouse_y - editwinrows - 3;
|
||||
/* Did we click in the first row of shortcuts? */
|
||||
|
||||
assert(0 <= x && x <= 1 && 0 <= y && y <= 1);
|
||||
|
||||
/* x = 0 means they clicked Yes or No.
|
||||
* y = 0 means Yes or All. */
|
||||
ok = -2 * x * y + x - y + 1;
|
||||
|
||||
if (ok == 2 && !all)
|
||||
ok = -2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* Look for the kbinput in the yes, no and (optionally) all
|
||||
@@ -1639,9 +1950,6 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
|
||||
ok = 2;
|
||||
} while (ok == -2);
|
||||
|
||||
/* Then blank the statusbar. */
|
||||
blank_statusbar_refresh();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -1884,7 +2192,7 @@ int do_help(void)
|
||||
no_more = 1;
|
||||
continue;
|
||||
}
|
||||
} while ((kbinput = get_kbinput(edit, &meta, ISSET(REBIND_DELETE))) != NANO_EXIT_KEY && kbinput != NANO_EXIT_FKEY);
|
||||
} while ((kbinput = get_kbinput(edit, &meta)) != NANO_EXIT_KEY && kbinput != NANO_EXIT_FKEY);
|
||||
|
||||
currshortcut = oldshortcut;
|
||||
|
||||
@@ -1927,7 +2235,13 @@ void do_replace_highlight(int highlight_flag, const char *word)
|
||||
if (highlight_flag)
|
||||
wattron(edit, A_REVERSE);
|
||||
|
||||
waddnstr(edit, word, y - 1);
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* This is so we can show zero-length regexes. */
|
||||
if (word_len == 0)
|
||||
waddstr(edit, " ");
|
||||
else
|
||||
#endif
|
||||
waddnstr(edit, word, y - 1);
|
||||
|
||||
if (word_len > y)
|
||||
waddch(edit, '$');
|
||||
@@ -2033,7 +2347,7 @@ void do_credits(void)
|
||||
"6", /* "and anyone else we forgot..." */
|
||||
"7", /* "Thank you for using nano!\n" */
|
||||
"", "", "", "",
|
||||
"(c) 1999-2003 Chris Allegretta",
|
||||
"(c) 1999-2004 Chris Allegretta",
|
||||
"", "", "", "",
|
||||
"http://www.nano-editor.org/"
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user