use crate::SettingsUI;
use crate::search::SearchTag;
use crate::section::{SLIDER_WIDTH, collapsing_section, keyword_section};
use par_term_config::DroppedFileQuoteStyle;
use std::collections::HashSet;
const SLIDER_HEIGHT: f32 = 18.0;
pub(crate) fn show_selection_section(
ui: &mut egui::Ui,
settings: &mut SettingsUI,
changes_this_frame: &mut bool,
collapsed: &mut HashSet<String>,
) {
keyword_section(
ui,
"Selection & Clipboard",
"input_selection",
&["osc52"],
true,
collapsed,
|ui| {
if ui
.checkbox(
&mut settings.config.selection.auto_copy_selection,
"Auto-copy selection",
)
.search_tag(&["auto_copy_selection"])
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
if ui
.checkbox(
&mut settings.config.selection.copy_trailing_newline,
"Include trailing newline when copying",
)
.search_tag(&["copy_trailing_newline"])
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
if ui
.checkbox(
&mut settings.config.selection.middle_click_paste,
"Middle-click paste",
)
.search_tag(&["middle_click_paste"])
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
if ui
.checkbox(
&mut settings.config.selection.warn_paste_control_chars,
"Warn before pasting control characters",
)
.search_tag(&["warn_paste_control_chars"])
.on_hover_text(
"Ask before pasting text that holds control characters (escape \
sequences, carriage returns) that a program could act on.",
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
if ui
.checkbox(
&mut settings.config.clipboard.osc52_clipboard,
"OSC 52 clipboard sync (programs set clipboard over SSH)",
)
.search_tag(&["osc52_clipboard"])
.on_hover_text(
"Apply OSC 52 clipboard-set sequences from programs to the system \
clipboard. This is how remote apps (tmux, herdr, etc.) copy to your \
local clipboard over SSH. Disable if you don't want programs to \
overwrite your clipboard.",
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
ui.horizontal(|ui| {
ui.label("Paste delay:");
if ui
.add_sized(
[SLIDER_WIDTH, SLIDER_HEIGHT],
egui::Slider::new(&mut settings.config.selection.paste_delay_ms, 0..=500)
.suffix(" ms"),
)
.search_tag(&["paste_delay_ms"])
.on_hover_text(
"Delay between pasted lines in milliseconds (0 = no delay). \
Useful for slow terminals or remote connections.",
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
crate::reset::reset_button(ui, settings, changes_this_frame, |c| {
&mut c.selection.paste_delay_ms
});
});
ui.separator();
ui.label("Dropped Files");
ui.horizontal(|ui| {
ui.label("Quote style:");
let quote_combo = egui::ComboBox::from_id_salt("input_dropped_file_quote_style")
.selected_text(
settings
.config
.selection
.dropped_file_quote_style
.display_name(),
)
.show_ui(ui, |ui| {
for style in DroppedFileQuoteStyle::all() {
if ui
.selectable_value(
&mut settings.config.selection.dropped_file_quote_style,
*style,
style.display_name(),
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
}
});
quote_combo
.response
.search_tag(&["dropped_file_quote_style"]);
})
.response
.on_hover_text("How to quote file paths when dropped into the terminal");
},
);
}
pub(crate) fn show_clipboard_limits_section(
ui: &mut egui::Ui,
settings: &mut SettingsUI,
changes_this_frame: &mut bool,
collapsed: &mut HashSet<String>,
) {
collapsing_section(
ui,
"Clipboard Limits",
"input_clipboard_limits",
false,
collapsed,
|ui| {
ui.horizontal(|ui| {
ui.label("Max clipboard sync events:");
if ui
.add_sized(
[SLIDER_WIDTH, SLIDER_HEIGHT],
egui::Slider::new(
&mut settings.config.clipboard.clipboard_max_sync_events,
8..=256,
)
.suffix(" events"),
)
.search_tag(&["clipboard_max_sync_events"])
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
crate::reset::reset_button(ui, settings, changes_this_frame, |c| {
&mut c.clipboard.clipboard_max_sync_events
});
});
ui.horizontal(|ui| {
ui.label("Max clipboard event bytes:");
if ui
.add_sized(
[SLIDER_WIDTH, SLIDER_HEIGHT],
egui::Slider::new(
&mut settings.config.clipboard.clipboard_max_event_bytes,
512..=16384,
)
.suffix(" bytes"),
)
.search_tag(&["clipboard_max_event_bytes"])
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
crate::reset::reset_button(ui, settings, changes_this_frame, |c| {
&mut c.clipboard.clipboard_max_event_bytes
});
});
},
);
}