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

@ -28,24 +28,24 @@ func _ready():
# better to use a dedicated terminal theme, rather than relying on this. # better to use a dedicated terminal theme, rather than relying on this.
_set_terminal_colors( _set_terminal_colors(
{ {
"Black": "caret_background_color", "black": "caret_background_color",
"Red": "keyword_color", "red": "keyword_color",
"Green": "gdscript/node_path_color", "green": "gdscript/node_path_color",
"Yellow": "string_color", "yellow": "string_color",
"Blue": "function_color", "blue": "function_color",
"Magenta": "symbol_color", "magenta": "symbol_color",
"Cyan": "gdscript/function_definition_color", "cyan": "gdscript/function_definition_color",
"Dark Grey": "comment_color", "white": "text_color",
"Light Grey": "text_color", "bright_black": "comment_color",
"Light Red": "breakpoint_color", "bright_red": "breakpoint_color",
"Light Green": "base_type_color", "bright_green": "base_type_color",
"Light Yellow": "search_result_color", "bright_yellow": "search_result_color",
"Light Blue": "member_variable_color", "bright_blue": "member_variable_color",
"Light Magenta": "code_folding_color", "bright_magenta": "code_folding_color",
"Light Cyan": "user_type_color", "bright_cyan": "user_type_color",
"White": "text_selected_color", "bright_white": "text_selected_color",
"Background": "background_color", "background": "background_color",
"Foreground": "caret_color", "foreground": "caret_color",
} }
) )
_native_terminal._update_theme() _native_terminal._update_theme()

View file

@ -47,7 +47,7 @@ var _tab_container_min_size
func _ready(): func _ready():
tab_container.add_stylebox_override("panel", get_stylebox("Background", "EditorStyles")) tab_container.add_stylebox_override("panel", get_stylebox("background", "EditorStyles"))
_update_settings() _update_settings()

View file

@ -39,8 +39,8 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
return err return err
var theme: Theme = XrdbTheme.new() var theme: Theme = XrdbTheme.new()
theme.set_font("Regular", "Terminal", preload("../themes/fonts/regular.tres")) theme.set_font("regular", "Terminal", preload("../themes/fonts/regular.tres"))
for font in ["Bold", "Italic", "Bold Italic"]: for font in ["bold", "italic", "bold_italic"]:
theme.set_font(font, "Terminal", null) theme.set_font(font, "Terminal", null)
var word_regex = RegEx.new() var word_regex = RegEx.new()
@ -77,48 +77,48 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
match name: match name:
"color0", "ansi_0_color": "color0", "ansi_0_color":
theme.set_color("Black", "Terminal", color) theme.set_color("black", "Terminal", color)
"color1", "ansi_1_color": "color1", "ansi_1_color":
theme.set_color("Red", "Terminal", color) theme.set_color("red", "Terminal", color)
"color2", "ansi_2_color": "color2", "ansi_2_color":
theme.set_color("Green", "Terminal", color) theme.set_color("green", "Terminal", color)
"color3", "ansi_3_color": "color3", "ansi_3_color":
theme.set_color("Yellow", "Terminal", color) theme.set_color("yellow", "Terminal", color)
"color4", "ansi_4_color": "color4", "ansi_4_color":
theme.set_color("Blue", "Terminal", color) theme.set_color("blue", "Terminal", color)
"color5", "ansi_5_color": "color5", "ansi_5_color":
theme.set_color("Magenta", "Terminal", color) theme.set_color("magenta", "Terminal", color)
"color6", "ansi_6_color": "color6", "ansi_6_color":
theme.set_color("Cyan", "Terminal", color) theme.set_color("cyan", "Terminal", color)
"color7", "ansi_7_color": "color7", "ansi_7_color":
theme.set_color("Light Grey", "Terminal", color) theme.set_color("white", "Terminal", color)
"color8", "ansi_8_color": "color8", "ansi_8_color":
theme.set_color("Dark Grey", "Terminal", color) theme.set_color("bright_black", "Terminal", color)
"color9", "ansi_9_color": "color9", "ansi_9_color":
theme.set_color("Light Red", "Terminal", color) theme.set_color("bright_red", "Terminal", color)
"color10", "ansi_10_color": "color10", "ansi_10_color":
theme.set_color("Light Green", "Terminal", color) theme.set_color("bright_green", "Terminal", color)
"color11", "ansi_11_color": "color11", "ansi_11_color":
theme.set_color("Light Yellow", "Terminal", color) theme.set_color("bright_yellow", "Terminal", color)
"color12", "ansi_12_color": "color12", "ansi_12_color":
theme.set_color("Light Blue", "Terminal", color) theme.set_color("bright_blue", "Terminal", color)
"color13", "ansi_13_color": "color13", "ansi_13_color":
theme.set_color("Light Magenta", "Terminal", color) theme.set_color("bright_magenta", "Terminal", color)
"color14", "ansi_14_color": "color14", "ansi_14_color":
theme.set_color("Light Cyan", "Terminal", color) theme.set_color("bright_cyan", "Terminal", color)
"color15", "ansi_15_color": "color15", "ansi_15_color":
theme.set_color("White", "Terminal", color) theme.set_color("bright_white", "Terminal", color)
"foreground", "foreground_color": "foreground", "foreground_color":
theme.set_color("Foreground", "Terminal", color) theme.set_color("foreground", "Terminal", color)
"background", "background_color": "background", "background_color":
theme.set_color("Background", "Terminal", color) theme.set_color("background", "Terminal", color)
"selection_color": "selection_color":
theme.set_color("Selection", "Terminal", color) theme.set_color("selection", "Terminal", color)
"selected_text_color": "selected_text_color":
theme.set_color("Selected Text", "Terminal", color) theme.set_color("selected_text", "Terminal", color)
"cursorcolor", "cursor_color": "cursorcolor", "cursor_color":
theme.set_color("Cursor", "Terminal", color) theme.set_color("cursor", "Terminal", color)
"cursor_text_color": "cursor_text_color":
theme.set_color("Cursor Text", "Terminal", color) theme.set_color("cursor_text", "Terminal", color)
return ResourceSaver.save("%s.%s" % [save_path, get_save_extension()], theme) return ResourceSaver.save("%s.%s" % [save_path, get_save_extension()], theme)

View file

@ -435,43 +435,46 @@ void Terminal::update_theme() {
/* Default to Xterm colors */ /* Default to Xterm colors */
/* ANSI 0 */ /* ANSI 0 */
set_pallete_color(TSM_COLOR_BLACK, "Black", Color::html("#000000")); set_pallete_color(TSM_COLOR_BLACK, "black", Color::html("#000000"));
/* ANSI 1 */ /* ANSI 1 */
set_pallete_color(TSM_COLOR_RED, "Red", Color::html("#CD0000")); set_pallete_color(TSM_COLOR_RED, "red", Color::html("#CD0000"));
/* ANSI 2 */ /* ANSI 2 */
set_pallete_color(TSM_COLOR_GREEN, "Green", Color::html("#00CD00")); set_pallete_color(TSM_COLOR_GREEN, "green", Color::html("#00CD00"));
/* ANSI 3 */ /* ANSI 3 */
set_pallete_color(TSM_COLOR_YELLOW, "Yellow", Color::html("#CDCD00")); set_pallete_color(TSM_COLOR_YELLOW, "yellow", Color::html("#CDCD00"));
/* ANSI 4 */ /* ANSI 4 */
set_pallete_color(TSM_COLOR_BLUE, "Blue", Color::html("#0000EE")); set_pallete_color(TSM_COLOR_BLUE, "blue", Color::html("#0000EE"));
/* ANSI 5 */ /* ANSI 5 */
set_pallete_color(TSM_COLOR_MAGENTA, "Magenta", Color::html("#CD00CD")); set_pallete_color(TSM_COLOR_MAGENTA, "magenta", Color::html("#CD00CD"));
/* ANSI 6 */ /* ANSI 6 */
set_pallete_color(TSM_COLOR_CYAN, "Cyan", Color::html("#00CDCD")); set_pallete_color(TSM_COLOR_CYAN, "cyan", Color::html("#00CDCD"));
/* ANSI 7 (White) */ /* ANSI 7 (White) */
set_pallete_color(TSM_COLOR_LIGHT_GREY, "Light Grey", Color::html("#E5E5E5")); set_pallete_color(TSM_COLOR_LIGHT_GREY, "white", Color::html("#E5E5E5"));
/* ANSI 8 (Bright Black) */ /* ANSI 8 (Bright Black) */
set_pallete_color(TSM_COLOR_DARK_GREY, "Dark Grey", Color::html("#7F7F7F")); set_pallete_color(TSM_COLOR_DARK_GREY, "bright_black",
Color::html("#7F7F7F"));
/* ANSI 9 */ /* ANSI 9 */
set_pallete_color(TSM_COLOR_LIGHT_RED, "Light Red", Color::html("#FF0000")); set_pallete_color(TSM_COLOR_LIGHT_RED, "bright_red", Color::html("#FF0000"));
/* ANSI 10 */ /* ANSI 10 */
set_pallete_color(TSM_COLOR_LIGHT_GREEN, "Light Green", set_pallete_color(TSM_COLOR_LIGHT_GREEN, "bright_green",
Color::html("#00FF00")); Color::html("#00FF00"));
/* ANSI 11 */ /* ANSI 11 */
set_pallete_color(TSM_COLOR_LIGHT_YELLOW, "Light Yellow", set_pallete_color(TSM_COLOR_LIGHT_YELLOW, "bright_yellow",
Color::html("#FFFF00")); Color::html("#FFFF00"));
/* ANSI 12 */ /* ANSI 12 */
set_pallete_color(TSM_COLOR_LIGHT_BLUE, "Light Blue", Color::html("#0000FC")); set_pallete_color(TSM_COLOR_LIGHT_BLUE, "bright_blue",
Color::html("#0000FC"));
/* ANSI 13 */ /* ANSI 13 */
set_pallete_color(TSM_COLOR_LIGHT_MAGENTA, "Light Magenta", set_pallete_color(TSM_COLOR_LIGHT_MAGENTA, "bright_magenta",
Color::html("#FF00FF")); Color::html("#FF00FF"));
/* ANSI 14 */ /* ANSI 14 */
set_pallete_color(TSM_COLOR_LIGHT_CYAN, "Light Cyan", Color::html("#00FFFF")); set_pallete_color(TSM_COLOR_LIGHT_CYAN, "bright_cyan",
Color::html("#00FFFF"));
/* ANSI 15 (Bright White) */ /* ANSI 15 (Bright White) */
set_pallete_color(TSM_COLOR_WHITE, "White", Color::html("#FFFFFF")); set_pallete_color(TSM_COLOR_WHITE, "bright_white", Color::html("#FFFFFF"));
set_pallete_color(TSM_COLOR_FOREGROUND, "Foreground", Color::html("#000000")); set_pallete_color(TSM_COLOR_FOREGROUND, "foreground", Color::html("#000000"));
set_pallete_color(TSM_COLOR_BACKGROUND, "Background", Color::html("#FFFFFF")); set_pallete_color(TSM_COLOR_BACKGROUND, "background", Color::html("#FFFFFF"));
if (tsm_vte_set_custom_palette(vte, color_palette)) { if (tsm_vte_set_custom_palette(vte, color_palette)) {
ERR_PRINT("Error setting custom palette"); ERR_PRINT("Error setting custom palette");
@ -489,11 +492,11 @@ void Terminal::update_theme() {
fontref = get_font(font_style, "Terminal"); fontref = get_font(font_style, "Terminal");
} else if (has_font_override(font_style)) { } else if (has_font_override(font_style)) {
fontref = get_font(font_style, ""); fontref = get_font(font_style, "");
} else if (has_font("Regular", "Terminal")) { } else if (has_font("regular", "Terminal")) {
fontref = get_font("Regular", "Terminal"); fontref = get_font("regular", "Terminal");
} else if (default_theme != nullptr && } else if (default_theme != nullptr &&
default_theme->has_font("Regular", "Terminal")) { default_theme->has_font("regular", "Terminal")) {
fontref = default_theme->get_font("Regular", "Terminal"); fontref = default_theme->get_font("regular", "Terminal");
} else { } else {
fontref = get_font(""); fontref = get_font("");
} }
@ -501,10 +504,10 @@ void Terminal::update_theme() {
fontmap.insert(std::pair<String, Ref<Font>>(font_style, fontref)); fontmap.insert(std::pair<String, Ref<Font>>(font_style, fontref));
}; };
load_font("Bold Italic"); load_font("bold_italic");
load_font("Bold"); load_font("bold");
load_font("Italic"); load_font("italic");
load_font("Regular"); load_font("regular");
// update_size(); // update_size();
} }
@ -523,13 +526,13 @@ void Terminal::draw_foreground(int row, int col, char *ch,
Ref<Font> fontref = get_font(""); Ref<Font> fontref = get_font("");
if (attr->bold && attr->italic) { if (attr->bold && attr->italic) {
fontref = fontmap["Bold Italic"]; fontref = fontmap["bold_italic"];
} else if (attr->bold) { } else if (attr->bold) {
fontref = fontmap["Bold"]; fontref = fontmap["bold"];
} else if (attr->italic) { } else if (attr->italic) {
fontref = fontmap["Italic"]; fontref = fontmap["italic"];
} else { } else {
fontref = fontmap["Regular"]; fontref = fontmap["regular"];
} }
/* Draw the foreground */ /* Draw the foreground */
@ -591,10 +594,10 @@ void Terminal::update_size() {
// the Control's rect_size. // the Control's rect_size.
Ref<Font> fontref; Ref<Font> fontref;
if (fontmap.count("Regular")) if (fontmap.count("regular"))
fontref = fontmap["Regular"]; fontref = fontmap["regular"];
else if (has_font("Regular", "Terminal")) else if (has_font("regular", "Terminal"))
fontref = get_font("Regular", "Terminal"); fontref = get_font("regular", "Terminal");
else else
fontref = get_font(""); fontref = get_font("");

View file

@ -175,22 +175,50 @@ func _update_theme():
# inheritance to work we can pass through the theme variables manually. # inheritance to work we can pass through the theme variables manually.
for color in _default_theme.get_color_list("Terminal"): for color in _default_theme.get_color_list("Terminal"):
var c: Color var c: Color
var deprecated_color: String = color.replace("bright", "light").replace("_", " ").capitalize()
match deprecated_color:
"White":
deprecated_color = "Light Grey"
"Light Black":
deprecated_color = "Dark Grey"
"Light White":
deprecated_color = "Wahite"
if has_color(color, "Terminal"): if has_color(color, "Terminal"):
c = get_color(color, "Terminal") c = get_color(color, "Terminal")
elif has_color(deprecated_color, "Terminal"):
push_warning(
(
"Color name '%s' is deprecated and will be removed it a future version. Use the name '%s' instead."
% [deprecated_color, color]
)
)
c = get_color(deprecated_color, "Terminal")
else: else:
c = _default_theme.get_color(color, "Terminal") c = _default_theme.get_color(color, "Terminal")
_native_terminal.add_color_override(color, c) _native_terminal.add_color_override(color, c)
for font in _default_theme.get_font_list("Terminal"): for font in _default_theme.get_font_list("Terminal"):
var f: Font var f: Font
var deprecated_font: String = font.replace("_", " ").capitalize()
if has_font(font, "Terminal"): if has_font(font, "Terminal"):
f = get_font(font, "Terminal") f = get_font(font, "Terminal")
elif has_font("Regular", "Terminal"): elif has_font(deprecated_font, "Terminal"):
f = get_font("Regular", "Terminal") push_warning(
(
"Font name '%s' is deprecated and will be removed in a future version. Use the name '%s' instead."
% [deprecated_font, font]
)
)
f = get_font(deprecated_font, "Terminal")
elif has_font("regular", "Terminal"):
f = get_font("regular", "Terminal")
else: else:
if _default_theme.has_font(font, "Terminal"): if _default_theme.has_font(font, "Terminal"):
f = _default_theme.get_font(font, "Terminal") f = _default_theme.get_font(font, "Terminal")
else: else:
f = _default_theme.get_font(font, "Regular") f = _default_theme.get_font(font, "regular")
_native_terminal.add_font_override(font, f) _native_terminal.add_font_override(font, f)
_native_terminal._update_theme() _native_terminal._update_theme()
_native_terminal._update_size() _native_terminal._update_size()

View file

@ -4,25 +4,25 @@
[resource] [resource]
default_font = ExtResource( 1 ) default_font = ExtResource( 1 )
Terminal/colors/Background = Color( 0.12549, 0.145098, 0.192157, 1 ) Terminal/colors/background = Color( 0.12549, 0.145098, 0.192157, 1 )
Terminal/colors/Black = Color( 0, 0, 0, 1 ) Terminal/colors/black = Color( 0, 0, 0, 1 )
Terminal/colors/Blue = Color( 0.341176, 0.698039, 1, 1 ) Terminal/colors/blue = Color( 0.341176, 0.698039, 1, 1 )
Terminal/colors/Cyan = Color( 0.4, 0.901961, 1, 1 ) Terminal/colors/bright_black = Color( 0.462745, 0.47451, 0.509804, 1 )
"Terminal/colors/Dark Grey" = Color( 0.462745, 0.47451, 0.509804, 1 ) Terminal/colors/bright_blue = Color( 0.737255, 0.878431, 1, 1 )
Terminal/colors/Foreground = Color( 0.8, 0.807843, 0.827451, 1 ) Terminal/colors/bright_cyan = Color( 0.776471, 1, 0.929412, 1 )
Terminal/colors/Green = Color( 0.388235, 0.760784, 0.34902, 1 ) Terminal/colors/bright_green = Color( 0.258824, 1, 0.760784, 1 )
"Terminal/colors/Light Blue" = Color( 0.737255, 0.878431, 1, 1 ) Terminal/colors/bright_magenta = Color( 0.807843, 0.643137, 0.945098, 1 )
"Terminal/colors/Light Cyan" = Color( 0.776471, 1, 0.929412, 1 ) Terminal/colors/bright_red = Color( 1, 0.439216, 0.521569, 1 )
"Terminal/colors/Light Green" = Color( 0.258824, 1, 0.760784, 1 ) Terminal/colors/bright_white = Color( 1, 1, 1, 1 )
"Terminal/colors/Light Grey" = Color( 0.8, 0.807843, 0.827451, 1 ) Terminal/colors/bright_yellow = Color( 1, 0.92549, 0.627451, 1 )
"Terminal/colors/Light Magenta" = Color( 0.807843, 0.643137, 0.945098, 1 ) Terminal/colors/cyan = Color( 0.4, 0.901961, 1, 1 )
"Terminal/colors/Light Red" = Color( 1, 0.439216, 0.521569, 1 ) Terminal/colors/foreground = Color( 0.8, 0.807843, 0.827451, 1 )
"Terminal/colors/Light Yellow" = Color( 1, 0.92549, 0.627451, 1 ) Terminal/colors/green = Color( 0.388235, 0.760784, 0.34902, 1 )
Terminal/colors/Magenta = Color( 0.623529, 0.439216, 1, 1 ) Terminal/colors/magenta = Color( 0.623529, 0.439216, 1, 1 )
Terminal/colors/Red = Color( 1, 0.47, 0.42, 1 ) Terminal/colors/red = Color( 1, 0.47, 0.42, 1 )
Terminal/colors/White = Color( 1, 1, 1, 1 ) Terminal/colors/white = Color( 0.8, 0.807843, 0.827451, 1 )
Terminal/colors/Yellow = Color( 1, 0.866667, 0.396078, 1 ) Terminal/colors/yellow = Color( 1, 0.866667, 0.396078, 1 )
Terminal/fonts/Bold = null Terminal/fonts/bold = null
"Terminal/fonts/Bold Italic" = null Terminal/fonts/bold_italic = null
Terminal/fonts/Italic = null Terminal/fonts/italic = null
Terminal/fonts/Regular = ExtResource( 1 ) Terminal/fonts/regular = ExtResource( 1 )

View file

@ -4,25 +4,25 @@
[resource] [resource]
default_font = ExtResource( 4 ) default_font = ExtResource( 4 )
Terminal/colors/Background = Color( 0.921569, 0.921569, 0.921569, 1 ) Terminal/colors/background = Color( 0.921569, 0.921569, 0.921569, 1 )
Terminal/colors/Black = Color( 0, 0, 0, 1 ) Terminal/colors/black = Color( 0, 0, 0, 1 )
Terminal/colors/Blue = Color( 0.239216, 0.392157, 0.866667, 1 ) Terminal/colors/blue = Color( 0.239216, 0.392157, 0.866667, 1 )
Terminal/colors/Cyan = Color( 0, 0.65098, 0.729412, 1 ) Terminal/colors/bright_black = Color( 0.25098, 0.25098, 0.25098, 1 )
"Terminal/colors/Dark Grey" = Color( 0.25098, 0.25098, 0.25098, 1 ) Terminal/colors/bright_blue = Color( 0.160784, 0.545098, 1, 1 )
Terminal/colors/Foreground = Color( 0.25098, 0.25098, 0.25098, 1 ) Terminal/colors/bright_cyan = Color( 0.133333, 0.8, 1, 1 )
Terminal/colors/Green = Color( 0, 0.380392, 0.188235, 1 ) Terminal/colors/bright_green = Color( 0, 0.760784, 0.380392, 1 )
"Terminal/colors/Light Blue" = Color( 0.160784, 0.545098, 1, 1 ) Terminal/colors/bright_magenta = Color( 0.658824, 0.364706, 0.913725, 1 )
"Terminal/colors/Light Cyan" = Color( 0.133333, 0.8, 1, 1 ) Terminal/colors/bright_red = Color( 1, 0.439216, 0.521569, 1 )
"Terminal/colors/Light Green" = Color( 0, 0.760784, 0.380392, 1 ) Terminal/colors/bright_white = Color( 1, 1, 1, 1 )
"Terminal/colors/Light Grey" = Color( 0.898039, 0.898039, 0.898039, 1 ) Terminal/colors/bright_yellow = Color( 1, 0.866667, 0.396078, 1 )
"Terminal/colors/Light Magenta" = Color( 0.658824, 0.364706, 0.913725, 1 ) Terminal/colors/cyan = Color( 0, 0.65098, 0.729412, 1 )
"Terminal/colors/Light Red" = Color( 1, 0.439216, 0.521569, 1 ) Terminal/colors/foreground = Color( 0.25098, 0.25098, 0.25098, 1 )
"Terminal/colors/Light Yellow" = Color( 1, 0.866667, 0.396078, 1 ) Terminal/colors/green = Color( 0, 0.380392, 0.188235, 1 )
Terminal/colors/Magenta = Color( 0.439216, 0.164706, 1, 1 ) Terminal/colors/magenta = Color( 0.439216, 0.164706, 1, 1 )
Terminal/colors/Red = Color( 0.74902, 0.352941, 0.313726, 1 ) Terminal/colors/red = Color( 0.74902, 0.352941, 0.313726, 1 )
Terminal/colors/White = Color( 1, 1, 1, 1 ) Terminal/colors/white = Color( 0.898039, 0.898039, 0.898039, 1 )
Terminal/colors/Yellow = Color( 0.698039, 0.572549, 0.0627451, 1 ) Terminal/colors/yellow = Color( 0.698039, 0.572549, 0.0627451, 1 )
Terminal/fonts/Bold = null Terminal/fonts/bold = null
"Terminal/fonts/Bold Italic" = null Terminal/fonts/bold_italic = null
Terminal/fonts/Italic = null Terminal/fonts/italic = null
Terminal/fonts/Regular = ExtResource( 4 ) Terminal/fonts/regular = ExtResource( 4 )

View file

@ -5,7 +5,7 @@ size = 14
extra_spacing_bottom = 1 extra_spacing_bottom = 1
[resource] [resource]
Terminal/fonts/Bold = null Terminal/fonts/bold = null
"Terminal/fonts/Bold Italic" = null Terminal/fonts/bold_italic = null
Terminal/fonts/Italic = null Terminal/fonts/italic = null
Terminal/fonts/Regular = SubResource( 1 ) Terminal/fonts/regular = SubResource( 1 )

View file

@ -229,7 +229,7 @@ func setup_options(options, font_names):
opts.add( opts.add(
"-gbackground_color", "-gbackground_color",
options.background_color, options.background_color,
'Background color as an html color, default "[default]"' 'background color as an html color, default "[default]"'
) )
opts.add("-gfont_color", options.font_color, 'Font color as an html color, default "[default]"') opts.add("-gfont_color", options.font_color, 'Font color as an html color, default "[default]"')

View file

@ -13,6 +13,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Deprecated the undocumented `get_master()` method of PTY that returned its Pipe. - Deprecated the undocumented `get_master()` method of PTY that returned its Pipe.
This method will be removed in a future version. This method will be removed in a future version.
The Pipe class is for internal use only and may be changed at any time. The Pipe class is for internal use only and may be changed at any time.
- Changed theme item names to be compatible with Godot version 3.5 (no spaces),
consistent with other theme item names (snake_case), and to match the ANSI
color names listed on the [ANSI escape code Wikipedia page](https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit).
Old names are deprecated and will be removed in a future version.
Please update theme item names as follows (paying particular attention to `Light Grey`, `Dark Grey`, `White`, `Bold Italic`, and the `Light *` variants):
- Colors:
- `Black` -> `black`
- `Red` -> `red`
- `Green` -> `green`
- `Yellow` -> `yellow`
- `Blue` -> `blue`
- `Magenta` -> `magenta`
- `Cyan` -> `cyan`
- `Light Grey` -> `white`
- `Dark Grey` -> `bright_black`
- `Light Red` -> `bright_red`
- `Light Green` -> `bright_green`
- `Light Yellow` -> `bright_yellow`
- `Light Blue` -> `bright_blue`
- `Light Magenta` -> `bright_magenta`
- `Light Cyan` -> `bright_cyan`
- `White` -> `bright_white`
- `Foreground` -> `foreground`
- `Background` -> `background`
- `Cursor` -> `cursor`
- Fonts:
- `Regular` -> `regular`
- `Italic` -> `italic`
- `Bold` -> `bold`
- `Bold Italic` -> `bold_italic`
### Removed ### Removed
- Removed support for Godot version 3.3.x. GodotXterm *might* still work with this - Removed support for Godot version 3.3.x. GodotXterm *might* still work with this

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) assert_true(theme is Theme)
var map := { var map := {
"Black": "#000000", "black": "#000000",
"Red": "#000001", "red": "#000001",
"Green": "#000002", "green": "#000002",
"Yellow": "#000003", "yellow": "#000003",
"Blue": "#000004", "blue": "#000004",
"Magenta": "#000005", "magenta": "#000005",
"Cyan": "#000006", "cyan": "#000006",
"Light Grey": "#000007", "white": "#000007",
"Dark Grey": "#000008", "bright_black": "#000008",
"Light Red": "#000009", "bright_red": "#000009",
"Light Green": "#000010", "bright_green": "#000010",
"Light Yellow": "#000011", "bright_yellow": "#000011",
"Light Blue": "#000012", "bright_blue": "#000012",
"Light Magenta": "#000013", "bright_magenta": "#000013",
"Light Cyan": "#000014", "bright_cyan": "#000014",
"White": "#000015", "bright_white": "#000015",
"Background": "#100000", "background": "#100000",
"Foreground": "#200000", "foreground": "#200000",
"Cursor": "#300000", "cursor": "#300000",
} }
for key in map.keys(): for key in map.keys():
@ -40,25 +40,25 @@ func test_Xresources():
assert_true(theme is Theme) assert_true(theme is Theme)
var map := { var map := {
"Black": "#282A2E", "black": "#282A2E",
"Red": "#A54242", "red": "#A54242",
"Green": "#8C9440", "green": "#8C9440",
"Yellow": "#DE935F", "yellow": "#DE935F",
"Blue": "#5F819D", "blue": "#5F819D",
"Magenta": "#85678F", "magenta": "#85678F",
"Cyan": "#5E8D87", "cyan": "#5E8D87",
"Light Grey": "#707880", "white": "#707880",
"Dark Grey": "#373B41", "bright_black": "#373B41",
"Light Red": "#CC6666", "bright_red": "#CC6666",
"Light Green": "#B5BD68", "bright_green": "#B5BD68",
"Light Yellow": "#F0C674", "bright_yellow": "#F0C674",
"Light Blue": "#81A2BE", "bright_blue": "#81A2BE",
"Light Magenta": "#B294BB", "bright_magenta": "#B294BB",
"Light Cyan": "#8ABEB7", "bright_cyan": "#8ABEB7",
"White": "#C5C8C6", "bright_white": "#C5C8C6",
"Background": "#1D1F21", "background": "#1D1F21",
"Foreground": "#C5C8C6", "foreground": "#C5C8C6",
"Cursor": "#C5C8C6", "cursor": "#C5C8C6",
} }
for key in map.keys(): for key in map.keys():
@ -70,25 +70,25 @@ func test_xresources():
assert_true(theme is Theme) assert_true(theme is Theme)
var map := { var map := {
"Black": "#000000", "black": "#000000",
"Red": "#1B0C13", "red": "#1B0C13",
"Green": "#351B27", "green": "#351B27",
"Yellow": "#563042", "yellow": "#563042",
"Blue": "#814B64", "blue": "#814B64",
"Magenta": "#B56B8D", "magenta": "#B56B8D",
"Cyan": "#D0A2B6", "cyan": "#D0A2B6",
"Light Grey": "#EDDFE4", "white": "#EDDFE4",
"Dark Grey": "#6DA3B8", "bright_black": "#6DA3B8",
"Light Red": "#CA956C", "bright_red": "#CA956C",
"Light Green": "#7CA7B9", "bright_green": "#7CA7B9",
"Light Yellow": "#A2C9BC", "bright_yellow": "#A2C9BC",
"Light Blue": "#9AAD72", "bright_blue": "#9AAD72",
"Light Magenta": "#82D0B7", "bright_magenta": "#82D0B7",
"Light Cyan": "#AE96D0", "bright_cyan": "#AE96D0",
"White": "#E6BFCF", "bright_white": "#E6BFCF",
"Background": "#000000", "background": "#000000",
"Foreground": "#EDDFE4", "foreground": "#EDDFE4",
"Cursor": "#EDDFE4", "cursor": "#EDDFE4",
} }
for key in map.keys(): 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 alt_theme := preload("res://addons/godot_xterm/themes/default_light.tres")
const COLORS := [ const COLORS := [
"Black", "black",
"Red", "red",
"Green", "green",
"Yellow", "yellow",
"Blue", "blue",
"Magenta", "magenta",
"Cyan", "cyan",
"Light Grey", "white",
"Dark Grey", "bright_black",
"Light Red", "bright_red",
"Light Green", "bright_green",
"Light Yellow", "bright_yellow",
"Light Blue", "bright_blue",
"Light Magenta", "bright_magenta",
"Light Cyan", "bright_cyan",
"White", "bright_white",
] ]
var terminal: Terminal var terminal: Terminal
@ -105,24 +105,18 @@ class TestTheme:
yield(yield_frames(1), YIELD) yield(yield_frames(1), YIELD)
func test_terminal_display_colors_from_default_theme(): func test_terminal_display_colors_from_default_theme():
if _version_gt_3_4():
return
terminal.theme = null terminal.theme = null
add_child(terminal) add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD) yield(yield_to(terminal, "theme_changed", 5), YIELD)
_check_colors(default_theme) _check_colors(default_theme)
func test_terminal_displays_colors_from_theme(): func test_terminal_displays_colors_from_theme():
if _version_gt_3_4():
return
terminal.theme = alt_theme terminal.theme = alt_theme
add_child(terminal) add_child(terminal)
yield(yield_to(terminal, "theme_changed", 5), YIELD) yield(yield_to(terminal, "theme_changed", 5), YIELD)
_check_colors(alt_theme) _check_colors(alt_theme)
func test_visible_characters_still_displayed_after_resize_with_default_theme(): func test_visible_characters_still_displayed_after_resize_with_default_theme():
if _version_gt_3_4():
return
terminal.theme = null terminal.theme = null
add_child(terminal) add_child(terminal)
yield(yield_frames(1), YIELD) yield(yield_frames(1), YIELD)
@ -131,8 +125,6 @@ class TestTheme:
_check_colors(default_theme) _check_colors(default_theme)
func test_visible_characters_still_displayed_after_resize_with_custom_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 # Issue 57: https://github.com/lihop/godot-xterm/issues/57
terminal.theme = alt_theme terminal.theme = alt_theme
add_child(terminal) add_child(terminal)
@ -142,8 +134,6 @@ class TestTheme:
_check_colors(alt_theme) _check_colors(alt_theme)
func test_updates_colors_after_theme_set(): func test_updates_colors_after_theme_set():
if _version_gt_3_4():
return
# Issue 58: https://github.com/lihop/godot-xterm/issues/58 # Issue 58: https://github.com/lihop/godot-xterm/issues/58
terminal.theme = null terminal.theme = null
add_child(terminal) add_child(terminal)
@ -153,8 +143,6 @@ class TestTheme:
_check_colors(alt_theme) _check_colors(alt_theme)
func test_updates_colors_after_theme_unset(): func test_updates_colors_after_theme_unset():
if _version_gt_3_4():
return
# Issue 58: https://github.com/lihop/godot-xterm/issues/58 # Issue 58: https://github.com/lihop/godot-xterm/issues/58
terminal.theme = alt_theme terminal.theme = alt_theme
add_child(terminal) add_child(terminal)
@ -164,8 +152,6 @@ class TestTheme:
_check_colors(default_theme) _check_colors(default_theme)
func test_updates_colors_after_theme_changed(): func test_updates_colors_after_theme_changed():
if _version_gt_3_4():
return
# Issue 58: https://github.com/lihop/godot-xterm/issues/58 # Issue 58: https://github.com/lihop/godot-xterm/issues/58
terminal.theme = alt_theme terminal.theme = alt_theme
add_child(terminal) add_child(terminal)
@ -173,3 +159,17 @@ class TestTheme:
terminal.theme = default_theme terminal.theme = default_theme
yield(yield_to(terminal, "theme_changed", 5), YIELD) yield(yield_to(terminal, "theme_changed", 5), YIELD)
_check_colors(default_theme) _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)

View file

@ -6,25 +6,25 @@
[ext_resource path="res://themes/fonts/regular.tres" type="DynamicFont" id=5] [ext_resource path="res://themes/fonts/regular.tres" type="DynamicFont" id=5]
[resource] [resource]
Terminal/colors/Background = Color( 0.12549, 0.145098, 0.192157, 1 ) Terminal/colors/background = Color( 0.12549, 0.145098, 0.192157, 1 )
Terminal/colors/Black = Color( 0, 0, 0, 1 ) Terminal/colors/black = Color( 0, 0, 0, 1 )
Terminal/colors/Blue = Color( 0.341176, 0.698039, 1, 1 ) Terminal/colors/blue = Color( 0.341176, 0.698039, 1, 1 )
Terminal/colors/Cyan = Color( 0.4, 0.901961, 1, 1 ) Terminal/colors/cyan = Color( 0.4, 0.901961, 1, 1 )
"Terminal/colors/Dark Grey" = Color( 0.462745, 0.47451, 0.509804, 1 ) "Terminal/colors/bright_black" = Color( 0.462745, 0.47451, 0.509804, 1 )
Terminal/colors/Foreground = Color( 0.8, 0.807843, 0.827451, 1 ) Terminal/colors/foreground = Color( 0.8, 0.807843, 0.827451, 1 )
Terminal/colors/Green = Color( 0.388235, 0.760784, 0.34902, 1 ) Terminal/colors/green = Color( 0.388235, 0.760784, 0.34902, 1 )
"Terminal/colors/Light Blue" = Color( 0.737255, 0.878431, 1, 1 ) "Terminal/colors/bright_blue" = Color( 0.737255, 0.878431, 1, 1 )
"Terminal/colors/Light Cyan" = Color( 0.776471, 1, 0.929412, 1 ) "Terminal/colors/bright_cyan" = Color( 0.776471, 1, 0.929412, 1 )
"Terminal/colors/Light Green" = Color( 0.258824, 1, 0.760784, 1 ) "Terminal/colors/bright_green" = Color( 0.258824, 1, 0.760784, 1 )
"Terminal/colors/Light Grey" = Color( 0.8, 0.807843, 0.827451, 1 ) "Terminal/colors/white" = Color( 0.8, 0.807843, 0.827451, 1 )
"Terminal/colors/Light Magenta" = Color( 0.807843, 0.643137, 0.945098, 1 ) "Terminal/colors/bright_magenta" = Color( 0.807843, 0.643137, 0.945098, 1 )
"Terminal/colors/Light Red" = Color( 1, 0.439216, 0.521569, 1 ) "Terminal/colors/bright_red" = Color( 1, 0.439216, 0.521569, 1 )
"Terminal/colors/Light Yellow" = Color( 1, 0.92549, 0.627451, 1 ) "Terminal/colors/bright_yellow" = Color( 1, 0.92549, 0.627451, 1 )
Terminal/colors/Magenta = Color( 0.623529, 0.439216, 1, 1 ) Terminal/colors/magenta = Color( 0.623529, 0.439216, 1, 1 )
Terminal/colors/Red = Color( 1, 0.47, 0.42, 1 ) Terminal/colors/red = Color( 1, 0.47, 0.42, 1 )
Terminal/colors/White = Color( 1, 1, 1, 1 ) Terminal/colors/bright_white = Color( 1, 1, 1, 1 )
Terminal/colors/Yellow = Color( 1, 0.866667, 0.396078, 1 ) Terminal/colors/yellow = Color( 1, 0.866667, 0.396078, 1 )
Terminal/fonts/Bold = ExtResource( 4 ) Terminal/fonts/bold = ExtResource( 4 )
"Terminal/fonts/Bold Italic" = ExtResource( 2 ) "Terminal/fonts/bold_italic" = ExtResource( 2 )
Terminal/fonts/Italic = ExtResource( 3 ) Terminal/fonts/italic = ExtResource( 3 )
Terminal/fonts/Regular = ExtResource( 5 ) Terminal/fonts/regular = ExtResource( 5 )

View file

@ -9,27 +9,27 @@ extra_spacing_bottom = 1
font_data = ExtResource( 2 ) font_data = ExtResource( 2 )
[resource] [resource]
Terminal/colors/Background = Color( 0.156863, 0.156863, 0.156863, 1 ) Terminal/colors/background = Color( 0.156863, 0.156863, 0.156863, 1 )
Terminal/colors/Black = Color( 0, 1, 0.4, 1 ) Terminal/colors/black = Color( 0, 1, 0.4, 1 )
Terminal/colors/Blue = Color( 0, 1, 0.4, 1 ) Terminal/colors/blue = Color( 0, 1, 0.4, 1 )
Terminal/colors/Cursor = Color( 0, 1, 0.4, 1 ) Terminal/colors/Cursor = Color( 0, 1, 0.4, 1 )
Terminal/colors/Cyan = Color( 0, 1, 0.4, 1 ) Terminal/colors/cyan = Color( 0, 1, 0.4, 1 )
"Terminal/colors/Dark Grey" = Color( 0, 1, 0.4, 1 ) "Terminal/colors/bright_black" = Color( 0, 1, 0.4, 1 )
Terminal/colors/Foreground = Color( 0, 1, 0.4, 1 ) Terminal/colors/foreground = Color( 0, 1, 0.4, 1 )
Terminal/colors/Green = Color( 0, 1, 0.4, 1 ) Terminal/colors/green = Color( 0, 1, 0.4, 1 )
"Terminal/colors/Light Blue" = Color( 0, 1, 0.4, 1 ) "Terminal/colors/bright_blue" = Color( 0, 1, 0.4, 1 )
"Terminal/colors/Light Cyan" = Color( 0, 1, 0.4, 1 ) "Terminal/colors/bright_cyan" = Color( 0, 1, 0.4, 1 )
"Terminal/colors/Light Green" = Color( 0, 1, 0.4, 1 ) "Terminal/colors/bright_green" = Color( 0, 1, 0.4, 1 )
"Terminal/colors/Light Grey" = Color( 0, 1, 0.4, 1 ) "Terminal/colors/white" = Color( 0, 1, 0.4, 1 )
"Terminal/colors/Light Magenta" = Color( 0, 1, 0.4, 1 ) "Terminal/colors/bright_magenta" = Color( 0, 1, 0.4, 1 )
"Terminal/colors/Light Red" = Color( 0, 1, 0.4, 1 ) "Terminal/colors/bright_red" = Color( 0, 1, 0.4, 1 )
"Terminal/colors/Light Yellow" = Color( 0, 1, 0.4, 1 ) "Terminal/colors/bright_yellow" = Color( 0, 1, 0.4, 1 )
Terminal/colors/Magenta = Color( 0, 1, 0.4, 1 ) Terminal/colors/magenta = Color( 0, 1, 0.4, 1 )
Terminal/colors/Red = Color( 0, 1, 0.4, 1 ) Terminal/colors/red = Color( 0, 1, 0.4, 1 )
Terminal/colors/White = Color( 0, 1, 0.4, 1 ) Terminal/colors/bright_white = Color( 0, 1, 0.4, 1 )
Terminal/colors/Yellow = Color( 0, 1, 0.4, 1 ) Terminal/colors/yellow = Color( 0, 1, 0.4, 1 )
Terminal/fonts/Bold = null Terminal/fonts/bold = null
"Terminal/fonts/Bold Italic" = null "Terminal/fonts/bold_italic" = null
Terminal/fonts/Italic = null Terminal/fonts/italic = null
Terminal/fonts/Regular = SubResource( 1 ) Terminal/fonts/regular = SubResource( 1 )
script = ExtResource( 1 ) script = ExtResource( 1 )