pub mod client;
pub mod error;
pub mod layout;
pub mod mock;
pub use client::RealTmuxClient;
pub use error::TmuxError;
pub use mock::MockTmuxClient;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum PaneDirection {
Left,
Right,
Above,
Below,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneInfo {
pub pane_id: String,
pub session_name: String,
pub window_index: u32,
pub pane_pid: u32,
pub width: u16,
pub height: u16,
pub is_active: bool,
}
#[async_trait]
pub trait TmuxClient: Send + Sync {
async fn split_window(
&self,
target: &str,
size: &str,
direction: PaneDirection,
command: Option<&str>,
) -> Result<String, TmuxError>;
async fn get_pane_cwd(&self, pane: &str) -> Result<Option<String>, TmuxError>;
async fn new_window(&self, session: &str, command: Option<&str>) -> Result<String, TmuxError>;
async fn kill_pane(&self, pane: &str) -> Result<(), TmuxError>;
async fn resize_pane(
&self,
pane: &str,
width: Option<u16>,
height: Option<u16>,
) -> Result<(), TmuxError>;
async fn send_keys(&self, pane: &str, keys: &str) -> Result<(), TmuxError>;
async fn list_panes(&self) -> Result<Vec<PaneInfo>, TmuxError>;
async fn display_popup(
&self,
width: &str,
height: &str,
command: &str,
) -> Result<(), TmuxError>;
async fn select_pane(&self, pane: &str) -> Result<(), TmuxError>;
async fn capture_pane(&self, pane: &str) -> Result<Vec<String>, TmuxError>;
async fn new_session(&self, name: &str) -> Result<String, TmuxError>;
}