summaryrefslogtreecommitdiffstats
path: root/filetree
diff options
context:
space:
mode:
authorAlex Goodman <wagoodman@users.noreply.github.com>2019-02-22 11:49:53 -0500
committerGitHub <noreply@github.com>2019-02-22 11:49:53 -0500
commit993be8d3ae178d7c62443e91f9a206777d6ed1ac (patch)
tree07ef1cbdfb4ee0e9be5db6b4ee569abd2d22eaae /filetree
parentcf8900da84c0f5ae7de3ea24746df2431dcc2e5b (diff)
Filetree improvements (#165)
* add filetree viewmodel * added attribute toggle * these views are really controllers * fix collapse all dir when selected file * determine filetree upperbound dynamically * support bounding cursor movements in the view model * added first view model test case * added test cases for filetree viewmodel
Diffstat (limited to 'filetree')
-rw-r--r--filetree/tree.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/filetree/tree.go b/filetree/tree.go
index b4584ff..b9cc834 100644
--- a/filetree/tree.go
+++ b/filetree/tree.go
@@ -119,14 +119,32 @@ func (tree *FileTree) renderStringTreeBetween(startRow, stopRow int, showAttribu
return result
}
+func (tree *FileTree) VisibleSize() int {
+ var size int
+
+ visitor := func(node *FileNode) error {
+ size++
+ return nil
+ }
+ visitEvaluator := func(node *FileNode) bool {
+ return !node.Data.ViewInfo.Collapsed && !node.Data.ViewInfo.Hidden
+ }
+ err := tree.VisitDepthParentFirst(visitor, visitEvaluator)
+ if err != nil {
+ logrus.Errorf("unable to determine visible tree size: %+v", err)
+ }
+
+ return size
+}
+
// String returns the entire tree in an ASCII representation.
func (tree *FileTree) String(showAttributes bool) string {
return tree.renderStringTreeBetween(0, tree.Size, showAttributes)
}
// StringBetween returns a partial tree in an ASCII representation.
-func (tree *FileTree) StringBetween(start, stop uint, showAttributes bool) string {
- return tree.renderStringTreeBetween(int(start), int(stop), showAttributes)
+func (tree *FileTree) StringBetween(start, stop int, showAttributes bool) string {
+ return tree.renderStringTreeBetween(start, stop, showAttributes)
}
// Copy returns a copy of the given FileTree