Ensure cursor is correctly positioned after emoji presentation char + VS15
cursor should be on the cell immediately after the the char since the variation selector makes the char one cell wide.
This commit is contained in:
parent
fe882dad15
commit
529337e00a
@ -373,6 +373,19 @@ draw_combining_char(Screen *self, char_type ch) {
|
||||
if (xpos == self->columns - 1) move_widened_char(self, cpu_cell, gpu_cell, xpos, ypos);
|
||||
else self->cursor->x++;
|
||||
}
|
||||
} else if (ch == 0xfe0e) {
|
||||
CPUCell *cpu_cell = self->linebuf->line->cpu_cells + xpos;
|
||||
GPUCell *gpu_cell = self->linebuf->line->gpu_cells + xpos;
|
||||
if ((gpu_cell->attrs & WIDTH_MASK) == 0 && cpu_cell->ch == 0 && xpos > 0) {
|
||||
xpos--;
|
||||
if (self->cursor->x > 0) self->cursor->x--;
|
||||
cpu_cell = self->linebuf->line->cpu_cells + xpos;
|
||||
gpu_cell = self->linebuf->line->gpu_cells + xpos;
|
||||
}
|
||||
|
||||
if ((gpu_cell->attrs & WIDTH_MASK) == 2 && cpu_cell->cc_idx[0] == VS15 && is_emoji_presentation_base(cpu_cell->ch)) {
|
||||
gpu_cell->attrs = (gpu_cell->attrs & !WIDTH_MASK) | 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,6 +429,20 @@ class TestScreen(BaseTest):
|
||||
s.scroll(2, True)
|
||||
self.ae(s.text_for_selection(), expected)
|
||||
|
||||
def test_variation_selectors(self):
|
||||
s = self.create_screen()
|
||||
s.draw('\U0001f610')
|
||||
self.ae(s.cursor.x, 2)
|
||||
s.carriage_return(), s.linefeed()
|
||||
s.draw('\U0001f610\ufe0e')
|
||||
self.ae(s.cursor.x, 1)
|
||||
s.carriage_return(), s.linefeed()
|
||||
s.draw('\u25b6')
|
||||
self.ae(s.cursor.x, 1)
|
||||
s.carriage_return(), s.linefeed()
|
||||
s.draw('\u25b6\ufe0f')
|
||||
self.ae(s.cursor.x, 2)
|
||||
|
||||
def test_serialize(self):
|
||||
s = self.create_screen()
|
||||
s.draw('ab' * s.columns)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user