add opening files

This commit is contained in:
2026-07-28 15:59:58 +10:00
parent 2e80aa7553
commit 66ce2fed82
3 changed files with 17 additions and 2 deletions

1
new.txt Normal file
View File

@@ -0,0 +1 @@
content

View File

@@ -44,7 +44,7 @@ class Berry(App):
Binding(self.bind_keys['open'], "open_file", "Open file"),
Binding(self.bind_keys['open-folder'], "open_folder", "Open directory"),
Binding(self.bind_keys['save'], "save", "Save"),
Binding(self.bind_keys['save-as'], "save_as", "Save as..."),
Binding(self.bind_keys['save-as'], "save_as", "Save as...", priority=True),
Binding(self.bind_keys['home'], "home", "Home"),
Binding(self.bind_keys['find'], "find", "Find and replace")
)
@@ -67,6 +67,12 @@ class Berry(App):
async def action_save(self):
await self.file_tabs.save()
async def action_save_as(self):
await self.file_tabs.save_as()
async def action_open_file(self):
await self.file_tabs.open_file_dialog()
async def action_new(self):
await self.file_tabs.new_file()

View File

@@ -88,7 +88,7 @@ class FileTabs(TabbedContent):
await self.remove_pane(self.active)
for tab in self.query(TabPane):
if isinstance(self.active_pane, HomeTab):
if isinstance(tab, HomeTab):
continue
if tab.path == new_path:
@@ -154,6 +154,14 @@ class FileTabs(TabbedContent):
file_tab.saved = True
async def open_file_dialog(self):
async def callback(path: str | None):
if path == None:
return
await self.open_file(path)
await self.app.push_screen(FileOpen(), callback=callback)
async def open_home(self) -> None:
await self.add_pane(HomeTab())