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

@ -341,8 +341,10 @@ enum selection_kind {
SELECTION_BLOCK
};
enum selection_direction {SELECTION_UNDIR, SELECTION_LEFT, SELECTION_RIGHT};
#if defined(FOOT_HAVE_SCROLLBACK)
enum selection_scroll_direction {SELECTION_SCROLL_NOT, SELECTION_SCROLL_UP, SELECTION_SCROLL_DOWN};
enum search_direction { SEARCH_BACKWARD_SAME_POSITION, SEARCH_BACKWARD, SEARCH_FORWARD };
#endif
struct ptmx_buffer {
void *data;
@ -365,7 +367,9 @@ enum term_surface {
enum overlay_style {
OVERLAY_NONE,
#if defined(FOOT_HAVE_SCROLLBACK)
OVERLAY_SEARCH,
#endif
OVERLAY_FLASH,
OVERLAY_UNICODE_MODE,
};
@ -605,13 +609,16 @@ struct terminal {
struct range pivot;
#if defined(FOOT_HAVE_SCROLLBACK)
struct {
int fd;
int col;
enum selection_scroll_direction direction;
} auto_scroll;
#endif
} selection;
#if defined(FOOT_HAVE_SCROLLBACK)
bool is_searching;
struct {
char32_t *buf;
@ -629,6 +636,7 @@ struct terminal {
size_t len;
} last;
} search;
#endif /* FOOT_HAVE_SCROLLBACK */
struct wayland *wl;
struct wl_window *window;
@ -639,8 +647,10 @@ struct terminal {
struct {
struct {
struct buffer_chain *grid;
#if defined(FOOT_HAVE_SCROLLBACK)
struct buffer_chain *search;
struct buffer_chain *scrollback_indicator;
#endif
struct buffer_chain *render_timer;
struct buffer_chain *url;
struct buffer_chain *csd;
@ -651,7 +661,9 @@ struct terminal {
struct {
bool grid;
bool csd;
#if defined(FOOT_HAVE_SCROLLBACK)
bool search;
#endif
bool urls;
} refresh;
@ -659,7 +671,9 @@ struct terminal {
struct {
bool grid;
bool csd;
#if defined(FOOT_HAVE_SCROLLBACK)
bool search;
#endif
bool urls;
} pending;
@ -681,7 +695,9 @@ struct terminal {
int timer_fd;
} app_id;
#if defined(FOOT_HAVE_SCROLLBACK)
uint32_t scrollback_lines; /* Number of scrollback lines, from conf (TODO: move out from render struct?) */
#endif
struct {
bool enabled;
@ -722,7 +738,9 @@ struct terminal {
struct buffer *last_overlay_buf;
pixman_region32_t last_overlay_clip;
#if defined(FOOT_HAVE_SCROLLBACK)
size_t search_glyph_offset;
#endif
struct timespec input_time;
} render;
@ -889,7 +907,9 @@ void term_erase(
struct terminal *term,
int start_row, int start_col,
int end_row, int end_col);
#if defined(FOOT_HAVE_SCROLLBACK)
void term_erase_scrollback(struct terminal *term);
#endif
int term_row_rel_to_abs(const struct terminal *term, int row);
void term_cursor_home(struct terminal *term);
@ -958,8 +978,10 @@ void term_disable_app_sync_updates(struct terminal *term);
enum term_surface term_surface_kind(
const struct terminal *term, const struct wl_surface *surface);
#if defined(FOOT_HAVE_SCROLLBACK)
bool term_scrollback_to_text(
const struct terminal *term, char **text, size_t *len);
#endif
bool term_view_to_text(
const struct terminal *term, char **text, size_t *len);
bool term_command_output_to_text(