Add an optional build-time switch to disable scrollback support

This change introduces a new `scrollback` Meson build option (enabled
by default) that lets foot be compiled without scrollback history.
When the option is off, `FOOT_HAVE_SCROLLBACK` is left
undefined and the relevant code is excluded from the build,
producing a slimmer terminal for use cases that do not need it.

With scrollback disabled:

- The `[scrollback]` section in `foot.ini` and its key bindings
  become no-ops.
- In-terminal search is removed,
  along with the "pipe scrollback" action, the scrollback indicator,
  and their colors/overlays.
- IME hooks for the search box, mouse-wheel scrollback handling,
  and related `terminal` state are compiled out.
- Selection auto-scroll (the timer that scrolls the viewport while
  a drag-selection extends past the visible area) is removed,
  since with no scrollback there is nowhere to scroll to.
  The associated function declarations,
  `enum selection_scroll_direction`,
  the `auto_scroll` field on `terminal::selection`,
  and their init/teardown sites are all excluded from the build.

To keep action enumerations stable across build configurations,
two range markers (`BIND_ACTION_PIPE_FIRST` / `BIND_ACTION_PIPE_LAST`)
are introduced so that pipe-action handling does not depend on
`PIPE_SCROLLBACK` being present. The build summary and
`foot --version` now report `+scrollback` or `-scrollback`,
and the config tests have been updated to account for optional section.
This commit is contained in:
Campbell Barton 2026-05-15 15:51:01 +10:00
parent f35e60577f
commit d28ac267d2
25 changed files with 317 additions and 22 deletions

View file

@ -1549,7 +1549,9 @@ selection_finalize(struct seat *seat, struct terminal *term, uint32_t serial)
LOG_DBG("selection finalize");
#if defined(FOOT_HAVE_SCROLLBACK)
selection_stop_scroll_timer(term);
#endif
term->selection.ongoing = false;
if (term->selection.coords.start.row < 0 || term->selection.coords.end.row < 0)
@ -1599,7 +1601,9 @@ selection_cancel(struct terminal *term)
term->selection.coords.start.row, term->selection.coords.start.col,
term->selection.coords.end.row, term->selection.coords.end.col);
#if defined(FOOT_HAVE_SCROLLBACK)
selection_stop_scroll_timer(term);
#endif
if (term->selection.coords.start.row >= 0 && term->selection.coords.end.row >= 0) {
foreach_selected(
@ -1616,7 +1620,9 @@ selection_cancel(struct terminal *term)
term->selection.direction = SELECTION_UNDIR;
term->selection.ongoing = false;
#if defined(FOOT_HAVE_SCROLLBACK)
search_selection_cancelled(term);
#endif
}
bool
@ -1671,6 +1677,7 @@ selection_primary_unset(struct seat *seat)
primary->text = NULL;
}
#if defined(FOOT_HAVE_SCROLLBACK)
static bool
fdm_scroll_timer(struct fdm *fdm, int fd, int events, void *data)
{
@ -1773,6 +1780,7 @@ selection_stop_scroll_timer(struct terminal *term)
term->selection.auto_scroll.fd = -1;
term->selection.auto_scroll.direction = SELECTION_SCROLL_NOT;
}
#endif /* FOOT_HAVE_SCROLLBACK */
static void
target(void *data, struct wl_data_source *wl_data_source, const char *mime_type)