Improve draw_single_line_of_text to support max_width and return (pixels, width) tuple

- Add freetype_text_width_for_single_line() in freetype_render_ui_text.c
- Add cocoa_text_width_for_single_line() in core_text.m
- Add text_width_for_single_line() wrapper in glfw.c for both platforms
- Modify draw_single_line_of_text() to accept optional max_width parameter
- Return (pixels, width) tuple instead of just pixels
- Update all Python call sites in tabs.py and window.py

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/508483db-ffcd-4d43-a8ee-83fcd3ec9c01

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-06 05:25:38 +00:00
committed by GitHub
parent c88adfba98
commit 4bcfafa945
9 changed files with 118 additions and 7 deletions

View File

@@ -1321,7 +1321,7 @@ class Window:
fg = color_as_int(self.screen.color_profile.default_fg)
bg = color_as_int(self.screen.color_profile.default_bg)
width = self.geometry.right - self.geometry.left
pixels = draw_single_line_of_text(self.os_window_id, url, 0xff000000 | fg, 0xff000000 | bg, width)
pixels, width = draw_single_line_of_text(self.os_window_id, url, 0xff000000 | fg, 0xff000000 | bg, width)
height = len(pixels) // (width * 4)
thumbnails = ((pixels, width, height),)
drag_data = {'text/uri-list': (url + '\r\n').encode()}