Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/rbong/kitty
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Aug 30, 2024
2 parents 8eb0b55 + de25e4b commit 0105536
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
6 changes: 3 additions & 3 deletions kitty/fonts.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ START_ALLOW_CASE_RANGE
case 0xe0b0 ... 0xe0bf: case 0xe0d6 ... 0xe0d7: // powerline box drawing
case 0xee00 ... 0xee0b: // fira code progress bar/spinner
case 0x1fb00 ... 0x1fbae: // symbols for legacy computing
case 0xf5d0 ... 0xf5fb: // branch drawing characters
case 0xf5d0 ... 0xf60d: // branch drawing characters
return BOX_FONT;
default:
*is_emoji_presentation = has_emoji_presentation(cpu_cell, gpu_cell);
Expand Down Expand Up @@ -649,8 +649,8 @@ START_ALLOW_CASE_RANGE
return 0xf00 + ch - 0x2800; // IDs from 0xf00 to 0xfff
case 0x1fb00 ... 0x1fbae:
return 0x1000 + ch - 0x1fb00; // IDs from 0x1000 to 0x10ae
case 0xf5d0 ... 0xf5fb:
return 0x2000 + ch - 0xf5d0; // IDs from 0x2000 to 0x202b
case 0xf5d0 ... 0xf60d:
return 0x2000 + ch - 0xf5d0; // IDs from 0x2000 to 0x203d
default:
return 0xffff;
}
Expand Down
61 changes: 40 additions & 21 deletions kitty/fonts/box_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,21 +595,22 @@ def draw_circle(buf: SSByteArray, width: int, height: int, scale: float = 1.0, g


@supersampled()
def commit(buf: SSByteArray, width: int, height: int, level: int = 1, scale: float = 0.75, line: str = 'none', solid: bool = True) -> None:
def commit(buf: SSByteArray, width: int, height: int, level: int = 1, scale: float = 0.9, lines: list[str] = [], solid: bool = True) -> None:
' Draw a circular commit with the given scale. Commits can either be solid or hollow and can have vertical, horizontal, up, down, left, or right line(s) '

factor = buf.supersample_factor
# Round half width/height to supersample factor to avoid misalignment with non-supersampled lines
hwidth, hheight = factor * (width // 2 // factor), factor * (height // 2 // factor)

if line == 'horizontal' or line == 'right':
draw_hline(buf, width, hwidth, width, hheight, level, supersample_factor=factor)
if line == 'horizontal' or line == 'left':
draw_hline(buf, width, 0, hwidth, hheight, level, supersample_factor=factor)
if line == 'vertical' or line == 'down':
draw_vline(buf, width, hheight, height, hwidth, level, supersample_factor=factor)
if line == 'vertical' or line == 'up':
draw_vline(buf, width, 0, hheight, hwidth, level, supersample_factor=factor)
for line in lines:
if line == 'horizontal' or line == 'right':
draw_hline(buf, width, hwidth, width, hheight, level, supersample_factor=factor)
if line == 'horizontal' or line == 'left':
draw_hline(buf, width, 0, hwidth, hheight, level, supersample_factor=factor)
if line == 'vertical' or line == 'down':
draw_vline(buf, width, hheight, height, hwidth, level, supersample_factor=factor)
if line == 'vertical' or line == 'up':
draw_vline(buf, width, 0, hheight, hwidth, level, supersample_factor=factor)

draw_circle(buf, width, height, scale=scale)
if not solid:
Expand Down Expand Up @@ -1332,18 +1333,36 @@ def braille(buf: BufType, width: int, height: int, which: int = 0) -> None:
'': [hline, p(rounded_corner, which='╮'), p(rounded_corner, which='╰')],
'': [commit],
'': [p(commit, solid=False)],
'': [p(commit, line='right')],
'': [p(commit, solid=False, line='right')],
'': [p(commit, line='left')],
'': [p(commit, solid=False, line='left')],
'': [p(commit, line='horizontal')],
'': [p(commit, solid=False, line='horizontal')],
'': [p(commit, line='down')],
'': [p(commit, solid=False, line='down')],
'': [p(commit, line='up')],
'': [p(commit, solid=False, line='up')],
'': [p(commit, line='vertical')],
'': [p(commit, solid=False, line='vertical')],
'': [p(commit, lines=['right'])],
'': [p(commit, solid=False, lines=['right'])],
'': [p(commit, lines=['left'])],
'': [p(commit, solid=False, lines=['left'])],
'': [p(commit, lines=['horizontal'])],
'': [p(commit, solid=False, lines=['horizontal'])],
'': [p(commit, lines=['down'])],
'': [p(commit, solid=False, lines=['down'])],
'': [p(commit, lines=['up'])],
'': [p(commit, solid=False, lines=['up'])],
'': [p(commit, lines=['vertical'])],
'': [p(commit, solid=False, lines=['vertical'])],
'': [p(commit, lines=['right', 'down'])],
'': [p(commit, solid=False, lines=['right', 'down'])],
'': [p(commit, lines=['left', 'down'])],
'': [p(commit, solid=False, lines=['left', 'down'])],
'': [p(commit, lines=['right', 'up'])],
'': [p(commit, solid=False, lines=['right', 'up'])],
'': [p(commit, lines=['left', 'up'])],
'': [p(commit, solid=False, lines=['left', 'up'])],
'': [p(commit, lines=['vertical', 'right'])],
'': [p(commit, solid=False, lines=['vertical', 'right'])],
'': [p(commit, lines=['vertical', 'left'])],
'': [p(commit, solid=False, lines=['vertical', 'left'])],
'': [p(commit, lines=['horizontal', 'down'])],
'': [p(commit, solid=False, lines=['horizontal', 'down'])],
'': [p(commit, lines=['horizontal', 'up'])],
'': [p(commit, solid=False, lines=['horizontal', 'up'])],
'': [p(commit, lines=['horizontal', 'vertical'])],
'': [p(commit, solid=False, lines=['horizontal', 'vertical'])],
}

t, f = 1, 3
Expand Down

0 comments on commit 0105536

Please sign in to comment.