Added an enum with the option for "No Wraping"
This commit is contained in:
parent
48087b592b
commit
b9fef72f76
7 changed files with 169 additions and 96 deletions
|
|
@ -32,6 +32,7 @@ use cosmic_text::{
|
|||
Metrics,
|
||||
SyntaxEditor,
|
||||
SyntaxSystem,
|
||||
Wrap,
|
||||
};
|
||||
use std::{
|
||||
env,
|
||||
|
|
@ -60,6 +61,12 @@ static FONT_SIZES: &'static [Metrics] = &[
|
|||
Metrics::new(32, 44), // Title 1
|
||||
];
|
||||
|
||||
static WRAP_MODE: &'static [Wrap] = & [
|
||||
Wrap::None,
|
||||
Wrap::Glyph,
|
||||
Wrap::Word,
|
||||
];
|
||||
|
||||
fn main() -> cosmic::iced::Result {
|
||||
env_logger::init();
|
||||
|
||||
|
|
@ -87,6 +94,7 @@ pub enum Message {
|
|||
Italic(bool),
|
||||
Monospaced(bool),
|
||||
MetricsChanged(Metrics),
|
||||
WrapChanged(Wrap),
|
||||
ThemeChanged(&'static str),
|
||||
}
|
||||
|
||||
|
|
@ -213,6 +221,10 @@ impl Application for Window {
|
|||
let mut editor = self.editor.lock().unwrap();
|
||||
editor.buffer_mut().set_metrics(metrics);
|
||||
},
|
||||
Message::WrapChanged(wrap) => {
|
||||
let mut editor = self.editor.lock().unwrap();
|
||||
editor.buffer_mut().set_wrap(wrap);
|
||||
},
|
||||
Message::ThemeChanged(theme) => {
|
||||
self.theme = match theme {
|
||||
"Dark" => Theme::Dark,
|
||||
|
|
@ -252,6 +264,15 @@ impl Application for Window {
|
|||
)
|
||||
};
|
||||
|
||||
let wrap_picker = {
|
||||
let editor = self.editor.lock().unwrap();
|
||||
pick_list(
|
||||
WRAP_MODE,
|
||||
Some(editor.buffer().wrap()),
|
||||
Message::WrapChanged,
|
||||
)
|
||||
};
|
||||
|
||||
let content: Element<_> = column![
|
||||
row![
|
||||
button(theme::Button::Secondary)
|
||||
|
|
@ -271,6 +292,8 @@ impl Application for Window {
|
|||
theme_picker,
|
||||
text("Font Size:"),
|
||||
font_size_picker,
|
||||
text("Wrap:"),
|
||||
wrap_picker,
|
||||
]
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(8)
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ where
|
|||
let layout_lines = shape.layout(
|
||||
self.metrics.font_size,
|
||||
limits.max().width as i32,
|
||||
self.line.wrap_simple()
|
||||
self.line.wrap()
|
||||
);
|
||||
|
||||
let mut width = 0;
|
||||
|
|
@ -180,7 +180,7 @@ where
|
|||
let layout_lines = shape.layout(
|
||||
self.metrics.font_size,
|
||||
layout_w,
|
||||
self.line.wrap_simple()
|
||||
self.line.wrap()
|
||||
);
|
||||
|
||||
let mut cache = state.cache.lock().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue