Skip to content

feat: add set_frozen_lines to keep header lines fixed (sticky header) - #173

Open
lovelock wants to merge 1 commit into
AMythicDev:mainfrom
lovelock:feat/sticky-header
Open

lovelock wants to merge 1 commit into
AMythicDev:mainfrom
lovelock:feat/sticky-header

Conversation

@lovelock

Copy link
Copy Markdown

Summary

Adds Pager::set_frozen_lines(n), which keeps the first n lines of the output (for example a table/column header) fixed at the top of the screen while the rest of the content scrolls beneath them — a "sticky header".

This is useful for applications that page through tabular output (e.g. a process list) and want the header row to stay visible while scrolling.

Changes

  • state: new PagerState::frozen_lines field (defaults to 0).
  • commands / ev_handler: new Command::SetFrozenLines(usize).
  • pager: new public Pager::set_frozen_lines(n) method (documented, with example).
  • display:
    • write_from_pagerstate renders the frozen rows first, then the scrolled content, and clamps upper_mark into the scrollable region.
    • draw_for_change falls back to a full redraw when frozen_lines > 0, because the incremental partial-scroll optimization is not valid when part of the view is frozen.

Behaviour / compatibility

  • Default frozen_lines == 0 keeps the existing behaviour and the optimized incremental scrolling unchanged.
  • When frozen_lines > 0, scrolling uses a full redraw instead of the partial-scroll optimization.

Tests

  • Added frozen_lines_stay_at_top_while_scrolling covering that the header rows stay at the top and the content window is correct after scrolling.
  • cargo test --features static_output,search: all pass.
  • cargo clippy --all-features --all-targets: clean.
  • cargo fmt --check: clean.

Add Pager::set_frozen_lines(n) which keeps the first n lines of the
output (e.g. a table header) fixed at the top while the remaining
content scrolls beneath them.

When n > 0 the scroll region excludes the frozen rows and scrolling
falls back to a full redraw, since the incremental partial-scroll
optimization is not valid with a frozen region. The default (0) keeps
the existing behaviour unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant