Rename wrap setting to word_wrap

This commit is contained in:
Jeremy Soller 2023-11-01 09:44:11 -06:00
parent 27523ef3ea
commit 621e9d75eb
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
4 changed files with 12 additions and 10 deletions

View file

@ -39,7 +39,7 @@ impl KeyBind {
bind!(CTRL, O, OpenFileDialog); bind!(CTRL, O, OpenFileDialog);
bind!(CTRL, S, Save); bind!(CTRL, S, Save);
bind!(CTRL, Q, Quit); bind!(CTRL, Q, Quit);
bind!(ALT, Z, ToggleWrap); bind!(ALT, Z, ToggleWordWrap);
keybinds keybinds
} }
@ -65,7 +65,7 @@ impl fmt::Display for KeyBind {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Config { pub struct Config {
pub wrap: bool, pub word_wrap: bool,
pub keybinds: HashMap<KeyBind, Message>, pub keybinds: HashMap<KeyBind, Message>,
} }
@ -73,7 +73,7 @@ impl Config {
//TODO: load from cosmic-config //TODO: load from cosmic-config
pub fn load() -> Self { pub fn load() -> Self {
Self { Self {
wrap: false, word_wrap: false,
keybinds: KeyBind::load(), keybinds: KeyBind::load(),
} }
} }

View file

@ -86,7 +86,7 @@ pub enum Message {
TabActivate(segmented_button::Entity), TabActivate(segmented_button::Entity),
TabClose(segmented_button::Entity), TabClose(segmented_button::Entity),
Todo, Todo,
ToggleWrap, ToggleWordWrap,
} }
impl App { impl App {
@ -539,8 +539,8 @@ impl cosmic::Application for App {
Message::Todo => { Message::Todo => {
log::warn!("TODO"); log::warn!("TODO");
} }
Message::ToggleWrap => { Message::ToggleWordWrap => {
self.config.wrap = !self.config.wrap; self.config.word_wrap = !self.config.word_wrap;
//TODO: provide iterator over data //TODO: provide iterator over data
let entities: Vec<_> = self.tab_model.iter().collect(); let entities: Vec<_> = self.tab_model.iter().collect();
for entity in entities { for entity in entities {

View file

@ -152,7 +152,7 @@ pub fn menu_bar<'a>(config: &Config) -> Element<'a, Message> {
], ],
), ),
MenuTree::new(horizontal_rule(1)), MenuTree::new(horizontal_rule(1)),
menu_checkbox(fl!("word-wrap"), config.wrap, Message::ToggleWrap), menu_checkbox(fl!("word-wrap"), config.word_wrap, Message::ToggleWordWrap),
menu_checkbox(fl!("show-line-numbers"), false, Message::Todo), menu_checkbox(fl!("show-line-numbers"), false, Message::Todo),
menu_checkbox(fl!("highlight-current-line"), false, Message::Todo), menu_checkbox(fl!("highlight-current-line"), false, Message::Todo),
menu_item(fl!("syntax-highlighting"), Message::Todo), menu_item(fl!("syntax-highlighting"), Message::Todo),

View file

@ -45,9 +45,11 @@ impl Tab {
let mut editor = self.editor.lock().unwrap(); let mut editor = self.editor.lock().unwrap();
let mut font_system = FONT_SYSTEM.lock().unwrap(); let mut font_system = FONT_SYSTEM.lock().unwrap();
let mut editor = editor.borrow_with(&mut font_system); let mut editor = editor.borrow_with(&mut font_system);
editor editor.buffer_mut().set_wrap(if config.word_wrap {
.buffer_mut() Wrap::Word
.set_wrap(if config.wrap { Wrap::Word } else { Wrap::None }); } else {
Wrap::None
});
} }
pub fn open(&mut self, path: PathBuf) { pub fn open(&mut self, path: PathBuf) {