tweaks: elide a parameter that is always 1
And adjust the comments accordingly.
Этот коммит содержится в:
родитель
1fb3218a14
Коммит
1ebb1da382
@ -502,7 +502,7 @@ void do_up(bool scroll_only)
|
|||||||
set_proper_index_and_pww(&leftedge, target_column, FALSE);
|
set_proper_index_and_pww(&leftedge, target_column, FALSE);
|
||||||
|
|
||||||
if (scroll_only)
|
if (scroll_only)
|
||||||
edit_scroll(BACKWARD, 1);
|
edit_scroll(BACKWARD);
|
||||||
|
|
||||||
edit_redraw(was_current, FLOWING);
|
edit_redraw(was_current, FLOWING);
|
||||||
|
|
||||||
@ -526,7 +526,7 @@ void do_down(bool scroll_only)
|
|||||||
set_proper_index_and_pww(&leftedge, target_column, TRUE);
|
set_proper_index_and_pww(&leftedge, target_column, TRUE);
|
||||||
|
|
||||||
if (scroll_only)
|
if (scroll_only)
|
||||||
edit_scroll(FORWARD, 1);
|
edit_scroll(FORWARD);
|
||||||
|
|
||||||
edit_redraw(was_current, FLOWING);
|
edit_redraw(was_current, FLOWING);
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ bool line_needs_update(const size_t old_column, const size_t new_column);
|
|||||||
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
|
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
|
||||||
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
|
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
|
||||||
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
|
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
|
||||||
void edit_scroll(bool direction, int nrows);
|
void edit_scroll(bool direction);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
|
size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
|
||||||
bool *end_of_line);
|
bool *end_of_line);
|
||||||
|
45
src/winio.c
45
src/winio.c
@ -2912,57 +2912,42 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
|
|||||||
return (openfile->current->lineno - was_lineno < editwinrows);
|
return (openfile->current->lineno - was_lineno < editwinrows);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scroll the edit window in the given direction and the given number of rows,
|
/* Scroll the edit window one row in the given direction, and
|
||||||
* and draw new lines on the blank lines left after the scrolling. */
|
* draw the relevant content on the resultant blank row. */
|
||||||
void edit_scroll(bool direction, int nrows)
|
void edit_scroll(bool direction)
|
||||||
{
|
{
|
||||||
filestruct *line;
|
filestruct *line;
|
||||||
size_t leftedge;
|
size_t leftedge;
|
||||||
|
int remainder = 0, nrows = 1;
|
||||||
|
|
||||||
/* Part 1: nrows is the number of rows we're going to scroll the text of
|
/* Move the top line of the edit window one row up or down. */
|
||||||
* the edit window. */
|
|
||||||
|
|
||||||
/* Move the top line of the edit window the requested number of rows up or
|
|
||||||
* down, and reduce the number of rows with the amount we couldn't move. */
|
|
||||||
if (direction == BACKWARD)
|
if (direction == BACKWARD)
|
||||||
nrows -= go_back_chunks(nrows, &openfile->edittop, &openfile->firstcolumn);
|
remainder = go_back_chunks(1, &openfile->edittop, &openfile->firstcolumn);
|
||||||
else
|
else
|
||||||
nrows -= go_forward_chunks(nrows, &openfile->edittop, &openfile->firstcolumn);
|
remainder = go_forward_chunks(1, &openfile->edittop, &openfile->firstcolumn);
|
||||||
|
|
||||||
/* Don't bother scrolling zero rows, nor more than the window can hold. */
|
if (remainder > 0) {
|
||||||
if (nrows == 0) {
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
statusline(ALERT, "Underscrolling -- please report a bug");
|
statusline(ALERT, "Could not scroll -- please report a bug");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (nrows >= editwinrows) {
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
if (editwinrows > 1)
|
|
||||||
statusline(ALERT, "Overscrolling -- please report a bug");
|
|
||||||
#endif
|
|
||||||
refresh_needed = TRUE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scroll the text of the edit window a number of rows up or down. */
|
/* Actually scroll the text of the edit window one row up or down. */
|
||||||
scrollok(edit, TRUE);
|
scrollok(edit, TRUE);
|
||||||
wscrl(edit, (direction == BACKWARD) ? -nrows : nrows);
|
wscrl(edit, (direction == BACKWARD) ? -1 : 1);
|
||||||
scrollok(edit, FALSE);
|
scrollok(edit, FALSE);
|
||||||
|
|
||||||
/* Part 2: nrows is now the number of rows in the scrolled region of the
|
|
||||||
* edit window that we need to draw. */
|
|
||||||
|
|
||||||
/* If we're not on the first "page" (when not softwrapping), or the mark
|
/* If we're not on the first "page" (when not softwrapping), or the mark
|
||||||
* is on, the row next to the scrolled region needs to be redrawn too. */
|
* is on, the row next to the scrolled region needs to be redrawn too. */
|
||||||
if (line_needs_update(openfile->placewewant, 0) && nrows < editwinrows)
|
if (line_needs_update(openfile->placewewant, 0) && nrows < editwinrows)
|
||||||
nrows++;
|
nrows++;
|
||||||
|
|
||||||
/* If we scrolled backward, start on the first line of the blank region. */
|
/* If we scrolled backward, the top row needs to be redrawn. */
|
||||||
line = openfile->edittop;
|
line = openfile->edittop;
|
||||||
leftedge = openfile->firstcolumn;
|
leftedge = openfile->firstcolumn;
|
||||||
|
|
||||||
/* If we scrolled forward, move down to the start of the blank region. */
|
/* If we scrolled forward, the bottom row needs to be redrawn. */
|
||||||
if (direction == FORWARD)
|
if (direction == FORWARD)
|
||||||
go_forward_chunks(editwinrows - nrows, &line, &leftedge);
|
go_forward_chunks(editwinrows - nrows, &line, &leftedge);
|
||||||
|
|
||||||
@ -2977,8 +2962,8 @@ void edit_scroll(bool direction, int nrows)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Draw new content on the blank rows inside the scrolled region
|
/* Draw new content on the blank row (and on the bordering row too
|
||||||
* (and on the bordering row too when it was deemed necessary). */
|
* when it was deemed necessary). */
|
||||||
while (nrows > 0 && line != NULL) {
|
while (nrows > 0 && line != NULL) {
|
||||||
nrows -= update_line(line, (line == openfile->current) ?
|
nrows -= update_line(line, (line == openfile->current) ?
|
||||||
openfile->current_x : 0);
|
openfile->current_x : 0);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user