Commit graph

95 commits

Author SHA1 Message Date
Leroy Hopson
b18726eac9
Pin nixpkgs version 2024-01-06 23:22:39 +13:00
Leroy Hopson
fac6361898
Upgrade min compatible Godot version to 4.2.1 2024-01-06 23:22:34 +13:00
Leroy Hopson
11ed797005
Update godot-cpp to match Godot v4.0-rc1 API
Usage of VARIANT_ENUM_CAST has changed.
2023-02-12 10:53:34 +13:00
Leroy Hopson
f36f1db315
Allow SCONS_CACHE env var in pure nix environment 2023-02-12 10:53:34 +13:00
Leroy Hopson
2ba480b4da
Update build files and GitHub Actions workflow 2023-01-26 08:21:43 +13:00
Leroy Hopson
9f269aec8c
Make update_modue a dropdown in editor inspector
Closes #61.
2023-01-21 11:03:22 +13:00
Leroy Hopson
9c7c5e1c17
Reorder methods 2023-01-21 10:37:26 +13:00
Leroy Hopson
754a20b1c3
Remove unused include 2023-01-21 10:18:26 +13:00
Leroy Hopson
dee6d537c0
Update godot-cpp for Godot v4.0-beta12 2023-01-14 22:38:17 +13:00
Leroy Hopson
8d56b5659a
Re-enable building of godot-cpp dependency 2023-01-14 22:35:30 +13:00
Leroy Hopson
ad7f97e493
Further progress towards Godot 4.0 support
- Primary example scenes (menu, terminal, and asciicast) working but
  still a lot of warning/error messages and some regressions.
- Editor integrated terminal works, but still a lot of warning/error
  messages and some regressions.
- Added support for "blink" display attribute.
- Removed GDScript terminal code. Terminal node is now purely a
  GDExtension. So is LibuvUtils.
- GUT tests not working yet.
- Still a lot of things to fix.
- So far, only built for and manually tested on Linux x86_64.
2023-01-08 22:45:18 +13:00
Leroy Hopson
44f7e3801c
Convert from GDNative to GDExtension
Work in progress.
2022-12-29 22:54:38 +13:00
Leroy Hopson
9435502c8d
Statically link libstdc++
Otherwise binaries build on GitHub Actions fail to load on NixOS as
dynamically linked libstdc++ cannot be found.
2022-08-27 20:45:41 +12:00
Leroy Hopson
10b9764fb3
Use default export templates for HTML5
Changes Emscripten SDK version to match that used to compile the default export
templates used by Godot 3.5 (in this case 3.1.14 as can be seen here:
https://github.com/godotengine/build-containers/blob/3.5/Dockerfile.javascript).

This means we no longer need to compile custom export templates when
exporting HTML5 for Godot 3.5. Exports from other Godot versions may
requiring compiling the GDNative library with a different version of the
Emscripten SDK.

- Changes renderer from GLES3 -> GLES2 and reduces MSAA level to better
  support HTML5 export.
- Updates GitHub Action to export HTML5 and upload as a build artifact.
- Adds Cypress test to smoke test HTML5 export.
2022-08-27 10:32:22 +12:00
Leroy Hopson
9765e94889
Change target Godot version to v3.5-stable
Upgrade setup-godot action from v1 -> v2 which changes default Godot
version from 3.4 -> 3.5.
2022-08-26 16:53:02 +12:00
Leroy Hopson
95b66115c4
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.
2022-08-26 09:28:38 +12:00
Leroy Hopson
d45ea7a3cd
Update libtsm to not erase screen on palette change
Fixes #57.
Fixes #58.
2022-08-22 22:56:50 +12:00
Leroy Hopson
f49410838c
Drop support for Godot 3.3.x 2022-08-22 10:02:50 +12:00
Leroy Hopson
9ed6750b83
Fix unicode errors
Changes `write()` method of native pipe and terminal to accept a
PoolByteArray rather than String. This means that `get_string_from_utf8()`
is no longer called on data coming from PTY and being sent to Terminal.

The terminal state machine already has a UTF8 parser which maintains
its state across calls to `write()`. This means that we can write half
the bytes of a single unicode character in one call and the remaining half
in the next call and the state machine will parse it correctly.

On the other hand, the `get_string_from_utf8()` method of Godot's
PoolByteArray requires that the array contains completely valid UTF8,
otherwise we get errors such as "Unicode error: invalid skip".

The data coming from PTY can be arbitrarily split in the middle of a
unicode character meaning that we will sometimes get errors when calling
`get_string_from_utf8()` on it. This is more likely to occur when there
is a large amount of output (i.e. it's more likely to be split). In other
cases, the data might intentionally contain invalid unicode such as when
printing binary files or random data (e.g. `cat /bin/sh`, `cat /dev/random`).

We avoid these errors by passing the PoolByteArray data directly to the terminal
state machine.

In addition to fixing unicode errors, this commit:
- Prevents repeated calls to pipes `_read_cb()` method that would block Godot
  and result in a crash with the message "ERROR: All memory pool allocations
  are in use" that resulted from writing data to an ever-increasing number of
  PoolByteArrays before any of them could be freed. This could be triggered by
  running the `cat /dev/urandom` command after making the change to `write()`
  mentioned above.
- Prevents memory leaks by freeing libuv buffers after they have been copied
  to PoolByteArrays.

Fixes #55.
2022-08-15 17:09:29 +12:00
Leroy Hopson
8a3adbbe68
Fix GitHub Actions godot-cpp-linux Docker build 2022-08-03 22:41:12 +12:00
Leroy Hopson
0ae1d80abb
Prevent exit callback instance leaks
De-references pty_baton's exit callback after it is called so it can be
automatically released, preventing leaked instances.

Adds basic implementation for Pipe's get_status() method and forces PTY
to wait for child process to exit to ensure exit callback is cleaned up.

Adds a test to check that exit callback is still called as usual.
2022-07-11 09:33:01 +12:00
Leroy Hopson
bea5d1c27d
Check if baton FuncRef is valid before calling call_funcv()
Often when closing a terminal in the terminal panel the error message
'Condition "!obj" is true.' would be printed to console.

This was due to the call_funcv() method being called on an invalid
FuncRef instance (invalid because it had already been deleted or queued
for delection).

Now we check the instance is valid before calling the method.
2022-07-11 09:33:00 +12:00
Leroy Hopson
f0bd70cb3e
Update target Godot version: 3.3.2-stable -> 3.4.4-stable
Also apply automatic updates to .import files after opening project in
3.4.4 editor.
2022-07-11 09:33:00 +12:00
Leroy Hopson
3fdc9ef27e
Add Docker build for Linux
Adds support for building Linux binaries inside a docker container in
order to target an older version of GLIBC.

Updates GitHub Actions workflow to use it.

As a result the minimum version of GLIBC that Linux users need to have
installed on their system is 2.17 which was released in 2012.
2022-07-11 09:33:00 +12:00
Leroy Hopson
1d51acb38d
Register pipe.close() method
Allows kill() method of unix PTY node to be called without error.
2022-07-11 09:33:00 +12:00
Leroy Hopson
57dadf7db2
Support universal (x86_64/arm64) builds for macOS
The macOS binary (libgodot-xterm.osx.64.dylib) is now a universal binary
that runs natively on both x86_64 and arm64.
2022-07-11 09:33:00 +12:00
Leroy Hopson
0ccac28cc6
Update godot-cpp submodule
- We now need to include `<string>` in `terminal.cpp`.
- Clean-up `.gitmodules` while we're at it.
2022-05-31 18:34:51 +07:00
Leroy Hopson
5f399ed46e
Allow theme inheritance
Terminal colors and fonts will be inherited from ancestor nodes if not
defined.
2021-07-23 09:30:25 +07:00
Leroy Hopson
c81da3820b
Kill child process and close pty on exit
- Adds kill() method to LibuvUtils.
- Adds close() method to Pipe.
2021-07-23 08:37:54 +07:00
Leroy Hopson
568a9835c6
Fallback to Regular Terminal font before default font
Will fallback to using Regular Terminal font for Bold, Italic, and Bold
Italic styles if they are not defined. Will only fallback to using the
default theme font if even Regular is not defined.
2021-07-23 08:37:47 +07:00
Leroy Hopson
10983653c6
Fix macOS builds 2021-07-20 11:18:52 +07:00
Leroy Hopson
8bc3a13adb
Fix windows builds
- Fixes build error for windows debug 32bit.
- Allows building windows release with PTY enabled.
- Updates godot-cpp.
2021-07-18 17:00:55 +07:00
Leroy Hopson
84243cd824
Enable compiling Pipe and LibuvUtils on Windows
Currently only works when building with debug target. On GitHub actions
target release results in linking errors. So disable PTY for release
builds.

Part of #25.
2021-07-18 15:09:21 +07:00
Leroy Hopson
88e5320a83
Update build script
- Add flags for target and disable_pty
- Only run docker-compose commands if docker-compose installed
2021-07-18 14:21:47 +07:00
Leroy Hopson
aa83b206a3
Update libuv 2021-07-18 11:05:56 +07:00
Leroy Hopson
97e07093b2
Change terminal menu option 'Select All' -> 'Copy All'
Adds copy_all() function to terminal node which returns all of the
screen's text.
2021-07-13 22:20:29 +07:00
Leroy Hopson
e8c27f2796
Add clear and sb_reset
Clearing the terminal removes all lines in the scrollback buffer except
for the most recent.

With sb_reset, the terminal will return the scrollback buffer to the
bottom when the user starts typing if they have previously scrolled up.
2021-07-13 06:33:44 +07:00
Leroy Hopson
e13bc7e082 Draw wide characters correctly
Draw the full background for wide characters as soon as they are
encountered. Don't draw any foreground or background if width is zero as
this means the previous character was wide.

Fixes #17
2021-07-12 22:46:43 +07:00
Leroy Hopson
5e25ebbab6 Add rudimentary terminal to editor's bottom panel
In order to use the gdnative library as an editor plugin it was
neccessary to set the `reloadable` property of the gdnlib file to false,
in order to prevent crashes when the godot editor window lost focus.

This may have consequences when recompiling the library.
See: https://docs.godotengine.org/en/3.3/classes/class_gdnativelibrary.html#class-gdnativelibrary-property-reloadable

Still crashes quite frequently and doesn't close child processes
properly.

Part of #43.
2021-07-11 23:03:33 +07:00
Leroy Hopson
f48e082b54 Reformat code causing clang-format clashes
VSCode and the clang-format git hook disagreed about how this one should
be formatted, so it kept changing.
2021-07-11 23:03:33 +07:00
Leroy Hopson
0e6334db96 Add copy selection support 2021-07-11 23:03:33 +07:00
Leroy Hopson
57c1c3524d Add basic pointer selection
Part of #4.
2021-07-11 23:03:33 +07:00
Leroy Hopson
fae28006cf Move scroll handling to GDScript
Just expose the underlying libtsm methods from gdnative, but write all
the logic in gdscript. Makes it much easier to customize and update.
2021-07-11 23:03:33 +07:00
Leroy Hopson
c95049c407
Update license information
- Renamed LICENSE -> LICENSE.md as it contains markdown, and added
  contact address.
- Adds THIRDPARTY_NOTICES.txt and THIRDPARTY_NOTICES_nopty.txt which
  bundles licenses of all third-party components for versions of
  GodotXterm compiled with and without PTY node support.
- Adds misc/gen_3rdparty_licenses.sh file to generate the above
  mentioned text files.
- Seperated node_pty and tmux licenses.
- Updated libuv submodule to use version that contains additional license
  information.
- Updated README to reflect these changes.
2021-07-07 21:39:54 +07:00
Leroy Hopson
5838b7fe7e
Add support for mouse scroll
Part of #4.
2021-07-07 21:36:24 +07:00
Leroy Hopson
44ea56aa0f
Add disable_pty compile option
If disable_pty=yes then the PTY node and dependencies (LibuvUtils, Pipe)
will be excluded. On platforms where the PTY node is not supported (e.g.
HTML5), this will always be equivalent to `disable_pty=yes`.
2021-07-07 21:32:26 +07:00
Leroy Hopson
09dc080a2e Add support for the bell "\a" character
Closes #39
2021-07-03 22:47:33 +07:00
Leroy Hopson
964af715d6 Enable Windows 32bit builds
Closes #24
2021-07-03 16:15:18 +07:00
Leroy Hopson
0dd2378387 Add new PTY node (replaces Pseudoterminal node)
Uses fork of node-pty native code for forking pseudoterminals.
Uses libuv pipe handle to communicate with the child process.

- Paves the way for cross-platform (Linux, macOS and Windows) support.
- Renames Pseudoterminal to PTY (which is much easier to type and spell :D).
- Better performance than the old Pseudoterminal node. Especially when
  streaming large amounts of data such as running the `yes` command.
- Allows setting custom file, args, initial window size, cwd, env vars
  (including important ones such as TERM and COLORTERM) and uid/gid
  on Linux and macOS.
- Returns process exit code and terminating signal.
2021-07-03 14:56:27 +07:00
Leroy Hopson
bfa561357e Yield for "frame_pre_draw" signal before writing to terminal
Fixes #41. But creates another issue where sometimes the yield will
resume after the terminal node has already been freed logging an error
to the console.

Also a few changes to where update is called it the gdnative terminal
code.

Also changed gdnative terminal to only accept strings.
2021-07-03 14:56:27 +07:00