diff --git a/tools/cmd/unicode_input/main.go b/tools/cmd/unicode_input/main.go index 3b4ce159c..d5ed89a72 100644 --- a/tools/cmd/unicode_input/main.go +++ b/tools/cmd/unicode_input/main.go @@ -163,9 +163,9 @@ type handler struct { } func (self *handler) initialize() { + self.ctx.AllowEscapeCodes = true self.table.initialize(self.emoji_variation, self.ctx) self.lp.SetWindowTitle("Unicode input") - self.ctx.AllowEscapeCodes = true self.current_char = InvalidChar self.current_tab_formatter = self.ctx.SprintFunc("reverse=false bold=true") self.tab_bar_formatter = self.ctx.SprintFunc("reverse=true") @@ -330,15 +330,25 @@ func (self *handler) draw_screen() { defer self.lp.RestoreCursorPosition() writeln() writeln(self.choice_line) + sz, _ := self.lp.ScreenSize() + + write_help := func(x string) { + lines := style.WrapTextAsLines(x, "", int(sz.WidthCells)-1) + wx := lines[0] + if len(lines) > 1 { + wx += "…" + } + writeln(self.dim_formatter(wx)) + } + switch self.mode { case HEX: - writeln(self.dim_formatter(fmt.Sprintf("Type %s followed by the index for the recent entries below", INDEX_CHAR))) + write_help(fmt.Sprintf("Type %s followed by the index for the recent entries below", INDEX_CHAR)) case NAME: - writeln(self.dim_formatter(fmt.Sprintf("Use Tab or arrow keys to choose a character. Type space and %s to select by index", INDEX_CHAR))) + write_help(fmt.Sprintf("Use Tab or arrow keys to choose a character. Type space and %s to select by index", INDEX_CHAR)) case FAVORITES: - writeln(self.dim_formatter("Press F12 to edit the list of favorites")) + write_help("Press F12 to edit the list of favorites") } - sz, _ := self.lp.ScreenSize() q := self.table.layout(int(sz.HeightCells)-y, int(sz.WidthCells)) if q != "" { self.lp.QueueWriteString(q) diff --git a/tools/cmd/unicode_input/table.go b/tools/cmd/unicode_input/table.go index 35fec456e..bb8a15d87 100644 --- a/tools/cmd/unicode_input/table.go +++ b/tools/cmd/unicode_input/table.go @@ -61,7 +61,7 @@ type table struct { num_cols, num_rows int mode Mode - green, reversed, not_reversed, intense_gray func(...any) string + green, reversed, intense_gray func(...any) string } func (self *table) initialize(emoji_variation string, ctx style.Context) { @@ -70,7 +70,6 @@ func (self *table) initialize(emoji_variation string, ctx style.Context) { self.last_cols, self.last_rows = -1, -1 self.green = ctx.SprintFunc("fg=green") self.reversed = ctx.SprintFunc("reverse=true") - self.not_reversed = ctx.SprintFunc("reverse=false") self.intense_gray = ctx.SprintFunc("fg=intense-gray") } @@ -149,8 +148,6 @@ func (self *table) layout(rows, cols int) string { } if is_current { text = self.reversed(text) - } else { - text = self.not_reversed(text) } output.WriteString(text) }