diff --git a/noroot.go b/pkg/noroot/noroot.go similarity index 71% rename from noroot.go rename to pkg/noroot/noroot.go index 6f5efcb..daa6742 100644 --- a/noroot.go +++ b/pkg/noroot/noroot.go @@ -2,7 +2,7 @@ // code is governed by the MIT license that can be found in the LICENSE // file. -package termshark +package noroot import ( "github.com/gcla/gowid/widgets/list" @@ -11,22 +11,22 @@ import ( //====================================================================== -type NoRootWalker struct { +type Walker struct { *tree.TreeWalker } -func NewNoRootWalker(w *tree.TreeWalker) *NoRootWalker { - return &NoRootWalker{ +func NewWalker(w *tree.TreeWalker) *Walker { + return &Walker{ TreeWalker: w, } } // for omitting top level node -func (f *NoRootWalker) Next(pos list.IWalkerPosition) list.IWalkerPosition { +func (f *Walker) Next(pos list.IWalkerPosition) list.IWalkerPosition { return tree.WalkerNext(f, pos) } -func (f *NoRootWalker) Previous(pos list.IWalkerPosition) list.IWalkerPosition { +func (f *Walker) Previous(pos list.IWalkerPosition) list.IWalkerPosition { fc := pos.(tree.IPos) pp := tree.PreviousPosition(fc, f.Tree()) if pp.Equal(tree.NewPos()) { diff --git a/ui/ui.go b/ui/ui.go index c8b8f3b..7a2ff43 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -48,6 +48,7 @@ import ( "github.com/gcla/termshark/v2" "github.com/gcla/termshark/v2/configs/profiles" "github.com/gcla/termshark/v2/pkg/fields" + "github.com/gcla/termshark/v2/pkg/noroot" "github.com/gcla/termshark/v2/pkg/pcap" "github.com/gcla/termshark/v2/pkg/pdmltree" "github.com/gcla/termshark/v2/pkg/psmlmodel" @@ -2630,7 +2631,7 @@ func setPacketListWidgets(psml iPsmlInfo, app gowid.IApp) { func expandStructWidgetAtPosition(row int, pos int, app gowid.IApp) { if curPacketStructWidget != nil { - walker := curPacketStructWidget.Walker().(*termshark.NoRootWalker) + walker := curPacketStructWidget.Walker().(*noroot.Walker) curTree := walker.Tree().(*pdmltree.Model) finalPos := make([]int, 0) @@ -2812,7 +2813,7 @@ func getStructWidgetToDisplay(row int, app gowid.IApp) gowid.IWidget { tree.NewCachingMaker(tree.WidgetMakerFunction(makeStructNodeWidget)), tree.NewCachingDecorator(tree.DecoratorFunction(makeStructNodeDecoration))) // Without the caching layer, clicking on a button has no effect - walker := termshark.NewNoRootWalker(rwalker) + walker := noroot.NewWalker(rwalker) // Send the layers represents the tree expansion to hex. // This could be the user clicking inside the tree. Or it might be the position changing