term: runtime switch between a ‘fast’ and a ‘generic’ ASCII print function

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
This commit is contained in:
Daniel Eklöf 2021-03-14 19:19:10 +01:00
parent d8f0e701b5
commit 60b3ccc641
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 84 additions and 16 deletions

View file

@ -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(