summaryrefslogtreecommitdiffstats
path: root/pkg/gui/types
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2024-01-07 19:44:19 +1100
committerJesse Duffield <jessedduffield@gmail.com>2024-01-19 10:47:21 +1100
commit24a4302c528e3a11b30855c006669de1adf9e1d4 (patch)
tree4b8053168746c2978c2b47968bae1576d3718bcf /pkg/gui/types
parente887a2eb3c0ece1d2be78b869ff936a0703a3940 (diff)
Add range selection ability on list contexts
This adds range select ability in two ways: 1) Sticky: like what we already have with the staging view i.e. press v then use arrow keys 2) Non-sticky: where you just use shift+up/down to expand the range The state machine works like this: (no range, press 'v') -> sticky range (no range, press arrow) -> no range (no range, press shift+arrow) -> nonsticky range (sticky range, press 'v') -> no range (sticky range, press arrow) -> sticky range (sticky range, press shift+arrow) -> nonsticky range (nonsticky range, press 'v') -> no range (nonsticky range, press arrow) -> no range (nonsticky range, press shift+arrow) -> nonsticky range
Diffstat (limited to 'pkg/gui/types')
-rw-r--r--pkg/gui/types/context.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go
index 82f03c70f..b20d70beb 100644
--- a/pkg/gui/types/context.go
+++ b/pkg/gui/types/context.go
@@ -163,6 +163,8 @@ type IPatchExplorerContext interface {
type IViewTrait interface {
FocusPoint(yIdx int)
+ SetRangeSelectStart(yIdx int)
+ CancelRangeSelect()
SetViewPortContent(content string)
SetContent(content string)
SetFooter(value string)
@@ -223,7 +225,13 @@ type IListCursor interface {
GetSelectedLineIdx() int
SetSelectedLineIdx(value int)
MoveSelectedLine(delta int)
- RefreshSelectedIdx()
+ ClampSelection()
+ CancelRangeSelect()
+ GetRangeStartIdx() (int, bool)
+ GetSelectionRange() (int, int)
+ IsSelectingRange() bool
+ ToggleStickyRange()
+ ExpandNonStickyRange(int)
}
type IListPanelState interface {