Skip to content

Commit

Permalink
A new minibuffer command to clear the filter and apply it
Browse files Browse the repository at this point in the history
Just a convenience from the keyboard - you can now issue

> clear-filter
  • Loading branch information
gcla committed Dec 29, 2020
1 parent 2f28793 commit 654a4aa
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,12 @@ func lastLineMode(app gowid.IApp) {
return nil
}))

MiniBuffer.Register("clear-filter", minibufferFn(func(gowid.IApp, ...string) error {
FilterWidget.SetValue("", app)
ApplyCurrentFilter(app)
return nil
}))

MiniBuffer.Register("marks", minibufferFn(func(gowid.IApp, ...string) error {
OpenTemplatedDialogExt(appView, "Marks", fixed, ratio(0.6), app)
return nil
Expand Down Expand Up @@ -2721,6 +2727,19 @@ func (w *prefixKeyWidget) UserInput(ev interface{}, size gowid.IRenderSize, focu

//======================================================================

func ApplyCurrentFilter(app gowid.IApp) {
PcapScheduler.RequestNewFilter(FilterWidget.Value(),
pcap.HandlerList{
MakeSaveRecents("", FilterWidget.Value(), app),
MakePacketViewUpdater(app),
ManageStreamCache{},
ManageCapinfoCache{},
},
)
}

//======================================================================

func Build() (*gowid.App, error) {

var err error
Expand Down Expand Up @@ -3141,14 +3160,7 @@ func Build() (*gowid.App, error) {
})

validFilterCb := gowid.MakeWidgetCallback("cb", func(app gowid.IApp, w gowid.IWidget) {
PcapScheduler.RequestNewFilter(FilterWidget.Value(),
pcap.HandlerList{
MakeSaveRecents("", FilterWidget.Value(), app),
MakePacketViewUpdater(app),
ManageStreamCache{},
ManageCapinfoCache{},
},
)
ApplyCurrentFilter(app)
})

// Will only be enabled to click if filter is valid
Expand Down

0 comments on commit 654a4aa

Please sign in to comment.