mirror of https://github.com/aristocratos/btop.git
Added: Case insensitive process filtering
This commit is contained in:
parent
0f117a0273
commit
abc4fb25c3
|
@ -187,6 +187,16 @@ namespace Tools {
|
||||||
return str.find(find_val) != string::npos;
|
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
|
//* Return index of <find_val> from vector <vec>, returns size of <vec> if <find_val> is not present
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline size_t v_index(const vector<T>& vec, const T& find_val) {
|
inline size_t v_index(const vector<T>& vec, const T& find_val) {
|
||||||
|
|
|
@ -1317,7 +1317,7 @@ namespace Proc {
|
||||||
filter_found = 0;
|
filter_found = 0;
|
||||||
for (auto &p : current_procs) {
|
for (auto &p : current_procs) {
|
||||||
if (not tree and not filter.empty()) {
|
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;
|
p.filtered = true;
|
||||||
filter_found++;
|
filter_found++;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1700,10 +1700,10 @@ namespace Proc {
|
||||||
filter_found = 0;
|
filter_found = 0;
|
||||||
for (auto& p : current_procs) {
|
for (auto& p : current_procs) {
|
||||||
if (not tree and not filter.empty()) {
|
if (not tree and not filter.empty()) {
|
||||||
if (not s_contains(to_string(p.pid), filter)
|
if (not s_contains_ic(to_string(p.pid), filter)
|
||||||
and not s_contains(p.name, filter)
|
and not s_contains_ic(p.name, filter)
|
||||||
and not s_contains(p.cmd, filter)
|
and not s_contains_ic(p.cmd, filter)
|
||||||
and not s_contains(p.user, filter)) {
|
and not s_contains_ic(p.user, filter)) {
|
||||||
p.filtered = true;
|
p.filtered = true;
|
||||||
filter_found++;
|
filter_found++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1372,7 +1372,7 @@ namespace Proc {
|
||||||
filter_found = 0;
|
filter_found = 0;
|
||||||
for (auto &p : current_procs) {
|
for (auto &p : current_procs) {
|
||||||
if (not tree and not filter.empty()) {
|
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;
|
p.filtered = true;
|
||||||
filter_found++;
|
filter_found++;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue