diff --git a/tools/tui/loop/api.go b/tools/tui/loop/api.go index 51396f911..1ac92c8fd 100644 --- a/tools/tui/loop/api.go +++ b/tools/tui/loop/api.go @@ -223,9 +223,12 @@ func (self *Loop) Println(args ...any) { } func (self *Loop) style_region(style string, start_x, start_y, end_x, end_y int) string { - sgr := self.SprintStyled(style, "|")[2:] - sgr = sgr[:strings.IndexByte(sgr, 'm')] - return fmt.Sprintf("\x1b[%d;%d;%d;%d;%s$r", start_y+1, start_x+1, end_y+1, end_x+1, sgr) + sgr := self.SprintStyled(style, "|") + if len(sgr) > 2 { + sgr = sgr[2:strings.IndexByte(sgr, 'm')] + return fmt.Sprintf("\x1b[%d;%d;%d;%d;%s$r", start_y+1, start_x+1, end_y+1, end_x+1, sgr) + } + return "" } // Apply the specified style to the specified region of the screen (0-based