diff --git a/kittens/choose_fonts/backend.py b/kittens/choose_fonts/backend.py index 9f3c94f38..a01eca3f5 100644 --- a/kittens/choose_fonts/backend.py +++ b/kittens/choose_fonts/backend.py @@ -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': diff --git a/kittens/choose_fonts/faces.go b/kittens/choose_fonts/faces.go index 22b67ded3..c83213e53 100644 --- a/kittens/choose_fonts/faces.go +++ b/kittens/choose_fonts/faces.go @@ -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) diff --git a/kitty/fonts/__init__.py b/kitty/fonts/__init__.py index 2eb6948f8..678d4a878 100644 --- a/kitty/fonts/__init__.py +++ b/kitty/fonts/__init__.py @@ -139,6 +139,7 @@ class FontSpec(NamedTuple): system: str = '' axes: Tuple[Tuple[str, float], ...] = () variable_name: str = '' + created_from_string: str = '' @property def is_system(self) -> bool: diff --git a/kitty/options/utils.py b/kitty/options/utils.py index 04bc813b5..2968523da 100644 --- a/kitty/options/utils.py +++ b/kitty/options/utils.py @@ -1392,10 +1392,10 @@ def parse_mouse_map(val: str) -> Iterable[MouseMapping]: def parse_font_spec(spec: str) -> FontSpec: if spec == 'auto': - return FontSpec(system='auto') + return FontSpec(system='auto', created_from_string=spec) items = tuple(shlex_split(spec)) if '=' not in items[0]: - return FontSpec(system=spec) + return FontSpec(system=spec, created_from_string=spec) axes = {} defined = {} for item in items: @@ -1409,7 +1409,9 @@ def parse_font_spec(spec: str) -> FontSpec: axes[k] = float(v) except Exception: raise ValueError(f'The font specification: {spec} is not valid as {v} is not a number') - return FontSpec(axes=tuple(axes.items()), **defined) + return FontSpec(axes=tuple(axes.items()), created_from_string=spec, **defined) + + def deprecated_hide_window_decorations_aliases(key: str, val: str, ans: Dict[str, Any]) -> None: if not hasattr(deprecated_hide_window_decorations_aliases, key): setattr(deprecated_hide_window_decorations_aliases, key, True)