Removed alignment from Buffer, added alignment per Bufferline to editor-libcosmic

This commit is contained in:
Hojjat 2023-02-23 14:23:56 -07:00
parent 4e7e1cc79e
commit d313713f44
4 changed files with 25 additions and 34 deletions

View file

@ -205,7 +205,7 @@ impl Application for Window {
}
Message::AlignmentChanged(align) => {
let mut editor = self.editor.lock().unwrap();
editor.buffer_mut().set_align(align);
update_alignment(&mut *editor, align);
}
Message::ThemeChanged(theme) => {
self.theme = match theme {
@ -324,3 +324,10 @@ fn update_attrs<'a, T: Edit<'a>>(editor: &mut T, attrs: Attrs<'a>) {
line.set_attrs_list(AttrsList::new(attrs));
});
}
fn update_alignment<'a, T: Edit<'a>>(editor: &mut T, align: Align) {
let current_line = editor.cursor().line;
if let Some(line) = editor.buffer_mut().lines.get_mut(current_line) {
line.set_align(align);
}
}