Simplify highlight method for text_editor widget
This commit is contained in:
parent
1aa0a8fa0d
commit
16212eaf52
3 changed files with 31 additions and 23 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use iced::highlighter::{self, Highlighter};
|
||||
use iced::highlighter;
|
||||
use iced::keyboard;
|
||||
use iced::widget::{
|
||||
button, column, container, horizontal_space, pick_list, row, text,
|
||||
|
|
@ -186,18 +186,13 @@ impl Editor {
|
|||
text_editor(&self.content)
|
||||
.height(Fill)
|
||||
.on_action(Message::ActionPerformed)
|
||||
.highlight::<Highlighter>(
|
||||
highlighter::Settings {
|
||||
theme: self.theme,
|
||||
token: self
|
||||
.file
|
||||
.as_deref()
|
||||
.and_then(Path::extension)
|
||||
.and_then(ffi::OsStr::to_str)
|
||||
.map(str::to_string)
|
||||
.unwrap_or(String::from("rs")),
|
||||
},
|
||||
|highlight, _theme| highlight.to_format()
|
||||
.highlight(
|
||||
self.file
|
||||
.as_deref()
|
||||
.and_then(Path::extension)
|
||||
.and_then(ffi::OsStr::to_str)
|
||||
.unwrap_or("rs"),
|
||||
self.theme,
|
||||
),
|
||||
status,
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue