adds Clean Copy Support
This commit is contained in:
@@ -15,6 +15,39 @@ extension WorkspaceModel {
|
||||
default:
|
||||
break
|
||||
}
|
||||
if new == .none, cleanCopy?.pending != nil {
|
||||
Task { @MainActor [weak self] in self?.showCleanCopy() }
|
||||
}
|
||||
}
|
||||
|
||||
/// `.clean-copy` changed on disk: new text opens the popup, or waits for the open overlay to close.
|
||||
func cleanCopyChanged() async {
|
||||
guard let cleanCopy else { return }
|
||||
let current = generation
|
||||
guard await cleanCopy.fileChanged(), generation == current, self.cleanCopy === cleanCopy else { return }
|
||||
showCleanCopy()
|
||||
}
|
||||
|
||||
/// Shows the pending clean-copy text when nothing else floats over the workspace.
|
||||
func showCleanCopy() {
|
||||
guard let cleanCopy, cleanCopy.pending != nil else { return }
|
||||
switch overlay.current {
|
||||
case .none:
|
||||
cleanCopy.takePending()
|
||||
overlay.present(.cleanCopy)
|
||||
case .cleanCopy:
|
||||
cleanCopy.refreshOpenPopup()
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/// Copies the popup's text as plain text, closes it and confirms with a toast.
|
||||
func copyCleanCopy() {
|
||||
guard let cleanCopy, overlay.current == .cleanCopy else { return }
|
||||
app.system.copy(cleanCopy.text)
|
||||
overlay.dismiss()
|
||||
toasts.show("Copied", detail: "\(cleanCopy.characterCount) characters")
|
||||
}
|
||||
|
||||
/// The recent projects other than this one, for ⇧⌘O.
|
||||
|
||||
Reference in New Issue
Block a user