Remove monospaced from attrs
This commit is contained in:
parent
521acb64e0
commit
3c7dc1f657
5 changed files with 17 additions and 29 deletions
|
|
@ -131,9 +131,7 @@ impl Application for Window {
|
|||
type Theme = Theme;
|
||||
|
||||
fn new(_flags: ()) -> (Self, Command<Self::Message>) {
|
||||
let attrs = cosmic_text::Attrs::new()
|
||||
.monospaced(true)
|
||||
.family(cosmic_text::Family::Monospace);
|
||||
let attrs = cosmic_text::Attrs::new().family(cosmic_text::Family::Monospace);
|
||||
|
||||
let mut editor = SyntaxEditor::new(
|
||||
Buffer::new(
|
||||
|
|
@ -225,14 +223,11 @@ impl Application for Window {
|
|||
update_attrs(&mut *editor, self.attrs);
|
||||
}
|
||||
Message::Monospaced(monospaced) => {
|
||||
self.attrs = self
|
||||
.attrs
|
||||
.family(if monospaced {
|
||||
cosmic_text::Family::Monospace
|
||||
} else {
|
||||
cosmic_text::Family::SansSerif
|
||||
})
|
||||
.monospaced(monospaced);
|
||||
self.attrs = self.attrs.family(if monospaced {
|
||||
cosmic_text::Family::Monospace
|
||||
} else {
|
||||
cosmic_text::Family::SansSerif
|
||||
});
|
||||
|
||||
let mut editor = self.editor.lock().unwrap();
|
||||
update_attrs(&mut *editor, self.attrs);
|
||||
|
|
@ -331,7 +326,11 @@ impl Application for Window {
|
|||
Message::Italic
|
||||
),
|
||||
text("Monospaced:"),
|
||||
toggler(None, self.attrs.monospaced, Message::Monospaced),
|
||||
toggler(
|
||||
None,
|
||||
self.attrs.family == cosmic_text::Family::Monospace,
|
||||
Message::Monospaced
|
||||
),
|
||||
text("Theme:"),
|
||||
theme_picker,
|
||||
text("Font Size:"),
|
||||
|
|
|
|||
|
|
@ -227,7 +227,9 @@ where
|
|||
|
||||
// Scale metrics
|
||||
let metrics = editor.buffer().metrics();
|
||||
editor.buffer_mut().set_metrics(metrics.scale(style.scale_factor as f32));
|
||||
editor
|
||||
.buffer_mut()
|
||||
.set_metrics(metrics.scale(style.scale_factor as f32));
|
||||
|
||||
// Set size
|
||||
editor.buffer_mut().set_size(image_w as f32, image_h as f32);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ fn main() {
|
|||
.buffer_mut()
|
||||
.set_size(window.width() as f32 - line_x * 2.0, window.height() as f32);
|
||||
|
||||
let attrs = Attrs::new().monospaced(true).family(Family::Monospace);
|
||||
let attrs = Attrs::new().family(Family::Monospace);
|
||||
match editor.load_text(&path, attrs) {
|
||||
Ok(()) => (),
|
||||
Err(err) => {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ fn main() {
|
|||
|
||||
let attrs = Attrs::new();
|
||||
let serif_attrs = attrs.family(Family::Serif);
|
||||
let mono_attrs = attrs.monospaced(true).family(Family::Monospace);
|
||||
let mono_attrs = attrs.family(Family::Monospace);
|
||||
let comic_attrs = attrs.family(Family::Name("Comic Neue"));
|
||||
|
||||
editor.buffer_mut().lines.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue