From 5083be138124e702be0b747586551214820c370b Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:18:35 +1000 Subject: [PATCH 1/2] Fix statusbar spacing --- os.go | 2 +- os_windows.go | 2 +- ui.go | 35 +++++++++++++++++++---------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/os.go b/os.go index bfbbb58f..db48c6de 100644 --- a/os.go +++ b/os.go @@ -239,5 +239,5 @@ func diskFree(wd string) string { } // Available blocks * size per block = available space in bytes - return " df: " + humanize(int64(uint64(stat.Bavail)*uint64(stat.Bsize))) + return "df: " + humanize(int64(uint64(stat.Bavail)*uint64(stat.Bsize))) } diff --git a/os_windows.go b/os_windows.go index faff5355..c1d41f18 100644 --- a/os_windows.go +++ b/os_windows.go @@ -198,5 +198,5 @@ func diskFree(wd string) string { log.Printf("diskfree: %s", err) return "" } - return " df: " + humanize(int64(free)) + return "df: " + humanize(int64(free)) } diff --git a/ui.go b/ui.go index e6a71e84..d0e53d06 100644 --- a/ui.go +++ b/ui.go @@ -815,7 +815,7 @@ func (ui *ui) drawStatLine(nav *nav) { ind := min(dir.ind+1, tot) acc := string(ui.keyCount) + string(ui.keyAcc) - var selection string + selection := []string{} if len(nav.saves) > 0 { copy := 0 @@ -828,55 +828,58 @@ func (ui *ui) drawStatLine(nav *nav) { } } if copy > 0 { - selection += fmt.Sprintf(" \033[33;7m %d \033[0m", copy) + selection = append(selection, fmt.Sprintf("\033[33;7m %d \033[0m", copy)) } if move > 0 { - selection += fmt.Sprintf(" \033[31;7m %d \033[0m", move) + selection = append(selection, fmt.Sprintf("\033[31;7m %d \033[0m", move)) } } currSelections := nav.currSelections() if len(currSelections) > 0 { - selection += fmt.Sprintf(" \033[35;7m %d \033[0m", len(currSelections)) + selection = append(selection, fmt.Sprintf("\033[35;7m %d \033[0m", len(currSelections))) } if len(dir.filter) != 0 { - selection += " \033[34;7m F \033[0m" + selection = append(selection, "\033[34;7m F \033[0m") } - var progress string + progress := []string{} if nav.copyTotal > 0 { percentage := int((100 * float64(nav.copyBytes)) / float64(nav.copyTotal)) - progress += fmt.Sprintf(" [%d%%]", percentage) + progress = append(progress, fmt.Sprintf("[%d%%]", percentage)) } if nav.moveTotal > 0 { - progress += fmt.Sprintf(" [%d/%d]", nav.moveCount, nav.moveTotal) + progress = append(progress, fmt.Sprintf("[%d/%d]", nav.moveCount, nav.moveTotal)) } if nav.deleteTotal > 0 { - progress += fmt.Sprintf(" [%d/%d]", nav.deleteCount, nav.deleteTotal) + progress = append(progress, fmt.Sprintf("[%d/%d]", nav.deleteCount, nav.deleteTotal)) } - ruler := "" + ruler := []string{} for _, s := range gOpts.ruler { switch s { case "df": - ruler = fmt.Sprintf("%s%s", ruler, diskFree(dir.path)) + df := diskFree(dir.path) + if df != "" { + ruler = append(ruler, df) + } case "acc": - ruler = fmt.Sprintf("%s%s", ruler, acc) + ruler = append(ruler, acc) case "progress": - ruler = fmt.Sprintf("%s%s", ruler, progress) + ruler = append(ruler, progress...) case "selection": - ruler = fmt.Sprintf("%s%s", ruler, selection) + ruler = append(ruler, selection...) case "ind": - ruler = fmt.Sprintf("%s %d/%d", ruler, ind, tot) + ruler = append(ruler, fmt.Sprintf("%d/%d", ind, tot)) } } - ui.msgWin.printRight(ui.screen, 0, st, ruler) + ui.msgWin.printRight(ui.screen, 0, st, strings.Join(ruler, " ")) } func (ui *ui) drawBox() { From 76cd5f95547808693b6ec40cd345e0702484936e Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:21:10 +1000 Subject: [PATCH 2/2] Fix ruler option check --- eval.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eval.go b/eval.go index d97173be..08129ca2 100644 --- a/eval.go +++ b/eval.go @@ -490,7 +490,7 @@ func (e *setExpr) eval(app *app, args []string) { toks := strings.Split(e.val, ":") for _, s := range toks { switch s { - case "df", "acc", "progress", "selection", "ind", "tot": + case "df", "acc", "progress", "selection", "ind": default: app.ui.echoerr("ruler: should consist of 'df', 'acc', 'progress', 'selection', or 'ind' separated with colon") return