From 5e287c79652568fd0932dce09ab2eebca325e72f Mon Sep 17 00:00:00 2001 From: kraanzu Date: Mon, 25 Nov 2024 12:33:29 +0530 Subject: [PATCH] feat: copy description from todos and workspaces --- dooit/ui/api/dooit_api.py | 5 +++++ dooit/ui/widgets/trees/model_tree.py | 4 ++++ dooit/utils/default_config.py | 1 + 3 files changed, 10 insertions(+) diff --git a/dooit/ui/api/dooit_api.py b/dooit/ui/api/dooit_api.py index a63856cd..31f2b321 100644 --- a/dooit/ui/api/dooit_api.py +++ b/dooit/ui/api/dooit_api.py @@ -76,6 +76,11 @@ def focused(self) -> ModelTree: raise ValueError(f"Expected BaseTree, got {type(focused)}") + def copy_description_to_clipboard(self): + """Copy the description of the focused item to the clipboard""" + + self.focused.copy_description_to_clipboard() + def switch_focus(self): """Switch focus between the workspace and the todo list""" diff --git a/dooit/ui/widgets/trees/model_tree.py b/dooit/ui/widgets/trees/model_tree.py index a76d0bb5..854b6af9 100644 --- a/dooit/ui/widgets/trees/model_tree.py +++ b/dooit/ui/widgets/trees/model_tree.py @@ -228,6 +228,10 @@ def refresh_options(self) -> None: def _get_parent(self, id: str) -> Optional[ModelType]: raise NotImplementedError # pragma: no cover + @require_highlighted_node + def copy_description_to_clipboard(self): + self.app.copy_to_clipboard(self.current_model.description) + @refresh_tree def _expand_node(self, _id: str) -> None: self.expanded_nodes[_id] = True diff --git a/dooit/utils/default_config.py b/dooit/utils/default_config.py index d537e905..0f70ec66 100644 --- a/dooit/utils/default_config.py +++ b/dooit/utils/default_config.py @@ -140,6 +140,7 @@ def key_setup(api: DooitAPI, _): api.keys.set("J", api.shift_down) api.keys.set("K", api.shift_up) api.keys.set("xx", api.remove_node) + api.keys.set("y", api.copy_description_to_clipboard) api.keys.set("c", api.toggle_complete) api.keys.set(["=", "+"], api.increase_urgency) api.keys.set(["-", "_"], api.decrease_urgency)