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
//! Detection settings section for the Content Prettifier tab.
use crate::SettingsUI;
use crate::section::collapsing_section;
use std::collections::HashSet;
pub fn show_detection_section(
ui: &mut egui::Ui,
settings: &mut SettingsUI,
changes_this_frame: &mut bool,
collapsed: &mut HashSet<String>,
) {
collapsing_section(
ui,
"Detection Settings",
"prettifier_detection",
true,
collapsed,
|ui| {
// Detection scope dropdown.
ui.horizontal(|ui| {
ui.label("Detection scope:");
let scope = &mut settings.config.content_prettifier.detection.scope;
let label = match scope.as_str() {
"command_output" => "Command Output",
"all" => "All Output",
"manual_only" => "Manual Only",
_ => "Command Output",
};
egui::ComboBox::from_id_salt("prettifier_detection_scope")
.selected_text(label)
.show_ui(ui, |ui| {
if ui
.selectable_label(scope == "command_output", "Command Output")
.clicked()
{
*scope = "command_output".to_string();
settings.has_changes = true;
*changes_this_frame = true;
}
if ui.selectable_label(scope == "all", "All Output").clicked() {
*scope = "all".to_string();
settings.has_changes = true;
*changes_this_frame = true;
}
if ui
.selectable_label(scope == "manual_only", "Manual Only")
.clicked()
{
*scope = "manual_only".to_string();
settings.has_changes = true;
*changes_this_frame = true;
}
});
});
// Confidence threshold slider.
ui.horizontal(|ui| {
ui.label("Confidence threshold:");
let threshold = &mut settings
.config
.content_prettifier
.detection
.confidence_threshold;
if ui
.add(egui::Slider::new(threshold, 0.0..=1.0).step_by(0.05))
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
});
// Max scan lines.
ui.horizontal(|ui| {
ui.label("Max scan lines:");
if ui
.add(
egui::DragValue::new(
&mut settings.config.content_prettifier.detection.max_scan_lines,
)
.range(50..=5000)
.speed(10.0),
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
});
// Debounce ms.
ui.horizontal(|ui| {
ui.label("Debounce (ms):");
if ui
.add(
egui::DragValue::new(
&mut settings.config.content_prettifier.detection.debounce_ms,
)
.range(0..=1000)
.speed(10.0),
)
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
});
// Per-block toggle.
if ui
.checkbox(
&mut settings.config.content_prettifier.per_block_toggle,
"Per-block source/rendered toggle",
)
.on_hover_text("Allow toggling between source and rendered view per content block")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
// Respect alternate screen.
if ui
.checkbox(
&mut settings.config.content_prettifier.respect_alternate_screen,
"Respect alternate screen",
)
.on_hover_text("Treat alternate screen transitions as content block boundaries")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
},
);
}