ok i gotta make it so plugins can define a save function

This commit is contained in:
2026-05-16 21:31:57 +10:00
parent fc07ffbfa8
commit b43392d0b7

10
main.py
View File

@@ -49,7 +49,7 @@ class Berry(App):
Binding(self.bindings["open"], "open", "Open File"),
Binding(self.bindings["save"], "save", "Save File"),
Binding(self.bindings["save-as"], "save_as", "Save File As..."),
Binding(self.bindings["find"], "find", "Find and Replace"),
Binding(self.bindings["find"], "find", "Find and Replace", priority=True), # this is priority because otherwise TextArea overrides it
Binding(self.bindings["settings"], "settings", "Settings"),
)
@@ -181,7 +181,7 @@ class Berry(App):
),
),
icon="🔍",
icon="󰍉",
start_open=True,
allow_resize=False,
allow_maximize=False,
@@ -333,8 +333,8 @@ class Berry(App):
def done_saving(self, result):
if result is None: return
with open(result, "w", encoding="utf-8") as f:
f.write(self.query_one("#code-editor").text)
#with open(result, "w", encoding="utf-8") as f:
# f.write(self.query_one("#code-editor").text)
tabs: Tabs = self.query_one("#file-tabs")
tabs.active_tab.label = os.path.basename(result)
@@ -345,7 +345,7 @@ class Berry(App):
self.push_screen(FileSave(), callback=self.done_saving)
def action_save(self):
if self.open_file == None and self.query_one("#code-editor").disabled == False:
if self.open_file == None:
self.action_save_as()
# dont bother saving if there are no new changes