Add persistent live OpenCADStudio control

This commit is contained in:
Hakan Seven committed 2026-09-04 22:25:55 +03:00
1 parent 9d991d7feb
commit 28cc473062
22 files changed
+1764 -95

No files matched your search

+8
View File
@@ -69,6 +69,8 @@ pub struct CommandLine {
/// instead of submitting. Saved in the user config.
pub literal_spaces: bool,
pub history: Vec<HistoryEntry>,
pub error_revision: u64,
pub last_error: Option<String>,
/// Successfully dispatched commands used for ↑/↓ recall, newest last.
/// Stored separately because recall also maintains its own cursor and draft.
pub cmd_recall: Vec<String>,
@@ -116,6 +118,8 @@ impl Default for CommandLine {
input: String::new(),
literal_spaces: false,
history: Vec::new(),
error_revision: 0,
last_error: None,
cmd_recall: Vec::new(),
recent_commands: Vec::new(),
recall_cursor: None,
@@ -307,6 +311,8 @@ impl CommandLine {
self.push(EntryKind::Output, msg.to_string());
}
pub fn push_error(&mut self, msg: &str) {
self.error_revision = self.error_revision.wrapping_add(1);
self.last_error = Some(msg.to_owned());
self.push(EntryKind::Error, format!("*{}* {msg}", t!("Invalid")));
}
/// Append an error unless it is already the latest history line. Repeated
@@ -314,6 +320,8 @@ impl CommandLine {
/// with identical copies (#498).
#[cfg(not(target_arch = "wasm32"))]
pub fn push_error_once(&mut self, msg: &str) {
self.error_revision = self.error_revision.wrapping_add(1);
self.last_error = Some(msg.to_owned());
let text = format!("*{}* {msg}", t!("Invalid"));
if let Some(last) = self
.history
+31
View File
@@ -122,6 +122,8 @@ impl StatusBar {
selection_filter_active: bool,
// Whether selection cycling is enabled.
selection_cycling: bool,
control_enabled: bool,
control_busy: bool,
// Which pills the user has chosen to show on the bar.
config: &'a StatusBarConfig,
menu_data: StatusMenuData<'a>,
@@ -493,6 +495,35 @@ impl StatusBar {
// use the remaining space on the final tab row when they fit; otherwise
// WrapBar adds another right-aligned row.
let mut left: Vec<Element<'_, Message>> = Vec::new();
let control_label = if !control_enabled {
"Control: off"
} else if control_busy {
"Control: busy"
} else {
"Control: ready"
};
let control_color = if !control_enabled {
Color::from_rgb(0.90, 0.35, 0.35)
} else if control_busy {
Color::from_rgb(0.95, 0.72, 0.25)
} else {
Color::from_rgb(0.35, 0.85, 0.55)
};
left.push(
button(text(control_label).size(11))
.on_press(Message::ControlToggle)
.style(move |theme: &Theme, status| {
let mut style = button::subtle(theme, status);
style.background = Some(Background::Color(control_color));
style.text_color = Color::from_rgb(0.08, 0.08, 0.10);
style.border.color = control_color;
style.border.width = 1.0;
style
})
.padding([4, 8])
.width(Length::Fixed(100.0))
.into(),
);
left.push(menu_btn);
if show_layout_tabs {
let reorderable_layouts: Arc<[String]> = reorderable_layouts.into();