mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-10 04:40:25 +01:00
Format .gd files and fix gdformat pre-commit hook
Previously this hook was not being run.
This commit is contained in:
parent
80bcc41855
commit
302bdf0714
5 changed files with 32 additions and 16 deletions
|
@ -11,14 +11,15 @@ const CURSOR_LEFT = "\u001b[D"
|
||||||
|
|
||||||
const DEFAULT_FOREGROUND_COLOR = "\u001b[0m"
|
const DEFAULT_FOREGROUND_COLOR = "\u001b[0m"
|
||||||
|
|
||||||
|
|
||||||
class ANSIColor:
|
class ANSIColor:
|
||||||
extends Object
|
extends Object
|
||||||
# Using ANSIColor constants, rather than Color will respect the
|
# Using ANSIColor constants, rather than Color will respect the
|
||||||
# colors of the selected terminal theme. Whereas Color will set
|
# colors of the selected terminal theme. Whereas Color will set
|
||||||
# the exact color specified regardless of theme.
|
# the exact color specified regardless of theme.
|
||||||
|
|
||||||
const black = { fg = 30, bg = 40 }
|
const black = {fg = 30, bg = 40}
|
||||||
const red = {fg = 31, bg = 41 }
|
const red = {fg = 31, bg = 41}
|
||||||
const green = {fg = 32, bg = 42}
|
const green = {fg = 32, bg = 42}
|
||||||
const yellow = {fg = 33, bg = 43}
|
const yellow = {fg = 33, bg = 43}
|
||||||
const blue = {fg = 34, bg = 44}
|
const blue = {fg = 34, bg = 44}
|
||||||
|
@ -35,9 +36,12 @@ class ANSIColor:
|
||||||
const bright_magenta = {fg = 95, bg = 105}
|
const bright_magenta = {fg = 95, bg = 105}
|
||||||
const bright_cyan = {fg = 96, bg = 106}
|
const bright_cyan = {fg = 96, bg = 106}
|
||||||
const bright_white = {fg = 97, bg = 107}
|
const bright_white = {fg = 97, bg = 107}
|
||||||
|
|
||||||
func _init():
|
func _init():
|
||||||
assert(false, "ANSIColor is an abstract class. You should only use the color constants (e.g. ANSIColor.black).")
|
assert(
|
||||||
|
false,
|
||||||
|
"ANSIColor is an abstract class. You should only use the color constants (e.g. ANSIColor.black)."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
var terminal
|
var terminal
|
||||||
|
|
|
@ -18,7 +18,15 @@ const TITLE_WIDTH = 42
|
||||||
|
|
||||||
var menu_items := [
|
var menu_items := [
|
||||||
{"name": "Asciicast", "scene": preload("../asciicast/asciicast.tscn")},
|
{"name": "Asciicast", "scene": preload("../asciicast/asciicast.tscn")},
|
||||||
{"name": "Terminal", "scene": preload("../web_console/web_console.tscn") if OS.has_feature("JavaScript") else preload("../terminal/terminal.tscn")},
|
{
|
||||||
|
"name": "Terminal",
|
||||||
|
"scene":
|
||||||
|
(
|
||||||
|
preload("../web_console/web_console.tscn")
|
||||||
|
if OS.has_feature("JavaScript")
|
||||||
|
else preload("../terminal/terminal.tscn")
|
||||||
|
)
|
||||||
|
},
|
||||||
{"name": "Exit"}
|
{"name": "Exit"}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -140,7 +148,11 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
|
||||||
"Terminal not Supported on Windows"
|
"Terminal not Supported on Windows"
|
||||||
)
|
)
|
||||||
var scene = item.scene.instance()
|
var scene = item.scene.instance()
|
||||||
var pty = scene if OS.has_feature("JavaScript") else scene.get_node("Pseudoterminal")
|
var pty = (
|
||||||
|
scene
|
||||||
|
if OS.has_feature("JavaScript")
|
||||||
|
else scene.get_node("Pseudoterminal")
|
||||||
|
)
|
||||||
get_tree().get_root().add_child(scene)
|
get_tree().get_root().add_child(scene)
|
||||||
visible = false
|
visible = false
|
||||||
scene.grab_focus()
|
scene.grab_focus()
|
||||||
|
|
|
@ -39,17 +39,17 @@ func grab_focus():
|
||||||
func _on_Terminal_key_pressed(_data, event: InputEventKey):
|
func _on_Terminal_key_pressed(_data, event: InputEventKey):
|
||||||
if not event:
|
if not event:
|
||||||
return
|
return
|
||||||
|
|
||||||
# For some reason, data String is malformed on HTML5, so only use event.unicode.
|
# For some reason, data String is malformed on HTML5, so only use event.unicode.
|
||||||
var data = char(event.unicode)
|
var data = char(event.unicode)
|
||||||
|
|
||||||
match event.scancode:
|
match event.scancode:
|
||||||
KEY_ENTER:
|
KEY_ENTER:
|
||||||
terminal.write("\r\n")
|
terminal.write("\r\n")
|
||||||
|
|
||||||
if line == "q" or line == "quit" or line == "exit":
|
if line == "q" or line == "quit" or line == "exit":
|
||||||
return emit_signal("exited", 0)
|
return emit_signal("exited", 0)
|
||||||
|
|
||||||
if not _has_js:
|
if not _has_js:
|
||||||
var msg := "WebConsole only available in HTML5 build."
|
var msg := "WebConsole only available in HTML5 build."
|
||||||
push_error(msg)
|
push_error(msg)
|
||||||
|
@ -62,11 +62,11 @@ func _on_Terminal_key_pressed(_data, event: InputEventKey):
|
||||||
_tput.setaf(TPut.ANSIColor.magenta)
|
_tput.setaf(TPut.ANSIColor.magenta)
|
||||||
terminal.write(str(json))
|
terminal.write(str(json))
|
||||||
_tput.sgr0()
|
_tput.sgr0()
|
||||||
|
|
||||||
line = ""
|
line = ""
|
||||||
#_tput.srg0()
|
#_tput.srg0()
|
||||||
prompt("\r\n>> ")
|
prompt("\r\n>> ")
|
||||||
|
|
||||||
KEY_BACKSPACE:
|
KEY_BACKSPACE:
|
||||||
if line.length() > 0:
|
if line.length() > 0:
|
||||||
terminal.write("\b \b")
|
terminal.write("\b \b")
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
# pre-commit hooks to be executed. They should be in the same .git/hooks/ folder
|
# pre-commit hooks to be executed. They should be in the same .git/hooks/ folder
|
||||||
# as this script. Hooks should return 0 if successful and nonzero to cancel the
|
# as this script. Hooks should return 0 if successful and nonzero to cancel the
|
||||||
# commit. They are executed in the order in which they are listed.
|
# commit. They are executed in the order in which they are listed.
|
||||||
HOOKS="pre-commit-gdformat"
|
HOOKS="pre-commit-gdformat pre-commit-clang-format"
|
||||||
HOOKS="pre-commit-clang-format"
|
|
||||||
###########################################################
|
###########################################################
|
||||||
# There should be no need to change anything below this line.
|
# There should be no need to change anything below this line.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#! /usr/bin/env nix-shell
|
#! /usr/bin/env nix-shell
|
||||||
#! nix-shell -i sh -p python38
|
#! nix-shell -i sh -p python38
|
||||||
|
set -e
|
||||||
|
|
||||||
GDTOOLKIT_VERSION=f5e2746d146200ec07ac6acb6fb378fd4c64f3f0
|
GDTOOLKIT_VERSION=f5e2746d146200ec07ac6acb6fb378fd4c64f3f0
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ if [ ! -f .venv/bin/activate ] || ! source .venv/bin/activate; then
|
||||||
python -m venv .venv && source .venv/bin/activate;
|
python -m venv .venv && source .venv/bin/activate;
|
||||||
fi
|
fi
|
||||||
if ! gdformat --version; then
|
if ! gdformat --version; then
|
||||||
pip install git+git://github.com/Scony/godot-gdscript-toolkit@${gdtoolkit_version};
|
pip install git+git://github.com/Scony/godot-gdscript-toolkit@${GDTOOLKIT_VERSION};
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Format all selected files.
|
# Format all selected files.
|
||||||
|
|
Loading…
Reference in a new issue