Get rendering of faces panel working

This commit is contained in:
Kovid Goyal
2024-05-13 20:48:26 +05:30
parent 88058c9075
commit 880078cab8
4 changed files with 20 additions and 14 deletions

View File

@@ -54,7 +54,7 @@ def opts_from_cmd(cmd: Dict[str, Any]) -> Tuple[Options, FamilyKey, float, float
family_key = []
def d(k: OptNames) -> None:
if k in cmd:
opts.font_family = parse_font_spec(cmd[k])
setattr(opts, k, parse_font_spec(cmd[k]))
family_key.append(k)
d('font_family')
d('bold_font')
@@ -82,7 +82,7 @@ def render_family_sample(
ans: Dict[str, str] = {}
font_files = get_font_files(opts)
for x in family_key:
key: FaceKey = x, base_key
key: FaceKey = getattr(opts, x).created_from_string, base_key
if x == 'font_family':
desc = font_files['medium']
elif x == 'bold_font':

View File

@@ -2,10 +2,11 @@ package choose_fonts
import (
"fmt"
"kitty/tools/tui/loop"
"kitty/tools/utils"
"math"
"sync"
"kitty/tools/tui/loop"
"kitty/tools/utils"
)
var _ = fmt.Print
@@ -35,7 +36,7 @@ func (self *faces) draw_screen() (err error) {
styled := lp.SprintStyled
lines := []string{
self.handler.format_title(self.family, 0), "",
fmt.Sprintf("Press %s to select this font, %s to go back to the font list or any of the highlighted keys below to fine-tune the appearance of the individual font styles.", styled("fg=green", "Enter"), styled("fg=red", "Esc")), "",
fmt.Sprintf("Press %s to select this font, %s to go back to the font list or any of the %s keys below to fine-tune the appearance of the individual font styles.", styled("fg=green", "Enter"), styled("fg=red", "Esc"), styled("fg=magenta bold", "highlighted")), "",
}
_, y, str := self.handler.render_lines.InRectangle(lines, 0, 0, int(sz.WidthCells), int(sz.HeightCells), &self.handler.mouse_state, self.on_click)
@@ -77,12 +78,14 @@ func (self *faces) draw_screen() (err error) {
return
}
lp.MoveCursorTo(1, y+1)
lp.QueueWriteString(title + fmt.Sprintf(" (%s %s)", setting, setting_val))
y += 1
lp.MoveCursorTo(1, y+1)
self.handler.graphics_manager.display_image(slot, previews[setting], key.width, key.height)
slot++
y += num_lines + 1
_, y, str = self.handler.render_lines.InRectangle([]string{title + fmt.Sprintf(" (%s %s)", setting, setting_val)}, 0, y, int(sz.WidthCells), int(sz.HeightCells), &self.handler.mouse_state, self.on_click)
lp.QueueWriteString(str)
if y+num_lines < int(sz.HeightCells) {
lp.MoveCursorTo(1, y+1)
self.handler.graphics_manager.display_image(slot, previews[setting], key.width, key.height)
slot++
y += num_lines + 1
}
}
d(`font_family`, styled("fg=magenta bold", "R")+`egular`, key.settings.font_family)
d(`bold_font`, styled("fg=magenta bold", "B")+`old`, key.settings.bold_font)