diff --git a/Cargo.lock b/Cargo.lock index 74f4a0d..37d59db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -865,7 +865,7 @@ dependencies = [ [[package]] name = "cosmic-text" version = "0.10.0" -source = "git+https://github.com/pop-os/cosmic-text?branch=vi-editor#c79c1326944c0a688e5c35015b834c18b53aa5c0" +source = "git+https://github.com/pop-os/cosmic-text?branch=vi-editor#9efcc41a5aca6df16a66da53aae75b1191ba0576" dependencies = [ "fontdb 0.15.0", "libm", @@ -2744,7 +2744,7 @@ dependencies = [ [[package]] name = "modit" version = "0.1.0" -source = "git+https://github.com/pop-os/modit.git#d44cd44692685c2972747ca465a81791887c2cdd" +source = "git+https://github.com/pop-os/modit.git#0bfedf9b11412b2f3612bdc5ffebcf882f88eb01" dependencies = [ "log", ] diff --git a/src/main.rs b/src/main.rs index 9714ba8..6f9f5fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,9 @@ use cosmic::{ }; use cosmic_text::{Cursor, Edit, Family, FontSystem, SwashCache, SyntaxSystem, ViMode}; use std::{ - env, fs, + env, + fmt::Write, + fs, path::{Path, PathBuf}, process, sync::Mutex, @@ -891,36 +893,42 @@ impl cosmic::Application for App { match self.active_tab() { Some(tab) => { - tab_column = - tab_column.push(text_box(&tab.editor, self.config.metrics()).padding(8)); - let status = match &tab.editor.lock().unwrap().parser().mode { - ViMode::Normal => String::new(), - ViMode::Insert => { - format!("-- INSERT --") - } - ViMode::Extra(extra) => { - format!("{}", extra) - } - ViMode::Replace => { - format!("-- REPLACE --") - } - ViMode::Visual => { - format!("-- VISUAL --") - } - ViMode::VisualLine => { - format!("-- VISUAL LINE --") - } - ViMode::Command { value } => { - format!(":{value}|") - } - ViMode::Search { value, forwards } => { - if *forwards { - format!("/{value}|") - } else { - format!("?{value}|") + let status = { + let editor = tab.editor.lock().unwrap(); + let parser = editor.parser(); + match &parser.mode { + ViMode::Normal => { + format!("{}", parser.cmd) + } + ViMode::Insert => { + format!("-- INSERT --") + } + ViMode::Extra(extra) => { + format!("{}{}", parser.cmd, extra) + } + ViMode::Replace => { + format!("-- REPLACE --") + } + ViMode::Visual => { + format!("-- VISUAL -- {}", parser.cmd) + } + ViMode::VisualLine => { + format!("-- VISUAL LINE -- {}", parser.cmd) + } + ViMode::Command { value } => { + format!(":{value}|") + } + ViMode::Search { value, forwards } => { + if *forwards { + format!("/{value}|") + } else { + format!("?{value}|") + } } } }; + tab_column = + tab_column.push(text_box(&tab.editor, self.config.metrics()).padding(8)); tab_column = tab_column.push(text(status).font(cosmic::font::Font::MONOSPACE)); } None => {