diff --git a/cmd/gotop/main.go b/cmd/gotop/main.go index 272eecc9..cd8293f1 100644 --- a/cmd/gotop/main.go +++ b/cmd/gotop/main.go @@ -353,7 +353,7 @@ func eventLoop(c gotop.Config, grid *layout.MyGrid) { grid.Proc.ToggleShowingGroupedProcs() ui.Render(grid.Proc) } - case "m", "c", "p": + case "m", "c", "n", "p": if grid.Proc != nil { grid.Proc.ChangeProcSortMethod(w.ProcSortMethod(e.ID)) ui.Render(grid.Proc) diff --git a/dicts/de_DE.toml b/dicts/de_DE.toml index edc74d8a..a3cbde4e 100644 --- a/dicts/de_DE.toml +++ b/dicts/de_DE.toml @@ -28,6 +28,7 @@ Process actions: Prozesssortierung: - c: CPU + - n: Cmd - m: Mem - p: PID diff --git a/dicts/en_US.toml b/dicts/en_US.toml index 30dacfa9..1e85f376 100644 --- a/dicts/en_US.toml +++ b/dicts/en_US.toml @@ -28,6 +28,7 @@ Process actions: Process sorting: - c: CPU + - n: Cmd - m: Mem - p: PID diff --git a/dicts/eo.toml b/dicts/eo.toml index 7371fa21..cae63986 100644 --- a/dicts/eo.toml +++ b/dicts/eo.toml @@ -28,6 +28,7 @@ Proceza agoj: Proceza ordigoj: - c: CPU + - n: Cmd - m: Memoro - p: PID diff --git a/dicts/es.toml b/dicts/es.toml index bb4f3d10..daf9aa61 100644 --- a/dicts/es.toml +++ b/dicts/es.toml @@ -28,6 +28,7 @@ Acciones de proceso : Ordenación de procesos: - c: CPU + - n: Cmd - m: Mem - p: PID diff --git a/dicts/fr.toml b/dicts/fr.toml index e694ed31..01d6516e 100644 --- a/dicts/fr.toml +++ b/dicts/fr.toml @@ -28,6 +28,7 @@ Action sur les processus: Tri des processus: - c: CPU + - n: Cmd - m: Mem - p: PID diff --git a/dicts/ru_RU.toml b/dicts/ru_RU.toml index 2656d188..cabb11c9 100644 --- a/dicts/ru_RU.toml +++ b/dicts/ru_RU.toml @@ -25,6 +25,7 @@ help=""" - d9: убить выбранный процесс или группу процессов с помощью SIGKILL (9) Сортировка процессов: - c: CPU + - n: Cmd - m: Память - p: PID Фильтр процессов: diff --git a/dicts/tt_TT.toml b/dicts/tt_TT.toml index 3e778bc8..2d0d2ac1 100644 --- a/dicts/tt_TT.toml +++ b/dicts/tt_TT.toml @@ -28,6 +28,7 @@ gnipuorg ssecorp elggot :>baT< - :gnitros ssecorP UPC :c - +dmC :n - meM :m - DIP :p - diff --git a/dicts/zh_CN.toml b/dicts/zh_CN.toml index bcce3041..bab7fb15 100644 --- a/dicts/zh_CN.toml +++ b/dicts/zh_CN.toml @@ -28,6 +28,7 @@ help=""" 进程排序: - c: CPU + - n: Cmd - m: 内存 - p: 进程标识 diff --git a/widgets/proc.go b/widgets/proc.go index 408906c6..d332a15d 100644 --- a/widgets/proc.go +++ b/widgets/proc.go @@ -25,6 +25,7 @@ const ( ProcSortCPU ProcSortMethod = "c" ProcSortMem = "m" ProcSortPid = "p" + ProcSortCmd = "n" ) type Proc struct { @@ -188,6 +189,9 @@ func (proc *ProcWidget) sortProcs() { case ProcSortMem: sort.Sort(sort.Reverse(SortProcsByMem(*procs))) proc.Header[3] += _downArrow + case ProcSortCmd: + sort.Sort(sort.Reverse(SortProcsByCmd(*procs))) + proc.Header[1] += _downArrow } } @@ -336,3 +340,20 @@ func (procs SortProcsByMem) Swap(i, j int) { func (procs SortProcsByMem) Less(i, j int) bool { return procs[i].Mem < procs[j].Mem } + +type SortProcsByCmd []Proc + +// Len implements Sort interface +func (procs SortProcsByCmd) Len() int { + return len(procs) +} + +// Swap implements Sort interface +func (procs SortProcsByCmd) Swap(i, j int) { + procs[i], procs[j] = procs[j], procs[i] +} + +// Less implements Sort interface +func (procs SortProcsByCmd) Less(i, j int) bool { + return strings.ToLower(procs[j].CommandName) < strings.ToLower(procs[i].CommandName) +}