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 --- terminal.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index 0fcd97ea..044fc581 100644 --- a/terminal.h +++ b/terminal.h @@ -266,6 +266,8 @@ struct terminal { struct reaper *reaper; const struct config *conf; + void (*ascii_printer)(struct terminal *term, wchar_t c); + pid_t slave; int ptmx; @@ -607,6 +609,8 @@ struct terminal *term_init( bool term_shutdown(struct terminal *term); int term_destroy(struct terminal *term); +void term_update_ascii_printer(struct terminal *term); + void term_reset(struct terminal *term, bool hard); bool term_to_slave(struct terminal *term, const void *data, size_t len); bool term_paste_data_to_slave( -- cgit v1.3