Update cosmic-text to allow for line selection

This commit is contained in:
Jeremy Soller 2023-11-28 10:45:40 -07:00
parent 94fe82f38e
commit 3ba99aaab5
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
3 changed files with 155 additions and 70 deletions

View file

@ -15,7 +15,7 @@ use cosmic::{
widget::{self, button, icon, nav_bar, segmented_button, view_switcher},
Application, ApplicationExt, Apply, Element,
};
use cosmic_text::{Cursor, Edit, Family, FontSystem, SwashCache, SyntaxSystem, ViMode};
use cosmic_text::{Cursor, Edit, Family, FontSystem, Selection, SwashCache, SyntaxSystem, ViMode};
use std::{
any::TypeId,
env, fs,
@ -889,7 +889,7 @@ impl Application for App {
let buffer = editor.buffer();
let last_line = buffer.lines.len().saturating_sub(1);
let last_index = buffer.lines[last_line].text().len();
editor.set_select_opt(Some(Cursor::new(last_line, last_index)));
editor.set_selection(Selection::Normal(Cursor::new(last_line, last_index)));
}
None => {}
}

View file

@ -350,7 +350,16 @@ where
image_color |= (color.0 & 0x00FF0000) >> 16;
// Shift blue channel
image_color |= (color.0 & 0x000000FF) << 16;
draw_rect(buffer, image_w, image_h, x, y, w as i32, h as i32, image_color);
draw_rect(
buffer,
image_w,
image_h,
x,
y,
w as i32,
h as i32,
image_color,
);
},
);