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

@ -10,6 +10,7 @@
enum bind_action_normal {
BIND_ACTION_NONE,
BIND_ACTION_NOOP,
#if defined(FOOT_HAVE_SCROLLBACK)
BIND_ACTION_SCROLLBACK_UP_PAGE,
BIND_ACTION_SCROLLBACK_UP_HALF_PAGE,
BIND_ACTION_SCROLLBACK_UP_LINE,
@ -18,10 +19,13 @@ enum bind_action_normal {
BIND_ACTION_SCROLLBACK_DOWN_LINE,
BIND_ACTION_SCROLLBACK_HOME,
BIND_ACTION_SCROLLBACK_END,
#endif /* FOOT_HAVE_SCROLLBACK */
BIND_ACTION_CLIPBOARD_COPY,
BIND_ACTION_CLIPBOARD_PASTE,
BIND_ACTION_PRIMARY_PASTE,
#if defined(FOOT_HAVE_SCROLLBACK)
BIND_ACTION_SEARCH_START,
#endif
BIND_ACTION_FONT_SIZE_UP,
BIND_ACTION_FONT_SIZE_DOWN,
BIND_ACTION_FONT_SIZE_RESET,
@ -29,8 +33,10 @@ enum bind_action_normal {
BIND_ACTION_MINIMIZE,
BIND_ACTION_MAXIMIZE,
BIND_ACTION_FULLSCREEN,
BIND_ACTION_PIPE_SCROLLBACK,
BIND_ACTION_PIPE_VIEW,
#if defined(FOOT_HAVE_SCROLLBACK)
BIND_ACTION_PIPE_SCROLLBACK,
#endif
BIND_ACTION_PIPE_SELECTED,
BIND_ACTION_PIPE_COMMAND_OUTPUT,
BIND_ACTION_SHOW_URLS_COPY,
@ -50,8 +56,10 @@ enum bind_action_normal {
BIND_ACTION_THEME_TOGGLE,
/* Mouse specific actions - i.e. they require a mouse coordinate */
#if defined(FOOT_HAVE_SCROLLBACK)
BIND_ACTION_SCROLLBACK_UP_MOUSE,
BIND_ACTION_SCROLLBACK_DOWN_MOUSE,
#endif /* FOOT_HAVE_SCROLLBACK */
BIND_ACTION_SELECT_BEGIN,
BIND_ACTION_SELECT_BEGIN_BLOCK,
BIND_ACTION_SELECT_EXTEND,
@ -63,8 +71,13 @@ enum bind_action_normal {
BIND_ACTION_KEY_COUNT = BIND_ACTION_THEME_TOGGLE + 1,
BIND_ACTION_COUNT = BIND_ACTION_SELECT_ROW + 1,
/* Range markers (aliases) - stable regardless of FOOT_HAVE_SCROLLBACK */
BIND_ACTION_PIPE_FIRST = BIND_ACTION_PIPE_VIEW,
BIND_ACTION_PIPE_LAST = BIND_ACTION_PIPE_COMMAND_OUTPUT,
};
#if defined(FOOT_HAVE_SCROLLBACK)
enum bind_action_search {
BIND_ACTION_SEARCH_NONE,
BIND_ACTION_SEARCH_SCROLLBACK_UP_PAGE,
@ -104,6 +117,7 @@ enum bind_action_search {
BIND_ACTION_SEARCH_UNICODE_INPUT,
BIND_ACTION_SEARCH_COUNT,
};
#endif /* FOOT_HAVE_SCROLLBACK */
enum bind_action_url {
BIND_ACTION_URL_NONE,
@ -142,7 +156,9 @@ struct wayland;
struct key_binding_set {
key_binding_list_t key;
#if defined(FOOT_HAVE_SCROLLBACK)
key_binding_list_t search;
#endif
key_binding_list_t url;
key_binding_list_t mouse;
xkb_mod_mask_t selection_overrides;