Skip to content

Commit 70d1a91

Browse files
committed
Update to Text Forge new syntax colors feature
1 parent 34fb6ab commit 70d1a91

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

modes/python/mode.gd

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
extends TextForgeMode
22

33
var keyword_colors: Dictionary[Color, Array] = {
4-
Color(1, 0.45, 0.55, 1): ["def", "class", "lambda", "return", "yield", "try", "except", "finally", "raise"],
5-
Color(1, 0.6, 0.85, 1): ["if", "elif", "else", "for", "while", "break", "continue", "pass", "with", "as", "assert"],
6-
Color(1, 0.7, 0.5, 1): ["import", "from", "global", "nonlocal", "del", "and", "or", "not", "in", "is"],
7-
Color(0.9, 0.8, 0.6, 1): ["True", "False", "None"],
4+
U.get_syntax_color(U.SyntaxColors.KEYWORD_1): ["def", "class", "lambda", "return", "yield", "try", "except", "finally", "raise"],
5+
U.get_syntax_color(U.SyntaxColors.KEYWORD_2): ["if", "elif", "else", "for", "while", "break", "continue", "pass", "with", "as", "assert"],
6+
U.get_syntax_color(U.SyntaxColors.KEYWORD_3): ["import", "from", "global", "nonlocal", "del", "and", "or", "not", "in", "is"],
7+
U.get_syntax_color(U.SyntaxColors.BUILTIN): ["True", "False", "None"],
88
}
99
var code_regions: Array[Array] = [
10-
[Color(1, 0.91, 0.64, 1), '"', '"', false],
11-
[Color(1, 0.92, 0.64, 1), "'", "'", false],
12-
[Color(1, 0.92, 0.65, 1), "'''", "'''", false],
13-
[Color(1, 0.91, 0.65, 1), '"""', '"""', false],
14-
[Color(0.8, 0.81, 0.82, 0.5), "#", "", true],
10+
[U.get_syntax_color(U.SyntaxColors.STRING), '"', '"', false],
11+
[U.get_syntax_color(U.SyntaxColors.STRING), "'", "'", false],
12+
[U.get_syntax_color(U.SyntaxColors.STRING), "'''", "'''", false],
13+
[U.get_syntax_color(U.SyntaxColors.STRING), '"""', '"""', false],
14+
[U.get_syntax_color(U.SyntaxColors.COMMENT), "#", "", true],
1515
]
1616

1717
func _initialize_mode() -> Error:
@@ -94,10 +94,10 @@ func _lint_file(text: String) -> Array[Dictionary]:
9494

9595
func _initialize_highlighter() -> void:
9696
syntax_highlighter = CodeHighlighter.new()
97-
syntax_highlighter.number_color = Color(0.85, 1, 0.7, 1)
98-
syntax_highlighter.symbol_color = Color(0.7, 0.8, 1, 1)
99-
syntax_highlighter.function_color = Color(0.35, 0.7, 1, 1)
100-
syntax_highlighter.member_variable_color = Color(0.8, 0.85, 1, 1)
97+
syntax_highlighter.number_color = U.get_syntax_color(U.SyntaxColors.NUMBER)
98+
syntax_highlighter.symbol_color = U.get_syntax_color(U.SyntaxColors.SYMBOL)
99+
syntax_highlighter.function_color = U.get_syntax_color(U.SyntaxColors.FUNCTION)
100+
syntax_highlighter.member_variable_color = U.get_syntax_color(U.SyntaxColors.MEMBER)
101101
for color in keyword_colors:
102102
for keyword in keyword_colors[color]:
103103
syntax_highlighter.add_keyword_color(keyword, color)

0 commit comments

Comments
 (0)