add opening files
This commit is contained in:
@@ -44,7 +44,7 @@ class Berry(App):
|
|||||||
Binding(self.bind_keys['open'], "open_file", "Open file"),
|
Binding(self.bind_keys['open'], "open_file", "Open file"),
|
||||||
Binding(self.bind_keys['open-folder'], "open_folder", "Open directory"),
|
Binding(self.bind_keys['open-folder'], "open_folder", "Open directory"),
|
||||||
Binding(self.bind_keys['save'], "save", "Save"),
|
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['home'], "home", "Home"),
|
||||||
Binding(self.bind_keys['find'], "find", "Find and replace")
|
Binding(self.bind_keys['find'], "find", "Find and replace")
|
||||||
)
|
)
|
||||||
@@ -67,6 +67,12 @@ class Berry(App):
|
|||||||
async def action_save(self):
|
async def action_save(self):
|
||||||
await self.file_tabs.save()
|
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):
|
async def action_new(self):
|
||||||
await self.file_tabs.new_file()
|
await self.file_tabs.new_file()
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class FileTabs(TabbedContent):
|
|||||||
await self.remove_pane(self.active)
|
await self.remove_pane(self.active)
|
||||||
|
|
||||||
for tab in self.query(TabPane):
|
for tab in self.query(TabPane):
|
||||||
if isinstance(self.active_pane, HomeTab):
|
if isinstance(tab, HomeTab):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if tab.path == new_path:
|
if tab.path == new_path:
|
||||||
@@ -154,6 +154,14 @@ class FileTabs(TabbedContent):
|
|||||||
|
|
||||||
file_tab.saved = True
|
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:
|
async def open_home(self) -> None:
|
||||||
await self.add_pane(HomeTab())
|
await self.add_pane(HomeTab())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user