More work on unicode input

This commit is contained in:
Kovid Goyal 2023-02-14 18:25:36 +05:30
parent fb66cbc792
commit a5eac42d92
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 9 deletions

View File

@ -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)

View File

@ -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)
}