added a line numbers option
This commit is contained in:
2
main.py
2
main.py
@@ -66,7 +66,7 @@ class Berry(App):
|
|||||||
first_tab,
|
first_tab,
|
||||||
id="file-tabs"
|
id="file-tabs"
|
||||||
)
|
)
|
||||||
yield TextArea.code_editor(placeholder="This file is empty.", theme="css", id="code-editor", disabled=True, soft_wrap=True)
|
yield TextArea.code_editor(placeholder="This file is empty.", theme="css", id="code-editor", disabled=True, soft_wrap=True, show_line_numbers=bool(int(self.config_handler.get("editor", "line_numbers"))))
|
||||||
|
|
||||||
#if os.name == "nt":
|
#if os.name == "nt":
|
||||||
#with Vertical(id="console-container"):
|
#with Vertical(id="console-container"):
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ class SettingsScreen(ModalScreen):
|
|||||||
if event.switch.id == "word-wrap":
|
if event.switch.id == "word-wrap":
|
||||||
self.app.query_one("#code-editor").soft_wrap = event.value
|
self.app.query_one("#code-editor").soft_wrap = event.value
|
||||||
self.app.config_handler.set("editor", "word_wrap", str(int(event.value)))
|
self.app.config_handler.set("editor", "word_wrap", str(int(event.value)))
|
||||||
|
elif event.switch.id == "line-numbers":
|
||||||
|
self.app.query_one("#code-editor").show_line_numbers = event.value
|
||||||
|
self.app.config_handler.set("editor", "line_numbers", str(int(event.value)))
|
||||||
elif event.switch.id == "plugins-enabled":
|
elif event.switch.id == "plugins-enabled":
|
||||||
self.app.config_handler.set("plugins", "enabled", str(int(event.value)))
|
self.app.config_handler.set("plugins", "enabled", str(int(event.value)))
|
||||||
self.notify("Restart for changes to apply.", title="Restart Required", severity="warning")
|
self.notify("Restart for changes to apply.", title="Restart Required", severity="warning")
|
||||||
@@ -122,6 +125,12 @@ class SettingsScreen(ModalScreen):
|
|||||||
yield Label("Word Wrap", classes="setting-name")
|
yield Label("Word Wrap", classes="setting-name")
|
||||||
yield Label("Enable word wrap in the code editor.", classes="setting-desc")
|
yield Label("Enable word wrap in the code editor.", classes="setting-desc")
|
||||||
yield Switch(value=bool(int(self.app.config_handler.get("editor", "word_wrap"))), id="word-wrap")
|
yield Switch(value=bool(int(self.app.config_handler.get("editor", "word_wrap"))), id="word-wrap")
|
||||||
|
|
||||||
|
with HorizontalGroup(classes="setting"):
|
||||||
|
with VerticalGroup():
|
||||||
|
yield Label("Line Numbers", classes="setting-name")
|
||||||
|
yield Label("Show line numbers in the editor.", classes="setting-desc")
|
||||||
|
yield Switch(value=bool(int(self.app.config_handler.get("editor", "line_numbers"))), id="line-numbers")
|
||||||
with TabPane("Plugins"):
|
with TabPane("Plugins"):
|
||||||
with VerticalScroll():
|
with VerticalScroll():
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ class ConfigHandler:
|
|||||||
return config_dir
|
return config_dir
|
||||||
|
|
||||||
def get(self, section: str, option: str):
|
def get(self, section: str, option: str):
|
||||||
|
if not self.config.has_section(section):
|
||||||
|
self.config.add_section(section)
|
||||||
|
if not self.config.has_option(section, option):
|
||||||
|
self.set(section, option, "0")
|
||||||
|
return "0"
|
||||||
|
|
||||||
return self.config.get(section, option, fallback=None)
|
return self.config.get(section, option, fallback=None)
|
||||||
|
|
||||||
def set(self, section: str, option: str, new_value: str):
|
def set(self, section: str, option: str, new_value: str):
|
||||||
@@ -86,7 +92,8 @@ class ConfigHandler:
|
|||||||
"version": "1"
|
"version": "1"
|
||||||
}
|
}
|
||||||
self.config["editor"] = {
|
self.config["editor"] = {
|
||||||
"word_wrap": "0"
|
"word_wrap": "0",
|
||||||
|
"line_numbers": "1"
|
||||||
}
|
}
|
||||||
self.config["plugins"] = {
|
self.config["plugins"] = {
|
||||||
"enabled": "1",
|
"enabled": "1",
|
||||||
|
|||||||
Reference in New Issue
Block a user