55 "maps"
66 "slices"
77 "sync"
8+ "time"
89 "zfs-file-history/internal/ui/scrollbar"
910 "zfs-file-history/internal/ui/theme"
1011 uiutil "zfs-file-history/internal/ui/util"
@@ -73,6 +74,9 @@ type RowSelectionTable[T RowSelectionTableEntry] struct {
7374 defaultSortInverted bool
7475
7576 isScrollbarVisible bool
77+
78+ lastSyncHeight int
79+ resizeTimer * time.Timer
7680}
7781
7882func NewTableContainer [T RowSelectionTableEntry ](
@@ -96,9 +100,27 @@ func NewTableContainer[T RowSelectionTableEntry](
96100 selectionChangedCallback : func (selectedEntry * T ) {},
97101 }
98102 tableContainer .createLayout ()
103+ tableContainer .setupResizeMonitor ()
99104 return tableContainer
100105}
101106
107+ func (c * RowSelectionTable [T ]) setupResizeMonitor () {
108+ c .table .SetDrawFunc (func (screen tcell.Screen , x , y , width , height int ) (int , int , int , int ) {
109+ if height > 0 && height != c .lastSyncHeight {
110+ c .lastSyncHeight = height
111+ if c .resizeTimer != nil {
112+ c .resizeTimer .Stop ()
113+ }
114+ c .resizeTimer = time .AfterFunc (50 * time .Millisecond , func () {
115+ c .application .QueueUpdateDraw (func () {
116+ c .syncScrollbar ()
117+ })
118+ })
119+ }
120+ return x , y , width , height
121+ })
122+ }
123+
102124func (c * RowSelectionTable [T ]) SetMultiSelect (multiSelect bool ) {
103125 c .multiSelectEnabled = multiSelect
104126 c .ClearMultiSelection ()
@@ -192,6 +214,7 @@ func (c *RowSelectionTable[T]) createLayout() {
192214 })
193215
194216 c .table = table
217+
195218 c .scrollbar = scrollbar .NewScrollbarComponent (c .application , scrollbar .ScrollBarVertical , 0 , 0 , 0 , 0 )
196219
197220 c .isScrollbarVisible = true
0 commit comments