diff --git a/examples/editor-test/src/main.rs b/examples/editor-test/src/main.rs index ea859d5..12318ce 100644 --- a/examples/editor-test/src/main.rs +++ b/examples/editor-test/src/main.rs @@ -1,7 +1,8 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use cosmic_text::{ - Action, BorrowedWithFontSystem, Buffer, Color, Edit, Editor, FontSystem, Metrics, SwashCache, + Action, BidiParagraphs, BorrowedWithFontSystem, Buffer, Color, Edit, Editor, FontSystem, + Metrics, SwashCache, }; use orbclient::{EventOption, Renderer, Window, WindowFlag}; use std::{env, fs, process, time::Instant}; @@ -84,7 +85,7 @@ fn main() { let test_start = Instant::now(); //TODO: support bidi - for line in text.lines() { + for line in BidiParagraphs::new(&text) { log::debug!("Line {:?}", line); for grapheme in line.graphemes(true) { diff --git a/src/buffer.rs b/src/buffer.rs index 7ddd20d..0807911 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -9,8 +9,8 @@ use core::{cmp, fmt}; use unicode_segmentation::UnicodeSegmentation; use crate::{ - Attrs, AttrsList, BorrowedWithFontSystem, BufferLine, Color, FontSystem, LayoutGlyph, - LayoutLine, ShapeLine, Shaping, Wrap, + Attrs, AttrsList, BidiParagraphs, BorrowedWithFontSystem, BufferLine, Color, FontSystem, + LayoutGlyph, LayoutLine, ShapeLine, Shaping, Wrap, }; /// Current cursor location @@ -580,7 +580,7 @@ impl Buffer { shaping: Shaping, ) { self.lines.clear(); - for line in text.lines() { + for line in BidiParagraphs::new(text) { self.lines.push(BufferLine::new( line.to_string(), AttrsList::new(attrs),