Implemented that the editor opens the file that gets specified by command line argument.

This commit is contained in:
The Wobbler 2024-12-07 20:34:24 +01:00
parent e2350c3711
commit 27e26903fb
2 changed files with 9 additions and 2 deletions

View file

@ -22,7 +22,7 @@ class BreadEditor:
def run(self):
self.gui.post_setup()
self.utils.open_last_file()
self.utils.on_start()
self.utils.popup_init()

View file

@ -106,7 +106,7 @@ class Utils:
editor.update_style()
def open_last_file(self):
def on_start(self):
if len(sys.argv) == 1: # if no parameters were passed to the editor
file_path = self.app.settings.last_opened_file
@ -118,3 +118,10 @@ class Utils:
file_path = f"{os.path.dirname(os.path.abspath(__file__))}/example.txt"
file = File(self.app, file_path, file_path.split("/")[-1])
self.app.open_files[file_path] = file
else:
file_path = sys.argv[1]
if os.path.isfile(file_path):
file = File(self.app, file_path, file_path.split("/")[-1])
self.app.open_files[file_path] = file