Update/deprecate theme item names

Updates theme names to be compatible with Godot 3.5 (no spaces),
consistent with other Godot theme item names (snake_case), and
match the color names listed on the
[ANSI escape code wikipedia page](https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit).

Deprecates the old names and warns users to change them.
This commit is contained in:
Leroy Hopson 2022-08-23 23:58:24 +12:00
parent aee3efd8de
commit 95b66115c4
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
15 changed files with 349 additions and 260 deletions

View file

@ -0,0 +1,28 @@
[gd_resource type="Theme" load_steps=2 format=2]
[ext_resource path="res://addons/godot_xterm/themes/fonts/regular.tres" type="DynamicFont" id=4]
[resource]
default_font = ExtResource( 4 )
Terminal/colors/Background = Color( 0.921569, 0.921569, 0.921569, 1 )
Terminal/colors/Black = Color( 0, 0, 0, 1 )
Terminal/colors/Blue = Color( 0.239216, 0.392157, 0.866667, 1 )
Terminal/colors/Cyan = Color( 0, 0.65098, 0.729412, 1 )
"Terminal/colors/Dark Grey" = Color( 0.25098, 0.25098, 0.25098, 1 )
Terminal/colors/Foreground = Color( 0.25098, 0.25098, 0.25098, 1 )
Terminal/colors/Green = Color( 0, 0.380392, 0.188235, 1 )
"Terminal/colors/Light Blue" = Color( 0.160784, 0.545098, 1, 1 )
"Terminal/colors/Light Cyan" = Color( 0.133333, 0.8, 1, 1 )
"Terminal/colors/Light Green" = Color( 0, 0.760784, 0.380392, 1 )
"Terminal/colors/Light Grey" = Color( 0.898039, 0.898039, 0.898039, 1 )
"Terminal/colors/Light Magenta" = Color( 0.658824, 0.364706, 0.913725, 1 )
"Terminal/colors/Light Red" = Color( 1, 0.439216, 0.521569, 1 )
"Terminal/colors/Light Yellow" = Color( 1, 0.866667, 0.396078, 1 )
Terminal/colors/Magenta = Color( 0.439216, 0.164706, 1, 1 )
Terminal/colors/Red = Color( 0.74902, 0.352941, 0.313726, 1 )
Terminal/colors/White = Color( 1, 1, 1, 1 )
Terminal/colors/Yellow = Color( 0.698039, 0.572549, 0.0627451, 1 )
Terminal/fonts/Bold = null
"Terminal/fonts/Bold Italic" = null
Terminal/fonts/Italic = null
Terminal/fonts/Regular = ExtResource( 4 )

View file

@ -10,25 +10,25 @@ func test_xrdb():
assert_true(theme is Theme)
var map := {
"Black": "#000000",
"Red": "#000001",
"Green": "#000002",
"Yellow": "#000003",
"Blue": "#000004",
"Magenta": "#000005",
"Cyan": "#000006",
"Light Grey": "#000007",
"Dark Grey": "#000008",
"Light Red": "#000009",
"Light Green": "#000010",
"Light Yellow": "#000011",
"Light Blue": "#000012",
"Light Magenta": "#000013",
"Light Cyan": "#000014",
"White": "#000015",
"Background": "#100000",
"Foreground": "#200000",
"Cursor": "#300000",
"black": "#000000",
"red": "#000001",
"green": "#000002",
"yellow": "#000003",
"blue": "#000004",
"magenta": "#000005",
"cyan": "#000006",
"white": "#000007",
"bright_black": "#000008",
"bright_red": "#000009",
"bright_green": "#000010",
"bright_yellow": "#000011",
"bright_blue": "#000012",
"bright_magenta": "#000013",
"bright_cyan": "#000014",
"bright_white": "#000015",
"background": "#100000",
"foreground": "#200000",
"cursor": "#300000",
}
for key in map.keys():
@ -40,25 +40,25 @@ func test_Xresources():
assert_true(theme is Theme)
var map := {
"Black": "#282A2E",
"Red": "#A54242",
"Green": "#8C9440",
"Yellow": "#DE935F",
"Blue": "#5F819D",
"Magenta": "#85678F",
"Cyan": "#5E8D87",
"Light Grey": "#707880",
"Dark Grey": "#373B41",
"Light Red": "#CC6666",
"Light Green": "#B5BD68",
"Light Yellow": "#F0C674",
"Light Blue": "#81A2BE",
"Light Magenta": "#B294BB",
"Light Cyan": "#8ABEB7",
"White": "#C5C8C6",
"Background": "#1D1F21",
"Foreground": "#C5C8C6",
"Cursor": "#C5C8C6",
"black": "#282A2E",
"red": "#A54242",
"green": "#8C9440",
"yellow": "#DE935F",
"blue": "#5F819D",
"magenta": "#85678F",
"cyan": "#5E8D87",
"white": "#707880",
"bright_black": "#373B41",
"bright_red": "#CC6666",
"bright_green": "#B5BD68",
"bright_yellow": "#F0C674",
"bright_blue": "#81A2BE",
"bright_magenta": "#B294BB",
"bright_cyan": "#8ABEB7",
"bright_white": "#C5C8C6",
"background": "#1D1F21",
"foreground": "#C5C8C6",
"cursor": "#C5C8C6",
}
for key in map.keys():
@ -70,25 +70,25 @@ func test_xresources():
assert_true(theme is Theme)
var map := {
"Black": "#000000",
"Red": "#1B0C13",
"Green": "#351B27",
"Yellow": "#563042",
"Blue": "#814B64",
"Magenta": "#B56B8D",
"Cyan": "#D0A2B6",
"Light Grey": "#EDDFE4",
"Dark Grey": "#6DA3B8",
"Light Red": "#CA956C",
"Light Green": "#7CA7B9",
"Light Yellow": "#A2C9BC",
"Light Blue": "#9AAD72",
"Light Magenta": "#82D0B7",
"Light Cyan": "#AE96D0",
"White": "#E6BFCF",
"Background": "#000000",
"Foreground": "#EDDFE4",
"Cursor": "#EDDFE4",
"black": "#000000",
"red": "#1B0C13",
"green": "#351B27",
"yellow": "#563042",
"blue": "#814B64",
"magenta": "#B56B8D",
"cyan": "#D0A2B6",
"white": "#EDDFE4",
"bright_black": "#6DA3B8",
"bright_red": "#CA956C",
"bright_green": "#7CA7B9",
"bright_yellow": "#A2C9BC",
"bright_blue": "#9AAD72",
"bright_magenta": "#82D0B7",
"bright_cyan": "#AE96D0",
"bright_white": "#E6BFCF",
"background": "#000000",
"foreground": "#EDDFE4",
"cursor": "#EDDFE4",
}
for key in map.keys():

View file

@ -49,22 +49,22 @@ class TestTheme:
const alt_theme := preload("res://addons/godot_xterm/themes/default_light.tres")
const COLORS := [
"Black",
"Red",
"Green",
"Yellow",
"Blue",
"Magenta",
"Cyan",
"Light Grey",
"Dark Grey",
"Light Red",
"Light Green",
"Light Yellow",
"Light Blue",
"Light Magenta",
"Light Cyan",
"White",
"black",
"red",
"green",
"yellow",
"blue",
"magenta",
"cyan",
"white",
"bright_black",
"bright_red",
"bright_green",
"bright_yellow",
"bright_blue",
"bright_magenta",
"bright_cyan",
"bright_white",
]
var terminal: Terminal
@ -105,24 +105,18 @@ class TestTheme:
yield(yield_frames(1), YIELD)
func test_terminal_display_colors_from_default_theme():
if _version_gt_3_4():
return
terminal.theme = null
add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD)
_check_colors(default_theme)
func test_terminal_displays_colors_from_theme():
if _version_gt_3_4():
return
terminal.theme = alt_theme
add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD)
_check_colors(alt_theme)
func test_visible_characters_still_displayed_after_resize_with_default_theme():
if _version_gt_3_4():
return
terminal.theme = null
add_child(terminal)
yield(yield_frames(1), YIELD)
@ -131,8 +125,6 @@ class TestTheme:
_check_colors(default_theme)
func test_visible_characters_still_displayed_after_resize_with_custom_theme():
if _version_gt_3_4():
return
# Issue 57: https://github.com/lihop/godot-xterm/issues/57
terminal.theme = alt_theme
add_child(terminal)
@ -142,8 +134,6 @@ class TestTheme:
_check_colors(alt_theme)
func test_updates_colors_after_theme_set():
if _version_gt_3_4():
return
# Issue 58: https://github.com/lihop/godot-xterm/issues/58
terminal.theme = null
add_child(terminal)
@ -153,8 +143,6 @@ class TestTheme:
_check_colors(alt_theme)
func test_updates_colors_after_theme_unset():
if _version_gt_3_4():
return
# Issue 58: https://github.com/lihop/godot-xterm/issues/58
terminal.theme = alt_theme
add_child(terminal)
@ -164,8 +152,6 @@ class TestTheme:
_check_colors(default_theme)
func test_updates_colors_after_theme_changed():
if _version_gt_3_4():
return
# Issue 58: https://github.com/lihop/godot-xterm/issues/58
terminal.theme = alt_theme
add_child(terminal)
@ -173,3 +159,17 @@ class TestTheme:
terminal.theme = default_theme
yield(yield_to(terminal, "theme_changed", 5), YIELD)
_check_colors(default_theme)
func test_deprecated_theme_item_names_continue_to_work_until_removed():
# This test can be removed after support for deperacted theme item names is removed.
# Not applicable to version 3.5 as deprecated theme can't be imported in that version.
var version := Engine.get_version_info()
if version.major > 3 or (version.major == 3 and version.minor >= 5):
return
var deprecated_theme := preload("../files/deprecated_theme.tres")
terminal.theme = deprecated_theme
yield(yield_to(terminal, "theme_changed", 5), YIELD)
add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD)
_check_colors(alt_theme)