mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-07-10 01:41:16 +00:00
Change algorithm for y position of dashed/dotted underlines
Make the inner loop faster and ensure that the same logic for y-position and thickness is used as for the straight underline. Fixes #8074
This commit is contained in:
parent
143705f2a7
commit
4118bfc8ee
2 changed files with 19 additions and 8 deletions
|
|
@ -99,6 +99,8 @@ Detailed list of changes
|
|||
|
||||
- Graphics protocol: Fix delete by number not deleting newest image with the specified number (:iss:`8071`)
|
||||
|
||||
- Fix dashed and dotted underlines not being drawn at the same y position as straight underlines at all font sizes (:iss:`8074`)
|
||||
|
||||
0.37.0 [2024-10-30]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -281,19 +281,28 @@ def add_curl(buf: CBufType, cell_width: int, position: int, thickness: int, cell
|
|||
|
||||
def add_dots(buf: CBufType, cell_width: int, position: int, thickness: int, cell_height: int) -> None:
|
||||
spacing, size = distribute_dots(cell_width, cell_width // (2 * thickness))
|
||||
|
||||
y = 1 + position - thickness // 2
|
||||
for i in range(y, min(y + thickness, cell_height)):
|
||||
y = position - thickness // 2
|
||||
buf_addr = ctypes.addressof(buf)
|
||||
while thickness > 0 and -1 < y < cell_height:
|
||||
offset = buf_addr + cell_width * y
|
||||
for j, s in enumerate(spacing):
|
||||
buf[cell_width * i + j * size + s: cell_width * i + (j + 1) * size + s] = [255] * size
|
||||
ctypes.memset(offset + j * size + s, 255, size)
|
||||
thickness -= 1
|
||||
y += 1
|
||||
|
||||
|
||||
def add_dashes(buf: CBufType, cell_width: int, position: int, thickness: int, cell_height: int) -> None:
|
||||
halfspace_width = cell_width // 4
|
||||
y = 1 + position - thickness // 2
|
||||
for i in range(y, min(y + thickness, cell_height)):
|
||||
buf[cell_width * i:cell_width * i + (cell_width - 3 * halfspace_width)] = [255] * (cell_width - 3 * halfspace_width)
|
||||
buf[cell_width * i + 3 * halfspace_width:cell_width * (i + 1)] = [255] * (cell_width - 3 * halfspace_width)
|
||||
y = position - thickness // 2
|
||||
dash_width = cell_width - 3 * halfspace_width
|
||||
second_dash_start = 3 * halfspace_width
|
||||
buf_addr = ctypes.addressof(buf)
|
||||
while thickness > 0 and -1 < y < cell_height:
|
||||
offset = buf_addr + cell_width * y
|
||||
ctypes.memset(offset, 255, dash_width)
|
||||
ctypes.memset(offset + second_dash_start, 255, dash_width)
|
||||
thickness -= 1
|
||||
y += 1
|
||||
|
||||
|
||||
def render_special(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue