From 07c24054cab965800983ef40f53a05c2db131ede Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 13:26:51 +0200 Subject: krino: 0.0.3 — the plan as one block per file, wrapped, and -P MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each file shows its steps, then the rule and the reason it matched, one field per line; on a terminal every line wraps to its width with continuation lines under their own column, and piped output is never wrapped. Choosing per file shows the same block. -P / --no-pager prints the plan without the pager. A duplicate's original is shown with ~. --- internal/tui/tui.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'internal/tui/tui.go') diff --git a/internal/tui/tui.go b/internal/tui/tui.go index c9f1241..e7872c8 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -36,6 +36,21 @@ func Colour(w io.Writer) bool { return !noColour } +// Width is the terminal's column count, 0 when w is not a terminal or the +// size cannot be read: callers wrap text to it, and treat 0 as "never +// wrap", which keeps output piped to a file one field per line. +func Width(w io.Writer) int { + f, ok := w.(*os.File) + if !ok || !isTerminal(int(f.Fd())) { + return 0 + } + cols, _, err := termSize(int(f.Fd())) + if err != nil { + return 0 + } + return cols +} + // height is the terminal's row count, 0 when it is not a terminal or the // size cannot be read. func height(w io.Writer) int { -- cgit v1.3