From ae19f2b4e4cbc4f217c42bac7841665a95b0e119 Mon Sep 17 00:00:00 2001 From: graelo Date: Tue, 23 Mar 2021 08:38:12 +0100 Subject: [PATCH] fix: tmux options read correctly --- src/config/basic.rs | 8 +++++--- src/config/extended.rs | 18 ++++-------------- src/tmux.rs | 4 ++-- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/config/basic.rs b/src/config/basic.rs index 993936e..785a0fa 100644 --- a/src/config/basic.rs +++ b/src/config/basic.rs @@ -83,10 +83,12 @@ impl FromStr for HintStyleArg { fn from_str(s: &str) -> Result { match s { - "leading" => Ok(HintStyleArg::Underline), - "trailing" => Ok(HintStyleArg::Surround), + "bold" => Ok(HintStyleArg::Bold), + "italic" => Ok(HintStyleArg::Italic), + "underline" => Ok(HintStyleArg::Underline), + "surrond" => Ok(HintStyleArg::Surround), _ => Err(error::ParseError::ExpectedString(String::from( - "underline or surround", + "bold, italic, underline or surround", ))), } } diff --git a/src/config/extended.rs b/src/config/extended.rs index 9c545f6..1b3686d 100644 --- a/src/config/extended.rs +++ b/src/config/extended.rs @@ -4,11 +4,7 @@ use std::fmt; use std::str::FromStr; use super::basic; -use crate::{ - error, - textbuf::{alphabet, regexes}, - tmux, ui, -}; +use crate::{error, textbuf::alphabet, tmux, ui}; /// Extended configuration for handling Tmux-specific configuration (options /// and outputs). This is only used by `tmux-copyrat` and parsed from command @@ -61,18 +57,12 @@ impl ConfigExt { for (name, value) in &tmux_options { match name.as_ref() { - "@copyrat-capture" => { + "@copyrat-capture-region" => { config_ext.capture_region = CaptureRegion::from_str(&value)? } "@copyrat-alphabet" => { wrapped.alphabet = alphabet::parse_alphabet(value)?; } - "@copyrat-pattern-name" => { - wrapped.named_patterns = vec![regexes::parse_pattern_name(value)?] - } - "@copyrat-custom-pattern" => { - wrapped.custom_patterns = vec![String::from(value)] - } "@copyrat-reverse" => { wrapped.reverse = value.parse::()?; } @@ -127,8 +117,8 @@ impl FromStr for CaptureRegion { fn from_str(s: &str) -> Result { match s { - "leading" => Ok(CaptureRegion::EntireHistory), - "trailing" => Ok(CaptureRegion::VisibleArea), + "entire-history" => Ok(CaptureRegion::EntireHistory), + "visible-area" => Ok(CaptureRegion::VisibleArea), _ => Err(error::ParseError::ExpectedString(String::from( "entire-history or visible-area", ))), diff --git a/src/tmux.rs b/src/tmux.rs index b87375a..fc15719 100644 --- a/src/tmux.rs +++ b/src/tmux.rs @@ -141,10 +141,10 @@ pub fn list_panes() -> Result, ParseError> { /// # Example /// ```get_options("@copyrat-")``` pub fn get_options(prefix: &str) -> Result, ParseError> { - let output = duct::cmd!("tmux", "show", "-g").read()?; + let output = duct::cmd!("tmux", "show-options", "-g").read()?; let lines: Vec<&str> = output.split('\n').collect(); - let pattern = format!(r#"{prefix}([\w\-0-9]+) "?(\w+)"?"#, prefix = prefix); + let pattern = format!(r#"({prefix}[\w\-0-9]+) "?(\w+)"?"#, prefix = prefix); let re = Regex::new(&pattern).unwrap(); let args: HashMap = lines