refactor: outputdestination.rs -> comm/output_destination.rs

This commit is contained in:
graelo 2021-03-20 22:58:09 +01:00
parent 9426d8bfee
commit 16fa4d45c1
6 changed files with 12 additions and 5 deletions

View 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"),
}
}
}