diff --git a/bpytop.py b/bpytop.py index 9f3c8ce..de52dcc 100755 --- a/bpytop.py +++ b/bpytop.py @@ -2566,7 +2566,7 @@ class ProcBox(Box): if not "delete" in Key.mouse: Key.mouse["delete"] = [[x+12 + len(proc.search_filter[-10:]) + i, y-1] for i in range(3)] elif "delete" in Key.mouse: del Key.mouse["delete"] - out_misc += (f'{Mv.to(y-1, x + 8)}{THEME.proc_box(Symbol.title_left)}{Fx.b if cls.filtering or proc.search_filter else ""}{THEME.hi_fg("f")}{THEME.title}' + + out_misc += (f'{Mv.to(y-1, x + 8)}{THEME.proc_box(Symbol.title_left)}{Fx.b if cls.filtering or proc.search_filter else ""}{THEME.hi_fg("F" if cls.filtering and proc.case_sensitive else "f")}{THEME.title}' + ("ilter" if not proc.search_filter and not cls.filtering else f' {proc.search_filter[-(10 if w < 83 else w - 74):]}{(Fx.bl + "█" + Fx.ubl) if cls.filtering else THEME.hi_fg(" del")}') + f'{THEME.proc_box(Symbol.title_right)}') @@ -3523,6 +3523,7 @@ class ProcCollector(Collector): '''Collects process stats''' buffer: str = ProcBox.buffer search_filter: str = "" + case_sensitive: bool = False processes: Dict = {} num_procs: int = 0 det_cpu: float = 0.0 @@ -3554,7 +3555,12 @@ class ProcCollector(Collector): sorting: str = CONFIG.proc_sorting reverse: bool = not CONFIG.proc_reversed proc_per_cpu: bool = CONFIG.proc_per_core - search: str = cls.search_filter + search: List[str] = [] + if cls.search_filter: + if cls.case_sensitive: + search = [i.strip() for i in cls.search_filter.split(",")] + else: + search = [i.strip() for i in cls.search_filter.lower().split(",")] err: float = 0.0 n: int = 0 @@ -3581,8 +3587,10 @@ class ProcCollector(Collector): if cls.detailed and p.info["pid"] == cls.detailed_pid: cls.det_cpu = p.info["cpu_percent"] for value in [ p.info["name"], " ".join(p.info["cmdline"]), str(p.info["pid"]), p.info["username"] ]: - for s in search.split(","): - if s.strip() in value: + if not cls.case_sensitive: + value = value.lower() + for s in search: + if s in value: break else: continue break @@ -3694,7 +3702,7 @@ class ProcCollector(Collector): if len(cls.details_mem) > ProcBox.width: del cls.details_mem[0] @classmethod - def _tree(cls, sort_cmd, reverse: bool, proc_per_cpu: bool, search: str): + def _tree(cls, sort_cmd, reverse: bool, proc_per_cpu: bool, search: List[str]): '''List all processess in a tree view with pid, name, threads, username, memory percent and cpu percent''' out: Dict = {} err: float = 0.0 @@ -3737,8 +3745,10 @@ class ProcCollector(Collector): if "username" in getinfo and isinstance(getinfo["username"], float): getinfo["username"] = "" if "cmdline" in getinfo and isinstance(getinfo["cmdline"], float): getinfo["cmdline"] = "" for value in [ name, str(pid), getinfo.get("username", ""), " ".join(getinfo.get("cmdline", "")) ]: - for s in search.split(","): - if s.strip() in value: + if not cls.case_sensitive: + value = value.lower() + for s in search: + if s in value: found = True break else: continue @@ -5178,8 +5188,9 @@ def process_keys(): elif key == "c": CONFIG.proc_per_core = not CONFIG.proc_per_core Collector.collect(ProcCollector, interrupt=True, redraw=True) - elif key == "f": + elif key in ["f", "F"]: ProcBox.filtering = True + ProcCollector.case_sensitive = key == "F" if not ProcCollector.search_filter: ProcBox.start = 0 Collector.collect(ProcCollector, redraw=True, only_draw=True) elif key in ["T", "K", "I"] and (ProcBox.selected > 0 or ProcCollector.detailed):