copyNoteText writes the title (if any) and body to the system clipboard, joined with a blank line. Updates the toast in place of error logs.
(title, body string)
| 1011 | // copyNoteText writes the title (if any) and body to the system clipboard, |
| 1012 | // joined with a blank line. Updates the toast in place of error logs. |
| 1013 | func (m *model) copyNoteText(title, body string) { |
| 1014 | parts := []string{} |
| 1015 | if title != "" { |
| 1016 | parts = append(parts, title) |
| 1017 | } |
| 1018 | if body != "" { |
| 1019 | parts = append(parts, body) |
| 1020 | } |
| 1021 | if len(parts) == 0 { |
| 1022 | m.setToast("nothing to copy") |
| 1023 | return |
| 1024 | } |
| 1025 | joined := parts[0] |
| 1026 | if len(parts) > 1 { |
| 1027 | joined = parts[0] + "\n\n" + parts[1] |
| 1028 | } |
| 1029 | if err := clipboard.WriteAll(joined); err == nil { |
| 1030 | m.setToast("copied note") |
| 1031 | } else { |
| 1032 | m.setToast("clipboard unavailable") |
| 1033 | } |
| 1034 | } |
| 1035 | |
| 1036 | // --- mouse handlers --------------------------------------------------- |
| 1037 |
no test coverage detected