From 60b3ccc64115fb7e4b303eb1b93ba16d10fff1b5 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 14 Mar 2021 19:19:10 +0100 Subject: term: runtime switch between a ‘fast’ and a ‘generic’ ASCII print function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit term_print() is called whenever the client application “prints” something to the grid. It is called for both ASCII and UTF-8 characters, and needs to handle sixels, insert mode and ASCII vs. graphical charsets. Since it’s on the hot path, this becomes unnecessarily slow. This patch adds a “fast” version of term_print(), tailored for the common case: ASCII characters in non-insert mode, without any sixels and non-graphical charsets. A new function, term_update_ascii_printer(), has been added, and must be called whenever: * The currently selected charset *index* changes * The currently selected charset changes (from ASCII to graphical, or vice verse) * Sixels are added to the grid * Sixels are removed from the grid * Insert mode is enabled/disabled --- csi.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'csi.c') diff --git a/csi.c b/csi.c index 5b102f58..4f0814bf 100644 --- a/csi.c +++ b/csi.c @@ -1136,6 +1136,7 @@ csi_dispatch(struct terminal *term, uint8_t final) case 4: /* Insert Mode - IRM */ term->insert_mode = true; + term_update_ascii_printer(term); break; case 12: /* Send/receive Mode - SRM */ @@ -1156,6 +1157,7 @@ csi_dispatch(struct terminal *term, uint8_t final) switch (vt_param_get(term, 0, 0)) { case 4: /* Insert Mode - IRM */ term->insert_mode = false; + term_update_ascii_printer(term); break; case 2: /* Keyboard Action Mode - AM */ -- cgit v1.3 From d2711190326e19396dcf6f4fa21e41e8059c9ca2 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 16 Mar 2021 13:07:09 +0100 Subject: csi: update ASCII printer function pointer when switching to/from alt screen This is necessary since switching screen may change how many sixels we have in the scrollback. --- csi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'csi.c') diff --git a/csi.c b/csi.c index 4f0814bf..ec83f81e 100644 --- a/csi.c +++ b/csi.c @@ -546,6 +546,7 @@ decset_decrst(struct terminal *term, unsigned param, bool enable) tll_free(term->alt.scroll_damage); term_damage_all(term); } + term_update_ascii_printer(term); break; case 1070: -- cgit v1.3