From 97b07968a0a239c862309bcdffe31848dfbf128c Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 20:11:26 +0200 Subject: plan 8: escape terminal controls in everything krino prints --- cmd/krino/undo.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'cmd/krino/undo.go') diff --git a/cmd/krino/undo.go b/cmd/krino/undo.go index 5e18a7e..b7a139f 100644 --- a/cmd/krino/undo.go +++ b/cmd/krino/undo.go @@ -375,12 +375,12 @@ func reviewUndoPerFile(in io.Reader, out io.Writer, files []engine.UndoFile, p p approved = map[int]bool{} yesRest := false for i, f := range files { - fmt.Fprintf(out, "\n[%d/%d] %s/%s\n", i+1, len(files), f.Dir, f.File) + fmt.Fprintf(out, "\n[%d/%d] %s/%s\n", i+1, len(files), display(f.Dir), display(f.File)) for _, s := range f.Steps { fmt.Fprintf(out, " %s\n", undoActionCell(s)) } if f.Refused != "" { - fmt.Fprintf(out, " refused: %s\n", f.Refused) + fmt.Fprintf(out, " refused: %s\n", display(f.Refused)) continue } if yesRest { @@ -459,15 +459,15 @@ const undoStepWidth = len("undo-displace") // no root-relative form to render here the way actionCell has. func undoActionCell(s engine.UndoStep) string { if s.Refused != "" { - return padCell(s.Action, undoStepWidth) + " refused: " + s.Refused + return padCell(s.Action, undoStepWidth) + " refused: " + display(s.Refused) } switch s.Action { case "undo-mkdir": - return padCell(s.Action, undoStepWidth) + " " + xdg.Abbrev(s.Src) + return padCell(s.Action, undoStepWidth) + " " + display(xdg.Abbrev(s.Src)) case "undo-copy": - return padCell(s.Action, undoStepWidth) + " " + xdg.Abbrev(s.Src) + " → trash" + return padCell(s.Action, undoStepWidth) + " " + display(xdg.Abbrev(s.Src)) + " → trash" } - return padCell(s.Action, undoStepWidth) + " → " + xdg.Abbrev(s.Dst) + return padCell(s.Action, undoStepWidth) + " → " + display(xdg.Abbrev(s.Dst)) } // printUndoPlan renders an undo plan the way krino undo shows it, below the @@ -497,9 +497,9 @@ type undoRow struct { func undoRows(files []engine.UndoFile) []undoRow { var rows []undoRow for i, f := range files { - label := f.Dir + "/" + f.File + label := display(f.Dir + "/" + f.File) if f.Refused != "" { - rows = append(rows, undoRow{num: strconv.Itoa(i + 1), file: label, action: "refused: " + f.Refused}) + rows = append(rows, undoRow{num: strconv.Itoa(i + 1), file: label, action: "refused: " + display(f.Refused)}) continue } for j, s := range f.Steps { -- cgit v1.3