C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 9s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 13s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 30s
Rust / build (pull_request) Successful in 49s
Rust / fmt (pull_request) Successful in 26s
Python / verify (pull_request) Successful in 1m44s
Rust / clippy (pull_request) Successful in 44s
36 lines
710 B
QML
36 lines
710 B
QML
pragma Singleton
|
|
|
|
import Quickshell
|
|
|
|
Singleton {
|
|
property var _regexCache: ({})
|
|
|
|
function percent(value: int): string {
|
|
// TRANSLATORS: %1 = a number
|
|
return qsTr("%1%").arg(value);
|
|
}
|
|
|
|
function percentOne(value: real): string {
|
|
return percent(Math.round(value * 100));
|
|
}
|
|
|
|
function testRegexList(filterList: list<string>, target: string): bool {
|
|
const regexChecker = /^\^.*\$$/;
|
|
for (const filter of filterList) {
|
|
if (regexChecker.test(filter)) {
|
|
let re = _regexCache[filter];
|
|
if (!re) {
|
|
re = new RegExp(filter);
|
|
_regexCache[filter] = re;
|
|
}
|
|
if (re.test(target))
|
|
return true;
|
|
} else {
|
|
if (filter === target)
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|