Skip to content

Commit

Permalink
Merge pull request #32 from mostypc123/themes
Browse files Browse the repository at this point in the history
Themes
  • Loading branch information
mostypc123 authored Dec 8, 2024
2 parents b98f393 + 0df169c commit 2874058
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 41 deletions.
38 changes: 38 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Source Code of XediX
In this folder, you can find the source code of XediX. **Here is a explanation of what all the files mean.**

### main.py
really? do you need a description of a file that is called main?!
### tools.py
The tools selector in XediX, when you press <kbd>Ctrl</kbd>+<kbd>T</kbd>, or select _Tools_ / _Tools_ in the menu.
### tools/*
The tools included in XediX.
### requirements.txt
The requirements to run XediX using Python. Run this to install:
```sh
# Windows
pip install -r reqiurements.txt
# macOS / Linux
pip3 install -r requirements.txt
```
### extension_*.py
The extension files.
### theme.xcfg
A XediX config file to set up themes.
Available themes: **Dark**, **Light**, **Obsidian** and **Night**.
As a default theme is set ```dark```.

## Themes (reference to theme.xcfg)

### Obsidian
![image](https://github.com/user-attachments/assets/99e3fa28-3726-411a-8618-81523ea4c888)

### Dark (default)
![image](https://github.com/user-attachments/assets/1376d058-5d2f-40ab-b5ea-8cd2faa2922c)

### Light
For the native UI guys.
![image](https://github.com/user-attachments/assets/9c2628b2-4d4c-4f44-8bf2-70cbc93afb90)

### Night
![image](https://github.com/user-attachments/assets/f2099e94-8d2a-434f-9867-0d4c1b22129d)
100 changes: 59 additions & 41 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,25 @@ def OnFileOpen(self, event):
text_area.Bind(wx.EVT_CHAR, self.OnChar)

# Set dark background and light text for the entire control
dark_bg_color = "#1E1E1E"
light_text_color = "#FFFFFF"

with open("theme.xcfg", 'r') as file:
theme = file.read()

if theme == "dark":
dark_bg_color = "#1E1E1E"
elif theme == "light":
dark_bg_color = "#FFFFFF"
light_text_color = "#1e1e1e"
elif theme == "night":
dark_bg_color = "#000000"
elif theme == "obsidian":
dark_bg_color = "#1A1B38"
else:
dark_bg_color = "#1E1E1E"

if theme != "light":
light_text_color = "#FFFFFF"

text_area.StyleSetBackground(stc.STC_STYLE_DEFAULT, dark_bg_color)
text_area.StyleSetForeground(stc.STC_STYLE_DEFAULT, light_text_color)
text_area.StyleClearAll() # Apply the default style to all text
Expand All @@ -344,131 +361,132 @@ def OnFileOpen(self, event):
text_area.SetLexer(stc.STC_LEX_PYTHON)

# Comments
text_area.StyleSetSpec(stc.STC_P_COMMENTLINE, "fore:#68C147,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_P_COMMENTLINE, f"fore:#68C147,italic,back:{dark_bg_color}")

# Strings
text_area.StyleSetSpec(stc.STC_P_STRING, "fore:#BA9EFE,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_P_STRING, f"fore:#BA9EFE,italic,back:{dark_bg_color}")

# Keywords
text_area.StyleSetSpec(stc.STC_P_WORD, "fore:#569CD6,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_P_WORD, f"fore:#569CD6,bold,back:{dark_bg_color}")
text_area.SetKeyWords(0,
"def class return if else elif import from as not is try except finally for while in with pass lambda")

# Functions and variables
text_area.StyleSetSpec(stc.STC_P_IDENTIFIER, "fore:#7BCCE1,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_P_IDENTIFIER, f"fore:#7BCCE1,italic,back:{dark_bg_color}")

# Operators
text_area.StyleSetSpec(stc.STC_P_OPERATOR, "fore:#D4D4D4,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_P_OPERATOR, f"fore:#D4D4D4,bold,back:{dark_bg_color}")

# Numbers
text_area.StyleSetSpec(stc.STC_P_NUMBER, "fore:#FFDD54,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_P_NUMBER, f"fore:#FFDD54,italic,back:{dark_bg_color}")

# Decorators
text_area.StyleSetSpec(stc.STC_P_DECORATOR, "fore:#C586C0,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_P_DECORATOR, f"fore:#C586C0,italic,back:{dark_bg_color}")

elif file_name.endswith(".html"):
self.SetStatusText("HTML", 1)
# Set up HTML syntax highlighting
text_area.SetLexer(stc.STC_LEX_HTML)

# Tags
text_area.StyleSetSpec(stc.STC_H_TAG, "fore:#569CD6,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_H_TAG, f"fore:#569CD6,bold,back:{dark_bg_color}")

# Attributes
text_area.StyleSetSpec(stc.STC_H_ATTRIBUTE, "fore:#D69D85,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_H_ATTRIBUTE, f"fore:#D69D85,italic,back:{dark_bg_color}")

# Attribute values
text_area.StyleSetSpec(stc.STC_H_VALUE, "fore:#BA9EFE,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_H_VALUE, f"fore:#BA9EFE,italic,back:{dark_bg_color}")

# Comments
text_area.StyleSetSpec(stc.STC_H_COMMENT, "fore:#68C147,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_H_COMMENT, f"fore:#68C147,italic,back:{dark_bg_color}")

# Entities
text_area.StyleSetSpec(stc.STC_H_ENTITY, "fore:#FFDD54,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_H_ENTITY, f"fore:#FFDD54,italic,back:{dark_bg_color}")

# Numbers
text_area.StyleSetSpec(stc.STC_H_NUMBER, "fore:#FFDD54,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_H_NUMBER, f"fore:#FFDD54,italic,back:{dark_bg_color}")

# Operators (like '=')
text_area.StyleSetSpec(stc.STC_H_OTHER, "fore:#D4D4D4,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_H_OTHER, f"fore:#D4D4D4,bold,back:{dark_bg_color}")

elif file_name.endswith(".json"):
self.SetStatusText("JSON", 1)
# Set up JSON syntax highlighting
text_area.SetLexer(stc.STC_LEX_JSON)

# Strings (e.g., "key" or "value")
text_area.StyleSetSpec(stc.STC_JSON_STRING, "fore:#BA9EFE,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_JSON_STRING, f"fore:#BA9EFE,italic,back:{dark_bg_color}")

# Numbers (e.g., 123, 3.14)
text_area.StyleSetSpec(stc.STC_JSON_NUMBER, "fore:#FFDD54,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_JSON_NUMBER, f"fore:#FFDD54,back:{dark_bg_color}")

# Colons (e.g., in "key": "value")
text_area.StyleSetSpec(stc.STC_JSON_OPERATOR, "fore:#D4D4D4,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_JSON_OPERATOR, f"fore:#D4D4D4,bold,back:{dark_bg_color}")

# Keywords (e.g., true, false, null)
text_area.StyleSetSpec(stc.STC_JSON_KEYWORD, "fore:#68C147,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_JSON_KEYWORD, f"fore:#68C147,bold,back:{dark_bg_color}")

elif file_name.endswith(".css"):
self.SetStatusText("CSS", 1)
# Set up CSS syntax highlighting
text_area.SetLexer(stc.STC_LEX_CSS)

# Default text
text_area.StyleSetSpec(stc.STC_CSS_DEFAULT, "fore:#D4D4D4,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_DEFAULT, f"fore:#D4D4D4,back:{dark_bg_color}")

# Comments (e.g., /* This is a comment */)
text_area.StyleSetSpec(stc.STC_CSS_COMMENT, "fore:#68C147,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_COMMENT, f"fore:#68C147,italic,back:{dark_bg_color}")

# Tag Names (e.g., body, h1, div)
text_area.StyleSetSpec(stc.STC_CSS_TAG, "fore:#569CD6,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_TAG, f"fore:#569CD6,bold,back:{dark_bg_color}")

# Class and IDs (e.g., .className, #idName)
text_area.StyleSetSpec(stc.STC_CSS_CLASS, "fore:#7BCCE1,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_ID, "fore:#FFAA33,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_CLASS, f"fore:#7BCCE1,italic,back:{dark_bg_color}")
text_area.StyleSetSpec(stc.STC_CSS_ID, f"fore:#FFAA33,italic,back:{dark_bg_color}")

# Attributes (e.g., color, margin, padding)
text_area.StyleSetSpec(stc.STC_CSS_ATTRIBUTE, "fore:#BA9EFE,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_ATTRIBUTE, f"fore:#BA9EFE,bold,back:{dark_bg_color}")

# Pseudo-classes and Elements (e.g., :hover, ::before)
text_area.StyleSetSpec(stc.STC_CSS_PSEUDOCLASS, "fore:#C586C0,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_PSEUDOELEMENT, "fore:#C586C0,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_PSEUDOCLASS, f"fore:#C586C0,italic,back:{dark_bg_color}")
text_area.StyleSetSpec(stc.STC_CSS_PSEUDOELEMENT, f"fore:#C586C0,italic,back:{dark_bg_color}")

# Property Values (e.g., red, 10px, 1em)
text_area.StyleSetSpec(stc.STC_CSS_VALUE, "fore:#FFDD54,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_VALUE, f"fore:#FFDD54,back:{dark_bg_color}")

# Operators (e.g., :, ;, {, })
text_area.StyleSetSpec(stc.STC_CSS_OPERATOR, "fore:#D4D4D4,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_OPERATOR, f"fore:#D4D4D4,bold,back:{dark_bg_color}")

# Import Statement (e.g., @import)
text_area.StyleSetSpec(stc.STC_CSS_DIRECTIVE, "fore:#68C147,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_CSS_DIRECTIVE, f"fore:#68C147,bold,back:{dark_bg_color}")

elif file_name.endswith(".js"):
self.SetStatusText("Javascript", 1)
# Set up JavaScript syntax highlighting
text_area.SetLexer(stc.STC_LEX_ESCRIPT)

# Default text
text_area.StyleSetSpec(stc.STC_ESCRIPT_DEFAULT, "fore:#D4D4D4,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_ESCRIPT_DEFAULT, f"fore:#D4D4D4,back:{dark_bg_color}")

# Comments (e.g., // This is a comment, /* multi-line */)
text_area.StyleSetSpec(stc.STC_ESCRIPT_COMMENT, "fore:#68C147,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_ESCRIPT_COMMENTLINE, "fore:#68C147,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_ESCRIPT_COMMENTDOC, "fore:#6A9955,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_ESCRIPT_COMMENT, f"fore:#68C147,italic,back:{dark_bg_color}")
text_area.StyleSetSpec(stc.STC_ESCRIPT_COMMENTLINE, f"fore:#68C147,italic,back:{dark_bg_color}")
text_area.StyleSetSpec(stc.STC_ESCRIPT_COMMENTDOC, f"fore:#6A9955,italic,back:{dark_bg_color}")

# Keywords (e.g., var, let, const, function)
text_area.StyleSetSpec(stc.STC_ESCRIPT_WORD, "fore:#569CD6,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_ESCRIPT_WORD, f"fore:#569CD6,bold,back:{dark_bg_color}")

# Strings (e.g., "text", 'text', `template literal`)
text_area.StyleSetSpec(stc.STC_ESCRIPT_STRING, "fore:#BA9EFE,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_ESCRIPT_STRING, f"fore:#BA9EFE,italic,back:{dark_bg_color}")

# Numbers (e.g., 123, 3.14, 0xFF)
text_area.StyleSetSpec(stc.STC_ESCRIPT_NUMBER, "fore:#FFDD54,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_ESCRIPT_NUMBER, f"fore:#FFDD54,back:{dark_bg_color}")

# Identifiers (e.g., variables, function names)
text_area.StyleSetSpec(stc.STC_ESCRIPT_IDENTIFIER, "fore:#D4D4D4,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_ESCRIPT_IDENTIFIER, f"fore:#D4D4D4,back:{dark_bg_color}")

# Operators (e.g., =, +, -, *, /, &&, ||)
text_area.StyleSetSpec(stc.STC_ESCRIPT_OPERATOR, "fore:#D4D4D4,bold,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_ESCRIPT_OPERATOR, f"fore:#D4D4D4,bold,back:{dark_bg_color}")

# Set JavaScript Keywords
text_area.SetKeyWords(0, "var let const function return if else for while do break continue switch case default try catch throw new this super class extends export import async await typeof instanceof delete")
Expand All @@ -479,7 +497,7 @@ def OnFileOpen(self, event):

# Adjust indentation guides
text_area.SetIndentationGuides(True)
text_area.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "fore:#858585,italic,back:#1E1E1E")
text_area.StyleSetSpec(stc.STC_STYLE_LINENUMBER, f"fore:{light_text_color},italic,back:{dark_bg_color}")
text_area.SetMarginType(1, stc.STC_MARGIN_NUMBER)
text_area.SetMarginWidth(1, 40)

Expand Down
1 change: 1 addition & 0 deletions src/theme.xcfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dark

0 comments on commit 2874058

Please sign in to comment.