ok i gotta make it so plugins can define a save function
This commit is contained in:
10
main.py
10
main.py
@@ -49,7 +49,7 @@ class Berry(App):
|
|||||||
Binding(self.bindings["open"], "open", "Open File"),
|
Binding(self.bindings["open"], "open", "Open File"),
|
||||||
Binding(self.bindings["save"], "save", "Save File"),
|
Binding(self.bindings["save"], "save", "Save File"),
|
||||||
Binding(self.bindings["save-as"], "save_as", "Save File As..."),
|
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"),
|
Binding(self.bindings["settings"], "settings", "Settings"),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ class Berry(App):
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
icon="🔍",
|
icon="",
|
||||||
start_open=True,
|
start_open=True,
|
||||||
allow_resize=False,
|
allow_resize=False,
|
||||||
allow_maximize=False,
|
allow_maximize=False,
|
||||||
@@ -333,8 +333,8 @@ class Berry(App):
|
|||||||
def done_saving(self, result):
|
def done_saving(self, result):
|
||||||
if result is None: return
|
if result is None: return
|
||||||
|
|
||||||
with open(result, "w", encoding="utf-8") as f:
|
#with open(result, "w", encoding="utf-8") as f:
|
||||||
f.write(self.query_one("#code-editor").text)
|
# f.write(self.query_one("#code-editor").text)
|
||||||
|
|
||||||
tabs: Tabs = self.query_one("#file-tabs")
|
tabs: Tabs = self.query_one("#file-tabs")
|
||||||
tabs.active_tab.label = os.path.basename(result)
|
tabs.active_tab.label = os.path.basename(result)
|
||||||
@@ -345,7 +345,7 @@ class Berry(App):
|
|||||||
self.push_screen(FileSave(), callback=self.done_saving)
|
self.push_screen(FileSave(), callback=self.done_saving)
|
||||||
|
|
||||||
def action_save(self):
|
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()
|
self.action_save_as()
|
||||||
|
|
||||||
# dont bother saving if there are no new changes
|
# dont bother saving if there are no new changes
|
||||||
|
|||||||
Reference in New Issue
Block a user