display: add extra variable, to avoid one-way toggling of SOLO_SIDESCROLL

Panning should not be switched off for the whole session
when the window became too narrow at some point.
This commit is contained in:
Benno Schulenberg 2026-01-17 12:34:04 +01:00
parent f6297f0933
commit 38f87fb5c3
7 changed files with 19 additions and 12 deletions

View File

@ -54,7 +54,7 @@ void expunge(undo_type action)
if (ISSET(SOFTWRAP) && extra_chunks_in(openfile->current) != old_amount)
refresh_needed = TRUE;
/* When panning, and we have come near edge of the viewport... */
else if (!ISSET(SOLO_SIDESCROLL) && openfile->placewewant < brink + CUSHION)
else if (united_sidescroll && openfile->placewewant < brink + CUSHION)
refresh_needed = TRUE;
/* Adjust the mark if it is after the cursor on the current line. */

View File

@ -73,6 +73,8 @@ char *title = NULL;
bool refresh_needed = FALSE;
/* Did a command mangle enough of the buffer that we should
* repaint the screen? */
bool united_sidescroll = TRUE;
/* Whether to scroll all lines sideways. That is: whether to pan. */
size_t brink = 0;
/* From which column the edit window is drawn (when panning). */
bool focusing = TRUE;

View File

@ -1553,7 +1553,7 @@ void inject(char *burst, size_t count)
openfile->placewewant = xplustabs();
/* When panning, and we have come near the edge of the viewport... */
if (!ISSET(SOLO_SIDESCROLL) && openfile->placewewant > brink + editwincols - CUSHION - 1 )
if (united_sidescroll && openfile->placewewant > brink + editwincols - CUSHION - 1 )
refresh_needed = TRUE;
#ifndef NANO_TINY
@ -2687,9 +2687,13 @@ int main(int argc, char **argv)
if (currmenu != MMAIN)
bottombars(MMAIN);
/* Fall back to single-line sidescrolling when the window is narrow. */
if (editwincols < 2 * CUSHION + 2)
SET(SOLO_SIDESCROLL);
/* Do sideways scrolling only when the user didn't switch it off,
* when not softwrapping, and the window is wide enough. */
if (united_sidescroll != (!ISSET(SOLO_SIDESCROLL) && !ISSET(SOFTWRAP) &&
editwincols > 2 * CUSHION + 2)) {
united_sidescroll = !united_sidescroll;
refresh_needed = TRUE;
}
#ifndef NANO_TINY
if (ISSET(MINIBAR) && !ISSET(ZERO) && LINES > 1 && lastmessage < REMARK)

View File

@ -47,6 +47,7 @@ extern int final_status;
extern bool inhelp;
extern char *title;
extern bool united_sidescroll;
extern size_t brink;
extern bool focusing;

View File

@ -334,7 +334,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
light_to_col = wideness(line->data, found_x + found_len);
/* When panning, ensure the end of the match will be visible too. */
if (!ISSET(SOLO_SIDESCROLL) && !ISSET(SOFTWRAP))
if (united_sidescroll)
brink = get_page_start(light_to_col);
refresh_needed = TRUE;
@ -596,7 +596,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
light_to_col = wideness(openfile->current->data,
openfile->current_x + match_len);
if (!ISSET(SOLO_SIDESCROLL) && !ISSET(SOFTWRAP))
if (united_sidescroll)
brink = get_page_start(light_to_col);
/* Refresh the edit window, scrolling it if necessary. */

View File

@ -343,7 +343,7 @@ char *free_and_assign(char *dest, char *src)
* displayed in the edit window when the cursor is at the given column. */
size_t get_page_start(size_t column)
{
if (!ISSET(SOLO_SIDESCROLL) && !ISSET(SOFTWRAP)) {
if (united_sidescroll) {
if (column < CUSHION)
return 0;
else if (column < brink + CUSHION)

View File

@ -2838,7 +2838,7 @@ int update_line(linestruct *line, size_t index)
#endif
row = line->lineno - openfile->edittop->lineno;
if (!ISSET(SOLO_SIDESCROLL))
if (united_sidescroll)
from_col = brink;
else
from_col = get_page_start(wideness(line->data, index));
@ -2937,7 +2937,7 @@ bool line_needs_update(const size_t old_column, const size_t new_column)
#endif
if (get_page_start(old_column) == get_page_start(new_column))
return FALSE;
if (!ISSET(SOLO_SIDESCROLL) && !ISSET(SOFTWRAP))
if (united_sidescroll)
refresh_needed = TRUE;
return !refresh_needed;
@ -3349,7 +3349,7 @@ void edit_redraw(linestruct *old_current, update_type manner)
adjust_viewport(ISSET(JUMPY_SCROLLING) ? CENTERING : manner);
refresh_needed = TRUE;
return;
} else if (!ISSET(SOLO_SIDESCROLL) && !ISSET(SOFTWRAP)) {
} else if (united_sidescroll) {
refresh_needed = TRUE;
return;
}
@ -3392,7 +3392,7 @@ void edit_refresh(void)
adjust_viewport((focusing || ISSET(JUMPY_SCROLLING)) ? CENTERING : FLOWING);
/* When panning, ensure the cursor will be within the viewport. */
if (!ISSET(SOLO_SIDESCROLL) && !ISSET(SOFTWRAP))
if (united_sidescroll)
brink = get_page_start(xplustabs());
#ifdef ENABLE_COLOR