use serde::{Deserialize, Serialize};
use super::CommandOutput;
use crate::{
PaneId, PaneOutputSubscriptionId, PaneStateSubscriptionId, PaneTarget, PaneTargetRef,
ResizePaneAdjustment, RmuxError, WindowTarget,
};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SplitWindowResponse {
pub pane: PaneTarget,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SplitWindowIdentityResponse {
pub pane: PaneTarget,
pub pane_id: PaneId,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SwapPaneResponse {
pub source: PaneTarget,
pub target: PaneTarget,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct MovePaneResponse {
pub target: PaneTarget,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct LastPaneResponse {
pub target: PaneTarget,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct JoinPaneResponse {
pub target: PaneTarget,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct BreakPaneResponse {
pub target: PaneTarget,
#[serde(default)]
pub output: Option<CommandOutput>,
}
impl BreakPaneResponse {
#[must_use]
pub const fn command_output(&self) -> Option<&CommandOutput> {
self.output.as_ref()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct KillPaneResponse {
pub target: PaneTarget,
pub window_destroyed: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ResizePaneResponse {
pub target: PaneTarget,
pub adjustment: ResizePaneAdjustment,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DisplayPanesResponse {
pub target: WindowTarget,
pub pane_count: u32,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PipePaneResponse {
pub target: PaneTarget,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RespawnPaneResponse {
pub target: PaneTarget,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SelectPaneResponse {
pub target: PaneTarget,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SendKeysResponse {
pub key_count: usize,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneBroadcastInputSuccess {
pub target_index: u32,
pub target: PaneTarget,
pub pane_id: Option<PaneId>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneBroadcastInputFailure {
pub target_index: u32,
pub target: PaneTargetRef,
pub error: RmuxError,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneBroadcastInputResponse {
pub key_count: usize,
pub successes: Vec<PaneBroadcastInputSuccess>,
pub failures: Vec<PaneBroadcastInputFailure>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneOptionSetResponse {
pub pane_id: PaneId,
pub name: String,
pub old_value: Option<String>,
pub new_value: Option<String>,
pub changed: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneOptionGetResponse {
pub pane_id: PaneId,
pub name: String,
pub value: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneOptionEntry {
pub name: String,
pub value: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ForegroundFieldSource {
Process,
RootProcess,
Osc7,
Profile,
Environment,
RuntimeName,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ForegroundSourcesDto {
#[serde(default)]
pub pid: Option<ForegroundFieldSource>,
#[serde(default)]
pub command: Option<ForegroundFieldSource>,
#[serde(default)]
pub cwd: Option<ForegroundFieldSource>,
#[serde(default)]
pub exe: Option<ForegroundFieldSource>,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ForegroundStateDto {
#[serde(default)]
pub pid: Option<u32>,
#[serde(default)]
pub command: Option<String>,
#[serde(default)]
pub cwd: Option<String>,
#[serde(default)]
pub exe: Option<String>,
#[serde(default)]
pub sources: ForegroundSourcesDto,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneStateSnapshot {
pub revision: u64,
#[serde(default)]
pub title: Option<String>,
#[serde(default)]
pub options: Vec<PaneOptionEntry>,
#[serde(default)]
pub foreground: Option<ForegroundStateDto>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PaneStateClosedReason {
Exited,
DiedKept,
Killed,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PaneStateEventDto {
TitleChanged {
revision: u64,
pane_id: PaneId,
old_title: String,
new_title: String,
},
OptionSet {
revision: u64,
pane_id: PaneId,
name: String,
old_value: Option<String>,
new_value: String,
},
OptionUnset {
revision: u64,
pane_id: PaneId,
name: String,
old_value: Option<String>,
},
ForegroundChanged {
revision: u64,
pane_id: PaneId,
old_state: ForegroundStateDto,
new_state: ForegroundStateDto,
},
Closed {
revision: u64,
pane_id: PaneId,
reason: PaneStateClosedReason,
},
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SubscribePaneStateResponse {
pub subscription_id: PaneStateSubscriptionId,
pub pane_id: PaneId,
pub snapshot: PaneStateSnapshot,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct UnsubscribePaneStateResponse {
pub subscription_id: PaneStateSubscriptionId,
pub removed: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneStateCursorResponse {
pub subscription_id: PaneStateSubscriptionId,
pub events: Vec<PaneStateEventDto>,
pub next_revision: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneStateLagResponse {
pub subscription_id: PaneStateSubscriptionId,
pub missed_from_revision: u64,
pub resume_revision: u64,
pub snapshot: PaneStateSnapshot,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneForegroundStateResponse {
pub pane_id: PaneId,
pub revision: u64,
pub state: Option<ForegroundStateDto>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneOutputCursor {
pub next_sequence: u64,
pub missed_events: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneOutputEvent {
pub sequence: u64,
pub bytes: Vec<u8>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneRecentOutput {
pub bytes: Vec<u8>,
pub oldest_sequence: Option<u64>,
pub newest_sequence: Option<u64>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneOutputLagNotice {
pub expected_sequence: u64,
pub resume_sequence: u64,
pub missed_events: u64,
pub newest_sequence: u64,
pub recent: PaneRecentOutput,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SubscribePaneOutputResponse {
pub subscription_id: PaneOutputSubscriptionId,
pub target: PaneTarget,
pub pane_id: PaneId,
pub cursor: PaneOutputCursor,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct UnsubscribePaneOutputResponse {
pub subscription_id: PaneOutputSubscriptionId,
pub removed: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneOutputCursorResponse {
pub subscription_id: PaneOutputSubscriptionId,
pub cursor: PaneOutputCursor,
pub events: Vec<PaneOutputEvent>,
pub limited: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneOutputLagResponse {
pub subscription_id: PaneOutputSubscriptionId,
pub cursor: PaneOutputCursor,
pub lag: PaneOutputLagNotice,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PaneRawRebaseReason {
Initial,
Lag,
Resize,
ClearHistory,
ParserStateExpired,
TerminalReset,
TranscriptMutation,
GenerationChanged,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneRecoveryCoverage {
pub history_rows_total: u64,
pub history_rows_included: u64,
pub metadata_complete: bool,
}
impl PaneRecoveryCoverage {
#[must_use]
pub const fn history_complete(self) -> bool {
self.history_rows_included >= self.history_rows_total
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneRawRebase {
pub epoch: u64,
pub generation: u64,
pub invalidation_revision: u64,
pub next_sequence: u64,
pub cols: u16,
pub rows: u16,
pub keyframe: Vec<u8>,
pub alternate: bool,
pub coverage: PaneRecoveryCoverage,
pub snapshot: Option<PaneSnapshotResponse>,
pub reason: PaneRawRebaseReason,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneRawBytes {
pub epoch: u64,
pub sequence: u64,
pub bytes: Vec<u8>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneSurfaceHyperlink {
pub id: u32,
pub uri: String,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneSurfaceDynamicColors {
pub foreground: Option<String>,
pub background: Option<String>,
pub cursor: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneSurfaceSnapshot {
pub cols: u16,
pub rows: u16,
pub cells: Vec<PaneSnapshotCell>,
pub hyperlinks: Vec<PaneSurfaceHyperlink>,
pub cursor: PaneSnapshotCursor,
pub title: String,
pub path: String,
pub dynamic_colors: PaneSurfaceDynamicColors,
pub metadata_complete: bool,
pub mode_bits: u32,
pub alternate: bool,
pub scroll_top: u32,
pub scroll_bottom: u32,
pub history_size: u64,
pub history_bytes: u64,
pub revision: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneSurfaceFrame {
pub epoch: u64,
pub revision: u64,
pub next_output_sequence: u64,
pub snapshot: PaneSurfaceSnapshot,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PaneStreamLifecycleEvent {
ProcessExited {
output_sequence: Option<u64>,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PaneStreamEndReason {
PaneRemoved,
AccessRevoked,
SlowConsumer,
SubscriptionExpired,
TransportLost,
ProjectionFailed,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum PaneStreamEvent {
RawRebase(Box<PaneRawRebase>),
RawBytes(PaneRawBytes),
SurfaceReset(Box<PaneSurfaceFrame>),
SurfacePatch(Box<PaneSurfaceFrame>),
Lifecycle(PaneStreamLifecycleEvent),
End(PaneStreamEndReason),
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SubscribePaneStreamResponse {
pub subscription_id: PaneOutputSubscriptionId,
pub target: PaneTarget,
pub pane_id: PaneId,
pub event: PaneStreamEvent,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneStreamCursorResponse {
pub subscription_id: PaneOutputSubscriptionId,
pub events: Vec<PaneStreamEvent>,
pub limited: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct UnsubscribePaneStreamResponse {
pub subscription_id: PaneOutputSubscriptionId,
pub removed: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneSnapshotCell {
pub text: String,
pub width: u8,
pub padding: bool,
pub attributes: u16,
pub fg: i32,
pub bg: i32,
pub us: i32,
pub link: u32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneSnapshotCursor {
pub row: u16,
pub col: u16,
pub visible: bool,
pub style: u32,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaneSnapshotResponse {
pub cols: u16,
pub rows: u16,
pub cells: Vec<PaneSnapshotCell>,
pub cursor: PaneSnapshotCursor,
pub revision: u64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ListPanesResponse {
pub output: CommandOutput,
}
impl ListPanesResponse {
#[must_use]
pub fn command_output(&self) -> &CommandOutput {
&self.output
}
}