From c2938a9b97b421f62786666032fc35af91ebc4c8 Mon Sep 17 00:00:00 2001 From: Christian Krause Date: Thu, 17 Jun 2021 09:18:28 +0200 Subject: [PATCH] state: adds offset access and manipulation --- src/widgets/list.rs | 10 ++++++++++ src/widgets/table.rs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/widgets/list.rs b/src/widgets/list.rs index d785d54..96cc86c 100644 --- a/src/widgets/list.rs +++ b/src/widgets/list.rs @@ -14,6 +14,16 @@ pub struct ListState { } impl ListState { + /// Returns the offset. + pub fn offset(&self) -> usize { + self.offset + } + + /// Mutably returns the offset. + pub fn offset_mut(&mut self) -> &mut usize { + &mut self.offset + } + pub fn selected(&self) -> Option { self.selected } diff --git a/src/widgets/table.rs b/src/widgets/table.rs index e1b1bf6..4e54b41 100644 --- a/src/widgets/table.rs +++ b/src/widgets/table.rs @@ -342,6 +342,16 @@ pub struct TableState { } impl TableState { + /// Returns the offset. + pub fn offset(&self) -> usize { + self.offset + } + + /// Mutably returns the offset. + pub fn offset_mut(&mut self) -> &mut usize { + &mut self.offset + } + pub fn selected(&self) -> Option { self.selected }