diff --git a/docs/changelog.rst b/docs/changelog.rst index 8994eb8ea..8246ac3aa 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -92,6 +92,8 @@ Detailed list of changes - Ignore :opt:`startup_session` when kitty is invoked with command line options specifying a command to run (:pull:`7198`) +- Box drawing: Specialize rendering for the Fira Code progress bar/spinner glyphs + 0.32.2 [2024-02-12] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/fonts.c b/kitty/fonts.c index afc74bb39..ed0733849 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -577,7 +577,7 @@ START_ALLOW_CASE_RANGE case 0x2574 ... 0x259f: case 0x2800 ... 0x28ff: case 0xe0b0 ... 0xe0bf: // powerline box drawing - case 0xee00 ... 0xee05: // fira code progress bar + case 0xee00 ... 0xee0b: // fira code progress bar/spinner case 0x1fb00 ... 0x1fbae: // symbols for legacy computing return BOX_FONT; default: @@ -613,7 +613,7 @@ START_ALLOW_CASE_RANGE switch(ch) { case 0x2500 ... 0x259f: return ch - 0x2500; // IDs from 0x00 to 0x9f - case 0xe0b0 ... 0xee08: + case 0xe0b0 ... 0xee0b: return 0xa0 + ch - 0xe0b0; // IDs from 0xa0 to 0xd58 case 0x2800 ... 0x28ff: return 0xe00 + ch - 0x2800; // IDs from 0xe00 to 0xeff diff --git a/kitty/fonts/box_drawing.py b/kitty/fonts/box_drawing.py index 8b7ec7acd..06be38e56 100644 --- a/kitty/fonts/box_drawing.py +++ b/kitty/fonts/box_drawing.py @@ -443,6 +443,24 @@ def draw_parametrized_curve( buf[pos] = min(255, buf[pos] + 255) +def circle_equations( + origin_x: int = 0, origin_y: int = 0, radius: float = 10., # radius is in pixels as are origin co-ords + start_at: float = 0., end_at: float = 360. +) -> Tuple[ParameterizedFunc, ParameterizedFunc]: + conv = math.pi / 180. + start = start_at * conv + end = end_at * conv + amt = end - start + + def x(t: float) -> float: + return origin_x + radius * math.cos(start + amt * t) + + def y(t: float) -> float: + return origin_y + radius * math.sin(start + amt * t) + + return x, y + + def rectircle_equations( cell_width: int, cell_height: int, supersample_factor: int, which: str = '╭' @@ -522,6 +540,14 @@ def rounded_separator(buf: SSByteArray, width: int, height: int, level: int = 1, buf[offset + dest_x] = mbuf[offset + src_x] +@supersampled() +def spinner(buf: SSByteArray, width: int, height: int, level: int = 1, start: float = 0, end: float = 360) -> None: + w, h = width // 2, height // 2 + radius = min(w, h) - int(thickness(level) * buf.supersample_factor) // 2 + arc_x, arc_y = circle_equations(w, h, radius, start_at=start, end_at=end) + draw_parametrized_curve(buf, width, height, level, arc_x, arc_y) + + def half_dhline(buf: BufType, width: int, height: int, level: int = 1, which: str = 'left', only: Optional[str] = None) -> Tuple[int, int]: x1, x2 = (0, width // 2) if which == 'left' else (width // 2, width) gap = thickness(level + 1, horizontal=False) @@ -928,6 +954,12 @@ box_chars: Dict[str, List[Callable[[BufType, int, int], Any]]] = { '': [p(progress_bar, which='l', filled=True)], '': [p(progress_bar, which='m', filled=True)], '': [p(progress_bar, which='r', filled=True)], + '': [p(spinner, start=235, end=305)], + '': [p(spinner, start=270, end=390)], + '': [p(spinner, start=315, end=470)], + '': [p(spinner, start=360, end=540)], + '': [p(spinner, start=80, end=220)], + '': [p(spinner, start=170, end=270)], '═': [dhline], '║': [dvline],