replace use of str::lines with BidiParagraphs

This commit is contained in:
tigregalis 2023-05-08 18:12:36 +08:00
parent e298259dd5
commit 6e336ad1cd
2 changed files with 6 additions and 5 deletions

View file

@ -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) {

View file

@ -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),