diff --git a/kitty/line.c b/kitty/line.c index 06d9709bdda..8463096d5b0 100644 --- a/kitty/line.c +++ b/kitty/line.c @@ -647,15 +647,6 @@ line_get_char(Line *self, index_type at) { return ch; } -void -line_set_printable_ascii_chars(Line *self, unsigned int at, const uint8_t *chars, unsigned num, GPUCell g, CPUCell cc) { - for (unsigned i = at; i < at + num; i++, chars++) { - cc.ch = *chars; - self->gpu_cells[i] = g; - self->cpu_cells[i] = cc; - } -} - void line_set_char(Line *self, unsigned int at, uint32_t ch, unsigned int width, Cursor *cursor, hyperlink_id_type hyperlink_id) { GPUCell *g = self->gpu_cells + at; diff --git a/kitty/lineops.h b/kitty/lineops.h index b9d6df08138..22dc9e8b5eb 100644 --- a/kitty/lineops.h +++ b/kitty/lineops.h @@ -86,7 +86,6 @@ void line_clear_text(Line *self, unsigned int at, unsigned int num, char_type ch void line_apply_cursor(Line *self, Cursor *cursor, unsigned int at, unsigned int num, bool clear_char); char_type line_get_char(Line *self, index_type at); void line_set_char(Line *, unsigned int , uint32_t , unsigned int , Cursor *, hyperlink_id_type); -void line_set_printable_ascii_chars(Line *self, unsigned int at, const uint8_t *chars, unsigned num, GPUCell g, CPUCell cc); void line_right_shift(Line *, unsigned int , unsigned int ); void line_add_combining_char(Line *, uint32_t , unsigned int ); index_type line_url_start_at(Line *self, index_type x); diff --git a/kitty/screen.c b/kitty/screen.c index 1445cb175dc..6101d165ce9 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -661,7 +661,7 @@ screen_draw_printable_ascii(Screen *self, const uint8_t *chars, size_t num) { screen_on_input(self); self->last_graphic_char = chars[num-1]; self->is_dirty = true; - CPUCell cc = {.hyperlink_id=self->active_hyperlink_id}; + const CPUCell cc = {.hyperlink_id=self->active_hyperlink_id}; GPUCell g = {.attrs=cursor_to_attrs(self->cursor, 1), .fg=self->cursor->fg & COL_MASK, .bg=self->cursor->bg & COL_MASK, .decoration_fg=self->cursor->decoration_fg & COL_MASK}; if (OPT(underline_hyperlinks) == UNDERLINE_ALWAYS && cc.hyperlink_id) { g.decoration_fg = ((OPT(url_color) & COL_MASK) << 8) | 2; @@ -671,8 +671,15 @@ screen_draw_printable_ascii(Screen *self, const uint8_t *chars, size_t num) { #define fill_single_line(chars, num) { \ linebuf_init_line(self->linebuf, self->cursor->y); \ if (self->modes.mIRM) line_right_shift(self->linebuf->line, self->cursor->x, num); \ - line_set_printable_ascii_chars(self->linebuf->line, self->cursor->x, chars, num, g, cc); \ - self->cursor->x += num; \ + const unsigned limit = self->cursor->x + num; \ + const uint8_t *p = chars; \ + GPUCell *gp = self->linebuf->line->gpu_cells; \ + CPUCell *cp = self->linebuf->line->cpu_cells; \ + for (; self->cursor->x < limit; self->cursor->x++, p++) { \ + gp[self->cursor->x] = g; \ + cp[self->cursor->x] = cc; \ + cp[self->cursor->x].ch = *p; \ + } \ if (selection_has_screen_line(&self->selections, self->cursor->y)) clear_selection(&self->selections); \ linebuf_mark_line_dirty(self->linebuf, self->cursor->y); \ } diff --git a/kitty/vt-parser.c b/kitty/vt-parser.c index 82964bad5f5..40f216416be 100644 --- a/kitty/vt-parser.c +++ b/kitty/vt-parser.c @@ -94,6 +94,9 @@ _report_params(PyObject *dump_callback, id_type window_id, const char *name, int #define REPORT_DRAW(ch) \ Py_XDECREF(PyObject_CallFunction(self->dump_callback, "KsC", self->window_id, "draw", ch)); PyErr_Clear(); +#define REPORT_DRAW_ASCII(ch, sz) \ + Py_XDECREF(PyObject_CallFunction(self->dump_callback, "Kss#", self->window_id, "draw", ch, (Py_ssize_t)sz)); PyErr_Clear(); + #define REPORT_PARAMS(name, params, num, is_group, region) _report_params(self->dump_callback, self->window_id, name, params, num_params, is_group, region) #define REPORT_OSC(name, string) \ @@ -110,6 +113,7 @@ _report_params(PyObject *dump_callback, id_type window_id, const char *name, int #define REPORT_COMMAND(...) #define REPORT_VA_COMMAND(...) #define REPORT_DRAW(ch) +#define REPORT_DRAW_ASCII(ch, sz) #define REPORT_PARAMS(...) #define REPORT_OSC(name, string) #define REPORT_OSC2(name, code, string) @@ -272,10 +276,9 @@ dispatch_normal_mode_byte(PS *self, uint8_t ch) { static void dispatch_printable_ascii(PS *self, const size_t sz) { - for (const size_t limit = self->read.pos + sz; self->read.pos < limit; self->read.pos++) { - REPORT_DRAW(self->buf[self->read.pos]); - screen_draw(self->screen, self->buf[self->read.pos]); - } + REPORT_DRAW_ASCII(self->buf + self->read.pos, sz); + screen_draw_printable_ascii(self->screen, self->buf + self->read.pos, sz); + self->read.pos += sz; } static void