tui-rs icon indicating copy to clipboard operation
tui-rs copied to clipboard

manipulating ListState/TableState offset

Open wookietreiber opened this issue 4 years ago • 2 comments

Problem

The offset of ListState and TableState can neither be accessed nor manipulated.

Solution

Add publicly visible fn offset and fn offset_mut to both ListState and TableState.

Alternatives

None.

Additional context

Offset manipulation is needed to implement controls to center the view around the currently selected list item or row, e.g. like Emacs' recenter-top-bottom via C-l shortcut.

wookietreiber avatar Jun 16 '21 19:06 wookietreiber

+1 for this, I'm looking for a way to get the offset value as well, so I can properly place a cursor on the active selection, which is not always obvious due to scrolling.

Ranguna avatar Nov 27 '21 23:11 Ranguna

I'm looking for a way to get the offset value as well, so I can properly place a cursor on the active selection, which is not always obvious due to scrolling.

@Ranguna You can test this with the PR branch I made, which currently sits directly on top of v0.17.0:

[dependencies.tui]
git = "https://github.com/wookietreiber/tui-rs"
branch = "offset-manipulation"

wookietreiber avatar Feb 26 '22 11:02 wookietreiber

My bad, PR #497 is better indeed.

bugnano avatar Jan 21 '23 08:01 bugnano