Do delete test using EGCs

This commit is contained in:
Jeremy Soller 2022-10-25 10:17:09 -06:00
parent cc68315a3f
commit c5e9412673
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
2 changed files with 18 additions and 14 deletions

View file

@ -12,6 +12,7 @@ env_logger = "0.9"
fontdb = "0.9"
log = "0.4"
orbclient = "0.3.35"
unicode-segmentation = "1.7"
[features]
mono = []

View file

@ -3,6 +3,7 @@
use cosmic_text::{FontSystem, TextAction, TextBuffer, TextMetrics};
use orbclient::{Color, EventOption, Renderer, Window, WindowFlag};
use std::{env, fs, process, thread, time::{Duration, Instant}};
use unicode_segmentation::UnicodeSegmentation;
fn redraw(window: &mut Window, buffer: &mut TextBuffer<'_>) {
let bg_color = Color::rgb(0x34, 0x34, 0x34);
@ -109,30 +110,32 @@ fn main() {
for line in text.lines() {
log::debug!("Line {:?}", line);
for c in line.chars() {
log::trace!("Insert {:?}", c);
for grapheme in line.graphemes(true) {
for c in grapheme.chars() {
log::trace!("Insert {:?}", c);
// Test backspace of character
{
let cursor = buffer.cursor();
// Test backspace of character
{
let cursor = buffer.cursor();
buffer.action(TextAction::Insert(c));
buffer.action(TextAction::Backspace);
assert_eq!(cursor, buffer.cursor());
}
// Finally, normal insert of character
buffer.action(TextAction::Insert(c));
buffer.action(TextAction::Backspace);
assert_eq!(cursor, buffer.cursor());
}
/*TODO: Delete will remove whole EGC
// Test delete of character
// Test delete of EGC
{
let cursor = buffer.cursor();
buffer.action(TextAction::Insert(c));
buffer.action(TextAction::Previous);
buffer.action(TextAction::Delete);
for c in grapheme.chars() {
buffer.action(TextAction::Insert(c));
}
assert_eq!(cursor, buffer.cursor());
}
*/
// Finally, normal insert of character
buffer.action(TextAction::Insert(c));
}
// Test backspace of newline