mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
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:
parent
d8f0e701b5
commit
60b3ccc641
5 changed files with 84 additions and 16 deletions
7
sixel.c
7
sixel.c
|
|
@ -331,6 +331,7 @@ sixel_scroll_up(struct terminal *term, int rows)
|
|||
}
|
||||
}
|
||||
|
||||
term_update_ascii_printer(term);
|
||||
verify_sixels(term);
|
||||
}
|
||||
|
||||
|
|
@ -353,6 +354,7 @@ sixel_scroll_down(struct terminal *term, int rows)
|
|||
break;
|
||||
}
|
||||
|
||||
term_update_ascii_printer(term);
|
||||
verify_sixels(term);
|
||||
}
|
||||
|
||||
|
|
@ -552,6 +554,8 @@ sixel_overwrite_by_rectangle(
|
|||
_sixel_overwrite_by_rectangle(term, 0, col, height - rows_to_wrap_around, width);
|
||||
} else
|
||||
_sixel_overwrite_by_rectangle(term, start, col, height, width);
|
||||
|
||||
term_update_ascii_printer(term);
|
||||
}
|
||||
|
||||
/* Row numbers are relative to grid offset */
|
||||
|
|
@ -605,6 +609,8 @@ sixel_overwrite_by_row(struct terminal *term, int _row, int col, int width)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
term_update_ascii_printer(term);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -859,6 +865,7 @@ sixel_unhook(struct terminal *term)
|
|||
LOG_DBG("you now have %zu sixels in current grid",
|
||||
tll_length(term->grid->sixel_images));
|
||||
|
||||
term_update_ascii_printer(term);
|
||||
render_refresh(term);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue