mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-04 20:24:23 +02:00
Add HTML5 support
This commit is contained in:
parent
fbb23661d3
commit
bb8d40df58
18 changed files with 284 additions and 31 deletions
|
@ -11,6 +11,35 @@ const CURSOR_LEFT = "\u001b[D"
|
|||
|
||||
const DEFAULT_FOREGROUND_COLOR = "\u001b[0m"
|
||||
|
||||
class ANSIColor:
|
||||
extends Object
|
||||
# Using ANSIColor constants, rather than Color will respect the
|
||||
# colors of the selected terminal theme. Whereas Color will set
|
||||
# the exact color specified regardless of theme.
|
||||
|
||||
const black = { fg = 30, bg = 40 }
|
||||
const red = {fg = 31, bg = 41 }
|
||||
const green = {fg = 32, bg = 42}
|
||||
const yellow = {fg = 33, bg = 43}
|
||||
const blue = {fg = 34, bg = 44}
|
||||
const magenta = {fg = 35, bg = 45}
|
||||
const cyan = {fg = 36, bg = 46}
|
||||
const white = {fg = 37, bg = 47}
|
||||
const bright_black = {fg = 90, bg = 100}
|
||||
const gray = bright_black
|
||||
const grey = bright_black
|
||||
const bright_red = {fg = 91, bg = 101}
|
||||
const bright_green = {fg = 92, bg = 102}
|
||||
const bright_yellow = {fg = 93, bg = 103}
|
||||
const bright_blue = {fg = 94, bg = 104}
|
||||
const bright_magenta = {fg = 95, bg = 105}
|
||||
const bright_cyan = {fg = 96, bg = 106}
|
||||
const bright_white = {fg = 97, bg = 107}
|
||||
|
||||
func _init():
|
||||
assert(false, "ANSIColor is an abstract class. You should only use the color constants (e.g. ANSIColor.black).")
|
||||
|
||||
|
||||
var terminal
|
||||
|
||||
|
||||
|
@ -44,14 +73,22 @@ func cup(row: int = 0, col: int = 0) -> void:
|
|||
terminal.write("\u001b[%d;%dH" % [row, col])
|
||||
|
||||
|
||||
func setaf(color: Color) -> void:
|
||||
var fg = "\u001b[38;2;%d;%d;%dm" % [color.r8, color.g8, color.b8]
|
||||
terminal.write(fg)
|
||||
func setaf(color) -> void:
|
||||
if color is Color:
|
||||
terminal.write("\u001b[38;2;%d;%d;%dm" % [color.r8, color.g8, color.b8])
|
||||
elif "fg" in color and color.fg is int:
|
||||
terminal.write("\u001b[%dm" % color.fg)
|
||||
else:
|
||||
push_error("Invalid color: %s" % color)
|
||||
|
||||
|
||||
func setab(color: Color) -> void:
|
||||
var bg = "\u001b[48;2;%d;%d;%dm" % [color.r8, color.g8, color.b8]
|
||||
terminal.write(bg)
|
||||
func setab(color) -> void:
|
||||
if color is Color:
|
||||
terminal.write("\u001b[48;2;%d;%d;%dm" % [color.r8, color.g8, color.b8])
|
||||
elif "bg" in color and color.bg is int:
|
||||
terminal.write("\u001b[%dm" % color.bg)
|
||||
else:
|
||||
push_error("Invalid color: %s" % color)
|
||||
|
||||
|
||||
func rev() -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue