From 0341b58c05435a1f83a4049441e1e1aca93b82be Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Wed, 21 Aug 2002 16:10:37 +0000 Subject: [PATCH] DLR: minor bits git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1264 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 42 ++++++++++++++++ TODO | 1 + color.c | 6 +-- files.c | 9 ++-- global.c | 16 +++---- move.c | 10 ++-- nano.1 | 6 ++- nano.1.html | 8 ++-- nano.c | 136 +++++++++++++++++++++++++++++----------------------- nano.h | 4 +- nano.texi | 6 ++- rcfile.c | 20 ++++---- search.c | 4 +- utils.c | 6 +-- winio.c | 72 +++++++++++++--------------- 15 files changed, 200 insertions(+), 146 deletions(-) diff --git a/ChangeLog b/ChangeLog index 816978a4..296ae8c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,20 @@ CVS code - - General: - 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: - Added pt_BR to ALL_LINGUAS (Jordi). - 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() - Rework to use getpwent() exclusively and end reliance on $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 completion works properly when we're trying to tab-complete a 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: do_next_word(), do_prev_word() - 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 ENABLE_COLOR is defined; if it isn't, and we're not deleting 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 - General: diff --git a/TODO b/TODO index 9f5ffb38..631c7e01 100644 --- a/TODO +++ b/TODO @@ -17,6 +17,7 @@ For version 1.2: For version 1.4: - UTF-8 support. +- Support for Pico's paragraph searching ability. - Undo/Redo key? Old requests: diff --git a/color.c b/color.c index 3d174160..beae8890 100644 --- a/color.c +++ b/color.c @@ -99,11 +99,11 @@ void update_color(void) for (tmpsyntax = syntaxes; tmpsyntax != NULL; tmpsyntax = tmpsyntax->next) { exttype *e; 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 */ - if (!regexec(&syntaxfile_regexp, filename, 1, synfilematches, 0)) - colorstrings = tmpsyntax->color; + if (!regexec(&syntaxfile_regexp, filename, 1, synfilematches, 0)) + colorstrings = tmpsyntax->color; regfree(&syntaxfile_regexp); } diff --git a/files.c b/files.c index 2216c203..e0ef4825 100644 --- a/files.c +++ b/files.c @@ -45,7 +45,6 @@ #define _(string) (string) #endif -/* statics for here */ #ifndef NANO_SMALL static int fileformat = 0; /* 0 = *nix, 1 = DOS, 2 = Mac */ #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) || S_ISBLK(fileinfo.st_mode)) { if (S_ISDIR(fileinfo.st_mode)) - statusbar(_("File \"%s\" is a directory"), filename); + statusbar(_("\"%s\" is a directory"), filename); else /* Don't open character or block files. Sorry, /dev/sndstat! */ 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. */ int open_prevfile_void(void) { - open_prevfile(0); - return 0; + return open_prevfile(0); } /* @@ -930,8 +928,7 @@ int open_nextfile(int closing_file) /* This function is used by the shortcut list. */ int open_nextfile_void(void) { - open_nextfile(0); - return 0; + return open_nextfile(0); } /* diff --git a/global.c b/global.c index 1841574b..cf5b429e 100644 --- a/global.c +++ b/global.c @@ -163,13 +163,11 @@ int length_of_list(const shortcut *s) } /* Initialize a struct *without* our lovely braces =( */ -static void sc_init_one(shortcut **shortcutage, int key, - const char *desc, +void sc_init_one(shortcut **shortcutage, int key, const char *desc, #ifndef DISABLE_HELP - const char *help, + const char *help, #endif - int alt, int misc1, int misc2, int view, - int (*func) (void)) + int alt, int misc1, int misc2, int view, int (*func) (void)) { shortcut *s; @@ -199,7 +197,7 @@ static void sc_init_one(shortcut **shortcutage, int key, #ifndef NANO_SMALL /* Create one new toggle structure, at the end of the toggles * 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; @@ -221,7 +219,7 @@ static void toggle_init_one(int val, const char *desc, int flag) #ifdef DEBUG /* Deallocate all of the toggles. */ -static void free_toggles(void) +void free_toggles(void) { while (toggles != NULL) { toggle *pt = toggles; /* Think "previous toggle" */ @@ -232,7 +230,7 @@ static void free_toggles(void) } #endif -static void toggle_init(void) +void toggle_init(void) { char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg, *toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg, @@ -293,7 +291,7 @@ static void toggle_init(void) #endif /* !NANO_SMALL */ /* Deallocate the given shortcut. */ -static void free_shortcutage(shortcut **shortcutage) +void free_shortcutage(shortcut **shortcutage) { assert(shortcutage != NULL); while (*shortcutage != NULL) { diff --git a/move.c b/move.c index 6f57d91f..27ed9ea3 100644 --- a/move.c +++ b/move.c @@ -105,10 +105,8 @@ void page_up(void) line and don't center it. */ if (edittop != fileage) center_cursor(); - else { - current = current->prev; + else reset_cursor(); - } } } else current_y = 0; @@ -186,10 +184,10 @@ int do_down(void) { } else #endif { - edit_update(editbot->next, CENTER); - /* sets edittop so editbot->next is centered */ + /* Set edittop so editbot->next (or else editbot) is + * centered, and set current_y = editwinrows / 2. */ + edit_update(editbot->next != NULL ? editbot->next : editbot, CENTER); center_cursor(); - /* sets current_y = editwinrows / 2 */ } } else { update_line(current->prev, 0); diff --git a/nano.1 b/nano.1 index 603c9c57..67818fe7 100644 --- a/nano.1 +++ b/nano.1 @@ -6,7 +6,7 @@ .\" Public License for copying conditions. There is NO warranty. .\" .\" $Id$ -.TH NANO 1 "July 14, 2002" +.TH NANO 1 "July 30, 2002" .\" Please adjust this date whenever revising the manpage. .\" .SH NAME @@ -56,7 +56,9 @@ Write file in Mac format. Disable automatic conversion of files from DOS/Mac format. .TP .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 .B \-R (\-\-regexp) Enable regular expression matching for search strings, as well as diff --git a/nano.1.html b/nano.1.html index 7c07baab..542b78b3 100644 --- a/nano.1.html +++ b/nano.1.html @@ -3,7 +3,7 @@ Content-type: text/html Manpage of NANO

NANO

-Section: User Commands (1)
Updated: July 14, 2002
Index +Section: User Commands (1)
Updated: July 30, 2002
Index Return to Main Contents
@@ -77,7 +77,9 @@ Disable automatic conversion of files from DOS/Mac format.
-Q [str] (--quotestr=[str])
-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.
-R (--regexp)
@@ -233,6 +235,6 @@ used by others). This document was created by man2html, using the manual pages.
-Time: 00:51:19 GMT, July 14, 2002 +Time: 21:12:05 GMT, July 30, 2002 diff --git a/nano.c b/nano.c index 0e2d573d..af63a7fd 100644 --- a/nano.c +++ b/nano.c @@ -62,7 +62,6 @@ #endif #ifndef DISABLE_WRAPJUSTIFY -/* Former global, now static */ static int fill = 0; /* Fill - where to wrap lines, basically */ #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 */ /* What we do when we're all set to exit */ -static RETSIGTYPE finish(int sigage) +RETSIGTYPE finish(int sigage) { keypad(edit, 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 * screen is too small. */ -static void die_too_small(void) +void die_too_small(void) { 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 * 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_y = 0; @@ -329,7 +328,7 @@ void renumber(filestruct *fileptr) /* Print one usage string to the screen, removes lots of duplicate * strings to translate and takes out the parts that shouldn't be * translatable (the flag names). */ -static void print1opt(const char *shortflag, const char *longflag, +void print1opt(const char *shortflag, const char *longflag, const char *desc) { printf(" %s\t", shortflag); @@ -347,7 +346,7 @@ static void print1opt(const char *shortflag, const char *longflag, printf("%s\n", desc); } -static void usage(void) +void usage(void) { #ifdef HAVE_GETOPT_LONG printf(_("Usage: nano [+LINE] [GNU long option] [option] [file]\n\n")); @@ -423,7 +422,7 @@ static void usage(void) exit(0); } -static void version(void) +void version(void) { printf(_(" GNU nano version %s (compiled %s, %s)\n"), VERSION, __TIME__, __DATE__); @@ -790,13 +789,15 @@ int do_wrap(filestruct *inptr) int wrap_loc = -1; /* index of inptr->data where we wrap */ int word_back = -1; #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) */ #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 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) */ char *newline = NULL; /* the line we create */ 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 * 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 * character with a new-line. In this step, we set wrap_loc as the * 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 * point if we are going to auto-indent! * - * Note that the code below could be optimised, by not calling strlenpt - * so often, and by not calling isspace(inptr->data[i+1]) and then in - * 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. */ + * Note that the code below could be optimised, by not calling strnlenpt() + * so often. */ #ifndef NANO_SMALL if (ISSET(AUTOINDENT)) i = indent_length(inptr->data); #endif - for(; i < len; i++) { + wrap_line = inptr->data + i; + for(; i < len; i++, wrap_line++) { /* record where the last word ended */ - if (!isspace((int)inptr->data[i])) + if (*wrap_line != ' ' && *wrap_line != '\t') word_back = i; /* if we have found a "legal wrap point" and the current word * 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; /* we record the latest "legal wrap point" */ - if (i != (current_x - 1) && isspace((int)inptr->data[i]) && - (i == (len - 1) || !isspace((int)inptr->data[i + 1]))) { + if (i != current_x - 1 && word_back != i && + wrap_line[1] != ' ' && wrap_line[1] != '\t') wrap_loc = i; - } } - if (wrap_loc < 0 || wrap_loc == len - 1 || i == len) + if (wrap_loc < 0 || i == len) return 0; /* Step 2, making the new wrap line. It will consist of indentation + @@ -906,7 +899,6 @@ int do_wrap(filestruct *inptr) } #endif strcat(newline, after_break); - after_break = NULL; /* We end the old line at wrap_loc. Note this eats the space. */ null_at(&inptr->data, wrap_loc); if (wrapping) { @@ -1130,7 +1122,7 @@ void wrap_reset(void) } #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_replace; @@ -1354,17 +1346,22 @@ int do_alt_speller(char *file_name) { int alt_spell_status, lineno_cur = current->lineno; int x_cur = current_x, y_cur = current_y, pww_cur = placewewant; -#ifndef NANO_SMALL - int mark_set; -#endif pid_t pid_spell; char *ptr; static int arglen = 3; - static char **spellargs = (char **) NULL; - + static char **spellargs = (char **)NULL; #ifndef NANO_SMALL - mark_set = ISSET(MARK_ISSET); - UNSET(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); + } #endif endwin(); @@ -1408,8 +1405,13 @@ int do_alt_speller(char *file_name) open_file(file_name, 0, 1); #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); + } #endif /* 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 */ -static RETSIGTYPE do_cont(int signal) +RETSIGTYPE do_cont(int signal) { /* Now we just update the screen instead of having to reenable the 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. * skip should be at most strlen(line->data). The skip+1st character must * not be whitespace. */ -static int justify_format(int changes_allowed, filestruct *line, - size_t skip) { +int justify_format(int changes_allowed, filestruct *line, size_t skip) +{ char *back, *front; /* 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 * quotestr. */ #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; 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; } #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 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 * the first a_quote characters. Check that the quotation part of * b_line is the same. */ -static int quotes_match(const char *a_line, size_t a_quote, - IFREG(const char *b_line, const regex_t *qreg)) { +int quotes_match(const char *a_line, size_t a_quote, + IFREG(const char *b_line, const regex_t *qreg)) +{ /* Here is the assumption about a_quote: */ assert(a_quote == quote_length(IFREG(a_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 * b_line could follow a_line in a paragraph. */ -static size_t indents_match(const char *a_line, size_t a_indent, - const char *b_line, size_t b_indent) { +size_t indents_match(const char *a_line, size_t a_indent, + const char *b_line, size_t b_indent) +{ assert(a_indent == indent_length(a_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 * copies of the lines in place, too. We return the new copy of * first_line. */ -static filestruct *backup_lines(filestruct *first_line, size_t par_len, - size_t quote_len) { +filestruct *backup_lines(filestruct *first_line, size_t par_len, + size_t quote_len) +{ /* 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 * 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. * Anyway, we then take the last space in that group of spaces. The * 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, * the screen width, which will always be reasonably small. */ int space_loc = -1; @@ -2173,7 +2181,8 @@ static int break_line(const char *line, int goal, int force) { #endif /* !DISABLE_JUSTIFY */ /* This function justifies the current paragraph. */ -int do_justify(void) { +int do_justify(void) +{ #ifdef DISABLE_JUSTIFY nano_disabled_msg(); return 1; @@ -2264,6 +2273,7 @@ int do_justify(void) { quote_len = quote_length(IFREG(current->data, &qreg)); indent_len = indent_length(current->data + quote_len); + current_x = 0; if (current->data[quote_len + indent_len] != '\0') { /* This line is part of a paragraph. So we must search back to * the first line of this paragraph. */ @@ -2279,6 +2289,7 @@ int do_justify(void) { /* indentation length of the previous line */ size_t temp_id_len = indent_length(current->prev->data + quote_len); + if (!indents_match(current->prev->data + quote_len, temp_id_len, current->data + quote_len, indent_len) || @@ -2286,6 +2297,7 @@ int do_justify(void) { break; indent_len = temp_id_len; current = current->prev; + current_y--; } } } else { @@ -2293,9 +2305,16 @@ int do_justify(void) { * to a non "blank" line. */ do { /* 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; + } current = current->next; + current_y++; quote_len = quote_length(IFREG(current->data, &qreg)); indent_len = indent_length(current->data + quote_len); } while (current->data[quote_len + indent_len] == '\0'); @@ -2360,7 +2379,7 @@ int do_justify(void) { /* The line is too long. Try to wrap it to the next. */ break_pos = break_line(current->data + indent_len, fill - strnlenpt(current->data, indent_len), - 1); + 1); if (break_pos == -1 || break_pos + indent_len == line_len) /* We can't break the line, or don't need to, so just go * on to the next. */ @@ -2467,7 +2486,7 @@ int do_justify(void) { current = current->next; } } else -continue_loc: + continue_loc: current = current->next; } /* We are now done justifying the paragraph. There are cleanup things to @@ -2478,11 +2497,11 @@ continue_loc: * fileage, set current_x. Also, edit_refresh() needs the line * numbers to be right, so we renumber(). */ last_par_line = current->prev; - if (first_mod_line != NULL && first_mod_line->prev == NULL) - fileage = first_mod_line; - current_x = 0; - if (first_mod_line != NULL) + if (first_mod_line != NULL) { + if (first_mod_line->prev == NULL) + fileage = first_mod_line; renumber(first_mod_line); + } if (current_y > editwinrows - 4) edit_update(current, CENTER); @@ -2566,7 +2585,6 @@ continue_loc: #endif } - #ifndef DISABLE_HELP /* This function allocates help_text, and stores the help string in it. * help_text should be NULL initially. */ @@ -2770,7 +2788,7 @@ void help_init(void) #endif #ifndef NANO_SMALL -static void do_toggle(const toggle *which) +void do_toggle(const toggle *which) { int enabled; diff --git a/nano.h b/nano.h index d1db7d4b..bc34f89f 100644 --- a/nano.h +++ b/nano.h @@ -344,10 +344,10 @@ know what you're doing */ #define TOGGLE_PICOMODE_KEY NANO_ALT_P #define TOGGLE_MOUSE_KEY NANO_ALT_M #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_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_DOS_KEY NANO_ALT_D #define TOGGLE_MAC_KEY NANO_ALT_O diff --git a/nano.texi b/nano.texi index b235d76b..234ab558 100644 --- a/nano.texi +++ b/nano.texi @@ -9,7 +9,7 @@ @smallbook @set EDITION 0.1 @set VERSION 1.1.10 -@set UPDATED 14 Jul 2002 +@set UPDATED 30 Jul 2002 @dircategory Editors @direntry @@ -134,6 +134,10 @@ Write file in Mac format. Do not convert files from DOS/Mac format. @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 "> ". @item -R, --regexp diff --git a/rcfile.c b/rcfile.c index 06d2ad98..6b7b1e7f 100644 --- a/rcfile.c +++ b/rcfile.c @@ -43,7 +43,6 @@ #define _(string) (string) #endif -/* Static stuff for the nanorc file */ static rcoption rcopts[] = { #ifndef NANO_SMALL {"autoindent", AUTOINDENT}, @@ -100,7 +99,7 @@ static 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. */ -static void rcfile_error(const char *msg, ...) +void rcfile_error(const char *msg, ...) { 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. */ -static void rcfile_msg(const char *msg, ...) +void rcfile_msg(const char *msg, ...) { 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. */ -static char *parse_next_word(char *ptr) +char *parse_next_word(char *ptr) { while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n' && *ptr != '\0') 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. * Otherwise, the word is interpreted as usual. That is so the arguments * can contain "s too. */ -static char *parse_argument(char *ptr) { +char *parse_argument(char *ptr) +{ const char *ptr_bak = ptr; char *last_quote = NULL; @@ -188,7 +188,7 @@ static char *parse_argument(char *ptr) { #ifdef ENABLE_COLOR -static char *parse_next_regex(char *ptr) +char *parse_next_regex(char *ptr) { while ((*ptr != '"' || (*(ptr + 1) != ' ' && *(ptr + 1) != '\n')) && *ptr != '\n' && *ptr != '\0') @@ -206,7 +206,7 @@ static char *parse_next_regex(char *ptr) return ptr; } -static int colortoint(const char *colorname, int *bright) +int colortoint(const char *colorname, int *bright) { int mcolor = 0; @@ -245,7 +245,7 @@ static int colortoint(const char *colorname, int *bright) return mcolor; } -static void parse_syntax(char *ptr) +void parse_syntax(char *ptr) { syntaxtype *tmpsyntax = 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 */ -static void parse_colors(char *ptr) +void parse_colors(char *ptr) { int fg, bg, bright = 0; int expectend = 0; /* Do we expect an end= line? */ @@ -434,7 +434,7 @@ static void parse_colors(char *ptr) #endif /* ENABLE_COLOR */ /* 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; int set = 0, i, j; diff --git a/search.c b/search.c index ac44f733..fe080bd2 100644 --- a/search.c +++ b/search.c @@ -42,7 +42,7 @@ #ifdef HAVE_REGEX_H 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); } @@ -71,7 +71,7 @@ void search_init_globals(void) 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; char *buf; diff --git a/utils.c b/utils.c index cf394fde..83ea2670 100644 --- a/utils.c +++ b/utils.c @@ -49,7 +49,7 @@ int num_of_digits(int n) int i = 1; if (n < 0) - n = 0 - n; + n = -n; while (n > 10) { n /= 10; @@ -96,7 +96,7 @@ void sunder(char *str) /* None of this is needed if we're using 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) { for(; rev_start >= haystack ; rev_start--) { @@ -110,7 +110,7 @@ static const char *revstrstr(const char *haystack, const char *needle, 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) { for (; rev_start >= haystack; rev_start--) { diff --git a/winio.c b/winio.c index 69ea4efc..2657f391 100644 --- a/winio.c +++ b/winio.c @@ -36,16 +36,10 @@ #define _(string) (string) #endif -/* winio.c statics */ static int statblank = 0; /* Number of keystrokes left after we call statusbar(), before we 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) { current = fileage; @@ -153,29 +147,6 @@ size_t strlenpt(const char *buf) 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) { 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 * off! */ -static void nanoget_repaint(const char *buf, const char *inputbuf, - int x) +void nanoget_repaint(const char *buf, const char *inputbuf, int x) { int len = strlen(buf) + 2; 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 * 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 #ifndef DISABLE_TABCOMP , int *list @@ -517,7 +487,7 @@ void titlebar(const char *path) * keystroke is e.g. "^G" and desc is e.g. "Get Help". * We are careful to write exactly len characters, even if len is * 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); 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)) return; @@ -637,12 +607,34 @@ int get_page_end_virtual(int page) return get_page_start_virtual(page) + COLS - 1; } -static int get_page_start(int column) +int get_page_start(int column) { assert(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 /* 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 */ k = start; - regcomp(&color_regexp, tmpcolor->start, 0); + regcomp(&color_regexp, tmpcolor->start, REG_EXTENDED); while (!regexec(&color_regexp, &fileptr->data[k], 1, colormatches, 0)) { @@ -789,7 +781,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, s = fileptr; while (s != NULL) { - regcomp(&color_regexp, tmpcolor->start, 0); + regcomp(&color_regexp, tmpcolor->start, REG_EXTENDED); if (!regexec (&color_regexp, s->data, 1, colormatches, 0)) { regfree(&color_regexp); @@ -805,7 +797,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, e = s; while (e != NULL && e != fileptr) { - regcomp(&color_regexp, tmpcolor->end, 0); + regcomp(&color_regexp, tmpcolor->end, REG_EXTENDED); if (!regexec (&color_regexp, e->data, 1, colormatches, 0)) { 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 */ else { /* Keep looking for an end */ while (e != NULL) { - regcomp(&color_regexp, tmpcolor->end, 0); + regcomp(&color_regexp, tmpcolor->end, REG_EXTENDED); if (!regexec (&color_regexp, e->data, 1, colormatches, 0)) { @@ -836,7 +828,7 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x, ematch = colormatches[0].rm_eo; while (e != NULL) { - regcomp(&color_regexp, tmpcolor->end, 0); + regcomp(&color_regexp, tmpcolor->end, REG_EXTENDED); if (!regexec (&color_regexp, e->data, 1, colormatches, 0)) {