diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c6b37f..d476ae7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Procedure when bumping the version number: ### Added - `help-config` CLI command +- `measure_widths` config option ### Changed - Simplified flake dependencies diff --git a/cove-config/src/lib.rs b/cove-config/src/lib.rs index 04b75bb..1f17988 100644 --- a/cove-config/src/lib.rs +++ b/cove-config/src/lib.rs @@ -90,6 +90,18 @@ pub struct Config { #[document(default = "`false`")] pub ephemeral: bool, + /// Whether to measure the width of characters as displayed by the terminal + /// emulator instead of guessing the width. + /// + /// Enabling this makes rendering a bit slower but more accurate. The screen + /// might also flash when encountering new characters (or, more accurately, + /// graphemes). + /// + /// See also the `--measure-graphemes` command line option. + #[serde(default)] + #[document(default = "`false`")] + pub measure_widths: bool, + /// Whether to start in offline mode. /// /// In offline mode, cove won't automatically join rooms marked via the diff --git a/cove/src/main.rs b/cove/src/main.rs index 72526b5..0c99ee4 100644 --- a/cove/src/main.rs +++ b/cove/src/main.rs @@ -120,6 +120,7 @@ fn update_config_with_args(config: &mut Config, args: &Args) { } config.ephemeral |= args.ephemeral; + config.measure_widths |= args.measure_widths; config.offline |= args.offline; } @@ -150,7 +151,7 @@ async fn main() -> anyhow::Result<()> { let config = Box::leak(Box::new(config)); match args.command.unwrap_or_default() { - Command::Run => run(logger, logger_rx, config, &dirs, args.measure_widths).await?, + Command::Run => run(logger, logger_rx, config, &dirs).await?, Command::Export(args) => export(config, &dirs, args).await?, Command::Gc => gc(config, &dirs).await?, Command::ClearCookies => clear_cookies(config, &dirs).await?, @@ -171,7 +172,6 @@ async fn run( logger_rx: mpsc::UnboundedReceiver<()>, config: &'static Config, dirs: &ProjectDirs, - measure_widths: bool, ) -> anyhow::Result<()> { info!( "Welcome to {} {}", @@ -182,7 +182,7 @@ async fn run( let vault = open_vault(config, dirs)?; let mut terminal = Terminal::new()?; - terminal.set_measuring(measure_widths); + terminal.set_measuring(config.measure_widths); Ui::run(config, &mut terminal, vault.clone(), logger, logger_rx).await?; drop(terminal);