mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-29 22:51:35 +02:00
Merge pull request #326 from abrasumente233/main
Added: Case insensitive process filtering
This commit is contained in:
commit
c257938d46
@ -187,6 +187,16 @@ namespace Tools {
|
||||
return str.find(find_val) != string::npos;
|
||||
}
|
||||
|
||||
//* Check if string <str> contains string <find_val>, while ignoring case
|
||||
inline bool s_contains_ic(const string& str, const string& find_val) {
|
||||
auto it = std::search(
|
||||
str.begin(), str.end(),
|
||||
find_val.begin(), find_val.end(),
|
||||
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); }
|
||||
);
|
||||
return it != str.end();
|
||||
}
|
||||
|
||||
//* Return index of <find_val> from vector <vec>, returns size of <vec> if <find_val> is not present
|
||||
template <typename T>
|
||||
inline size_t v_index(const vector<T>& vec, const T& find_val) {
|
||||
|
@ -1317,7 +1317,7 @@ namespace Proc {
|
||||
filter_found = 0;
|
||||
for (auto &p : current_procs) {
|
||||
if (not tree and not filter.empty()) {
|
||||
if (not s_contains(to_string(p.pid), filter) and not s_contains(p.name, filter) and not s_contains(p.cmd, filter) and not s_contains(p.user, filter)) {
|
||||
if (not s_contains_ic(to_string(p.pid), filter) and not s_contains_ic(p.name, filter) and not s_contains_ic(p.cmd, filter) and not s_contains_ic(p.user, filter)) {
|
||||
p.filtered = true;
|
||||
filter_found++;
|
||||
} else {
|
||||
|
@ -1722,10 +1722,10 @@ namespace Proc {
|
||||
filter_found = 0;
|
||||
for (auto& p : current_procs) {
|
||||
if (not tree and not filter.empty()) {
|
||||
if (not s_contains(to_string(p.pid), filter)
|
||||
and not s_contains(p.name, filter)
|
||||
and not s_contains(p.cmd, filter)
|
||||
and not s_contains(p.user, filter)) {
|
||||
if (not s_contains_ic(to_string(p.pid), filter)
|
||||
and not s_contains_ic(p.name, filter)
|
||||
and not s_contains_ic(p.cmd, filter)
|
||||
and not s_contains_ic(p.user, filter)) {
|
||||
p.filtered = true;
|
||||
filter_found++;
|
||||
}
|
||||
|
@ -1372,7 +1372,7 @@ namespace Proc {
|
||||
filter_found = 0;
|
||||
for (auto &p : current_procs) {
|
||||
if (not tree and not filter.empty()) {
|
||||
if (not s_contains(to_string(p.pid), filter) and not s_contains(p.name, filter) and not s_contains(p.cmd, filter) and not s_contains(p.user, filter)) {
|
||||
if (not s_contains_ic(to_string(p.pid), filter) and not s_contains_ic(p.name, filter) and not s_contains_ic(p.cmd, filter) and not s_contains_ic(p.user, filter)) {
|
||||
p.filtered = true;
|
||||
filter_found++;
|
||||
} else {
|
||||
@ -1432,4 +1432,4 @@ namespace Tools {
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
} // namespace Tools
|
||||
} // namespace Tools
|
||||
|
Loading…
Reference in New Issue
Block a user