DLR: minor bits
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1264 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
64f49c7a99
commit
0341b58c05
42
ChangeLog
42
ChangeLog
|
@ -1,9 +1,20 @@
|
||||||
CVS code -
|
CVS code -
|
||||||
- General:
|
- General:
|
||||||
- Translation updates (see po/ChangeLog for details).
|
- Translation updates (see po/ChangeLog for details).
|
||||||
|
- Updated nano.1, nano.1.html, and nano.texi to fix an
|
||||||
|
inaccuracy in the description of -Q/--quotestr. (DLR)
|
||||||
|
- Set REG_EXTENDED in all regcomp() calls. (DLR)
|
||||||
|
- Minor cosmetic code cleanups. (DLR)
|
||||||
- configure.ac:
|
- configure.ac:
|
||||||
- Added pt_BR to ALL_LINGUAS (Jordi).
|
- Added pt_BR to ALL_LINGUAS (Jordi).
|
||||||
- files.c:
|
- files.c:
|
||||||
|
open_file()
|
||||||
|
- String change: "File "x" is a directory" -> ""x" is a
|
||||||
|
directory". (Jordi)
|
||||||
|
open_prevfile_void(), open_nextfile_void()
|
||||||
|
- Return the return values of open_prevfile() and
|
||||||
|
open_nextfile(), respectively, instead of (incorrectly)
|
||||||
|
calling them and returning 0. (DLR)
|
||||||
real_dir_from_tilde()
|
real_dir_from_tilde()
|
||||||
- Rework to use getpwent() exclusively and end reliance on
|
- Rework to use getpwent() exclusively and end reliance on
|
||||||
$HOME. Adapted from equivalent code in do_rcfile(). (DLR)
|
$HOME. Adapted from equivalent code in do_rcfile(). (DLR)
|
||||||
|
@ -11,6 +22,18 @@ CVS code -
|
||||||
- Most likely fixed the check marked with FIXME, so that tab
|
- Most likely fixed the check marked with FIXME, so that tab
|
||||||
completion works properly when we're trying to tab-complete a
|
completion works properly when we're trying to tab-complete a
|
||||||
username and the string already contains data. (DLR)
|
username and the string already contains data. (DLR)
|
||||||
|
- move.c:
|
||||||
|
page_up()
|
||||||
|
- Fix bug where current is moved up two lines when the up arrow
|
||||||
|
is pressed on the top line of the edit window; this causes a
|
||||||
|
segfault is the top line in the edit window is the second
|
||||||
|
line of the file, as the line current ends up on doesn't
|
||||||
|
exist. (Jeff Defouw)
|
||||||
|
do_down()
|
||||||
|
- Fix bug where, if the last line in the edit window is the
|
||||||
|
line before the magicline, and smooth scrolling is turned
|
||||||
|
off, pressing the down arrow on that last line centers the
|
||||||
|
cursor without updating the edit window. (Jeff DeFouw)
|
||||||
- nano.c:
|
- nano.c:
|
||||||
do_next_word(), do_prev_word()
|
do_next_word(), do_prev_word()
|
||||||
- If we're on the last/first line of the file, don't center the
|
- If we're on the last/first line of the file, don't center the
|
||||||
|
@ -24,6 +47,25 @@ CVS code -
|
||||||
- Rework to only call edit_refresh() unconditionally if
|
- Rework to only call edit_refresh() unconditionally if
|
||||||
ENABLE_COLOR is defined; if it isn't, and we're not deleting
|
ENABLE_COLOR is defined; if it isn't, and we're not deleting
|
||||||
the end of the line, only call update_line(). (DLR)
|
the end of the line, only call update_line(). (DLR)
|
||||||
|
do_wrap()
|
||||||
|
- Make sure wrapping is done properly when the number of
|
||||||
|
characters on the line is exactly one over the limit. (David
|
||||||
|
Benbennick)
|
||||||
|
do_alt_speller()
|
||||||
|
- Readd DLR's fix to preserve marking when using the alternate
|
||||||
|
spell checker; it was accidentally dropped. (David
|
||||||
|
Benbennick)
|
||||||
|
do_justify()
|
||||||
|
- Fix cosmetic problems caused when justifying on the
|
||||||
|
magicline. (David Benbennick)
|
||||||
|
- nano.h:
|
||||||
|
- Change search toggles for case sensitive searching and regexp
|
||||||
|
searching to M-C and M-R, respectively. (DLR; suggested by
|
||||||
|
Chris)
|
||||||
|
- TODO:
|
||||||
|
- Add entry in the 1.4 section for Pico's paragraph searching
|
||||||
|
ability (at the search prompt, ^W goes to the paragraph's
|
||||||
|
beginning, and ^O goes to the paragraph's end). (DLR)
|
||||||
|
|
||||||
GNU nano 1.1.10 - 07/25/2002
|
GNU nano 1.1.10 - 07/25/2002
|
||||||
- General:
|
- General:
|
||||||
|
|
1
TODO
1
TODO
|
@ -17,6 +17,7 @@ For version 1.2:
|
||||||
|
|
||||||
For version 1.4:
|
For version 1.4:
|
||||||
- UTF-8 support.
|
- UTF-8 support.
|
||||||
|
- Support for Pico's paragraph searching ability.
|
||||||
- Undo/Redo key?
|
- Undo/Redo key?
|
||||||
|
|
||||||
Old requests:
|
Old requests:
|
||||||
|
|
2
color.c
2
color.c
|
@ -99,7 +99,7 @@ void update_color(void)
|
||||||
for (tmpsyntax = syntaxes; tmpsyntax != NULL; tmpsyntax = tmpsyntax->next) {
|
for (tmpsyntax = syntaxes; tmpsyntax != NULL; tmpsyntax = tmpsyntax->next) {
|
||||||
exttype *e;
|
exttype *e;
|
||||||
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
|
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
|
||||||
regcomp(&syntaxfile_regexp, e->val, 0);
|
regcomp(&syntaxfile_regexp, e->val, REG_EXTENDED);
|
||||||
|
|
||||||
/* Set colorstrings if we matched the extension regex */
|
/* Set colorstrings if we matched the extension regex */
|
||||||
if (!regexec(&syntaxfile_regexp, filename, 1, synfilematches, 0))
|
if (!regexec(&syntaxfile_regexp, filename, 1, synfilematches, 0))
|
||||||
|
|
9
files.c
9
files.c
|
@ -45,7 +45,6 @@
|
||||||
#define _(string) (string)
|
#define _(string) (string)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* statics for here */
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
static int fileformat = 0; /* 0 = *nix, 1 = DOS, 2 = Mac */
|
static int fileformat = 0; /* 0 = *nix, 1 = DOS, 2 = Mac */
|
||||||
#endif
|
#endif
|
||||||
|
@ -362,7 +361,7 @@ int open_file(const char *filename, int insert, int quiet)
|
||||||
if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
|
if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
|
||||||
S_ISBLK(fileinfo.st_mode)) {
|
S_ISBLK(fileinfo.st_mode)) {
|
||||||
if (S_ISDIR(fileinfo.st_mode))
|
if (S_ISDIR(fileinfo.st_mode))
|
||||||
statusbar(_("File \"%s\" is a directory"), filename);
|
statusbar(_("\"%s\" is a directory"), filename);
|
||||||
else
|
else
|
||||||
/* Don't open character or block files. Sorry, /dev/sndstat! */
|
/* Don't open character or block files. Sorry, /dev/sndstat! */
|
||||||
statusbar(_("File \"%s\" is a device file"), filename);
|
statusbar(_("File \"%s\" is a device file"), filename);
|
||||||
|
@ -866,8 +865,7 @@ int open_prevfile(int closing_file)
|
||||||
/* This function is used by the shortcut list. */
|
/* This function is used by the shortcut list. */
|
||||||
int open_prevfile_void(void)
|
int open_prevfile_void(void)
|
||||||
{
|
{
|
||||||
open_prevfile(0);
|
return open_prevfile(0);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -930,8 +928,7 @@ int open_nextfile(int closing_file)
|
||||||
/* This function is used by the shortcut list. */
|
/* This function is used by the shortcut list. */
|
||||||
int open_nextfile_void(void)
|
int open_nextfile_void(void)
|
||||||
{
|
{
|
||||||
open_nextfile(0);
|
return open_nextfile(0);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
14
global.c
14
global.c
|
@ -163,13 +163,11 @@ int length_of_list(const shortcut *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize a struct *without* our lovely braces =( */
|
/* Initialize a struct *without* our lovely braces =( */
|
||||||
static void sc_init_one(shortcut **shortcutage, int key,
|
void sc_init_one(shortcut **shortcutage, int key, const char *desc,
|
||||||
const char *desc,
|
|
||||||
#ifndef DISABLE_HELP
|
#ifndef DISABLE_HELP
|
||||||
const char *help,
|
const char *help,
|
||||||
#endif
|
#endif
|
||||||
int alt, int misc1, int misc2, int view,
|
int alt, int misc1, int misc2, int view, int (*func) (void))
|
||||||
int (*func) (void))
|
|
||||||
{
|
{
|
||||||
shortcut *s;
|
shortcut *s;
|
||||||
|
|
||||||
|
@ -199,7 +197,7 @@ static void sc_init_one(shortcut **shortcutage, int key,
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* Create one new toggle structure, at the end of the toggles
|
/* Create one new toggle structure, at the end of the toggles
|
||||||
* linked list. */
|
* linked list. */
|
||||||
static void toggle_init_one(int val, const char *desc, int flag)
|
void toggle_init_one(int val, const char *desc, int flag)
|
||||||
{
|
{
|
||||||
toggle *u;
|
toggle *u;
|
||||||
|
|
||||||
|
@ -221,7 +219,7 @@ static void toggle_init_one(int val, const char *desc, int flag)
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* Deallocate all of the toggles. */
|
/* Deallocate all of the toggles. */
|
||||||
static void free_toggles(void)
|
void free_toggles(void)
|
||||||
{
|
{
|
||||||
while (toggles != NULL) {
|
while (toggles != NULL) {
|
||||||
toggle *pt = toggles; /* Think "previous toggle" */
|
toggle *pt = toggles; /* Think "previous toggle" */
|
||||||
|
@ -232,7 +230,7 @@ static void free_toggles(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void toggle_init(void)
|
void toggle_init(void)
|
||||||
{
|
{
|
||||||
char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
|
char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
|
||||||
*toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg,
|
*toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg,
|
||||||
|
@ -293,7 +291,7 @@ static void toggle_init(void)
|
||||||
#endif /* !NANO_SMALL */
|
#endif /* !NANO_SMALL */
|
||||||
|
|
||||||
/* Deallocate the given shortcut. */
|
/* Deallocate the given shortcut. */
|
||||||
static void free_shortcutage(shortcut **shortcutage)
|
void free_shortcutage(shortcut **shortcutage)
|
||||||
{
|
{
|
||||||
assert(shortcutage != NULL);
|
assert(shortcutage != NULL);
|
||||||
while (*shortcutage != NULL) {
|
while (*shortcutage != NULL) {
|
||||||
|
|
10
move.c
10
move.c
|
@ -105,11 +105,9 @@ void page_up(void)
|
||||||
line and don't center it. */
|
line and don't center it. */
|
||||||
if (edittop != fileage)
|
if (edittop != fileage)
|
||||||
center_cursor();
|
center_cursor();
|
||||||
else {
|
else
|
||||||
current = current->prev;
|
|
||||||
reset_cursor();
|
reset_cursor();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
current_y = 0;
|
current_y = 0;
|
||||||
|
|
||||||
|
@ -186,10 +184,10 @@ int do_down(void) {
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
edit_update(editbot->next, CENTER);
|
/* Set edittop so editbot->next (or else editbot) is
|
||||||
/* sets edittop so editbot->next is centered */
|
* centered, and set current_y = editwinrows / 2. */
|
||||||
|
edit_update(editbot->next != NULL ? editbot->next : editbot, CENTER);
|
||||||
center_cursor();
|
center_cursor();
|
||||||
/* sets current_y = editwinrows / 2 */
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
update_line(current->prev, 0);
|
update_line(current->prev, 0);
|
||||||
|
|
6
nano.1
6
nano.1
|
@ -6,7 +6,7 @@
|
||||||
.\" Public License for copying conditions. There is NO warranty.
|
.\" Public License for copying conditions. There is NO warranty.
|
||||||
.\"
|
.\"
|
||||||
.\" $Id$
|
.\" $Id$
|
||||||
.TH NANO 1 "July 14, 2002"
|
.TH NANO 1 "July 30, 2002"
|
||||||
.\" Please adjust this date whenever revising the manpage.
|
.\" Please adjust this date whenever revising the manpage.
|
||||||
.\"
|
.\"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
|
@ -56,7 +56,9 @@ Write file in Mac format.
|
||||||
Disable automatic conversion of files from DOS/Mac format.
|
Disable automatic conversion of files from DOS/Mac format.
|
||||||
.TP
|
.TP
|
||||||
.B \-Q \fI[str]\fP (\-\-quotestr=\fI[str]\fP)
|
.B \-Q \fI[str]\fP (\-\-quotestr=\fI[str]\fP)
|
||||||
Set the quoting string for justifying. The default is "> ".
|
Set the quoting string for justifying. The default is
|
||||||
|
"^([ \\t]*[|>:}#])+" if regular expression support is available, or
|
||||||
|
"> " otherwise.
|
||||||
.TP
|
.TP
|
||||||
.B \-R (\-\-regexp)
|
.B \-R (\-\-regexp)
|
||||||
Enable regular expression matching for search strings, as well as
|
Enable regular expression matching for search strings, as well as
|
||||||
|
|
|
@ -3,7 +3,7 @@ Content-type: text/html
|
||||||
<HTML><HEAD><TITLE>Manpage of NANO</TITLE>
|
<HTML><HEAD><TITLE>Manpage of NANO</TITLE>
|
||||||
</HEAD><BODY>
|
</HEAD><BODY>
|
||||||
<H1>NANO</H1>
|
<H1>NANO</H1>
|
||||||
Section: User Commands (1)<BR>Updated: July 14, 2002<BR><A HREF="#index">Index</A>
|
Section: User Commands (1)<BR>Updated: July 30, 2002<BR><A HREF="#index">Index</A>
|
||||||
<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,7 +77,9 @@ Disable automatic conversion of files from DOS/Mac format.
|
||||||
<DT><B>-Q </B><I>[str]</I> (--quotestr=<I>[str]</I>)
|
<DT><B>-Q </B><I>[str]</I> (--quotestr=<I>[str]</I>)
|
||||||
|
|
||||||
<DD>
|
<DD>
|
||||||
Set the quoting string for justifying. The default is "> ".
|
Set the quoting string for justifying. The default is
|
||||||
|
"^([ \t]*[|>:}#])+" if regular expression support is available, or
|
||||||
|
"> " otherwise.
|
||||||
<DT><B>-R (--regexp)</B>
|
<DT><B>-R (--regexp)</B>
|
||||||
|
|
||||||
<DD>
|
<DD>
|
||||||
|
@ -233,6 +235,6 @@ used by others).
|
||||||
This document was created by
|
This document was created by
|
||||||
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
|
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
|
||||||
using the manual pages.<BR>
|
using the manual pages.<BR>
|
||||||
Time: 00:51:19 GMT, July 14, 2002
|
Time: 21:12:05 GMT, July 30, 2002
|
||||||
</BODY>
|
</BODY>
|
||||||
</HTML>
|
</HTML>
|
||||||
|
|
126
nano.c
126
nano.c
|
@ -62,7 +62,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_WRAPJUSTIFY
|
#ifndef DISABLE_WRAPJUSTIFY
|
||||||
/* Former global, now static */
|
|
||||||
static int fill = 0; /* Fill - where to wrap lines, basically */
|
static int fill = 0; /* Fill - where to wrap lines, basically */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ static struct sigaction act; /* For all our fun signal handlers */
|
||||||
static sigjmp_buf jmpbuf; /* Used to return to mainloop after SIGWINCH */
|
static sigjmp_buf jmpbuf; /* Used to return to mainloop after SIGWINCH */
|
||||||
|
|
||||||
/* What we do when we're all set to exit */
|
/* What we do when we're all set to exit */
|
||||||
static RETSIGTYPE finish(int sigage)
|
RETSIGTYPE finish(int sigage)
|
||||||
{
|
{
|
||||||
keypad(edit, TRUE);
|
keypad(edit, TRUE);
|
||||||
keypad(bottomwin, TRUE);
|
keypad(bottomwin, TRUE);
|
||||||
|
@ -180,7 +179,7 @@ void die_save_file(const char *die_filename)
|
||||||
|
|
||||||
/* Die with an error message that the screen was too small if, well, the
|
/* Die with an error message that the screen was too small if, well, the
|
||||||
* screen is too small. */
|
* screen is too small. */
|
||||||
static void die_too_small(void)
|
void die_too_small(void)
|
||||||
{
|
{
|
||||||
die(_("Window size is too small for nano...\n"));
|
die(_("Window size is too small for nano...\n"));
|
||||||
}
|
}
|
||||||
|
@ -192,7 +191,7 @@ void print_view_warning(void)
|
||||||
|
|
||||||
/* Initialize global variables - no better way for now. If
|
/* Initialize global variables - no better way for now. If
|
||||||
* save_cutbuffer is nonzero, don't set cutbuffer to NULL. */
|
* save_cutbuffer is nonzero, don't set cutbuffer to NULL. */
|
||||||
static void global_init(int save_cutbuffer)
|
void global_init(int save_cutbuffer)
|
||||||
{
|
{
|
||||||
current_x = 0;
|
current_x = 0;
|
||||||
current_y = 0;
|
current_y = 0;
|
||||||
|
@ -329,7 +328,7 @@ void renumber(filestruct *fileptr)
|
||||||
/* Print one usage string to the screen, removes lots of duplicate
|
/* Print one usage string to the screen, removes lots of duplicate
|
||||||
* strings to translate and takes out the parts that shouldn't be
|
* strings to translate and takes out the parts that shouldn't be
|
||||||
* translatable (the flag names). */
|
* translatable (the flag names). */
|
||||||
static void print1opt(const char *shortflag, const char *longflag,
|
void print1opt(const char *shortflag, const char *longflag,
|
||||||
const char *desc)
|
const char *desc)
|
||||||
{
|
{
|
||||||
printf(" %s\t", shortflag);
|
printf(" %s\t", shortflag);
|
||||||
|
@ -347,7 +346,7 @@ static void print1opt(const char *shortflag, const char *longflag,
|
||||||
printf("%s\n", desc);
|
printf("%s\n", desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(void)
|
void usage(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
printf(_("Usage: nano [+LINE] [GNU long option] [option] [file]\n\n"));
|
printf(_("Usage: nano [+LINE] [GNU long option] [option] [file]\n\n"));
|
||||||
|
@ -423,7 +422,7 @@ static void usage(void)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void version(void)
|
void version(void)
|
||||||
{
|
{
|
||||||
printf(_(" GNU nano version %s (compiled %s, %s)\n"),
|
printf(_(" GNU nano version %s (compiled %s, %s)\n"),
|
||||||
VERSION, __TIME__, __DATE__);
|
VERSION, __TIME__, __DATE__);
|
||||||
|
@ -790,13 +789,15 @@ int do_wrap(filestruct *inptr)
|
||||||
int wrap_loc = -1; /* index of inptr->data where we wrap */
|
int wrap_loc = -1; /* index of inptr->data where we wrap */
|
||||||
int word_back = -1;
|
int word_back = -1;
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
char *indentation = NULL; /* indentation to prepend to the new line */
|
const char *indentation = NULL;
|
||||||
|
/* indentation to prepend to the new line */
|
||||||
int indent_len = 0; /* strlen(indentation) */
|
int indent_len = 0; /* strlen(indentation) */
|
||||||
#endif
|
#endif
|
||||||
char *after_break; /* text after the wrap point */
|
const char *after_break; /* text after the wrap point */
|
||||||
int after_break_len; /* strlen(after_break) */
|
int after_break_len; /* strlen(after_break) */
|
||||||
int wrapping = 0; /* do we prepend to the next line? */
|
int wrapping = 0; /* do we prepend to the next line? */
|
||||||
char *wrap_line = NULL; /* the next line, minus indentation */
|
const char *wrap_line = NULL;
|
||||||
|
/* the next line, minus indentation */
|
||||||
int wrap_line_len = 0; /* strlen(wrap_line) */
|
int wrap_line_len = 0; /* strlen(wrap_line) */
|
||||||
char *newline = NULL; /* the line we create */
|
char *newline = NULL; /* the line we create */
|
||||||
int new_line_len = 0; /* eventual length of newline */
|
int new_line_len = 0; /* eventual length of newline */
|
||||||
|
@ -804,10 +805,6 @@ int do_wrap(filestruct *inptr)
|
||||||
/* There are three steps. First, we decide where to wrap. Then, we
|
/* There are three steps. First, we decide where to wrap. Then, we
|
||||||
* create the new wrap line. Finally, we clean up. */
|
* create the new wrap line. Finally, we clean up. */
|
||||||
|
|
||||||
/* Is it necessary to do anything? */
|
|
||||||
if (strlenpt(inptr->data) <= fill)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Step 1, finding where to wrap. We are going to replace a white-space
|
/* Step 1, finding where to wrap. We are going to replace a white-space
|
||||||
* character with a new-line. In this step, we set wrap_loc as the
|
* character with a new-line. In this step, we set wrap_loc as the
|
||||||
* location of this replacement.
|
* location of this replacement.
|
||||||
|
@ -825,32 +822,28 @@ int do_wrap(filestruct *inptr)
|
||||||
* Note that the initial indentation does not count as a legal wrap
|
* Note that the initial indentation does not count as a legal wrap
|
||||||
* point if we are going to auto-indent!
|
* point if we are going to auto-indent!
|
||||||
*
|
*
|
||||||
* Note that the code below could be optimised, by not calling strlenpt
|
* Note that the code below could be optimised, by not calling strnlenpt()
|
||||||
* so often, and by not calling isspace(inptr->data[i+1]) and then in
|
* so often. */
|
||||||
* the next loop calling isspace(inptr->data[i]). Oh well, fixing the
|
|
||||||
* first point would entail expanding the definition of strnlenpt, which
|
|
||||||
* I won't do since it will probably change soon. Fixing the second
|
|
||||||
* point would entail nested loops. */
|
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (ISSET(AUTOINDENT))
|
if (ISSET(AUTOINDENT))
|
||||||
i = indent_length(inptr->data);
|
i = indent_length(inptr->data);
|
||||||
#endif
|
#endif
|
||||||
for(; i < len; i++) {
|
wrap_line = inptr->data + i;
|
||||||
|
for(; i < len; i++, wrap_line++) {
|
||||||
/* record where the last word ended */
|
/* record where the last word ended */
|
||||||
if (!isspace((int)inptr->data[i]))
|
if (*wrap_line != ' ' && *wrap_line != '\t')
|
||||||
word_back = i;
|
word_back = i;
|
||||||
/* if we have found a "legal wrap point" and the current word
|
/* if we have found a "legal wrap point" and the current word
|
||||||
* extends too far, then we stop */
|
* extends too far, then we stop */
|
||||||
if (wrap_loc != -1 && strnlenpt(inptr->data,word_back) > fill)
|
if (wrap_loc != -1 && strnlenpt(inptr->data, word_back + 1) > fill)
|
||||||
break;
|
break;
|
||||||
/* we record the latest "legal wrap point" */
|
/* we record the latest "legal wrap point" */
|
||||||
if (i != (current_x - 1) && isspace((int)inptr->data[i]) &&
|
if (i != current_x - 1 && word_back != i &&
|
||||||
(i == (len - 1) || !isspace((int)inptr->data[i + 1]))) {
|
wrap_line[1] != ' ' && wrap_line[1] != '\t')
|
||||||
wrap_loc = i;
|
wrap_loc = i;
|
||||||
}
|
}
|
||||||
}
|
if (wrap_loc < 0 || i == len)
|
||||||
if (wrap_loc < 0 || wrap_loc == len - 1 || i == len)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Step 2, making the new wrap line. It will consist of indentation +
|
/* Step 2, making the new wrap line. It will consist of indentation +
|
||||||
|
@ -906,7 +899,6 @@ int do_wrap(filestruct *inptr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
strcat(newline, after_break);
|
strcat(newline, after_break);
|
||||||
after_break = NULL;
|
|
||||||
/* We end the old line at wrap_loc. Note this eats the space. */
|
/* We end the old line at wrap_loc. Note this eats the space. */
|
||||||
null_at(&inptr->data, wrap_loc);
|
null_at(&inptr->data, wrap_loc);
|
||||||
if (wrapping) {
|
if (wrapping) {
|
||||||
|
@ -1130,7 +1122,7 @@ void wrap_reset(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
static int do_int_spell_fix(const char *word)
|
int do_int_spell_fix(const char *word)
|
||||||
{
|
{
|
||||||
char *save_search;
|
char *save_search;
|
||||||
char *save_replace;
|
char *save_replace;
|
||||||
|
@ -1354,17 +1346,22 @@ int do_alt_speller(char *file_name)
|
||||||
{
|
{
|
||||||
int alt_spell_status, lineno_cur = current->lineno;
|
int alt_spell_status, lineno_cur = current->lineno;
|
||||||
int x_cur = current_x, y_cur = current_y, pww_cur = placewewant;
|
int x_cur = current_x, y_cur = current_y, pww_cur = placewewant;
|
||||||
#ifndef NANO_SMALL
|
|
||||||
int mark_set;
|
|
||||||
#endif
|
|
||||||
pid_t pid_spell;
|
pid_t pid_spell;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
static int arglen = 3;
|
static int arglen = 3;
|
||||||
static char **spellargs = (char **)NULL;
|
static char **spellargs = (char **)NULL;
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
mark_set = ISSET(MARK_ISSET);
|
int mark_set = ISSET(MARK_ISSET);
|
||||||
|
int mbb_lineno_cur = 0;
|
||||||
|
/* We're going to close the current file, and open the output of
|
||||||
|
the alternate spell command. The line that mark_beginbuf
|
||||||
|
points to will be freed, so we save the line number and restore
|
||||||
|
afterwards. */
|
||||||
|
|
||||||
|
if (mark_set) {
|
||||||
|
mbb_lineno_cur = mark_beginbuf->lineno;
|
||||||
UNSET(MARK_ISSET);
|
UNSET(MARK_ISSET);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
endwin();
|
endwin();
|
||||||
|
@ -1408,8 +1405,13 @@ int do_alt_speller(char *file_name)
|
||||||
open_file(file_name, 0, 1);
|
open_file(file_name, 0, 1);
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (mark_set)
|
if (mark_set) {
|
||||||
|
do_gotopos(mbb_lineno_cur, mark_beginx, y_cur, 0);
|
||||||
|
mark_beginbuf = current;
|
||||||
|
mark_beginx = current_x;
|
||||||
|
/* In case the line got shorter, assign mark_beginx. */
|
||||||
SET(MARK_ISSET);
|
SET(MARK_ISSET);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* go back to the old position, mark the file as modified, and make
|
/* go back to the old position, mark the file as modified, and make
|
||||||
|
@ -1751,7 +1753,7 @@ RETSIGTYPE do_suspend(int signal)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore the suspend handler when we come back into the prog */
|
/* Restore the suspend handler when we come back into the prog */
|
||||||
static RETSIGTYPE do_cont(int signal)
|
RETSIGTYPE do_cont(int signal)
|
||||||
{
|
{
|
||||||
/* Now we just update the screen instead of having to reenable the
|
/* Now we just update the screen instead of having to reenable the
|
||||||
SIGTSTP handler. */
|
SIGTSTP handler. */
|
||||||
|
@ -1974,8 +1976,8 @@ size_t indent_length(const char *line) {
|
||||||
* justify_format will not look at the first skip characters of line.
|
* justify_format will not look at the first skip characters of line.
|
||||||
* skip should be at most strlen(line->data). The skip+1st character must
|
* skip should be at most strlen(line->data). The skip+1st character must
|
||||||
* not be whitespace. */
|
* not be whitespace. */
|
||||||
static int justify_format(int changes_allowed, filestruct *line,
|
int justify_format(int changes_allowed, filestruct *line, size_t skip)
|
||||||
size_t skip) {
|
{
|
||||||
char *back, *front;
|
char *back, *front;
|
||||||
|
|
||||||
/* These four asserts are assumptions about the input data. */
|
/* These four asserts are assumptions about the input data. */
|
||||||
|
@ -2041,7 +2043,8 @@ static int justify_format(int changes_allowed, filestruct *line,
|
||||||
* Note that if !HAVE_REGEX_H then we match concatenated copies of
|
* Note that if !HAVE_REGEX_H then we match concatenated copies of
|
||||||
* quotestr. */
|
* quotestr. */
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
static size_t quote_length(const char *line, const regex_t *qreg) {
|
size_t quote_length(const char *line, const regex_t *qreg)
|
||||||
|
{
|
||||||
regmatch_t matches;
|
regmatch_t matches;
|
||||||
int rc = regexec(qreg, line, 1, &matches, 0);
|
int rc = regexec(qreg, line, 1, &matches, 0);
|
||||||
|
|
||||||
|
@ -2052,7 +2055,8 @@ static size_t quote_length(const char *line, const regex_t *qreg) {
|
||||||
return matches.rm_eo;
|
return matches.rm_eo;
|
||||||
}
|
}
|
||||||
#else /* !HAVE_REGEX_H */
|
#else /* !HAVE_REGEX_H */
|
||||||
static size_t quote_length(const char *line) {
|
size_t quote_length(const char *line)
|
||||||
|
{
|
||||||
size_t qdepth = 0;
|
size_t qdepth = 0;
|
||||||
size_t qlen = strlen(quotestr);
|
size_t qlen = strlen(quotestr);
|
||||||
|
|
||||||
|
@ -2072,8 +2076,9 @@ static size_t quote_length(const char *line) {
|
||||||
/* a_line and b_line are lines of text. The quotation part of a_line is
|
/* a_line and b_line are lines of text. The quotation part of a_line is
|
||||||
* the first a_quote characters. Check that the quotation part of
|
* the first a_quote characters. Check that the quotation part of
|
||||||
* b_line is the same. */
|
* b_line is the same. */
|
||||||
static int quotes_match(const char *a_line, size_t a_quote,
|
int quotes_match(const char *a_line, size_t a_quote,
|
||||||
IFREG(const char *b_line, const regex_t *qreg)) {
|
IFREG(const char *b_line, const regex_t *qreg))
|
||||||
|
{
|
||||||
/* Here is the assumption about a_quote: */
|
/* Here is the assumption about a_quote: */
|
||||||
assert(a_quote == quote_length(IFREG(a_line, qreg)));
|
assert(a_quote == quote_length(IFREG(a_line, qreg)));
|
||||||
return a_quote == quote_length(IFREG(b_line, qreg)) &&
|
return a_quote == quote_length(IFREG(b_line, qreg)) &&
|
||||||
|
@ -2082,8 +2087,9 @@ static int quotes_match(const char *a_line, size_t a_quote,
|
||||||
|
|
||||||
/* We assume a_line and b_line have no quote part. Then, we return whether
|
/* We assume a_line and b_line have no quote part. Then, we return whether
|
||||||
* b_line could follow a_line in a paragraph. */
|
* b_line could follow a_line in a paragraph. */
|
||||||
static size_t indents_match(const char *a_line, size_t a_indent,
|
size_t indents_match(const char *a_line, size_t a_indent,
|
||||||
const char *b_line, size_t b_indent) {
|
const char *b_line, size_t b_indent)
|
||||||
|
{
|
||||||
assert(a_indent == indent_length(a_line));
|
assert(a_indent == indent_length(a_line));
|
||||||
assert(b_indent == indent_length(b_line));
|
assert(b_indent == indent_length(b_line));
|
||||||
|
|
||||||
|
@ -2094,8 +2100,9 @@ static size_t indents_match(const char *a_line, size_t a_indent,
|
||||||
* buffer. We assume there are enough lines after first_line. We leave
|
* buffer. We assume there are enough lines after first_line. We leave
|
||||||
* copies of the lines in place, too. We return the new copy of
|
* copies of the lines in place, too. We return the new copy of
|
||||||
* first_line. */
|
* first_line. */
|
||||||
static filestruct *backup_lines(filestruct *first_line, size_t par_len,
|
filestruct *backup_lines(filestruct *first_line, size_t par_len,
|
||||||
size_t quote_len) {
|
size_t quote_len)
|
||||||
|
{
|
||||||
/* We put the original lines, not copies, into the cut buffer, just
|
/* We put the original lines, not copies, into the cut buffer, just
|
||||||
* out of a misguided sense of consistency, so if you un-cut, you
|
* out of a misguided sense of consistency, so if you un-cut, you
|
||||||
* get the actual same paragraph back, not a copy. */
|
* get the actual same paragraph back, not a copy. */
|
||||||
|
@ -2132,7 +2139,8 @@ static filestruct *backup_lines(filestruct *first_line, size_t par_len,
|
||||||
* no such space, and force is not 0, then we find the first space.
|
* no such space, and force is not 0, then we find the first space.
|
||||||
* Anyway, we then take the last space in that group of spaces. The
|
* Anyway, we then take the last space in that group of spaces. The
|
||||||
* terminating '\0' counts as a space. */
|
* terminating '\0' counts as a space. */
|
||||||
static int break_line(const char *line, int goal, int force) {
|
int break_line(const char *line, int goal, int force)
|
||||||
|
{
|
||||||
/* Note that we use int instead of size_t, since goal is at most COLS,
|
/* Note that we use int instead of size_t, since goal is at most COLS,
|
||||||
* the screen width, which will always be reasonably small. */
|
* the screen width, which will always be reasonably small. */
|
||||||
int space_loc = -1;
|
int space_loc = -1;
|
||||||
|
@ -2173,7 +2181,8 @@ static int break_line(const char *line, int goal, int force) {
|
||||||
#endif /* !DISABLE_JUSTIFY */
|
#endif /* !DISABLE_JUSTIFY */
|
||||||
|
|
||||||
/* This function justifies the current paragraph. */
|
/* This function justifies the current paragraph. */
|
||||||
int do_justify(void) {
|
int do_justify(void)
|
||||||
|
{
|
||||||
#ifdef DISABLE_JUSTIFY
|
#ifdef DISABLE_JUSTIFY
|
||||||
nano_disabled_msg();
|
nano_disabled_msg();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2264,6 +2273,7 @@ int do_justify(void) {
|
||||||
quote_len = quote_length(IFREG(current->data, &qreg));
|
quote_len = quote_length(IFREG(current->data, &qreg));
|
||||||
indent_len = indent_length(current->data + quote_len);
|
indent_len = indent_length(current->data + quote_len);
|
||||||
|
|
||||||
|
current_x = 0;
|
||||||
if (current->data[quote_len + indent_len] != '\0') {
|
if (current->data[quote_len + indent_len] != '\0') {
|
||||||
/* This line is part of a paragraph. So we must search back to
|
/* This line is part of a paragraph. So we must search back to
|
||||||
* the first line of this paragraph. */
|
* the first line of this paragraph. */
|
||||||
|
@ -2279,6 +2289,7 @@ int do_justify(void) {
|
||||||
/* indentation length of the previous line */
|
/* indentation length of the previous line */
|
||||||
size_t temp_id_len =
|
size_t temp_id_len =
|
||||||
indent_length(current->prev->data + quote_len);
|
indent_length(current->prev->data + quote_len);
|
||||||
|
|
||||||
if (!indents_match(current->prev->data + quote_len,
|
if (!indents_match(current->prev->data + quote_len,
|
||||||
temp_id_len, current->data + quote_len,
|
temp_id_len, current->data + quote_len,
|
||||||
indent_len) ||
|
indent_len) ||
|
||||||
|
@ -2286,6 +2297,7 @@ int do_justify(void) {
|
||||||
break;
|
break;
|
||||||
indent_len = temp_id_len;
|
indent_len = temp_id_len;
|
||||||
current = current->prev;
|
current = current->prev;
|
||||||
|
current_y--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2293,9 +2305,16 @@ int do_justify(void) {
|
||||||
* to a non "blank" line. */
|
* to a non "blank" line. */
|
||||||
do {
|
do {
|
||||||
/* There is no next paragraph, so nothing to justify. */
|
/* There is no next paragraph, so nothing to justify. */
|
||||||
if (current->next == NULL)
|
if (current->next == NULL) {
|
||||||
|
placewewant = 0;
|
||||||
|
if (current_y > editwinrows - 4)
|
||||||
|
edit_update(current, CENTER);
|
||||||
|
else
|
||||||
|
edit_refresh();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
current = current->next;
|
current = current->next;
|
||||||
|
current_y++;
|
||||||
quote_len = quote_length(IFREG(current->data, &qreg));
|
quote_len = quote_length(IFREG(current->data, &qreg));
|
||||||
indent_len = indent_length(current->data + quote_len);
|
indent_len = indent_length(current->data + quote_len);
|
||||||
} while (current->data[quote_len + indent_len] == '\0');
|
} while (current->data[quote_len + indent_len] == '\0');
|
||||||
|
@ -2478,11 +2497,11 @@ continue_loc:
|
||||||
* fileage, set current_x. Also, edit_refresh() needs the line
|
* fileage, set current_x. Also, edit_refresh() needs the line
|
||||||
* numbers to be right, so we renumber(). */
|
* numbers to be right, so we renumber(). */
|
||||||
last_par_line = current->prev;
|
last_par_line = current->prev;
|
||||||
if (first_mod_line != NULL && first_mod_line->prev == NULL)
|
if (first_mod_line != NULL) {
|
||||||
|
if (first_mod_line->prev == NULL)
|
||||||
fileage = first_mod_line;
|
fileage = first_mod_line;
|
||||||
current_x = 0;
|
|
||||||
if (first_mod_line != NULL)
|
|
||||||
renumber(first_mod_line);
|
renumber(first_mod_line);
|
||||||
|
}
|
||||||
|
|
||||||
if (current_y > editwinrows - 4)
|
if (current_y > editwinrows - 4)
|
||||||
edit_update(current, CENTER);
|
edit_update(current, CENTER);
|
||||||
|
@ -2566,7 +2585,6 @@ continue_loc:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef DISABLE_HELP
|
#ifndef DISABLE_HELP
|
||||||
/* This function allocates help_text, and stores the help string in it.
|
/* This function allocates help_text, and stores the help string in it.
|
||||||
* help_text should be NULL initially. */
|
* help_text should be NULL initially. */
|
||||||
|
@ -2770,7 +2788,7 @@ void help_init(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
static void do_toggle(const toggle *which)
|
void do_toggle(const toggle *which)
|
||||||
{
|
{
|
||||||
int enabled;
|
int enabled;
|
||||||
|
|
||||||
|
|
4
nano.h
4
nano.h
|
@ -344,10 +344,10 @@ know what you're doing */
|
||||||
#define TOGGLE_PICOMODE_KEY NANO_ALT_P
|
#define TOGGLE_PICOMODE_KEY NANO_ALT_P
|
||||||
#define TOGGLE_MOUSE_KEY NANO_ALT_M
|
#define TOGGLE_MOUSE_KEY NANO_ALT_M
|
||||||
#define TOGGLE_CUTTOEND_KEY NANO_ALT_K
|
#define TOGGLE_CUTTOEND_KEY NANO_ALT_K
|
||||||
#define TOGGLE_REGEXP_KEY NANO_ALT_E
|
#define TOGGLE_REGEXP_KEY NANO_ALT_R
|
||||||
#define TOGGLE_WRAP_KEY NANO_ALT_W
|
#define TOGGLE_WRAP_KEY NANO_ALT_W
|
||||||
#define TOGGLE_BACKWARDS_KEY NANO_ALT_B
|
#define TOGGLE_BACKWARDS_KEY NANO_ALT_B
|
||||||
#define TOGGLE_CASE_KEY NANO_ALT_A
|
#define TOGGLE_CASE_KEY NANO_ALT_C
|
||||||
#define TOGGLE_LOAD_KEY NANO_ALT_F
|
#define TOGGLE_LOAD_KEY NANO_ALT_F
|
||||||
#define TOGGLE_DOS_KEY NANO_ALT_D
|
#define TOGGLE_DOS_KEY NANO_ALT_D
|
||||||
#define TOGGLE_MAC_KEY NANO_ALT_O
|
#define TOGGLE_MAC_KEY NANO_ALT_O
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
@smallbook
|
@smallbook
|
||||||
@set EDITION 0.1
|
@set EDITION 0.1
|
||||||
@set VERSION 1.1.10
|
@set VERSION 1.1.10
|
||||||
@set UPDATED 14 Jul 2002
|
@set UPDATED 30 Jul 2002
|
||||||
|
|
||||||
@dircategory Editors
|
@dircategory Editors
|
||||||
@direntry
|
@direntry
|
||||||
|
@ -134,6 +134,10 @@ Write file in Mac format.
|
||||||
Do not convert files from DOS/Mac format.
|
Do not convert files from DOS/Mac format.
|
||||||
|
|
||||||
@item -Q [str], --quotestr [str]
|
@item -Q [str], --quotestr [str]
|
||||||
|
Set the quoting string for justifying. The default is
|
||||||
|
"^([ \t]*[|>:@}#])+" if regular expression support is available, or
|
||||||
|
"> " otherwise.
|
||||||
|
|
||||||
Set the quoting string for justifying. The default is "> ".
|
Set the quoting string for justifying. The default is "> ".
|
||||||
|
|
||||||
@item -R, --regexp
|
@item -R, --regexp
|
||||||
|
|
20
rcfile.c
20
rcfile.c
|
@ -43,7 +43,6 @@
|
||||||
#define _(string) (string)
|
#define _(string) (string)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Static stuff for the nanorc file */
|
|
||||||
static rcoption rcopts[] = {
|
static rcoption rcopts[] = {
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
{"autoindent", AUTOINDENT},
|
{"autoindent", AUTOINDENT},
|
||||||
|
@ -100,7 +99,7 @@ static char *nanorc;
|
||||||
|
|
||||||
/* We have an error in some part of the rcfile; put it on stderr and
|
/* 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. */
|
make the user hit return to continue starting up nano. */
|
||||||
static void rcfile_error(const char *msg, ...)
|
void rcfile_error(const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
@ -117,7 +116,7 @@ static void rcfile_error(const char *msg, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Just print the error (one of many, perhaps) but don't abort, yet. */
|
/* Just print the error (one of many, perhaps) but don't abort, yet. */
|
||||||
static void rcfile_msg(const char *msg, ...)
|
void rcfile_msg(const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ static void rcfile_msg(const char *msg, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the next word from the string. Returns NULL if we hit EOL. */
|
/* Parse the next word from the string. Returns NULL if we hit EOL. */
|
||||||
static char *parse_next_word(char *ptr)
|
char *parse_next_word(char *ptr)
|
||||||
{
|
{
|
||||||
while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n' && *ptr != '\0')
|
while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n' && *ptr != '\0')
|
||||||
ptr++;
|
ptr++;
|
||||||
|
@ -155,7 +154,8 @@ static char *parse_next_word(char *ptr)
|
||||||
* next word starts with a ", we say it ends with the last " of the line.
|
* next word starts with a ", we say it ends with the last " of the line.
|
||||||
* Otherwise, the word is interpreted as usual. That is so the arguments
|
* Otherwise, the word is interpreted as usual. That is so the arguments
|
||||||
* can contain "s too. */
|
* can contain "s too. */
|
||||||
static char *parse_argument(char *ptr) {
|
char *parse_argument(char *ptr)
|
||||||
|
{
|
||||||
const char *ptr_bak = ptr;
|
const char *ptr_bak = ptr;
|
||||||
char *last_quote = NULL;
|
char *last_quote = NULL;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ static char *parse_argument(char *ptr) {
|
||||||
|
|
||||||
#ifdef ENABLE_COLOR
|
#ifdef ENABLE_COLOR
|
||||||
|
|
||||||
static char *parse_next_regex(char *ptr)
|
char *parse_next_regex(char *ptr)
|
||||||
{
|
{
|
||||||
while ((*ptr != '"' || (*(ptr + 1) != ' ' && *(ptr + 1) != '\n'))
|
while ((*ptr != '"' || (*(ptr + 1) != ' ' && *(ptr + 1) != '\n'))
|
||||||
&& *ptr != '\n' && *ptr != '\0')
|
&& *ptr != '\n' && *ptr != '\0')
|
||||||
|
@ -206,7 +206,7 @@ static char *parse_next_regex(char *ptr)
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int colortoint(const char *colorname, int *bright)
|
int colortoint(const char *colorname, int *bright)
|
||||||
{
|
{
|
||||||
int mcolor = 0;
|
int mcolor = 0;
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ static int colortoint(const char *colorname, int *bright)
|
||||||
return mcolor;
|
return mcolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_syntax(char *ptr)
|
void parse_syntax(char *ptr)
|
||||||
{
|
{
|
||||||
syntaxtype *tmpsyntax = NULL;
|
syntaxtype *tmpsyntax = NULL;
|
||||||
const char *fileregptr = NULL, *nameptr = NULL;
|
const char *fileregptr = NULL, *nameptr = NULL;
|
||||||
|
@ -320,7 +320,7 @@ static void parse_syntax(char *ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the color stuff into the colorstrings array */
|
/* Parse the color stuff into the colorstrings array */
|
||||||
static void parse_colors(char *ptr)
|
void parse_colors(char *ptr)
|
||||||
{
|
{
|
||||||
int fg, bg, bright = 0;
|
int fg, bg, bright = 0;
|
||||||
int expectend = 0; /* Do we expect an end= line? */
|
int expectend = 0; /* Do we expect an end= line? */
|
||||||
|
@ -434,7 +434,7 @@ static void parse_colors(char *ptr)
|
||||||
#endif /* ENABLE_COLOR */
|
#endif /* ENABLE_COLOR */
|
||||||
|
|
||||||
/* Parse the RC file, once it has been opened successfully */
|
/* Parse the RC file, once it has been opened successfully */
|
||||||
static void parse_rcfile(FILE *rcstream)
|
void parse_rcfile(FILE *rcstream)
|
||||||
{
|
{
|
||||||
char *buf, *ptr, *keyword, *option;
|
char *buf, *ptr, *keyword, *option;
|
||||||
int set = 0, i, j;
|
int set = 0, i, j;
|
||||||
|
|
4
search.c
4
search.c
|
@ -42,7 +42,7 @@
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
void regexp_init(const char *regexp)
|
void regexp_init(const char *regexp)
|
||||||
{
|
{
|
||||||
regcomp(&search_regexp, regexp, ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE);
|
regcomp(&search_regexp, regexp, (ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE) | REG_EXTENDED);
|
||||||
SET(REGEXP_COMPILED);
|
SET(REGEXP_COMPILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void search_init_globals(void)
|
||||||
|
|
||||||
replacing = 1 if we call from do_replace, 0 if called from do_search func.
|
replacing = 1 if we call from do_replace, 0 if called from do_search func.
|
||||||
*/
|
*/
|
||||||
static int search_init(int replacing)
|
int search_init(int replacing)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
6
utils.c
6
utils.c
|
@ -49,7 +49,7 @@ int num_of_digits(int n)
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
n = 0 - n;
|
n = -n;
|
||||||
|
|
||||||
while (n > 10) {
|
while (n > 10) {
|
||||||
n /= 10;
|
n /= 10;
|
||||||
|
@ -96,7 +96,7 @@ void sunder(char *str)
|
||||||
|
|
||||||
/* None of this is needed if we're using NANO_SMALL! */
|
/* None of this is needed if we're using NANO_SMALL! */
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
static const char *revstrstr(const char *haystack, const char *needle,
|
const char *revstrstr(const char *haystack, const char *needle,
|
||||||
const char *rev_start)
|
const char *rev_start)
|
||||||
{
|
{
|
||||||
for(; rev_start >= haystack ; rev_start--) {
|
for(; rev_start >= haystack ; rev_start--) {
|
||||||
|
@ -110,7 +110,7 @@ static const char *revstrstr(const char *haystack, const char *needle,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *revstristr(const char *haystack, const char *needle,
|
const char *revstristr(const char *haystack, const char *needle,
|
||||||
const char *rev_start)
|
const char *rev_start)
|
||||||
{
|
{
|
||||||
for (; rev_start >= haystack; rev_start--) {
|
for (; rev_start >= haystack; rev_start--) {
|
||||||
|
|
72
winio.c
72
winio.c
|
@ -36,16 +36,10 @@
|
||||||
#define _(string) (string)
|
#define _(string) (string)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* winio.c statics */
|
|
||||||
static int statblank = 0; /* Number of keystrokes left after
|
static int statblank = 0; /* Number of keystrokes left after
|
||||||
we call statusbar(), before we
|
we call statusbar(), before we
|
||||||
actually blank the statusbar */
|
actually blank the statusbar */
|
||||||
|
|
||||||
/* Local Function Prototypes for only winio.c */
|
|
||||||
static int get_page_start(int column);
|
|
||||||
|
|
||||||
/* Window I/O */
|
|
||||||
|
|
||||||
int do_first_line(void)
|
int do_first_line(void)
|
||||||
{
|
{
|
||||||
current = fileage;
|
current = fileage;
|
||||||
|
@ -153,29 +147,6 @@ size_t strlenpt(const char *buf)
|
||||||
return strnlenpt(buf, -1);
|
return strnlenpt(buf, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Resets current_y, based on the position of current, and puts the
|
|
||||||
* cursor at (current_y, current_x). */
|
|
||||||
void reset_cursor(void)
|
|
||||||
{
|
|
||||||
const filestruct *ptr = edittop;
|
|
||||||
size_t x;
|
|
||||||
|
|
||||||
/* Yuck. This condition can be true after open_file when opening the
|
|
||||||
* first file. */
|
|
||||||
if (edittop == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
current_y = 0;
|
|
||||||
|
|
||||||
while (ptr != current && ptr != editbot && ptr->next != NULL) {
|
|
||||||
ptr = ptr->next;
|
|
||||||
current_y++;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = xplustabs();
|
|
||||||
wmove(edit, current_y, x - get_page_start(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
void blank_bottombars(void)
|
void blank_bottombars(void)
|
||||||
{
|
{
|
||||||
if (!no_help()) {
|
if (!no_help()) {
|
||||||
|
@ -218,8 +189,7 @@ void check_statblank(void)
|
||||||
*
|
*
|
||||||
* Note that we must turn on A_REVERSE here, since do_help turns it
|
* Note that we must turn on A_REVERSE here, since do_help turns it
|
||||||
* off! */
|
* off! */
|
||||||
static void nanoget_repaint(const char *buf, const char *inputbuf,
|
void nanoget_repaint(const char *buf, const char *inputbuf, int x)
|
||||||
int x)
|
|
||||||
{
|
{
|
||||||
int len = strlen(buf) + 2;
|
int len = strlen(buf) + 2;
|
||||||
int wid = COLS - len;
|
int wid = COLS - len;
|
||||||
|
@ -239,7 +209,7 @@ static void nanoget_repaint(const char *buf, const char *inputbuf,
|
||||||
|
|
||||||
/* Get the input from the kb; this should only be called from
|
/* Get the input from the kb; this should only be called from
|
||||||
* statusq(). */
|
* statusq(). */
|
||||||
static int nanogetstr(int allowtabs, const char *buf, const char *def,
|
int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||||
const shortcut *s
|
const shortcut *s
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
, int *list
|
, int *list
|
||||||
|
@ -517,7 +487,7 @@ void titlebar(const char *path)
|
||||||
* keystroke is e.g. "^G" and desc is e.g. "Get Help".
|
* keystroke is e.g. "^G" and desc is e.g. "Get Help".
|
||||||
* We are careful to write exactly len characters, even if len is
|
* We are careful to write exactly len characters, even if len is
|
||||||
* very small and keystroke and desc are long. */
|
* very small and keystroke and desc are long. */
|
||||||
static void onekey(const char *keystroke, const char *desc, int len)
|
void onekey(const char *keystroke, const char *desc, int len)
|
||||||
{
|
{
|
||||||
wattron(bottomwin, A_REVERSE);
|
wattron(bottomwin, A_REVERSE);
|
||||||
waddnstr(bottomwin, keystroke, len);
|
waddnstr(bottomwin, keystroke, len);
|
||||||
|
@ -533,7 +503,7 @@ static void onekey(const char *keystroke, const char *desc, int len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clear_bottomwin(void)
|
void clear_bottomwin(void)
|
||||||
{
|
{
|
||||||
if (ISSET(NO_HELP))
|
if (ISSET(NO_HELP))
|
||||||
return;
|
return;
|
||||||
|
@ -637,12 +607,34 @@ int get_page_end_virtual(int page)
|
||||||
return get_page_start_virtual(page) + COLS - 1;
|
return get_page_start_virtual(page) + COLS - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_page_start(int column)
|
int get_page_start(int column)
|
||||||
{
|
{
|
||||||
assert(COLS > 9);
|
assert(COLS > 9);
|
||||||
return column < COLS - 1 ? 0 : column - 7 - (column - 8) % (COLS - 9);
|
return column < COLS - 1 ? 0 : column - 7 - (column - 8) % (COLS - 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Resets current_y, based on the position of current, and puts the
|
||||||
|
* cursor at (current_y, current_x). */
|
||||||
|
void reset_cursor(void)
|
||||||
|
{
|
||||||
|
const filestruct *ptr = edittop;
|
||||||
|
size_t x;
|
||||||
|
|
||||||
|
/* Yuck. This condition can be true after open_file when opening the
|
||||||
|
* first file. */
|
||||||
|
if (edittop == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
current_y = 0;
|
||||||
|
|
||||||
|
while (ptr != current && ptr != editbot && ptr->next != NULL) {
|
||||||
|
ptr = ptr->next;
|
||||||
|
current_y++;
|
||||||
|
}
|
||||||
|
|
||||||
|
x = xplustabs();
|
||||||
|
wmove(edit, current_y, x - get_page_start(x));
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* This takes care of the case where there is a mark that covers only */
|
/* This takes care of the case where there is a mark that covers only */
|
||||||
|
@ -729,7 +721,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
|
||||||
|
|
||||||
/* First, highlight all single-line regexes */
|
/* First, highlight all single-line regexes */
|
||||||
k = start;
|
k = start;
|
||||||
regcomp(&color_regexp, tmpcolor->start, 0);
|
regcomp(&color_regexp, tmpcolor->start, REG_EXTENDED);
|
||||||
while (!regexec(&color_regexp, &fileptr->data[k], 1,
|
while (!regexec(&color_regexp, &fileptr->data[k], 1,
|
||||||
colormatches, 0)) {
|
colormatches, 0)) {
|
||||||
|
|
||||||
|
@ -789,7 +781,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
|
||||||
|
|
||||||
s = fileptr;
|
s = fileptr;
|
||||||
while (s != NULL) {
|
while (s != NULL) {
|
||||||
regcomp(&color_regexp, tmpcolor->start, 0);
|
regcomp(&color_regexp, tmpcolor->start, REG_EXTENDED);
|
||||||
if (!regexec
|
if (!regexec
|
||||||
(&color_regexp, s->data, 1, colormatches, 0)) {
|
(&color_regexp, s->data, 1, colormatches, 0)) {
|
||||||
regfree(&color_regexp);
|
regfree(&color_regexp);
|
||||||
|
@ -805,7 +797,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
|
||||||
|
|
||||||
e = s;
|
e = s;
|
||||||
while (e != NULL && e != fileptr) {
|
while (e != NULL && e != fileptr) {
|
||||||
regcomp(&color_regexp, tmpcolor->end, 0);
|
regcomp(&color_regexp, tmpcolor->end, REG_EXTENDED);
|
||||||
if (!regexec
|
if (!regexec
|
||||||
(&color_regexp, e->data, 1, colormatches, 0)) {
|
(&color_regexp, e->data, 1, colormatches, 0)) {
|
||||||
regfree(&color_regexp);
|
regfree(&color_regexp);
|
||||||
|
@ -819,7 +811,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
|
||||||
continue; /* There's an end before us */
|
continue; /* There's an end before us */
|
||||||
else { /* Keep looking for an end */
|
else { /* Keep looking for an end */
|
||||||
while (e != NULL) {
|
while (e != NULL) {
|
||||||
regcomp(&color_regexp, tmpcolor->end, 0);
|
regcomp(&color_regexp, tmpcolor->end, REG_EXTENDED);
|
||||||
if (!regexec
|
if (!regexec
|
||||||
(&color_regexp, e->data, 1, colormatches,
|
(&color_regexp, e->data, 1, colormatches,
|
||||||
0)) {
|
0)) {
|
||||||
|
@ -836,7 +828,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
|
||||||
ematch = colormatches[0].rm_eo;
|
ematch = colormatches[0].rm_eo;
|
||||||
|
|
||||||
while (e != NULL) {
|
while (e != NULL) {
|
||||||
regcomp(&color_regexp, tmpcolor->end, 0);
|
regcomp(&color_regexp, tmpcolor->end, REG_EXTENDED);
|
||||||
if (!regexec
|
if (!regexec
|
||||||
(&color_regexp, e->data, 1,
|
(&color_regexp, e->data, 1,
|
||||||
colormatches, 0)) {
|
colormatches, 0)) {
|
||||||
|
|
Loading…
Reference in New Issue