mirror of
https://github.com/lihop/godot-xterm.git
synced 2025-05-04 12:14:24 +02:00
parent
399acf00c7
commit
007182b117
11 changed files with 56 additions and 97 deletions
|
@ -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,26 +127,29 @@ elif env['platform'] == 'osx':
|
|||
elif env['platform'] == 'windows':
|
||||
env.Append(CPPDEFINES=['PLATFORM_WINDOWS'])
|
||||
|
||||
env.Append(CCFLAGS=['-Wwrite-strings'])
|
||||
env.Append(LINKFLAGS=[
|
||||
'--static',
|
||||
'-Wl,--no-undefined',
|
||||
'-static-libgcc',
|
||||
'-static-libstdc++',
|
||||
])
|
||||
|
||||
if env['target'] == 'debug':
|
||||
env.Append(CCFLAGS=['-Og', '-g'])
|
||||
elif env['target'] == 'release':
|
||||
env.Append(CCFLAGS=['-O3'])
|
||||
|
||||
# On Windows.
|
||||
# On Windows using MSVC.
|
||||
if host_platform == 'windows':
|
||||
env = env.Clone(tools=['mingw'])
|
||||
env["SPAWN"] = mySpawn
|
||||
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 Linux or MacOS.
|
||||
# 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',
|
||||
'-static-libgcc',
|
||||
'-static-libstdc++',
|
||||
])
|
||||
|
||||
if env['target'] == 'debug':
|
||||
env.Append(CCFLAGS=['-Og', '-g'])
|
||||
elif env['target'] == 'release':
|
||||
env.Append(CCFLAGS=['-O3'])
|
||||
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue