Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6718cf209 | ||
|
|
a88347069c | ||
|
|
35fb55aba2 | ||
|
|
c08368bd19 | ||
|
|
b4041d6821 | ||
|
|
95f3812db1 | ||
|
|
a27bd65057 | ||
|
|
bb50b305d5 | ||
|
|
7e8dd19a72 | ||
|
|
df13e3beef | ||
|
|
7dfec43f42 | ||
|
|
69a28122c1 | ||
|
|
76356bd05b | ||
|
|
82dc1c17f2 | ||
|
|
95e39e5f46 | ||
|
|
1e7f1ea1e8 | ||
|
|
6420d445c2 | ||
|
|
049e4a5db3 | ||
|
|
6b24856c2f | ||
|
|
c7b6ac5afe | ||
|
|
00d7798756 | ||
|
|
ce62e82a93 | ||
|
|
73cd1a5ded | ||
|
|
76f63ff58d | ||
|
|
22fac783f5 | ||
|
|
c53ab2a854 | ||
|
|
4d44d2de0e | ||
|
|
8bf9ba0c16 | ||
|
|
76fb3eccda | ||
|
|
b8c479a9e9 | ||
|
|
a6d26d04fd | ||
|
|
906257932f | ||
|
|
9ef3adbc1d | ||
|
|
819c7f0327 | ||
|
|
f56cc9e0e9 | ||
|
|
360093a652 | ||
|
|
86e851b4e7 | ||
|
|
2d140c2980 | ||
|
|
7d3817fb3e | ||
|
|
331e659e98 | ||
|
|
8aaf03000b | ||
|
|
ad1fd0d968 | ||
|
|
1536f8613d | ||
|
|
c41d428b41 | ||
|
|
8037fe076b | ||
|
|
94b975ce7c | ||
|
|
04419b9702 | ||
|
|
36dd87b1fb | ||
|
|
24f10c30c3 | ||
|
|
fd3039a8e7 | ||
|
|
fb8bf40efb | ||
|
|
aea4dabf59 | ||
|
|
300b87fda6 | ||
|
|
49c3f2406d | ||
|
|
576bf331ef | ||
|
|
d717d4bac6 | ||
|
|
0273829353 | ||
|
|
f708037715 | ||
|
|
a5dda84a07 | ||
|
|
0af8604ec9 | ||
|
|
ec721c8e80 | ||
|
|
2ad320926f | ||
|
|
962cc74620 | ||
|
|
25529074d3 | ||
|
|
f7b5d930a9 | ||
|
|
309fbcbddf | ||
|
|
4693864a78 | ||
|
|
01a6bf4f9a | ||
|
|
c8c69d5449 | ||
|
|
edab0cc0a5 | ||
|
|
72e51ab037 | ||
|
|
74912c6090 | ||
|
|
ebd0d7c859 | ||
|
|
0fb841a78a | ||
|
|
cff5558394 | ||
|
|
db357a1ece | ||
|
|
a539fce4ad | ||
|
|
d36715e8ac |
281
ChangeLog
281
ChangeLog
@@ -1,3 +1,284 @@
|
||||
GNU nano 1.3.4 - 2004.08.17
|
||||
- General:
|
||||
- More minor comment cleanups. (DLR)
|
||||
- Convert more ints and functions using 0 and 1 to bools using
|
||||
TRUE and FALSE. (David Benbennick and DLR)
|
||||
- Change more instances of ints that have large enough upper
|
||||
bounds and which can never be negative to size_t's, and
|
||||
convert nano to handle them properly. (DLR)
|
||||
- Convert the shortcut list functions and most related functions
|
||||
to return void instead of int, as the return values of all
|
||||
those functions are essentially unused. Changes to
|
||||
sc_init_one(), shortcut_init(), etc. (David Benbennick and
|
||||
DLR)
|
||||
- Make flags and all variables meant to store the value of flags
|
||||
longs for consistency. (David Benbennick)
|
||||
- Rename the TEMP_OPT flags to TEMP_FILE, as it's more
|
||||
descriptive. (DLR)
|
||||
- Remove unused global variable search_offscreen. (David
|
||||
Benbennick)
|
||||
- Add new N_() macro to mark strings that aren't translated
|
||||
immediately, and convert nano to use it in cases where the
|
||||
translated string is stored in a const char*. Changes
|
||||
to sc_init_one(), print1opt(), help_init(), rcfile_error(),
|
||||
do_credits(), etc. (David Benbennick) DLR: Do this for
|
||||
toggle_init_one() too.
|
||||
- Minor tweaks and clarifications to some option descriptions.
|
||||
(DLR)
|
||||
- Overhaul the shortcut list and toggle list initialization
|
||||
code for efficiency. Changes to shortcut_init() and
|
||||
toggle_init(). (David Benbennick) DLR: Move "Cancel" to just
|
||||
after "Get Help" in the file browser list, for consistency
|
||||
with all the other lists, have the replace list accept all the
|
||||
same function keys as the search list, and clarify a few
|
||||
shortcut descriptions.
|
||||
- Convert nano to use the new parse_num() function to read in
|
||||
numeric values at the command line and in the rcfile, and
|
||||
duplicate the messages used in the rcfile in the command line
|
||||
for consistency. (David Benbennick) DLR: Tweak parse_num() to
|
||||
parse ssize_t values instead of ints and to return a bool
|
||||
indicating whether parsing succeeded. Convert tabsize,
|
||||
wrap_at, and fill to ssize_t in order to work with
|
||||
parse_num() properly and also to increase their capacity
|
||||
while keeping the ability to hold negative numbers in case of
|
||||
errors. Also exit instead of calling usage() in the event of
|
||||
an invalid fill value, for consistency with how an invalid
|
||||
tabsize value is handled. Finally, handle invalid tabsize
|
||||
entries in the rcfile the same way as on the command line,
|
||||
and reset tabsize and wrap_at to their default values if
|
||||
invalid rcfile entries are specified for them.
|
||||
- Remove several unnecessary reset_cursor() calls. (David
|
||||
Benbennick)
|
||||
- Include <sys/types.h> in proto.h. (David Benbennick) DLR:
|
||||
Remove some redundant inclusions of <sys/types.h> elsewhere.
|
||||
- Move the main terminal initialization functions, aside from
|
||||
initscr(), into a new terminal_init() function, and convert
|
||||
nano to use it. (DLR)
|
||||
- Convert placewewant to a size_t, and convert some functions
|
||||
that use it as a parameter to use size_t as well. (David
|
||||
Benbennick and DLR)
|
||||
- Overhaul the paragraph searching code and some of the justify
|
||||
code to clarify it and fix a bug where searches from the
|
||||
previous paragraph would move up too far. Also make
|
||||
quotestr-related variables global so that they only have to be
|
||||
compiled once, and remove the no-longer-needed IFREG() macro.
|
||||
New functions begpar() and inpar(); changes to quote_length(),
|
||||
quotes_match(), do_para_search(), do_para_begin(),
|
||||
do_para_end(), and do_justify(). (David Benbennick)
|
||||
- Readded the errors flag and moved the ending prompt from
|
||||
rcfile_error() to parse_rcfile() so that we only get prompted
|
||||
once for all errors instead of separately for each error.
|
||||
(DLR) David Benbennick: Make sure that no rcfile error
|
||||
messages end in newlines, and show the ending prompt if we
|
||||
can't read the .nano_history file while starting nano.
|
||||
- Don't treat the return value of strn?(case)?cmp() as boolean.
|
||||
(DLR and David Benbennick)
|
||||
- Automatically install a symlink "rnano" pointing to nano.
|
||||
Changes to src/Marefile.am. (DLR)
|
||||
- Move the static int pid to the beginning of nano.c with all
|
||||
the other static variables. (DLR)
|
||||
- Consolidate some if blocks to remove some redundant code.
|
||||
(David Benbennick)
|
||||
- Fix warnings when compiling with ENABLE_NLS undefined and with
|
||||
-the fwritable-strings option. (David Benbennick)
|
||||
- Add various #ifdefs to fix warnings and compilation problems
|
||||
when compiling with every option manually turned on, including
|
||||
NANO_SMALL. (David Benbennick)
|
||||
- Simplify some of the rcfile and statusbar error messages, and
|
||||
make some of them more consistent. (David Benbennick and DLR)
|
||||
- Change some functions to take const char*'s instead of char*'s
|
||||
where possible. (David Benbennick)
|
||||
- Tweak some #ifdefs around indent_length() and references to
|
||||
fill_flag_used to avoid warnings when compiling with
|
||||
--disable-wrapping, --disable-justify, or a combination of the
|
||||
two. (DLR)
|
||||
- Overhaul the routines used to read the rcfiles and history
|
||||
files for efficiency, make them work properly on lines over
|
||||
1023 characters long and on lines containing nulls, and make
|
||||
them properly handle the case where the user's home directory
|
||||
changes in the middle of a session. New functions
|
||||
histfilename() and writehist(); changes to
|
||||
thanks_for_all_the_fish(), load_history(), save_history(), and
|
||||
do_rcfile(). (David Benbennick)
|
||||
- files.c:
|
||||
get_next_filename()
|
||||
- Tweak for efficiency, and add the ".save" suffix to the file
|
||||
here. (David Benbennick)
|
||||
close_open_file()
|
||||
- Tweak to no longer rely on the return values of
|
||||
open_(prev|next)file(). (DLR)
|
||||
write_file()
|
||||
- For consistency with nano 1.2.x and with other editors, make
|
||||
the mode of newly created files 666 instead of 600 before
|
||||
it's modified by the umask. (DLR)
|
||||
do_writeout()
|
||||
- If we're in restricted mode and the current filename isn't
|
||||
blank, we can't change it, so disable tab completion in that
|
||||
case. (DLR)
|
||||
- Fix spacing problem in the "Save Under Different Name"
|
||||
prompt. (DLR)
|
||||
- global.c:
|
||||
shortcut_init()
|
||||
- Fix erroneous #ifdef so that nano compiles with
|
||||
--disable-justify again. (DLR, found by Mike Frysinger)
|
||||
- Change the Cancel shortcut in the file browser to an Exit
|
||||
shortcut, to be more compatible with the current version of
|
||||
Pico. (DLR)
|
||||
thanks_for_all_the_fish()
|
||||
- Delete topwin, edit, and bottomwin. (David Benbennick)
|
||||
- nano.c:
|
||||
die()
|
||||
- Don't add the ".save" suffix to a saved file here anymore,
|
||||
since get_next_filename() does that now. (David Benbennick)
|
||||
die_save_file()
|
||||
- Tweak for efficiency. (David Benbennick)
|
||||
help_init()
|
||||
- Fix the display of the translated key descriptions "Up" and
|
||||
"Space" under all circumstances, and make the help browser
|
||||
work properly when there are fewer than 24 columns available.
|
||||
(David Benbennick)
|
||||
usage()
|
||||
- Don't translate the option strings for -Z/--restricted.
|
||||
(David Benbennick)
|
||||
do_enter()
|
||||
- Don't treat it as a special case when the user presses Enter
|
||||
on the last line of the screen and smooth scrolling is on, for
|
||||
consistency. (DLR)
|
||||
do_alt_speller()
|
||||
- When reloading the newly spell-checked temporary file, call
|
||||
terminal_init() to make sure that all the original terminal
|
||||
settings are restored, as a curses-based alternative spell
|
||||
checker (e.g. aspell) can change them. (DLR)
|
||||
quote_length()
|
||||
- Fix problem where quoted justify wouldn't work if HAVE_REGEX_H
|
||||
wasn't set. (David Benbennick)
|
||||
do_justify()
|
||||
- Add allow_respacing flag, used to indicate when we've moved to
|
||||
the next line after justifying the current line, and only run
|
||||
the respacing routine when it's true. This keeps the
|
||||
respacing routine from erroneously being run more than once on
|
||||
the same line. (DLR)
|
||||
- Check for first_par_line's not being NULL and only run the
|
||||
renumbering and cutbuffer-splicing routines depending on that
|
||||
if that's the case. This fixes a segfault occurring when
|
||||
trying to do full justification on a file with no paragraphs
|
||||
(in which case there are no normal lines to renumber and no
|
||||
backed-up lines to be stored in the cutbuffer or spliced back
|
||||
in during unjustify). (DLR)
|
||||
do_exit()
|
||||
- Tweak for efficiency. (David Benbennick)
|
||||
main()
|
||||
- Move the reset_cursor() call to the beginning of the main
|
||||
input loop, and remove the apparently unnecessary wrefresh()
|
||||
call. (David Benbennick)
|
||||
- Call setlocale() outside the ENABLE_NLS #ifdef, since UTF-8
|
||||
support won't work properly if the locale isn't set, whether
|
||||
NLS is enabled or not. (Junichi Uekawa)
|
||||
- Add titlebar() calls before all open_file() calls and remove
|
||||
the titlebar() call after them, so that the titlebar is
|
||||
displayed properly for all file(s) loaded. Also call
|
||||
display_main_list() after adding the first file to open_files,
|
||||
so that "Close" is properly displayed then instead of "Exit".
|
||||
(DLR)
|
||||
- nano.h:
|
||||
- Reassign the key for full justification to Ctrl-U, for
|
||||
compatibility with the current version of Pico. (DLR)
|
||||
- Remove justbegend enum, as it's no longer needed. (DLR)
|
||||
- proto.h:
|
||||
- Change the variables in the prototypes for do_justify(),
|
||||
get_verbatim_kbinput(), and get_mouseinput() to match the ones
|
||||
used in the actual functions. (DLR)
|
||||
- Remove unused declaration of temp_opt. (David Benbennick)
|
||||
- Add missing copy_file() prototype. (David Benbennick)
|
||||
- Move the load_history() and save_history() prototypes up to
|
||||
match their corresponding location in files.c. (DLR)
|
||||
- rcfile.c:
|
||||
rcfile_msg()
|
||||
- Removed and replaced with calls to rcfile_error(). (David
|
||||
Benbennick)
|
||||
- Removed the reference to "starting nano" in the statusbar
|
||||
message, as it may be called when we exit if the history file
|
||||
can't be saved. (DLR)
|
||||
parse_rcfile()
|
||||
- Have whitespace display default to off instead of on. (Mike
|
||||
Frysinger)
|
||||
nregcomp()
|
||||
- Rename the variable flags to eflags so as not to conflict with
|
||||
the global flags. (DLR)
|
||||
- search.c:
|
||||
do_replace_loop()
|
||||
- Make sure old_pww is updated to the current value of
|
||||
placewewant when a new match is found, so that edit_redraw()
|
||||
will redraw the screen properly when only placewewant changes.
|
||||
(DLR, found by Mike Frysinger)
|
||||
do_replace()
|
||||
- Instead of using edit_update() to redraw the screen with
|
||||
edittop at the top, set edittop beforehand and call
|
||||
edit_refresh(). (DLR)
|
||||
do_gotoline()
|
||||
- Use parse_num() to interpret a line entered by the user, and
|
||||
start the search for a line from current instead of fileage.
|
||||
(DLR)
|
||||
do_gotopos(), find_node(), free_history()
|
||||
- Tweak for efficiency. (David Benbennick)
|
||||
free_history()
|
||||
- Only include when DEBUG is defined. (David Benbennick)
|
||||
- utils.c:
|
||||
parse_num()
|
||||
- New function to parse numeric values, so that we don't have to
|
||||
duplicate code that calls strtol() all over the place. (David
|
||||
Benbennick) DLR: Renamed from parse_int() to parse_num() and
|
||||
converted to use ssize_t instead of int.
|
||||
nstrnicmp()
|
||||
- Remove code chacking for n's being less than 0 that will never
|
||||
be run, since n is a size_t and is hence unsigned. (David
|
||||
Benbennick)
|
||||
ngetdelim(), ngetline()
|
||||
- New functions equivalent to getdelim() and getline(), which
|
||||
are both GNU extensions. (DLR, adapted from GNU mailutils
|
||||
0.5 with minor changes to better integrate with nano and
|
||||
increase efficiency)
|
||||
- winio.c:
|
||||
get_kbinput()
|
||||
- Since the only valid values for escapes are 0, 1, and 2,
|
||||
convert it to an int. (DLR)
|
||||
get_control_kbinput()
|
||||
- Fix erroneous debugging statement so that nano compiles with
|
||||
--enable-debug again. (Jon Oberheide)
|
||||
nanogetstr()
|
||||
- Tweak the code to update the edit window just before getting
|
||||
statusbar input for efficiency, and update bottomwin just
|
||||
before then too. (David Benbennick)
|
||||
- Don't delete the statusbar line on UnCut, since the current
|
||||
version of Pico doesn't. (DLR)
|
||||
do_cursorpos()
|
||||
- Add assert to check whether totsize is correct. (David
|
||||
Benbennick)
|
||||
line_len()
|
||||
- Rename to help_line_len() so as not to conflict with the
|
||||
line_len variable used elsewhere, and move inside the
|
||||
DISABLE_HELP #ifdef surrounding do_help() since it's only
|
||||
called in do_help(). (DLR)
|
||||
do_help()
|
||||
- Have help_line_len() properly return an int again, since its
|
||||
value can't be larger than COLS. (DLR)
|
||||
- Allow the user to exit the help browser via Ctrl-C as well as
|
||||
Ctrl-X, for consistency with the file browser. (DLR)
|
||||
- configure.ac:
|
||||
- Add AC_PROG_LN_S, so that we can portably create symlinks.
|
||||
(DLR)
|
||||
- Check for getdelim() and getline(), which are both GNU
|
||||
extensions. (DLR)
|
||||
- nanorc.sample:
|
||||
- Add sample regexes for patch files. (Mike Frysinger)
|
||||
- Various improvements to the "c-file" regexes. Add double,
|
||||
typedef, extern, union, unsigned, inline, and long to the
|
||||
green list. (Mike Frysinger) DLR: Also add signed, short, and
|
||||
enum to the green list.
|
||||
- nano.spec.in:
|
||||
- Tweak to include all files in %{_bindir} instead of just nano,
|
||||
so that the "rnano" symlink will be properly packaged. (DLR)
|
||||
|
||||
GNU nano 1.3.3 - 2004.06.28
|
||||
- General:
|
||||
- Minor comment cleanups. (DLR)
|
||||
|
||||
20
NEWS
20
NEWS
@@ -1,3 +1,23 @@
|
||||
2004.08.17 - GNU nano 1.3.4 marches forth after a false start. This
|
||||
release mainly features fixes for the bugs that crept
|
||||
into the last release. Among other things, nano now
|
||||
compiles again with certain options, quoted justify now
|
||||
works properly on systems without regex.h, full justify
|
||||
no longer segfaults when used on a file with no
|
||||
paragraphs, previous paragraph searching works properly
|
||||
again, tab completion is properly disabled when needed
|
||||
in restricted mode, Ctrl-C is no longer disabled after
|
||||
using the alternate spell checker, the permissions of a
|
||||
newly created file now match those of nano 1.2.x again,
|
||||
and replacing all text in a file now properly updates
|
||||
the screen in all cases. New features include sample
|
||||
regexes for patch files, improvements to the sample
|
||||
regexes for C files, and support for strings
|
||||
greater than 1023 characters and/or containing nulls in
|
||||
.nano_history. Additionally, the full justify keystroke
|
||||
has been changed to match current Pico, and whitespace
|
||||
display mode is now turned off by default. Enjoy.
|
||||
|
||||
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
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [1.3.3], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [1.3.4], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AM_INIT_AUTOMAKE
|
||||
AM_CONFIG_HEADER([config.h:config.h.in])
|
||||
@@ -29,6 +29,7 @@ AC_PREREQ(2.54)
|
||||
dnl Checks for programs.
|
||||
AC_GNU_SOURCE
|
||||
AC_PROG_CC
|
||||
AC_PROG_LN_S
|
||||
AC_ISC_POSIX
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
@@ -289,7 +290,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 isblank strcasecmp strncasecmp strcasestr strnlen)
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf isblank strcasecmp strncasecmp strcasestr strnlen getline getdelim)
|
||||
if test "x$ac_cv_func_snprintf" = "xno" -o "xac_cv_func_vsnprintf" = "xno"
|
||||
then
|
||||
AM_PATH_GLIB_2_0(2.0.0,,
|
||||
|
||||
@@ -78,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.3. 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.4. 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%">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
.\" Public License for copying conditions. There is NO warranty.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANO 1 "version 1.3.3" "June 28, 2004"
|
||||
.TH NANO 1 "version 1.3.4" "August 17, 2004"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
.\" Public License for copying conditions. There is NO warranty.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANORC 5 "version 1.3.3" "June 28, 2004"
|
||||
.TH NANORC 5 "version 1.3.4" "August 17, 2004"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.SH NAME
|
||||
|
||||
@@ -138,9 +138,9 @@
|
||||
##
|
||||
# syntax "c-file" "\.(c|h)$"
|
||||
# color red "\<[A-Z_]{2,}\>"
|
||||
# color green "\<(float|char|int|void|static|const|struct)\>"
|
||||
# color brightyellow "\<(if|while|do|else|case|switch)\>"
|
||||
# color brightcyan "^ *# *(define|include|ifn?def|endif|elif|else|if)"
|
||||
# color green "\<(float|double|char|int|short|long|enum|void|static|const|struct|union|typedef|extern|signed|unsigned|inline)\>"
|
||||
# color brightyellow "\<(for|if|while|do|else|case|switch|break)\>"
|
||||
# color brightcyan "^ *# *(define|undef|include|ifn?def|endif|elif|else|if)"
|
||||
##
|
||||
## You will in general want your comments and strings to come last,
|
||||
## because syntax highlighting rules will be applied in the order they
|
||||
@@ -225,6 +225,17 @@
|
||||
# color brightblue start="/\*\*" end="\*/"
|
||||
# color brightgreen,green " +$"
|
||||
|
||||
## Here is an example for patch files
|
||||
##
|
||||
# syntax "patch" "\.(patch|diff)$"
|
||||
# color brightgreen "^\+.*"
|
||||
# color green "^\+\+\+.*"
|
||||
# color brightblue "^ .*"
|
||||
# color brightred "^-.*"
|
||||
# color red "^---.*"
|
||||
# color brightyellow "^@@.*"
|
||||
# color magenta "^diff.*"
|
||||
|
||||
## Here is an example for your .nanorc
|
||||
##
|
||||
#syntax "nanorc" "(\.|/|)nanorc$"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
info_TEXINFOS = nano.texi
|
||||
MAKEINFO = makeinfo --no-split
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
@c Run `makeinfo' rather than `texinfo-format-buffer'.
|
||||
@smallbook
|
||||
@set EDITION 0.1
|
||||
@set VERSION 1.3.3
|
||||
@set UPDATED 28 Jun 2004
|
||||
@set VERSION 1.3.4
|
||||
@set UPDATED 17 Aug 2004
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 1.3.3
|
||||
@subtitle version 1.3.4
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
|
||||
@@ -31,7 +31,7 @@ make DESTDIR="$RPM_BUILD_ROOT" install
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/nanorc.sample
|
||||
%{_bindir}/nano
|
||||
%{_bindir}/*
|
||||
%{_mandir}/*/*
|
||||
%{_datadir}/locale/*/LC_MESSAGES/nano.mo
|
||||
%{_infodir}/nano.info*
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
DEFS= -DSYSCONFDIR=\"$(sysconfdir)\"
|
||||
localedir = $(datadir)/locale
|
||||
INCLUDES = -Iintl -DLOCALEDIR=\"$(localedir)\" -I@includedir@
|
||||
@@ -20,3 +19,6 @@ nano_SOURCES = color.c \
|
||||
winio.c
|
||||
|
||||
nano_LDADD = @GLIB_LIBS@ @LIBINTL@
|
||||
|
||||
install-exec-hook:
|
||||
cd $(DESTDIR)$(bindir) && $(LN_S) nano rnano
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "proto.h"
|
||||
@@ -121,7 +120,7 @@ void update_color(void)
|
||||
if (colorstrings == NULL && syntaxstr != NULL) {
|
||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
|
||||
tmpsyntax = tmpsyntax->next) {
|
||||
if (!strcasecmp(tmpsyntax->desc, syntaxstr))
|
||||
if (strcasecmp(tmpsyntax->desc, syntaxstr) == 0)
|
||||
colorstrings = tmpsyntax->color;
|
||||
}
|
||||
}
|
||||
|
||||
31
src/cut.c
31
src/cut.c
@@ -28,13 +28,13 @@
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
static int keep_cutbuffer = FALSE;
|
||||
static bool 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;
|
||||
static bool concatenate_cut;
|
||||
/* Should we add this cut string to the end of the last one? */
|
||||
#endif
|
||||
static filestruct *cutbottom = NULL;
|
||||
@@ -50,7 +50,7 @@ filestruct *get_cutbottom(void)
|
||||
return cutbottom;
|
||||
}
|
||||
|
||||
void add_to_cutbuffer(filestruct *inptr, int allow_concat)
|
||||
void add_to_cutbuffer(filestruct *inptr, bool allow_concat)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "add_to_cutbuffer(): inptr->data = %s\n", inptr->data);
|
||||
@@ -61,7 +61,7 @@ void add_to_cutbuffer(filestruct *inptr, int allow_concat)
|
||||
#ifndef NANO_SMALL
|
||||
else if (allow_concat && concatenate_cut) {
|
||||
/* Just tack the text in inptr onto the text in cutbottom,
|
||||
* unless allow_concat is false. */
|
||||
* unless allow_concat is FALSE. */
|
||||
cutbottom->data = charealloc(cutbottom->data,
|
||||
strlen(cutbottom->data) + strlen(inptr->data) + 1);
|
||||
strcat(cutbottom->data, inptr->data);
|
||||
@@ -199,7 +199,7 @@ void cut_marked_segment(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
int do_cut_text(void)
|
||||
void do_cut_text(void)
|
||||
{
|
||||
filestruct *fileptr;
|
||||
|
||||
@@ -226,7 +226,7 @@ int do_cut_text(void)
|
||||
&& !ISSET(MARK_ISSET)
|
||||
#endif
|
||||
)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
keep_cutbuffer = TRUE;
|
||||
|
||||
@@ -251,7 +251,7 @@ int do_cut_text(void)
|
||||
|
||||
do_delete();
|
||||
marked_cut = 2;
|
||||
return 1;
|
||||
return;
|
||||
} else {
|
||||
SET(MARK_ISSET);
|
||||
|
||||
@@ -274,8 +274,7 @@ int do_cut_text(void)
|
||||
marked_cut = 1;
|
||||
edit_refresh();
|
||||
set_modified();
|
||||
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
@@ -305,10 +304,9 @@ int do_cut_text(void)
|
||||
#ifndef NANO_SMALL
|
||||
concatenate_cut = FALSE;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_uncut_text(void)
|
||||
void do_uncut_text(void)
|
||||
{
|
||||
filestruct *tmp = current;
|
||||
filestruct *newbuf = NULL;
|
||||
@@ -319,7 +317,7 @@ int do_uncut_text(void)
|
||||
#endif
|
||||
check_statblank();
|
||||
if (cutbuffer == NULL || current == NULL)
|
||||
return 0; /* AIEEEEEEEEEEEE */
|
||||
return; /* AIEEEEEEEEEEEE */
|
||||
|
||||
/* If we're uncutting a previously non-marked block, uncut to end if
|
||||
* we're not at the beginning of the line. If we are at the
|
||||
@@ -410,11 +408,9 @@ int do_uncut_text(void)
|
||||
current = newend;
|
||||
}
|
||||
|
||||
/* If marked cut == 2, that means that we're doing a cut to end
|
||||
/* If marked cut == 2, it means that we're doing a cut to end
|
||||
* and we don't want anything else on the line, so we have to
|
||||
* screw up all the work we just did and separate the line.
|
||||
* There must be a better way to do this, but not at 1 AM on a
|
||||
* work night. */
|
||||
* screw up all the work we just did and separate the line. */
|
||||
if (marked_cut == 2) {
|
||||
tmp = make_new_node(current);
|
||||
tmp->data = mallocstrcpy(NULL, current->data + current_x);
|
||||
@@ -437,7 +433,7 @@ int do_uncut_text(void)
|
||||
#endif
|
||||
set_modified();
|
||||
edit_refresh();
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (current != fileage) {
|
||||
@@ -468,5 +464,4 @@ int do_uncut_text(void)
|
||||
#endif
|
||||
|
||||
set_modified();
|
||||
return 1;
|
||||
}
|
||||
|
||||
497
src/files.c
497
src/files.c
File diff suppressed because it is too large
Load Diff
1018
src/global.c
1018
src/global.c
File diff suppressed because it is too large
Load Diff
62
src/move.c
62
src/move.c
@@ -28,32 +28,30 @@
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
int do_first_line(void)
|
||||
void do_first_line(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
size_t 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)
|
||||
void do_last_line(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
size_t 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)
|
||||
void do_home(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
size_t old_pww = placewewant;
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(SMART_HOME)) {
|
||||
int old_current_x = current_x;
|
||||
@@ -76,23 +74,21 @@ int do_home(void)
|
||||
check_statblank();
|
||||
if (need_horizontal_update(old_pww))
|
||||
update_line(current, current_x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_end(void)
|
||||
void do_end(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
size_t old_pww = placewewant;
|
||||
current_x = strlen(current->data);
|
||||
placewewant = xplustabs();
|
||||
check_statblank();
|
||||
if (need_horizontal_update(old_pww))
|
||||
update_line(current, current_x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_page_up(void)
|
||||
void do_page_up(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
size_t old_pww = placewewant;
|
||||
const filestruct *old_current = current;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
@@ -134,12 +130,11 @@ int do_page_up(void)
|
||||
edit_redraw(old_current, old_pww);
|
||||
|
||||
check_statblank();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_page_down(void)
|
||||
void do_page_down(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
size_t old_pww = placewewant;
|
||||
const filestruct *old_current = current;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
@@ -182,10 +177,9 @@ int do_page_down(void)
|
||||
edit_redraw(old_current, old_pww);
|
||||
|
||||
check_statblank();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_up(void)
|
||||
void do_up(void)
|
||||
{
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
@@ -193,7 +187,7 @@ int do_up(void)
|
||||
check_statblank();
|
||||
|
||||
if (current->prev == NULL)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
assert(current_y == current->lineno - edittop->lineno);
|
||||
current = current->prev;
|
||||
@@ -216,13 +210,9 @@ int do_up(void)
|
||||
if (need_vertical_update(0))
|
||||
update_line(current->next, 0);
|
||||
update_line(current, current_x);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return value 1 means we moved down, 0 means we were already at the
|
||||
* bottom. */
|
||||
int do_down(void)
|
||||
void do_down(void)
|
||||
{
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
@@ -230,7 +220,7 @@ int do_down(void)
|
||||
check_statblank();
|
||||
|
||||
if (current->next == NULL)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
assert(current_y == current->lineno - edittop->lineno);
|
||||
current = current->next;
|
||||
@@ -253,13 +243,11 @@ int do_down(void)
|
||||
if (need_vertical_update(0))
|
||||
update_line(current->prev, 0);
|
||||
update_line(current, current_x);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_left(int allow_update)
|
||||
void do_left(int allow_update)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
size_t old_pww = placewewant;
|
||||
if (current_x > 0)
|
||||
current_x--;
|
||||
else if (current != fileage) {
|
||||
@@ -270,17 +258,16 @@ int do_left(int allow_update)
|
||||
check_statblank();
|
||||
if (allow_update && need_horizontal_update(old_pww))
|
||||
update_line(current, current_x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_left_void(void)
|
||||
void do_left_void(void)
|
||||
{
|
||||
return do_left(TRUE);
|
||||
do_left(TRUE);
|
||||
}
|
||||
|
||||
int do_right(int allow_update)
|
||||
void do_right(int allow_update)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
size_t old_pww = placewewant;
|
||||
assert(current_x <= strlen(current->data));
|
||||
|
||||
if (current->data[current_x] != '\0')
|
||||
@@ -293,10 +280,9 @@ int do_right(int allow_update)
|
||||
check_statblank();
|
||||
if (allow_update && need_horizontal_update(old_pww))
|
||||
update_line(current, current_x);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_right_void(void)
|
||||
void do_right_void(void)
|
||||
{
|
||||
return do_right(TRUE);
|
||||
do_right(TRUE);
|
||||
}
|
||||
|
||||
1362
src/nano.c
1362
src/nano.c
File diff suppressed because it is too large
Load Diff
41
src/nano.h
41
src/nano.h
@@ -34,7 +34,7 @@
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
/* Macros for the flags int... */
|
||||
/* Macros for the flags long... */
|
||||
#define SET(bit) flags |= bit
|
||||
#define UNSET(bit) flags &= ~bit
|
||||
#define ISSET(bit) ((flags & bit) != 0)
|
||||
@@ -76,6 +76,9 @@
|
||||
# define _(string) (string)
|
||||
# define P_(singular, plural, number) (number == 1 ? singular : plural)
|
||||
#endif
|
||||
#define gettext_noop(string) (string)
|
||||
#define N_(string) gettext_noop(string)
|
||||
/* Mark a string that will be sent to gettext later. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -92,8 +95,8 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If no isblank(), strcasecmp(), strncasecmp(), strcasestr(), or
|
||||
* strnlen(), use the versions we have. */
|
||||
/* If no isblank(), strcasecmp(), strncasecmp(), strcasestr(),
|
||||
* strnlen(), getdelim(), or getline(), use the versions we have. */
|
||||
#ifndef HAVE_ISBLANK
|
||||
#define isblank is_blank_char
|
||||
#endif
|
||||
@@ -114,6 +117,14 @@
|
||||
#define strnlen nstrnlen
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETDELIM
|
||||
#define getdelim ngetdelim
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETLINE
|
||||
#define getline ngetline
|
||||
#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
|
||||
@@ -160,10 +171,10 @@ typedef struct openfilestruct {
|
||||
* position. */
|
||||
int file_current_y; /* Current file's y-coordinate
|
||||
* position. */
|
||||
int file_flags; /* Current file's flags: modification
|
||||
long file_flags; /* Current file's flags: modification
|
||||
* status (and marking status, if
|
||||
* available). */
|
||||
int file_placewewant; /* Current file's place we want. */
|
||||
size_t file_placewewant; /* Current file's place we want. */
|
||||
int file_totlines; /* Current file's total number of
|
||||
* lines. */
|
||||
long file_totsize; /* Current file's total size. */
|
||||
@@ -179,7 +190,7 @@ typedef struct shortcut {
|
||||
int funcval; /* Function key we want bound. */
|
||||
int miscval; /* Other Meta key we want bound. */
|
||||
int viewok; /* Is this function legal in view mode? */
|
||||
int (*func) (void); /* Function to call when we catch this key. */
|
||||
void (*func)(void); /* Function to call when we catch this key. */
|
||||
const char *desc; /* Description, e.g. "Page Up". */
|
||||
#ifndef DISABLE_HELP
|
||||
const char *help; /* Help file entry text. */
|
||||
@@ -194,7 +205,7 @@ typedef struct toggle {
|
||||
const char *desc; /* Description for when toggle is, uh, toggled,
|
||||
* e.g. "Cut to end"; we'll append Enabled or
|
||||
* Disabled. */
|
||||
int flag; /* What flag actually gets toggled. */
|
||||
long flag; /* What flag actually gets toggled. */
|
||||
struct toggle *next;
|
||||
} toggle;
|
||||
#endif /* !NANO_SMALL */
|
||||
@@ -202,7 +213,7 @@ typedef struct toggle {
|
||||
#ifdef ENABLE_NANORC
|
||||
typedef struct rcoption {
|
||||
const char *name;
|
||||
int flag;
|
||||
long flag;
|
||||
} rcoption;
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
||||
@@ -264,7 +275,7 @@ typedef struct historyheadtype {
|
||||
#define VIEW_MODE (1<<9)
|
||||
#define USE_MOUSE (1<<10)
|
||||
#define USE_REGEXP (1<<11)
|
||||
#define TEMP_OPT (1<<12)
|
||||
#define TEMP_FILE (1<<12)
|
||||
#define CUT_TO_END (1<<13)
|
||||
#define REVERSE_SEARCH (1<<14)
|
||||
#define MULTIBUFFER (1<<15)
|
||||
@@ -362,6 +373,8 @@ typedef struct historyheadtype {
|
||||
#define NANO_HISTORY_KEY -3
|
||||
|
||||
/* Normal keys. */
|
||||
#define NANO_XON_KEY NANO_CONTROL_Q
|
||||
#define NANO_XOFF_KEY NANO_CONTROL_S
|
||||
#define NANO_INSERTFILE_KEY NANO_CONTROL_R
|
||||
#define NANO_INSERTFILE_FKEY KEY_F(5)
|
||||
#define NANO_EXIT_KEY NANO_CONTROL_X
|
||||
@@ -429,7 +442,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_FULLJUSTIFY_KEY NANO_CONTROL_U
|
||||
#define NANO_VERBATIM_KEY NANO_ALT_V
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
@@ -457,12 +470,8 @@ typedef struct historyheadtype {
|
||||
|
||||
#define MAIN_VISIBLE 12
|
||||
|
||||
#define VIEW 1
|
||||
#define NOVIEW 0
|
||||
|
||||
typedef enum {
|
||||
JUSTIFY, BEGIN, END
|
||||
} justbegend;
|
||||
#define VIEW TRUE
|
||||
#define NOVIEW FALSE
|
||||
|
||||
typedef enum {
|
||||
UP, DOWN
|
||||
|
||||
255
src/proto.h
255
src/proto.h
@@ -22,28 +22,25 @@
|
||||
/* Externs. */
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_REGEX_H
|
||||
#include <regex.h>
|
||||
#endif
|
||||
|
||||
#include "nano.h"
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
extern int wrap_at;
|
||||
extern ssize_t wrap_at;
|
||||
#endif
|
||||
extern int editwinrows;
|
||||
extern int current_x, current_y, totlines;
|
||||
extern int placewewant;
|
||||
extern size_t placewewant;
|
||||
#ifndef NANO_SMALL
|
||||
extern int mark_beginx;
|
||||
#endif
|
||||
extern long totsize;
|
||||
extern int temp_opt;
|
||||
extern int flags;
|
||||
extern int tabsize;
|
||||
extern long flags;
|
||||
extern ssize_t tabsize;
|
||||
extern int search_last_line;
|
||||
extern int search_offscreen;
|
||||
extern int currslen;
|
||||
|
||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||
@@ -54,6 +51,13 @@ extern char *whitespace;
|
||||
extern char *punct;
|
||||
extern char *brackets;
|
||||
extern char *quotestr;
|
||||
#ifdef HAVE_REGEX_H
|
||||
extern regex_t quotereg;
|
||||
extern int quoterc;
|
||||
extern char *quoteerr;
|
||||
#else
|
||||
extern size_t quotelen;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
@@ -136,7 +140,11 @@ extern historyheadtype search_history;
|
||||
extern historyheadtype replace_history;
|
||||
#endif
|
||||
|
||||
extern int curses_ended;
|
||||
extern bool curses_ended;
|
||||
|
||||
#ifdef ENABLE_NANORC
|
||||
extern char *homedir;
|
||||
#endif
|
||||
|
||||
/* Functions we want available. */
|
||||
|
||||
@@ -150,33 +158,34 @@ void update_color(void);
|
||||
/* Public functions in cut.c */
|
||||
void cutbuffer_reset(void);
|
||||
filestruct *get_cutbottom(void);
|
||||
void add_to_cutbuffer(filestruct *inptr, int allow_concat);
|
||||
void add_to_cutbuffer(filestruct *inptr, bool allow_concat);
|
||||
void cut_marked_segment(void);
|
||||
int do_cut_text(void);
|
||||
int do_uncut_text(void);
|
||||
void do_cut_text(void);
|
||||
void 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, size_t
|
||||
len);
|
||||
int read_file(FILE *f, const char *filename, int quiet);
|
||||
int open_file(const char *filename, int insert, int quiet);
|
||||
void read_file(FILE *f, const char *filename, int quiet);
|
||||
bool open_file(const char *filename, int insert, int quiet);
|
||||
char *get_next_filename(const char *name);
|
||||
int do_insertfile(int loading_file);
|
||||
int do_insertfile_void(void);
|
||||
void do_insertfile(int loading_file);
|
||||
void do_insertfile_void(void);
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
openfilestruct *make_new_opennode(openfilestruct *prevnode);
|
||||
void splice_opennode(openfilestruct *begin, openfilestruct *newnode, openfilestruct *end);
|
||||
void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
|
||||
openfilestruct *end);
|
||||
void unlink_opennode(const openfilestruct *fileptr);
|
||||
void delete_opennode(openfilestruct *fileptr);
|
||||
void free_openfilestruct(openfilestruct *src);
|
||||
int add_open_file(int update);
|
||||
int load_open_file(void);
|
||||
int open_prevfile(int closing_file);
|
||||
int open_prevfile_void(void);
|
||||
int open_nextfile(int closing_file);
|
||||
int open_nextfile_void(void);
|
||||
void add_open_file(int update);
|
||||
void load_open_file(void);
|
||||
void open_prevfile(int closing_file);
|
||||
void open_prevfile_void(void);
|
||||
void open_nextfile(int closing_file);
|
||||
void open_nextfile_void(void);
|
||||
int close_open_file(void);
|
||||
#endif
|
||||
#if !defined(DISABLE_SPELLER) || !defined(DISABLE_OPERATINGDIR)
|
||||
@@ -193,18 +202,20 @@ int check_operating_dir(const char *currpath, int allow_tabcomp);
|
||||
#ifndef NANO_SMALL
|
||||
void init_backup_dir(void);
|
||||
#endif
|
||||
int copy_file(FILE *inn, FILE *out);
|
||||
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);
|
||||
#endif
|
||||
int do_writeout(int exiting);
|
||||
int do_writeout_void(void);
|
||||
void do_writeout_void(void);
|
||||
char *real_dir_from_tilde(const char *buf);
|
||||
#ifndef DISABLE_TABCOMP
|
||||
int append_slash_if_dir(char *buf, int *lastwastab, int *place);
|
||||
int append_slash_if_dir(char *buf, bool *lastwastab, int *place);
|
||||
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);
|
||||
char *input_tab(char *buf, int place, bool *lastwastab, int *newplace,
|
||||
bool *list);
|
||||
#endif
|
||||
const char *tail(const char *foo);
|
||||
#ifndef DISABLE_BROWSER
|
||||
@@ -216,41 +227,47 @@ char **browser_init(const char *path, int *longest, int *numents);
|
||||
char *do_browser(const char *inpath);
|
||||
char *do_browse_from(const char *inpath);
|
||||
#endif
|
||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||
char *histfilename(void);
|
||||
void load_history(void);
|
||||
bool writehist(FILE *hist, historyheadtype *histhead);
|
||||
void save_history(void);
|
||||
#endif
|
||||
|
||||
/* Public functions in global.c */
|
||||
int length_of_list(const shortcut *s);
|
||||
void sc_init_one(shortcut **shortcutage, int key, const char *desc,
|
||||
#ifndef DISABLE_HELP
|
||||
const char *help,
|
||||
#endif
|
||||
int metaval, int funcval, int miscval, int view, int
|
||||
(*func)(void));
|
||||
size_t length_of_list(const shortcut *s);
|
||||
#ifndef NANO_SMALL
|
||||
void toggle_init_one(int val, const char *desc, int flag);
|
||||
void toggle_init_one(int val, const char *desc, long flag);
|
||||
void toggle_init(void);
|
||||
#ifdef DEBUG
|
||||
void free_toggles(void);
|
||||
#endif
|
||||
#endif
|
||||
void free_shortcutage(shortcut **shortcutage);
|
||||
void sc_init_one(shortcut **shortcutage, int key, const char *desc,
|
||||
#ifndef DISABLE_HELP
|
||||
const char *help,
|
||||
#endif
|
||||
int metaval, int funcval, int miscval, int view, void
|
||||
(*func)(void));
|
||||
void shortcut_init(int unjustify);
|
||||
void free_shortcutage(shortcut **shortcutage);
|
||||
#ifdef DEBUG
|
||||
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(int allow_update);
|
||||
int do_left_void(void);
|
||||
int do_right(int allow_update);
|
||||
int do_right_void(void);
|
||||
void do_first_line(void);
|
||||
void do_last_line(void);
|
||||
void do_home(void);
|
||||
void do_end(void);
|
||||
void do_page_up(void);
|
||||
void do_page_down(void);
|
||||
void do_up(void);
|
||||
void do_down(void);
|
||||
void do_left(int allow_update);
|
||||
void do_left_void(void);
|
||||
void do_right(int allow_update);
|
||||
void do_right_void(void);
|
||||
|
||||
/* Public functions in nano.c */
|
||||
void finish(void);
|
||||
@@ -258,7 +275,7 @@ void die(const char *msg, ...);
|
||||
void die_save_file(const char *die_filename);
|
||||
void die_too_small(void);
|
||||
void print_view_warning(void);
|
||||
void global_init(int save_cutbuffer);
|
||||
void global_init(bool save_cutbuffer);
|
||||
void window_init(void);
|
||||
#ifndef DISABLE_MOUSE
|
||||
void mouse_init(void);
|
||||
@@ -268,109 +285,100 @@ void help_init(void);
|
||||
#endif
|
||||
filestruct *make_new_node(filestruct *prevnode);
|
||||
filestruct *copy_node(const filestruct *src);
|
||||
void splice_node(filestruct *begin, filestruct *newnode, filestruct *end);
|
||||
void splice_node(filestruct *begin, filestruct *newnode, filestruct
|
||||
*end);
|
||||
void unlink_node(const filestruct *fileptr);
|
||||
void delete_node(filestruct *fileptr);
|
||||
filestruct *copy_filestruct(const filestruct *src);
|
||||
void free_filestruct(filestruct *src);
|
||||
void renumber_all(void);
|
||||
void renumber(filestruct *fileptr);
|
||||
void print1opt(const char *shortflag, const char *longflag,
|
||||
const char *desc);
|
||||
void print1opt(const char *shortflag, const char *longflag, const char
|
||||
*desc);
|
||||
void usage(void);
|
||||
void version(void);
|
||||
int no_help(void);
|
||||
int nano_disabled_msg(void);
|
||||
void nano_disabled_msg(void);
|
||||
#ifndef NANO_SMALL
|
||||
RETSIGTYPE cancel_fork(int signal);
|
||||
int open_pipe(const char *command);
|
||||
bool open_pipe(const char *command);
|
||||
#endif
|
||||
#ifndef DISABLE_MOUSE
|
||||
void do_mouse(void);
|
||||
#endif
|
||||
void do_char(char ch);
|
||||
int do_verbatim_input(void);
|
||||
int do_backspace(void);
|
||||
int do_delete(void);
|
||||
int do_tab(void);
|
||||
int do_enter(void);
|
||||
void do_verbatim_input(void);
|
||||
void do_backspace(void);
|
||||
void do_delete(void);
|
||||
void do_tab(void);
|
||||
void do_enter(void);
|
||||
#ifndef NANO_SMALL
|
||||
int do_next_word(void);
|
||||
int do_prev_word(void);
|
||||
int do_mark(void);
|
||||
void do_next_word(void);
|
||||
void do_prev_word(void);
|
||||
void do_mark(void);
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPPING
|
||||
void wrap_reset(void);
|
||||
int do_wrap(filestruct *inptr);
|
||||
bool do_wrap(filestruct *inptr);
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
int do_int_spell_fix(const char *word);
|
||||
const char *do_int_speller(char *tempfile_name);
|
||||
bool do_int_spell_fix(const char *word);
|
||||
const char *do_int_speller(const char *tempfile_name);
|
||||
const char *do_alt_speller(char *tempfile_name);
|
||||
int do_spell(void);
|
||||
void do_spell(void);
|
||||
#endif
|
||||
#if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
|
||||
#if !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
|
||||
size_t indent_length(const char *line);
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
void justify_format(filestruct *line, size_t skip);
|
||||
#ifdef HAVE_REGEX_H
|
||||
size_t quote_length(const char *line, const regex_t *qreg);
|
||||
#else
|
||||
size_t quote_length(const char *line);
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
# define IFREG(a, b) a, b
|
||||
#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
|
||||
bool quotes_match(const char *a_line, size_t a_quote, const char
|
||||
*b_line);
|
||||
bool indents_match(const char *a_line, size_t a_indent, const char
|
||||
*b_line, size_t b_indent);
|
||||
bool begpar(const filestruct *const foo);
|
||||
void do_para_begin(void);
|
||||
bool inpar(const char *str);
|
||||
void do_para_end(void);
|
||||
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(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);
|
||||
bool breakable(const char *line, int goal);
|
||||
int break_line(const char *line, int goal, bool force);
|
||||
bool do_para_search(size_t *const quote, size_t *const par);
|
||||
void do_justify(bool full_justify);
|
||||
void do_justify_void(void);
|
||||
void do_full_justify(void);
|
||||
#endif /* !DISABLE_JUSTIFY */
|
||||
int do_exit(void);
|
||||
void do_exit(void);
|
||||
void signal_init(void);
|
||||
RETSIGTYPE handle_hupterm(int signal);
|
||||
RETSIGTYPE do_suspend(int signal);
|
||||
RETSIGTYPE do_cont(int signal);
|
||||
#ifndef NANO_SMALL
|
||||
void handle_sigwinch(int s);
|
||||
void allow_pending_sigwinch(int allow);
|
||||
void allow_pending_sigwinch(bool allow);
|
||||
#endif
|
||||
#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);
|
||||
void terminal_init(void);
|
||||
|
||||
/* Public functions in rcfile.c */
|
||||
#ifdef ENABLE_NANORC
|
||||
void rcfile_error(const char *msg, ...);
|
||||
void rcfile_msg(const char *msg, ...);
|
||||
char *parse_next_word(char *ptr);
|
||||
char *parse_argument(char *ptr);
|
||||
#ifdef ENABLE_COLOR
|
||||
int colortoint(const char *colorname, int *bright);
|
||||
char *parse_next_regex(char *ptr);
|
||||
int nregcomp(regex_t *preg, const char *regex, int flags);
|
||||
int nregcomp(regex_t *preg, const char *regex, int eflags);
|
||||
void parse_syntax(char *ptr);
|
||||
void parse_colors(char *ptr);
|
||||
#endif /* ENABLE_COLOR */
|
||||
@@ -391,9 +399,9 @@ int is_whole_word(int curr_pos, const char *datastr, const char
|
||||
*searchword);
|
||||
int findnextstr(int can_display_wrap, int wholeword, const filestruct
|
||||
*begin, size_t beginx, const char *needle, int no_sameline);
|
||||
int do_search(void);
|
||||
void do_search(void);
|
||||
#ifndef NANO_SMALL
|
||||
int do_research(void);
|
||||
void do_research(void);
|
||||
#endif
|
||||
void replace_abort(void);
|
||||
#ifdef HAVE_REGEX_H
|
||||
@@ -402,26 +410,24 @@ int replace_regexp(char *string, int create_flag);
|
||||
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 do_replace(void);
|
||||
int do_gotoline(int line, int save_pos);
|
||||
int do_gotoline_void(void);
|
||||
void do_replace(void);
|
||||
void do_gotoline(int line, bool save_pos);
|
||||
void do_gotoline_void(void);
|
||||
#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_SPELLER)
|
||||
void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant);
|
||||
void do_gotopos(int line, int pos_x, int pos_y, size_t pos_pww);
|
||||
#endif
|
||||
int do_find_bracket(void);
|
||||
void do_find_bracket(void);
|
||||
#ifndef NANO_SMALL
|
||||
void history_init(void);
|
||||
historytype *find_node(historytype *h, char *s);
|
||||
historytype *find_node(historytype *h, const char *s);
|
||||
void remove_node(historytype *r);
|
||||
void insert_node(historytype *h, const char *s);
|
||||
void update_history(historyheadtype *h, char *s);
|
||||
void update_history(historyheadtype *h, const char *s);
|
||||
char *get_history_older(historyheadtype *h);
|
||||
char *get_history_newer(historyheadtype *h);
|
||||
char *get_history_completion(historyheadtype *h, char *s);
|
||||
#ifdef DEBUG
|
||||
void free_history(historyheadtype *h);
|
||||
#ifdef ENABLE_NANORC
|
||||
void load_history(void);
|
||||
void save_history(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -438,6 +444,7 @@ int is_blank_char(int c);
|
||||
#endif
|
||||
int is_cntrl_char(int c);
|
||||
int num_of_digits(int n);
|
||||
bool parse_num(const char *str, ssize_t *val);
|
||||
void align(char **strp);
|
||||
void null_at(char **data, size_t index);
|
||||
void unsunder(char *str, size_t true_len);
|
||||
@@ -460,6 +467,14 @@ const char *revstristr(const char *haystack, const char *needle, const
|
||||
#ifndef HAVE_STRNLEN
|
||||
size_t nstrnlen(const char *s, size_t maxlen);
|
||||
#endif
|
||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||
#ifndef HAVE_GETLINE
|
||||
ssize_t ngetline(char **lineptr, size_t *n, FILE *stream);
|
||||
#endif
|
||||
#ifndef HAVE_GETDELIM
|
||||
ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream);
|
||||
#endif
|
||||
#endif /* !NANO_SMALL && ENABLE_NANORC */
|
||||
const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
const char *start);
|
||||
void nperror(const char *s);
|
||||
@@ -468,8 +483,8 @@ void *nrealloc(void *ptr, size_t howmuch);
|
||||
char *mallocstrcpy(char *dest, const char *src);
|
||||
void new_magicline(void);
|
||||
#ifndef NANO_SMALL
|
||||
void mark_order(const filestruct **top, size_t *top_x,
|
||||
const filestruct **bot, size_t *bot_x);
|
||||
void mark_order(const filestruct **top, size_t *top_x, const filestruct
|
||||
**bot, size_t *bot_x);
|
||||
#endif
|
||||
#ifndef DISABLE_TABCOMP
|
||||
int check_wildcard_match(const char *text, const char *pattern);
|
||||
@@ -494,8 +509,8 @@ 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_verbatim_kbinput(WINDOW *win, int *v_kbinput, size_t *v_len,
|
||||
int allow_ascii);
|
||||
int get_untranslated_kbinput(int kbinput, size_t position, int
|
||||
allow_ascii
|
||||
#ifndef NANO_SMALL
|
||||
@@ -503,7 +518,7 @@ int get_untranslated_kbinput(int kbinput, size_t position, int
|
||||
#endif
|
||||
);
|
||||
#ifndef DISABLE_MOUSE
|
||||
int get_mouseinput(int *mouse_x, int *mouse_y, int shortcut);
|
||||
int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts);
|
||||
#endif
|
||||
size_t xplustabs(void);
|
||||
size_t actual_x(const char *str, size_t xplus);
|
||||
@@ -522,7 +537,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
#endif
|
||||
const shortcut *s
|
||||
#ifndef DISABLE_TABCOMP
|
||||
, int *list
|
||||
, bool *list
|
||||
#endif
|
||||
);
|
||||
void titlebar(const char *path);
|
||||
@@ -538,10 +553,10 @@ void reset_cursor(void);
|
||||
void edit_add(const filestruct *fileptr, const char *converted, int
|
||||
yval, size_t start);
|
||||
void update_line(const filestruct *fileptr, size_t index);
|
||||
int need_horizontal_update(int old_placewewant);
|
||||
int need_vertical_update(int old_placewewant);
|
||||
int need_horizontal_update(size_t old_pww);
|
||||
int need_vertical_update(size_t old_pww);
|
||||
void edit_scroll(updown direction, int nlines);
|
||||
void edit_redraw(const filestruct *old_current, int old_pww);
|
||||
void edit_redraw(const filestruct *old_current, size_t old_pww);
|
||||
void edit_refresh(void);
|
||||
void edit_update(filestruct *fileptr, topmidnone location);
|
||||
int statusq(int allowtabs, const shortcut *s, const char *def,
|
||||
@@ -550,12 +565,14 @@ int statusq(int allowtabs, const shortcut *s, const char *def,
|
||||
#endif
|
||||
const char *msg, ...);
|
||||
int do_yesno(int all, const char *msg);
|
||||
int total_refresh(void);
|
||||
void total_refresh(void);
|
||||
void display_main_list(void);
|
||||
int do_cursorpos(int constant);
|
||||
int do_cursorpos_void(void);
|
||||
int line_len(const char *ptr);
|
||||
int do_help(void);
|
||||
void do_cursorpos(int constant);
|
||||
void do_cursorpos_void(void);
|
||||
#ifndef DISABLE_HELP
|
||||
int help_line_len(const char *ptr);
|
||||
void do_help(void);
|
||||
#endif
|
||||
void do_replace_highlight(int highlight_flag, const char *word);
|
||||
#ifdef DEBUG
|
||||
void dump_buffer(const filestruct *inptr);
|
||||
|
||||
250
src/rcfile.c
250
src/rcfile.c
@@ -27,7 +27,6 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
@@ -92,7 +91,7 @@ const static rcoption rcopts[] = {
|
||||
#endif
|
||||
{"suspend", SUSPEND},
|
||||
{"tabsize", 0},
|
||||
{"tempfile", TEMP_OPT},
|
||||
{"tempfile", TEMP_FILE},
|
||||
{"view", VIEW_MODE},
|
||||
#ifndef NANO_SMALL
|
||||
{"whitespace", 0},
|
||||
@@ -100,9 +99,9 @@ const static rcoption rcopts[] = {
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static int errors = 0;
|
||||
static bool errors = FALSE;
|
||||
static int lineno = 0;
|
||||
static char *nanorc;
|
||||
static const char *nanorc;
|
||||
|
||||
/* We have an error in some part of the rcfile; put it on stderr and
|
||||
make the user hit return to continue starting up nano. */
|
||||
@@ -111,29 +110,15 @@ void rcfile_error(const char *msg, ...)
|
||||
va_list ap;
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
if (lineno > 0)
|
||||
if (lineno > 0) {
|
||||
errors = TRUE;
|
||||
fprintf(stderr, _("Error in %s on line %d: "), nanorc, lineno);
|
||||
|
||||
va_start(ap, msg);
|
||||
vfprintf(stderr, msg, ap);
|
||||
va_end(ap);
|
||||
fprintf(stderr, _("\nPress return to continue starting nano\n"));
|
||||
|
||||
while (getchar() != '\n');
|
||||
}
|
||||
|
||||
/* Just print the error (one of many, perhaps) but don't abort, yet. */
|
||||
void rcfile_msg(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (!errors) {
|
||||
errors = 1;
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
va_start(ap, msg);
|
||||
vfprintf(stderr, msg, ap);
|
||||
vfprintf(stderr, _(msg), ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
@@ -183,7 +168,7 @@ char *parse_argument(char *ptr)
|
||||
ptr = NULL;
|
||||
else
|
||||
*ptr++ = '\0';
|
||||
rcfile_error(_("Argument %s has unterminated \""), ptr_bak);
|
||||
rcfile_error(N_("Argument %s has unterminated \""), ptr_bak);
|
||||
} else {
|
||||
*last_quote = '\0';
|
||||
ptr = last_quote + 1;
|
||||
@@ -203,33 +188,33 @@ int colortoint(const char *colorname, int *bright)
|
||||
if (colorname == NULL)
|
||||
return -1;
|
||||
|
||||
if (!strncasecmp(colorname, "bright", 6)) {
|
||||
if (strncasecmp(colorname, "bright", 6) == 0) {
|
||||
*bright = 1;
|
||||
colorname += 6;
|
||||
}
|
||||
|
||||
if (!strcasecmp(colorname, "green"))
|
||||
if (strcasecmp(colorname, "green") == 0)
|
||||
mcolor = COLOR_GREEN;
|
||||
else if (!strcasecmp(colorname, "red"))
|
||||
else if (strcasecmp(colorname, "red") == 0)
|
||||
mcolor = COLOR_RED;
|
||||
else if (!strcasecmp(colorname, "blue"))
|
||||
else if (strcasecmp(colorname, "blue") == 0)
|
||||
mcolor = COLOR_BLUE;
|
||||
else if (!strcasecmp(colorname, "white"))
|
||||
else if (strcasecmp(colorname, "white") == 0)
|
||||
mcolor = COLOR_WHITE;
|
||||
else if (!strcasecmp(colorname, "yellow"))
|
||||
else if (strcasecmp(colorname, "yellow") == 0)
|
||||
mcolor = COLOR_YELLOW;
|
||||
else if (!strcasecmp(colorname, "cyan"))
|
||||
else if (strcasecmp(colorname, "cyan") == 0)
|
||||
mcolor = COLOR_CYAN;
|
||||
else if (!strcasecmp(colorname, "magenta"))
|
||||
else if (strcasecmp(colorname, "magenta") == 0)
|
||||
mcolor = COLOR_MAGENTA;
|
||||
else if (!strcasecmp(colorname, "black"))
|
||||
else if (strcasecmp(colorname, "black") == 0)
|
||||
mcolor = COLOR_BLACK;
|
||||
else {
|
||||
rcfile_error(_("Color %s not understood.\n"
|
||||
"Valid colors are \"green\", \"red\", \"blue\", \n"
|
||||
"\"white\", \"yellow\", \"cyan\", \"magenta\" and \n"
|
||||
"\"black\", with the optional prefix \"bright\" \n"
|
||||
"for foreground colors.\n"), colorname);
|
||||
rcfile_error(N_("Color %s not understood.\n"
|
||||
"Valid colors are \"green\", \"red\", \"blue\", \n"
|
||||
"\"white\", \"yellow\", \"cyan\", \"magenta\" and \n"
|
||||
"\"black\", with the optional prefix \"bright\" \n"
|
||||
"for foreground colors."), colorname);
|
||||
mcolor = -1;
|
||||
}
|
||||
return mcolor;
|
||||
@@ -253,18 +238,18 @@ char *parse_next_regex(char *ptr)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/* Compile the regular expression regex to preg. Returns FALSE on success,
|
||||
TRUE if the expression is invalid. */
|
||||
int nregcomp(regex_t *preg, const char *regex, int flags)
|
||||
/* Compile the regular expression regex to preg. Returns FALSE on
|
||||
* success, or TRUE if the expression is invalid. */
|
||||
int nregcomp(regex_t *preg, const char *regex, int eflags)
|
||||
{
|
||||
int rc = regcomp(preg, regex, REG_EXTENDED | flags);
|
||||
int rc = regcomp(preg, regex, REG_EXTENDED | eflags);
|
||||
|
||||
if (rc != 0) {
|
||||
size_t len = regerror(rc, preg, NULL, 0);
|
||||
char *str = charalloc(len);
|
||||
|
||||
regerror(rc, preg, str, len);
|
||||
rcfile_error(_("Bad regex \"%s\": %s"), regex, str);
|
||||
rcfile_error(N_("Bad regex \"%s\": %s"), regex, str);
|
||||
free(str);
|
||||
}
|
||||
return rc != 0;
|
||||
@@ -284,7 +269,7 @@ void parse_syntax(char *ptr)
|
||||
return;
|
||||
|
||||
if (*ptr != '"') {
|
||||
rcfile_error(_("Regex strings must begin and end with a \" character\n"));
|
||||
rcfile_error(N_("Regex strings must begin and end with a \" character"));
|
||||
return;
|
||||
}
|
||||
ptr++;
|
||||
@@ -293,7 +278,7 @@ void parse_syntax(char *ptr)
|
||||
ptr = parse_next_regex(ptr);
|
||||
|
||||
if (ptr == NULL) {
|
||||
rcfile_error(_("Missing syntax name"));
|
||||
rcfile_error(N_("Missing syntax name"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -362,7 +347,7 @@ void parse_colors(char *ptr)
|
||||
ptr = parse_next_word(ptr);
|
||||
|
||||
if (ptr == NULL) {
|
||||
rcfile_error(_("Missing color name"));
|
||||
rcfile_error(N_("Missing color name"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -370,8 +355,8 @@ void parse_colors(char *ptr)
|
||||
char *bgcolorname;
|
||||
strtok(fgstr, ",");
|
||||
bgcolorname = strtok(NULL, ",");
|
||||
if (!strncasecmp(bgcolorname, "bright", 6)) {
|
||||
rcfile_error(_("Background color %s cannot be bright"), bgcolorname);
|
||||
if (strncasecmp(bgcolorname, "bright", 6) == 0) {
|
||||
rcfile_error(N_("Background color %s cannot be bright"), bgcolorname);
|
||||
return;
|
||||
}
|
||||
bg = colortoint(bgcolorname, &bright);
|
||||
@@ -385,7 +370,7 @@ void parse_colors(char *ptr)
|
||||
return;
|
||||
|
||||
if (syntaxes == NULL) {
|
||||
rcfile_error(_("Cannot add a color directive without a syntax line"));
|
||||
rcfile_error(N_("Cannot add a color directive without a syntax line"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -408,13 +393,13 @@ void parse_colors(char *ptr)
|
||||
if (*ptr == '\n' || *ptr == '\0')
|
||||
break;
|
||||
|
||||
if (!strncasecmp(ptr, "start=", 6)) {
|
||||
if (strncasecmp(ptr, "start=", 6) == 0) {
|
||||
ptr += 6;
|
||||
expectend = 1;
|
||||
}
|
||||
|
||||
if (*ptr != '"') {
|
||||
rcfile_error(_("Regex strings must begin and end with a \" character\n"));
|
||||
rcfile_error(N_("Regex strings must begin and end with a \" character"));
|
||||
ptr = parse_next_regex(ptr);
|
||||
continue;
|
||||
}
|
||||
@@ -436,8 +421,7 @@ void parse_colors(char *ptr)
|
||||
if (tmpsyntax->color == NULL) {
|
||||
tmpsyntax->color = newcolor;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Starting a new colorstring for fg %d bg %d\n",
|
||||
fg, bg);
|
||||
fprintf(stderr, "Starting a new colorstring for fg %d bg %d\n", fg, bg);
|
||||
#endif
|
||||
} else {
|
||||
for (tmpcolor = tmpsyntax->color; tmpcolor->next != NULL;
|
||||
@@ -451,17 +435,15 @@ void parse_colors(char *ptr)
|
||||
}
|
||||
|
||||
if (expectend) {
|
||||
if (ptr == NULL || strncasecmp(ptr, "end=", 4)) {
|
||||
rcfile_error(_
|
||||
("\"start=\" requires a corresponding \"end=\""));
|
||||
if (ptr == NULL || strncasecmp(ptr, "end=", 4) != 0) {
|
||||
rcfile_error(N_("\"start=\" requires a corresponding \"end=\""));
|
||||
return;
|
||||
}
|
||||
|
||||
ptr += 4;
|
||||
|
||||
if (*ptr != '"') {
|
||||
rcfile_error(_
|
||||
("Regex strings must begin and end with a \" character\n"));
|
||||
rcfile_error(N_("Regex strings must begin and end with a \" character"));
|
||||
continue;
|
||||
}
|
||||
ptr++;
|
||||
@@ -488,7 +470,7 @@ void parse_colors(char *ptr)
|
||||
void parse_rcfile(FILE *rcstream)
|
||||
{
|
||||
char *buf, *ptr, *keyword, *option;
|
||||
int set = 0, i, j;
|
||||
int set = 0, i;
|
||||
|
||||
buf = charalloc(1024);
|
||||
while (fgets(buf, 1023, rcstream) != 0) {
|
||||
@@ -514,18 +496,18 @@ void parse_rcfile(FILE *rcstream)
|
||||
continue;
|
||||
|
||||
/* Else try to parse the keyword */
|
||||
if (!strcasecmp(keyword, "set"))
|
||||
if (strcasecmp(keyword, "set") == 0)
|
||||
set = 1;
|
||||
else if (!strcasecmp(keyword, "unset"))
|
||||
else if (strcasecmp(keyword, "unset") == 0)
|
||||
set = -1;
|
||||
#ifdef ENABLE_COLOR
|
||||
else if (!strcasecmp(keyword, "syntax"))
|
||||
else if (strcasecmp(keyword, "syntax") == 0)
|
||||
parse_syntax(ptr);
|
||||
else if (!strcasecmp(keyword, "color"))
|
||||
else if (strcasecmp(keyword, "color") == 0)
|
||||
parse_colors(ptr);
|
||||
#endif /* ENABLE_COLOR */
|
||||
else {
|
||||
rcfile_msg(_("Command %s not understood"), keyword);
|
||||
rcfile_error(N_("Command %s not understood"), keyword);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -535,38 +517,36 @@ void parse_rcfile(FILE *rcstream)
|
||||
|
||||
if (set != 0) {
|
||||
for (i = 0; rcopts[i].name != NULL; i++) {
|
||||
if (!strcasecmp(option, rcopts[i].name)) {
|
||||
if (strcasecmp(option, rcopts[i].name) == 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%s: Parsing option %s\n",
|
||||
"parse_rcfile()", rcopts[i].name);
|
||||
#endif
|
||||
if (set == 1) {
|
||||
if (!strcasecmp(rcopts[i].name, "tabsize")
|
||||
if (strcasecmp(rcopts[i].name, "tabsize") == 0
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
|| !strcasecmp(rcopts[i].name, "operatingdir")
|
||||
|| strcasecmp(rcopts[i].name, "operatingdir") == 0
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
|| !strcasecmp(rcopts[i].name, "fill")
|
||||
|| strcasecmp(rcopts[i].name, "fill") == 0
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
|| !strcasecmp(rcopts[i].name, "whitespace")
|
||||
|| strcasecmp(rcopts[i].name, "whitespace") == 0
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
|| !strcasecmp(rcopts[i].name, "punct")
|
||||
|| !strcasecmp(rcopts[i].name, "brackets")
|
||||
|| !strcasecmp(rcopts[i].name, "quotestr")
|
||||
|| strcasecmp(rcopts[i].name, "punct") == 0
|
||||
|| strcasecmp(rcopts[i].name, "brackets") == 0
|
||||
|| strcasecmp(rcopts[i].name, "quotestr") == 0
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
|| !strcasecmp(rcopts[i].name, "backupdir")
|
||||
|| strcasecmp(rcopts[i].name, "backupdir") == 0
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
|| !strcasecmp(rcopts[i].name, "speller")
|
||||
|| strcasecmp(rcopts[i].name, "speller") == 0
|
||||
#endif
|
||||
) {
|
||||
if (*ptr == '\n' || *ptr == '\0') {
|
||||
rcfile_error(_
|
||||
("Option %s requires an argument"),
|
||||
rcopts[i].name);
|
||||
rcfile_error(N_("Option %s requires an argument"), rcopts[i].name);
|
||||
continue;
|
||||
}
|
||||
option = ptr;
|
||||
@@ -577,79 +557,63 @@ void parse_rcfile(FILE *rcstream)
|
||||
fprintf(stderr, "option = %s\n", option);
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if (!strcasecmp(rcopts[i].name, "operatingdir"))
|
||||
if (strcasecmp(rcopts[i].name, "operatingdir") == 0)
|
||||
operating_dir = mallocstrcpy(NULL, option);
|
||||
else
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
if (!strcasecmp(rcopts[i].name, "fill")) {
|
||||
char *first_error;
|
||||
|
||||
/* Using strtol() instead of atoi() lets
|
||||
* us accept 0 while checking other
|
||||
* errors. */
|
||||
j = (int)strtol(option, &first_error, 10);
|
||||
if (errno == ERANGE || *option == '\0' || *first_error != '\0')
|
||||
rcfile_error(_("Requested fill size %d invalid"),
|
||||
j);
|
||||
else
|
||||
wrap_at = j;
|
||||
if (strcasecmp(rcopts[i].name, "fill") == 0) {
|
||||
if (!parse_num(option, &wrap_at)) {
|
||||
rcfile_error(N_("Requested fill size %s invalid"), option);
|
||||
wrap_at = -CHARS_FROM_EOL;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
if (!strcasecmp(rcopts[i].name, "whitespace")) {
|
||||
if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
|
||||
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"));
|
||||
rcfile_error(N_("Two non-control characters required"));
|
||||
free(whitespace);
|
||||
whitespace = NULL;
|
||||
} else
|
||||
SET(WHITESPACE_DISPLAY);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
if (!strcasecmp(rcopts[i].name, "punct")) {
|
||||
if (strcasecmp(rcopts[i].name, "punct") == 0) {
|
||||
punct = mallocstrcpy(NULL, option);
|
||||
if (strchr(punct, '\t') != NULL || strchr(punct, ' ') != NULL) {
|
||||
rcfile_error(_("Non-tab and non-space characters required"));
|
||||
rcfile_error(N_("Non-tab and non-space characters required"));
|
||||
free(punct);
|
||||
punct = NULL;
|
||||
}
|
||||
} else if (!strcasecmp(rcopts[i].name, "brackets")) {
|
||||
} else if (strcasecmp(rcopts[i].name, "brackets") == 0) {
|
||||
brackets = mallocstrcpy(NULL, option);
|
||||
if (strchr(brackets, '\t') != NULL || strchr(brackets, ' ') != NULL) {
|
||||
rcfile_error(_("Non-tab and non-space characters required"));
|
||||
rcfile_error(N_("Non-tab and non-space characters required"));
|
||||
free(brackets);
|
||||
brackets = NULL;
|
||||
}
|
||||
} else if (!strcasecmp(rcopts[i].name, "quotestr"))
|
||||
} else if (strcasecmp(rcopts[i].name, "quotestr") == 0)
|
||||
quotestr = mallocstrcpy(NULL, option);
|
||||
else
|
||||
#endif
|
||||
#ifndef NANO_SMALL
|
||||
if (!strcasecmp(rcopts[i].name, "backupdir"))
|
||||
if (strcasecmp(rcopts[i].name, "backupdir") == 0)
|
||||
backup_dir = mallocstrcpy(NULL, option);
|
||||
else
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
if (!strcasecmp(rcopts[i].name, "speller"))
|
||||
if (strcasecmp(rcopts[i].name, "speller") == 0)
|
||||
alt_speller = mallocstrcpy(NULL, option);
|
||||
else
|
||||
#endif
|
||||
if (!strcasecmp(rcopts[i].name, "tabsize")) {
|
||||
char *first_error;
|
||||
|
||||
/* Using strtol instead of atoi lets us
|
||||
* accept 0 while checking other
|
||||
* errors. */
|
||||
j = (int)strtol(option, &first_error, 10);
|
||||
if (errno == ERANGE || *option == '\0' || *first_error != '\0')
|
||||
rcfile_error(_("Requested tab size %d invalid"),
|
||||
j);
|
||||
else
|
||||
tabsize = j;
|
||||
if (strcasecmp(rcopts[i].name, "tabsize") == 0) {
|
||||
if (!parse_num(option, &tabsize) || tabsize <= 0)
|
||||
rcfile_error(N_("Requested tab size %s invalid"), option);
|
||||
tabsize = -1;
|
||||
}
|
||||
} else
|
||||
SET(rcopts[i].flag);
|
||||
@@ -669,8 +633,13 @@ void parse_rcfile(FILE *rcstream)
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
if (errors)
|
||||
rcfile_error(_("Errors found in .nanorc file"));
|
||||
|
||||
if (errors) {
|
||||
errors = FALSE;
|
||||
fprintf(stderr, _("\nPress Return to continue starting nano\n"));
|
||||
while (getchar() != '\n')
|
||||
;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -679,16 +648,13 @@ void parse_rcfile(FILE *rcstream)
|
||||
void do_rcfile(void)
|
||||
{
|
||||
FILE *rcstream;
|
||||
const struct passwd *userage;
|
||||
uid_t euid = geteuid();
|
||||
char *homenv = getenv("HOME");
|
||||
|
||||
#ifdef SYSCONFDIR
|
||||
assert(sizeof(SYSCONFDIR) == strlen(SYSCONFDIR) + 1);
|
||||
nanorc = charalloc(sizeof(SYSCONFDIR) + 7);
|
||||
sprintf(nanorc, "%s/nanorc", SYSCONFDIR);
|
||||
nanorc = SYSCONFDIR "/nanorc";
|
||||
/* Try to open system nanorc */
|
||||
if ((rcstream = fopen(nanorc, "r")) != NULL) {
|
||||
rcstream = fopen(nanorc, "r");
|
||||
if (rcstream != NULL) {
|
||||
/* Parse it! */
|
||||
parse_rcfile(rcstream);
|
||||
fclose(rcstream);
|
||||
@@ -697,47 +663,51 @@ void do_rcfile(void)
|
||||
|
||||
lineno = 0;
|
||||
|
||||
/* Rely on $HOME, fall back on getpwuid() */
|
||||
if (homenv != NULL) {
|
||||
nanorc = charealloc(nanorc, strlen(homenv) + 10);
|
||||
sprintf(nanorc, "%s/.nanorc", homenv);
|
||||
} else {
|
||||
userage = getpwuid(euid);
|
||||
endpwent();
|
||||
{
|
||||
const char *homenv = getenv("HOME");
|
||||
|
||||
if (userage == NULL) {
|
||||
rcfile_error(_("I can't find my home directory! Wah!"));
|
||||
SET(NO_RCFILE);
|
||||
} else {
|
||||
nanorc = charealloc(nanorc, strlen(userage->pw_dir) + 9);
|
||||
sprintf(nanorc, "%s/.nanorc", userage->pw_dir);
|
||||
/* Rely on $HOME, fall back on getpwuid() */
|
||||
if (homenv == NULL) {
|
||||
const struct passwd *userage = getpwuid(geteuid());
|
||||
|
||||
if (userage != NULL)
|
||||
homenv = userage->pw_dir;
|
||||
}
|
||||
homedir = mallocstrcpy(NULL, homenv);
|
||||
}
|
||||
|
||||
if (!ISSET(NO_RCFILE)) {
|
||||
if (homedir == NULL) {
|
||||
rcfile_error(N_("I can't find my home directory! Wah!"));
|
||||
SET(NO_RCFILE);
|
||||
} else {
|
||||
size_t homelen = strlen(homedir);
|
||||
char *nanorcf = charalloc(homelen + 9);
|
||||
|
||||
nanorc = nanorcf;
|
||||
strcpy(nanorcf, homedir);
|
||||
strcpy(nanorcf + homelen, "/.nanorc");
|
||||
|
||||
#if defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING)
|
||||
/* If we've already read SYSCONFDIR/nanorc (if it's there), we're
|
||||
root, and --disable-wrapping-as-root is used, turn wrapping off */
|
||||
if (euid == NANO_ROOT_UID)
|
||||
if (geteuid() == NANO_ROOT_UID)
|
||||
SET(NO_WRAP);
|
||||
#endif
|
||||
if ((rcstream = fopen(nanorc, "r")) == NULL) {
|
||||
rcstream = fopen(nanorc, "r");
|
||||
if (rcstream == NULL) {
|
||||
/* Don't complain about the file not existing */
|
||||
if (errno != ENOENT) {
|
||||
rcfile_error(_("Unable to open ~/.nanorc file, %s"),
|
||||
strerror(errno));
|
||||
rcfile_error(N_("Error reading %s: %s"), nanorc, strerror(errno));
|
||||
SET(NO_RCFILE);
|
||||
}
|
||||
} else {
|
||||
parse_rcfile(rcstream);
|
||||
fclose(rcstream);
|
||||
}
|
||||
free(nanorcf);
|
||||
}
|
||||
lineno = 0;
|
||||
|
||||
free(nanorc);
|
||||
#ifdef ENABLE_COLOR
|
||||
set_colorpairs();
|
||||
#endif
|
||||
|
||||
155
src/search.c
155
src/search.c
@@ -238,11 +238,9 @@ int search_init(int replacing)
|
||||
#ifndef NANO_SMALL
|
||||
search_history.current = search_history.next;
|
||||
#endif
|
||||
i = (int)strtol(answer, &buf, 10); /* Just testing answer here. */
|
||||
if (!(errno == ERANGE || *answer == '\0' || *buf != '\0'))
|
||||
do_gotoline(-1, 0);
|
||||
else
|
||||
do_gotoline_void();
|
||||
/* If answer parses as an integer, put it up on the
|
||||
* statusbar. */
|
||||
do_gotoline(parse_num(answer, NULL) ? -1 : 0, FALSE);
|
||||
/* Fall through. */
|
||||
default:
|
||||
return -1;
|
||||
@@ -359,9 +357,10 @@ int findnextstr(int can_display_wrap, int wholeword, const filestruct
|
||||
}
|
||||
|
||||
/* Search for a string. */
|
||||
int do_search(void)
|
||||
void do_search(void)
|
||||
{
|
||||
int old_pww = placewewant, i, fileptr_x = current_x, didfind;
|
||||
size_t old_pww = placewewant, fileptr_x = current_x;
|
||||
int i, didfind;
|
||||
filestruct *fileptr = current;
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
@@ -380,7 +379,7 @@ int do_search(void)
|
||||
#endif
|
||||
|
||||
if (i != 0)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
/* If answer is now "", copy last_search into answer. */
|
||||
if (answer[0] == '\0')
|
||||
@@ -407,8 +406,10 @@ int do_search(void)
|
||||
* that we find one only once per line. We should only end up
|
||||
* back at the same position if the string isn't found again, in
|
||||
* which case it's the only occurrence. */
|
||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp, last_search)) {
|
||||
didfind = findnextstr(TRUE, FALSE, current, current_x, answer, TRUE);
|
||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
||||
last_search)) {
|
||||
didfind = findnextstr(TRUE, FALSE, current, current_x,
|
||||
answer, TRUE);
|
||||
if (fileptr == current && fileptr_x == current_x && !didfind)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
} else {
|
||||
@@ -422,15 +423,14 @@ int do_search(void)
|
||||
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)
|
||||
void do_research(void)
|
||||
{
|
||||
int old_pww = placewewant, fileptr_x = current_x, didfind;
|
||||
size_t old_pww = placewewant, fileptr_x = current_x;
|
||||
int didfind;
|
||||
filestruct *fileptr = current;
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
@@ -443,11 +443,12 @@ int do_research(void)
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Since answer is "", use last_search! */
|
||||
if (ISSET(USE_REGEXP) && regexp_init(last_search) == 0)
|
||||
return -1;
|
||||
return;
|
||||
#endif
|
||||
|
||||
search_last_line = FALSE;
|
||||
didfind = findnextstr(TRUE, FALSE, current, current_x, last_search, FALSE);
|
||||
didfind = findnextstr(TRUE, FALSE, current, current_x,
|
||||
last_search, FALSE);
|
||||
|
||||
/* Check to see if there's only one occurrence of the string and
|
||||
* we're on it now. */
|
||||
@@ -458,8 +459,10 @@ int do_research(void)
|
||||
* "^$"), so that we find one only once per line. We should
|
||||
* only end up back at the same position if the string isn't
|
||||
* found again, in which case it's the only occurrence. */
|
||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp, last_search)) {
|
||||
didfind = findnextstr(TRUE, FALSE, current, current_x, answer, TRUE);
|
||||
if (ISSET(USE_REGEXP) && regexp_bol_or_eol(&search_regexp,
|
||||
last_search)) {
|
||||
didfind = findnextstr(TRUE, FALSE, current, current_x,
|
||||
answer, TRUE);
|
||||
if (fileptr == current && fileptr_x == current_x && !didfind)
|
||||
statusbar(_("This is the only occurrence"));
|
||||
} else {
|
||||
@@ -475,8 +478,6 @@ int do_research(void)
|
||||
placewewant = xplustabs();
|
||||
edit_redraw(fileptr, old_pww);
|
||||
search_abort();
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -587,8 +588,8 @@ 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 old_pww = placewewant, replaceall = 0, numreplaced = -1;
|
||||
size_t current_x_save = current_x;
|
||||
int replaceall = FALSE, numreplaced = -1;
|
||||
size_t old_pww = placewewant, current_x_save = current_x;
|
||||
const filestruct *current_save = current;
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* The starting-line match and bol/eol regex flags. */
|
||||
@@ -634,8 +635,11 @@ int do_replace_loop(const char *needle, const filestruct *real_current,
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!replaceall)
|
||||
if (!replaceall) {
|
||||
placewewant = xplustabs();
|
||||
edit_redraw(current_save, old_pww);
|
||||
old_pww = placewewant;
|
||||
}
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
@@ -681,7 +685,7 @@ int do_replace_loop(const char *needle, const filestruct *real_current,
|
||||
int length_change;
|
||||
|
||||
if (i == 2)
|
||||
replaceall = 1;
|
||||
replaceall = TRUE;
|
||||
|
||||
copy = replace_line(needle);
|
||||
|
||||
@@ -743,7 +747,7 @@ int do_replace_loop(const char *needle, const filestruct *real_current,
|
||||
}
|
||||
|
||||
/* Replace a string. */
|
||||
int do_replace(void)
|
||||
void do_replace(void)
|
||||
{
|
||||
int i, numreplaced;
|
||||
filestruct *edittop_save, *begin;
|
||||
@@ -752,23 +756,23 @@ int do_replace(void)
|
||||
if (ISSET(VIEW_MODE)) {
|
||||
print_view_warning();
|
||||
replace_abort();
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
i = search_init(1);
|
||||
if (i == -1) { /* Cancel, Go to Line, blank search
|
||||
* string, or regcomp() failed. */
|
||||
replace_abort();
|
||||
return 0;
|
||||
return;
|
||||
} else if (i == -2) { /* No Replace. */
|
||||
do_search();
|
||||
return 0;
|
||||
return;
|
||||
} else if (i == 1) /* Case Sensitive, Backwards, or Regexp
|
||||
* search toggle. */
|
||||
do_replace();
|
||||
|
||||
if (i != 0)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
/* If answer is not "", add answer to the search history list and
|
||||
* copy answer into last_search. */
|
||||
@@ -804,7 +808,7 @@ int do_replace(void)
|
||||
statusbar(_("Replace Cancelled"));
|
||||
}
|
||||
replace_abort();
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
last_replace = mallocstrcpy(last_replace, answer);
|
||||
@@ -818,24 +822,24 @@ int do_replace(void)
|
||||
numreplaced = do_replace_loop(last_search, begin, &beginx, FALSE);
|
||||
|
||||
/* Restore where we were. */
|
||||
edittop = edittop_save;
|
||||
current = begin;
|
||||
current_x = beginx;
|
||||
renumber_all();
|
||||
edit_update(edittop_save, TOP);
|
||||
edit_refresh();
|
||||
|
||||
if (numreplaced >= 0)
|
||||
statusbar(P_("Replaced %d occurrence", "Replaced %d occurrences",
|
||||
numreplaced), numreplaced);
|
||||
|
||||
replace_abort();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_gotoline(int line, int save_pos)
|
||||
void do_gotoline(int line, bool save_pos)
|
||||
{
|
||||
if (line <= 0) { /* Ask for it */
|
||||
if (line <= 0) { /* Ask for it. */
|
||||
char *ans = mallocstrcpy(NULL, answer);
|
||||
int st = statusq(FALSE, goto_list, line != 0 ? ans : "",
|
||||
int st = statusq(FALSE, goto_list, line < 0 ? ans : "",
|
||||
#ifndef NANO_SMALL
|
||||
NULL,
|
||||
#endif
|
||||
@@ -848,64 +852,70 @@ int do_gotoline(int line, int save_pos)
|
||||
statusbar(_("Aborted"));
|
||||
if (st != 0) {
|
||||
display_main_list();
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
line = atoi(answer);
|
||||
|
||||
/* Bounds check. */
|
||||
if (line <= 0) {
|
||||
if (!parse_num(answer, &line) || line < 0) {
|
||||
statusbar(_("Come on, be reasonable"));
|
||||
display_main_list();
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (current = fileage; current->next != NULL && line > 1; line--)
|
||||
current = current->next;
|
||||
if (current->lineno > line) {
|
||||
for (; current->prev != NULL && current->lineno > line;
|
||||
current = current->prev)
|
||||
;
|
||||
} else {
|
||||
for (; current->next != NULL && current->lineno < line;
|
||||
current = current->next)
|
||||
;
|
||||
}
|
||||
|
||||
current_x = 0;
|
||||
|
||||
/* If save_pos is nonzero, don't change the cursor position when
|
||||
/* If save_pos is TRUE, don't change the cursor position when
|
||||
* updating the edit window. */
|
||||
edit_update(current, save_pos ? NONE : CENTER);
|
||||
|
||||
placewewant = 0;
|
||||
display_main_list();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_gotoline_void(void)
|
||||
void do_gotoline_void(void)
|
||||
{
|
||||
return do_gotoline(0, 0);
|
||||
do_gotoline(0, FALSE);
|
||||
}
|
||||
|
||||
#if defined(ENABLE_MULTIBUFFER) || !defined(DISABLE_SPELLER)
|
||||
void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant)
|
||||
void do_gotopos(int line, int pos_x, int pos_y, size_t pos_pww)
|
||||
{
|
||||
/* since do_gotoline() resets the x-coordinate but not the
|
||||
y-coordinate, set the coordinates up this way */
|
||||
/* Since do_gotoline() resets the x-coordinate but not the
|
||||
* y-coordinate, set the coordinates up this way. */
|
||||
current_y = pos_y;
|
||||
do_gotoline(line, 1);
|
||||
do_gotoline(line, TRUE);
|
||||
|
||||
/* make sure that the x-coordinate is sane here */
|
||||
if (pos_x > strlen(current->data))
|
||||
pos_x = strlen(current->data);
|
||||
/* Make sure that the x-coordinate is sane here. */
|
||||
current_x = strlen(current->data);
|
||||
if (pos_x < current_x)
|
||||
current_x = pos_x;
|
||||
|
||||
/* set the rest of the coordinates up */
|
||||
current_x = pos_x;
|
||||
placewewant = pos_placewewant;
|
||||
/* Set the rest of the coordinates up. */
|
||||
placewewant = pos_pww;
|
||||
update_line(current, pos_x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
|
||||
int do_find_bracket(void)
|
||||
void do_find_bracket(void)
|
||||
{
|
||||
char ch_under_cursor, wanted_ch;
|
||||
const char *pos, *brackets = "([{<>}])";
|
||||
char regexp_pat[] = "[ ]";
|
||||
int old_pww = placewewant, current_x_save, flagsave, count = 1;
|
||||
size_t old_pww, current_x_save;
|
||||
int count = 1;
|
||||
long flags_save;
|
||||
filestruct *current_save;
|
||||
|
||||
ch_under_cursor = current->data[current_x];
|
||||
@@ -913,25 +923,28 @@ int do_find_bracket(void)
|
||||
pos = strchr(brackets, ch_under_cursor);
|
||||
if (ch_under_cursor == '\0' || pos == NULL) {
|
||||
statusbar(_("Not a bracket"));
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
|
||||
assert(strlen(brackets) % 2 == 0);
|
||||
wanted_ch = brackets[(strlen(brackets) - 1) - (pos - brackets)];
|
||||
|
||||
old_pww = placewewant;
|
||||
current_x_save = current_x;
|
||||
current_save = current;
|
||||
flagsave = flags;
|
||||
flags_save = flags;
|
||||
SET(USE_REGEXP);
|
||||
|
||||
/* Apparent near redundancy with regexp_pat[] here is needed.
|
||||
* "[][]" works, "[[]]" doesn't. */
|
||||
|
||||
if (pos < brackets + (strlen(brackets) / 2)) { /* On a left bracket. */
|
||||
if (pos < brackets + (strlen(brackets) / 2)) {
|
||||
/* On a left bracket. */
|
||||
regexp_pat[1] = wanted_ch;
|
||||
regexp_pat[2] = ch_under_cursor;
|
||||
UNSET(REVERSE_SEARCH);
|
||||
} else { /* On a right bracket. */
|
||||
} else {
|
||||
/* On a right bracket. */
|
||||
regexp_pat[1] = ch_under_cursor;
|
||||
regexp_pat[2] = wanted_ch;
|
||||
SET(REVERSE_SEARCH);
|
||||
@@ -943,7 +956,8 @@ int do_find_bracket(void)
|
||||
|
||||
search_last_line = FALSE;
|
||||
while (TRUE) {
|
||||
if (findnextstr(FALSE, FALSE, current, current_x, regexp_pat, FALSE) != 0) {
|
||||
if (findnextstr(FALSE, FALSE, current, current_x, regexp_pat,
|
||||
FALSE) != 0) {
|
||||
/* Found identical bracket. */
|
||||
if (current->data[current_x] == ch_under_cursor)
|
||||
count++;
|
||||
@@ -964,8 +978,7 @@ int do_find_bracket(void)
|
||||
}
|
||||
|
||||
regexp_cleanup();
|
||||
flags = flagsave;
|
||||
return 0;
|
||||
flags = flags_save;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -993,7 +1006,7 @@ void history_init(void)
|
||||
}
|
||||
|
||||
/* find first node containing string *s in history list *h */
|
||||
historytype *find_node(historytype *h, char *s)
|
||||
historytype *find_node(historytype *h, const char *s)
|
||||
{
|
||||
for (; h->next != NULL; h = h->next)
|
||||
if (strcmp(s, h->data) == 0)
|
||||
@@ -1017,14 +1030,14 @@ void insert_node(historytype *h, const char *s)
|
||||
|
||||
a = (historytype *)nmalloc(sizeof(historytype));
|
||||
a->next = h->next;
|
||||
a->prev = h->next->prev;
|
||||
a->prev = h;
|
||||
h->next->prev = a;
|
||||
h->next = a;
|
||||
a->data = mallocstrcpy(NULL, s);
|
||||
}
|
||||
|
||||
/* update history list */
|
||||
void update_history(historyheadtype *h, char *s)
|
||||
void update_history(historyheadtype *h, const char *s)
|
||||
{
|
||||
historytype *p;
|
||||
|
||||
@@ -1082,14 +1095,16 @@ char *get_history_completion(historyheadtype *h, char *s)
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* free a history list */
|
||||
void free_history(historyheadtype *h)
|
||||
{
|
||||
historytype *p, *n;
|
||||
historytype *p;
|
||||
|
||||
for (p = h->next; (n = p->next); p = n)
|
||||
for (p = h->next; p->next != NULL; p = p->next)
|
||||
remove_node(p);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* end of history support functions */
|
||||
#endif /* !NANO_SMALL */
|
||||
|
||||
94
src/utils.c
94
src/utils.c
@@ -21,11 +21,12 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
@@ -83,6 +84,23 @@ int num_of_digits(int n)
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Read an int from str, and store it in *val (if val is not NULL). On
|
||||
* error, we return FALSE and don't change *val. Otherwise, we return
|
||||
* TRUE. */
|
||||
bool parse_num(const char *str, ssize_t *val)
|
||||
{
|
||||
char *first_error;
|
||||
ssize_t j;
|
||||
|
||||
assert(str != NULL);
|
||||
j = (ssize_t)strtol(str, &first_error, 10);
|
||||
if (errno == ERANGE || *str == '\0' || *first_error != '\0')
|
||||
return FALSE;
|
||||
if (val != NULL)
|
||||
*val = j;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Fix the memory allocation for a string. */
|
||||
void align(char **strp)
|
||||
{
|
||||
@@ -149,10 +167,8 @@ int nstrnicmp(const char *s1, const char *s2, size_t n)
|
||||
|
||||
if (n > 0)
|
||||
return (tolower(*s1) - tolower(*s2));
|
||||
else if (n == 0)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -224,6 +240,66 @@ size_t nstrnlen(const char *s, size_t maxlen)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||
#ifndef HAVE_GETLINE
|
||||
/* This function is equivalent to getline(). It was adapted from
|
||||
* GNU mailutils' getline() function. */
|
||||
ssize_t ngetline(char **lineptr, size_t *n, FILE *stream)
|
||||
{
|
||||
return getdelim(lineptr, n, '\n', stream);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETDELIM
|
||||
/* This function is equivalent to getdelim(). It was adapted from
|
||||
* GNU mailutils' getdelim() function. */
|
||||
ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream)
|
||||
{
|
||||
size_t indx = 0;
|
||||
int c;
|
||||
|
||||
/* Sanity checks. */
|
||||
if (lineptr == NULL || n == NULL || stream == NULL)
|
||||
return -1;
|
||||
|
||||
/* Allocate the line the first time. */
|
||||
if (*lineptr == NULL) {
|
||||
*lineptr = charalloc(128);
|
||||
*n = 128;
|
||||
}
|
||||
|
||||
while ((c = getc(stream)) != EOF) {
|
||||
/* Check if more memory is needed. */
|
||||
if (indx >= *n) {
|
||||
*lineptr = charealloc(*lineptr, *n + 128);
|
||||
*n += 128;
|
||||
}
|
||||
|
||||
/* Push the result in the line. */
|
||||
(*lineptr)[indx++] = (char)c;
|
||||
|
||||
/* Bail out. */
|
||||
if (c == delim)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Make room for the null character. */
|
||||
if (indx >= *n) {
|
||||
*lineptr = charealloc(*lineptr, *n + 128);
|
||||
*n += 128;
|
||||
}
|
||||
|
||||
/* Null terminate the buffer. */
|
||||
null_at(lineptr, indx++);
|
||||
*n = indx;
|
||||
|
||||
/* The last line may not have the delimiter, we have to return what
|
||||
* we got and the error will be seen on the next iteration. */
|
||||
return (c == EOF && (indx - 1) == 0) ? -1 : indx - 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* !NANO_SMALL && ENABLE_NANORC */
|
||||
|
||||
/* If we are searching backwards, we will find the last match that
|
||||
* starts no later than start. Otherwise we find the first match
|
||||
* starting no earlier than start. If we are doing a regexp search, we
|
||||
@@ -352,8 +428,8 @@ void new_magicline(void)
|
||||
#ifndef NANO_SMALL
|
||||
/* Set top_x and bot_x to the top and bottom x-coordinates of the mark,
|
||||
* respectively, based on the locations of top and bot. */
|
||||
void mark_order(const filestruct **top, size_t *top_x,
|
||||
const filestruct **bot, size_t *bot_x)
|
||||
void mark_order(const filestruct **top, size_t *top_x, const filestruct
|
||||
**bot, size_t *bot_x)
|
||||
{
|
||||
assert(top != NULL && top_x != NULL && bot != NULL && bot_x != NULL);
|
||||
if ((current->lineno == mark_beginbuf->lineno && current_x > mark_beginx)
|
||||
@@ -420,10 +496,10 @@ int check_wildcard_match(const char *text, const char *pattern)
|
||||
found = TRUE;
|
||||
}
|
||||
len = strlen(text);
|
||||
if (found == FALSE && len != 0) {
|
||||
if (!found && len != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
if (found == TRUE) {
|
||||
if (found) {
|
||||
if (strlen(pattern) == 0 && len == 1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
145
src/winio.c
145
src/winio.c
@@ -193,7 +193,8 @@ int get_translated_kbinput(int kbinput, int *es
|
||||
#endif
|
||||
)
|
||||
{
|
||||
static size_t escapes = 0, ascii_digits = 0;
|
||||
static int escapes = 0;
|
||||
static size_t ascii_digits = 0;
|
||||
int retval = ERR;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
@@ -413,9 +414,9 @@ int get_translated_kbinput(int kbinput, int *es
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_translated_kbinput(): kbinput = %d, es = %d, escapes = %d, ascii_digits = %d, retval = %d\n", kbinput, *es, escapes, ascii_digits, retval);
|
||||
fprintf(stderr, "get_translated_kbinput(): kbinput = %d, es = %d, escapes = %d, ascii_digits = %lu, retval = %d\n", kbinput, *es, escapes, (unsigned long)ascii_digits, retval);
|
||||
#endif
|
||||
|
||||
/* Return the result. */
|
||||
@@ -511,7 +512,7 @@ int get_ascii_kbinput(int kbinput, size_t ascii_digits
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_ascii_kbinput(): kbinput = %d, ascii_digits = %d, ascii_kbinput = %d, retval = %d\n", kbinput, ascii_digits, ascii_kbinput, retval);
|
||||
fprintf(stderr, "get_ascii_kbinput(): kbinput = %d, ascii_digits = %lu, ascii_kbinput = %d, retval = %d\n", kbinput, (unsigned long)ascii_digits, ascii_kbinput, retval);
|
||||
#endif
|
||||
|
||||
/* If the result is an ASCII character, reset the ASCII character
|
||||
@@ -550,7 +551,7 @@ int get_control_kbinput(int kbinput)
|
||||
retval = kbinput;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_control_kbinput(): kbinput = %d, retval = %d\n", kbinput, ascii_digits, *complete, retval);
|
||||
fprintf(stderr, "get_control_kbinput(): kbinput = %d, retval = %d\n", kbinput, retval);
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
@@ -1069,8 +1070,8 @@ int get_escape_seq_abcd(int kbinput)
|
||||
/* Read in a string of input characters (e.g. an escape sequence)
|
||||
* verbatim. Store the string in v_kbinput and return the length
|
||||
* of the string in v_len. Assume nodelay(win) is FALSE. */
|
||||
int *get_verbatim_kbinput(WINDOW *win, int *v_kbinput, size_t
|
||||
*v_len, int allow_ascii)
|
||||
int *get_verbatim_kbinput(WINDOW *win, int *v_kbinput, size_t *v_len,
|
||||
int allow_ascii)
|
||||
{
|
||||
int kbinput;
|
||||
size_t i = 0, v_newlen = 0;
|
||||
@@ -1096,7 +1097,7 @@ int *get_verbatim_kbinput(WINDOW *win, int *v_kbinput, size_t
|
||||
(*v_len)++;
|
||||
v_kbinput[0] = kbinput;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_verbatim_kbinput(): kbinput = %d, v_len = %d\n", kbinput, *v_len);
|
||||
fprintf(stderr, "get_verbatim_kbinput(): kbinput = %d, v_len = %lu\n", kbinput, (unsigned long)*v_len);
|
||||
#endif
|
||||
|
||||
/* Read any following characters using non-blocking input, until
|
||||
@@ -1111,7 +1112,7 @@ int *get_verbatim_kbinput(WINDOW *win, int *v_kbinput, size_t
|
||||
v_kbinput = (int *)nrealloc(v_kbinput, *v_len * sizeof(int));
|
||||
v_kbinput[*v_len - 1] = kbinput;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_verbatim_kbinput(): kbinput = %d, v_len = %d\n", kbinput, *v_len);
|
||||
fprintf(stderr, "get_verbatim_kbinput(): kbinput = %d, v_len = %lu\n", kbinput, (unsigned long)*v_len);
|
||||
#endif
|
||||
}
|
||||
nodelay(win, FALSE);
|
||||
@@ -1230,7 +1231,7 @@ int get_untranslated_kbinput(int kbinput, size_t position, int
|
||||
retval = kbinput;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_untranslated_kbinput(): kbinput = %d, position = %d, ascii_digits = %d\n", kbinput, position, ascii_digits);
|
||||
fprintf(stderr, "get_untranslated_kbinput(): kbinput = %d, position = %lu, ascii_digits = %lu\n", kbinput, (unsigned long)position, (unsigned long)ascii_digits);
|
||||
#endif
|
||||
|
||||
return retval;
|
||||
@@ -1239,12 +1240,12 @@ int get_untranslated_kbinput(int kbinput, size_t position, int
|
||||
#ifndef DISABLE_MOUSE
|
||||
/* Check for a mouse event, and if one's taken place, save the
|
||||
* coordinates where it took place in mouse_x and mouse_y. After that,
|
||||
* if allow_shortcuts is zero, return 0. Otherwise, if the mouse event
|
||||
* took place on the shortcut list on the bottom two lines of the screen
|
||||
* (assuming that the shortcut list is visible), figure out which
|
||||
* shortcut was clicked and ungetch() the equivalent keystroke(s).
|
||||
* Return 0 if no keystrokes were ungetch()ed, or 1 if at least one was.
|
||||
* Assume that KEY_MOUSE has already been read in. */
|
||||
* assuming allow_shortcuts is FALSE, if the shortcut list on the
|
||||
* bottom two lines of the screen is visible and the mouse event took
|
||||
* place on it, figure out which shortcut was clicked and ungetch() the
|
||||
* equivalent keystroke(s). Return FALSE if no keystrokes were
|
||||
* ungetch()ed, or TRUE if at least one was. Assume that KEY_MOUSE has
|
||||
* already been read in. */
|
||||
int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||
{
|
||||
MEVENT mevent;
|
||||
@@ -1254,7 +1255,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||
|
||||
/* First, get the actual mouse event. */
|
||||
if (getmouse(&mevent) == ERR)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
/* Save the screen coordinates where the mouse event took place. */
|
||||
*mouse_x = mevent.x;
|
||||
@@ -1262,7 +1263,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||
|
||||
/* If we're not allowing shortcuts' we're done now. */
|
||||
if (!allow_shortcuts)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
/* Otherwise, if the current shortcut list is being displayed on the
|
||||
* last two lines of the screen and the mouse event took place
|
||||
@@ -1270,7 +1271,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||
* ungetch() the equivalent keystroke(s) for it. */
|
||||
if (!ISSET(NO_HELP) && wenclose(bottomwin, *mouse_y, *mouse_x)) {
|
||||
int i, j;
|
||||
int currslen;
|
||||
size_t currslen;
|
||||
/* The number of shortcuts in the current shortcut list. */
|
||||
const shortcut *s = currshortcut;
|
||||
/* The actual shortcut we clicked on, starting at the first
|
||||
@@ -1318,9 +1319,9 @@ int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts)
|
||||
ungetch(NANO_CONTROL_3);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1392,7 +1393,7 @@ void blank_titlebar(void)
|
||||
|
||||
void blank_edit(void)
|
||||
{
|
||||
size_t i;
|
||||
int i;
|
||||
for (i = 0; i < editwinrows; i++)
|
||||
mvwaddstr(edit, i, 0, hblank);
|
||||
}
|
||||
@@ -1535,7 +1536,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
#endif
|
||||
const shortcut *s
|
||||
#ifndef DISABLE_TABCOMP
|
||||
, int *list
|
||||
, bool *list
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -1545,7 +1546,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
/* the cursor position in 'answer' */
|
||||
int xend;
|
||||
/* length of 'answer', the status bar text */
|
||||
int tabbed = 0;
|
||||
bool tabbed = FALSE;
|
||||
/* used by input_tab() */
|
||||
const shortcut *t;
|
||||
|
||||
@@ -1589,7 +1590,8 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
|
||||
/* Make sure any editor screen updates are displayed before getting
|
||||
input */
|
||||
wrefresh(edit);
|
||||
wnoutrefresh(edit);
|
||||
wrefresh(bottomwin);
|
||||
|
||||
/* 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 writing
|
||||
@@ -1628,7 +1630,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
assert(0 <= x && x <= xend && xend == strlen(answer));
|
||||
|
||||
if (kbinput != '\t')
|
||||
tabbed = 0;
|
||||
tabbed = FALSE;
|
||||
|
||||
switch (kbinput) {
|
||||
#ifndef DISABLE_MOUSE
|
||||
@@ -1668,10 +1670,8 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
}
|
||||
break;
|
||||
case NANO_CUT_KEY:
|
||||
case NANO_UNCUT_KEY:
|
||||
/* If we're using restricted mode, the filename isn't blank,
|
||||
* and we're at the "Write File" prompt, disable Cut and
|
||||
* UnCut. */
|
||||
* and we're at the "Write File" prompt, disable Cut. */
|
||||
if (!ISSET(RESTRICTED) || filename[0] == '\0' || s != writefile_list) {
|
||||
null_at(&answer, 0);
|
||||
xend = 0;
|
||||
@@ -1736,7 +1736,8 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
search history, and we need to save the current
|
||||
answer in currentbuf; do this and reset use_cb to
|
||||
0 */
|
||||
if (currentbuf == NULL || (use_cb == 1 && strcmp(currentbuf, answer))) {
|
||||
if (currentbuf == NULL || (use_cb == 1 &&
|
||||
strcmp(currentbuf, answer) != 0)) {
|
||||
currentbuf = mallocstrcpy(currentbuf, answer);
|
||||
use_cb = 0;
|
||||
}
|
||||
@@ -1747,7 +1748,8 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
we need to make the string in currentbuf the current
|
||||
answer; do this, blow away currentbuf since we don't
|
||||
need it anymore, and reset use_cb to 0 */
|
||||
if (currentbuf != NULL && use_cb == 2 && strcmp(currentbuf, answer)) {
|
||||
if (currentbuf != NULL && use_cb == 2 &&
|
||||
strcmp(currentbuf, answer) != 0) {
|
||||
answer = mallocstrcpy(answer, currentbuf);
|
||||
free(currentbuf);
|
||||
currentbuf = NULL;
|
||||
@@ -1818,7 +1820,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||
fprintf(stderr, "Aha! \'%c\' (%d)\n", kbinput,
|
||||
kbinput);
|
||||
#endif
|
||||
if (meta_key == TRUE && (kbinput == t->metaval || kbinput == t->miscval))
|
||||
if (meta_key && (kbinput == t->metaval || kbinput == t->miscval))
|
||||
/* We hit a meta key. Do like above. We don't
|
||||
* just ungetch() the letter and let it get
|
||||
* caught above cause that screws the
|
||||
@@ -2182,7 +2184,6 @@ void reset_cursor(void)
|
||||
current_y = current->lineno - edittop->lineno;
|
||||
if (current_y < editwinrows) {
|
||||
size_t x = xplustabs();
|
||||
|
||||
wmove(edit, current_y, x - get_page_start(x));
|
||||
}
|
||||
}
|
||||
@@ -2545,7 +2546,7 @@ void update_line(const filestruct *fileptr, size_t index)
|
||||
/* Return a nonzero value if we need an update after moving
|
||||
* horizontally. We need one if the mark is on or if old_pww and
|
||||
* placewewant are on different pages. */
|
||||
int need_horizontal_update(int old_pww)
|
||||
int need_horizontal_update(size_t old_pww)
|
||||
{
|
||||
return
|
||||
#ifndef NANO_SMALL
|
||||
@@ -2557,7 +2558,7 @@ int need_horizontal_update(int old_pww)
|
||||
/* Return a nonzero value if we need an update after moving vertically.
|
||||
* We need one if the mark is on or if old_pww and placewewant
|
||||
* are on different pages. */
|
||||
int need_vertical_update(int old_pww)
|
||||
int need_vertical_update(size_t old_pww)
|
||||
{
|
||||
return
|
||||
#ifndef NANO_SMALL
|
||||
@@ -2632,7 +2633,7 @@ void edit_scroll(updown direction, int nlines)
|
||||
|
||||
/* Update any lines between old_current and current that need to be
|
||||
* updated. */
|
||||
void edit_redraw(const filestruct *old_current, int old_pww)
|
||||
void edit_redraw(const filestruct *old_current, size_t old_pww)
|
||||
{
|
||||
int do_refresh = need_vertical_update(0) ||
|
||||
need_vertical_update(old_pww);
|
||||
@@ -2691,7 +2692,7 @@ void edit_refresh(void)
|
||||
const filestruct *foo = edittop;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_refresh(): edittop->lineno = %ld\n", edittop->lineno);
|
||||
fprintf(stderr, "edit_refresh(): edittop->lineno = %d\n", edittop->lineno);
|
||||
#endif
|
||||
|
||||
while (nlines < editwinrows) {
|
||||
@@ -2706,9 +2707,6 @@ void edit_refresh(void)
|
||||
nlines++;
|
||||
}
|
||||
reset_cursor();
|
||||
|
||||
/* What the hell are we expecting to update the screen if this
|
||||
* isn't here? Luck? */
|
||||
wrefresh(edit);
|
||||
}
|
||||
}
|
||||
@@ -2746,7 +2744,7 @@ int statusq(int allowtabs, const shortcut *s, const char *def,
|
||||
char *foo = charalloc(COLS - 3);
|
||||
int ret;
|
||||
#ifndef DISABLE_TABCOMP
|
||||
int list = 0;
|
||||
bool list = FALSE;
|
||||
#endif
|
||||
|
||||
bottombars(s);
|
||||
@@ -2887,7 +2885,7 @@ int do_yesno(int all, const char *msg)
|
||||
/* Look ma! We get to duplicate lots of code from
|
||||
* do_mouse()!! */
|
||||
else if (kbinput == KEY_MOUSE) {
|
||||
kbinput = get_mouseinput(&mouse_x, &mouse_y, 0);
|
||||
kbinput = get_mouseinput(&mouse_x, &mouse_y, FALSE);
|
||||
|
||||
if (mouse_x != -1 && mouse_y != -1 && !ISSET(NO_HELP) &&
|
||||
wenclose(bottomwin, mouse_y, mouse_x) && mouse_x <
|
||||
@@ -2923,7 +2921,7 @@ int do_yesno(int all, const char *msg)
|
||||
return ok;
|
||||
}
|
||||
|
||||
int total_refresh(void)
|
||||
void total_refresh(void)
|
||||
{
|
||||
clearok(topwin, TRUE);
|
||||
clearok(edit, TRUE);
|
||||
@@ -2937,7 +2935,6 @@ int total_refresh(void)
|
||||
clearok(bottomwin, FALSE);
|
||||
edit_refresh();
|
||||
titlebar(NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void display_main_list(void)
|
||||
@@ -2945,14 +2942,14 @@ void display_main_list(void)
|
||||
bottombars(main_list);
|
||||
}
|
||||
|
||||
/* If constant is FALSE, the user typed ^C so we unconditionally display
|
||||
* the cursor position. Otherwise, we display it only if the character
|
||||
* position changed, and DISABLE_CURPOS is not set.
|
||||
/* If constant is FALSE, the user typed Ctrl-C, so we unconditionally
|
||||
* display the cursor position. Otherwise, we display it only if the
|
||||
* character position changed and DISABLE_CURPOS is not set.
|
||||
*
|
||||
* If constant is TRUE and DISABLE_CURPOS is set, we unset it and update
|
||||
* old_i and old_totsize. That way, we leave the current statusbar
|
||||
* alone, but next time we will display. */
|
||||
int do_cursorpos(int constant)
|
||||
void do_cursorpos(int constant)
|
||||
{
|
||||
const filestruct *fileptr;
|
||||
unsigned long i = 0;
|
||||
@@ -2970,19 +2967,23 @@ int do_cursorpos(int constant)
|
||||
}
|
||||
i += current_x;
|
||||
|
||||
/* Check whether totsize is correct. Else there is a bug
|
||||
* somewhere. */
|
||||
assert(current != filebot || i == totsize);
|
||||
|
||||
if (constant && ISSET(DISABLE_CURPOS)) {
|
||||
UNSET(DISABLE_CURPOS);
|
||||
old_i = i;
|
||||
old_totsize = totsize;
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* If constant is FALSE, display the position on the statusbar
|
||||
* unconditionally; otherwise, only display the position when the
|
||||
* character values have changed. */
|
||||
if (!constant || old_i != i || old_totsize != totsize) {
|
||||
unsigned long xpt = xplustabs() + 1;
|
||||
unsigned long cur_len = strlenpt(current->data) + 1;
|
||||
size_t xpt = xplustabs() + 1;
|
||||
size_t cur_len = strlenpt(current->data) + 1;
|
||||
int linepct = 100 * current->lineno / totlines;
|
||||
int colpct = 100 * xpt / cur_len;
|
||||
int bytepct = totsize == 0 ? 0 : 100 * i / totsize;
|
||||
@@ -2990,25 +2991,23 @@ int do_cursorpos(int constant)
|
||||
statusbar(
|
||||
_("line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%ld (%d%%)"),
|
||||
current->lineno, totlines, linepct,
|
||||
xpt, cur_len, colpct,
|
||||
(unsigned long)xpt, (unsigned long)cur_len, colpct,
|
||||
i, totsize, bytepct);
|
||||
UNSET(DISABLE_CURPOS);
|
||||
}
|
||||
|
||||
old_i = i;
|
||||
old_totsize = totsize;
|
||||
|
||||
reset_cursor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_cursorpos_void(void)
|
||||
void do_cursorpos_void(void)
|
||||
{
|
||||
return do_cursorpos(0);
|
||||
do_cursorpos(FALSE);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
/* Calculate the next line of help_text, starting at ptr. */
|
||||
int line_len(const char *ptr)
|
||||
int help_line_len(const char *ptr)
|
||||
{
|
||||
int j = 0;
|
||||
|
||||
@@ -3033,9 +3032,8 @@ int line_len(const char *ptr)
|
||||
return j;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_HELP
|
||||
/* Our dynamic, shortcut-list-compliant help function. */
|
||||
int do_help(void)
|
||||
void do_help(void)
|
||||
{
|
||||
int line = 0;
|
||||
/* The line number in help_text of the first displayed help line.
|
||||
@@ -3120,13 +3118,13 @@ int do_help(void)
|
||||
/* Calculate where in the text we should be, based on the
|
||||
* page. */
|
||||
for (i = 0; i < line; i++) {
|
||||
ptr += line_len(ptr);
|
||||
ptr += help_line_len(ptr);
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
}
|
||||
|
||||
for (i = 0; i < editwinrows && *ptr != '\0'; i++) {
|
||||
int j = line_len(ptr);
|
||||
int j = help_line_len(ptr);
|
||||
|
||||
mvwaddnstr(edit, i, 0, ptr, j);
|
||||
ptr += j;
|
||||
@@ -3137,7 +3135,8 @@ int do_help(void)
|
||||
|
||||
skip_redisplay:
|
||||
kbinput = get_kbinput(edit, &meta_key);
|
||||
} while (kbinput != NANO_EXIT_KEY && kbinput != NANO_EXIT_FKEY);
|
||||
} while (kbinput != NANO_CANCEL_KEY && kbinput != NANO_EXIT_KEY &&
|
||||
kbinput != NANO_EXIT_FKEY);
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
currshortcut = oldshortcut;
|
||||
@@ -3159,8 +3158,6 @@ int do_help(void)
|
||||
* anymore. */
|
||||
free(help_text);
|
||||
help_text = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif /* !DISABLE_HELP */
|
||||
|
||||
@@ -3168,7 +3165,7 @@ int do_help(void)
|
||||
* expect word to have tabs and control characters expanded. */
|
||||
void do_replace_highlight(int highlight_flag, const char *word)
|
||||
{
|
||||
int y = xplustabs();
|
||||
size_t y = xplustabs();
|
||||
size_t word_len = strlen(word);
|
||||
|
||||
y = get_page_start(y) + COLS - y;
|
||||
@@ -3291,14 +3288,14 @@ void do_credits(void)
|
||||
};
|
||||
|
||||
const char *xlcredits[XLCREDIT_LEN] = {
|
||||
"The nano text editor",
|
||||
"version",
|
||||
"Brought to you by:",
|
||||
"Special thanks to:",
|
||||
"The Free Software Foundation",
|
||||
"For ncurses:",
|
||||
"and anyone else we forgot...",
|
||||
"Thank you for using nano!"
|
||||
N_("The nano text editor"),
|
||||
N_("version"),
|
||||
N_("Brought to you by:"),
|
||||
N_("Special thanks to:"),
|
||||
N_("The Free Software Foundation"),
|
||||
N_("For ncurses:"),
|
||||
N_("and anyone else we forgot..."),
|
||||
N_("Thank you for using nano!")
|
||||
};
|
||||
|
||||
curs_set(0);
|
||||
|
||||
Reference in New Issue
Block a user