SyntaxEditor: Allow retrieving syntax theme, optimize updates to theme

This commit is contained in:
Jeremy Soller 2023-11-02 12:55:45 -06:00
parent 241c4ca357
commit ac389d9eeb
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
2 changed files with 25 additions and 6 deletions

View file

@ -4,7 +4,7 @@ use unicode_segmentation::UnicodeSegmentation;
use crate::{
Action, AttrsList, BorrowedWithFontSystem, Buffer, Color, Cursor, Edit, FontSystem,
SyntaxEditor,
SyntaxEditor, SyntaxTheme,
};
#[derive(Clone, Debug, Eq, PartialEq)]
@ -37,6 +37,11 @@ impl<'a> ViEditor<'a> {
}
}
/// Modifies the theme of the [`SyntaxEditor`], returning false if the theme is missing
pub fn update_theme(&mut self, theme_name: &str) -> bool {
self.editor.update_theme(theme_name)
}
/// Load text from a file, and also set syntax to the best option
#[cfg(feature = "std")]
pub fn load_text<P: AsRef<std::path::Path>>(
@ -58,6 +63,11 @@ impl<'a> ViEditor<'a> {
self.editor.foreground_color()
}
/// Get the current syntect theme
pub fn theme(&self) -> &SyntaxTheme {
self.editor.theme()
}
/// Set passthrough mode (true will turn off vi features)
pub fn set_passthrough(&mut self, passthrough: bool) {
if passthrough != (self.mode == ViMode::Passthrough) {