tweaks: frob a couple of comments

master
Benno Schulenberg 2017-03-28 19:44:41 +02:00
parent 8091d0a574
commit 54e4505b2f
1 changed files with 7 additions and 8 deletions

View File

@ -2779,6 +2779,7 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
if (ISSET(SOFTWRAP)) { if (ISSET(SOFTWRAP)) {
size_t current_chunk = (*leftedge) / editwincols; size_t current_chunk = (*leftedge) / editwincols;
/* Recede through the requested number of chunks. */
for (i = nrows; i > 0; i--) { for (i = nrows; i > 0; i--) {
if (current_chunk > 0) { if (current_chunk > 0) {
current_chunk--; current_chunk--;
@ -2820,6 +2821,7 @@ int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge)
size_t current_chunk = (*leftedge) / editwincols; size_t current_chunk = (*leftedge) / editwincols;
size_t last_chunk = strlenpt((*line)->data) / editwincols; size_t last_chunk = strlenpt((*line)->data) / editwincols;
/* Advance through the requested number of chunks. */
for (i = nrows; i > 0; i--) { for (i = nrows; i > 0; i--) {
if (current_chunk < last_chunk) { if (current_chunk < last_chunk) {
current_chunk++; current_chunk++;
@ -2864,8 +2866,7 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
} }
/* Scroll the edit window in the given direction and the given number of rows, /* Scroll the edit window in the given direction and the given number of rows,
* and draw new lines on the blank lines left after the scrolling. We change * and draw new lines on the blank lines left after the scrolling. */
* edittop, and assume that current and current_x are up to date. */
void edit_scroll(scroll_dir direction, int nrows) void edit_scroll(scroll_dir direction, int nrows)
{ {
int i; int i;
@ -2875,15 +2876,13 @@ void edit_scroll(scroll_dir direction, int nrows)
/* Part 1: nrows is the number of rows we're going to scroll the text of /* Part 1: nrows is the number of rows we're going to scroll the text of
* the edit window. */ * the edit window. */
/* Move the top line of the edit window up or down (depending on the value /* Move the top line of the edit window the requested number of rows. */
* of direction) nrows rows, or as many rows as we can if there are fewer
* than nrows rows available. */
if (direction == UPWARD) if (direction == UPWARD)
i = go_back_chunks(nrows, &openfile->edittop, &openfile->firstcolumn); i = go_back_chunks(nrows, &openfile->edittop, &openfile->firstcolumn);
else else
i = go_forward_chunks(nrows, &openfile->edittop, &openfile->firstcolumn); i = go_forward_chunks(nrows, &openfile->edittop, &openfile->firstcolumn);
/* Limit nrows to the number of rows we could scroll. */ /* If necessary, reduce the number of rows to what we could scroll. */
nrows -= i; nrows -= i;
/* Don't bother scrolling zero rows, nor more than the window can hold. */ /* Don't bother scrolling zero rows, nor more than the window can hold. */
@ -2907,11 +2906,11 @@ void edit_scroll(scroll_dir direction, int nrows)
if (line_needs_update(openfile->placewewant, 0) && nrows < editwinrows) if (line_needs_update(openfile->placewewant, 0) && nrows < editwinrows)
nrows++; nrows++;
/* If we scrolled up, we're on the line before the scrolled region. */ /* If we scrolled backward, start on the first line of the blank region. */
line = openfile->edittop; line = openfile->edittop;
leftedge = openfile->firstcolumn; leftedge = openfile->firstcolumn;
/* If we scrolled down, move down to the line before the scrolled region. */ /* If we scrolled forward, move down to the start of the blank region. */
if (direction == DOWNWARD) if (direction == DOWNWARD)
go_forward_chunks(editwinrows - nrows, &line, &leftedge); go_forward_chunks(editwinrows - nrows, &line, &leftedge);