Compare commits
113 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1151561ad | ||
|
|
dbde9d7577 | ||
|
|
524534405b | ||
|
|
21ad762998 | ||
|
|
d350727726 | ||
|
|
91bc83a97a | ||
|
|
537a880856 | ||
|
|
85529b37c6 | ||
|
|
973a96be62 | ||
|
|
4e1a98c9c3 | ||
|
|
45eda52d7e | ||
|
|
74af3a7419 | ||
|
|
3b0729cf5d | ||
|
|
2b6c3018b0 | ||
|
|
452513750b | ||
|
|
a9a6ce09d6 | ||
|
|
7ea39efdbd | ||
|
|
d8974451f0 | ||
|
|
e65e639465 | ||
|
|
16eb518dcd | ||
|
|
498e13df30 | ||
|
|
ae064bf255 | ||
|
|
e7638ea75f | ||
|
|
ce1d7652f3 | ||
|
|
0675c2f355 | ||
|
|
18b583d55b | ||
|
|
9a527f5a17 | ||
|
|
684b19380e | ||
|
|
4a80fcff4e | ||
|
|
f521b60f52 | ||
|
|
28260475bb | ||
|
|
c21790d6d9 | ||
|
|
be26561620 | ||
|
|
b6a4b10daf | ||
|
|
8d911991a3 | ||
|
|
89bb93733a | ||
|
|
2c62b07d2b | ||
|
|
483ea32c75 | ||
|
|
c833d9e80f | ||
|
|
12e066f9d4 | ||
|
|
9d325a03d9 | ||
|
|
32e3b88e09 | ||
|
|
dd7cc7230e | ||
|
|
3aedb36e68 | ||
|
|
570ea8969b | ||
|
|
2ed225f78d | ||
|
|
48ae986730 | ||
|
|
d12fd4b1fb | ||
|
|
0aa2264687 | ||
|
|
2f0d03b4a2 | ||
|
|
228148b87a | ||
|
|
c372488179 | ||
|
|
8328fc2439 | ||
|
|
da141063e3 | ||
|
|
0d29555a13 | ||
|
|
c279a63100 | ||
|
|
5a8995a097 | ||
|
|
32613fa3f6 | ||
|
|
2e3aeae5bc | ||
|
|
32d19ce47c | ||
|
|
a9fcaa589a | ||
|
|
1b525e9ad6 | ||
|
|
4be15f0158 | ||
|
|
4178db0328 | ||
|
|
1dcf36a370 | ||
|
|
fa394047ba | ||
|
|
bcebe325f0 | ||
|
|
14bf80399f | ||
|
|
c7acf69cb2 | ||
|
|
684e7ebd37 | ||
|
|
8e4adcdac3 | ||
|
|
e608f94a6f | ||
|
|
fd462b164e | ||
|
|
837a02b256 | ||
|
|
d7fd200a6a | ||
|
|
36e363f525 | ||
|
|
1cadddd111 | ||
|
|
7097d7b6d2 | ||
|
|
1d43db879e | ||
|
|
97133f5963 | ||
|
|
fda18c3935 | ||
|
|
d4693cb0be | ||
|
|
021960dfb7 | ||
|
|
68a44a4905 | ||
|
|
f613ca78c6 | ||
|
|
94e7094cee | ||
|
|
1122c85e34 | ||
|
|
8d3e7f3217 | ||
|
|
9830d7500f | ||
|
|
71d0a1fab3 | ||
|
|
2c4c788477 | ||
|
|
5aa39834aa | ||
|
|
a849ab12ea | ||
|
|
0381c2199d | ||
|
|
4b741b9c7b | ||
|
|
d893fa946d | ||
|
|
e5b2f83031 | ||
|
|
d62b63492a | ||
|
|
b88234049d | ||
|
|
dc35cb8e16 | ||
|
|
0a25808f34 | ||
|
|
805547fed0 | ||
|
|
45108343c8 | ||
|
|
f38230ae6d | ||
|
|
9be546b2f3 | ||
|
|
604caf3d6c | ||
|
|
07d3febe1b | ||
|
|
e1e7cb250e | ||
|
|
edc1ea4c16 | ||
|
|
d7db0a6dbf | ||
|
|
5520e85ee4 | ||
|
|
a3370c4232 | ||
|
|
befb25a4e6 |
479
ChangeLog
479
ChangeLog
@@ -1,3 +1,470 @@
|
||||
GNU nano 1.3.3 - 2004.06.28
|
||||
- General:
|
||||
- Minor comment cleanups. (DLR)
|
||||
- Convert more ints used as boolean values to use TRUE and
|
||||
FALSE. (David Benbennick)
|
||||
- Make sure the special control keys are handled the same way
|
||||
after the window is resized or we come out of suspend mode.
|
||||
Changes to do_cont() and handle_sigwinch(). (DLR)
|
||||
- Change some instances of ints that can never be negative to
|
||||
size_t's. (DLR)
|
||||
- Add better explanations for and in the "Terminal breakage"
|
||||
comments, and handle missing key #ifdefs inside the functions
|
||||
that use those keys. (DLR)
|
||||
- Add restricted mode, accessible via the -Z/--restricted
|
||||
command line option or by invoking nano with any name
|
||||
beginning with 'r' (e.g. "rnano"). In restricted mode, nano
|
||||
will not read or write to any file not specified on the
|
||||
command line, read any nanorc files, allow suspending, or
|
||||
allow a file to be appended to, prepended to, or saved under a
|
||||
different name if it already has one. (IO ERROR) DLR: Also
|
||||
disable backup files and spell checking (since the latter can
|
||||
leave a pre-spell-checked version of the file in a temporary
|
||||
directory), use tail() to get the program name so that the
|
||||
check for its beginning with 'r' will work when a path is
|
||||
specified, disable toggles that are only useful with options
|
||||
that are disabled in restricted mode, call nano_disabled_msg()
|
||||
when trying to read or spell check a file instead of leaving
|
||||
the shortcuts out of the main list, and instead of acting as
|
||||
though TEMP_OPT is enabled when exiting with a modified file
|
||||
(which caused problems if the filename was blank), only allow
|
||||
a filename to be modified at the writeout prompt if it's blank
|
||||
beforehand. Changes to do_writeout(), toggle_init(),
|
||||
shortcut_init(), die_save_file(), and nanogetstr().
|
||||
- Call nano_disabled_msg() directly from the shortcut list
|
||||
instead of inside the disabled functions. (David Benbennick)
|
||||
- Clarifications to comments explaining exactly what control
|
||||
characters and escape sequences are supported. (DLR)
|
||||
- Disable "Where Is Next" in tiny mode. (DLR)
|
||||
- Added the ability to justify the entire file at once, which
|
||||
Pico has via ^W^J. Changes to backup_lines() and
|
||||
do_justify(); new functions do_justify_void() and
|
||||
do_full_justify(). (DLR)
|
||||
- Modify the justification algorithm to work the same way as in
|
||||
the current version of Pico, i.e, add a space at the end of
|
||||
each line of the justified paragraph except for the last one,
|
||||
and if there was a space at the end of the last one, remove
|
||||
it. Changes to justify_format() and do_justify(). Note that
|
||||
we can no longer reliably detect the first modified line in a
|
||||
paragraph, since a line unmodified by justify_format() may get
|
||||
a space tacked onto the end of it or removed from the end of
|
||||
it later. The entire original paragraph is now always backed
|
||||
up, and justify_format() no longer has a non-modifying mode,
|
||||
so it's now only called in backup_lines(). (DLR)
|
||||
- Wrap the long jump code in NANO_SMALL #ifdefs, since we only
|
||||
use it if we're resizing the window, which is disabled when
|
||||
NANO_SMALL is defined. (DLR)
|
||||
- Add smart home key option, accessible via -A/--smarthome on
|
||||
the command line, "set smarthome" in the rcfile, and the
|
||||
Meta-H toggle in the edit window. Smart home works as
|
||||
follows: When Home is pressed anywhere but at the very
|
||||
beginning of non-whitespace characters on a line, the cursor
|
||||
will jump to that beginning (either forwards or backwards).
|
||||
If the cursor is already at that position, it will jump to the
|
||||
true beginning of the line. This option is disabled in tiny
|
||||
mode. Changes to do_home(), nanogetstr(), etc. (DLR;
|
||||
suggested by Stephan T. Lavavej)
|
||||
- Minor tweaks to the punctuation in some statusbar messages.
|
||||
(DLR)
|
||||
- Overhaul the low-level input routines into main routines that
|
||||
actually get the input and state machines that interpret the
|
||||
input. This allows better handling of the input (e.g. ignored
|
||||
keys are now always ignored instead of just being ignored when
|
||||
there are no escapes prefixing them) and will make it easier
|
||||
to port to interfaces that don't have blocking input. New
|
||||
functions reset_kbinput(), get_translated_kbinput(),
|
||||
get_control_kbinput(), and get_untranslated_kbinput(); changes
|
||||
to do_verbatim_input(), handle_sigwinch(), get_kbinput(),
|
||||
get_ascii_kbinput(), get_escape_seq_kbinput(), and
|
||||
get_verbatim_kbinput(); removal of get_ignored_kbinput() and
|
||||
get_accepted_kbinput(). (DLR)
|
||||
- Overhaul all the movement functions in order to avoid
|
||||
redundant screen redraws (and regexec()s when color support is
|
||||
available) whenever possible during ordinary cursor movement
|
||||
when the text doesn't change. Do the same for moving in
|
||||
do_char(), do_delete(), do_next_word(), do_prev_word(),
|
||||
do_search(), do_research(), and do_replace_loop. Changes to
|
||||
do_first_line(), do_last_line(), do_home(), do_end(),
|
||||
do_page_up(), do_page_down(), do_up(), do_down(), do_left(),
|
||||
do_right(), do_delete(), do_backspace(), do_search(),
|
||||
do_research(), do_replace_loop(), do_find_bracket(), and
|
||||
edit_refresh(). New functions do_left_void(),
|
||||
do_right_void(), need_horizontal_update(),
|
||||
need_vertical_update(), edit_scroll(), and edit_redraw(). All
|
||||
of these functions but the first two require the previous
|
||||
versions of current and/or placewewant as parameters, so that
|
||||
they can redraw properly when the location has changed. Also
|
||||
rename the int refresh in do_delete() and do_backspace() to
|
||||
do_refresh so as not to conflict with refresh(). (DLR)
|
||||
- Add some comments better explaining what is disabled in
|
||||
restricted mode and why. (DLR)
|
||||
- Since KEEP_CUTBUFFER is only used in cut.c, make it a static
|
||||
variable in cut.c instead of a flag, and unset it in other
|
||||
files via the new function cutbuffer_reset(). (DLR)
|
||||
- Add the ability to change the characters used to display the
|
||||
beginning characters of tabs and spaces via the rcfile entry
|
||||
"whitespace". This is disabled if nanorc support is disabled
|
||||
or if we're in tiny mode. Displaying the new characters is
|
||||
toggled on and off by Meta-P; the default is on. (Mike
|
||||
Frysinger; minor changes and adaptations by DLR)
|
||||
- Add the ability to change the closing punctuation and closing
|
||||
brackets used to control justification, via the rcfile
|
||||
entries "punct" and "brackets". (DLR)
|
||||
- Translation updates (see po/ChangeLog for details).
|
||||
- Make the former flag same_line_wrap use TRUE and FALSE
|
||||
instead of 1 and 0. (DLR)
|
||||
- files.c:
|
||||
add_open_file()
|
||||
- Rearrange the NANO_SMALL #ifdef so that the code to set the
|
||||
MODIFIED flag in open_files->flags is included only once.
|
||||
(DLR)
|
||||
write_marked()
|
||||
- Call write_file() with nonamechange set to TRUE so that we
|
||||
don't erroneously change the current filename when writing a
|
||||
selection, and don't take a nonamechange parameter anymore
|
||||
since we don't use it. (DLR)
|
||||
do_writeout()
|
||||
- Refactor so that no recursion is needed if we try to exit with
|
||||
a modified file that has no name when TEMP_OPT is set. (DLR)
|
||||
- Add spaces to the ends of the "Overwrite" and "Different Name"
|
||||
prompts, for consistency. (DLR)
|
||||
do_browser()
|
||||
- Call check_statblank() instead of blanking the statusbar
|
||||
unconditionally, for consistency. (David Benbennick)
|
||||
- global.c:
|
||||
shortcut_init()
|
||||
- Don't assign any handler functions to the help browser keys,
|
||||
as the help browser handles them all internally. (David
|
||||
Benbennick)
|
||||
- move.c:
|
||||
do_first_line(), do_last_line()
|
||||
- Move these functions here from winio.c. (DLR)
|
||||
- nano.c:
|
||||
finish()
|
||||
- Call blank_statusbar() and blank_bottombars() to blank out
|
||||
the statusbar and shortcut list in bottomwin. (DLR)
|
||||
- Since all of the calls to finish() use 0 for the value of
|
||||
sigage, and the return value of finish() is never used, make
|
||||
it accept and return void. (David Benbennick)
|
||||
die_save_file()
|
||||
- Call write_file() with nonamechange set to TRUE since we don't
|
||||
need to change the current filename if we're writing emergency
|
||||
backup files. (DLR)
|
||||
do_early_abort()
|
||||
- Removed, as it's no longer called anywhere. (David Benbennick)
|
||||
usage()
|
||||
- Add missing "[dir]" and two missing _()'s around the strings
|
||||
describing the -E [dir]/--backupdir=[dir]" option. (CHAO
|
||||
Wei-Lun)
|
||||
open_pipe()
|
||||
- Call enable_signals() at the beginning and disable_signals()
|
||||
at the end, so that we get a SIGINT when Ctrl-C is pressed
|
||||
during wait() and can then call cancel_fork() properly. (DLR)
|
||||
do_delete(), do_enter()
|
||||
- Tweak for efficiency. (David Benbennick)
|
||||
do_prev_word()
|
||||
- Switch the last test (current != NULL or not) around to match
|
||||
the order of the same test in do_next_word() (current ==
|
||||
NULL). The results are the same either way. (DLR)
|
||||
do_wrap()
|
||||
- Tweak for efficiency. (David Benbennick)
|
||||
do_spell()
|
||||
- Tweak for efficiency. (David Benbennick)
|
||||
- Change the statusbar entries used in cases of failure so that
|
||||
they all display the actual error that occurred. (David
|
||||
Benbennick and DLR)
|
||||
do_int_speller(), do_alt_speller()
|
||||
- Make these functions return const char*'s instead of char*'s.
|
||||
(David Benbennick)
|
||||
justify_format()
|
||||
- Remove redundant assignment. (DLR)
|
||||
do_para_search()
|
||||
- Remove unneeded edit_update() calls. (David Benbennick)
|
||||
- Convert to use an enum to specify the search type: JUSTIFY,
|
||||
BEGIN, or END. (DLR)
|
||||
- Refactor to properly do searches for beginnings of paragraphs
|
||||
in the same way as searches for endings of paragraphs, without
|
||||
needing the old (and somewhat inaccurate) recursive approach.
|
||||
(DLR)
|
||||
do_justify()
|
||||
- Remove unneeded edit_update() calls, and add a few minor
|
||||
efficiency tweaks. (David Benbennick)
|
||||
- Simplify an if statement. (DLR)
|
||||
do_exit()
|
||||
- Refactor so that no recursion is needed if we try to exit with
|
||||
a modified file that has no name when TEMP_OPT is set. (DLR)
|
||||
print_numlock_warning()
|
||||
- Removed, as it's no longer needed and was never called
|
||||
anywhere after the input overhaul. (DLR)
|
||||
signal_init()
|
||||
- Don't use termios and _POSIX_VDISABLE to disable keys anymore,
|
||||
as there's no real equivalent of it when the latter isn't
|
||||
defined. (DLR)
|
||||
handle_sigwinch()
|
||||
- Call resetty() to get the original terminal settings back.
|
||||
(DLR)
|
||||
- Rework so that nano properly redraws the screen on systems
|
||||
that don't have resizeterm() and/or wresize(). In curses, we
|
||||
now leave and immediately reenter curses mode via endwin() and
|
||||
refresh(), and then reinitialize all windows via
|
||||
window_init(). In slang, the above routine will only work if
|
||||
the resize made the window smaller, so we now leave and
|
||||
immediately reenter screen management mode via
|
||||
SLsmg_reset_smg() and SLsmg_init_smg(), and then reinitialize
|
||||
all windows via window_init(). (DLR, adapted from code in
|
||||
Minimum Profit 3.3.0 and mutt 1.4.2.1, respectively)
|
||||
do_toggle()
|
||||
- Call blank_statusbar() and blank_bottombars() to blank out
|
||||
the statusbar and shortcut list in bottomwin. (DLR)
|
||||
do_verbatim_input()
|
||||
- If PRESERVE is set, disable flow control characters before
|
||||
getting input and reenable them after getting input. (DLR)
|
||||
disable_signals(), enable_signals(), disable_flow_control(),
|
||||
enable_flow_control()
|
||||
- New functions that allow more fine-grained control of the
|
||||
terminal: disabling and enabling signals without having to use
|
||||
_POSIX_VDISABLE and disabling and enabling flow control
|
||||
characters. (DLR)
|
||||
main()
|
||||
- Don't open the first file in quiet mode, since if we do, an
|
||||
error message won't be shown if it's unreadable. (DLR; found
|
||||
by Jaap Eldering)
|
||||
- If we've specified multiple files on the command line and
|
||||
multibuffer support is compiled in, turn multibuffer mode on
|
||||
when reading those files and turn it off afterward if it was
|
||||
off before. This allows us to open multiple files without
|
||||
having to turn multibuffer mode on at the command line or in
|
||||
the nanorc first, both of which are unintuitive. Multibuffer
|
||||
mode should only affect how the "Read File" command behaves
|
||||
anyway. (DLR)
|
||||
- Remove the disabling of implementation-defined input
|
||||
processing, as cbreak mode appears to turn it off anyway.
|
||||
(DLR)
|
||||
- After noecho(), call disable_signals() and
|
||||
disable_flow_control(), the latter only if PRESERVE is not
|
||||
set. (DLR)
|
||||
- Move the savetty() call down from just after initscr() to just
|
||||
after the terminal is properly set up, so that we can restore
|
||||
it easily after a resize. (DLR)
|
||||
- Add missing cast to char when calling do_char(). (DLR)
|
||||
- Don't initialize the backup directory if we're in restricted
|
||||
mode, since backups are disabled then. (DLR)
|
||||
- Check $SPELL for an alternative spell checker if we didn't get
|
||||
one from the command line and/or rcfile, as Pico does. Don't
|
||||
do this if we're in restricted mode, since spell checking is
|
||||
disabled then. (DLR)
|
||||
- Add some cleanups for greater readability, and remove a few
|
||||
bits of redundant code. (DLR and David Benbennick)
|
||||
- nano.h:
|
||||
- Since REGEXP_COMPILED is only used in search.c, convert it
|
||||
from a flag to a static int there. (DLR)
|
||||
- Add justbegend enum, used in do_para_search(). (DLR)
|
||||
- Add updown enum, used in edit_scroll(). (DLR)
|
||||
- proto.h:
|
||||
- Remove unused xpt() and add_marked_sameline() prototypes.
|
||||
(DLR)
|
||||
- Add missing #ifdefs around the nstristr() and get_mouseinput()
|
||||
prototypes. (DLR)
|
||||
- rcfile.c:
|
||||
- Move "rebinddelete" up in the list of options so that the list
|
||||
is in alphabetical order. (DLR)
|
||||
- Cosmetic reorganization of the order in which some options are
|
||||
interpreted. (DLR)
|
||||
- Explicitly check for rcopts[i].name's being "tabsize" to avoid
|
||||
a spurious error under some circumstances about tabsize's
|
||||
being 0 when there's no tabsize entry in the rcfile. (DLR)
|
||||
- search.c:
|
||||
regexp_init()
|
||||
- Overhaul for efficiency. Also check if regcomp() failed, and
|
||||
if so, display "Bad regex" message on the statusbar, so that
|
||||
we don't have to display it separately after every call to
|
||||
this function. (David Benbennick)
|
||||
search_init()
|
||||
- Only check whether USE_REGEXP is set, and hence whether or not
|
||||
to display "[Regexp]" on the search prompt, if HAVE_REGEX_H is
|
||||
defined. (DLR)
|
||||
not_found_msg()
|
||||
- Convert to properly handle strings generated by
|
||||
display_string() that have been used in the search prompt
|
||||
since 1.3.0. (David Benbennick)
|
||||
- Use display_string() directly to display the text that we
|
||||
didn't find instead of relying on statusbar() to do it
|
||||
indirectly, since the latter won't display its text with the
|
||||
user-specified whitespace characters and the former will.
|
||||
(DLR)
|
||||
- utils.c:
|
||||
is_blank_char()
|
||||
- New function used as an isblank() equivalent, since isblank()
|
||||
is a GNU extension. (DLR)
|
||||
nstricmp(), nstrnicmp()
|
||||
- Add extra blank lines for greater readability, and remove
|
||||
unneeded test for n's being less than zero (since it's already
|
||||
been tested for being greater than zero or equal to zero at
|
||||
that point) from nstrnicmp(). (DLR)
|
||||
stristr()
|
||||
- Rename to nstristr() to avoid a potential conflict with an
|
||||
existing stristr() function, and move up to just after
|
||||
nstrnicmp(). (DLR) David Benbennick: Tweak for efficiency.
|
||||
- Include and use only when strcasestr() is unavailable, since
|
||||
strcasestr() is a GNU extension. (DLR)
|
||||
nstrnlen()
|
||||
- New function used as a strnlen() equivalent, since strnlen()
|
||||
is a GNU extension. (DLR)
|
||||
- winio.c:
|
||||
get_verbatim_kbinput()
|
||||
- Refactor the output in the DEBUG #ifdef. It didn't work
|
||||
properly ever since this function was changed to use an int*
|
||||
instead of a char*. (DLR)
|
||||
- When reading characters from input, properly reallocate
|
||||
verbatim_kbinput via (int*)nrealloc() instead of an uncast
|
||||
realloc(). (DLR)
|
||||
get_accepted_kbinput()
|
||||
- Add proper support for the keypad values and escape sequences
|
||||
generated by the NumLock glitch and by certain keys on the
|
||||
numeric keypad. (DLR)
|
||||
- Add an extra break and move an #endif down to fix a potential
|
||||
problem when NANO_SMALL is defined or KEY_RESIZE isn't, and
|
||||
when PDCURSES isn't defined. (DLR)
|
||||
get_escape_seq_kbinput()
|
||||
- Add proper support for the keypad values and escape sequences
|
||||
generated by the NumLock glitch. (DLR)
|
||||
- Add ignore_seq parameter. If a sequence is recognized but
|
||||
ignored, we will now return ERR and set ignore_seq to TRUE, and
|
||||
if a sequence is unrecognized, we will now return ERR and set
|
||||
ignore_seq to FALSE. Also, here and elsewhere, don't bother
|
||||
assigning ERR to retval when that's its initial value. (DLR)
|
||||
- Fix problem where the escape sequence for F3 on the FreeBSD
|
||||
console would not be interpreted properly. (DLR)
|
||||
get_mouseinput()
|
||||
- Don't ungetch() anything if there's no control key and no meta
|
||||
key defined in the shortcut we clicked. (DLR)
|
||||
bottombars()
|
||||
- Don't display any more than MAIN_VISIBLE shortcuts. Adding
|
||||
justification of the entire file above made the search
|
||||
shortcut list longer than this and hence made the shortcuts in
|
||||
it so short as to be almost incomprehensible. (DLR)
|
||||
- Tweak for efficiency and to better handle shorter screen
|
||||
widths. (David Benbennick)
|
||||
- Restructure the if block used for the sentinel key values,
|
||||
dynamically allocate keystr based on the number of columns
|
||||
available, and make sure we can display shortcuts even when
|
||||
the number of available columns is too short for any complete
|
||||
one. (DLR)
|
||||
onekey()
|
||||
- Don't bother padding the displayed shortcuts with spaces.
|
||||
(David Benbennick)
|
||||
- Convert len to a size_t. (DLR)
|
||||
edit_add()
|
||||
- Minor cosmetic reformatting. Also remove unused int
|
||||
searched_later_lines. (DLR)
|
||||
blank_bottomwin()
|
||||
- Removed, as it does the same thing as blank_bottombars().
|
||||
(David Benbennick)
|
||||
blank_titlebar()
|
||||
- New function used to blank the titlebar in topwin. (DLR)
|
||||
blank_statusbar_refresh()
|
||||
- Removed, as it's now unnecessary. (David Benbennick)
|
||||
titlebar()
|
||||
- Overhaul to use display_string() to display the filename, and
|
||||
to better handle shorter screen widths. Also remove
|
||||
now-unneeded wrefresh(topwin) calls. (David Benbennick)
|
||||
DLR: Tweak to reserve enough space for "Modified", plus
|
||||
padding, in all cases, to make sure that the version message
|
||||
takes up no more more than 1/3 of the available width, minus
|
||||
padding, and to include a reset_cursor() call so that the
|
||||
cursor is always in the right place.
|
||||
bottombars()
|
||||
- Call blank_bottombars() instead of blank_bottomwin(). (David
|
||||
Benbennick)
|
||||
check_statblank()
|
||||
- Overhaul for efficiency, (David Benbennick) DLR: Add
|
||||
reset_cursor() call to ensure that the cursor is always in the
|
||||
right place.
|
||||
update_cursor()
|
||||
- Removed, as it's no longer called anywhere. (David Benbennick)
|
||||
edit_refresh()
|
||||
- Remove apparently unneeded leaveok() calls. (David Benbennick)
|
||||
edit_refresh_clearok(), center_cursor()
|
||||
- Removed, as they are now unnecessary. (David Benbennick)
|
||||
statusq()
|
||||
- Don't allow "Full Justify" when in view mode. (DLR)
|
||||
statusbar()
|
||||
- Call reset_cursor() just before refreshing the edit window, so
|
||||
that slang and other non-ncurses versions of curses will
|
||||
properly place the cursor back in the edit window instead of
|
||||
leaving it at the end of the statusbar. (DLR)
|
||||
do_help()
|
||||
- Overhaul for efficiency, and allow scrolling through the help
|
||||
via the arrow keys as well as the paging keys. (David
|
||||
Benbennick) DLR: Revert the use of the return value of
|
||||
curs_set() to restore the previous state of the cursor, as
|
||||
some curses implementations (including slang) get it wrong,
|
||||
and explicitly turn the cursor off where needed instead.
|
||||
do_credits()
|
||||
- Use napms() instead of nanosleep(), as it does the same thing
|
||||
(aside from taking an argument in milliseconds instead of
|
||||
microseconds) and curses includes it. (DLR)
|
||||
- Overhaul for efficiency, and make sure the xlcredits
|
||||
translations are done after initialization in order to avoid
|
||||
an error when compiling with -pedantic. (David Benbennick)
|
||||
do_yesno()
|
||||
- Add a comment to encourage translators to use both native and
|
||||
English shortcuts, if possible. (Jordi)
|
||||
- configure.ac:
|
||||
- Add tests for isblank(), strcasestr(), and strnlen(), and
|
||||
define _GNU_SOURCE so that the tests work properly. Increase
|
||||
the minimum required autoconf version to 2.54. (DLR)
|
||||
- Reformat the test programs so that they aren't packed into
|
||||
fewer lines than usual, so as to make them easier to read, and
|
||||
remove unnecessary inclusion of stdio.h in the slang test
|
||||
programs. (DLR)
|
||||
- Remove the checks for resizeterm() and wresize(), as they're
|
||||
no longer needed. (DLR)
|
||||
- config.rpath:
|
||||
- Replace usage of egrep with grep -E, avoiding a XSI:ism (David
|
||||
Weinehall)
|
||||
|
||||
- faq.html:
|
||||
- Removed question about the NumLock glitch, as it's no longer
|
||||
needed. (DLR)
|
||||
- nano.1:
|
||||
- Document restricted mode. (IO ERROR) DLR: Add minor
|
||||
modifications to account for the above changes.
|
||||
- Document the smart home key option. (DLR)
|
||||
- Document the use of the SPELL environment variable. (DLR)
|
||||
- nanorc.5:
|
||||
- Document the smart home key option. (DLR)
|
||||
- Document the whitespace option. (DLR, adapted from
|
||||
documentation by Mike Frysinger)
|
||||
- Document the punct and brackets options. (DLR)
|
||||
- nano.texi:
|
||||
- Fix toggle inaccuracies: Meta-L now toggles line wrapping, and
|
||||
Meta-< and Meta-> aren't toggles. (DLR)
|
||||
- Document restricted mode. (IO ERROR) DLR: Add minor
|
||||
modifications to account for the above changes.
|
||||
- Fix version number inaccuracies: Search/replace history and
|
||||
sorting/uniqueness filtering for the internal spell chacker
|
||||
were added in nano 1.1.99pre1. (DLR)
|
||||
- Document the smart home key option. (DLR)
|
||||
- Document the use of the SPELL environment variable. (DLR)
|
||||
- nanorc.sample:
|
||||
- Add missing mouse entry, and update the nanorc sample regexes
|
||||
to account for the backupdir and mouse options. (DLR)
|
||||
- Add smarthome description. (DLR)
|
||||
- Document the whitespace option. (DLR, adapted from
|
||||
documentation by Mike Frysinger)
|
||||
- README.CVS:
|
||||
- Increase the minimum required autoconf version to 2.54, and
|
||||
change the recommended automake version 1.7 to the minimum
|
||||
required automake version. Note that autoconf 2.54 will
|
||||
technically also work with automake 1.6c, but that is a CVS
|
||||
version as opposed to a stable release version, and automake
|
||||
1.7 requires at least autoconf 2.54 in any case. (DLR)
|
||||
- TODO:
|
||||
- Added entry for justifying the entire file at once, since Pico
|
||||
can do it, and with "[DONE]" since it's already been
|
||||
implemented. (DLR)
|
||||
|
||||
GNU nano 1.3.2 - 2004.03.31
|
||||
- General:
|
||||
- Change instances in the code that refresh the entire edit
|
||||
@@ -37,7 +504,7 @@ GNU nano 1.3.2 - 2004.03.31
|
||||
the value of def; if the realloc() of answer leads to its
|
||||
pointing to a different memory block, there will be a segfault
|
||||
when the value of def is copied into it via strcpy().
|
||||
(bort@alltel.net, Christian Weisgarber, David Benbennick, and
|
||||
(bort@alltel.net, Christian Weisgerber, David Benbennick, and
|
||||
DLR)
|
||||
- Remove the last editbot references, to avoid any potential
|
||||
segfaults related to them. Also remove fix_editbot(), as it's
|
||||
@@ -174,9 +641,9 @@ GNU nano 1.3.2 - 2004.03.31
|
||||
- Fix segfault when doing a regex replace of a string that
|
||||
matches inside a line (e.g. replace the "b" in "abc" with
|
||||
anything). (David Benbennick)
|
||||
- If the mark is on at the beginning of the functio, turn it off
|
||||
and turn it back on just before returning. Also overhaul to
|
||||
rely on the return value of findnextstr() instead of a loop
|
||||
- If the mark is on at the beginning of the function, turn it
|
||||
off and turn it back on just before returning. Also overhaul
|
||||
to rely on the return value of findnextstr() instead of a loop
|
||||
invariant, to not need to take an int* parameter, and store
|
||||
the beginning x-coordinate in a size_t instead of an int.
|
||||
(David Benbennick)
|
||||
@@ -469,8 +936,8 @@ GNU nano 1.3.0 - 2003.10.22
|
||||
function do_research(). (Wouter van Hemel)
|
||||
- Added the ability to move to the beginning or end of the
|
||||
paragraph, which Pico has via ^W^W (previous paragraph)
|
||||
and ^W^O (next paragraph). Modifications to do_justify(),
|
||||
new functions do_para_operation(), do_para_begin(), and
|
||||
and ^W^O (next paragraph). Changes to do_justify(); new
|
||||
functions do_para_operation(), do_para_begin(), and
|
||||
do_para_end(). Note that the last three functions are
|
||||
disabled if justification is disabled. (DLR)
|
||||
- Make sure the "historylog" option isn't included at all if
|
||||
|
||||
22
NEWS
22
NEWS
@@ -1,3 +1,25 @@
|
||||
2004.06.28 - GNU nano 1.3.3 marches forth. There are several new
|
||||
features in this release, including a restricted mode
|
||||
that provides better security than just setting an
|
||||
operating directory, the ability to justify the entire
|
||||
file at once, support for a "smart" home key that can
|
||||
leap from the beginning of text on a line to the true
|
||||
beginning of the line (or the reverse) in one stroke,
|
||||
support for specifying an alternative spell checker in
|
||||
$SPELL, the ability to specify the characters used to
|
||||
display spaces and tabs so that they can easily be told
|
||||
apart, and the ability to specify the characters marking
|
||||
the ends of sentences as used in justification. There
|
||||
are also several bug fixes; among other things,
|
||||
justification now keeps spaces at the ends of all but
|
||||
the last line of a paragraph as Pico does, saving a
|
||||
marked selection no longer changes the current filename
|
||||
to the filename the selection was saved under, resizing
|
||||
now works better and no longer corrupts the screen under
|
||||
slang, and the movement functions now avoid doing
|
||||
unnecessary redraws and hence work faster. In short,
|
||||
there are a lot of new things to play with. Enjoy.
|
||||
|
||||
2004.03.31 - GNU nano 1.3.2 is prepared for the void. New features in
|
||||
this release include the ability to spell-check only
|
||||
marked text and the ability to save all backup files in
|
||||
|
||||
@@ -7,8 +7,8 @@ more care than the official stable and unstable tarballs.
|
||||
To successfully compile GNU nano from CVS, you'll need the
|
||||
following packages:
|
||||
|
||||
- autoconf (version >= 2.52)
|
||||
- automake (version >= 1.6, 1.7.x recommended)
|
||||
- autoconf (version >= 2.54)
|
||||
- automake (version >= 1.7)
|
||||
- gettext (version >= 0.11.5)
|
||||
- texinfo
|
||||
- cvs
|
||||
|
||||
1
THANKS
1
THANKS
@@ -4,6 +4,7 @@ If we missed you here, let us know!
|
||||
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com>
|
||||
Malay translator
|
||||
Laurentiu Buzdugan <buzdugan@voyager.net> Romanian translator
|
||||
CHAO Wei-Lun <chaoweilun@pcmail.com.tw> Traditional Chinese translator
|
||||
Ricardo Cárdenes Medina <ricardo@conisys.com> Spanish translator
|
||||
Marco Colombo <magicdice@inwind.it> Italian translator
|
||||
Karl Eichwalder <keichwa@gmx.net> German translator
|
||||
|
||||
1
TODO
1
TODO
@@ -4,6 +4,7 @@ TODO file (? means the feature may be implemented, but not definitely)
|
||||
For version 1.4:
|
||||
- UTF-8 support.
|
||||
- Support for paragraph searches. [DONE]
|
||||
- Support for justifying the entire file at once. [DONE]
|
||||
- Support for filename searches in the file browser.
|
||||
- Undo/Redo key?
|
||||
- Rebindable keys?
|
||||
|
||||
@@ -125,7 +125,7 @@ if test "$with_gnu_ld" = yes; then
|
||||
ld_shlibs=no
|
||||
;;
|
||||
beos*)
|
||||
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
|
||||
if $LD --help 2>&1 | grep -E ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
@@ -137,9 +137,9 @@ if test "$with_gnu_ld" = yes; then
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
;;
|
||||
solaris* | sysv5*)
|
||||
if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
|
||||
if $LD -v 2>&1 | grep -E 'BFD 2\.8' > /dev/null; then
|
||||
ld_shlibs=no
|
||||
elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
|
||||
elif $LD --help 2>&1 | grep -E ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
@@ -149,7 +149,7 @@ if test "$with_gnu_ld" = yes; then
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
*)
|
||||
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
|
||||
if $LD --help 2>&1 | grep -E ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
|
||||
43
configure.ac
43
configure.ac
@@ -19,14 +19,15 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [1.3.2], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [1.3.3], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AM_INIT_AUTOMAKE
|
||||
AM_CONFIG_HEADER([config.h:config.h.in])
|
||||
|
||||
AC_PREREQ(2.52)
|
||||
AC_PREREQ(2.54)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_GNU_SOURCE
|
||||
AC_PROG_CC
|
||||
AC_ISC_POSIX
|
||||
AC_SYS_LARGEFILE
|
||||
@@ -43,7 +44,16 @@ AC_CHECK_HEADER(regex.h,
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
int main(void) { regex_t reg; size_t n = 1; regmatch_t r; regcomp(®, "\\<", 0); regexec(®, "", n, &r, 0); regfree(®); return 0; }],
|
||||
int main(void)
|
||||
{
|
||||
regex_t reg;
|
||||
size_t n = 1;
|
||||
regmatch_t r;
|
||||
regcomp(®, "\\<", 0);
|
||||
regexec(®, "", n, &r, 0);
|
||||
regfree(®);
|
||||
return 0;
|
||||
}],
|
||||
AC_MSG_RESULT(no),
|
||||
AC_MSG_RESULT(yes); AC_DEFINE(BROKEN_REGEXEC, 1, [Define this if your regexec() function segfaults when passed an empty string under certain conditions.])
|
||||
)
|
||||
@@ -199,9 +209,12 @@ AC_ARG_WITH(slang,
|
||||
_libs=$LIBS
|
||||
LIBS="$LIBS -lslang"
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <slcurses.h>
|
||||
int main(void) { SLtt_initialize(NULL); return 0; }],
|
||||
int main(void)
|
||||
{
|
||||
SLtt_initialize(NULL);
|
||||
return 0;
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
|
||||
slang_support=yes
|
||||
@@ -221,9 +234,12 @@ int main(void) { SLtt_initialize(NULL); return 0; }],
|
||||
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
|
||||
LIBS="$LIBS $tcap"
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <slcurses.h>
|
||||
int main(void) { SLtt_initialize(NULL); return 0; }],
|
||||
int main(void)
|
||||
{
|
||||
SLtt_initialize(NULL);
|
||||
return 0;
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
|
||||
slang_support=yes
|
||||
@@ -238,9 +254,12 @@ int main(void) { SLtt_initialize(NULL); return 0; }],
|
||||
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
|
||||
LIBS="$LIBS -lm"
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <slcurses.h>
|
||||
int main(void) { SLtt_initialize(NULL); return 0; }],
|
||||
int main(void)
|
||||
{
|
||||
SLtt_initialize(NULL);
|
||||
return 0;
|
||||
}],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG, 1, [Define to use the slang wrappers for curses instead of native curses.])
|
||||
slang_support=yes
|
||||
@@ -270,7 +289,7 @@ AC_MSG_WARN([*** Can not use slang when cross-compiling])),
|
||||
esac], [AC_MSG_RESULT(no)])
|
||||
|
||||
dnl Checks for functions
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf strcasecmp strncasecmp)
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf isblank strcasecmp strncasecmp strcasestr strnlen)
|
||||
if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
|
||||
then
|
||||
AM_PATH_GLIB_2_0(2.0.0,,
|
||||
@@ -326,10 +345,6 @@ fi
|
||||
|
||||
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], use_default_colors, AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors command.]))
|
||||
if test x$slang_support != xyes; then
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], wresize, AC_DEFINE(HAVE_WRESIZE, 1, [Define this if you have the wresize function in your ncurses-type library.]))
|
||||
AC_CHECK_LIB([$CURSES_LIB_NAME], resizeterm, AC_DEFINE(HAVE_RESIZETERM, 1, [Define this if you have the resizeterm function in your ncurses-type library.]))
|
||||
fi
|
||||
|
||||
dnl Parse any configure options
|
||||
|
||||
|
||||
15
doc/faq.html
15
doc/faq.html
@@ -38,9 +38,8 @@
|
||||
<a href="#4.4">4.4. [version 1.1.12 and earlier] Why does nano show ^\ in the shortcut list instead of ^J?</a><br>
|
||||
<a href="#4.5a">4.5a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!</a><br>
|
||||
<a href="#4.5b">4.5b. [version 1.2.2 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?</a><br>
|
||||
<a href="#4.6">4.6. I get the message "NumLock glitch detected. Keypad will malfunction with NumLock off." What gives?</a><br>
|
||||
<a href="#4.7">4.7. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||
<a href="#4.8">4.8. I've compiled nano with color support, but I don't see any color when I run it!</a></p></blockquote>
|
||||
<a href="#4.6">4.6. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
|
||||
<a href="#4.7">4.7. I've compiled nano with color support, but I don't see any color when I run it!</a></p></blockquote>
|
||||
<h2><a href="#5">5. Internationalization</a></h2>
|
||||
<blockquote><p><a href="#5.1">5.1. There's no translation for my language!</a><br>
|
||||
<a href="#5.2">5.2. I don't like the translation for <x> in my language. How can I fix it?</a></p></blockquote>
|
||||
@@ -79,7 +78,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.2. 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.3. 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%">
|
||||
@@ -183,10 +182,7 @@
|
||||
<blockquote><p>In nano version 0.9.20, the default is to have a completely consistent user interface across all user input functions. This means that regardless of whether you're being asked for a filename to insert or write, or a string to search for, the previous value is already inserted before the cursor. If you prefer the old behavior, use the Pico emulation mode (-p or --pico) or just hit Meta-P while in nano (see the ^G help text for more details).</p></blockquote>
|
||||
<h2><a name="4.5b"></a>4.5b. [version 1.2.2 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?</h2>
|
||||
<blockquote><p>It was decided that consistency was nice, but people are used to Pico's inconsistent behavior. Also, in version 1.1.99pre1, search and replace history was introduced. If you wish to edit your previous search/replace entry (or any previous entry), you can do so by hitting the up arrow to cycle through your history. This method allows the best of both worlds: You don't need to erase the previous string if you want to enter a new one, but you can with one keystroke recall previous entries for editing. Therefore there is now no "Pico mode", nano is and has always been a Pico <b>clone</b>, and clones by default should be compatible.</p></blockquote>
|
||||
<h2><a name="4.6"></a>4.6. I get the message "NumLock glitch detected. Keypad will malfunction with NumLock off." What gives?</h2>
|
||||
<blockquote><p>Nano (and actually almost all console editors) has issues when cycling the NumLock key in certain X terminals (rxvt, aterm, wterm, etc...). When you switch NumLock from on to off, you put the terminal into an "application mode" that changes what sequences are sent by the keypad. These sequences vary sufficiently from terminal to terminal that it is nearly impossible to work around them from within nano.</p>
|
||||
<p>In a nutshell, if you want to be able to use the keypad with the arrow and page up/down functionality, you have to exit nano and reset your terminal (presumably with "reset" or "stty sane" or similar) and then run nano again with NumLock off. If you know an easier way to restore "normal mode", please mail <a href="mailto:nano@nano-editor.org">nano@nano-editor.org</a>.</p></blockquote>
|
||||
<h2><a name="4.7"></a>4.7. How do I make nano my default editor (in Pine, mutt, etc.)?</h2>
|
||||
<h2><a name="4.6"></a>4.6. How do I make nano my default editor (in Pine, mutt, etc.)?</h2>
|
||||
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
|
||||
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
|
||||
<p>or if you use tcsh put this in your <b>.cshrc</b> file:</p>
|
||||
@@ -199,7 +195,7 @@
|
||||
<p>Mutt users should see an effect immediately the next time you log in, no further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
|
||||
<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>
|
||||
<h2><a name="4.7"></a>4.7. 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.9">3.9</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
<h1><a name="5"></a>5. Internationalization</h1>
|
||||
@@ -241,6 +237,7 @@
|
||||
<h2><a name="8"></a>8. ChangeLog</h2>
|
||||
<blockquote>
|
||||
<p>
|
||||
2004/04/07 - Removed NumLock glitch question, as it's no longer needed. (DLR)<br>
|
||||
2004/01/30 - Fixed inaccuracy: multibuffer mode was first in nano 1.1.0, not 1.1.12. (DLR)<br>
|
||||
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>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
.\" Public License for copying conditions. There is NO warranty.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANO 1 "version 1.3.2" "March 31, 2004"
|
||||
.TH NANO 1 "version 1.3.3" "June 28, 2004"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
@@ -35,6 +35,13 @@ replace" and "go to line number".
|
||||
.B \+\fILINE\fP
|
||||
Places cursor at \fILINE\fP on startup.
|
||||
.TP
|
||||
.B \-A (\-\-smarthome)
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
very beginning of non-whitespace characters on a line, the cursor will
|
||||
jump to that beginning (either forwards or backwards). If the cursor is
|
||||
already at that position, it will jump to the true beginning of the
|
||||
line.
|
||||
.TP
|
||||
.B \-B (\-\-backup)
|
||||
When saving a file, back up the previous version of it to the current
|
||||
filename suffixed with a ~.
|
||||
@@ -89,9 +96,16 @@ Show the current version number and author.
|
||||
.TP
|
||||
.B \-Y \fIstr\fP (\-\-syntax=\fIstr\fP)
|
||||
Specify a specific syntax highlighting from the
|
||||
.I .nanorc
|
||||
.I nanorc
|
||||
to use, if available.
|
||||
.TP
|
||||
.B \-Z (\-\-restricted)
|
||||
Restricted mode: Don't read or write to any file not specified on the
|
||||
command line, read any nanorc files, allow suspending, or allow a file
|
||||
to be appended to, prepended to, or saved under a different name if it
|
||||
already has one. Also accessible by invoking \fBnano\fP with any name
|
||||
beginning with 'r' (e.g. "rnano").
|
||||
.TP
|
||||
.B \-c (\-\-const)
|
||||
Constantly show the cursor position.
|
||||
.TP
|
||||
@@ -165,6 +179,10 @@ and the example file \fBnanorc.sample\fP which should be provided with
|
||||
\fBnano\fP.
|
||||
|
||||
.SH NOTES
|
||||
If no alternative spell checker command is specified on the command
|
||||
line or in one of the nanorc files, \fBnano\fP will check the
|
||||
\fBSPELL\fP environment variable for one.
|
||||
|
||||
\fBnano\fP will try to dump the buffer into an emergency file in some
|
||||
cases. Mainly, this will happen if \fBnano\fP receives a SIGHUP or
|
||||
SIGTERM or runs out of memory, when it will write the buffer into a file
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
.\" Public License for copying conditions. There is NO warranty.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANORC 5 "version 1.3.2" "March 31, 2004"
|
||||
.TH NANORC 5 "version 1.3.3" "June 28, 2004"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.SH NAME
|
||||
@@ -50,6 +50,10 @@ Create backup files in
|
||||
\fBset backupdir "\fIdirectory\fP"\fP
|
||||
Set the directory where \fBnano\fP puts the backup files if file backups
|
||||
are enabled.
|
||||
\fBset brackets "\fIstring\fP"\fP
|
||||
Set the characters treated as closing brackets. They cannot contain
|
||||
tabs or spaces. Only closing punctuation, optionally followed by
|
||||
closing brackets, can end sentences.
|
||||
.TP
|
||||
\fBset/unset const\fP
|
||||
Constantly display the cursor position in the status bar.
|
||||
@@ -90,6 +94,11 @@ feature is turned off.
|
||||
\fBset/unset preserve\fP
|
||||
Preserve the XON and XOFF keys (^Q and ^S).
|
||||
.TP
|
||||
\fBset punct "\fIstring\fP"\fP
|
||||
Set the characters treated as closing punctuation. They cannot contain
|
||||
tabs or spaces. Only closing punctuation, optionally followed by
|
||||
closing brackets, can end sentences.
|
||||
.TP
|
||||
\fBset quotestr "\fIstring\fP"\fP
|
||||
The email-quote string, used to justify email-quoted paragraphs. This
|
||||
is an "extended regular expression" if your system supports them,
|
||||
@@ -108,6 +117,13 @@ acts like Delete on your system.
|
||||
\fBset/unset regexp\fP
|
||||
Do regular expression searches by default.
|
||||
.TP
|
||||
\fBset/unset smarthome\fP
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
very beginning of non-whitespace characters on a line, the cursor will
|
||||
jump to that beginning (either forwards or backwards). If the cursor is
|
||||
already at that position, it will jump to the true beginning of the
|
||||
line.
|
||||
.TP
|
||||
\fBset/unset smooth\fP
|
||||
Use smooth scrolling by default.
|
||||
.TP
|
||||
@@ -128,6 +144,10 @@ Save automatically on exit, don't prompt.
|
||||
\fBset/unset view\fP
|
||||
Disallow file modification.
|
||||
.TP
|
||||
\fBset whitespace "\fIstring\fP"\fP
|
||||
Set the two characters used to display the first characters of tabs and
|
||||
spaces. They cannot be control characters.
|
||||
.TP
|
||||
.B syntax "\fIstr\fP" ["\fIfileregex\fP" ... ]
|
||||
Defines a syntax named \fIstr\fP which can be activated via the \fB-Y\fP
|
||||
flag, or will be automatically activated if the current filename matches
|
||||
|
||||
@@ -8,19 +8,25 @@
|
||||
## For the options that take parameters, the default value is given.
|
||||
## Other options are unset by default.
|
||||
|
||||
## Use auto-indentation
|
||||
## Use auto-indentation.
|
||||
# set autoindent
|
||||
|
||||
## Backup files to filename~
|
||||
## Backup files to filename~.
|
||||
# set backup
|
||||
|
||||
## The directory to put the backup files in.
|
||||
# set backupdir ""
|
||||
|
||||
## The characters treated as closing brackets. They cannot contain tabs
|
||||
## or spaces. Only closing punctuation, optionally followed by closing
|
||||
## brackets, can end sentences.
|
||||
##
|
||||
# set brackets "'")}]>"
|
||||
|
||||
## Constantly display the cursor position in the status bar.
|
||||
# set const
|
||||
|
||||
## Use cut to end of line with ^K by default
|
||||
## Use cut to end of line with ^K by default.
|
||||
# set cut
|
||||
|
||||
## Set the line length for wrapping text and justifying paragraphs.
|
||||
@@ -32,22 +38,26 @@
|
||||
## Enable ~/.nano_history for saving and reading search/replace strings.
|
||||
# set historylog
|
||||
|
||||
## Allow multiple file buffers (using ^R inserts into separate buffer).
|
||||
## You must have configured with --enable-multibuffer or --enable-extra
|
||||
## for this to work.
|
||||
##
|
||||
## set multibuffer
|
||||
## Enable mouse support so that mouse clicks can be used to set the mark
|
||||
## and run shortcuts.
|
||||
# set mouse
|
||||
|
||||
## Don't convert files from DOS/Mac format
|
||||
## Allow multiple file buffers (using ^R will insert into a separate
|
||||
## buffer). You must have configured with --enable-multibuffer or
|
||||
## --enable-extra for this to work.
|
||||
##
|
||||
# set multibuffer
|
||||
|
||||
## Don't convert files from DOS/Mac format.
|
||||
# set noconvert
|
||||
|
||||
## Don't follow symlinks when writing files
|
||||
## Don't follow symlinks when writing files.
|
||||
# set nofollow
|
||||
|
||||
## Don't display the help lists at the bottom of the screen
|
||||
## Don't display the helpful shortcut lists at the bottom of the screen.
|
||||
# set nohelp
|
||||
|
||||
## Don't wrap text at all
|
||||
## Don't wrap text at all.
|
||||
# set nowrap
|
||||
|
||||
## Set operating directory. nano will not read or write files outside
|
||||
@@ -57,9 +67,15 @@
|
||||
##
|
||||
# set operatingdir ""
|
||||
|
||||
## Preserve the XON and XOFF keys (^Q and ^S)
|
||||
## Preserve the XON and XOFF keys (^Q and ^S).
|
||||
# set preserve
|
||||
|
||||
## The characters treated as closing punctuation. They cannot contain
|
||||
## tabs or spaces. Only closing punctuation, optionally followed by
|
||||
## closing brackets, can end sentences.
|
||||
##
|
||||
# set punct ".?!"
|
||||
|
||||
## The email-quote string, used to justify email-quoted paragraphs.
|
||||
## This is an extended regular expression if your system supports them,
|
||||
## otherwise a literal string. Default:
|
||||
@@ -69,13 +85,20 @@
|
||||
## You can get old nano quoted-justify behavior via:
|
||||
# set quotestr "(> )+"
|
||||
|
||||
## Fix Backspace/Delete confusion problem
|
||||
## Fix Backspace/Delete confusion problem.
|
||||
# set rebinddelete
|
||||
|
||||
## Do extended regular expression searches by default
|
||||
## Do extended regular expression searches by default.
|
||||
# set regexp
|
||||
|
||||
## Use smooth scrolling as the default
|
||||
## Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
## very beginning of non-whitespace characters on a line, the cursor
|
||||
## will jump to that beginning (either forwards or backwards). If the
|
||||
## cursor is already at that position, it will jump to the true
|
||||
## beginning of the line.
|
||||
# set smarthome
|
||||
|
||||
## Use smooth scrolling as the default.
|
||||
# set smooth
|
||||
|
||||
## Use this spelling checker instead of the internal one. This option
|
||||
@@ -83,18 +106,22 @@
|
||||
##
|
||||
# set speller "aspell -c"
|
||||
|
||||
## Allow nano to be suspended with ^Z
|
||||
## Allow nano to be suspended with ^Z.
|
||||
# set suspend
|
||||
|
||||
## Use this tab size instead of the default; it must be greater than 0
|
||||
## Use this tab size instead of the default; it must be greater than 0.
|
||||
# set tabsize 8
|
||||
|
||||
## Save automatically on exit, don't prompt
|
||||
## Save automatically on exit, don't prompt.
|
||||
# set tempfile
|
||||
|
||||
## Disallow file modification, why would you want this in an rc file? ;)
|
||||
# set view
|
||||
|
||||
## The two characters used to display the first characters of tabs and
|
||||
## spaces. ASCII 187 and ASCII 183 seem to be good values for these.
|
||||
# set whitespace " "
|
||||
|
||||
## Color setup
|
||||
## Format:
|
||||
## syntax "short description" ["filename regex" ...]
|
||||
@@ -204,7 +231,7 @@
|
||||
## highlight possible errors and parameters
|
||||
#color brightwhite "^ *(set|unset|syntax|color).*$"
|
||||
## set, unset and syntax
|
||||
#color cyan "^ *(set|unset) +(autoindent|backup|const|cut|fill|historylog|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|rebinddelete|regexp|smooth|speller|suspend|tabsize|tempfile|view)"
|
||||
#color cyan "^ *(set|unset) +(autoindent|backup|backupdir|brackets|const|cut|fill|historylog|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|punct|quotestr|rebinddelete|regexp|smarthome|smooth|speller|suspend|tabsize|tempfile|view|whitespace)"
|
||||
#color green "^ *(set|unset|syntax)\>"
|
||||
## colors
|
||||
#color yellow "^ *color +(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
@c Run `makeinfo' rather than `texinfo-format-buffer'.
|
||||
@smallbook
|
||||
@set EDITION 0.1
|
||||
@set VERSION 1.3.2
|
||||
@set UPDATED 31 Mar 2004
|
||||
@set VERSION 1.3.3
|
||||
@set UPDATED 28 Jun 2004
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 1.3.2
|
||||
@subtitle version 1.3.3
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -107,6 +107,13 @@ Email bug reports to @email{nano@@nano-editor.org}.
|
||||
|
||||
@table @code
|
||||
|
||||
@item -A, --smarthome
|
||||
Make the Home key smarter. When Home is pressed anywhere but at the
|
||||
very beginning of non-whitespace characters on a line, the cursor will
|
||||
jump to that beginning (either forwards or backwards). If the cursor is
|
||||
already at that position, it will jump to the true beginning of the
|
||||
line.
|
||||
|
||||
@item -B, --backup
|
||||
When saving a file, back up the previous version of it to the current
|
||||
filename suffixed with a ~.
|
||||
@@ -157,6 +164,13 @@ Print the version number and copyright and quit.
|
||||
Specify a specific syntax highlighting from the .nanorc to use, if
|
||||
available.
|
||||
|
||||
@item -Z, --restricted
|
||||
Restricted mode: Don't read or write to any file not specified on the
|
||||
command line, read any nanorc files, allow suspending, or allow a file
|
||||
to be appended to, prepended to, or saved under a different name if it
|
||||
already has one. Also accessible by invoking @code{nano} with any name
|
||||
beginning with 'r' (e.g. "rnano").
|
||||
|
||||
@item -c, --const
|
||||
Constantly display the cursor position and line number on the statusbar.
|
||||
|
||||
@@ -199,9 +213,10 @@ from the right of the screen, allowing it to vary along with the screen
|
||||
width if the screen is resized.
|
||||
|
||||
@item -s [prog], --speller=[prog]
|
||||
Invoke [prog] as the spell checker. By default, @code{nano} uses its
|
||||
own interactive spell checker that requires the @code{spell} program be
|
||||
installed on your system.
|
||||
Invoke [prog] as the spell checker. By default, @code{nano} uses the
|
||||
command specified in the SPELL environment variable, or, if SPELL is not
|
||||
set, its own interactive spell checker that requires the @code{spell}
|
||||
program to be installed on your system.
|
||||
|
||||
@item -t, --tempfile
|
||||
Do not ask whether or not to save the current contents of the file when
|
||||
@@ -339,12 +354,18 @@ toggles the -D (@code{--dos}) command line flag.
|
||||
@item Multiple Files Toggle (Meta-F)
|
||||
toggles the -F (@code{--multibuffer}) command line flag.
|
||||
|
||||
@item Backup File Toggle (Meta-H)
|
||||
toggles the -A (@code{--smarthome}) command line flag.
|
||||
|
||||
@item AutoIndent Toggle (Meta-I)
|
||||
toggles the -i (@code{--autoindent}) command line flag.
|
||||
|
||||
@item Cut To End Toggle (Meta-K)
|
||||
toggles the -k (@code{--cut}) command line flag.
|
||||
|
||||
@item Auto Line Wrap Toggle (Meta-L)
|
||||
toggles the -w (@code{--nowrap}) command line flag.
|
||||
|
||||
@item Mouse Toggle (Meta-M)
|
||||
toggles the -m (@code{--mouse}) command line flag.
|
||||
|
||||
@@ -354,21 +375,12 @@ toggles the -M (@code{--mac}) command line flag.
|
||||
@item Smooth Scrolling Toggle (Meta-S)
|
||||
toggles the -S (@code{--smooth}) command line flag.
|
||||
|
||||
@item AutoWrap Toggle (Meta-W)
|
||||
toggles the -w (@code{--nowrap}) command line flag.
|
||||
|
||||
@item Expert/Nohelp Toggle (Meta-X)
|
||||
toggles the -x (@code{--nohelp}) command line flag.
|
||||
|
||||
@item Suspend Toggle (Meta-Z)
|
||||
toggles the -z (@code{--suspend}) command line flag.
|
||||
|
||||
@item Open Previous File Toggle (Meta-<)
|
||||
changes buffer to previously loaded file.
|
||||
|
||||
@item Open Next File Toggle (Meta->)
|
||||
changes buffer to next loaded file.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@@ -394,17 +406,18 @@ are certain differences between the editors:
|
||||
|
||||
@table @code
|
||||
@item Search and Replace History
|
||||
As of version 1.2.2 of @code{nano}, text entered as search or replace
|
||||
strings will be stored and can be accessed with the up/down arrow keys.
|
||||
Previously, @code{nano} offered a more consistent, but incompatible with
|
||||
Pico, method for entering search and replace strings. In the old
|
||||
method, previous entries would be displayed by default as editable text
|
||||
in front of the cursor, as opposed to being bracketed and uneditable as
|
||||
it is in Pico. The old behavior could be made compatible with Pico via
|
||||
the @code{-p} flag, but recent versions of Pico use the @code{-p} flag
|
||||
to preserve the XON and XOFF sequences within the editor. Since with
|
||||
the new method search and replace strings can still be edited by simply
|
||||
hitting the up arrow key once, the old method was removed completely.
|
||||
As of version 1.1.99pre1 of @code{nano}, text entered as search or
|
||||
replace strings will be stored and can be accessed with the up/down
|
||||
arrow keys. Previously, @code{nano} offered a more consistent, but
|
||||
incompatible with Pico, method for entering search and replace strings.
|
||||
In the old method, previous entries would be displayed by default as
|
||||
editable text in front of the cursor, as opposed to being bracketed and
|
||||
uneditable as it is in Pico. The old behavior could be made compatible
|
||||
with Pico via the @code{-p} flag, but recent versions of Pico use the
|
||||
@code{-p} flag to preserve the XON and XOFF sequences within the editor.
|
||||
Since with the new method search and replace strings can still be edited
|
||||
by simply hitting the up arrow key once, the old method was removed
|
||||
completely.
|
||||
|
||||
|
||||
@item Writing or Appending Selected Text to Files
|
||||
@@ -431,9 +444,9 @@ replace it. The @code{nano} implementation will stop at each search
|
||||
string found and query whether to replace this instance or not. The
|
||||
internal spell checker operates similarly. Note that these is no way to
|
||||
force these functions to behave in the Pico fashion. As of version
|
||||
1.2.2, misspelled words are sorted and trimmed for uniqueness in the
|
||||
internal spell checker such that the words 'apple' and 'Apple' will be
|
||||
prompted for correction separately.
|
||||
1.1.99pre1, misspelled words are sorted and trimmed for uniqueness in
|
||||
the internal spell checker such that the words 'apple' and 'Apple' will
|
||||
be prompted for correction separately.
|
||||
@end table
|
||||
|
||||
@node Building and Configure Options, , Pico Compatibility, Top
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
2004-06-01 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* zh_TW.po: Added Traditional Chinese translation by
|
||||
CHAO Wei-Lun <chaoweilun@pcmail.com.tw>.
|
||||
* LINGUAS: Added "zh_TW".
|
||||
|
||||
2004-02-24 Jordi Mallach <jordi@gnu.org>
|
||||
|
||||
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# List of available languages.
|
||||
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
|
||||
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 zh_TW
|
||||
|
||||
1603
po/zh_TW.po
Normal file
1603
po/zh_TW.po
Normal file
File diff suppressed because it is too large
Load Diff
@@ -119,7 +119,7 @@ void update_color(void)
|
||||
|
||||
/* if we haven't found a match, use the override string */
|
||||
if (colorstrings == NULL && syntaxstr != NULL) {
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
if (!strcasecmp(tmpsyntax->desc, syntaxstr))
|
||||
colorstrings = tmpsyntax->color;
|
||||
|
||||
27
src/cut.c
27
src/cut.c
@@ -28,17 +28,22 @@
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
static int marked_cut; /* Is the cutbuffer from a mark?
|
||||
* 0 means whole-line cut, 1 means mark,
|
||||
* 2 means cut-from-cursor. */
|
||||
|
||||
static int keep_cutbuffer = FALSE;
|
||||
/* Should we keep the contents of the cutbuffer? */
|
||||
static int marked_cut;
|
||||
/* Is the cutbuffer from a mark? 0 means whole-line cut, 1
|
||||
* means mark, and 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? */
|
||||
static int concatenate_cut;
|
||||
/* Should we add this cut string to the end of the last one? */
|
||||
#endif
|
||||
|
||||
static filestruct *cutbottom = NULL;
|
||||
/* Pointer to end of cutbuffer. */
|
||||
/* Pointer to end of cutbuffer. */
|
||||
|
||||
void cutbuffer_reset(void)
|
||||
{
|
||||
keep_cutbuffer = FALSE;
|
||||
}
|
||||
|
||||
filestruct *get_cutbottom(void)
|
||||
{
|
||||
@@ -202,7 +207,7 @@ int do_cut_text(void)
|
||||
|
||||
check_statblank();
|
||||
|
||||
if (!ISSET(KEEP_CUTBUFFER)) {
|
||||
if (!keep_cutbuffer) {
|
||||
free_filestruct(cutbuffer);
|
||||
cutbuffer = NULL;
|
||||
marked_cut = 0;
|
||||
@@ -215,7 +220,7 @@ int do_cut_text(void)
|
||||
}
|
||||
|
||||
/* You can't cut the magicline except with the mark. But trying
|
||||
* does clear the cutbuffer if KEEP_CUTBUFFER is not set. */
|
||||
* does clear the cutbuffer if keep_cutbuffer is FALSE. */
|
||||
if (current == filebot
|
||||
#ifndef NANO_SMALL
|
||||
&& !ISSET(MARK_ISSET)
|
||||
@@ -223,7 +228,7 @@ int do_cut_text(void)
|
||||
)
|
||||
return 0;
|
||||
|
||||
SET(KEEP_CUTBUFFER);
|
||||
keep_cutbuffer = TRUE;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) {
|
||||
|
||||
106
src/files.c
106
src/files.c
@@ -105,7 +105,8 @@ void new_file(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, int len)
|
||||
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, size_t
|
||||
len)
|
||||
{
|
||||
filestruct *fileptr = (filestruct *)nmalloc(sizeof(filestruct));
|
||||
|
||||
@@ -189,7 +190,7 @@ int read_file(FILE *f, const char *filename, int quiet)
|
||||
assume it's a DOS or Mac formatted file if it hasn't been
|
||||
detected as one already! */
|
||||
if (fileformat == 0 && !ISSET(NO_CONVERT)
|
||||
&& is_cntrl_char((int)input) != 0 && input != '\t'
|
||||
&& is_cntrl_char(input) && input != '\t'
|
||||
&& input != '\r' && input != '\n')
|
||||
SET(NO_CONVERT);
|
||||
#endif
|
||||
@@ -785,17 +786,14 @@ int add_open_file(int update)
|
||||
/* if we're updating, save current modification status (and marking
|
||||
status, if available) */
|
||||
if (update) {
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(MODIFIED))
|
||||
open_files->file_flags |= MODIFIED;
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(MARK_ISSET)) {
|
||||
open_files->file_mark_beginbuf = mark_beginbuf;
|
||||
open_files->file_mark_beginx = mark_beginx;
|
||||
open_files->file_flags |= MARK_ISSET;
|
||||
}
|
||||
#else
|
||||
if (ISSET(MODIFIED))
|
||||
open_files->file_flags |= MODIFIED;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1397,8 +1395,8 @@ int copy_file(FILE *inn, FILE *out)
|
||||
* 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.
|
||||
* nonamechange means don't change the current filename. It is ignored
|
||||
* if tmp is FALSE 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)
|
||||
@@ -1455,7 +1453,7 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
|
||||
/* 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."));
|
||||
statusbar(_("Cannot prepend or append to a symlink with --nofollow set"));
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
@@ -1640,7 +1638,7 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
/* There might not be a magic line. There won't be when writing out
|
||||
/* There might not be a magicline. There won't be when writing out
|
||||
* a selection. */
|
||||
assert(fileage != NULL && filebot != NULL);
|
||||
while (fileptr != filebot) {
|
||||
@@ -1739,11 +1737,11 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
|
||||
#ifndef NANO_SMALL
|
||||
/* Write a marked selection from a file out. First, set fileage and
|
||||
* filebot as the top and bottom of the mark, respectively. Then call
|
||||
* write_file() with the values of name, temp, append, and nonamechange.
|
||||
* Finally, set fileage and filebot back to their old values and
|
||||
* return. */
|
||||
int write_marked(const char *name, int tmp, int append, int
|
||||
nonamechange)
|
||||
* write_file() with the values of name, temp, and append, and with
|
||||
* nonamechange set to TRUE so that we don't change the current
|
||||
* filename. Finally, set fileage and filebot back to their old values
|
||||
* and return. */
|
||||
int write_marked(const char *name, int tmp, int append)
|
||||
{
|
||||
int retval = -1;
|
||||
filestruct *fileagebak = fileage;
|
||||
@@ -1785,7 +1783,7 @@ int write_marked(const char *name, int tmp, int append, int
|
||||
if (filebot->data[0] != '\0' && filebot->next != NULL)
|
||||
filebot = filebot->next;
|
||||
|
||||
retval = write_file(name, tmp, append, nonamechange);
|
||||
retval = write_file(name, tmp, append, TRUE);
|
||||
|
||||
/* Now restore everything. */
|
||||
fileage->data -= topx;
|
||||
@@ -1811,24 +1809,12 @@ int do_writeout(int exiting)
|
||||
currshortcut = writefile_list;
|
||||
#endif
|
||||
|
||||
if (exiting && ISSET(TEMP_OPT)) {
|
||||
i = -1;
|
||||
if (filename[0] != '\0') {
|
||||
i = write_file(filename, FALSE, 0, FALSE);
|
||||
if (i == 1) {
|
||||
/* Write succeeded. */
|
||||
display_main_list();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* No filename or the write above failed. */
|
||||
if (i == -1) {
|
||||
UNSET(TEMP_OPT);
|
||||
do_exit();
|
||||
|
||||
/* They cancelled; abort quit. */
|
||||
return -1;
|
||||
if (exiting && filename[0] != '\0' && ISSET(TEMP_OPT)) {
|
||||
i = write_file(filename, FALSE, 0, FALSE);
|
||||
if (i == 1) {
|
||||
/* Write succeeded. */
|
||||
display_main_list();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1941,25 +1927,32 @@ int do_writeout(int exiting)
|
||||
struct stat st;
|
||||
|
||||
if (!stat(answer, &st)) {
|
||||
i = do_yesno(FALSE, _("File exists, OVERWRITE ?"));
|
||||
i = do_yesno(FALSE, _("File exists, OVERWRITE ? "));
|
||||
if (i == 0 || i == -1)
|
||||
continue;
|
||||
} else if (filename[0] != '\0'
|
||||
/* If we're using restricted mode, we aren't allowed to
|
||||
* change the name of a file once it has one because that
|
||||
* would allow reading from or writing to files not
|
||||
* specified on the command line. In this case, don't
|
||||
* bother showing the "Different Name" prompt. */
|
||||
} else if (!ISSET(RESTRICTED) && filename[0] != '\0'
|
||||
#ifndef NANO_SMALL
|
||||
&& (!ISSET(MARK_ISSET) || exiting)
|
||||
&& (exiting || !ISSET(MARK_ISSET))
|
||||
#endif
|
||||
) {
|
||||
i = do_yesno(FALSE, _("Save file under DIFFERENT NAME ?"));
|
||||
i = do_yesno(FALSE, _("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. */
|
||||
if (ISSET(MARK_ISSET) && !exiting)
|
||||
i = write_marked(answer, FALSE, append, FALSE);
|
||||
/* Here's where we allow the selected text to be written to a
|
||||
* separate file. If we're using restricted mode, this is
|
||||
* disabled since it allows reading from or writing to files not
|
||||
* specified on the command line. */
|
||||
if (!ISSET(RESTRICTED) && !exiting && ISSET(MARK_ISSET))
|
||||
i = write_marked(answer, FALSE, append);
|
||||
else
|
||||
#endif /* !NANO_SMALL */
|
||||
i = write_file(answer, FALSE, append, FALSE);
|
||||
@@ -2245,7 +2238,7 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list)
|
||||
tmp = matchbuf;
|
||||
|
||||
/* skip any leading white space */
|
||||
while (*tmp && isspace((int)*tmp))
|
||||
while (*tmp && isblank(*tmp))
|
||||
++tmp;
|
||||
|
||||
/* Free up any memory already allocated */
|
||||
@@ -2435,7 +2428,6 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list)
|
||||
}
|
||||
#endif /* !DISABLE_TABCOMP */
|
||||
|
||||
#if !defined(DISABLE_BROWSER) || !defined(NANO_SMALL)
|
||||
/* Only print the last part of a path; isn't there a shell
|
||||
* command for this? */
|
||||
const char *tail(const char *foo)
|
||||
@@ -2450,7 +2442,6 @@ const char *tail(const char *foo)
|
||||
|
||||
return tmp;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
/* Our sort routine for file listings -- sort directories before
|
||||
@@ -2471,7 +2462,7 @@ int diralphasort(const void *va, const void *vb)
|
||||
}
|
||||
|
||||
/* Free our malloc()ed memory */
|
||||
void free_charptrarray(char **array, int len)
|
||||
void free_charptrarray(char **array, size_t len)
|
||||
{
|
||||
for (; len > 0; len--)
|
||||
free(array[len - 1]);
|
||||
@@ -2608,7 +2599,7 @@ char *do_browser(const char *inpath)
|
||||
char *new_path;
|
||||
/* Used by the Go To Directory prompt. */
|
||||
|
||||
blank_statusbar_refresh();
|
||||
check_statblank();
|
||||
|
||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||
currshortcut = browser_list;
|
||||
@@ -2677,7 +2668,7 @@ char *do_browser(const char *inpath)
|
||||
case NANO_PREVPAGE_FKEY:
|
||||
case '-': /* Pico compatibility */
|
||||
if (selected >= (editwinrows + lineno % editwinrows) * width)
|
||||
selected -= (editwinrows + lineno % editwinrows) * width;
|
||||
selected -= (editwinrows + lineno % editwinrows) * width;
|
||||
else
|
||||
selected = 0;
|
||||
break;
|
||||
@@ -2691,8 +2682,9 @@ char *do_browser(const char *inpath)
|
||||
case NANO_HELP_KEY:
|
||||
case NANO_HELP_FKEY:
|
||||
case '?': /* Pico compatibility */
|
||||
do_help();
|
||||
break;
|
||||
do_help();
|
||||
curs_set(0);
|
||||
break;
|
||||
case NANO_ENTER_KEY:
|
||||
case 'S': /* Pico compatibility */
|
||||
case 's':
|
||||
@@ -2967,7 +2959,7 @@ void load_history(void)
|
||||
if (errno != ENOENT) {
|
||||
/* Don't save history when we quit. */
|
||||
UNSET(HISTORYLOG);
|
||||
rcfile_error(_("Unable to open ~/.nano_history file, %s"), strerror(errno));
|
||||
rcfile_error(_("Unable to open ~/.nano_history file: %s"), strerror(errno));
|
||||
}
|
||||
free(nanohist);
|
||||
} else {
|
||||
@@ -3017,28 +3009,28 @@ void save_history(void)
|
||||
if (homenv != NULL || userage != NULL) {
|
||||
hist = fopen(nanohist, "wb");
|
||||
if (hist == NULL) {
|
||||
rcfile_msg(_("Unable to write ~/.nano_history file, %s"), strerror(errno));
|
||||
rcfile_msg(_("Unable to write ~/.nano_history file: %s"), strerror(errno));
|
||||
} else {
|
||||
/* set rw only by owner for security ?? */
|
||||
chmod(nanohist, S_IRUSR | S_IWUSR);
|
||||
/* write oldest first */
|
||||
for (h = search_history.tail ; h->prev ; h = h->prev) {
|
||||
for (h = search_history.tail; h->prev; h = h->prev) {
|
||||
h->data = charealloc(h->data, strlen(h->data) + 2);
|
||||
strcat(h->data, "\n");
|
||||
if (fputs(h->data, hist) == EOF) {
|
||||
rcfile_msg(_("Unable to write ~/.nano_history file, %s"), strerror(errno));
|
||||
rcfile_msg(_("Unable to write ~/.nano_history file: %s"), strerror(errno));
|
||||
goto come_from;
|
||||
}
|
||||
}
|
||||
if (fputs("\n", hist) == EOF) {
|
||||
rcfile_msg(_("Unable to write ~/.nano_history file, %s"), strerror(errno));
|
||||
rcfile_msg(_("Unable to write ~/.nano_history file: %s"), strerror(errno));
|
||||
goto come_from;
|
||||
}
|
||||
for (h = replace_history.tail ; h->prev ; h = h->prev) {
|
||||
for (h = replace_history.tail; h->prev; h = h->prev) {
|
||||
h->data = charealloc(h->data, strlen(h->data) + 2);
|
||||
strcat(h->data, "\n");
|
||||
if (fputs(h->data, hist) == EOF) {
|
||||
rcfile_msg(_("Unable to write ~/.nano_history file, %s"), strerror(errno));
|
||||
rcfile_msg(_("Unable to write ~/.nano_history file: %s"), strerror(errno));
|
||||
goto come_from;
|
||||
}
|
||||
}
|
||||
|
||||
256
src/global.c
256
src/global.c
@@ -66,7 +66,18 @@ filestruct *cutbuffer = NULL; /* A place to store cut text */
|
||||
openfilestruct *open_files = NULL; /* The list of open files */
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||
char *whitespace = NULL; /* Characters used when displaying
|
||||
the first characters of tabs and
|
||||
spaces. */
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
char *punct = NULL; /* Closing punctuation that can end
|
||||
sentences. */
|
||||
char *brackets = NULL; /* Closing brackets that can follow
|
||||
closing punctuation and can end
|
||||
sentences. */
|
||||
char *quotestr = NULL; /* Quote string. The default value is
|
||||
set in main(). */
|
||||
#endif
|
||||
@@ -231,18 +242,21 @@ void toggle_init(void)
|
||||
char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
|
||||
*toggle_nohelp_msg, *toggle_cuttoend_msg,
|
||||
*toggle_noconvert_msg, *toggle_dos_msg, *toggle_mac_msg,
|
||||
*toggle_backup_msg, *toggle_smooth_msg;
|
||||
*toggle_backup_msg, *toggle_smooth_msg, *toggle_smarthome_msg;
|
||||
#ifndef DISABLE_MOUSE
|
||||
char *toggle_mouse_msg;
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPPING
|
||||
char *toggle_wrap_msg;
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
char *toggle_syntax_msg;
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
char *toggle_multibuffer_msg;
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
char *toggle_syntax_msg;
|
||||
#ifdef ENABLE_NANORC
|
||||
char *toggle_whitespace_msg;
|
||||
#endif
|
||||
|
||||
/* There is no need to reinitialize the toggles. They can't
|
||||
@@ -263,19 +277,26 @@ void toggle_init(void)
|
||||
toggle_mac_msg = _("Writing file in Mac format");
|
||||
toggle_backup_msg = _("Backing up file");
|
||||
toggle_smooth_msg = _("Smooth scrolling");
|
||||
#ifdef ENABLE_COLOR
|
||||
toggle_syntax_msg = _("Color syntax highlighting");
|
||||
#endif
|
||||
toggle_smarthome_msg = _("Smart home key");
|
||||
#ifndef DISABLE_WRAPPING
|
||||
toggle_wrap_msg = _("Auto line wrap");
|
||||
#endif
|
||||
#ifdef ENABLE_COLOR
|
||||
toggle_syntax_msg = _("Color syntax highlighting");
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
toggle_multibuffer_msg = _("Multiple file buffers");
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
toggle_whitespace_msg = _("Whitespace display");
|
||||
#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);
|
||||
/* If we're using restricted mode, the multibuffer toggle is
|
||||
* disabled. It's useless since inserting files is disabled. */
|
||||
if (!ISSET(RESTRICTED))
|
||||
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);
|
||||
@@ -283,18 +304,31 @@ void toggle_init(void)
|
||||
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);
|
||||
/* If we're using restricted mode, the suspend toggle is disabled.
|
||||
* It's useless since suspending is disabled. */
|
||||
if (!ISSET(RESTRICTED))
|
||||
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_NOCONVERT_KEY, toggle_noconvert_msg, NO_CONVERT);
|
||||
toggle_init_one(TOGGLE_DOS_KEY, toggle_dos_msg, DOS_FILE);
|
||||
toggle_init_one(TOGGLE_MAC_KEY, toggle_mac_msg, MAC_FILE);
|
||||
toggle_init_one(TOGGLE_BACKUP_KEY, toggle_backup_msg, BACKUP_FILE);
|
||||
/* If we're using restricted mode, the no-conversion, DOS format,
|
||||
* Mac format, and backup toggles are disabled. The first, second,
|
||||
* and third are useless since inserting files is disabled, and the
|
||||
* fourth is useless since backups are disabled. */
|
||||
if (!ISSET(RESTRICTED)) {
|
||||
toggle_init_one(TOGGLE_NOCONVERT_KEY, toggle_noconvert_msg, NO_CONVERT);
|
||||
toggle_init_one(TOGGLE_DOS_KEY, toggle_dos_msg, DOS_FILE);
|
||||
toggle_init_one(TOGGLE_MAC_KEY, toggle_mac_msg, MAC_FILE);
|
||||
toggle_init_one(TOGGLE_BACKUP_KEY, toggle_backup_msg, BACKUP_FILE);
|
||||
}
|
||||
toggle_init_one(TOGGLE_SMOOTH_KEY, toggle_smooth_msg, SMOOTHSCROLL);
|
||||
toggle_init_one(TOGGLE_SMARTHOME_KEY, toggle_smarthome_msg, SMART_HOME);
|
||||
#ifdef ENABLE_COLOR
|
||||
toggle_init_one(TOGGLE_SYNTAX_KEY, toggle_syntax_msg, COLOR_SYNTAX);
|
||||
#endif
|
||||
#ifdef ENABLE_NANORC
|
||||
toggle_init_one(TOGGLE_WHITESPACE_KEY, toggle_whitespace_msg, WHITESPACE_DISPLAY);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -348,7 +382,7 @@ void shortcut_init(int unjustify)
|
||||
"", *nano_execute_msg = "", *nano_dos_msg =
|
||||
"", *nano_mac_msg = "", *nano_backup_msg =
|
||||
"", *nano_editstr_msg = "", *nano_parabegin_msg =
|
||||
"", *nano_paraend_msg = "";
|
||||
"", *nano_paraend_msg = "", *nano_fulljustify_msg = "";
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
const char *nano_openprev_msg = "", *nano_opennext_msg =
|
||||
@@ -412,6 +446,7 @@ void shortcut_init(int unjustify)
|
||||
nano_editstr_msg = _("Edit the previous search/replace strings");
|
||||
nano_parabegin_msg = _("Go to the beginning of the current paragraph");
|
||||
nano_paraend_msg = _("Go to the end of the current paragraph");
|
||||
nano_fulljustify_msg = _("Justify the entire file");
|
||||
#ifdef HAVE_REGEX_H
|
||||
nano_regexp_msg = _("Use regular expressions");
|
||||
nano_bracket_msg = _("Find other bracket");
|
||||
@@ -425,9 +460,9 @@ void shortcut_init(int unjustify)
|
||||
|
||||
free_shortcutage(&main_list);
|
||||
|
||||
/* The following macro is to be used in calling sc_init_one. The point is
|
||||
* that sc_init_one takes 9 arguments, unless DISABLE_HELP is defined,
|
||||
* when the fourth one should not be there. */
|
||||
/* The following macro is to be used in calling sc_init_one(). The
|
||||
* point is that sc_init_one() takes 9 arguments, unless DISABLE_HELP is
|
||||
* defined, when the 4th one should not be there. */
|
||||
#ifndef DISABLE_HELP
|
||||
# define IFHELP(help, nextvar) help, nextvar
|
||||
#else
|
||||
@@ -437,7 +472,13 @@ void shortcut_init(int unjustify)
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
if (open_files != NULL && (open_files->prev != NULL || open_files->next != NULL))
|
||||
@@ -461,9 +502,19 @@ void shortcut_init(int unjustify)
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_JUSTIFY_KEY, _("Justify"),
|
||||
IFHELP(nano_justify_msg, NANO_NO_KEY),
|
||||
NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW, do_justify);
|
||||
NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW,
|
||||
#ifndef NANO_SMALL
|
||||
do_justify_void
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
/* this is so we can view multiple files */
|
||||
/* We allow inserting files in view mode if multibuffers are
|
||||
* available, so that we can view multiple files. */
|
||||
/* If we're using restricted mode, inserting files is disabled since
|
||||
* it allows reading from or writing to files not specified on the
|
||||
* command line. */
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
|
||||
IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
|
||||
@@ -473,7 +524,7 @@ void shortcut_init(int unjustify)
|
||||
#else
|
||||
NOVIEW
|
||||
#endif
|
||||
, do_insertfile_void);
|
||||
, !ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"),
|
||||
@@ -511,10 +562,17 @@ void shortcut_init(int unjustify)
|
||||
IFHELP(nano_cursorpos_msg, NANO_NO_KEY), NANO_CURSORPOS_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_cursorpos_void);
|
||||
|
||||
/* If we're using restricted mode, spell checking is disabled
|
||||
* because it allows reading from or writing to files not specified
|
||||
* on the command line. */
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&main_list, NANO_SPELL_KEY, _("To Spell"),
|
||||
IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
|
||||
NANO_NO_KEY, NOVIEW, do_spell);
|
||||
NANO_NO_KEY, NOVIEW,
|
||||
#ifndef DISABLE_SPELLER
|
||||
!ISSET(RESTRICTED) ? do_spell :
|
||||
#endif
|
||||
nano_disabled_msg);
|
||||
|
||||
sc_init_one(&main_list, NANO_GOTO_KEY, _("Go To Line"),
|
||||
IFHELP(nano_goto_msg, NANO_ALT_GOTO_KEY), NANO_GOTO_FKEY,
|
||||
@@ -534,11 +592,11 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&main_list, NANO_FORWARD_KEY, _("Forward"),
|
||||
IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_right);
|
||||
NANO_NO_KEY, VIEW, do_right_void);
|
||||
|
||||
sc_init_one(&main_list, NANO_BACK_KEY, _("Back"),
|
||||
IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_left);
|
||||
NANO_NO_KEY, VIEW, do_left_void);
|
||||
|
||||
sc_init_one(&main_list, NANO_HOME_KEY, _("Home"),
|
||||
IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
@@ -554,7 +612,13 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&main_list, NANO_MARK_KEY, _("Mark Text"),
|
||||
IFHELP(nano_mark_msg, NANO_ALT_MARK_KEY),
|
||||
NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_mark);
|
||||
NANO_NO_KEY, NANO_NO_KEY, NOVIEW,
|
||||
#ifndef NANO_SMALL
|
||||
do_mark
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
sc_init_one(&main_list, NANO_DELETE_KEY, _("Delete"),
|
||||
IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
@@ -596,7 +660,8 @@ void shortcut_init(int unjustify)
|
||||
NANO_OPENNEXT_ALTKEY, VIEW, open_nextfile_void);
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
|
||||
#ifndef NANO_SMALL
|
||||
#ifdef 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);
|
||||
@@ -605,12 +670,19 @@ void shortcut_init(int unjustify)
|
||||
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);
|
||||
#endif
|
||||
|
||||
free_shortcutage(&whereis_list);
|
||||
|
||||
sc_init_one(&whereis_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
@@ -647,6 +719,11 @@ void shortcut_init(int unjustify)
|
||||
sc_init_one(&whereis_list, NANO_PARAEND_KEY, _("End of Par"),
|
||||
IFHELP(nano_paraend_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, do_para_end);
|
||||
|
||||
/* Translators: try to keep this string under 10 characters long */
|
||||
sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, _("FullJstify"),
|
||||
IFHELP(nano_fulljustify_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, do_full_justify);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
@@ -680,7 +757,13 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&replace_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
sc_init_one(&replace_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
@@ -727,7 +810,13 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&replace_list_2, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
sc_init_one(&replace_list_2, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
@@ -751,7 +840,13 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&goto_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
sc_init_one(&goto_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
@@ -770,55 +865,83 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&help_list, NANO_PREVPAGE_KEY, _("Prev Page"),
|
||||
IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_page_up);
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&help_list, NANO_NEXTPAGE_KEY, _("Next Page"),
|
||||
IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_page_down);
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&help_list, NANO_PREVLINE_KEY, _("Prev Line"),
|
||||
IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&help_list, NANO_NEXTLINE_KEY, _("Next Line"),
|
||||
IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
|
||||
sc_init_one(&help_list, NANO_EXIT_KEY, _("Exit"),
|
||||
IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_exit);
|
||||
NANO_NO_KEY, VIEW, 0);
|
||||
#endif
|
||||
|
||||
free_shortcutage(&writefile_list);
|
||||
|
||||
sc_init_one(&writefile_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
/* If we're using restricted mode, the file browser is disabled.
|
||||
* It's useless since inserting files is disabled. */
|
||||
/* Translators: try to keep this string under 16 characters long */
|
||||
sc_init_one(&writefile_list, NANO_TOFILES_KEY, _("To Files"),
|
||||
if (!ISSET(RESTRICTED))
|
||||
sc_init_one(&writefile_list, NANO_TOFILES_KEY, _("To Files"),
|
||||
IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* If we're using restricted mode, the DOS format, Mac format,
|
||||
* append, prepend, and backup toggles are disabled. The first and
|
||||
* second are useless since inserting files is disabled, the third
|
||||
* and fourth are disabled because they allow writing to files not
|
||||
* specified on the command line, and the fifth is useless since
|
||||
* backups are disabled. */
|
||||
/* Translators: try to keep this string under 16 characters long */
|
||||
sc_init_one(&writefile_list, NANO_NO_KEY, _("DOS Format"),
|
||||
if (!ISSET(RESTRICTED))
|
||||
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, NANO_NO_KEY, _("Mac Format"),
|
||||
if (!ISSET(RESTRICTED))
|
||||
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_NO_KEY, _("Append"),
|
||||
if (!ISSET(RESTRICTED))
|
||||
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_NO_KEY, _("Prepend"),
|
||||
if (!ISSET(RESTRICTED))
|
||||
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, NANO_NO_KEY, _("Backup File"),
|
||||
if (!ISSET(RESTRICTED))
|
||||
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
|
||||
@@ -831,27 +954,42 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&insertfile_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
sc_init_one(&insertfile_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
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"),
|
||||
/* If we're using restricted mode, the file browser is disabled.
|
||||
* It's useless since inserting files is disabled. */
|
||||
if (!ISSET(RESTRICTED))
|
||||
sc_init_one(&insertfile_list, NANO_TOFILES_KEY, _("To Files"),
|
||||
IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* If we're using restricted mode, command execution is disabled.
|
||||
* It's useless since inserting files is disabled. */
|
||||
/* Translators: try to keep this string under 22 characters long */
|
||||
sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, _("Execute Command"),
|
||||
if (!ISSET(RESTRICTED))
|
||||
sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, _("Execute Command"),
|
||||
IFHELP(nano_execute_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
NANO_NO_KEY, NOVIEW, 0);
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
/* If we're using restricted mode, the multibuffer toggle is
|
||||
* disabled. It's useless since inserting files is disabled. */
|
||||
/* Translators: try to keep this string under 22 characters long */
|
||||
sc_init_one(&insertfile_list, NANO_NO_KEY, _("New Buffer"),
|
||||
if (!ISSET(RESTRICTED))
|
||||
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
|
||||
@@ -862,7 +1000,13 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&spell_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
sc_init_one(&spell_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
@@ -874,7 +1018,13 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&extcmd_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
sc_init_one(&extcmd_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
@@ -886,7 +1036,13 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&browser_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
sc_init_one(&browser_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
@@ -909,7 +1065,13 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&gotodir_list, NANO_HELP_KEY, _("Get Help"),
|
||||
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
|
||||
NANO_NO_KEY, VIEW, do_help);
|
||||
NANO_NO_KEY, VIEW,
|
||||
#ifndef DISABLE_HELP
|
||||
do_help
|
||||
#else
|
||||
nano_disabled_msg
|
||||
#endif
|
||||
);
|
||||
|
||||
sc_init_one(&gotodir_list, NANO_CANCEL_KEY, _("Cancel"),
|
||||
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
|
||||
|
||||
175
src/move.c
175
src/move.c
@@ -23,53 +23,99 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
int do_first_line(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
current = fileage;
|
||||
placewewant = 0;
|
||||
current_x = 0;
|
||||
if (edittop != fileage || need_vertical_update(old_pww))
|
||||
edit_update(current, TOP);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_last_line(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
current = filebot;
|
||||
placewewant = 0;
|
||||
current_x = 0;
|
||||
if (edittop->lineno + (editwinrows / 2) != filebot->lineno ||
|
||||
need_vertical_update(old_pww))
|
||||
edit_update(current, CENTER);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_home(void)
|
||||
{
|
||||
current_x = 0;
|
||||
placewewant = 0;
|
||||
int old_pww = placewewant;
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(SMART_HOME)) {
|
||||
int old_current_x = current_x;
|
||||
|
||||
for (current_x = 0; isblank(current->data[current_x]) &&
|
||||
current->data[current_x] != '\0'; current_x++)
|
||||
;
|
||||
|
||||
if (current_x == old_current_x || current->data[current_x] == '\0')
|
||||
current_x = 0;
|
||||
|
||||
placewewant = xplustabs();
|
||||
} else {
|
||||
#endif
|
||||
current_x = 0;
|
||||
placewewant = 0;
|
||||
#ifndef NANO_SMALL
|
||||
}
|
||||
#endif
|
||||
check_statblank();
|
||||
update_line(current, current_x);
|
||||
if (need_horizontal_update(old_pww))
|
||||
update_line(current, current_x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_end(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
current_x = strlen(current->data);
|
||||
placewewant = xplustabs();
|
||||
check_statblank();
|
||||
update_line(current, current_x);
|
||||
if (need_horizontal_update(old_pww))
|
||||
update_line(current, current_x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_page_up(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
int old_pww = placewewant;
|
||||
const filestruct *old_current = current;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
#endif
|
||||
|
||||
/* If edittop is the first line of the file, move current up there
|
||||
/* If the first line of the file is onscreen, move current up there
|
||||
* and put the cursor at the beginning of the line. */
|
||||
if (edittop == fileage) {
|
||||
current = fileage;
|
||||
placewewant = 0;
|
||||
} else {
|
||||
/* Move the top line of the edit window up a page. */
|
||||
for (i = 0; i < editwinrows - 2 && edittop->prev != NULL; i++)
|
||||
edittop = edittop->prev;
|
||||
edit_scroll(UP, editwinrows - 2);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* If we're in smooth scrolling mode and there was at least one
|
||||
/* If we're in smooth scrolling mode and there's at least one
|
||||
* page of text left, move the current line of the edit window
|
||||
* up a page. */
|
||||
if (ISSET(SMOOTHSCROLL) && current->lineno > editwinrows - 2)
|
||||
if (ISSET(SMOOTHSCROLL) && current->lineno > editwinrows - 2) {
|
||||
int i;
|
||||
for (i = 0; i < editwinrows - 2; i++)
|
||||
current = current->prev;
|
||||
/* If we're not in smooth scrolling mode and there was at least
|
||||
}
|
||||
/* If we're not in smooth scrolling mode or there isn't at least
|
||||
* one page of text left, put the cursor at the beginning of the
|
||||
* top line of the edit window, as Pico does. */
|
||||
else {
|
||||
@@ -80,10 +126,12 @@ int do_page_up(void)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Get the equivalent x-coordinate of the new line. */
|
||||
current_x = actual_x(current->data, placewewant);
|
||||
|
||||
edit_refresh();
|
||||
/* Update all the lines that need to be updated. */
|
||||
edit_redraw(old_current, old_pww);
|
||||
|
||||
check_statblank();
|
||||
return 1;
|
||||
@@ -91,8 +139,8 @@ int do_page_up(void)
|
||||
|
||||
int do_page_down(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
int old_pww = placewewant;
|
||||
const filestruct *old_current = current;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
#endif
|
||||
@@ -103,17 +151,19 @@ int do_page_down(void)
|
||||
current = filebot;
|
||||
placewewant = 0;
|
||||
} else {
|
||||
/* Move the top line of the edit window down a page. */
|
||||
for (i = 0; i < editwinrows - 2; i++)
|
||||
edittop = edittop->next;
|
||||
edit_scroll(DOWN, editwinrows - 2);
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* If we're in smooth scrolling mode and there was at least one
|
||||
/* If we're in smooth scrolling mode and there's at least one
|
||||
* page of text left, move the current line of the edit window
|
||||
* down a page. */
|
||||
if (ISSET(SMOOTHSCROLL) && current->lineno + editwinrows - 2 <= filebot->lineno)
|
||||
if (ISSET(SMOOTHSCROLL) && current->lineno + editwinrows - 2 <=
|
||||
filebot->lineno) {
|
||||
int i;
|
||||
for (i = 0; i < editwinrows - 2; i++)
|
||||
current = current->next;
|
||||
/* If we're not in smooth scrolling mode and there was at least
|
||||
}
|
||||
/* If we're not in smooth scrolling mode or there isn't at least
|
||||
* one page of text left, put the cursor at the beginning of the
|
||||
* top line of the edit window, as Pico does. */
|
||||
else {
|
||||
@@ -124,10 +174,12 @@ int do_page_down(void)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Get the equivalent x-coordinate of the new line. */
|
||||
current_x = actual_x(current->data, placewewant);
|
||||
|
||||
edit_refresh();
|
||||
/* Update all the lines that need to be updated. */
|
||||
edit_redraw(old_current, old_pww);
|
||||
|
||||
check_statblank();
|
||||
return 1;
|
||||
@@ -146,18 +198,25 @@ int do_up(void)
|
||||
assert(current_y == current->lineno - edittop->lineno);
|
||||
current = current->prev;
|
||||
current_x = actual_x(current->data, placewewant);
|
||||
if (current_y > 0) {
|
||||
update_line(current->next, 0);
|
||||
/* It was necessary to change current first, so that the
|
||||
* mark display will change! */
|
||||
update_line(current, current_x);
|
||||
} else
|
||||
|
||||
/* If we're on the first row of the edit window, scroll up one line
|
||||
* if we're in smooth scrolling mode, or up half a page if we're
|
||||
* not. */
|
||||
if (current_y == 0)
|
||||
edit_scroll(UP,
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(SMOOTHSCROLL))
|
||||
edit_update(current, TOP);
|
||||
else
|
||||
ISSET(SMOOTHSCROLL) ? 1 :
|
||||
#endif
|
||||
edit_update(current, CENTER);
|
||||
editwinrows / 2);
|
||||
|
||||
/* Update the lines left alone by edit_scroll(): the line we were on
|
||||
* before and the line we're on now. The former needs to be redrawn
|
||||
* if we're not on the first page, and the latter needs to be
|
||||
* drawn. */
|
||||
if (need_vertical_update(0))
|
||||
update_line(current->next, 0);
|
||||
update_line(current, current_x);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -177,25 +236,30 @@ int do_down(void)
|
||||
current = current->next;
|
||||
current_x = actual_x(current->data, placewewant);
|
||||
|
||||
/* Note that current_y is zero-based. This test checks for the
|
||||
* cursor's being not on the last row of the edit window. */
|
||||
if (current_y != editwinrows - 1) {
|
||||
update_line(current->prev, 0);
|
||||
update_line(current, current_x);
|
||||
} else
|
||||
/* If we're on the last row of the edit window, scroll down one line
|
||||
* if we're in smooth scrolling mode, or down half a page if we're
|
||||
* not. */
|
||||
if (current_y == editwinrows - 1)
|
||||
edit_scroll(DOWN,
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(SMOOTHSCROLL))
|
||||
/* In this case current_y does not change. The cursor remains
|
||||
* at the bottom of the edit window. */
|
||||
edit_update(edittop->next, TOP);
|
||||
else
|
||||
ISSET(SMOOTHSCROLL) ? 1 :
|
||||
#endif
|
||||
edit_update(current, CENTER);
|
||||
editwinrows / 2);
|
||||
|
||||
/* Update the lines left alone by edit_scroll(): the line we were on
|
||||
* before and the line we're on now. The former needs to be redrawn
|
||||
* if we're not on the first page, and the latter needs to be
|
||||
* drawn. */
|
||||
if (need_vertical_update(0))
|
||||
update_line(current->prev, 0);
|
||||
update_line(current, current_x);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_left(void)
|
||||
int do_left(int allow_update)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
if (current_x > 0)
|
||||
current_x--;
|
||||
else if (current != fileage) {
|
||||
@@ -204,12 +268,19 @@ int do_left(void)
|
||||
}
|
||||
placewewant = xplustabs();
|
||||
check_statblank();
|
||||
update_line(current, current_x);
|
||||
if (allow_update && need_horizontal_update(old_pww))
|
||||
update_line(current, current_x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_right(void)
|
||||
int do_left_void(void)
|
||||
{
|
||||
return do_left(TRUE);
|
||||
}
|
||||
|
||||
int do_right(int allow_update)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
assert(current_x <= strlen(current->data));
|
||||
|
||||
if (current->data[current_x] != '\0')
|
||||
@@ -220,6 +291,12 @@ int do_right(void)
|
||||
}
|
||||
placewewant = xplustabs();
|
||||
check_statblank();
|
||||
update_line(current, current_x);
|
||||
if (allow_update && need_horizontal_update(old_pww))
|
||||
update_line(current, current_x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_right_void(void)
|
||||
{
|
||||
return do_right(TRUE);
|
||||
}
|
||||
|
||||
1602
src/nano.c
1602
src/nano.c
File diff suppressed because it is too large
Load Diff
126
src/nano.h
126
src/nano.h
@@ -54,9 +54,10 @@
|
||||
#endif
|
||||
|
||||
#ifdef USE_SLANG
|
||||
/* Slang support enabled. Work around Slang's not defining KEY_DC or
|
||||
* KEY_IC. */
|
||||
/* Slang support enabled. */
|
||||
#include <slcurses.h>
|
||||
/* Slang curses emulation brain damage, part 2: Slang doesn't define the
|
||||
* curses equivalents of the Insert or Delete keys. */
|
||||
#define KEY_DC SL_KEY_DELETE
|
||||
#define KEY_IC SL_KEY_IC
|
||||
#elif defined(HAVE_NCURSES_H)
|
||||
@@ -91,7 +92,12 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If no strcasecmp()/strncasecmp(), use the versions we have. */
|
||||
/* If no isblank(), strcasecmp(), strncasecmp(), strcasestr(), or
|
||||
* strnlen(), use the versions we have. */
|
||||
#ifndef HAVE_ISBLANK
|
||||
#define isblank is_blank_char
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
#define strcasecmp nstricmp
|
||||
#endif
|
||||
@@ -100,39 +106,19 @@
|
||||
#define strncasecmp nstrnicmp
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASESTR
|
||||
#define strcasestr nstristr
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
#define strnlen nstrnlen
|
||||
#endif
|
||||
|
||||
/* Assume ERR is defined as -1. To avoid duplicate case values when
|
||||
* 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. */
|
||||
#ifndef KEY_HOME
|
||||
#define KEY_HOME -2
|
||||
#endif
|
||||
|
||||
#ifndef KEY_END
|
||||
#define KEY_END -3
|
||||
#endif
|
||||
|
||||
/* 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, KEY_SLEFT, or
|
||||
* KEY_SRIGHT. */
|
||||
#ifndef KEY_SUSPEND
|
||||
#define KEY_SUSPEND -5
|
||||
#endif
|
||||
|
||||
#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
|
||||
@@ -267,35 +253,36 @@ typedef struct historyheadtype {
|
||||
/* 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)
|
||||
#define MARK_ISSET (1<<3)
|
||||
#define CONSTUPDATE (1<<4)
|
||||
#define NO_HELP (1<<5)
|
||||
#define NOFOLLOW_SYMLINKS (1<<6)
|
||||
#define SUSPEND (1<<7)
|
||||
#define NO_WRAP (1<<8)
|
||||
#define AUTOINDENT (1<<9)
|
||||
#define VIEW_MODE (1<<10)
|
||||
#define USE_MOUSE (1<<11)
|
||||
#define USE_REGEXP (1<<12)
|
||||
#define REGEXP_COMPILED (1<<13)
|
||||
#define TEMP_OPT (1<<14)
|
||||
#define CUT_TO_END (1<<15)
|
||||
#define REVERSE_SEARCH (1<<16)
|
||||
#define MULTIBUFFER (1<<17)
|
||||
#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 REBIND_DELETE (1<<22)
|
||||
#define NO_CONVERT (1<<23)
|
||||
#define BACKUP_FILE (1<<24)
|
||||
#define NO_RCFILE (1<<25)
|
||||
#define COLOR_SYNTAX (1<<26)
|
||||
#define PRESERVE (1<<27)
|
||||
#define HISTORY_CHANGED (1<<28)
|
||||
#define HISTORYLOG (1<<29)
|
||||
#define CASE_SENSITIVE (1<<1)
|
||||
#define MARK_ISSET (1<<2)
|
||||
#define CONSTUPDATE (1<<3)
|
||||
#define NO_HELP (1<<4)
|
||||
#define NOFOLLOW_SYMLINKS (1<<5)
|
||||
#define SUSPEND (1<<6)
|
||||
#define NO_WRAP (1<<7)
|
||||
#define AUTOINDENT (1<<8)
|
||||
#define VIEW_MODE (1<<9)
|
||||
#define USE_MOUSE (1<<10)
|
||||
#define USE_REGEXP (1<<11)
|
||||
#define TEMP_OPT (1<<12)
|
||||
#define CUT_TO_END (1<<13)
|
||||
#define REVERSE_SEARCH (1<<14)
|
||||
#define MULTIBUFFER (1<<15)
|
||||
#define DOS_FILE (1<<16)
|
||||
#define MAC_FILE (1<<17)
|
||||
#define SMOOTHSCROLL (1<<18)
|
||||
#define DISABLE_CURPOS (1<<19) /* Damn, we still need it. */
|
||||
#define REBIND_DELETE (1<<20)
|
||||
#define NO_CONVERT (1<<21)
|
||||
#define BACKUP_FILE (1<<22)
|
||||
#define NO_RCFILE (1<<23)
|
||||
#define COLOR_SYNTAX (1<<24)
|
||||
#define PRESERVE (1<<25)
|
||||
#define HISTORY_CHANGED (1<<26)
|
||||
#define HISTORYLOG (1<<27)
|
||||
#define RESTRICTED (1<<28)
|
||||
#define SMART_HOME (1<<29)
|
||||
#define WHITESPACE_DISPLAY (1<<30)
|
||||
|
||||
/* Control key sequences, changing these would be very very bad. */
|
||||
#define NANO_CONTROL_SPACE 0
|
||||
@@ -366,13 +353,13 @@ typedef struct historyheadtype {
|
||||
#define NANO_ALT_SPACE ' '
|
||||
|
||||
/* Some semi-changeable keybindings; don't play with these unless you're
|
||||
* sure you know what you're doing. */
|
||||
* sure you know what you're doing. Assume ERR is defined as -1. */
|
||||
|
||||
/* No key at all. */
|
||||
#define NANO_NO_KEY -8
|
||||
#define NANO_NO_KEY -2
|
||||
|
||||
/* Special sentinel key used for search string history. */
|
||||
#define NANO_HISTORY_KEY -9
|
||||
/* Special sentinel key used for search/replace history. */
|
||||
#define NANO_HISTORY_KEY -3
|
||||
|
||||
/* Normal keys. */
|
||||
#define NANO_INSERTFILE_KEY NANO_CONTROL_R
|
||||
@@ -442,6 +429,7 @@ typedef struct historyheadtype {
|
||||
#define NANO_PREVWORD_KEY NANO_ALT_SPACE
|
||||
#define NANO_PARABEGIN_KEY NANO_CONTROL_W
|
||||
#define NANO_PARAEND_KEY NANO_CONTROL_O
|
||||
#define NANO_FULLJUSTIFY_KEY NANO_CONTROL_J
|
||||
#define NANO_VERBATIM_KEY NANO_ALT_V
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
@@ -463,6 +451,8 @@ typedef struct historyheadtype {
|
||||
#define TOGGLE_NOCONVERT_KEY NANO_ALT_N
|
||||
#define TOGGLE_BACKUP_KEY NANO_ALT_B
|
||||
#define TOGGLE_SYNTAX_KEY NANO_ALT_Y
|
||||
#define TOGGLE_SMARTHOME_KEY NANO_ALT_H
|
||||
#define TOGGLE_WHITESPACE_KEY NANO_ALT_P
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
#define MAIN_VISIBLE 12
|
||||
@@ -470,6 +460,14 @@ typedef struct historyheadtype {
|
||||
#define VIEW 1
|
||||
#define NOVIEW 0
|
||||
|
||||
typedef enum {
|
||||
JUSTIFY, BEGIN, END
|
||||
} justbegend;
|
||||
|
||||
typedef enum {
|
||||
UP, DOWN
|
||||
} updown;
|
||||
|
||||
typedef enum {
|
||||
TOP, CENTER, NONE
|
||||
} topmidnone;
|
||||
|
||||
163
src/proto.h
163
src/proto.h
@@ -46,7 +46,13 @@ extern int search_last_line;
|
||||
extern int search_offscreen;
|
||||
extern int currslen;
|
||||
|
||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||
extern char *whitespace;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
extern char *punct;
|
||||
extern char *brackets;
|
||||
extern char *quotestr;
|
||||
#endif
|
||||
|
||||
@@ -54,7 +60,7 @@ extern char *quotestr;
|
||||
extern char *backup_dir;
|
||||
#endif
|
||||
|
||||
extern WINDOW *edit, *topwin, *bottomwin;
|
||||
extern WINDOW *topwin, *edit, *bottomwin;
|
||||
extern char *filename;
|
||||
extern struct stat originalfilestat;
|
||||
extern char *answer;
|
||||
@@ -114,10 +120,10 @@ extern const shortcut *currshortcut;
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
extern regex_t search_regexp;
|
||||
extern regmatch_t regmatches[10];
|
||||
extern regmatch_t regmatches[10];
|
||||
#ifdef ENABLE_COLOR
|
||||
extern regex_t syntaxfile_regexp;
|
||||
extern regmatch_t synfilematches[1];
|
||||
extern regmatch_t synfilematches[1];
|
||||
#endif /* ENABLE_COLOR */
|
||||
#endif /* HAVE_REGEX_H */
|
||||
|
||||
@@ -142,6 +148,7 @@ void update_color(void);
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
/* Public functions in cut.c */
|
||||
void cutbuffer_reset(void);
|
||||
filestruct *get_cutbottom(void);
|
||||
void add_to_cutbuffer(filestruct *inptr, int allow_concat);
|
||||
void cut_marked_segment(void);
|
||||
@@ -151,7 +158,8 @@ int do_uncut_text(void);
|
||||
/* Public functions in files.c */
|
||||
void load_file(int update);
|
||||
void new_file(void);
|
||||
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, int len);
|
||||
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, size_t
|
||||
len);
|
||||
int read_file(FILE *f, const char *filename, int quiet);
|
||||
int open_file(const char *filename, int insert, int quiet);
|
||||
char *get_next_filename(const char *name);
|
||||
@@ -187,8 +195,7 @@ void init_backup_dir(void);
|
||||
#endif
|
||||
int write_file(const char *name, int tmp, int append, int nonamechange);
|
||||
#ifndef NANO_SMALL
|
||||
int write_marked(const char *name, int tmp, int append, int
|
||||
nonamechange);
|
||||
int write_marked(const char *name, int tmp, int append);
|
||||
#endif
|
||||
int do_writeout(int exiting);
|
||||
int do_writeout_void(void);
|
||||
@@ -199,12 +206,10 @@ char **username_tab_completion(char *buf, int *num_matches);
|
||||
char **cwd_tab_completion(char *buf, int *num_matches);
|
||||
char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list);
|
||||
#endif
|
||||
#if !defined(DISABLE_BROWSER) || !defined(NANO_SMALL)
|
||||
const char *tail(const char *foo);
|
||||
#endif
|
||||
#ifndef DISABLE_BROWSER
|
||||
int diralphasort(const void *va, const void *vb);
|
||||
void free_charptrarray(char **array, int len);
|
||||
void free_charptrarray(char **array, size_t len);
|
||||
void striponedir(char *foo);
|
||||
int readable_dir(const char *path);
|
||||
char **browser_init(const char *path, int *longest, int *numents);
|
||||
@@ -234,17 +239,21 @@ void thanks_for_all_the_fish(void);
|
||||
#endif
|
||||
|
||||
/* Public functions in move.c */
|
||||
int do_first_line(void);
|
||||
int do_last_line(void);
|
||||
int do_home(void);
|
||||
int do_end(void);
|
||||
int do_page_up(void);
|
||||
int do_page_down(void);
|
||||
int do_up(void);
|
||||
int do_down(void);
|
||||
int do_left(void);
|
||||
int do_right(void);
|
||||
int do_left(int allow_update);
|
||||
int do_left_void(void);
|
||||
int do_right(int allow_update);
|
||||
int do_right_void(void);
|
||||
|
||||
/* Public functions in nano.c */
|
||||
RETSIGTYPE finish(int sigage);
|
||||
void finish(void);
|
||||
void die(const char *msg, ...);
|
||||
void die_save_file(const char *die_filename);
|
||||
void die_too_small(void);
|
||||
@@ -270,11 +279,8 @@ void print1opt(const char *shortflag, const char *longflag,
|
||||
const char *desc);
|
||||
void usage(void);
|
||||
void version(void);
|
||||
void do_early_abort(void);
|
||||
int no_help(void);
|
||||
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || defined(DISABLE_HELP) || defined(NANO_SMALL)
|
||||
void nano_disabled_msg(void);
|
||||
#endif
|
||||
int nano_disabled_msg(void);
|
||||
#ifndef NANO_SMALL
|
||||
RETSIGTYPE cancel_fork(int signal);
|
||||
int open_pipe(const char *command);
|
||||
@@ -291,23 +297,23 @@ int do_enter(void);
|
||||
#ifndef NANO_SMALL
|
||||
int do_next_word(void);
|
||||
int do_prev_word(void);
|
||||
#endif
|
||||
int do_mark(void);
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPPING
|
||||
void wrap_reset(void);
|
||||
int do_wrap(filestruct *inptr);
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
int do_int_spell_fix(const char *word);
|
||||
char *do_int_speller(char *tempfile_name);
|
||||
char *do_alt_speller(char *tempfile_name);
|
||||
#endif
|
||||
const char *do_int_speller(char *tempfile_name);
|
||||
const char *do_alt_speller(char *tempfile_name);
|
||||
int do_spell(void);
|
||||
#endif
|
||||
#if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
|
||||
size_t indent_length(const char *line);
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
int justify_format(int changes_allowed, filestruct *line, size_t skip);
|
||||
void justify_format(filestruct *line, size_t skip);
|
||||
#ifdef HAVE_REGEX_H
|
||||
size_t quote_length(const char *line, const regex_t *qreg);
|
||||
#else
|
||||
@@ -318,20 +324,22 @@ size_t quote_length(const char *line);
|
||||
#else
|
||||
# define IFREG(a, b) a
|
||||
#endif
|
||||
int quotes_match(const char *a_line, size_t a_quote,
|
||||
IFREG(const char *b_line, const regex_t *qreg));
|
||||
size_t indents_match(const char *a_line, size_t a_indent,
|
||||
const char *b_line, size_t b_indent);
|
||||
filestruct *backup_lines(filestruct *first_line, size_t par_len,
|
||||
size_t quote_len);
|
||||
int quotes_match(const char *a_line, size_t a_quote, IFREG(const char
|
||||
*b_line, const regex_t *qreg));
|
||||
size_t indents_match(const char *a_line, size_t a_indent, const char
|
||||
*b_line, size_t b_indent);
|
||||
filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
|
||||
quote_len);
|
||||
int breakable(const char *line, int goal);
|
||||
int break_line(const char *line, int goal, int force);
|
||||
int do_para_search(int search_type, size_t *quote, size_t *par, size_t
|
||||
*indent, int do_refresh);
|
||||
int do_para_search(justbegend search_type, size_t *quote, size_t *par,
|
||||
size_t *indent, int do_refresh);
|
||||
int do_para_begin(void);
|
||||
int do_para_end(void);
|
||||
int do_justify(int justify_all);
|
||||
int do_justify_void(void);
|
||||
int do_full_justify(void);
|
||||
#endif /* !DISABLE_JUSTIFY */
|
||||
int do_justify(void);
|
||||
int do_exit(void);
|
||||
void signal_init(void);
|
||||
RETSIGTYPE handle_hupterm(int signal);
|
||||
@@ -341,10 +349,17 @@ RETSIGTYPE do_cont(int signal);
|
||||
void handle_sigwinch(int s);
|
||||
void allow_pending_sigwinch(int allow);
|
||||
#endif
|
||||
void print_numlock_warning(void);
|
||||
#ifndef NANO_SMALL
|
||||
void do_toggle(const toggle *which);
|
||||
#endif
|
||||
#if !defined(NANO_SMALL) || defined(USE_SLANG)
|
||||
void disable_signals(void);
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
void enable_signals(void);
|
||||
#endif
|
||||
void disable_flow_control(void);
|
||||
void enable_flow_control(void);
|
||||
|
||||
/* Public functions in rcfile.c */
|
||||
#ifdef ENABLE_NANORC
|
||||
@@ -377,7 +392,9 @@ int is_whole_word(int curr_pos, const char *datastr, const char
|
||||
int findnextstr(int can_display_wrap, int wholeword, const filestruct
|
||||
*begin, size_t beginx, const char *needle, int no_sameline);
|
||||
int do_search(void);
|
||||
#ifndef NANO_SMALL
|
||||
int do_research(void);
|
||||
#endif
|
||||
void replace_abort(void);
|
||||
#ifdef HAVE_REGEX_H
|
||||
int replace_regexp(char *string, int create_flag);
|
||||
@@ -403,7 +420,7 @@ char *get_history_newer(historyheadtype *h);
|
||||
char *get_history_completion(historyheadtype *h, char *s);
|
||||
void free_history(historyheadtype *h);
|
||||
#ifdef ENABLE_NANORC
|
||||
void load_history(void);
|
||||
void load_history(void);
|
||||
void save_history(void);
|
||||
#endif
|
||||
#endif
|
||||
@@ -416,6 +433,9 @@ int regexec_safe(const regex_t *preg, const char *string, size_t nmatch,
|
||||
#endif
|
||||
int regexp_bol_or_eol(const regex_t *preg, const char *string);
|
||||
#endif
|
||||
#ifndef HAVE_ISBLANK
|
||||
int is_blank_char(int c);
|
||||
#endif
|
||||
int is_cntrl_char(int c);
|
||||
int num_of_digits(int n);
|
||||
void align(char **strp);
|
||||
@@ -428,13 +448,18 @@ int nstricmp(const char *s1, const char *s2);
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
int nstrnicmp(const char *s1, const char *s2, size_t n);
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
const char *revstrstr(const char *haystack, const char *needle,
|
||||
const char *rev_start);
|
||||
const char *revstristr(const char *haystack, const char *needle,
|
||||
const char *rev_start);
|
||||
#ifndef HAVE_STRCASESTR
|
||||
const char *nstristr(const char *haystack, const char *needle);
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
const char *revstrstr(const char *haystack, const char *needle, const
|
||||
char *rev_start);
|
||||
const char *revstristr(const char *haystack, const char *needle, const
|
||||
char *rev_start);
|
||||
#endif
|
||||
#ifndef HAVE_STRNLEN
|
||||
size_t nstrnlen(const char *s, size_t maxlen);
|
||||
#endif
|
||||
const char *stristr(const char *haystack, const char *needle);
|
||||
const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
const char *start);
|
||||
void nperror(const char *s);
|
||||
@@ -451,30 +476,45 @@ int check_wildcard_match(const char *text, const char *pattern);
|
||||
#endif
|
||||
|
||||
/* Public functions in winio.c */
|
||||
#ifndef NANO_SMALL
|
||||
void reset_kbinput(void);
|
||||
#endif
|
||||
int get_kbinput(WINDOW *win, int *meta_key);
|
||||
int *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_key);
|
||||
int get_ascii_kbinput(WINDOW *win, int kbinput);
|
||||
int get_escape_seq_kbinput(WINDOW *win, int *escape_seq, int
|
||||
escape_seq_len);
|
||||
int get_translated_kbinput(int kbinput, int *es
|
||||
#ifndef NANO_SMALL
|
||||
, int reset
|
||||
#endif
|
||||
);
|
||||
int get_ascii_kbinput(int kbinput, size_t ascii_digits
|
||||
#ifndef NANO_SMALL
|
||||
, int reset
|
||||
#endif
|
||||
);
|
||||
int get_control_kbinput(int kbinput);
|
||||
int get_escape_seq_kbinput(int *escape_seq, size_t es_len, int
|
||||
*ignore_seq);
|
||||
int get_escape_seq_abcd(int kbinput);
|
||||
int *get_verbatim_kbinput(WINDOW *win, int *verbatim_kbinput, size_t
|
||||
*verbatim_len, int allow_ascii);
|
||||
int get_untranslated_kbinput(int kbinput, size_t position, int
|
||||
allow_ascii
|
||||
#ifndef NANO_SMALL
|
||||
, int reset
|
||||
#endif
|
||||
);
|
||||
#ifndef DISABLE_MOUSE
|
||||
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);
|
||||
#endif
|
||||
size_t xplustabs(void);
|
||||
size_t actual_x(const char *str, size_t xplus);
|
||||
size_t strnlenpt(const char *buf, size_t size);
|
||||
size_t strlenpt(const char *buf);
|
||||
void blank_bottombars(void);
|
||||
void blank_bottomwin(void);
|
||||
void blank_titlebar(void);
|
||||
void blank_edit(void);
|
||||
void blank_statusbar(void);
|
||||
void blank_statusbar_refresh(void);
|
||||
void check_statblank(void);
|
||||
char *display_string(const char *buf, size_t start_col, int len);
|
||||
void blank_bottombars(void);
|
||||
char *display_string(const char *buf, size_t start_col, size_t len);
|
||||
void nanoget_repaint(const char *buf, const char *inputbuf, size_t x);
|
||||
int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
#ifndef NANO_SMALL
|
||||
@@ -485,24 +525,24 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
, int *list
|
||||
#endif
|
||||
);
|
||||
void set_modified(void);
|
||||
void titlebar(const char *path);
|
||||
void set_modified(void);
|
||||
void statusbar(const char *msg, ...);
|
||||
void bottombars(const shortcut *s);
|
||||
void onekey(const char *keystroke, const char *desc, int len);
|
||||
void onekey(const char *keystroke, const char *desc, size_t len);
|
||||
#ifndef NDEBUG
|
||||
int check_linenumbers(const filestruct *fileptr);
|
||||
#endif
|
||||
size_t get_page_start(size_t column);
|
||||
void reset_cursor(void);
|
||||
void add_marked_sameline(int begin, int end, filestruct *fileptr, int y,
|
||||
int virt_cur_x, int this_page);
|
||||
void edit_add(const filestruct *fileptr, const char *converted,
|
||||
int yval, size_t start);
|
||||
void edit_add(const filestruct *fileptr, const char *converted, int
|
||||
yval, size_t start);
|
||||
void update_line(const filestruct *fileptr, size_t index);
|
||||
void update_cursor(void);
|
||||
void center_cursor(void);
|
||||
int need_horizontal_update(int old_placewewant);
|
||||
int need_vertical_update(int old_placewewant);
|
||||
void edit_scroll(updown direction, int nlines);
|
||||
void edit_redraw(const filestruct *old_current, int old_pww);
|
||||
void edit_refresh(void);
|
||||
void edit_refresh_clearok(void);
|
||||
void edit_update(filestruct *fileptr, topmidnone location);
|
||||
int statusq(int allowtabs, const shortcut *s, const char *def,
|
||||
#ifndef NANO_SMALL
|
||||
@@ -512,7 +552,6 @@ int statusq(int allowtabs, const shortcut *s, const char *def,
|
||||
int do_yesno(int all, const char *msg);
|
||||
int total_refresh(void);
|
||||
void display_main_list(void);
|
||||
void statusbar(const char *msg, ...);
|
||||
int do_cursorpos(int constant);
|
||||
int do_cursorpos_void(void);
|
||||
int line_len(const char *ptr);
|
||||
|
||||
70
src/rcfile.c
70
src/rcfile.c
@@ -31,6 +31,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
@@ -42,6 +43,9 @@ const static rcoption rcopts[] = {
|
||||
{"autoindent", AUTOINDENT},
|
||||
{"backup", BACKUP_FILE},
|
||||
{"backupdir", 0},
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
{"brackets", 0},
|
||||
#endif
|
||||
{"const", CONSTUPDATE},
|
||||
#ifndef NANO_SMALL
|
||||
@@ -71,14 +75,16 @@ const static rcoption rcopts[] = {
|
||||
{"operatingdir", 0},
|
||||
#endif
|
||||
{"preserve", PRESERVE},
|
||||
{"rebinddelete", REBIND_DELETE},
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
{"punct", 0},
|
||||
{"quotestr", 0},
|
||||
#endif
|
||||
{"rebinddelete", REBIND_DELETE},
|
||||
#ifdef HAVE_REGEX_H
|
||||
{"regexp", USE_REGEXP},
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTHSCROLL},
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
@@ -88,6 +94,9 @@ const static rcoption rcopts[] = {
|
||||
{"tabsize", 0},
|
||||
{"tempfile", TEMP_OPT},
|
||||
{"view", VIEW_MODE},
|
||||
#ifndef NANO_SMALL
|
||||
{"whitespace", 0},
|
||||
#endif
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
@@ -131,7 +140,7 @@ void rcfile_msg(const char *msg, ...)
|
||||
/* Parse the next word from the string. Returns NULL if we hit EOL. */
|
||||
char *parse_next_word(char *ptr)
|
||||
{
|
||||
while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n' && *ptr != '\0')
|
||||
while (!isblank(*ptr) && *ptr != '\n' && *ptr != '\0')
|
||||
ptr++;
|
||||
|
||||
if (*ptr == '\0')
|
||||
@@ -140,15 +149,16 @@ char *parse_next_word(char *ptr)
|
||||
/* Null terminate and advance ptr */
|
||||
*ptr++ = 0;
|
||||
|
||||
while (*ptr == ' ' || *ptr == '\t')
|
||||
while (isblank(*ptr))
|
||||
ptr++;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* The keywords operatingdir, backupdir, fill, tabsize, speller, and
|
||||
* quotestr take an argument when set. Among these, operatingdir,
|
||||
* backupdir, speller, and quotestr have to allow tabs and spaces in the
|
||||
/* The keywords operatingdir, backupdir, fill, tabsize, speller,
|
||||
* punct, brackets, quotestr, and whitespace take an argument when set.
|
||||
* Among these, operatingdir, backupdir, speller, punct, brackets,
|
||||
* quotestr, and whitespace have to allow tabs and spaces in the
|
||||
* argument. Thus, if the next word starts with a ", we say it ends
|
||||
* with the last " of the line. Otherwise, the word is interpreted as
|
||||
* usual. That is so the arguments can contain "s too. */
|
||||
@@ -179,7 +189,7 @@ char *parse_argument(char *ptr)
|
||||
ptr = last_quote + 1;
|
||||
}
|
||||
if (ptr != NULL)
|
||||
while (*ptr == ' ' || *ptr == '\t')
|
||||
while (isblank(*ptr))
|
||||
ptr++;
|
||||
return ptr;
|
||||
}
|
||||
@@ -237,7 +247,7 @@ char *parse_next_regex(char *ptr)
|
||||
/* Null terminate and advance ptr. */
|
||||
*ptr++ = '\0';
|
||||
|
||||
while (*ptr == ' ' || *ptr == '\t')
|
||||
while (isblank(*ptr))
|
||||
ptr++;
|
||||
|
||||
return ptr;
|
||||
@@ -326,7 +336,7 @@ void parse_syntax(char *ptr)
|
||||
ptr = parse_next_regex(ptr);
|
||||
|
||||
newext = (exttype *)nmalloc(sizeof(exttype));
|
||||
if (nregcomp(&newext->val, fileregptr, REG_NOSUB))
|
||||
if (nregcomp(&newext->val, fileregptr, REG_NOSUB) != 0)
|
||||
free(newext);
|
||||
else {
|
||||
if (endext == NULL)
|
||||
@@ -413,7 +423,7 @@ void parse_colors(char *ptr)
|
||||
newcolor = (colortype *)nmalloc(sizeof(colortype));
|
||||
fgstr = ptr;
|
||||
ptr = parse_next_regex(ptr);
|
||||
if (nregcomp(&newcolor->start, fgstr, 0)) {
|
||||
if (nregcomp(&newcolor->start, fgstr, 0) != 0) {
|
||||
free(newcolor);
|
||||
cancelled = 1;
|
||||
} else {
|
||||
@@ -464,7 +474,7 @@ void parse_colors(char *ptr)
|
||||
if (cancelled)
|
||||
continue;
|
||||
newcolor->end = (regex_t *)nmalloc(sizeof(regex_t));
|
||||
if (nregcomp(newcolor->end, fgstr, 0)) {
|
||||
if (nregcomp(newcolor->end, fgstr, 0) != 0) {
|
||||
free(newcolor->end);
|
||||
newcolor->end = NULL;
|
||||
}
|
||||
@@ -484,7 +494,7 @@ void parse_rcfile(FILE *rcstream)
|
||||
while (fgets(buf, 1023, rcstream) != 0) {
|
||||
lineno++;
|
||||
ptr = buf;
|
||||
while (*ptr == ' ' || *ptr == '\t')
|
||||
while (isblank(*ptr))
|
||||
ptr++;
|
||||
|
||||
if (*ptr == '\n' || *ptr == '\0')
|
||||
@@ -538,7 +548,12 @@ void parse_rcfile(FILE *rcstream)
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
|| !strcasecmp(rcopts[i].name, "fill")
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
|| !strcasecmp(rcopts[i].name, "whitespace")
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
|| !strcasecmp(rcopts[i].name, "punct")
|
||||
|| !strcasecmp(rcopts[i].name, "brackets")
|
||||
|| !strcasecmp(rcopts[i].name, "quotestr")
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
@@ -581,8 +596,35 @@ void parse_rcfile(FILE *rcstream)
|
||||
wrap_at = j;
|
||||
} else
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
if (!strcasecmp(rcopts[i].name, "whitespace")) {
|
||||
size_t ws_len;
|
||||
whitespace = mallocstrcpy(NULL, option);
|
||||
ws_len = strlen(whitespace);
|
||||
if (ws_len != 2 || (ws_len == 2 && (is_cntrl_char(whitespace[0]) || is_cntrl_char(whitespace[1])))) {
|
||||
rcfile_error(_("Two non-control characters required"));
|
||||
free(whitespace);
|
||||
whitespace = NULL;
|
||||
} else
|
||||
SET(WHITESPACE_DISPLAY);
|
||||
} else
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
if (!strcasecmp(rcopts[i].name, "quotestr"))
|
||||
if (!strcasecmp(rcopts[i].name, "punct")) {
|
||||
punct = mallocstrcpy(NULL, option);
|
||||
if (strchr(punct, '\t') != NULL || strchr(punct, ' ') != NULL) {
|
||||
rcfile_error(_("Non-tab and non-space characters required"));
|
||||
free(punct);
|
||||
punct = NULL;
|
||||
}
|
||||
} else if (!strcasecmp(rcopts[i].name, "brackets")) {
|
||||
brackets = mallocstrcpy(NULL, option);
|
||||
if (strchr(brackets, '\t') != NULL || strchr(brackets, ' ') != NULL) {
|
||||
rcfile_error(_("Non-tab and non-space characters required"));
|
||||
free(brackets);
|
||||
brackets = NULL;
|
||||
}
|
||||
} else if (!strcasecmp(rcopts[i].name, "quotestr"))
|
||||
quotestr = mallocstrcpy(NULL, option);
|
||||
else
|
||||
#endif
|
||||
@@ -596,7 +638,7 @@ void parse_rcfile(FILE *rcstream)
|
||||
alt_speller = mallocstrcpy(NULL, option);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (!strcasecmp(rcopts[i].name, "tabsize")) {
|
||||
char *first_error;
|
||||
|
||||
/* Using strtol instead of atoi lets us
|
||||
|
||||
129
src/search.c
129
src/search.c
@@ -31,24 +31,39 @@
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
/* Regular expression helper functions */
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
static int regexp_compiled = FALSE;
|
||||
|
||||
/* Regular expression helper functions. */
|
||||
|
||||
/* Compile the given regular expression. Return value 0 means the
|
||||
* expression was invalid, and we wrote an error message on the status
|
||||
* bar. Return value 1 means success. */
|
||||
int regexp_init(const char *regexp)
|
||||
{
|
||||
/* Hmm, perhaps we should check for whether regcomp returns successfully */
|
||||
if (regcomp(&search_regexp, regexp, (ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE)
|
||||
| REG_EXTENDED) != 0)
|
||||
return 0;
|
||||
int rc = regcomp(&search_regexp, regexp, REG_EXTENDED |
|
||||
(ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE));
|
||||
|
||||
SET(REGEXP_COMPILED);
|
||||
assert(!regexp_compiled);
|
||||
if (rc != 0) {
|
||||
size_t len = regerror(rc, &search_regexp, NULL, 0);
|
||||
char *str = charalloc(len);
|
||||
|
||||
regerror(rc, &search_regexp, str, len);
|
||||
statusbar(_("Bad regex \"%s\": %s"), regexp, str);
|
||||
free(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
regexp_compiled = TRUE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void regexp_cleanup(void)
|
||||
{
|
||||
if (ISSET(REGEXP_COMPILED)) {
|
||||
UNSET(REGEXP_COMPILED);
|
||||
if (regexp_compiled) {
|
||||
regexp_compiled = FALSE;
|
||||
regfree(&search_regexp);
|
||||
}
|
||||
}
|
||||
@@ -56,15 +71,18 @@ void regexp_cleanup(void)
|
||||
|
||||
void not_found_msg(const char *str)
|
||||
{
|
||||
if (strlen(str) <= COLS / 2)
|
||||
statusbar(_("\"%s\" not found"), str);
|
||||
else {
|
||||
char *foo = mallocstrcpy(NULL, str);
|
||||
char *disp;
|
||||
int numchars;
|
||||
|
||||
assert(str != NULL);
|
||||
|
||||
foo[COLS / 2] = '\0';
|
||||
statusbar(_("\"%s...\" not found"), foo);
|
||||
free(foo);
|
||||
}
|
||||
disp = display_string(str, 0, (COLS / 2) + 1);
|
||||
numchars = strnlen(disp, COLS / 2);
|
||||
|
||||
statusbar(_("\"%.*s%s\" not found"), numchars, disp,
|
||||
disp[numchars] == '\0' ? "" : "...");
|
||||
|
||||
free(disp);
|
||||
}
|
||||
|
||||
void search_abort(void)
|
||||
@@ -150,9 +168,12 @@ int search_init(int replacing)
|
||||
#endif
|
||||
"",
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* This string is just a modifier for the search prompt; no
|
||||
* grammar is implied. */
|
||||
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
|
||||
ISSET(USE_REGEXP) ? _(" [Regexp]") :
|
||||
#endif
|
||||
"",
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* This string is just a modifier for the search prompt; no
|
||||
@@ -174,7 +195,6 @@ int search_init(int replacing)
|
||||
if (i == -1 || (i < 0 && last_search[0] == '\0') ||
|
||||
(!replacing && i == 0 && answer[0] == '\0')) {
|
||||
statusbar(_("Search Cancelled"));
|
||||
reset_cursor();
|
||||
#ifndef NANO_SMALL
|
||||
search_history.current = search_history.next;
|
||||
#endif
|
||||
@@ -184,21 +204,15 @@ int search_init(int replacing)
|
||||
case -2: /* It's the same string. */
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Since answer is "", use last_search! */
|
||||
if (ISSET(USE_REGEXP) && regexp_init(last_search) == 0) {
|
||||
statusbar(_("Invalid regex \"%s\""), last_search);
|
||||
reset_cursor();
|
||||
if (ISSET(USE_REGEXP) && regexp_init(last_search) == 0)
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 0: /* They entered something new. */
|
||||
last_replace[0] = '\0';
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP) && regexp_init(answer) == 0) {
|
||||
statusbar(_("Invalid regex \"%s\""), answer);
|
||||
reset_cursor();
|
||||
if (ISSET(USE_REGEXP) && regexp_init(answer) == 0)
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#ifndef NANO_SMALL
|
||||
@@ -311,7 +325,7 @@ int findnextstr(int can_display_wrap, int wholeword, const filestruct
|
||||
|
||||
/* Original start line reached. */
|
||||
if (fileptr == begin)
|
||||
search_last_line = 1;
|
||||
search_last_line = TRUE;
|
||||
rev_start = fileptr->data;
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(REVERSE_SEARCH))
|
||||
@@ -347,9 +361,8 @@ int findnextstr(int can_display_wrap, int wholeword, const filestruct
|
||||
/* Search for a string. */
|
||||
int do_search(void)
|
||||
{
|
||||
int i;
|
||||
int old_pww = placewewant, i, fileptr_x = current_x, didfind;
|
||||
filestruct *fileptr = current;
|
||||
int fileptr_x = current_x, didfind;
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
@@ -382,10 +395,8 @@ int do_search(void)
|
||||
update_history(&search_history, answer);
|
||||
#endif
|
||||
|
||||
search_last_line = 0;
|
||||
search_last_line = FALSE;
|
||||
didfind = findnextstr(TRUE, FALSE, current, current_x, answer, FALSE);
|
||||
edit_refresh();
|
||||
placewewant = xplustabs();
|
||||
|
||||
/* Check to see if there's only one occurrence of the string and
|
||||
* we're on it now. */
|
||||
@@ -408,16 +419,19 @@ int do_search(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
placewewant = xplustabs();
|
||||
edit_redraw(fileptr, old_pww);
|
||||
search_abort();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
/* Search for the next string without prompting. */
|
||||
int do_research(void)
|
||||
{
|
||||
int old_pww = placewewant, fileptr_x = current_x, didfind;
|
||||
filestruct *fileptr = current;
|
||||
int fileptr_x = current_x, didfind;
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
@@ -428,17 +442,12 @@ int do_research(void)
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Since answer is "", use last_search! */
|
||||
if (ISSET(USE_REGEXP) && regexp_init(last_search) == 0) {
|
||||
statusbar(_("Invalid regex \"%s\""), last_search);
|
||||
reset_cursor();
|
||||
return -1;
|
||||
}
|
||||
if (ISSET(USE_REGEXP) && regexp_init(last_search) == 0)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
search_last_line = 0;
|
||||
search_last_line = FALSE;
|
||||
didfind = findnextstr(TRUE, FALSE, current, current_x, last_search, FALSE);
|
||||
edit_refresh();
|
||||
placewewant = xplustabs();
|
||||
|
||||
/* Check to see if there's only one occurrence of the string and
|
||||
* we're on it now. */
|
||||
@@ -463,10 +472,13 @@ int do_research(void)
|
||||
} else
|
||||
statusbar(_("No current search pattern"));
|
||||
|
||||
placewewant = xplustabs();
|
||||
edit_redraw(fileptr, old_pww);
|
||||
search_abort();
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void replace_abort(void)
|
||||
{
|
||||
@@ -533,7 +545,7 @@ char *replace_line(const char *needle)
|
||||
/* Calculate the size of the new line. */
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||
search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||
new_line_size = replace_regexp(NULL, 0);
|
||||
} else {
|
||||
#endif
|
||||
@@ -575,12 +587,12 @@ char *replace_line(const char *needle)
|
||||
int do_replace_loop(const char *needle, const filestruct *real_current,
|
||||
size_t *real_current_x, int wholewords)
|
||||
{
|
||||
int replaceall = 0, numreplaced = -1;
|
||||
const filestruct *current_save = current;
|
||||
int old_pww = placewewant, replaceall = 0, numreplaced = -1;
|
||||
size_t current_x_save = current_x;
|
||||
const filestruct *current_save = current;
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* The starting-line match and bol/eol regex flags. */
|
||||
int begin_line = 0, bol_or_eol = 0;
|
||||
int begin_line = FALSE, bol_or_eol = FALSE;
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
int mark_set = ISSET(MARK_ISSET);
|
||||
@@ -617,12 +629,13 @@ int do_replace_loop(const char *needle, const filestruct *real_current,
|
||||
* continue. */
|
||||
else {
|
||||
if (current == real_current)
|
||||
begin_line = 1;
|
||||
bol_or_eol = 0;
|
||||
begin_line = TRUE;
|
||||
bol_or_eol = FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
edit_refresh();
|
||||
if (!replaceall)
|
||||
edit_redraw(current_save, old_pww);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
@@ -660,7 +673,7 @@ int do_replace_loop(const char *needle, const filestruct *real_current,
|
||||
* replace ("^", "$", or "^$"). */
|
||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
||||
needle))
|
||||
bol_or_eol = 1;
|
||||
bol_or_eol = TRUE;
|
||||
#endif
|
||||
|
||||
if (i > 0 || replaceall) { /* Yes, replace it!!!! */
|
||||
@@ -703,7 +716,15 @@ int do_replace_loop(const char *needle, const filestruct *real_current,
|
||||
free(current->data);
|
||||
current->data = copy;
|
||||
|
||||
edit_refresh();
|
||||
if (!replaceall) {
|
||||
#ifdef ENABLE_COLOR
|
||||
if (ISSET(COLOR_SYNTAX))
|
||||
edit_refresh();
|
||||
else
|
||||
#endif
|
||||
update_line(current, current_x);
|
||||
}
|
||||
|
||||
set_modified();
|
||||
numreplaced++;
|
||||
}
|
||||
@@ -884,7 +905,7 @@ int do_find_bracket(void)
|
||||
char ch_under_cursor, wanted_ch;
|
||||
const char *pos, *brackets = "([{<>}])";
|
||||
char regexp_pat[] = "[ ]";
|
||||
int flagsave, current_x_save, count = 1;
|
||||
int old_pww = placewewant, current_x_save, flagsave, count = 1;
|
||||
filestruct *current_save;
|
||||
|
||||
ch_under_cursor = current->data[current_x];
|
||||
@@ -918,9 +939,9 @@ int do_find_bracket(void)
|
||||
|
||||
regexp_init(regexp_pat);
|
||||
/* We constructed regexp_pat to be a valid expression. */
|
||||
assert(ISSET(REGEXP_COMPILED));
|
||||
assert(regexp_compiled);
|
||||
|
||||
search_last_line = 0;
|
||||
search_last_line = FALSE;
|
||||
while (TRUE) {
|
||||
if (findnextstr(FALSE, FALSE, current, current_x, regexp_pat, FALSE) != 0) {
|
||||
/* Found identical bracket. */
|
||||
@@ -928,8 +949,8 @@ int do_find_bracket(void)
|
||||
count++;
|
||||
/* Found complementary bracket. */
|
||||
else if (--count == 0) {
|
||||
edit_refresh();
|
||||
placewewant = xplustabs();
|
||||
edit_redraw(current_save, old_pww);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
78
src/utils.c
78
src/utils.c
@@ -52,10 +52,20 @@ int regexp_bol_or_eol(const regex_t *preg, const char *string)
|
||||
}
|
||||
#endif /* HAVE_REGEX_H */
|
||||
|
||||
#ifndef HAVE_ISBLANK
|
||||
/* This function is equivalent to isblank(). */
|
||||
int is_blank_char(int c)
|
||||
{
|
||||
return (c == '\t' || c == ' ');
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function is equivalent to iscntrl(), except in that it also
|
||||
* handles control characters with their high bits set. */
|
||||
int is_cntrl_char(int c)
|
||||
{
|
||||
return (-128 <= c && c < -96) || (0 <= c && c < 32) ||
|
||||
(127 <= c && c < 160);
|
||||
(127 <= c && c < 160);
|
||||
}
|
||||
|
||||
int num_of_digits(int n)
|
||||
@@ -116,10 +126,12 @@ void sunder(char *str)
|
||||
int nstricmp(const char *s1, const char *s2)
|
||||
{
|
||||
assert(s1 != NULL && s2 != NULL);
|
||||
|
||||
for (; *s1 != '\0' && *s2 != '\0'; s1++, s2++) {
|
||||
if (tolower(*s1) != tolower(*s2))
|
||||
break;
|
||||
}
|
||||
|
||||
return (tolower(*s1) - tolower(*s2));
|
||||
}
|
||||
#endif
|
||||
@@ -129,23 +141,47 @@ int nstricmp(const char *s1, const char *s2)
|
||||
int nstrnicmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
assert(s1 != NULL && s2 != NULL);
|
||||
|
||||
for (; n > 0 && *s1 != '\0' && *s2 != '\0'; n--, s1++, s2++) {
|
||||
if (tolower(*s1) != tolower(*s2))
|
||||
break;
|
||||
}
|
||||
|
||||
if (n > 0)
|
||||
return (tolower(*s1) - tolower(*s2));
|
||||
else if (n == 0)
|
||||
return 0;
|
||||
else if (n < 0)
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASESTR
|
||||
/* This function is equivalent to strcasestr(). It was adapted from
|
||||
* mutt's mutt_stristr() function. */
|
||||
const char *nstristr(const char *haystack, const char *needle)
|
||||
{
|
||||
assert(haystack != NULL && needle != NULL);
|
||||
|
||||
for (; *haystack != '\0'; haystack++) {
|
||||
const char *p = haystack;
|
||||
const char *q = needle;
|
||||
|
||||
for (; tolower(*p) == tolower(*q) && *q != '\0'; p++, q++)
|
||||
;
|
||||
|
||||
if (*q == '\0')
|
||||
return haystack;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* None of this is needed if we're using NANO_SMALL! */
|
||||
#ifndef NANO_SMALL
|
||||
const char *revstrstr(const char *haystack, const char *needle,
|
||||
const char *rev_start)
|
||||
const char *revstrstr(const char *haystack, const char *needle, const
|
||||
char *rev_start)
|
||||
{
|
||||
for (; rev_start >= haystack; rev_start--) {
|
||||
const char *r, *q;
|
||||
@@ -158,8 +194,8 @@ const char *revstrstr(const char *haystack, const char *needle,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *revstristr(const char *haystack, const char *needle,
|
||||
const char *rev_start)
|
||||
const char *revstristr(const char *haystack, const char *needle, const
|
||||
char *rev_start)
|
||||
{
|
||||
for (; rev_start >= haystack; rev_start--) {
|
||||
const char *r = rev_start, *q = needle;
|
||||
@@ -173,26 +209,20 @@ const char *revstristr(const char *haystack, const char *needle,
|
||||
}
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
/* This is now mutt's version (called mutt_stristr) because it doesn't
|
||||
* use memory allocation to do a simple search (yuck). */
|
||||
const char *stristr(const char *haystack, const char *needle)
|
||||
#ifndef HAVE_STRNLEN
|
||||
/* This function is equivalent to strnlen(). */
|
||||
size_t nstrnlen(const char *s, size_t maxlen)
|
||||
{
|
||||
const char *p, *q;
|
||||
size_t n = 0;
|
||||
|
||||
if (haystack == NULL)
|
||||
return NULL;
|
||||
if (needle == NULL)
|
||||
return haystack;
|
||||
|
||||
while (*(p = haystack) != '\0') {
|
||||
for (q = needle; *p != 0 && *q != 0 && tolower(*p) == tolower(*q); p++, q++)
|
||||
;
|
||||
if (*q == 0)
|
||||
return haystack;
|
||||
haystack++;
|
||||
}
|
||||
return NULL;
|
||||
assert(s != NULL);
|
||||
|
||||
for (; maxlen > 0 && *s != '\0'; maxlen--, n++, s++)
|
||||
;
|
||||
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we are searching backwards, we will find the last match that
|
||||
* starts no later than start. Otherwise we find the first match
|
||||
@@ -253,7 +283,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
else if (ISSET(REVERSE_SEARCH))
|
||||
return revstristr(haystack, needle, start);
|
||||
#endif
|
||||
return stristr(start, needle);
|
||||
return strcasestr(start, needle);
|
||||
}
|
||||
|
||||
/* This is a wrapper for the perror() function. The wrapper takes care
|
||||
|
||||
2488
src/winio.c
2488
src/winio.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user