Skip to content

Commit

Permalink
feat: add keybind to remove node
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Sep 16, 2024
1 parent 2c425a8 commit 5447f95
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dooit/ui/api/dooit_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def toggle_expand_parent(self):
def add_child_node(self):
self.focused.add_child_node()

def remove_node(self):
self.focused.remove_node()

def set_workspace_layout(self, layout: WorkspaceLayout):
registry.set_workspace_layout(layout)
self.app.workspace_tree.refresh_options()
Expand Down
7 changes: 7 additions & 0 deletions dooit/ui/widgets/trees/model_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ def add_sibling(self):
self.highlighted = self.get_option_index(node.uuid)
self.start_edit("description")

def remove_node(self):
if self.highlighted is None:
return

self.current_model.drop()
self.force_refresh()

@fix_highlight
def shift_up(self) -> None:
self.current_model.shift_up()
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 @@ -42,6 +42,7 @@ def key_setup(api: DooitAPI):
api.set_key_normal("A", api.add_child_node)
api.set_key_normal("J", api.shift_down)
api.set_key_normal("K", api.shift_up)
api.set_key_normal("x", api.remove_node)

api.set_workspace_layout([WorkspaceComponent.description])

Expand Down

0 comments on commit 5447f95

Please sign in to comment.