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-d3aeb78583b8master
parent
1458891b9f
commit
b802a13c5a
|
@ -34,10 +34,6 @@ CVS code -
|
||||||
(DLR)
|
(DLR)
|
||||||
- Consistently make the flags global and any variables used to
|
- Consistently make the flags global and any variables used to
|
||||||
hold it longs. (DLR)
|
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
|
- Consistently make the fg and bg colortype struct entries and
|
||||||
any variables used to hold them shorts. Changes to
|
any variables used to hold them shorts. Changes to
|
||||||
do_colorinit() (renamed color_init()), color_to_int() (renamed
|
do_colorinit() (renamed color_init()), color_to_int() (renamed
|
||||||
|
@ -101,6 +97,8 @@ CVS code -
|
||||||
- Blank out last_replace properly again just before displaying
|
- Blank out last_replace properly again just before displaying
|
||||||
the "Replace" prompt. (DLR, found by Mike Frysinger)
|
the "Replace" prompt. (DLR, found by Mike Frysinger)
|
||||||
- winio.c:
|
- winio.c:
|
||||||
|
edit_scroll()
|
||||||
|
- Clean up and simplify. (DLR)
|
||||||
do_statusbar_next_word()
|
do_statusbar_next_word()
|
||||||
- Rework to be more like do_statusbar_prev_word(), to avoid a
|
- Rework to be more like do_statusbar_prev_word(), to avoid a
|
||||||
potential problem if we start at the end of a line. (DLR)
|
potential problem if we start at the end of a line. (DLR)
|
||||||
|
|
67
src/move.c
67
src/move.c
|
@ -100,6 +100,9 @@ void do_end(void)
|
||||||
|
|
||||||
void do_page_up(void)
|
void do_page_up(void)
|
||||||
{
|
{
|
||||||
|
const filestruct *current_save = openfile->current;
|
||||||
|
size_t pww_save = openfile->placewewant;
|
||||||
|
|
||||||
#ifndef DISABLE_WRAPPING
|
#ifndef DISABLE_WRAPPING
|
||||||
wrap_reset();
|
wrap_reset();
|
||||||
#endif
|
#endif
|
||||||
|
@ -108,22 +111,21 @@ void 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 (openfile->edittop == openfile->fileage) {
|
if (openfile->edittop == openfile->fileage) {
|
||||||
openfile->current = openfile->fileage;
|
openfile->current = openfile->fileage;
|
||||||
openfile->current_x = 0;
|
|
||||||
openfile->placewewant = 0;
|
openfile->placewewant = 0;
|
||||||
} else {
|
} else {
|
||||||
|
/* Scroll the edit window up a page. */
|
||||||
|
edit_scroll(UP, editwinrows - 2);
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* If we're in smooth scrolling mode and there's at least one
|
/* 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
|
* page of text left, move the current line of the edit window
|
||||||
* up a page, and then get the equivalent x-coordinate of the
|
* up a page. */
|
||||||
* current line. */
|
|
||||||
if (ISSET(SMOOTH_SCROLL) && openfile->current->lineno >
|
if (ISSET(SMOOTH_SCROLL) && openfile->current->lineno >
|
||||||
editwinrows - 2) {
|
editwinrows - 2) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (; i < editwinrows - 2; i++)
|
for (; i < editwinrows - 2; i++)
|
||||||
openfile->current = openfile->current->prev;
|
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
|
/* 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
|
* one page of text left, put the cursor at the beginning of the
|
||||||
|
@ -131,21 +133,27 @@ void do_page_up(void)
|
||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
openfile->current = openfile->edittop;
|
openfile->current = openfile->edittop;
|
||||||
openfile->current_x = 0;
|
|
||||||
openfile->placewewant = 0;
|
openfile->placewewant = 0;
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
}
|
}
|
||||||
#endif
|
#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();
|
check_statusblank();
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_page_down(void)
|
void do_page_down(void)
|
||||||
{
|
{
|
||||||
|
const filestruct *current_save = openfile->current;
|
||||||
|
size_t pww_save = openfile->placewewant;
|
||||||
|
|
||||||
#ifndef DISABLE_WRAPPING
|
#ifndef DISABLE_WRAPPING
|
||||||
wrap_reset();
|
wrap_reset();
|
||||||
#endif
|
#endif
|
||||||
|
@ -155,23 +163,21 @@ void do_page_down(void)
|
||||||
if (openfile->edittop->lineno + editwinrows >
|
if (openfile->edittop->lineno + editwinrows >
|
||||||
openfile->filebot->lineno) {
|
openfile->filebot->lineno) {
|
||||||
openfile->current = openfile->filebot;
|
openfile->current = openfile->filebot;
|
||||||
openfile->current_x = 0;
|
|
||||||
openfile->placewewant = 0;
|
openfile->placewewant = 0;
|
||||||
} else {
|
} else {
|
||||||
|
/* Scroll the edit window down a page. */
|
||||||
|
edit_scroll(DOWN, editwinrows - 2);
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* If we're in smooth scrolling mode and there's at least one
|
/* 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
|
* page of text left, move the current line of the edit window
|
||||||
* down a page, and then get the equivalent x-coordinate of the
|
* down a page. */
|
||||||
* current line. */
|
|
||||||
if (ISSET(SMOOTH_SCROLL) && openfile->current->lineno +
|
if (ISSET(SMOOTH_SCROLL) && openfile->current->lineno +
|
||||||
editwinrows - 2 <= openfile->filebot->lineno) {
|
editwinrows - 2 <= openfile->filebot->lineno) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (; i < editwinrows - 2; i++)
|
for (; i < editwinrows - 2; i++)
|
||||||
openfile->current = openfile->current->next;
|
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
|
/* 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
|
* one page of text left, put the cursor at the beginning of the
|
||||||
|
@ -179,16 +185,19 @@ void do_page_down(void)
|
||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
openfile->current = openfile->edittop;
|
openfile->current = openfile->edittop;
|
||||||
openfile->current_x = 0;
|
|
||||||
openfile->placewewant = 0;
|
openfile->placewewant = 0;
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
}
|
}
|
||||||
#endif
|
#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();
|
check_statusblank();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,15 +229,14 @@ void do_up(void)
|
||||||
ISSET(SMOOTH_SCROLL) ? 1 :
|
ISSET(SMOOTH_SCROLL) ? 1 :
|
||||||
#endif
|
#endif
|
||||||
editwinrows / 2);
|
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
|
/* Update the line we were on before and the line we're on now. The
|
||||||
* page, and the latter needs to be redrawn unconditionally. */
|
* former needs to be redrawn if we're not on the first page, and
|
||||||
else {
|
* the latter needs to be drawn unconditionally. */
|
||||||
if (need_vertical_update(0))
|
if (need_vertical_update(0))
|
||||||
update_line(openfile->current->next, 0);
|
update_line(openfile->current->next, 0);
|
||||||
update_line(openfile->current, openfile->current_x);
|
update_line(openfile->current, openfile->current_x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void do_down(void)
|
void do_down(void)
|
||||||
{
|
{
|
||||||
|
@ -258,15 +266,14 @@ void do_down(void)
|
||||||
ISSET(SMOOTH_SCROLL) ? 1 :
|
ISSET(SMOOTH_SCROLL) ? 1 :
|
||||||
#endif
|
#endif
|
||||||
editwinrows / 2);
|
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
|
/* Update the line we were on before and the line we're on now. The
|
||||||
* page, and the latter needs to be redrawn unconditionally. */
|
* former needs to be redrawn if we're not on the first page, and
|
||||||
else {
|
* the latter needs to be drawn unconditionally. */
|
||||||
if (need_vertical_update(0))
|
if (need_vertical_update(0))
|
||||||
update_line(openfile->current->prev, 0);
|
update_line(openfile->current->prev, 0);
|
||||||
update_line(openfile->current, openfile->current_x);
|
update_line(openfile->current, openfile->current_x);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void do_left(bool allow_update)
|
void do_left(bool allow_update)
|
||||||
{
|
{
|
||||||
|
|
17
src/winio.c
17
src/winio.c
|
@ -3503,8 +3503,11 @@ int need_vertical_update(size_t old_pww)
|
||||||
/* Scroll the edit window in the given direction and the given number
|
/* 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
|
* of lines, and draw new lines on the blank lines left after the
|
||||||
* scrolling. direction is the direction to scroll, either UP or DOWN,
|
* 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 nlines is the number of lines to scroll.
|
||||||
* and current_x are up to date, and only change edittop. */
|
*
|
||||||
|
* 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)
|
void edit_scroll(updown direction, int nlines)
|
||||||
{
|
{
|
||||||
filestruct *foo;
|
filestruct *foo;
|
||||||
|
@ -3543,19 +3546,15 @@ void edit_scroll(updown direction, int nlines)
|
||||||
foo = openfile->edittop;
|
foo = openfile->edittop;
|
||||||
|
|
||||||
if (direction == DOWN) {
|
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;
|
foo = foo->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw new lines on the blank top or bottom lines of the edit
|
/* Draw new lines on the blank top or bottom lines of the edit
|
||||||
* window, depending on the value of direction. */
|
* window, depending on the value of direction. */
|
||||||
scroll_rows++;
|
for (; scroll_rows > 0 && foo != NULL; scroll_rows--) {
|
||||||
|
update_line(foo, 0);
|
||||||
while (scroll_rows > 0 && foo != NULL) {
|
|
||||||
update_line(foo, (foo == openfile->current) ?
|
|
||||||
openfile->current_x : 0);
|
|
||||||
foo = foo->next;
|
foo = foo->next;
|
||||||
scroll_rows--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue