edit_redraw() fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1788 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
be26561620
commit
c21790d6d9
|
@ -88,9 +88,11 @@ CVS code -
|
|||
do_research(), do_replace_loop(), do_find_bracket(), and
|
||||
edit_refresh(). New functions do_left_void(),
|
||||
do_right_void(), need_horizontal_update(),
|
||||
need_vertical_update(), edit_scroll(), and edit_redraw().
|
||||
Also rename the int refresh in do_delete() and do_backspace()
|
||||
to do_refresh so as not to conflict with refresh(). (DLR)
|
||||
need_vertical_update(), edit_scroll(), and edit_redraw(). All
|
||||
of these functions but the first two require the previous
|
||||
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
|
||||
restricted mode and why. (DLR)
|
||||
- Since KEEP_CUTBUFFER is only used in cut.c, make it a static
|
||||
|
|
28
src/move.c
28
src/move.c
|
@ -92,7 +92,7 @@ int do_end(void)
|
|||
|
||||
int do_page_up(void)
|
||||
{
|
||||
int new_pww = placewewant;
|
||||
int old_pww = placewewant;
|
||||
const filestruct *old_current = current;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
|
@ -102,7 +102,7 @@ int do_page_up(void)
|
|||
* and put the cursor at the beginning of the line. */
|
||||
if (edittop == fileage) {
|
||||
current = fileage;
|
||||
new_pww = 0;
|
||||
placewewant = 0;
|
||||
} else {
|
||||
edit_scroll(UP, editwinrows - 2);
|
||||
|
||||
|
@ -121,19 +121,17 @@ int do_page_up(void)
|
|||
else {
|
||||
#endif
|
||||
current = edittop;
|
||||
new_pww = 0;
|
||||
placewewant = 0;
|
||||
#ifndef NANO_SMALL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 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
|
||||
* placewewant, so that the update will work properly. */
|
||||
edit_redraw(old_current);
|
||||
placewewant = new_pww;
|
||||
/* Update all the lines that need to be updated. */
|
||||
edit_redraw(old_current, old_pww);
|
||||
|
||||
check_statblank();
|
||||
return 1;
|
||||
|
@ -141,7 +139,7 @@ int do_page_up(void)
|
|||
|
||||
int do_page_down(void)
|
||||
{
|
||||
int new_pww = placewewant;
|
||||
int old_pww = placewewant;
|
||||
const filestruct *old_current = current;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
wrap_reset();
|
||||
|
@ -151,7 +149,7 @@ int do_page_down(void)
|
|||
* there and put the cursor at the beginning of the line. */
|
||||
if (edittop->lineno + editwinrows > filebot->lineno) {
|
||||
current = filebot;
|
||||
new_pww = 0;
|
||||
placewewant = 0;
|
||||
} else {
|
||||
edit_scroll(DOWN, editwinrows - 2);
|
||||
|
||||
|
@ -171,19 +169,17 @@ int do_page_down(void)
|
|||
else {
|
||||
#endif
|
||||
current = edittop;
|
||||
new_pww = 0;
|
||||
placewewant = 0;
|
||||
#ifndef NANO_SMALL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 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
|
||||
* placewewant, so that the update will work properly. */
|
||||
edit_redraw(old_current);
|
||||
placewewant = new_pww;
|
||||
/* Update all the lines that need to be updated. */
|
||||
edit_redraw(old_current, old_pww);
|
||||
|
||||
check_statblank();
|
||||
return 1;
|
||||
|
|
13
src/nano.c
13
src/nano.c
|
@ -1165,6 +1165,7 @@ int do_enter(void)
|
|||
#ifndef NANO_SMALL
|
||||
int do_next_word(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
const filestruct *current_save = current;
|
||||
assert(current != NULL && current->data != NULL);
|
||||
|
||||
|
@ -1190,7 +1191,7 @@ int do_next_word(void)
|
|||
|
||||
/* Refresh the screen. If current has run off the bottom, this
|
||||
* call puts it at the center line. */
|
||||
edit_redraw(current_save);
|
||||
edit_redraw(current_save, old_pww);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1198,6 +1199,7 @@ int do_next_word(void)
|
|||
/* The same thing for backwards. */
|
||||
int do_prev_word(void)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
const filestruct *current_save = current;
|
||||
assert(current != NULL && current->data != NULL);
|
||||
|
||||
|
@ -1228,7 +1230,7 @@ int do_prev_word(void)
|
|||
|
||||
/* Refresh the screen. If current has run off the top, this call
|
||||
* puts it at the center line. */
|
||||
edit_redraw(current_save);
|
||||
edit_redraw(current_save, old_pww);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -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,
|
||||
size_t *indent, int do_refresh)
|
||||
{
|
||||
int old_pww = placewewant;
|
||||
const filestruct *current_save = current;
|
||||
size_t quote_len;
|
||||
/* 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,
|
|||
if (current->prev == NULL) {
|
||||
placewewant = 0;
|
||||
if (do_refresh)
|
||||
edit_redraw(current_save);
|
||||
edit_redraw(current_save, old_pww);
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (!do_restart)
|
||||
regfree(&qreg);
|
||||
|
@ -2256,7 +2259,7 @@ int do_para_search(justbegend search_type, size_t *quote, size_t *par,
|
|||
if (current->next == NULL) {
|
||||
placewewant = 0;
|
||||
if (do_refresh)
|
||||
edit_redraw(current_save);
|
||||
edit_redraw(current_save, old_pww);
|
||||
#ifdef HAVE_REGEX_H
|
||||
regfree(&qreg);
|
||||
#endif
|
||||
|
@ -2347,7 +2350,7 @@ int do_para_search(justbegend search_type, size_t *quote, size_t *par,
|
|||
|
||||
/* Refresh the screen if needed. */
|
||||
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
|
||||
* needed. */
|
||||
|
|
|
@ -540,7 +540,7 @@ void update_line(const filestruct *fileptr, size_t index);
|
|||
int need_horizontal_update(int old_placewewant);
|
||||
int need_vertical_update(int old_placewewant);
|
||||
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_update(filestruct *fileptr, topmidnone location);
|
||||
int statusq(int allowtabs, const shortcut *s, const char *def,
|
||||
|
|
16
src/search.c
16
src/search.c
|
@ -361,7 +361,7 @@ int findnextstr(int can_display_wrap, int wholeword, const filestruct
|
|||
/* Search for a string. */
|
||||
int do_search(void)
|
||||
{
|
||||
int i, fileptr_x = current_x, didfind;
|
||||
int old_pww = placewewant, i, fileptr_x = current_x, didfind;
|
||||
filestruct *fileptr = current;
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
|
@ -419,8 +419,8 @@ int do_search(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
edit_redraw(fileptr);
|
||||
placewewant = xplustabs();
|
||||
edit_redraw(fileptr, old_pww);
|
||||
search_abort();
|
||||
|
||||
return 1;
|
||||
|
@ -430,7 +430,7 @@ int do_search(void)
|
|||
/* Search for the next string without prompting. */
|
||||
int do_research(void)
|
||||
{
|
||||
int fileptr_x = current_x, didfind;
|
||||
int old_pww = placewewant, fileptr_x = current_x, didfind;
|
||||
filestruct *fileptr = current;
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
|
@ -472,8 +472,8 @@ int do_research(void)
|
|||
} else
|
||||
statusbar(_("No current search pattern"));
|
||||
|
||||
edit_redraw(fileptr);
|
||||
placewewant = xplustabs();
|
||||
edit_redraw(fileptr, old_pww);
|
||||
search_abort();
|
||||
|
||||
return 1;
|
||||
|
@ -587,7 +587,7 @@ char *replace_line(const char *needle)
|
|||
int do_replace_loop(const char *needle, const filestruct *real_current,
|
||||
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;
|
||||
const filestruct *current_save = current;
|
||||
#ifdef HAVE_REGEX_H
|
||||
|
@ -635,7 +635,7 @@ int do_replace_loop(const char *needle, const filestruct *real_current,
|
|||
#endif
|
||||
|
||||
if (!replaceall)
|
||||
edit_redraw(current_save);
|
||||
edit_redraw(current_save, old_pww);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
|
@ -905,7 +905,7 @@ int do_find_bracket(void)
|
|||
char ch_under_cursor, wanted_ch;
|
||||
const char *pos, *brackets = "([{<>}])";
|
||||
char regexp_pat[] = "[ ]";
|
||||
int current_x_save, flagsave, count = 1;
|
||||
int old_pww = placewewant, current_x_save, flagsave, count = 1;
|
||||
filestruct *current_save;
|
||||
|
||||
ch_under_cursor = current->data[current_x];
|
||||
|
@ -949,8 +949,8 @@ int do_find_bracket(void)
|
|||
count++;
|
||||
/* Found complementary bracket. */
|
||||
else if (--count == 0) {
|
||||
edit_redraw(current_save);
|
||||
placewewant = xplustabs();
|
||||
edit_redraw(current_save, old_pww);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
11
src/winio.c
11
src/winio.c
|
@ -2610,14 +2610,11 @@ void edit_scroll(updown direction, int nlines)
|
|||
}
|
||||
|
||||
/* Update any lines between old_current and current that need to be
|
||||
* updated. Note that we use placewewant to determine whether we need
|
||||
* updates and current_x to update current, so if placewewant needs to
|
||||
* be changed, it should be changed after calling this, and if current_x
|
||||
* 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)
|
||||
* updated. Assume none of the text has changed since the last
|
||||
* update. */
|
||||
void edit_redraw(const filestruct *old_current, int old_pww)
|
||||
{
|
||||
int do_refresh = need_vertical_update(0);
|
||||
int do_refresh = need_vertical_update(old_pww);
|
||||
const filestruct *foo;
|
||||
|
||||
/* If either old_current or current is offscreen, refresh the screen
|
||||
|
|
Loading…
Reference in New Issue