feat(command-line): copy/clear history + selectable log (#232)

The command-line history dropdown was display-only, so users had to
screenshot and OCR the log to report output. Make it copyable:

- Render the whole backlog in one read-only text_editor so a single
  mouse drag selects across lines and Ctrl+C copies the span.
- Add Copy (whole log to clipboard) and Clear buttons to the dropdown.
- Gate the Ctrl+C/X/V accelerators on event Status::Ignored so a focused
  text widget's copy/cut/paste wins instead of firing COPYCLIP/CUTCLIP;
  the drawing's clipboard shortcuts still work when it has focus.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-01 18:17:46 +03:00
1 parent ada9952f06
commit 1e9de924be
6 files changed
+181 -30

No files matched your search

+35
View File
@@ -774,6 +774,41 @@ impl OpenCADStudio {
Message::CommandHistoryToggle => {
self.command_line.toggle_history();
// On open, snapshot the current log into the read-only editor
// buffer so it can be drag-selected across lines and copied.
if self.command_line.history_open {
use iced::widget::text_editor::{Action, Motion};
self.history_content = iced::widget::text_editor::Content::with_text(
&self.command_line.history_plain_text(),
);
// Scroll to the newest line (bottom), the most useful when
// opening the log to grab a recent error.
self.history_content.perform(Action::Move(Motion::DocumentEnd));
}
Task::none()
}
Message::CommandHistoryCopy => {
let text = self.command_line.history_plain_text();
if text.is_empty() {
Task::none()
} else {
iced::clipboard::write(text)
}
}
Message::CommandHistoryClear => {
self.command_line.clear_history();
self.history_content = iced::widget::text_editor::Content::new();
Task::none()
}
Message::CommandHistoryEdit(action) => {
// Read-only: drop edits, keep selection / cursor / scroll so
// the user can still highlight and Ctrl+C the log.
if !action.is_edit() {
self.history_content.perform(action);
}
Task::none()
}