it turns out edit_redraw() is needed after all when doing

PageUp/PageDown; revert all the movement code and edit_scroll() changes
except for added comments and edit_scroll() simplifications


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2860 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey 2005-07-14 22:15:09 +00:00
parent 1458891b9f
commit b802a13c5a
3 changed files with 53 additions and 49 deletions

View File

@ -34,10 +34,6 @@ CVS code -
(DLR)
- Consistently make the flags global and any variables used to
hold it longs. (DLR)
- Tweak the movement routines to redraw all necessary lines
instead of relying on edit_redraw(). Changes to
do_page_up(), do_page_down(), do_up(), do_down(), and
edit_scroll(). (DLR)
- Consistently make the fg and bg colortype struct entries and
any variables used to hold them shorts. Changes to
do_colorinit() (renamed color_init()), color_to_int() (renamed
@ -101,6 +97,8 @@ CVS code -
- Blank out last_replace properly again just before displaying
the "Replace" prompt. (DLR, found by Mike Frysinger)
- winio.c:
edit_scroll()
- Clean up and simplify. (DLR)
do_statusbar_next_word()
- Rework to be more like do_statusbar_prev_word(), to avoid a
potential problem if we start at the end of a line. (DLR)

View File

@ -100,6 +100,9 @@ void do_end(void)
void do_page_up(void)
{
const filestruct *current_save = openfile->current;
size_t pww_save = openfile->placewewant;
#ifndef DISABLE_WRAPPING
wrap_reset();
#endif
@ -108,22 +111,21 @@ void do_page_up(void)
* and put the cursor at the beginning of the line. */
if (openfile->edittop == openfile->fileage) {
openfile->current = openfile->fileage;
openfile->current_x = 0;
openfile->placewewant = 0;
} else {
/* Scroll the edit window up a page. */
edit_scroll(UP, editwinrows - 2);
#ifndef NANO_SMALL
/* If we're in smooth scrolling mode and there's at least one
* page of text left, move the current line of the edit window
* up a page, and then get the equivalent x-coordinate of the
* current line. */
* up a page. */
if (ISSET(SMOOTH_SCROLL) && openfile->current->lineno >
editwinrows - 2) {
int i = 0;
for (; i < editwinrows - 2; i++)
openfile->current = openfile->current->prev;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
}
/* If we're not in smooth scrolling mode or there isn't at least
* one page of text left, put the cursor at the beginning of the
@ -131,21 +133,27 @@ void do_page_up(void)
else {
#endif
openfile->current = openfile->edittop;
openfile->current_x = 0;
openfile->placewewant = 0;
#ifndef NANO_SMALL
}
#endif
/* Scroll the edit window down a page. */
edit_scroll(UP, editwinrows - 2);
}
/* Get the equivalent x-coordinate of the current line. */
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* Update the screen. */
edit_redraw(current_save, pww_save);
check_statusblank();
}
void do_page_down(void)
{
const filestruct *current_save = openfile->current;
size_t pww_save = openfile->placewewant;
#ifndef DISABLE_WRAPPING
wrap_reset();
#endif
@ -155,23 +163,21 @@ void do_page_down(void)
if (openfile->edittop->lineno + editwinrows >
openfile->filebot->lineno) {
openfile->current = openfile->filebot;
openfile->current_x = 0;
openfile->placewewant = 0;
} else {
/* Scroll the edit window down a page. */
edit_scroll(DOWN, editwinrows - 2);
#ifndef NANO_SMALL
/* If we're in smooth scrolling mode and there's at least one
* page of text left, move the current line of the edit window
* down a page, and then get the equivalent x-coordinate of the
* current line. */
* down a page. */
if (ISSET(SMOOTH_SCROLL) && openfile->current->lineno +
editwinrows - 2 <= openfile->filebot->lineno) {
int i = 0;
for (; i < editwinrows - 2; i++)
openfile->current = openfile->current->next;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
}
/* If we're not in smooth scrolling mode or there isn't at least
* one page of text left, put the cursor at the beginning of the
@ -179,16 +185,19 @@ void do_page_down(void)
else {
#endif
openfile->current = openfile->edittop;
openfile->current_x = 0;
openfile->placewewant = 0;
#ifndef NANO_SMALL
}
#endif
/* Scroll the edit window down a page. */
edit_scroll(DOWN, editwinrows - 2);
}
/* Get the equivalent x-coordinate of the current line. */
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* Update the screen. */
edit_redraw(current_save, pww_save);
check_statusblank();
}
@ -220,15 +229,14 @@ void do_up(void)
ISSET(SMOOTH_SCROLL) ? 1 :
#endif
editwinrows / 2);
/* Otherwise, update the line we were on before and the line we're
* on now. The former needs to be redrawn if we're not on the first
* page, and the latter needs to be redrawn unconditionally. */
else {
/* Update the line we were on before and the line we're on now. The
* former needs to be redrawn if we're not on the first page, and
* the latter needs to be drawn unconditionally. */
if (need_vertical_update(0))
update_line(openfile->current->next, 0);
update_line(openfile->current, openfile->current_x);
}
}
void do_down(void)
{
@ -258,15 +266,14 @@ void do_down(void)
ISSET(SMOOTH_SCROLL) ? 1 :
#endif
editwinrows / 2);
/* Otherwise, update the line we were on before and the line we're
* on now. The former needs to be redrawn if we're not on the first
* page, and the latter needs to be redrawn unconditionally. */
else {
/* Update the line we were on before and the line we're on now. The
* former needs to be redrawn if we're not on the first page, and
* the latter needs to be drawn unconditionally. */
if (need_vertical_update(0))
update_line(openfile->current->prev, 0);
update_line(openfile->current, openfile->current_x);
}
}
void do_left(bool allow_update)
{

View File

@ -3503,8 +3503,11 @@ int need_vertical_update(size_t old_pww)
/* Scroll the edit window in the given direction and the given number
* of lines, and draw new lines on the blank lines left after the
* scrolling. direction is the direction to scroll, either UP or DOWN,
* and nlines is the number of lines to scroll. We assume that current
* and current_x are up to date, and only change edittop. */
* and nlines is the number of lines to scroll.
*
* Note that we don't draw the topmost or bottommost lines before or
* after scrolling, since we can make no assumptions about which of the
* two is the current line. */
void edit_scroll(updown direction, int nlines)
{
filestruct *foo;
@ -3543,19 +3546,15 @@ void edit_scroll(updown direction, int nlines)
foo = openfile->edittop;
if (direction == DOWN) {
for (i = editwinrows - nlines - 1; i > 0 && foo != NULL; i--)
for (i = editwinrows - scroll_rows; i > 0 && foo != NULL; i--)
foo = foo->next;
}
/* Draw new lines on the blank top or bottom lines of the edit
* window, depending on the value of direction. */
scroll_rows++;
while (scroll_rows > 0 && foo != NULL) {
update_line(foo, (foo == openfile->current) ?
openfile->current_x : 0);
for (; scroll_rows > 0 && foo != NULL; scroll_rows--) {
update_line(foo, 0);
foo = foo->next;
scroll_rows--;
}
}