tweaks: rename a variable, to better indicate what it represents

And also to get away from the abundance of the word "current".
This commit is contained in:
Benno Schulenberg 2024-03-30 11:35:41 +01:00
parent 8610857015
commit 25d07b422d
7 changed files with 28 additions and 29 deletions

View File

@ -561,8 +561,8 @@ typedef struct openfilestruct {
/* The file's x-coordinate position. */
size_t placewewant;
/* The file's x position we would like. */
ssize_t current_y;
/* The file's y-coordinate position. */
ssize_t cursor_row;
/* The row in the edit window that the cursor is on. */
struct stat *statinfo;
/* The file's stat information from when it was opened or last saved. */
#ifdef ENABLE_WRAPPING

View File

@ -73,7 +73,7 @@ void make_new_buffer(void)
openfile->current = openfile->filetop;
openfile->current_x = 0;
openfile->placewewant = 0;
openfile->current_y = 0;
openfile->cursor_row = 0;
openfile->edittop = openfile->filetop;
openfile->firstcolumn = 0;

View File

@ -41,7 +41,7 @@ void to_last_line(void)
openfile->placewewant = xplustabs();
/* Set the last line of the screen as the target for the cursor. */
openfile->current_y = editwinrows - 1;
openfile->cursor_row = editwinrows - 1;
refresh_needed = TRUE;
#ifdef ENABLE_COLOR
@ -124,7 +124,7 @@ void do_page_up(void)
if (ISSET(JUMPY_SCROLLING)) {
openfile->current = openfile->edittop;
leftedge = openfile->firstcolumn;
openfile->current_y = 0;
openfile->cursor_row = 0;
target_column = 0;
} else
#endif
@ -156,7 +156,7 @@ void do_page_down(void)
if (ISSET(JUMPY_SCROLLING)) {
openfile->current = openfile->edittop;
leftedge = openfile->firstcolumn;
openfile->current_y = 0;
openfile->cursor_row = 0;
target_column = 0;
} else
#endif
@ -559,7 +559,7 @@ void do_up(void)
set_proper_index_and_pww(&leftedge, target_column, FALSE);
if (openfile->current_y == 0 && !ISSET(JUMPY_SCROLLING))
if (openfile->cursor_row == 0 && !ISSET(JUMPY_SCROLLING))
edit_scroll(BACKWARD);
else
edit_redraw(was_current, FLOWING);
@ -582,7 +582,7 @@ void do_down(void)
set_proper_index_and_pww(&leftedge, target_column, TRUE);
if (openfile->current_y == editwinrows - 1 && !ISSET(JUMPY_SCROLLING))
if (openfile->cursor_row == editwinrows - 1 && !ISSET(JUMPY_SCROLLING))
edit_scroll(FORWARD);
else
edit_redraw(was_current, FLOWING);
@ -599,7 +599,7 @@ void do_scroll_up(void)
if (openfile->edittop->prev == NULL && openfile->firstcolumn == 0)
return;
if (openfile->current_y == editwinrows - 1)
if (openfile->cursor_row == editwinrows - 1)
do_up();
if (editwinrows > 1)
@ -609,7 +609,7 @@ void do_scroll_up(void)
/* Scroll down one line or chunk without moving the cursor textwise. */
void do_scroll_down(void)
{
if (openfile->current_y == 0)
if (openfile->cursor_row == 0)
do_down();
if (editwinrows > 1 && (openfile->edittop->next != NULL

View File

@ -1335,12 +1335,11 @@ int do_mouse(void)
/* If the click was in the edit window, put the cursor in that spot. */
if (wmouse_trafo(midwin, &click_row, &click_col, FALSE)) {
linestruct *current_save = openfile->current;
ssize_t row_count = click_row - openfile->current_y;
ssize_t row_count = click_row - openfile->cursor_row;
size_t leftedge;
#ifndef NANO_TINY
size_t current_x_save = openfile->current_x;
bool sameline = (click_row == openfile->current_y);
/* Whether the click was on the row where the cursor is. */
bool sameline = (click_row == openfile->cursor_row);
if (ISSET(SOFTWRAP))
leftedge = leftedge_for(xplustabs(), openfile->current);
@ -1468,7 +1467,7 @@ void inject(char *burst, size_t count)
size_t old_amount = 0;
if (ISSET(SOFTWRAP)) {
if (openfile->current_y == editwinrows - 1)
if (openfile->cursor_row == editwinrows - 1)
original_row = chunk_for(xplustabs(), thisline);
old_amount = extra_chunks_in(thisline);
}
@ -1522,7 +1521,7 @@ void inject(char *burst, size_t count)
#else
if (margin)
#endif
if (openfile->current_y < editwinrows - 1)
if (openfile->cursor_row < editwinrows - 1)
update_line(thisline->next, 0);
}
@ -1542,7 +1541,7 @@ void inject(char *burst, size_t count)
* or we were on the last row of the edit window and moved to a new chunk,
* we need a full refresh. */
if (ISSET(SOFTWRAP) && (extra_chunks_in(openfile->current) != old_amount ||
(openfile->current_y == editwinrows - 1 &&
(openfile->cursor_row == editwinrows - 1 &&
chunk_for(openfile->placewewant, openfile->current) > original_row))) {
refresh_needed = TRUE;
focusing = FALSE;
@ -2642,7 +2641,7 @@ int main(int argc, char **argv)
/* In barless mode, either redraw a relevant status message,
* or overwrite a minor, redundant one. */
if (ISSET(ZERO) && lastmessage > HUSH) {
if (openfile->current_y == editwinrows - 1 && LINES > 1) {
if (openfile->cursor_row == editwinrows - 1 && LINES > 1) {
edit_scroll(FORWARD);
wnoutrefresh(midwin);
}

View File

@ -861,7 +861,7 @@ void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer,
* line or chunk on the bottom line of the screen; otherwise, just
* center the target line. */
if (rows_from_tail < editwinrows / 2 && !ISSET(JUMPY_SCROLLING)) {
openfile->current_y = editwinrows - 1 - rows_from_tail;
openfile->cursor_row = editwinrows - 1 - rows_from_tail;
adjust_viewport(STATIONARY);
} else
adjust_viewport(CENTERING);

View File

@ -618,12 +618,12 @@ void do_undo(void)
case COUPLE_BEGIN:
undidmsg = u->strdata;
goto_line_posx(u->head_lineno, u->head_x);
openfile->current_y = u->tail_lineno;
openfile->cursor_row = u->tail_lineno;
adjust_viewport(STATIONARY);
break;
case COUPLE_END:
/* Remember the row of the cursor for a possible redo. */
openfile->current_undo->head_lineno = openfile->current_y;
openfile->current_undo->head_lineno = openfile->cursor_row;
openfile->current_undo = openfile->current_undo->next;
do_undo();
do_undo();
@ -796,7 +796,7 @@ void do_redo(void)
case COUPLE_END:
redidmsg = u->strdata;
goto_line_posx(u->tail_lineno, u->tail_x);
openfile->current_y = u->head_lineno;
openfile->cursor_row = u->head_lineno;
adjust_viewport(STATIONARY);
break;
case INDENT:
@ -1075,7 +1075,7 @@ void add_undo(undo_type action, const char *message)
u->xflags |= INCLUDED_LAST_LINE;
break;
case COUPLE_BEGIN:
u->tail_lineno = openfile->current_y;
u->tail_lineno = openfile->cursor_row;
/* Fall-through. */
case COUPLE_END:
u->strdata = copy_of(_(message));
@ -3025,7 +3025,7 @@ void do_verbatim_input(void)
#ifndef NANO_TINY
/* When barless and with cursor on bottom row, make room for the feedback. */
if (ISSET(ZERO) && openfile->current_y == editwinrows - 1 && LINES > 1) {
if (ISSET(ZERO) && openfile->cursor_row == editwinrows - 1 && LINES > 1) {
edit_scroll(FORWARD);
edit_refresh();
}

View File

@ -2503,8 +2503,8 @@ void bottombars(int menu)
wrefresh(footwin);
}
/* Redetermine current_y from the position of current relative to edittop,
* and put the cursor in the edit window at (current_y, "current_x"). */
/* Redetermine `cursor_row` from the position of current relative to edittop,
* and put the cursor in the edit window at (cursor_row, "current_x"). */
void place_the_cursor(void)
{
ssize_t row = 0;
@ -2544,7 +2544,7 @@ void place_the_cursor(void)
wnoutrefresh(midwin); /* Only needed for NetBSD curses. */
#endif
openfile->current_y = row;
openfile->cursor_row = row;
}
/* The number of bytes after which to stop painting, to avoid major slowdowns. */
@ -3461,7 +3461,7 @@ void adjust_viewport(update_type manner)
int goal = 0;
if (manner == STATIONARY)
goal = openfile->current_y;
goal = openfile->cursor_row;
else if (manner == CENTERING)
goal = editwinrows / 2;
else if (!current_is_above_screen())
@ -3554,7 +3554,7 @@ void spotlight(size_t from_col, size_t to_col)
wattron(midwin, interface_color_pair[SPOTLIGHTED]);
waddnstr(midwin, word, actual_x(word, to_col));
if (overshoots)
mvwaddch(midwin, openfile->current_y, COLS - 1 - sidebar, '>');
mvwaddch(midwin, openfile->cursor_row, COLS - 1 - sidebar, '>');
wattroff(midwin, interface_color_pair[SPOTLIGHTED]);
free(word);
@ -3572,7 +3572,7 @@ void spotlight_softwrapped(size_t from_col, size_t to_col)
char *word;
place_the_cursor();
row = openfile->current_y;
row = openfile->cursor_row;
while (row < editwinrows) {
break_col = get_softwrap_breakpoint(openfile->current->data,