Accept keyword arguments in draw_single_line_of_text, use max_width=True in window.py, remove changelog entry

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/9a89a6c8-4bc2-4f11-9947-55b713b15348

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-06 06:01:59 +00:00 committed by GitHub
parent 398fb8d156
commit 9a878c9edc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 6 deletions

View file

@ -185,8 +185,6 @@ Detailed list of changes
- Allow optionally dragging URLs with the mouse, see :sc:`start_simple_selection` (:pull:`9804`)
- Improve ``draw_single_line_of_text()`` to accept an optional ``max_width`` parameter. When set, the width is treated as a maximum and reduced to the actual text width if smaller. The function now returns both pixel data and actual width used.
- Fix thickness of diagonal lines in box drawing characters not the same as horizontal/vertical lines (:iss:`9719`)
- Graphics protocol: Fix crash when handling invalid PNG image with direct transmission

View file

@ -3087,12 +3087,13 @@ grab_keyboard(PyObject *self UNUSED, PyObject *action) {
}
static PyObject*
draw_single_line_of_text(PyObject *self UNUSED, PyObject *args) {
draw_single_line_of_text(PyObject *self UNUSED, PyObject *args, PyObject *kw) {
unsigned long long os_window_id;
const char *text;
unsigned int fg, bg;
int width, padding_y = 2, max_width = 0;
if (!PyArg_ParseTuple(args, "KsIIi|ip", &os_window_id, &text, &fg, &bg, &width, &padding_y, &max_width)) return NULL;
static const char* kwlist[] = {"os_window_id", "text", "fg", "bg", "width", "padding_y", "max_width", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kw, "KsIIi|ip", (char**)kwlist, &os_window_id, &text, &fg, &bg, &width, &padding_y, &max_width)) return NULL;
OSWindow *w = os_window_for_id(os_window_id);
if (!w || !w->fonts_data) {
PyErr_SetString(PyExc_KeyError, "OS Window with specified id does not exist or has no fonts data");
@ -3256,7 +3257,7 @@ static PyMethodDef module_methods[] = {
{"create_os_window", (PyCFunction)(void (*) (void))(create_os_window), METH_VARARGS | METH_KEYWORDS, NULL},
{"start_drag_with_data", (PyCFunction)(void (*) (void))(start_drag_with_data), METH_VARARGS | METH_KEYWORDS, NULL},
METHODB(change_drag_thumbnail, METH_VARARGS),
METHODB(draw_single_line_of_text, METH_VARARGS),
{"draw_single_line_of_text", (PyCFunction)(void (*) (void))(draw_single_line_of_text), METH_VARARGS | METH_KEYWORDS, NULL},
METHODB(set_default_window_icon, METH_VARARGS),
METHODB(set_os_window_icon, METH_VARARGS),
METHODB(set_clipboard_data_types, METH_VARARGS),

View file

@ -1321,7 +1321,7 @@ def drag_url(self, url: str, hyperlink_id: int) -> None:
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, width = 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, max_width=True)
height = len(pixels) // (width * 4)
thumbnails = ((pixels, width, height),)
drag_data = {'text/uri-list': (url + '\r\n').encode()}