viewer: click to copy values, amounts, and identifiers

Company details (EIN, state number, address, every profile value), an
entry's number and amount, an account's code and balance, a document's
file name and SHA-256 copy on click: a pointer and copy icon on hover,
a check for a moment after. Amounts copy as their exact plain decimal
(fmt::plain: no "$", commas, or parentheses; "-" for negatives); where a
click already drills down (report cells, register and transaction rows,
general ledger lines), a right-click menu copies the amounts, the entry
number, or the description. The sidebar's chain check copies the
journal head and data folder.

tests/copy.rs: every display style copies back to the exact value
(property), and clicking the EIN, an entry's amount, and its number puts
exactly that on the clipboard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GWVo7x3UHw5kwCUaWxiejX
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-10-14 15:38:05 -06:00
1 parent c126843ce1
commit afd427a023
10 files changed
+344 -17

No files matched your search

+25 -2
View File
@@ -168,18 +168,22 @@ pub fn show_account(ui: &mut Ui, b: &Books, id: u64, shell: &mut Shell<'_>) {
.range
.unwrap_or((first.min(b.today), b.today));
page(ui, "account", |ui| {
ui.label(
widgets::copyable(
ui,
RichText::new(format!("{:?} account · {}", a.account_type, a.code))
.font(theme::regular(13.0))
.color(p.muted),
&a.code,
);
ui.label(RichText::new(&a.name).font(theme::bold(26.0)));
ui.add_space(4.0);
let bal = b.balance_on(id, b.today);
ui.label(
widgets::copyable(
ui,
RichText::new(format!("Balance today {}", fmt::dollars(bal)))
.font(theme::regular(15.0))
.color(p.muted),
&fmt::plain(&fmt::dollars(bal)).unwrap_or_default(),
);
ui.add_space(14.0);
let hist = balance_history(&b.ledger, &[id]);
@@ -274,6 +278,25 @@ pub fn show_account(ui: &mut Ui, b: &Books, id: u64, shell: &mut Shell<'_>) {
vec2(w, if sub.is_empty() { 30.0 } else { 42.0 }),
Sense::click(),
);
resp.context_menu(|ui| {
for (label, v) in [("Copy debit", d), ("Copy credit", c)] {
if !v.is_zero() {
widgets::copy_item(
ui,
label,
&fmt::plain(&fmt::money(v)).unwrap_or_default(),
);
}
}
widgets::copy_item(
ui,
"Copy balance",
&fmt::plain(&fmt::money(bal)).unwrap_or_default(),
);
if let Some(id) = sub.strip_prefix('#').and_then(|t| t.split(' ').next()) {
widgets::copy_item(ui, "Copy entry number", &format!("#{id}"));
}
});
if resp.hovered() && !strong {
ui.painter().rect_filled(r, CornerRadius::same(6), p.hover);
}