Browse Source

Add TreeView.Transform

tablepad
Trevor Slocum 2 years ago
parent
commit
e00b7a3984
  1. 1
      CHANGELOG
  2. 23
      treeview.go
  3. 13
      util.go

1
CHANGELOG

@ -1,6 +1,7 @@
v1.4.5 (WIP)
- Add multithreading support
- Add ContextMenu (initially supported by List)
- Add TreeView.Transform
- Merge upstream mouse support
v1.4.4 (2020-02-24)

23
treeview.go

@ -551,6 +551,29 @@ func (t *TreeView) GetRowCount() int {
return len(t.nodes)
}
// Transform modifies the current selection.
func (t *TreeView) Transform(tr Transformation) {
t.Lock()
defer t.Unlock()
switch tr {
case TransformFirstItem:
t.movement = treeHome
case TransformLastItem:
t.movement = treeEnd
case TransformPreviousItem:
t.movement = treeUp
case TransformNextItem:
t.movement = treeDown
case TransformPreviousPage:
t.movement = treePageUp
case TransformNextPage:
t.movement = treePageDown
}
t.process()
}
// process builds the visible tree, populates the "nodes" slice, and processes
// pending selection actions.
func (t *TreeView) process() {

13
util.go

@ -50,6 +50,19 @@ var (
InputFieldMaxLength func(maxLength int) func(text string, ch rune) bool
)
// Transformation describes a widget modification.
type Transformation int
// Widget transformations.
const (
TransformFirstItem Transformation = 1
TransformLastItem Transformation = 2
TransformPreviousItem Transformation = 3
TransformNextItem Transformation = 4
TransformPreviousPage Transformation = 5
TransformNextPage Transformation = 6
)
// Package initialization.
func init() {
runewidth.EastAsianWidth = true

Loading…
Cancel
Save