image from code wooo
better highlighting
| -rw-r--r-- | HighlightedTextEdit.gd | 93 | ||||
| -rw-r--r-- | Main.tscn | 3 | ||||
| -rw-r--r-- | project.godot | 4 |
3 files changed, 18 insertions, 82 deletions
diff --git a/HighlightedTextEdit.gd b/HighlightedTextEdit.gd index 7692bae..ff7f26d 100644 --- a/HighlightedTextEdit.gd +++ b/HighlightedTextEdit.gd @@ -1,10 +1,11 @@ extends ShrinkingTextEdit class_name HighlightedTextEdit -const CLASS_COLOR = Color("ffd33682") +const BUILTIN_COLOR = Color("ffd33682") const KEYWORD_COLOR = Color("ffb58900") const SYMBOL_COLOR = Color("ff839496") const FUNCTION_COLOR = Color("ff268bd2") +# const FUNC_DEF_COLOR = Color("ff2aa198") const MEMBER_VAR_COLOR = Color("ff268bd2") const NUMBER_COLOR = Color("ffd33682") const STRING_COLOR = Color("ff2aa198") @@ -12,95 +13,33 @@ const COMMENT_COLOR = Color("ff586e75") const NODE_PATH_COLOR = Color("ffd33682") const FONT_COLOR = Color("ff839496") -const keyword_colors := { - "if": KEYWORD_COLOR, - "elif": KEYWORD_COLOR, - "else": KEYWORD_COLOR, - "for": KEYWORD_COLOR, - "while": KEYWORD_COLOR, - "match": KEYWORD_COLOR, - "break": KEYWORD_COLOR, - "continue": KEYWORD_COLOR, - "pass": KEYWORD_COLOR, - "return": KEYWORD_COLOR, - "class": KEYWORD_COLOR, - "class_name": KEYWORD_COLOR, - "extends": KEYWORD_COLOR, - "is": KEYWORD_COLOR, - "as": KEYWORD_COLOR, - "self": KEYWORD_COLOR, - "signal": KEYWORD_COLOR, - "func": KEYWORD_COLOR, - "static": KEYWORD_COLOR, - "const": KEYWORD_COLOR, - "enum": KEYWORD_COLOR, - "var": KEYWORD_COLOR, - "breakpoint": KEYWORD_COLOR, - "preload": KEYWORD_COLOR, - "await": KEYWORD_COLOR, - "yield": KEYWORD_COLOR, - "assert": KEYWORD_COLOR, - "void": KEYWORD_COLOR, - "in": KEYWORD_COLOR, - "not": KEYWORD_COLOR, - "and": KEYWORD_COLOR, - "or": KEYWORD_COLOR, - "PI": KEYWORD_COLOR, - "TAU": KEYWORD_COLOR, - "INF": KEYWORD_COLOR, - "NAN": KEYWORD_COLOR, - "null": KEYWORD_COLOR, - "int": KEYWORD_COLOR, - "float": KEYWORD_COLOR, - "bool": KEYWORD_COLOR, - "super": KEYWORD_COLOR, - "true": KEYWORD_COLOR, - "false": KEYWORD_COLOR, - "AABB": CLASS_COLOR, - "Array": CLASS_COLOR, - "Basis": CLASS_COLOR, - "Color": CLASS_COLOR, - "Dictionary": CLASS_COLOR, - "NodePath": CLASS_COLOR, - "Plane": CLASS_COLOR, - "PoolByteArray": CLASS_COLOR, - "PoolColorArray": CLASS_COLOR, - "PoolIntArray": CLASS_COLOR, - "PoolRealArray": CLASS_COLOR, - "PoolStringArray": CLASS_COLOR, - "PoolVector2Array": CLASS_COLOR, - "PoolVector3Array": CLASS_COLOR, - "Quat": CLASS_COLOR, - "RID": CLASS_COLOR, - "Rect2": CLASS_COLOR, - "String": CLASS_COLOR, - "Transform": CLASS_COLOR, - "Transform2D": CLASS_COLOR, - "Variant": CLASS_COLOR, - "Vector2": CLASS_COLOR, - "Vector3": CLASS_COLOR, - "ClassDB": CLASS_COLOR, -} +const keywords = 'and in not or self void as assert breakpoint class class_name extends is func setget signal tool yield const enum export onready static var break continue if elif else for pass return match while remote sync master puppet remotesync mastersync puppetsync' +const literals = 'null true false' +const builtin = 'Color8 ColorN abs acos asin atan atan2 bytes2var cartesian2polar ceil char clamp convert cos cosh db2linear decimals dectime deg2rad dict2inst ease exp floor fmod fposmod funcref get_stack hash inst2dict instance_from_id inverse_lerp is_equal_approx is_inf is_instance_valid is_nan is_zero_approx len lerp lerp_angle linear2db load log max min move_toward nearest_po2 ord parse_json polar2cartesian posmod pow preload print_stack push_error push_warning rad2deg rand_range rand_seed randf randi randomize range_lerp round seed sign sin sinh smoothstep sqrt step_decimals stepify str str2var tan tanh to_json type_exists typeof validate_json var2bytes var2str weakref wrapf wrapi bool int float String NodePath Vector2 Rect2 Transform2D Vector3 Rect3 Plane Quat Basis Transform Color RID Object NodePath Dictionary Array PoolByteArray PoolIntArray PoolRealArray PoolStringArray PoolVector2Array PoolVector3Array PoolColorArray' func _ready(): - for keyword in keyword_colors: - add_keyword_color(keyword, keyword_colors[keyword]) + for keyword in keywords.split(" "): + add_keyword_color(keyword, KEYWORD_COLOR) + + for builtin in builtin.split(" "): + add_keyword_color(builtin, BUILTIN_COLOR) + + for literal in literals.split(" "): + add_keyword_color(literal, KEYWORD_COLOR) for cls in ClassDB.get_class_list(): - add_keyword_color(cls, CLASS_COLOR) + add_keyword_color(cls, BUILTIN_COLOR) add_color_region('"', '"', STRING_COLOR, false) add_color_region("'", "'", STRING_COLOR, false) add_color_region("$", " ", NODE_PATH_COLOR, true) add_color_region("#", "", COMMENT_COLOR, true) + # add_color_region("func", ":", FUNC_DEF_COLOR) + add_color_override("font_color", FONT_COLOR) add_color_override("function_color", FUNCTION_COLOR) add_color_override("member_variable_color", MEMBER_VAR_COLOR) add_color_override("number_color", NUMBER_COLOR) add_color_override("symbol_color", SYMBOL_COLOR) - - -func _resized(): - pass # Replace with function body. @@ -30,7 +30,6 @@ anchor_right = 1.0 anchor_bottom = 1.0 rect_min_size = Vector2( 300, 140 ) theme = ExtResource( 2 ) -text = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" syntax_highlighting = true show_line_numbers = true context_menu_enabled = false @@ -40,5 +39,3 @@ selecting_enabled = false deselect_on_focus_loss_enabled = false drag_and_drop_selection_enabled = false script = ExtResource( 3 ) - -[connection signal="resized" from="CodeViewport/Code" to="CodeViewport/Code" method="_resized"] diff --git a/project.godot b/project.godot index c853132..da41160 100644 --- a/project.godot +++ b/project.godot @@ -116,10 +116,10 @@ _global_script_class_icons={ [application] -config/name="Godot Template" +config/name="code image" run/main_scene="res://Main.tscn" config/use_custom_user_dir=true -config/custom_user_dir_name="GodotTemplate" +config/custom_user_dir_name="codeimg" [debug] |