summaryrefslogtreecommitdiff
path: root/src/core.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.h')
-rw-r--r--src/core.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/core.h b/src/core.h
index 79e6eb9..aab2cde 100644
--- a/src/core.h
+++ b/src/core.h
@@ -30,6 +30,39 @@ static inline void sc_print_ascii(struct term *t, const char *s, int n);
/* Print one glyph (single codepoint or cluster handle). */
void term_sc_print_glyph(struct term *t, uint32_t cp, int width, uint16_t flags);
+static inline void sc_print_cell(struct term *t, uint32_t cp, int width, uint16_t flags)
+{
+ if (TERM_EXPECT(width == 1 && !t->pending_wrap && !t->insert_mode &&
+ !t->lr_margin_mode && t->cursor_x < t->cols, 1)) {
+ struct srow *srow = term_row(t, t->cursor_y);
+ int cx = t->cursor_x;
+ int len = srow->len;
+ if (TERM_EXPECT(srow->kind == ROW_CELLS && cx <= len, 1)) {
+ struct cell *row = srow->cells;
+ if (TERM_EXPECT(!((cx < len && (row[cx].flags & CELL_TRAIL)) ||
+ (cx + 1 < len && (row[cx + 1].flags & CELL_TRAIL))), 1)) {
+ row[cx] = (struct cell){cp,
+ t->inverse ? t->cur_bg : t->cur_fg,
+ t->inverse ? t->cur_fg : t->cur_bg,
+ flags, t->cur_link};
+ t->last_char = cp;
+ cx++;
+ if (cx > len) srow->len = (uint16_t)cx;
+ srow->version++;
+ if (cx < t->cols) {
+ t->cursor_x = cx;
+ t->pending_wrap = false;
+ } else {
+ t->cursor_x = t->cols - 1;
+ t->pending_wrap = t->autowrap;
+ }
+ return;
+ }
+ }
+ }
+ term_sc_print_glyph(t, cp, width, flags);
+}
+
/* Extend the last printed glyph into a grapheme cluster. */
bool term_sc_extend_cluster(struct term *t, uint32_t cp, int klass);