actually load the settings when you open the app

This commit is contained in:
SpookyDervish
2025-10-30 07:20:01 +11:00
parent 7bc671ef63
commit 4f23e7570c
3 changed files with 40 additions and 12 deletions

View File

@@ -1,10 +1,12 @@
from textual.app import App
from pathlib import Path
import os
import configparser
class ConfigHandler:
def __init__(self):
def __init__(self, app: App):
self.app: App = app
self.config: configparser.ConfigParser = configparser.ConfigParser()
self.config_dir: str = self.ensure_hidden_config_dir()
@@ -20,7 +22,17 @@ class ConfigHandler:
return self.config.get(section, option)
def set(self, section: str, option: str, new_value: str):
return self.config.set(section, option, new_value)
self.config.set(section, option, new_value)
self.write_settings()
def apply_settings(self):
self.app.query_one("#code-editor").soft_wrap = bool(int(self.get("editor", "word_wrap")))
self.app.theme = self.get("appearance", "colour_theme")
self.app.notify(self.get("appearance", "colour_theme"))
def write_settings(self):
with open(self.config_dir / "config.ini", "w") as configfile:
self.config.write(configfile)
def load_settings(self):
if os.path.isfile(self.config_dir / "config.ini"):