mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +01:00
fix: tmux options read correctly
This commit is contained in:
parent
7ce0e95c8c
commit
ae19f2b4e4
3 changed files with 11 additions and 19 deletions
|
|
@ -83,10 +83,12 @@ impl FromStr for HintStyleArg {
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, error::ParseError> {
|
fn from_str(s: &str) -> Result<Self, error::ParseError> {
|
||||||
match s {
|
match s {
|
||||||
"leading" => Ok(HintStyleArg::Underline),
|
"bold" => Ok(HintStyleArg::Bold),
|
||||||
"trailing" => Ok(HintStyleArg::Surround),
|
"italic" => Ok(HintStyleArg::Italic),
|
||||||
|
"underline" => Ok(HintStyleArg::Underline),
|
||||||
|
"surrond" => Ok(HintStyleArg::Surround),
|
||||||
_ => Err(error::ParseError::ExpectedString(String::from(
|
_ => Err(error::ParseError::ExpectedString(String::from(
|
||||||
"underline or surround",
|
"bold, italic, underline or surround",
|
||||||
))),
|
))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,7 @@ use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use super::basic;
|
use super::basic;
|
||||||
use crate::{
|
use crate::{error, textbuf::alphabet, tmux, ui};
|
||||||
error,
|
|
||||||
textbuf::{alphabet, regexes},
|
|
||||||
tmux, ui,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Extended configuration for handling Tmux-specific configuration (options
|
/// Extended configuration for handling Tmux-specific configuration (options
|
||||||
/// and outputs). This is only used by `tmux-copyrat` and parsed from command
|
/// 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 {
|
for (name, value) in &tmux_options {
|
||||||
match name.as_ref() {
|
match name.as_ref() {
|
||||||
"@copyrat-capture" => {
|
"@copyrat-capture-region" => {
|
||||||
config_ext.capture_region = CaptureRegion::from_str(&value)?
|
config_ext.capture_region = CaptureRegion::from_str(&value)?
|
||||||
}
|
}
|
||||||
"@copyrat-alphabet" => {
|
"@copyrat-alphabet" => {
|
||||||
wrapped.alphabet = alphabet::parse_alphabet(value)?;
|
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" => {
|
"@copyrat-reverse" => {
|
||||||
wrapped.reverse = value.parse::<bool>()?;
|
wrapped.reverse = value.parse::<bool>()?;
|
||||||
}
|
}
|
||||||
|
|
@ -127,8 +117,8 @@ impl FromStr for CaptureRegion {
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, error::ParseError> {
|
fn from_str(s: &str) -> Result<Self, error::ParseError> {
|
||||||
match s {
|
match s {
|
||||||
"leading" => Ok(CaptureRegion::EntireHistory),
|
"entire-history" => Ok(CaptureRegion::EntireHistory),
|
||||||
"trailing" => Ok(CaptureRegion::VisibleArea),
|
"visible-area" => Ok(CaptureRegion::VisibleArea),
|
||||||
_ => Err(error::ParseError::ExpectedString(String::from(
|
_ => Err(error::ParseError::ExpectedString(String::from(
|
||||||
"entire-history or visible-area",
|
"entire-history or visible-area",
|
||||||
))),
|
))),
|
||||||
|
|
|
||||||
|
|
@ -141,10 +141,10 @@ pub fn list_panes() -> Result<Vec<Pane>, ParseError> {
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```get_options("@copyrat-")```
|
/// ```get_options("@copyrat-")```
|
||||||
pub fn get_options(prefix: &str) -> Result<HashMap<String, String>, ParseError> {
|
pub fn get_options(prefix: &str) -> Result<HashMap<String, String>, 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 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 re = Regex::new(&pattern).unwrap();
|
||||||
|
|
||||||
let args: HashMap<String, String> = lines
|
let args: HashMap<String, String> = lines
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue