From 8f1afee8132e36e3abcfb92bbff84c290e24b437 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sat, 16 Jul 2005 07:06:36 +0000 Subject: [PATCH] fix color breakage; also, in main(), when opening files with "+LINE,COLUMN" arguments on the command line, don't update the screen when moving to their specified lines and columns git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2873 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 7 +++++++ src/color.c | 2 ++ src/files.c | 4 +--- src/nano.c | 6 ++++-- src/proto.h | 2 +- src/search.c | 23 ++++++++++++++--------- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33f450b6..5dcf1744 100644 --- a/ChangeLog +++ b/ChangeLog @@ -84,6 +84,10 @@ CVS code - allow_pending_sigwinch() - Simplify by using the "?" operator instead of an if clause. (DLR) + main() + - When opening files with "+LINE,COLUMN" arguments on the + command line, don't update the screen when moving to their + specified lines and columns. (DLR) - nano.h: - Since we only use vsnprintf() now, remove the #ifdef block for HAVE_SNPRINTF. (DLR) @@ -103,6 +107,9 @@ CVS code - - Blank out last_replace properly again just before displaying the "Replace" prompt. (DLR, found by Mike Frysinger) - Remove unnecessary renumber(). (DLR) + do_gotolinecolumn() + - Add parameter allow_update to control whether the screen is + updated after moving. (DLR) - winio.c: edit_scroll(), edit_redraw(), edit_refresh() - Clean up and simplify. (DLR) diff --git a/src/color.c b/src/color.c index c54a7bf8..b1085822 100644 --- a/src/color.c +++ b/src/color.c @@ -161,6 +161,8 @@ void color_update(void) REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0)); } } + + color_init(); } #endif /* ENABLE_COLOR */ diff --git a/src/files.c b/src/files.c index 94fb7377..d4bba67f 100644 --- a/src/files.c +++ b/src/files.c @@ -1586,10 +1586,8 @@ int write_file(const char *name, FILE *f_open, bool tmp, int append, realname); #ifdef ENABLE_COLOR /* We might have changed the filename, so update the colors - * to account for it, and make sure we're using the updated - * colors, if applicable. */ + * to account for it. */ color_update(); - color_init(); /* If color syntaxes are available and turned on, we need to * call edit_refresh(). */ diff --git a/src/nano.c b/src/nano.c index 64f2ce18..4533524b 100644 --- a/src/nano.c +++ b/src/nano.c @@ -4676,7 +4676,8 @@ int main(int argc, char **argv) open_buffer(argv[i]); if (iline > 1 || icol > 1) { - do_gotolinecolumn(iline, icol, FALSE, FALSE, FALSE); + do_gotolinecolumn(iline, icol, FALSE, FALSE, FALSE, + FALSE); iline = 1; icol = 1; } @@ -4710,7 +4711,8 @@ int main(int argc, char **argv) #endif if (startline > 1 || startcol > 1) - do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE); + do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE, + FALSE); display_main_list(); diff --git a/src/proto.h b/src/proto.h index 8d8ad854..38a1de2f 100644 --- a/src/proto.h +++ b/src/proto.h @@ -503,7 +503,7 @@ ssize_t do_replace_loop(const char *needle, const filestruct *canceled); void do_replace(void); void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, - bool interactive, bool save_pos); + bool interactive, bool save_pos, bool allow_update); void do_gotolinecolumn_void(void); #if defined(ENABLE_MULTIBUFFER) || !defined(DISABLE_SPELLER) void do_gotopos(ssize_t line, size_t pos_x, ssize_t pos_y, size_t diff --git a/src/search.c b/src/search.c index 365a9f9b..f3e263ac 100644 --- a/src/search.c +++ b/src/search.c @@ -244,7 +244,8 @@ int search_init(bool replacing, bool use_answer) return -2; /* Call the opposite search function. */ case NANO_TOGOTOLINE_KEY: do_gotolinecolumn(openfile->current->lineno, - openfile->placewewant + 1, TRUE, TRUE, FALSE); + openfile->placewewant + 1, TRUE, TRUE, FALSE, + TRUE); /* Put answer up on the statusbar and * fall through. */ default: @@ -968,12 +969,15 @@ void do_replace(void) /* Go to the specified line and column, or ask for them if interactive * is TRUE. Save the x-coordinate and y-coordinate if save_pos is TRUE. - * Note that both the line and column numbers should be one-based. */ + * Update the screen afterwards if allow_update is TRUE. Note that both + * the line and column numbers should be one-based. */ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, - bool interactive, bool save_pos) + bool interactive, bool save_pos, bool allow_update) { - if (interactive) { /* Ask for it. */ + if (interactive) { char *ans = mallocstrcpy(NULL, answer); + + /* Ask for it. */ int i = statusq(FALSE, gotoline_list, use_answer ? ans : "", #ifndef NANO_SMALL NULL, @@ -1022,9 +1026,10 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, openfile->current_x = actual_x(openfile->current->data, column - 1); openfile->placewewant = column - 1; - /* If save_pos is TRUE, don't change the cursor position when - * updating the edit window. */ - edit_update(save_pos ? NONE : CENTER); + /* If allow_update is TRUE, update the edit window. If save_pos is + * TRUE, don't change the cursor position when doing it. */ + if (allow_update) + edit_update(save_pos ? NONE : CENTER); display_main_list(); } @@ -1032,7 +1037,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer, void do_gotolinecolumn_void(void) { do_gotolinecolumn(openfile->current->lineno, - openfile->placewewant + 1, FALSE, TRUE, FALSE); + openfile->placewewant + 1, FALSE, TRUE, FALSE, TRUE); } #if defined(ENABLE_MULTIBUFFER) || !defined(DISABLE_SPELLER) @@ -1042,7 +1047,7 @@ void do_gotopos(ssize_t line, size_t pos_x, ssize_t pos_y, size_t /* Since do_gotolinecolumn() resets the x-coordinate but not the * y-coordinate, set the coordinates up this way. */ openfile->current_y = pos_y; - do_gotolinecolumn(line, pos_x + 1, FALSE, FALSE, TRUE); + do_gotolinecolumn(line, pos_x + 1, FALSE, FALSE, TRUE, TRUE); /* Set the rest of the coordinates up. */ openfile->placewewant = pos_pww; -- 2.39.5