Repository navigation
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
Pager::set_frozen_lines(n), which keeps the firstnlines 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: newPagerState::frozen_linesfield (defaults to0).commands/ev_handler: newCommand::SetFrozenLines(usize).pager: new publicPager::set_frozen_lines(n)method (documented, with example).display:write_from_pagerstaterenders the frozen rows first, then the scrolled content, and clampsupper_markinto the scrollable region.draw_for_changefalls back to a full redraw whenfrozen_lines > 0, because the incremental partial-scroll optimization is not valid when part of the view is frozen.Behaviour / compatibility
frozen_lines == 0keeps the existing behaviour and the optimized incremental scrolling unchanged.frozen_lines > 0, scrolling uses a full redraw instead of the partial-scroll optimization.Tests
frozen_lines_stay_at_top_while_scrollingcovering 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.