mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-14 08:53:52 +01:00
refactor: OutputDestination -> config/tmux_bridge.rs
This commit is contained in:
parent
a26a4a56d8
commit
d4fb6c417b
8 changed files with 42 additions and 43 deletions
|
|
@ -1,13 +1,13 @@
|
|||
use clap::Clap;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
|
||||
use super::basic;
|
||||
use crate::{
|
||||
comm::tmux,
|
||||
error,
|
||||
textbuf::{alphabet, regexes},
|
||||
ui,
|
||||
tmux, ui,
|
||||
};
|
||||
|
||||
/// Main configuration, parsed from command line.
|
||||
|
|
@ -135,3 +135,32 @@ impl FromStr for CaptureRegion {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes the type of buffer the selected should be copied to: either a
|
||||
/// tmux buffer or the system clipboard.
|
||||
#[derive(Clone)]
|
||||
pub enum OutputDestination {
|
||||
/// The selection will be copied to the tmux buffer.
|
||||
Tmux,
|
||||
/// The selection will be copied to the system clipboard.
|
||||
Clipboard,
|
||||
}
|
||||
|
||||
impl OutputDestination {
|
||||
/// Toggle between the variants of `OutputDestination`.
|
||||
pub fn toggle(&mut self) {
|
||||
match *self {
|
||||
Self::Tmux => *self = Self::Clipboard,
|
||||
Self::Clipboard => *self = Self::Tmux,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for OutputDestination {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Tmux => write!(f, "tmux buffer"),
|
||||
Self::Clipboard => write!(f, "clipboard"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue