Skip to main content

rmux_proto/request/
buffer.rs

1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3
4use crate::PaneTarget;
5
6/// Request payload for `set-buffer`.
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8pub struct SetBufferRequest {
9    /// The optional buffer name. When `None`, an unnamed buffer is created.
10    pub name: Option<String>,
11    /// The buffer content.
12    pub content: Vec<u8>,
13    /// Whether new content should append to an existing buffer.
14    #[serde(default)]
15    pub append: bool,
16    /// Optional new name for a rename-only mutation.
17    #[serde(default)]
18    pub new_name: Option<String>,
19    /// Whether the buffer should also be copied to the client clipboard.
20    #[serde(default)]
21    pub set_clipboard: bool,
22}
23
24/// Request payload for `show-buffer`.
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26pub struct ShowBufferRequest {
27    /// The optional buffer name. When `None`, the stack-head buffer is shown.
28    pub name: Option<String>,
29}
30
31/// Request payload for `paste-buffer`.
32#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
33pub struct PasteBufferRequest {
34    /// The optional buffer name. When `None`, the stack-head buffer is pasted.
35    pub name: Option<String>,
36    /// The target pane to write the buffer content to.
37    pub target: PaneTarget,
38    /// Whether to delete the buffer after pasting.
39    pub delete_after: bool,
40    /// Optional replacement separator for embedded newlines.
41    #[serde(default)]
42    pub separator: Option<String>,
43    /// Whether newline separators should use `\\n` instead of `\\r`.
44    #[serde(default)]
45    pub linefeed: bool,
46    /// Whether raw bytes should be written without vis-style escaping.
47    #[serde(default)]
48    pub raw: bool,
49    /// Whether bracketed paste wrappers should be emitted when enabled on the pane.
50    #[serde(default)]
51    pub bracketed: bool,
52}
53
54/// Request payload for `list-buffers`.
55#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
56pub struct ListBuffersRequest {
57    /// Optional format template.
58    #[serde(default)]
59    pub format: Option<String>,
60    /// Optional filter expression.
61    #[serde(default)]
62    pub filter: Option<String>,
63    /// Optional sort order string.
64    #[serde(default)]
65    pub sort_order: Option<String>,
66    /// Whether to reverse the rendered order.
67    #[serde(default)]
68    pub reversed: bool,
69}
70
71/// Request payload for `delete-buffer`.
72#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
73pub struct DeleteBufferRequest {
74    /// The optional buffer name. When `None`, the stack-head buffer is deleted.
75    pub name: Option<String>,
76}
77
78/// Request payload for `load-buffer`.
79#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
80pub struct LoadBufferRequest {
81    /// The caller-supplied path to read.
82    pub path: String,
83    /// The caller working directory used to resolve relative paths.
84    pub cwd: Option<PathBuf>,
85    /// The optional buffer name. When `None`, an unnamed buffer is created.
86    pub name: Option<String>,
87    /// Whether the loaded content should also be copied to the client clipboard.
88    #[serde(default)]
89    pub set_clipboard: bool,
90}
91
92/// Request payload for `save-buffer`.
93#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
94pub struct SaveBufferRequest {
95    /// The caller-supplied path to write.
96    pub path: String,
97    /// The caller working directory used to resolve relative paths.
98    pub cwd: Option<PathBuf>,
99    /// The optional buffer name. When `None`, the stack-head buffer is saved.
100    pub name: Option<String>,
101    /// Whether output should append to the file instead of replacing it.
102    #[serde(default)]
103    pub append: bool,
104}
105
106/// Request payload for `capture-pane`.
107#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
108pub struct CapturePaneRequest {
109    /// The pane whose retained transcript should be captured.
110    pub target: PaneTarget,
111    /// The optional inclusive start line.
112    pub start: Option<i64>,
113    /// The optional inclusive end line.
114    pub end: Option<i64>,
115    /// Whether to print captured bytes to stdout instead of writing a buffer.
116    pub print: bool,
117    /// The optional destination buffer name for non-printing captures.
118    pub buffer_name: Option<String>,
119    /// Whether the saved alternate-screen copy should be captured.
120    #[serde(default)]
121    pub alternate: bool,
122    /// Whether ANSI SGR and hyperlink sequences should be preserved.
123    #[serde(default)]
124    pub escape_ansi: bool,
125    /// Whether control sequences should be octal-escaped.
126    #[serde(default)]
127    pub escape_sequences: bool,
128    /// Whether wrapped rows should be joined without intervening newlines.
129    #[serde(default)]
130    pub join_wrapped: bool,
131    /// Whether the copy-mode screen should be captured when present.
132    #[serde(default)]
133    pub use_mode_screen: bool,
134    /// Whether trailing spaces should be preserved.
135    #[serde(default)]
136    pub preserve_trailing_spaces: bool,
137    /// Whether trailing spaces should not be trimmed.
138    #[serde(default)]
139    pub do_not_trim_spaces: bool,
140    /// Whether pending parser bytes should be captured instead of the screen grid.
141    #[serde(default)]
142    pub pending_input: bool,
143    /// Whether missing alternate-screen content should be silenced.
144    #[serde(default)]
145    pub quiet: bool,
146    /// Whether `-S -` was used.
147    #[serde(default)]
148    pub start_is_absolute: bool,
149    /// Whether `-E -` was used.
150    #[serde(default)]
151    pub end_is_absolute: bool,
152}
153
154/// Request payload for `clear-history`.
155#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
156pub struct ClearHistoryRequest {
157    /// The target pane whose history should be cleared.
158    pub target: PaneTarget,
159    /// Whether OSC 8 hyperlink storage should also be reset.
160    #[serde(default)]
161    pub reset_hyperlinks: bool,
162}