mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +01:00
refactor: outputdestination.rs -> comm/output_destination.rs
This commit is contained in:
parent
9426d8bfee
commit
16fa4d45c1
6 changed files with 12 additions and 5 deletions
30
src/comm/output_destination.rs
Normal file
30
src/comm/output_destination.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue