mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 08:00:08 +01:00
30 lines
835 B
Rust
30 lines
835 B
Rust
use std::fmt;
|
|
|
|
/// 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"),
|
|
}
|
|
}
|
|
}
|