From e768f7342ed979195d2ad831f6c95234f986f40b Mon Sep 17 00:00:00 2001 From: fireaid101 Date: Sun, 1 Mar 2026 15:54:14 +0200 Subject: [PATCH 1/2] Updated default css + added support for editor coloring - Fixed cutoff scrollbar with default style.css - Added support for a custom css tag called Editor in which users can define background and foregrounds colors for the actual editor part of the text editor. No more being stuck on white - Created a new theme called really dark, which is a more dark-mode friendly styled text-editor. --- .gitignore | 3 +- scratchpad.py | 35 ++++++++++- style.css | 49 +++++++++++++-- themes/default.css | 92 ++++++++++++++++++++++++++++ themes/really-dark.css | 136 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 309 insertions(+), 6 deletions(-) create mode 100644 themes/default.css create mode 100644 themes/really-dark.css diff --git a/.gitignore b/.gitignore index 29f4159..04ddfec 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ *.spec __pycache__/ *.pyc -.DS_Store \ No newline at end of file +.DS_Store +venv \ No newline at end of file diff --git a/scratchpad.py b/scratchpad.py index 1f6cab7..09fdf4b 100644 --- a/scratchpad.py +++ b/scratchpad.py @@ -9,8 +9,9 @@ QFileDialog, QMessageBox, QStatusBar, QDialog, QInputDialog, QVBoxLayout, QLabel, QLineEdit, QPushButton, QHBoxLayout) from PyQt5.QtCore import QThread, pyqtSignal, Qt, QSettings, QSignalBlocker -from PyQt5.QtGui import QIcon, QFont, QFontDatabase, QTextDocument +from PyQt5.QtGui import QIcon, QFont, QFontDatabase, QTextDocument, QColor from PyQt5.Qsci import QsciScintilla, QsciScintillaBase +import re @@ -373,6 +374,38 @@ def __init__(self, parent=None): self._zoom = 0 self.setUtf8(True) if hasattr(self, 'setUtf8') else None + css_file_path = os.path.join(os.path.dirname(__file__), 'style.css') + + if os.path.exists(css_file_path): + css_file = open('style.css') + + class_name = 'Editor' + regex_pattern = rf"\b{class_name}\b\s*\{{([^}}]*)\}}" + + match = re.search(regex_pattern, css_file.read(), re.IGNORECASE) + + if match: + internals = match.group(1).strip() + + bg_match = re.search(r"background-color\s*:\s*([^;]+)", internals) + text_match = re.search(r"(? Date: Sun, 1 Mar 2026 16:03:22 +0200 Subject: [PATCH 2/2] Removed redudant else statment --- scratchpad.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scratchpad.py b/scratchpad.py index 09fdf4b..44928fe 100644 --- a/scratchpad.py +++ b/scratchpad.py @@ -399,8 +399,6 @@ def __init__(self, parent=None): self.setColor(QColor(text_color)) self.setCaretForegroundColor(QColor(text_color)) - else: - print("Selector not found.") css_file.close() else: print("Default CSS file not found: {css_file_path}")