diff --git a/connect_gui.py b/connect_gui.py
index 998da25..1ef3183 100644
--- a/connect_gui.py
+++ b/connect_gui.py
@@ -7,3 +7,4 @@ def connect_gui(app):
app.gui.QTMainWindow.closeEvent = app.utils.on_close
app.gui.main_window.menuSettings.triggered.connect(app.gui.main_window.settingsDock.show)
app.gui.main_window.bitsAreSquaresSetting.stateChanged.connect(app.utils.update_font_in_all_bit_editors)
+ app.gui.main_window.highlightOnesSetting.stateChanged.connect(app.utils.update_font_in_all_bit_editors)
diff --git a/gui/raw_ui/main_window.ui b/gui/raw_ui/main_window.ui
index da95905..d90abb6 100644
--- a/gui/raw_ui/main_window.ui
+++ b/gui/raw_ui/main_window.ui
@@ -66,6 +66,18 @@
true
+
+
+ 0
+ 0
+
+
+
+
+ 200
+ 124
+
+
@@ -88,10 +100,22 @@
-
+
+
+ 0
+ 0
+
+
0
+
+
+ 0
+ 0
+
+
@@ -101,18 +125,35 @@
Appearance
-
-
-
-
-
- Bits are squares
-
-
- false
-
-
-
-
+
+
+
+ 10
+ 10
+ 111
+ 21
+
+
+
+ Highlight ones
+
+
+
+
+
+ 10
+ 30
+ 119
+ 21
+
+
+
+ Bits are squares
+
+
+ false
+
+
diff --git a/main.py b/main.py
index 2b38f13..36b9777 100755
--- a/main.py
+++ b/main.py
@@ -12,11 +12,13 @@ class BreadEditor:
def __init__(self):
self.settings = load_dataclass_json(Settings, "settings.json")
setattr(self.settings, "save", lambda: save_dataclass_json(self.settings, "settings.json"))
+ print(self.settings.highlight_ones)
# save the file module to a variable because we need to use it in other classes but we change some file class --
# variables that also need to be accesible from the other classes.
self.file = file
File = file.File
+
self.utils = Utils(self)
self.file_actions = file.FileActions(self)
self.gui = GUI(self)
diff --git a/settings.py b/settings.py
index 47bf7f9..532cb30 100644
--- a/settings.py
+++ b/settings.py
@@ -7,4 +7,5 @@ from dataclasses import dataclass
@dataclass
class Settings:
last_opened_file: str=f"{os.path.dirname(os.path.abspath(__file__))}/example.txt"
+ highlight_ones: bool=False
square_bits: bool=False
diff --git a/ui.py b/ui.py
index 1a9d7aa..b863a21 100644
--- a/ui.py
+++ b/ui.py
@@ -29,3 +29,13 @@ class GUI:
spacing = 200 if self.app.settings.square_bits else 100
self.app.file.BitEditor.font.setLetterSpacing(QFont.SpacingType.PercentageSpacing, spacing)
+
+ print(self.app.settings.highlight_ones)
+ self.main_window.highlightOnesSetting.setChecked(self.app.settings.highlight_ones)
+
+ for file_path in self.app.open_files:
+ editor = self.app.open_files[file_path].bit_editor
+
+ highlighter_document = editor.input.document() if self.app.settings.highlight_ones else None
+
+ editor.bit_highlighter.setDocument(highlighter_document)
diff --git a/utils.py b/utils.py
index 0d959a8..0723f74 100644
--- a/utils.py
+++ b/utils.py
@@ -88,12 +88,19 @@ class Utils:
self.app.settings.save()
def update_font_in_all_bit_editors(self):
+ self.app.settings.highlight_ones = self.app.gui.main_window.highlightOnesSetting.isChecked()
self.app.settings.square_bits = self.app.gui.main_window.bitsAreSquaresSetting.isChecked()
for file_path in self.app.open_files:
editor = self.app.open_files[file_path].bit_editor
- square = self.app.gui.main_window.bitsAreSquaresSetting.isChecked()
+ highlight_ones = self.app.settings.highlight_ones
+
+ highlighter_document = editor.input.document() if highlight_ones else None
+
+ editor.bit_highlighter.setDocument(highlighter_document)
+
+ square = self.app.settings.square_bits
spacing = 200 if square else 100 # add spacing when setting is checked