-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Filter on process list #136
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
35347d7
add proc filter dialog
stijnveenman becc644
setup search form and calls to pcView
stijnveenman 141c25c
add srocessRegex to filter processes
stijnveenman 2b51f11
moved KeyEnter to allow for cancel
stijnveenman c36e9c1
import regex
stijnveenman 06ca1e1
reset proc search on esc
stijnveenman c0fc88a
fixed variable order in searchProcess
stijnveenman ca15d2c
changed call on showProcFilter
stijnveenman 57c4fad
updated proc-filter
stijnveenman f1032d8
add mutex around pocessFilterRegex
stijnveenman 2f8e269
add workaround for inner tview issue
stijnveenman bd14106
update mutex behaviour to be thread safe
stijnveenman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package tui | ||
|
||
import ( | ||
"github.com/gdamore/tcell/v2" | ||
"github.com/rivo/tview" | ||
) | ||
|
||
func (pv *pcView) showProcFilter() { | ||
const fieldWidth = 50 | ||
f := tview.NewForm() | ||
f.SetCancelFunc(func() { | ||
pv.pages.RemovePage(PageDialog) | ||
}) | ||
f.SetItemPadding(1) | ||
f.SetBorder(true) | ||
f.SetFieldBackgroundColor(tcell.ColorLightSkyBlue) | ||
f.SetFieldTextColor(tcell.ColorBlack) | ||
f.SetButtonsAlign(tview.AlignCenter) | ||
f.SetTitle("Search Process") | ||
|
||
f.AddInputField("Search For", "", fieldWidth, nil, nil) | ||
f.AddCheckbox("Case Sensitive", false, nil) | ||
f.AddCheckbox("Regex", false, nil) | ||
|
||
searchFunc := func(searchTerm string) { | ||
caseSensitive := f.GetFormItem(1).(*tview.Checkbox).IsChecked() | ||
isRegex := f.GetFormItem(2).(*tview.Checkbox).IsChecked() | ||
|
||
pv.searchProcess(searchTerm, isRegex, caseSensitive) | ||
} | ||
f.GetFormItem(0).(*tview.InputField).SetChangedFunc(func(text string) { | ||
searchFunc(text) | ||
}) | ||
|
||
f.GetFormItem(0).(*tview.InputField).SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { | ||
if event.Key() == tcell.KeyEnter { | ||
pv.pages.RemovePage(PageDialog) | ||
return nil | ||
} | ||
|
||
return event | ||
}) | ||
|
||
f.AddButton("Search", func() { | ||
pv.pages.RemovePage(PageDialog) | ||
}) | ||
f.AddButton("Cancel", func() { | ||
pv.resetProcessSearch() | ||
pv.pages.RemovePage(PageDialog) | ||
}) | ||
|
||
f.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { | ||
switch event.Key() { | ||
case tcell.KeyEsc: | ||
pv.resetProcessSearch() | ||
pv.pages.RemovePage(PageDialog) | ||
default: | ||
return event | ||
} | ||
return nil | ||
}) | ||
f.SetFocus(0) | ||
pv.resetProcessSearch() | ||
// Display and focus the dialog | ||
pv.pages.AddPage(PageDialog, createDialogPage(f, fieldWidth+20, 11), true, true) | ||
pv.appView.SetFocus(f) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you encountered my bug, which I already fixed in my env.
Instead of this block, can you try:
Notice the
row - 1
In the line below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this block as a workaround for the issue in
tview
. It seems to break if the currently selected row is removed from the table. Which i was also able to replicate in isolation.At one point i tried to fix it by calling
table.clear()
before rendering the rows, which means it didn't have to clean up the remaining rows. And it still had the same issue (with the lines you mentioned removed).I tried it with this change and run into the same issue. (to test it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's strange. I couldn't replicate it in my environment by, for example, hiding a selected namespace
Ctrl+G
.Even if it's the last row, leaving me with 0 rows (except the title row).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. How did you filter all rows using namespaces? Doesn't every namespace in the list have at least one project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am cheating :) I also have the implementation of #133
I have 2 processes:
I select the
aaa
namespace and toggle disabled procs. Leaving me with an empty list:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sorry, that's what i ment by "crashing" , actually the background processes also keep running fine. (As seen by the logs updating by looking at the logfile directly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I attached a goroutine profiler. It looks like the table is stuck in this loop:
https://github.com/rivo/tview/blob/861aa94d61c899b32a1304d61b840d0178ece408/table.go#L1373
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this remaining issue, is there anything else in this PR that still needs to be addressed?
Do you think this workaround should be used for now? GIven that #133 will have a similar issue? Or wait for an upstream fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already merged your PR locally.
I believe I will release a new version over the weekend.
Does this timeline work for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! no rush, i was just wondering if there were any more changes needed 👌