Add LEFT‑TO‑RIGHT ISOLATE character to the beginning of lines

This zero-width char will force the shaper to treat detected RTL
 lines as LTR.

 RTL text would still be rendered correctly. But this fixes the wrong
 behavior of it being displayed aligned to the right.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
Mohammad AlSaleh 2024-01-11 02:31:28 +03:00 committed by Jeremy Soller
parent b161db94d1
commit 0eea366410

View file

@ -433,6 +433,12 @@ impl Terminal {
}
pub fn update(&mut self) -> bool {
// LEFTTORIGHT ISOLATE character.
// This will be added to the beginning of lines to force the shaper to treat detected RTL
// lines as LTR. RTL text would still be rendered correctly. But this fixes the wrong
// behavior of it being aligned to the right.
const LRI:char = '\u{2066}';
let instant = Instant::now();
//TODO: is redraw needed after all events?
@ -442,7 +448,7 @@ impl Terminal {
let mut line_i = 0;
let mut last_point = None;
let mut text = String::new();
let mut text = String::from(LRI);
let mut attrs_list = AttrsList::new(self.default_attrs);
{
let term = self.term.lock();
@ -464,6 +470,7 @@ impl Terminal {
line_i += 1;
text.clear();
text.push(LRI);
attrs_list.clear_spans();
}
//TODO: use indexed.point.column?