Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930package chrome
import ( "slices"
"github.com/charmbracelet/x/ansi")
// FitHints is " " and the labelled hints in room columns. A screen lists its// hints most important first and esc last. What the screen already says goes// first: moving, then the least important hints one at a time from the end,// always keeping esc. Empty when not even three of them fit.func FitHints(hints []Hint, room int) string { still := slices.DeleteFunc(slices.Clone(hints), func(h Hint) bool { return h.Key == "↑↓" }) candidates := [][]Hint{hints, still} leaving := slices.IndexFunc(still, func(h Hint) bool { return h.Key == "esc" }) if leaving >= 0 { staying := slices.Delete(slices.Clone(still), leaving, leaving+1) for n := len(staying) - 1; n >= min(2, len(staying)); n-- { candidates = append(candidates, append(slices.Clone(staying[:n]), still[leaving])) } } for _, candidate := range candidates { if line := " " + KeyHints(candidate...); len(candidate) > 0 && ansi.StringWidth(line) <= room { return line } } return ""}