add debug pane
This commit is contained in:
parent
d655e9436a
commit
2a67ef9cbb
@ -174,10 +174,24 @@ func (node *FileNode) deriveDiffType(diffType DiffType) error {
|
||||
}
|
||||
|
||||
func (node *FileNode) AssignDiffType(diffType DiffType) error {
|
||||
var err error
|
||||
|
||||
// todo, this is an indicator that the root node approach isn't working
|
||||
if node.Path() == "/" {
|
||||
return nil
|
||||
}
|
||||
|
||||
node.Data.DiffType = diffType
|
||||
|
||||
// if we've removed this node, then all children have been removed as well
|
||||
if diffType == Removed {
|
||||
for _, child := range node.Children {
|
||||
err = child.AssignDiffType(diffType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ func (tree *FileTree) Compare(upper *FileTree) error {
|
||||
} else {
|
||||
diffType := existingNode.compare(node)
|
||||
// fmt.Printf("found existing node at %s\n", existingNode.Path())
|
||||
existingNode.deriveDiffType(diffType)
|
||||
return existingNode.deriveDiffType(diffType)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -90,9 +90,12 @@ func (view *FileTreeView) setLayer(layerIndex int) error {
|
||||
// now that the tree has been rebuilt, keep the view seleciton in parity with the previous selection
|
||||
view.setHiddenFromDiffTypes()
|
||||
|
||||
// v, _ := view.gui.View("debug")
|
||||
// v.Clear()
|
||||
// _, _ = fmt.Fprintln(v, view.RefTrees[layerIndex])
|
||||
if debug {
|
||||
v, _ := view.gui.View("debug")
|
||||
v.Clear()
|
||||
_, _ = fmt.Fprintln(v, view.RefTrees[layerIndex])
|
||||
}
|
||||
|
||||
view.view.SetCursor(0, 0)
|
||||
view.TreeIndex = 0
|
||||
view.Tree = newTree
|
||||
|
21
ui/ui.go
21
ui/ui.go
@ -8,6 +8,8 @@ import (
|
||||
"github.com/wagoodman/docker-image-explorer/image"
|
||||
)
|
||||
|
||||
const debug = true
|
||||
|
||||
var Views struct {
|
||||
Tree *FileTreeView
|
||||
Layer *LayerView
|
||||
@ -85,7 +87,11 @@ func keybindings(g *gocui.Gui) error {
|
||||
func layout(g *gocui.Gui) error {
|
||||
maxX, maxY := g.Size()
|
||||
splitCols := maxX / 2
|
||||
debugCols := maxX - 0
|
||||
debugWidth := 0
|
||||
if debug {
|
||||
debugWidth = maxX / 4
|
||||
}
|
||||
debugCols := maxX - debugWidth
|
||||
bottomRows := 1
|
||||
if view, err := g.SetView(Views.Layer.Name, -1, -1, splitCols, maxY-bottomRows); err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
@ -105,6 +111,13 @@ func layout(g *gocui.Gui) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if debug {
|
||||
if _, err := g.SetView("debug", debugCols, -1, maxX, maxY-bottomRows); err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if view, err := g.SetView(Views.Status.Name, -1, maxY-bottomRows-1, maxX, maxY); err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
@ -113,12 +126,6 @@ func layout(g *gocui.Gui) error {
|
||||
|
||||
}
|
||||
|
||||
// if _, err := g.SetView("debug", debugCol, -1, maxX, maxY-bottomRows); err != nil {
|
||||
// if err != gocui.ErrUnknownView {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user