diff -rup nano-1.2.5/ChangeLog nano-1.2.5p/ChangeLog --- nano-1.2.5/ChangeLog Sun May 15 20:29:42 2005 +++ nano-1.2.5p/ChangeLog Sat Sep 30 22:21:06 2006 @@ -1,3 +1,35 @@ +Locally patched GNU nano 1.2.5p - 2006.09.30 +- General: + - This locally applied patch adds bracket flashing, which is + like bracket matching, but happens live: when the user types + a close bracket, the matching open bracket is highlighted, + if it is on screen; or, a status bar message displays the + text from the offscreen line with the matching bracket. + See http://www.zeuscat.com/andrew/software/nano/ for details. +- configure: + - Update version number to 1.2.5p so users know they are using + a locally patched version. +- global.c, proto.h: + - Add global last_highlight_y which is y coordinate of last + highlighted match, or -1 if nothing is highlighted; also + declare do_flash_bracket(), similar to do_find_bracket(). +- nano.c: + do_char() + - Call edit_refresh() to undo last highlight, if any. + If a close bracket is typed, call do_flash_bracket(). +- search.c: + do_find_bracket(), do_flash_bracket(), do_find_or_flash_bracket() + - Since both bracket matching and flashing features use the + same searching code, have them call the same function with + a flag. do_find_or_flash_bracket() includes a logic block + to highlight the matching open bracket, then restore the + cursor position (since the default behavior is to move the + cursor to the matching bracket). +- winio.c: + highlight_char() + - Add new function to highlight an individual character + (display it in reverse video). + GNU nano 1.2.5 - 2005.05.15 - files.c: open_prevfile(), open_nextfile() diff -rup nano-1.2.5/configure nano-1.2.5p/configure --- nano-1.2.5/configure Thu Apr 14 20:01:40 2005 +++ nano-1.2.5p/configure Sat Sep 30 02:59:46 2006 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for GNU Nano 1.2.5. +# Generated by GNU Autoconf 2.59 for GNU Nano 1.2.5p. # # Report bugs to . # @@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='GNU Nano' PACKAGE_TARNAME='nano' -PACKAGE_VERSION='1.2.5' -PACKAGE_STRING='GNU Nano 1.2.5' +PACKAGE_VERSION='1.2.5p' +PACKAGE_STRING='GNU Nano 1.2.5p' PACKAGE_BUGREPORT='nano-devel@gnu.org' ac_unique_file="nano.c" @@ -780,7 +780,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures GNU Nano 1.2.5 to adapt to many kinds of systems. +\`configure' configures GNU Nano 1.2.5p to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -846,7 +846,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU Nano 1.2.5:";; + short | recursive ) echo "Configuration of GNU Nano 1.2.5p:";; esac cat <<\_ACEOF @@ -996,7 +996,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -GNU Nano configure 1.2.5 +GNU Nano configure 1.2.5p generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1010,7 +1010,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by GNU Nano $as_me 1.2.5, which was +It was created by GNU Nano $as_me 1.2.5p, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1654,7 +1654,7 @@ fi # Define the identity of the package. PACKAGE='nano' - VERSION='1.2.5' + VERSION='1.2.5p' cat >>confdefs.h <<_ACEOF @@ -8374,7 +8374,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by GNU Nano $as_me 1.2.5, which was +This file was extended by GNU Nano $as_me 1.2.5p, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -8437,7 +8437,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -GNU Nano config.status 1.2.5 +GNU Nano config.status 1.2.5p configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff -rup nano-1.2.5/global.c nano-1.2.5p/global.c --- nano-1.2.5/global.c Tue Mar 22 07:04:02 2005 +++ nano-1.2.5p/global.c Sat Sep 30 21:39:43 2006 @@ -87,6 +87,12 @@ char *hblank = NULL; /* A horizontal bl char *help_text; /* The text in the help window */ #endif +/* Stuff for bracket flashing */ + +#ifndef NANO_SMALL +int last_highlight_y; /* line with the last highlighted bracket */ +#endif + /* More stuff for the marker select */ #ifndef NANO_SMALL diff -rup nano-1.2.5/nano.c nano-1.2.5p/nano.c --- nano-1.2.5/nano.c Tue Mar 22 07:04:02 2005 +++ nano-1.2.5p/nano.c Sat Sep 30 21:57:58 2006 @@ -210,6 +210,10 @@ void global_init(int save_cutbuffer) totsize = 0; placewewant = 0; +#ifndef NANO_SMALL + last_highlight_y = -1; +#endif + #ifndef DISABLE_WRAPJUSTIFY fill = wrap_at; if (fill <= 0) @@ -1027,6 +1031,20 @@ void do_char(char ch) #if !defined(DISABLE_WRAPPING) || defined(ENABLE_COLOR) if (refresh) edit_refresh(); +#endif + +#ifndef NANO_SMALL + if (last_highlight_y >= 0) { + edit_refresh(); + last_highlight_y = -1; + } + + /* flash brackets */ + if (ch == '}' || ch == ']' || ch == ')') { + current_x--; + do_flash_bracket(); + current_x++; + } #endif } diff -rup nano-1.2.5/proto.h nano-1.2.5p/proto.h --- nano-1.2.5/proto.h Tue Mar 22 07:04:02 2005 +++ nano-1.2.5p/proto.h Sat Sep 30 03:04:21 2006 @@ -70,6 +70,7 @@ extern struct stat fileinfo; extern filestruct *current, *fileage, *edittop, *editbot, *filebot; extern filestruct *cutbuffer; #ifndef NANO_SMALL +extern int last_highlight_y; extern filestruct *mark_beginbuf; #endif @@ -375,6 +376,7 @@ int do_gotoline_void(void); void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant); #endif int do_find_bracket(void); +int do_flash_bracket(void); #ifndef NANO_SMALL void history_init(void); historytype *find_node(historytype *h, char *s); @@ -487,6 +489,7 @@ int do_cursorpos_void(void); int line_len(const char *ptr); int do_help(void); int keypad_on(WINDOW *win, int newval); +void highlight_char(WINDOW *win, int y, int x, char c); void do_replace_highlight(int highlight_flag, const char *word); void fix_editbot(void); #ifdef DEBUG diff -rup nano-1.2.5/search.c nano-1.2.5p/search.c --- nano-1.2.5/search.c Fri Jun 25 17:23:40 2004 +++ nano-1.2.5p/search.c Thu Oct 5 23:27:14 2006 @@ -889,10 +889,21 @@ void do_gotopos(int line, int pos_x, int #if !defined(NANO_SMALL) && defined(HAVE_REGEX_H) int do_find_bracket(void) { + do_find_or_flash_bracket(0); +} + +int do_flash_bracket(void) +{ + do_find_or_flash_bracket(1); +} + +int do_find_or_flash_bracket(int is_flash) +{ char ch_under_cursor, wanted_ch; const char *pos, *brackets = "([{<>}])"; char regexp_pat[] = "[ ]"; int offset, have_search_offscreen = 0, flagsave, current_x_save, count = 1; + int match_y, match_x, page_start_save; filestruct *current_save; ch_under_cursor = current->data[current_x]; @@ -910,6 +921,7 @@ int do_find_bracket(void) current_x_save = current_x; current_save = current; + page_start_save = get_page_start(xplustabs() + 1); flagsave = flags; SET(USE_REGEXP); @@ -939,10 +951,34 @@ int do_find_bracket(void) /* found complementary bracket */ if (!(--count)) { - if (have_search_offscreen) - edit_update(current, CENTER); - else - update_line(current, current_x); + if(is_flash) { + match_y = current->lineno - edittop->lineno; + match_x = xplustabs() - page_start_save; + if (have_search_offscreen) { + /* match was on another screen */ + statusbar(_("Matched line %ld: %s"), + current->lineno, current->data); + } else if(match_x < 0) { + /* match was on offscreen column of same line */ + statusbar(_("Matched: %s"), current->data); + /* TODO: display only up to matching paren */ + } else { + /* match is displayed, so flash bracket */ + assert(match_y < 0 || + match_y == check_linenumbers(current)); + highlight_char(edit, match_y, match_x, + current->data[current_x]); + } + /* restore values, don't actually reposition cursor */ + current_x = current_x_save; + current = current_save; + } else { + /* non-flash behavior is to move cursor to match */ + if (have_search_offscreen) + edit_update(current, CENTER); + else + update_line(current, current_x); + } placewewant = xplustabs(); reset_cursor(); break; diff -rup nano-1.2.5/winio.c nano-1.2.5p/winio.c --- nano-1.2.5/winio.c Tue Mar 22 07:04:02 2005 +++ nano-1.2.5p/winio.c Sat Sep 30 03:10:15 2006 @@ -1748,6 +1748,21 @@ void do_replace_highlight(int highlight_ free(highlight_word); } +/* Highlight a character */ +void highlight_char(WINDOW *win, int y, int x, char c) { +#ifndef NANO_SMALL + last_highlight_y = y; +#endif NANO_SMALL + wattron(win, A_REVERSE); + wmove(win, y, x); + wechochar(win, c); + wattroff(edit, A_REVERSE); + + /* Restore cursor in edit buffer, if necessary */ + if (win == edit && (y != current_y || x != current_x)) + wmove(edit, current_y, current_x); +} + /* Fix editbot, based on the assumption that edittop is correct. */ void fix_editbot(void) {