allow scrolling more than editwinrows lines via edit_scroll(), take 2
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2912 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
47bb888ad2
commit
c009759c23
18
ChangeLog
18
ChangeLog
|
@ -36,15 +36,15 @@ CVS code -
|
||||||
- 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)
|
||||||
- Make edit_scroll() sophisticated enough to keep track of
|
- Make edit_scroll() sophisticated enough to keep track of
|
||||||
current and current_x and update the lines before and after
|
current and current_x, update the lines before and after the
|
||||||
the scrolled region, and change the movement functions that
|
scrolled region, and properly scroll more than editwinrows
|
||||||
use edit_scroll() to (a) set current and current_x before
|
lines; and change the movement functions that use
|
||||||
calling it, and (b) no longer call edit_redraw() afterward,
|
edit_scroll() to (a) set current and current_x before calling
|
||||||
since it's now unnecessary. These changes eliminate
|
it, and (b) no longer call edit_redraw() afterward, as it's
|
||||||
redundant screen updates when the mark is on, since the mark
|
now unnecessary. These changes eliminate redundant screen
|
||||||
display depends on current and current_x. Changes to
|
updates when the mark is on, since the mark display depends on
|
||||||
edit_scroll(), do_page_up(), do_page_down(), do_up(), and
|
current and current_x. Changes to edit_scroll(),
|
||||||
do_down(). (DLR)
|
do_page_up(), do_page_down(), do_up(), and do_down(). (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
|
||||||
|
|
30
src/winio.c
30
src/winio.c
|
@ -3496,11 +3496,13 @@ void edit_scroll(updown direction, int nlines)
|
||||||
const filestruct *foo;
|
const filestruct *foo;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Scrolling less than one line or more than editwinrows lines is
|
/* Don't bother scrolling less than one line. */
|
||||||
* redundant, so don't allow it. */
|
if (nlines < 1)
|
||||||
if (nlines < 1 || nlines > editwinrows)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* Part 1: nlines is the number of lines we're going to scroll the
|
||||||
|
* text of the edit window. */
|
||||||
|
|
||||||
/* Move the top line of the edit window up or down (depending on the
|
/* Move the top line of the edit window up or down (depending on the
|
||||||
* value of direction) nlines lines, or as many lines as we can if
|
* value of direction) nlines lines, or as many lines as we can if
|
||||||
* there are fewer than nlines lines available. */
|
* there are fewer than nlines lines available. */
|
||||||
|
@ -3516,22 +3518,28 @@ void edit_scroll(updown direction, int nlines)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scroll the text on the screen up or down nlines lines, depending
|
/* Limit nlines to the number of lines in the edit window. */
|
||||||
* on the value of direction. */
|
if (nlines > editwinrows)
|
||||||
|
nlines = editwinrows;
|
||||||
|
|
||||||
|
/* Scroll the text of the edit window up or down nlines lines,
|
||||||
|
* depending on the value of direction. */
|
||||||
scrollok(edit, TRUE);
|
scrollok(edit, TRUE);
|
||||||
wscrl(edit, (direction == UP) ? -nlines : nlines);
|
wscrl(edit, (direction == UP) ? -nlines : nlines);
|
||||||
scrollok(edit, FALSE);
|
scrollok(edit, FALSE);
|
||||||
|
|
||||||
|
/* Part 2: nlines is the number of lines in the scrolled region of
|
||||||
|
* the edit window that we need to draw. */
|
||||||
|
|
||||||
/* If we scrolled up, we couldn't scroll up all nlines lines, and
|
/* If we scrolled up, we couldn't scroll up all nlines lines, and
|
||||||
* we're now at the top of the file, we need to treat the entire
|
* we're now at the top of the file, we need to draw the entire edit
|
||||||
* screen as the scrolled region, instead of just the top nlines
|
* window instead of just its top nlines lines. */
|
||||||
* lines. */
|
|
||||||
if (direction == UP && i > 0 && openfile->edittop ==
|
if (direction == UP && i > 0 && openfile->edittop ==
|
||||||
openfile->fileage)
|
openfile->fileage)
|
||||||
nlines = editwinrows;
|
nlines = editwinrows - 2;
|
||||||
|
|
||||||
/* Make nlines account for the lines before and after the scrolled
|
/* If the lines before and after the scrolled region are visible in
|
||||||
* region, if they're onsccreen. */
|
* the edit window, we need to draw them too. */
|
||||||
nlines += 2;
|
nlines += 2;
|
||||||
if (nlines > editwinrows)
|
if (nlines > editwinrows)
|
||||||
nlines = editwinrows;
|
nlines = editwinrows;
|
||||||
|
|
Loading…
Reference in New Issue