tweaks: reshuffle some statements, to avoid double assignments

master
Benno Schulenberg 2017-03-27 11:38:52 +02:00
parent 384332d08c
commit c277cd6e5b
1 changed files with 14 additions and 18 deletions

View File

@ -52,26 +52,24 @@ void do_last_line(void)
/* Move up one page. */ /* Move up one page. */
void do_page_up(void) void do_page_up(void)
{ {
int mustmove; int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge = 0; size_t leftedge = 0, target_column;
size_t target_column = openfile->placewewant;
/* If we're not in smooth scrolling mode, put the cursor at the /* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */ * beginning of the top line of the edit window, as Pico does. */
if (!ISSET(SMOOTH_SCROLL)) { if (!ISSET(SMOOTH_SCROLL)) {
openfile->current = openfile->edittop; openfile->current = openfile->edittop;
openfile->placewewant = target_column = openfile->firstcolumn; openfile->placewewant = openfile->firstcolumn;
openfile->current_y = 0; openfile->current_y = 0;
} }
mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
#ifndef NANO_TINY #ifndef NANO_TINY
if (ISSET(SOFTWRAP)) { if (ISSET(SOFTWRAP)) {
leftedge = (openfile->placewewant / editwincols) * editwincols; leftedge = (openfile->placewewant / editwincols) * editwincols;
target_column = openfile->placewewant % editwincols; target_column = openfile->placewewant % editwincols;
} } else
#endif #endif
target_column = openfile->placewewant;
/* Move up the required number of lines or chunks. If we can't, we're /* Move up the required number of lines or chunks. If we can't, we're
* at the top of the file, so put the cursor there and get out. */ * at the top of the file, so put the cursor there and get out. */
@ -80,9 +78,9 @@ void do_page_up(void)
return; return;
} }
openfile->current_x = actual_x(openfile->current->data,
leftedge + target_column);
openfile->placewewant = leftedge + target_column; openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* Scroll the edit window up a page. */ /* Scroll the edit window up a page. */
adjust_viewport(STATIONARY); adjust_viewport(STATIONARY);
@ -92,26 +90,24 @@ void do_page_up(void)
/* Move down one page. */ /* Move down one page. */
void do_page_down(void) void do_page_down(void)
{ {
int mustmove; int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge = 0; size_t leftedge = 0, target_column;
size_t target_column = openfile->placewewant;
/* If we're not in smooth scrolling mode, put the cursor at the /* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */ * beginning of the top line of the edit window, as Pico does. */
if (!ISSET(SMOOTH_SCROLL)) { if (!ISSET(SMOOTH_SCROLL)) {
openfile->current = openfile->edittop; openfile->current = openfile->edittop;
openfile->placewewant = target_column = openfile->firstcolumn; openfile->placewewant = openfile->firstcolumn;
openfile->current_y = 0; openfile->current_y = 0;
} }
mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
#ifndef NANO_TINY #ifndef NANO_TINY
if (ISSET(SOFTWRAP)) { if (ISSET(SOFTWRAP)) {
leftedge = (openfile->placewewant / editwincols) * editwincols; leftedge = (openfile->placewewant / editwincols) * editwincols;
target_column = openfile->placewewant % editwincols; target_column = openfile->placewewant % editwincols;
} } else
#endif #endif
target_column = openfile->placewewant;
/* Move down the required number of lines or chunks. If we can't, we're /* Move down the required number of lines or chunks. If we can't, we're
* at the bottom of the file, so put the cursor there and get out. */ * at the bottom of the file, so put the cursor there and get out. */
@ -120,9 +116,9 @@ void do_page_down(void)
return; return;
} }
openfile->current_x = actual_x(openfile->current->data,
leftedge + target_column);
openfile->placewewant = leftedge + target_column; openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* Scroll the edit window down a page. */ /* Scroll the edit window down a page. */
adjust_viewport(STATIONARY); adjust_viewport(STATIONARY);