use crate::app::TmuxSession;
use tokio::sync::oneshot;
#[derive(Debug)]
pub enum TmuxCommand {
RefreshAll,
CapturePane { target: String, start: i32, end: i32 },
NewSession { name: String },
RenameSession { old_name: String, new_name: String },
KillSession { name: String },
SendKeys {
target: String,
keys: String,
reply: Option<oneshot::Sender<TmuxResponse>>,
},
SwitchClient {
target: String,
reply: Option<oneshot::Sender<TmuxResponse>>,
},
}
#[derive(Debug, Clone)]
pub enum TmuxResponse {
SessionsRefreshed { sessions: Vec<TmuxSession> },
PaneCaptured {
#[allow(dead_code)]
target: String,
content: String,
},
SessionCreated {
name: String,
success: bool,
error: Option<String>,
},
SessionRenamed {
success: bool,
error: Option<String>,
},
SessionKilled {
success: bool,
error: Option<String>,
},
KeysSent {
#[allow(dead_code)]
success: bool,
error: Option<String>,
},
ClientSwitched {
#[allow(dead_code)]
target: String,
success: bool,
error: Option<String>,
},
Error { message: String },
}
#[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum UIEvent {
RequestCapture,
Tick,
Shutdown,
}
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct RefreshControl {
paused: Arc<AtomicBool>,
}
impl RefreshControl {
pub fn new() -> Self {
Self {
paused: Arc::new(AtomicBool::new(false)),
}
}
pub fn pause(&self) {
self.paused.store(true, Ordering::SeqCst);
}
pub fn resume(&self) {
self.paused.store(false, Ordering::SeqCst);
}
pub fn is_paused(&self) -> bool {
self.paused.load(Ordering::SeqCst)
}
}
impl Default for RefreshControl {
fn default() -> Self {
Self::new()
}
}