Commit c21790d6 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

edit_redraw() fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1788 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent be265616
Showing with 38 additions and 40 deletions
+38 -40
...@@ -88,9 +88,11 @@ CVS code - ...@@ -88,9 +88,11 @@ CVS code -
do_research(), do_replace_loop(), do_find_bracket(), and do_research(), do_replace_loop(), do_find_bracket(), and
edit_refresh(). New functions do_left_void(), edit_refresh(). New functions do_left_void(),
do_right_void(), need_horizontal_update(), do_right_void(), need_horizontal_update(),
need_vertical_update(), edit_scroll(), and edit_redraw(). need_vertical_update(), edit_scroll(), and edit_redraw(). All
Also rename the int refresh in do_delete() and do_backspace() of these functions but the first two require the previous
to do_refresh so as not to conflict with refresh(). (DLR) versions of current and/or placewewant as parameters. Also
rename the int refresh in do_delete() and do_backspace() to
do_refresh so as not to conflict with refresh(). (DLR)
- Add some comments better explaining what is disabled in - Add some comments better explaining what is disabled in
restricted mode and why. (DLR) restricted mode and why. (DLR)
- Since KEEP_CUTBUFFER is only used in cut.c, make it a static - Since KEEP_CUTBUFFER is only used in cut.c, make it a static
......
...@@ -92,7 +92,7 @@ int do_end(void) ...@@ -92,7 +92,7 @@ int do_end(void)
int do_page_up(void) int do_page_up(void)
{ {
int new_pww = placewewant; int old_pww = placewewant;
const filestruct *old_current = current; const filestruct *old_current = current;
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
wrap_reset(); wrap_reset();
...@@ -102,7 +102,7 @@ int do_page_up(void) ...@@ -102,7 +102,7 @@ int do_page_up(void)
* and put the cursor at the beginning of the line. */ * and put the cursor at the beginning of the line. */
if (edittop == fileage) { if (edittop == fileage) {
current = fileage; current = fileage;
new_pww = 0; placewewant = 0;
} else { } else {
edit_scroll(UP, editwinrows - 2); edit_scroll(UP, editwinrows - 2);
...@@ -121,19 +121,17 @@ int do_page_up(void) ...@@ -121,19 +121,17 @@ int do_page_up(void)
else { else {
#endif #endif
current = edittop; current = edittop;
new_pww = 0; placewewant = 0;
#ifndef NANO_SMALL #ifndef NANO_SMALL
} }
#endif #endif
} }
/* Get the equivalent x-coordinate of the new line. */ /* Get the equivalent x-coordinate of the new line. */
current_x = actual_x(current->data, new_pww); current_x = actual_x(current->data, placewewant);
/* Update all the lines that need to be updated, and then set /* Update all the lines that need to be updated. */
* placewewant, so that the update will work properly. */ edit_redraw(old_current, old_pww);
edit_redraw(old_current);
placewewant = new_pww;
check_statblank(); check_statblank();
return 1; return 1;
...@@ -141,7 +139,7 @@ int do_page_up(void) ...@@ -141,7 +139,7 @@ int do_page_up(void)
int do_page_down(void) int do_page_down(void)
{ {
int new_pww = placewewant; int old_pww = placewewant;
const filestruct *old_current = current; const filestruct *old_current = current;
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
wrap_reset(); wrap_reset();
...@@ -151,7 +149,7 @@ int do_page_down(void) ...@@ -151,7 +149,7 @@ int do_page_down(void)
* there and put the cursor at the beginning of the line. */ * there and put the cursor at the beginning of the line. */
if (edittop->lineno + editwinrows > filebot->lineno) { if (edittop->lineno + editwinrows > filebot->lineno) {
current = filebot; current = filebot;
new_pww = 0; placewewant = 0;
} else { } else {
edit_scroll(DOWN, editwinrows - 2); edit_scroll(DOWN, editwinrows - 2);
...@@ -171,19 +169,17 @@ int do_page_down(void) ...@@ -171,19 +169,17 @@ int do_page_down(void)
else { else {
#endif #endif
current = edittop; current = edittop;
new_pww = 0; placewewant = 0;
#ifndef NANO_SMALL #ifndef NANO_SMALL
} }
#endif #endif
} }
/* Get the equivalent x-coordinate of the new line. */ /* Get the equivalent x-coordinate of the new line. */
current_x = actual_x(current->data, new_pww); current_x = actual_x(current->data, placewewant);
/* Update all the lines that need to be updated, and then set /* Update all the lines that need to be updated. */
* placewewant, so that the update will work properly. */ edit_redraw(old_current, old_pww);
edit_redraw(old_current);
placewewant = new_pww;
check_statblank(); check_statblank();
return 1; return 1;
......
...@@ -1165,6 +1165,7 @@ int do_enter(void) ...@@ -1165,6 +1165,7 @@ int do_enter(void)
#ifndef NANO_SMALL #ifndef NANO_SMALL
int do_next_word(void) int do_next_word(void)
{ {
int old_pww = placewewant;
const filestruct *current_save = current; const filestruct *current_save = current;
assert(current != NULL && current->data != NULL); assert(current != NULL && current->data != NULL);
...@@ -1190,7 +1191,7 @@ int do_next_word(void) ...@@ -1190,7 +1191,7 @@ int do_next_word(void)
/* Refresh the screen. If current has run off the bottom, this /* Refresh the screen. If current has run off the bottom, this
* call puts it at the center line. */ * call puts it at the center line. */
edit_redraw(current_save); edit_redraw(current_save, old_pww);
return 0; return 0;
} }
...@@ -1198,6 +1199,7 @@ int do_next_word(void) ...@@ -1198,6 +1199,7 @@ int do_next_word(void)
/* The same thing for backwards. */ /* The same thing for backwards. */
int do_prev_word(void) int do_prev_word(void)
{ {
int old_pww = placewewant;
const filestruct *current_save = current; const filestruct *current_save = current;
assert(current != NULL && current->data != NULL); assert(current != NULL && current->data != NULL);
...@@ -1228,7 +1230,7 @@ int do_prev_word(void) ...@@ -1228,7 +1230,7 @@ int do_prev_word(void)
/* Refresh the screen. If current has run off the top, this call /* Refresh the screen. If current has run off the top, this call
* puts it at the center line. */ * puts it at the center line. */
edit_redraw(current_save); edit_redraw(current_save, old_pww);
return 0; return 0;
} }
...@@ -2160,6 +2162,7 @@ int break_line(const char *line, int goal, int force) ...@@ -2160,6 +2162,7 @@ int break_line(const char *line, int goal, int force)
int do_para_search(justbegend search_type, size_t *quote, size_t *par, int do_para_search(justbegend search_type, size_t *quote, size_t *par,
size_t *indent, int do_refresh) size_t *indent, int do_refresh)
{ {
int old_pww = placewewant;
const filestruct *current_save = current; const filestruct *current_save = current;
size_t quote_len; size_t quote_len;
/* Length of the initial quotation of the paragraph we /* Length of the initial quotation of the paragraph we
...@@ -2235,7 +2238,7 @@ int do_para_search(justbegend search_type, size_t *quote, size_t *par, ...@@ -2235,7 +2238,7 @@ int do_para_search(justbegend search_type, size_t *quote, size_t *par,
if (current->prev == NULL) { if (current->prev == NULL) {
placewewant = 0; placewewant = 0;
if (do_refresh) if (do_refresh)
edit_redraw(current_save); edit_redraw(current_save, old_pww);
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
if (!do_restart) if (!do_restart)
regfree(&qreg); regfree(&qreg);
...@@ -2256,7 +2259,7 @@ int do_para_search(justbegend search_type, size_t *quote, size_t *par, ...@@ -2256,7 +2259,7 @@ int do_para_search(justbegend search_type, size_t *quote, size_t *par,
if (current->next == NULL) { if (current->next == NULL) {
placewewant = 0; placewewant = 0;
if (do_refresh) if (do_refresh)
edit_redraw(current_save); edit_redraw(current_save, old_pww);
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
regfree(&qreg); regfree(&qreg);
#endif #endif
...@@ -2347,7 +2350,7 @@ int do_para_search(justbegend search_type, size_t *quote, size_t *par, ...@@ -2347,7 +2350,7 @@ int do_para_search(justbegend search_type, size_t *quote, size_t *par,
/* Refresh the screen if needed. */ /* Refresh the screen if needed. */
if (do_refresh) if (do_refresh)
edit_redraw(current_save); edit_redraw(current_save, old_pww);
/* Save the values of quote_len, par_len, and indent_len if /* Save the values of quote_len, par_len, and indent_len if
* needed. */ * needed. */
......
...@@ -540,7 +540,7 @@ void update_line(const filestruct *fileptr, size_t index); ...@@ -540,7 +540,7 @@ void update_line(const filestruct *fileptr, size_t index);
int need_horizontal_update(int old_placewewant); int need_horizontal_update(int old_placewewant);
int need_vertical_update(int old_placewewant); int need_vertical_update(int old_placewewant);
void edit_scroll(updown direction, int nlines); void edit_scroll(updown direction, int nlines);
void edit_redraw(const filestruct *old_current); void edit_redraw(const filestruct *old_current, int old_pww);
void edit_refresh(void); void edit_refresh(void);
void edit_update(filestruct *fileptr, topmidnone location); void edit_update(filestruct *fileptr, topmidnone location);
int statusq(int allowtabs, const shortcut *s, const char *def, int statusq(int allowtabs, const shortcut *s, const char *def,
......
...@@ -361,7 +361,7 @@ int findnextstr(int can_display_wrap, int wholeword, const filestruct ...@@ -361,7 +361,7 @@ int findnextstr(int can_display_wrap, int wholeword, const filestruct
/* Search for a string. */ /* Search for a string. */
int do_search(void) int do_search(void)
{ {
int i, fileptr_x = current_x, didfind; int old_pww = placewewant, i, fileptr_x = current_x, didfind;
filestruct *fileptr = current; filestruct *fileptr = current;
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
...@@ -419,8 +419,8 @@ int do_search(void) ...@@ -419,8 +419,8 @@ int do_search(void)
#endif #endif
} }
edit_redraw(fileptr);
placewewant = xplustabs(); placewewant = xplustabs();
edit_redraw(fileptr, old_pww);
search_abort(); search_abort();
return 1; return 1;
...@@ -430,7 +430,7 @@ int do_search(void) ...@@ -430,7 +430,7 @@ int do_search(void)
/* Search for the next string without prompting. */ /* Search for the next string without prompting. */
int do_research(void) int do_research(void)
{ {
int fileptr_x = current_x, didfind; int old_pww = placewewant, fileptr_x = current_x, didfind;
filestruct *fileptr = current; filestruct *fileptr = current;
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
...@@ -472,8 +472,8 @@ int do_research(void) ...@@ -472,8 +472,8 @@ int do_research(void)
} else } else
statusbar(_("No current search pattern")); statusbar(_("No current search pattern"));
edit_redraw(fileptr);
placewewant = xplustabs(); placewewant = xplustabs();
edit_redraw(fileptr, old_pww);
search_abort(); search_abort();
return 1; return 1;
...@@ -587,7 +587,7 @@ char *replace_line(const char *needle) ...@@ -587,7 +587,7 @@ char *replace_line(const char *needle)
int do_replace_loop(const char *needle, const filestruct *real_current, int do_replace_loop(const char *needle, const filestruct *real_current,
size_t *real_current_x, int wholewords) size_t *real_current_x, int wholewords)
{ {
int replaceall = 0, numreplaced = -1; int old_pww = placewewant, replaceall = 0, numreplaced = -1;
size_t current_x_save = current_x; size_t current_x_save = current_x;
const filestruct *current_save = current; const filestruct *current_save = current;
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
...@@ -635,7 +635,7 @@ int do_replace_loop(const char *needle, const filestruct *real_current, ...@@ -635,7 +635,7 @@ int do_replace_loop(const char *needle, const filestruct *real_current,
#endif #endif
if (!replaceall) if (!replaceall)
edit_redraw(current_save); edit_redraw(current_save, old_pww);
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) if (ISSET(USE_REGEXP))
...@@ -905,7 +905,7 @@ int do_find_bracket(void) ...@@ -905,7 +905,7 @@ int do_find_bracket(void)
char ch_under_cursor, wanted_ch; char ch_under_cursor, wanted_ch;
const char *pos, *brackets = "([{<>}])"; const char *pos, *brackets = "([{<>}])";
char regexp_pat[] = "[ ]"; char regexp_pat[] = "[ ]";
int current_x_save, flagsave, count = 1; int old_pww = placewewant, current_x_save, flagsave, count = 1;
filestruct *current_save; filestruct *current_save;
ch_under_cursor = current->data[current_x]; ch_under_cursor = current->data[current_x];
...@@ -949,8 +949,8 @@ int do_find_bracket(void) ...@@ -949,8 +949,8 @@ int do_find_bracket(void)
count++; count++;
/* Found complementary bracket. */ /* Found complementary bracket. */
else if (--count == 0) { else if (--count == 0) {
edit_redraw(current_save);
placewewant = xplustabs(); placewewant = xplustabs();
edit_redraw(current_save, old_pww);
break; break;
} }
} else { } else {
......
...@@ -2610,14 +2610,11 @@ void edit_scroll(updown direction, int nlines) ...@@ -2610,14 +2610,11 @@ void edit_scroll(updown direction, int nlines)
} }
/* Update any lines between old_current and current that need to be /* Update any lines between old_current and current that need to be
* updated. Note that we use placewewant to determine whether we need * updated. Assume none of the text has changed since the last
* updates and current_x to update current, so if placewewant needs to * update. */
* be changed, it should be changed after calling this, and if current_x void edit_redraw(const filestruct *old_current, int old_pww)
* needs to be changed, it should be changed before calling this.
* Assume none of the text has changed since the last update. */
void edit_redraw(const filestruct *old_current)
{ {
int do_refresh = need_vertical_update(0); int do_refresh = need_vertical_update(old_pww);
const filestruct *foo; const filestruct *foo;
/* If either old_current or current is offscreen, refresh the screen /* If either old_current or current is offscreen, refresh the screen
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment