mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-24 18:20:25 +01:00
parent
399acf00c7
commit
007182b117
11 changed files with 56 additions and 97 deletions
19
.github/workflows/main.yml
vendored
19
.github/workflows/main.yml
vendored
|
@ -25,3 +25,22 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- name: Build for supported platforms on Ubuntu
|
||||
run: docker-compose run build-ubuntu
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Install SCons software construction tool
|
||||
run: choco install python3 && python -m pip install scons
|
||||
- name: Build for Windows 64-bit using MSVC
|
||||
run: |
|
||||
cd addons/godot_xterm/native/external/godot-cpp
|
||||
scons platform=windows target=release bits=64 generate_bindings=yes
|
||||
cd ../../
|
||||
scons platform=windows target=release bits=64
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: bin
|
||||
path: addons/godot_xterm/native/bin/*.dll
|
||||
|
|
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -3,4 +3,4 @@
|
|||
url = https://github.com/godotengine/godot-cpp
|
||||
[submodule "addons/godot_xterm/libtsm"]
|
||||
path = addons/godot_xterm/native/external/libtsm
|
||||
url = https://github.com/Aetf/libtsm
|
||||
url = https://github.com/lihop/libtsm
|
||||
|
|
|
@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Support for Windows 64-bit.
|
||||
- Support for Windows 64-bit and compiling on Windows using MSVC.
|
||||
|
||||
### Changed
|
||||
- Updated build script. `./build.sh` will create a debug build of the gdnative library for the current platform. `./build.sh release-all` will create release build of the gdnative library for every supported platform.
|
||||
|
|
|
@ -63,8 +63,12 @@ addons/godot_xterm/native/build.sh
|
|||
#### Other Linux Distributions
|
||||
Will probably be similar to the above. When in doubt check the documentation in the submodule repos, the [build.sh] script, and the [SConstruct] file.
|
||||
|
||||
### Windows
|
||||
Compiling on Windows for 64-bit is supported using [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/) version 2019, although other versions might work. See the [Godot documentation](https://docs.godotengine.org/en/stable/development/compiling/compiling_for_windows.html) for more information on setting up the development environment.
|
||||
See the [github workflow file](.github/workflows/main.yml) for the commands that can be used to build the native libraries.
|
||||
|
||||
### Other Operating Systems
|
||||
This plugin is not currently supported for other operating systems (e.g. MacOS, Windows). If you manage to build it on one of these platforms, please submit a PR for this readme.
|
||||
This plugin is not currently supported for other operating systems (i.e. MacOS). If you manage to build it on a different platform, please submit a PR for this readme.
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
|
@ -14,56 +14,6 @@ import os
|
|||
import sys
|
||||
import subprocess
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def decode_utf8(x):
|
||||
return x
|
||||
else:
|
||||
import codecs
|
||||
def decode_utf8(x):
|
||||
return codecs.utf_8_decode(x)[0]
|
||||
|
||||
# Workaround for MinGW. See:
|
||||
# http://www.scons.org/wiki/LongCmdLinesOnWin32
|
||||
if (os.name=="nt"):
|
||||
import subprocess
|
||||
|
||||
def mySubProcess(cmdline,env):
|
||||
#print "SPAWNED : " + cmdline
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env)
|
||||
data, err = proc.communicate()
|
||||
rv = proc.wait()
|
||||
if rv:
|
||||
print("=====")
|
||||
print(err.decode("utf-8"))
|
||||
print("=====")
|
||||
return rv
|
||||
|
||||
def mySpawn(sh, escape, cmd, args, env):
|
||||
|
||||
newargs = ' '.join(args[1:])
|
||||
cmdline = cmd + " " + newargs
|
||||
|
||||
rv=0
|
||||
if len(cmdline) > 32000 and cmd.endswith("ar") :
|
||||
cmdline = cmd + " " + args[1] + " " + args[2] + " "
|
||||
for i in range(3,len(args)) :
|
||||
rv = mySubProcess( cmdline + args[i], env )
|
||||
if rv :
|
||||
break
|
||||
else:
|
||||
rv = mySubProcess( cmdline, env )
|
||||
|
||||
return rv
|
||||
|
||||
def add_sources(sources, dir, extension):
|
||||
for f in os.listdir(dir):
|
||||
if f.endswith('.' + extension):
|
||||
sources.append(dir + '/' + f)
|
||||
|
||||
|
||||
# Try to detect the host platform automatically.
|
||||
# This is used if no `platform` argument is passed.
|
||||
if sys.platform.startswith('linux'):
|
||||
|
@ -177,7 +127,17 @@ elif env['platform'] == 'osx':
|
|||
elif env['platform'] == 'windows':
|
||||
env.Append(CPPDEFINES=['PLATFORM_WINDOWS'])
|
||||
|
||||
env.Append(CCFLAGS=['-Wwrite-strings'])
|
||||
# On Windows using MSVC.
|
||||
if host_platform == 'windows':
|
||||
env.Append(LINKFLAGS=['/W3', '/GR'])
|
||||
if env['target'] == 'debug':
|
||||
env.Append(CCFLAGS=['/Z7', '/Od', '/EHsc', '/D_DEBUG', '/MDd'])
|
||||
elif env['target'] == 'release':
|
||||
env.Append(CCFLAGS=['/O2', '/EHsc', '/DNDEBUG', '/MD'])
|
||||
|
||||
# On Windows, Linux, or MacOS using MinGW.
|
||||
elif host_platform == 'linux' or host_platform == 'osx':
|
||||
env.Append(CCFLAGS=['-std=c++14', '-Wwrite-strings'])
|
||||
env.Append(LINKFLAGS=[
|
||||
'--static',
|
||||
'-Wl,--no-undefined',
|
||||
|
@ -190,13 +150,6 @@ elif env['platform'] == 'windows':
|
|||
elif env['target'] == 'release':
|
||||
env.Append(CCFLAGS=['-O3'])
|
||||
|
||||
# On Windows.
|
||||
if host_platform == 'windows':
|
||||
env = env.Clone(tools=['mingw'])
|
||||
env["SPAWN"] = mySpawn
|
||||
|
||||
# On Linux or MacOS.
|
||||
elif host_platform == 'linux' or host_platform == 'osx':
|
||||
if env['bits'] == '64':
|
||||
env['CC'] = 'x86_64-w64-mingw32-gcc'
|
||||
env['CXX'] = 'x86_64-w64-mingw32-g++'
|
||||
|
|
2
addons/godot_xterm/native/external/libtsm
vendored
2
addons/godot_xterm/native/external/libtsm
vendored
|
@ -1 +1 @@
|
|||
Subproject commit f70e37982f382b03c6939dac3d5f814450bda253
|
||||
Subproject commit 1f3ae2bc36236136b8ed328b0c64ed954beac33f
|
|
@ -11,6 +11,7 @@ Server.64="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.64.so"
|
|||
X11.64="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.64.so"
|
||||
X11.32="res://addons/godot_xterm/native/bin/libgodot-xterm.linux.32.so"
|
||||
Windows.64="res://addons/godot_xterm/native/bin/libgodot-xterm.windows.64.dll"
|
||||
Windows.32="res://addons/godot_xterm/native/bin/libgodot-xterm.windows.32.dll"
|
||||
OSX.64="res://addons/godot_xterm/native/bin/libgodot-xterm.osx.64.dylib"
|
||||
|
||||
[dependencies]
|
||||
|
@ -19,4 +20,5 @@ Server.64=[ ]
|
|||
X11.64=[ ]
|
||||
X11.32=[ ]
|
||||
Windows.64=[ ]
|
||||
Windows.32=[ ]
|
||||
OSX.64=[ ]
|
||||
|
|
0
addons/godot_xterm/native/src/.gdignore
Normal file
0
addons/godot_xterm/native/src/.gdignore
Normal file
|
@ -8,28 +8,7 @@
|
|||
|
||||
using namespace godot;
|
||||
|
||||
// Use xterm default for default color palette.
|
||||
const uint8_t Terminal::default_color_palette[TSM_COLOR_NUM][3] = {
|
||||
[TSM_COLOR_BLACK] = {0x00, 0x00, 0x00},
|
||||
[TSM_COLOR_RED] = {0x80, 0x00, 0x00},
|
||||
[TSM_COLOR_GREEN] = {0x00, 0x80, 0x00},
|
||||
[TSM_COLOR_YELLOW] = {0x80, 0x80, 0x00},
|
||||
[TSM_COLOR_BLUE] = {0x00, 0x00, 0x80},
|
||||
[TSM_COLOR_MAGENTA] = {0x80, 0x00, 0x80},
|
||||
[TSM_COLOR_CYAN] = {0x00, 0x80, 0x80},
|
||||
[TSM_COLOR_LIGHT_GREY] = {0xc0, 0xc0, 0xc0},
|
||||
[TSM_COLOR_DARK_GREY] = {0x80, 0x80, 0x80},
|
||||
[TSM_COLOR_LIGHT_RED] = {0xff, 0x00, 0x00},
|
||||
[TSM_COLOR_LIGHT_GREEN] = {0x00, 0xff, 0x00},
|
||||
[TSM_COLOR_LIGHT_YELLOW] = {0xff, 0xff, 0x00},
|
||||
[TSM_COLOR_LIGHT_BLUE] = {0x00, 0x00, 0xff},
|
||||
[TSM_COLOR_LIGHT_MAGENTA] = {0xff, 0x00, 0xff},
|
||||
[TSM_COLOR_LIGHT_CYAN] = {0x00, 0xff, 0xff},
|
||||
[TSM_COLOR_WHITE] = {0xff, 0xff, 0xff},
|
||||
|
||||
[TSM_COLOR_FOREGROUND] = {0xff, 0xff, 0xff},
|
||||
[TSM_COLOR_BACKGROUND] = {0x00, 0x00, 0x00},
|
||||
};
|
||||
const struct Terminal::cell Terminal::empty_cell = {{0, 0, 0, 0, 0}, {}};
|
||||
|
||||
const std::map<std::pair<int64_t, int64_t>, uint32_t> Terminal::keymap = {
|
||||
|
||||
|
@ -387,9 +366,6 @@ void Terminal::_draw()
|
|||
|
||||
void Terminal::update_color_palette()
|
||||
{
|
||||
// Start with a copy of the default color palette
|
||||
memcpy(color_palette, Terminal::default_color_palette, sizeof(Terminal::default_color_palette));
|
||||
|
||||
/* Generate color palette based on theme */
|
||||
|
||||
// Converts a color from the Control's theme to one that can
|
||||
|
|
|
@ -20,7 +20,8 @@ namespace godot
|
|||
{
|
||||
char ch[5];
|
||||
struct tsm_screen_attr attr;
|
||||
} empty_cell = {ch : {0, 0, 0, 0, 0}, attr : {}};
|
||||
};
|
||||
static const struct cell empty_cell;
|
||||
|
||||
public:
|
||||
typedef std::vector<std::vector<struct cell>> Cells;
|
||||
|
|
|
@ -130,6 +130,10 @@ func _on_Terminal_key_pressed(data: String, event: InputEventKey) -> void:
|
|||
$Terminal.grab_focus()
|
||||
scene.queue_free()
|
||||
"Terminal":
|
||||
if OS.get_name() == "Windows":
|
||||
return OS.call_deferred("alert", "Psuedoterminal node currently"
|
||||
+ " uses pty.h but needs to use either winpty or conpty"
|
||||
+ " to work on Windows.", "Terminal not Supported on Windows")
|
||||
var scene = item.scene.instance()
|
||||
var pty = scene.get_node("Pseudoterminal")
|
||||
get_tree().get_root().add_child(scene)
|
||||
|
|
Loading…
Reference in a new issue