1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
//! tmux Integration section for the advanced settings tab.
//!
//! Covers: tmux enable/disable, path, default session, auto-attach, clipboard sync,
//! status bar (left/right format, refresh interval), prefix key.
use crate::SettingsUI;
use crate::section::{INPUT_WIDTH, collapsing_section};
use std::collections::HashSet;
pub(super) fn show_tmux_section(
ui: &mut egui::Ui,
settings: &mut SettingsUI,
changes_this_frame: &mut bool,
collapsed: &mut HashSet<String>,
) {
collapsing_section(
ui,
"tmux Integration",
"advanced_tmux",
true,
collapsed,
|ui| {
ui.label("Configure tmux control mode integration");
ui.add_space(8.0);
if ui
.checkbox(&mut settings.config.tmux_enabled, "Enable tmux integration")
.on_hover_text("Use tmux control mode for session management and split panes")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
if !settings.config.tmux_enabled {
ui.label(egui::RichText::new("tmux integration is disabled").italics());
return;
}
ui.add_space(8.0);
// tmux Path
ui.label(egui::RichText::new("Executable").strong());
ui.horizontal(|ui| {
ui.label("tmux path:");
if ui
.add(
egui::TextEdit::singleline(&mut settings.config.tmux_path)
.desired_width(INPUT_WIDTH),
)
.on_hover_text("Path to tmux executable (default: 'tmux' uses PATH)")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
});
ui.add_space(8.0);
// Session Settings
ui.label(egui::RichText::new("Sessions").strong());
ui.horizontal(|ui| {
ui.label("Default session name:");
let mut session_name = settings
.config
.tmux_default_session
.clone()
.unwrap_or_default();
if ui
.add(egui::TextEdit::singleline(&mut session_name).desired_width(INPUT_WIDTH))
.on_hover_text("Name for new tmux sessions (leave empty for tmux default)")
.changed()
{
settings.config.tmux_default_session = if session_name.is_empty() {
None
} else {
Some(session_name)
};
settings.has_changes = true;
*changes_this_frame = true;
}
});
ui.add_space(8.0);
// Auto-attach
ui.label(egui::RichText::new("Auto-Attach").strong());
if ui
.checkbox(
&mut settings.config.tmux_auto_attach,
"Auto-attach on startup",
)
.on_hover_text("Automatically attach to a tmux session when par-term starts")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
if settings.config.tmux_auto_attach {
ui.horizontal(|ui| {
ui.label("Session to attach:");
let mut attach_session = settings
.config
.tmux_auto_attach_session
.clone()
.unwrap_or_default();
if ui
.add(
egui::TextEdit::singleline(&mut attach_session)
.desired_width(INPUT_WIDTH),
)
.on_hover_text("Session name to auto-attach (leave empty for most recent)")
.changed()
{
settings.config.tmux_auto_attach_session = if attach_session.is_empty() {
None
} else {
Some(attach_session)
};
settings.has_changes = true;
*changes_this_frame = true;
}
});
}
ui.add_space(8.0);
// Clipboard Sync
ui.label(egui::RichText::new("Clipboard").strong());
if ui
.checkbox(
&mut settings.config.tmux_clipboard_sync,
"Sync clipboard with tmux",
)
.on_hover_text("When copying, also update tmux's paste buffer via set-buffer")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
ui.add_space(8.0);
// Status Bar
ui.label(egui::RichText::new("Status Bar").strong());
if ui
.checkbox(
&mut settings.config.tmux_show_status_bar,
"Show tmux status bar",
)
.on_hover_text("Display tmux status bar at bottom when connected")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
// Status bar settings (only show if status bar is enabled)
if settings.config.tmux_show_status_bar {
ui.horizontal(|ui| {
ui.label("Refresh interval:");
let mut refresh_secs =
settings.config.tmux_status_bar_refresh_ms as f32 / 1000.0;
if ui
.add(egui::Slider::new(&mut refresh_secs, 0.5..=10.0).suffix("s"))
.on_hover_text("How often to update the status bar content")
.changed()
{
settings.config.tmux_status_bar_refresh_ms = (refresh_secs * 1000.0) as u64;
settings.has_changes = true;
*changes_this_frame = true;
}
});
ui.add_space(4.0);
// Left format string
ui.horizontal(|ui| {
ui.label("Left format:");
if ui
.add(
egui::TextEdit::singleline(&mut settings.config.tmux_status_bar_left)
.desired_width(INPUT_WIDTH),
)
.on_hover_text(
"Format string for left side. Variables: {session}, {windows}, {pane}, {time:FORMAT}, {hostname}, {user}",
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
});
// Right format string
ui.horizontal(|ui| {
ui.label("Right format:");
if ui
.add(
egui::TextEdit::singleline(&mut settings.config.tmux_status_bar_right)
.desired_width(INPUT_WIDTH),
)
.on_hover_text(
"Format string for right side. Variables: {session}, {windows}, {pane}, {time:FORMAT}, {hostname}, {user}",
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
});
// Help text for format variables
ui.add_space(2.0);
ui.label(
egui::RichText::new(
"Variables: {session}, {windows}, {pane}, {time:%H:%M}, {hostname}, {user}",
)
.small()
.color(egui::Color32::GRAY),
);
}
ui.add_space(8.0);
// Prefix Key
ui.label(egui::RichText::new("Prefix Key").strong());
ui.horizontal(|ui| {
ui.label("Prefix key:");
if ui
.add(
egui::TextEdit::singleline(&mut settings.config.tmux_prefix_key)
.desired_width(INPUT_WIDTH),
)
.on_hover_text("Key combination for tmux commands (e.g., C-b, C-Space)")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
});
},
);
}