aboutsummaryrefslogtreecommitdiff
path: root/internal/tui/tui.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 13:26:51 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 13:26:51 +0200
commit07c24054cab965800983ef40f53a05c2db131ede (patch)
tree741db561d614b35f8f94fee04fb5ce663a629a0b /internal/tui/tui.go
parent70dccf8d573028aaed64185acb8e134e5339afa3 (diff)
downloadkrino-07c24054cab965800983ef40f53a05c2db131ede.tar.gz
krino-07c24054cab965800983ef40f53a05c2db131ede.zip
krino: 0.0.3 — the plan as one block per file, wrapped, and -Pv0.0.3
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 ~.
Diffstat (limited to 'internal/tui/tui.go')
-rw-r--r--internal/tui/tui.go15
1 files changed, 15 insertions, 0 deletions
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 {