Simplify editor example
This commit is contained in:
parent
4e757a26d0
commit
06dc12bfbf
1 changed files with 6 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ use iced::widget::{
|
||||||
button, column, container, horizontal_space, pick_list, row, text,
|
button, column, container, horizontal_space, pick_list, row, text,
|
||||||
text_editor, tooltip,
|
text_editor, tooltip,
|
||||||
};
|
};
|
||||||
use iced::{Application, Command, Element, Font, Length, Settings};
|
use iced::{Alignment, Application, Command, Element, Font, Length, Settings};
|
||||||
|
|
||||||
use highlighter::Highlighter;
|
use highlighter::Highlighter;
|
||||||
|
|
||||||
|
|
@ -169,7 +169,8 @@ impl Application for Editor {
|
||||||
.text_size(14)
|
.text_size(14)
|
||||||
.padding([5, 10])
|
.padding([5, 10])
|
||||||
]
|
]
|
||||||
.spacing(10);
|
.spacing(10)
|
||||||
|
.align_items(Alignment::Center);
|
||||||
|
|
||||||
let status = row![
|
let status = row![
|
||||||
text(if let Some(path) = &self.file {
|
text(if let Some(path) = &self.file {
|
||||||
|
|
@ -275,8 +276,7 @@ fn action<'a, Message: Clone + 'a>(
|
||||||
label: &'a str,
|
label: &'a str,
|
||||||
on_press: Option<Message>,
|
on_press: Option<Message>,
|
||||||
) -> Element<'a, Message> {
|
) -> Element<'a, Message> {
|
||||||
let action =
|
let action = button(container(content).width(30).center_x());
|
||||||
button(container(content).width(Length::Fill).center_x()).width(40);
|
|
||||||
|
|
||||||
if let Some(on_press) = on_press {
|
if let Some(on_press) = on_press {
|
||||||
tooltip(
|
tooltip(
|
||||||
|
|
@ -316,7 +316,7 @@ mod highlighter {
|
||||||
|
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use syntect::highlighting;
|
use syntect::highlighting;
|
||||||
use syntect::parsing::{self, SyntaxReference};
|
use syntect::parsing;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
|
|
@ -374,7 +374,7 @@ mod highlighter {
|
||||||
|
|
||||||
pub struct Highlighter {
|
pub struct Highlighter {
|
||||||
syntaxes: parsing::SyntaxSet,
|
syntaxes: parsing::SyntaxSet,
|
||||||
syntax: SyntaxReference,
|
syntax: parsing::SyntaxReference,
|
||||||
theme: highlighting::Theme,
|
theme: highlighting::Theme,
|
||||||
caches: Vec<(parsing::ParseState, parsing::ScopeStack)>,
|
caches: Vec<(parsing::ParseState, parsing::ScopeStack)>,
|
||||||
current_line: usize,
|
current_line: usize,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue