change: reallow spaces to represent "and"
This commit is contained in:
parent
a71d991695
commit
b253d0153b
|
@ -268,10 +268,10 @@ Run using `btm`.
|
||||||
|
|
||||||
Note that the `and` operator takes precedence over the `or` operator.
|
Note that the `and` operator takes precedence over the `or` operator.
|
||||||
|
|
||||||
| Keywords | Usage | Description |
|
| Keywords | Usage | Description |
|
||||||
| ---------- | ------------------------------------- | --------------------------------------------------- |
|
| ------------------ | -------------------------------------------- | --------------------------------------------------- |
|
||||||
| `and, &&` | `<CONDITION 1> and/&&<CONDITION 2>` | Requires both conditions to be true to match |
|
| `and, &&, <Space>` | `<CONDITION 1> and/&&/<Space> <CONDITION 2>` | Requires both conditions to be true to match |
|
||||||
| `or, \|\|` | `<CONDITION 1> or/\|\| <CONDITION 2>` | Requires at least one condition to be true to match |
|
| `or, \|\|` | `<CONDITION 1> or/\|\| <CONDITION 2>` | Requires at least one condition to be true to match |
|
||||||
|
|
||||||
#### Supported units
|
#### Supported units
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ use crate::{
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
const DELIMITER_LIST: [char; 6] = ['=', '>', '<', '(', ')', '\"'];
|
const DELIMITER_LIST: [char; 6] = ['=', '>', '<', '(', ')', '\"'];
|
||||||
|
|
||||||
const OR_LIST: [&str; 2] = ["or", "||"];
|
const OR_LIST: [&str; 2] = ["or", "||"];
|
||||||
const AND_LIST: [&str; 2] = ["and", "&&"];
|
const AND_LIST: [&str; 2] = ["and", "&&"];
|
||||||
|
|
||||||
|
@ -111,26 +110,24 @@ impl ProcessQuery for ProcWidgetState {
|
||||||
let mut rhs: Option<Box<Prefix>> = None;
|
let mut rhs: Option<Box<Prefix>> = None;
|
||||||
|
|
||||||
while let Some(queue_top) = query.front() {
|
while let Some(queue_top) = query.front() {
|
||||||
if AND_LIST.contains(&queue_top.to_lowercase().as_str()) {
|
if queue_top == ")" {
|
||||||
|
break;
|
||||||
|
} else if AND_LIST.contains(&queue_top.to_lowercase().as_str()) {
|
||||||
query.pop_front();
|
query.pop_front();
|
||||||
rhs = Some(Box::new(process_prefix(query, false)?));
|
}
|
||||||
|
rhs = Some(Box::new(process_prefix(query, false)?));
|
||||||
|
|
||||||
if let Some(queue_next) = query.front() {
|
if query.front().is_some() {
|
||||||
if AND_LIST.contains(&queue_next.to_lowercase().as_str()) {
|
// Must merge LHS and RHS
|
||||||
// Must merge LHS and RHS
|
lhs = Prefix {
|
||||||
lhs = Prefix {
|
or: Some(Box::new(Or {
|
||||||
or: Some(Box::new(Or {
|
lhs: And { lhs, rhs },
|
||||||
lhs: And { lhs, rhs },
|
rhs: None,
|
||||||
rhs: None,
|
})),
|
||||||
})),
|
regex_prefix: None,
|
||||||
regex_prefix: None,
|
compare_prefix: None,
|
||||||
compare_prefix: None,
|
};
|
||||||
};
|
rhs = None;
|
||||||
rhs = None;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ pub const SEARCH_HELP_TEXT: [&str; 43] = [
|
||||||
"<= ex: cpu <= 1\n",
|
"<= ex: cpu <= 1\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Logical operators:\n",
|
"Logical operators:\n",
|
||||||
"and/&& ex: btm and cpu > 1 and mem > 1\n",
|
"and/&&/<Space> ex: btm and cpu > 1 and mem > 1\n",
|
||||||
"or/|| ex: btm or firefox\n",
|
"or/|| ex: btm or firefox\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Supported units:\n",
|
"Supported units:\n",
|
||||||
|
|
Loading…
Reference in New Issue