Skip to content

Commit

Permalink
feat: copy description from todos and workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Nov 25, 2024
1 parent 9a61998 commit 5e287c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dooit/ui/api/dooit_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down
4 changes: 4 additions & 0 deletions dooit/ui/widgets/trees/model_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions dooit/utils/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5e287c7

Please sign in to comment.