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    /// Optional attached client whose clipboard should receive `-w` output.
23    #[serde(default)]
24    pub target_client: Option<String>,
25}
26
27/// Request payload for `show-buffer`.
28#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
29pub struct ShowBufferRequest {
30    /// The optional buffer name. When `None`, the stack-head buffer is shown.
31    pub name: Option<String>,
32}
33
34/// Request payload for `paste-buffer`.
35#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
36pub struct PasteBufferRequest {
37    /// The optional buffer name. When `None`, the stack-head buffer is pasted.
38    pub name: Option<String>,
39    /// The target pane to write the buffer content to.
40    pub target: PaneTarget,
41    /// Whether to delete the buffer after pasting.
42    pub delete_after: bool,
43    /// Optional replacement separator for embedded newlines.
44    #[serde(default)]
45    pub separator: Option<String>,
46    /// Whether newline separators should use `\\n` instead of `\\r`.
47    #[serde(default)]
48    pub linefeed: bool,
49    /// Whether raw bytes should be written without vis-style escaping.
50    #[serde(default)]
51    pub raw: bool,
52    /// Whether bracketed paste wrappers should be emitted when enabled on the pane.
53    #[serde(default)]
54    pub bracketed: bool,
55}
56
57/// Request payload for `list-buffers`.
58#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
59pub struct ListBuffersRequest {
60    /// Optional format template.
61    #[serde(default)]
62    pub format: Option<String>,
63    /// Optional filter expression.
64    #[serde(default)]
65    pub filter: Option<String>,
66    /// Optional sort order string.
67    #[serde(default)]
68    pub sort_order: Option<String>,
69    /// Whether to reverse the rendered order.
70    #[serde(default)]
71    pub reversed: bool,
72}
73
74/// Request payload for `delete-buffer`.
75#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
76pub struct DeleteBufferRequest {
77    /// The optional buffer name. When `None`, the stack-head buffer is deleted.
78    pub name: Option<String>,
79}
80
81/// Request payload for `load-buffer`.
82#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
83pub struct LoadBufferRequest {
84    /// The caller-supplied path to read.
85    pub path: String,
86    /// The caller working directory used to resolve relative paths.
87    pub cwd: Option<PathBuf>,
88    /// The optional buffer name. When `None`, an unnamed buffer is created.
89    pub name: Option<String>,
90    /// Whether the loaded content should also be copied to the client clipboard.
91    #[serde(default)]
92    pub set_clipboard: bool,
93    /// Optional attached client whose clipboard should receive `-w` output.
94    #[serde(default)]
95    pub target_client: Option<String>,
96}
97
98/// Request payload for `save-buffer`.
99#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
100pub struct SaveBufferRequest {
101    /// The caller-supplied path to write.
102    pub path: String,
103    /// The caller working directory used to resolve relative paths.
104    pub cwd: Option<PathBuf>,
105    /// The optional buffer name. When `None`, the stack-head buffer is saved.
106    pub name: Option<String>,
107    /// Whether output should append to the file instead of replacing it.
108    #[serde(default)]
109    pub append: bool,
110}
111
112/// Request payload for `capture-pane`.
113#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
114pub struct CapturePaneRequest {
115    /// The pane whose retained transcript should be captured.
116    pub target: PaneTarget,
117    /// The optional inclusive start line.
118    pub start: Option<i64>,
119    /// The optional inclusive end line.
120    pub end: Option<i64>,
121    /// Whether to print captured bytes to stdout instead of writing a buffer.
122    pub print: bool,
123    /// The optional destination buffer name for non-printing captures.
124    pub buffer_name: Option<String>,
125    /// Whether the saved alternate-screen copy should be captured.
126    #[serde(default)]
127    pub alternate: bool,
128    /// Whether ANSI SGR and hyperlink sequences should be preserved.
129    #[serde(default)]
130    pub escape_ansi: bool,
131    /// Whether control sequences should be octal-escaped.
132    #[serde(default)]
133    pub escape_sequences: bool,
134    /// Whether each captured line should be prefixed with tmux line flags.
135    #[serde(default)]
136    pub include_format: bool,
137    /// Whether hyperlink information should be captured instead of text.
138    #[serde(default)]
139    pub hyperlinks: bool,
140    /// Whether each captured line should be prefixed with its line number.
141    #[serde(default)]
142    pub line_numbers: bool,
143    /// Whether wrapped rows should be joined without intervening newlines.
144    #[serde(default)]
145    pub join_wrapped: bool,
146    /// Whether the copy-mode screen should be captured when present.
147    #[serde(default)]
148    pub use_mode_screen: bool,
149    /// Whether trailing spaces should be preserved.
150    #[serde(default)]
151    pub preserve_trailing_spaces: bool,
152    /// Whether trailing spaces should not be trimmed.
153    #[serde(default)]
154    pub do_not_trim_spaces: bool,
155    /// Whether pending parser bytes should be captured instead of the screen grid.
156    #[serde(default)]
157    pub pending_input: bool,
158    /// Whether missing alternate-screen content should be silenced.
159    #[serde(default)]
160    pub quiet: bool,
161    /// Whether `-S -` was used.
162    #[serde(default)]
163    pub start_is_absolute: bool,
164    /// Whether `-E -` was used.
165    #[serde(default)]
166    pub end_is_absolute: bool,
167}
168
169/// Request payload for `capture-pane` carrying raw tmux target text.
170#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
171pub struct CapturePaneTargetActionRequest {
172    /// Optional raw `-t` target. `None` uses the requester's current pane.
173    #[serde(default)]
174    pub target: Option<String>,
175    /// The optional inclusive start line.
176    pub start: Option<i64>,
177    /// The optional inclusive end line.
178    pub end: Option<i64>,
179    /// Whether to print captured bytes to stdout instead of writing a buffer.
180    pub print: bool,
181    /// The optional destination buffer name for non-printing captures.
182    pub buffer_name: Option<String>,
183    /// Whether the saved alternate-screen copy should be captured.
184    #[serde(default)]
185    pub alternate: bool,
186    /// Whether ANSI SGR and hyperlink sequences should be preserved.
187    #[serde(default)]
188    pub escape_ansi: bool,
189    /// Whether control sequences should be octal-escaped.
190    #[serde(default)]
191    pub escape_sequences: bool,
192    /// Whether each captured line should be prefixed with tmux line flags.
193    #[serde(default)]
194    pub include_format: bool,
195    /// Whether hyperlink information should be captured instead of text.
196    #[serde(default)]
197    pub hyperlinks: bool,
198    /// Whether each captured line should be prefixed with its line number.
199    #[serde(default)]
200    pub line_numbers: bool,
201    /// Whether wrapped rows should be joined without intervening newlines.
202    #[serde(default)]
203    pub join_wrapped: bool,
204    /// Whether the copy-mode screen should be captured when present.
205    #[serde(default)]
206    pub use_mode_screen: bool,
207    /// Whether trailing spaces should be preserved.
208    #[serde(default)]
209    pub preserve_trailing_spaces: bool,
210    /// Whether trailing spaces should not be trimmed.
211    #[serde(default)]
212    pub do_not_trim_spaces: bool,
213    /// Whether pending parser bytes should be captured instead of the screen grid.
214    #[serde(default)]
215    pub pending_input: bool,
216    /// Whether missing alternate-screen content should be silenced.
217    #[serde(default)]
218    pub quiet: bool,
219    /// Whether `-S -` was used.
220    #[serde(default)]
221    pub start_is_absolute: bool,
222    /// Whether `-E -` was used.
223    #[serde(default)]
224    pub end_is_absolute: bool,
225}
226
227/// Request payload for `clear-history`.
228#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
229pub struct ClearHistoryRequest {
230    /// The target pane whose history should be cleared.
231    pub target: PaneTarget,
232    /// Whether OSC 8 hyperlink storage should also be reset.
233    #[serde(default)]
234    pub reset_hyperlinks: bool,
235}