Skip to content

Commit

Permalink
[rename] rebind remove
Browse files Browse the repository at this point in the history
  • Loading branch information
NextFire committed Feb 8, 2024
1 parent 454aec6 commit d880a14
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions sachi/screens/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class RenameScreen(Screen):
SUB_TITLE = "Rename"
CSS_PATH = __file__.replace(".py", ".tcss")
BINDINGS = [
("x", "remove_element", "Remove"),
("j", "move('down')", "Move Down"),
("k", "move('up')", "Move Up"),
("d", "remove_element", "Remove"),
("p", "apply_renames", "Apply"),
]

Expand Down Expand Up @@ -67,6 +67,19 @@ async def on_mount(self):

# Key bindings

def action_remove_element(self):
table = self.query_one(DataTable)
cell_key = table.coordinate_to_cell_key(table.cursor_coordinate)
col_i = table.cursor_column
match col_i:
case 0:
table.remove_row(cell_key.row_key)
del self.files[cell_key.row_key]
case 1:
self.files[cell_key.row_key].match = None
case _:
raise RuntimeError(f"Invalid column: {col_i}")

def action_move(self, direction: Literal["up", "down"]):
with suppress(CellDoesNotExist):
table = self.query_one(DataTable)
Expand Down Expand Up @@ -113,19 +126,6 @@ def action_move(self, direction: Literal["up", "down"]):
case _:
assert_never(direction)

def action_remove_element(self):
table = self.query_one(DataTable)
cell_key = table.coordinate_to_cell_key(table.cursor_coordinate)
col_i = table.cursor_column
match col_i:
case 0:
table.remove_row(cell_key.row_key)
del self.files[cell_key.row_key]
case 1:
self.files[cell_key.row_key].match = None
case _:
raise RuntimeError(f"Invalid column: {col_i}")

async def action_apply_renames(self):
table = self.query_one(DataTable)
for row in table.ordered_rows:
Expand Down

0 comments on commit d880a14

Please sign in to comment.