Commit graph

191 commits

Author SHA1 Message Date
Leroy Hopson
575c3875b6
Implement get_cursor_pos() 2024-02-07 23:14:52 +13:00
Leroy Hopson
8c30bec861
Add support for two different inverse modes
- Inverse mode invert (default) will invert the color in shader.
- Inverse mode swap will simply swap the foreground and background
  colors. This is the default behavior of libtsm and GodotXterm v3.
2024-02-07 23:03:11 +13:00
Leroy Hopson
930f3ef352
Expose blink_on_time and blink_off_time properties 2024-02-07 22:26:45 +13:00
Leroy Hopson
7de5e2a835
Restore terminal.gd for referencing 2024-02-07 22:03:41 +13:00
Leroy Hopson
8b320622f9
Use shader include for fore/background shaders
The two shaders use a lot of common logic for co-ordinate and attribute
look up, so it makes sense to use a common include shader for both.

Adds support for the inverse and blink attributes to the foreground shader.
2024-02-07 21:59:01 +13:00
Leroy Hopson
a849423096
Rewrite terminal.cpp
Rewrites the Terminal class as a GDExtension to be used directly in
Godot without a terminal.gd proxy.

Breaks a lot of things in its current state (e.g. signals and other
functions have not be implemented yet), but does add support for
transparent colors and true color inversion. It also seems to
be about 4x faster (FPS-wise) than the old version with some basic
stress testing.

Old source code has been moved to a different directory to be copied
over and/or rewritten piece by piece.
2024-02-07 00:14:33 +13:00
Leroy Hopson
7d2e22530e
Update libtsm 2024-02-06 23:56:21 +13:00
Leroy Hopson
f694544834
Remove unused code 2024-01-07 11:07:20 +13:00
Leroy Hopson
33ca5b3af7
Change build options
- Removes --disable-pty build option.
- Sets debug_symbols="yes" when build target is debug.
2024-01-07 11:06:26 +13:00
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
52a89827c9
Allow script loading when compiled with PTY_DISABLED 2024-01-06 23:16:52 +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
e563a15ce2
Format files using GDScript Toolkit 2023-01-21 15:33:25 +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
c115c34e6c
Fix some errors preventing running of the main scene 2023-01-14 22:36:25 +13:00
Leroy Hopson
8d56b5659a
Re-enable building of godot-cpp dependency 2023-01-14 22:35:30 +13:00
Leroy Hopson
a26320d9a5
Automatic editor updates
Automatic updates performed by the editor after opening files in Godot
v4.0-beta12.
2023-01-14 22:34:24 +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
aad8e39dae
Update themes 2023-01-08 21:36:42 +13:00
Leroy Hopson
44f7e3801c
Convert from GDNative to GDExtension
Work in progress.
2022-12-29 22:54:38 +13:00
Leroy Hopson
6b47d35835
Update import plugins 2022-12-28 11:52:19 +13:00
Leroy Hopson
4490296d4d
Update .import files 2022-12-28 11:43:36 +13:00
Daniel Inkpen
5c39a8071f Probably some progress 2022-11-09 22:29:11 +00:00
Daniel Inkpen
b1ec881c8c First open project in Godot 4 2022-11-09 21:58:07 +00:00
Daniel Inkpen
099100d3e0 Reverse most obvious mistakes from Godot 4 automatic changes 2022-11-09 21:52:54 +00:00
Daniel Inkpen
cdbf3f2adc Godot 4 automatic changes 2022-11-09 20:57:46 +00: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
cceffd4edf
Use load() rather than preload() for terminal icon
Allows the plugin to load even if resources have not been imported yet.
For example, if someone has opened a project with the plugin for the
first time. Otherwise, the plugin will fail to load and be disable in
the `project.godot` file.
2022-08-27 10:32:27 +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
94df3faa69
Automatic theme updates
Performed after opening and saving the files in the editor without
making any changes.
2022-08-26 16:53:07 +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
002fcf3b78
Remove deprecated cols/rows properties of Terminal 2022-08-26 14:50:24 +12:00
Leroy Hopson
8d656d8c71
Remove deprecated get_master() method of PTY 2022-08-26 12:35:54 +12:00
Leroy Hopson
b2f190d29a
Remove support for deprecated theme item names 2022-08-26 12:30:07 +12:00
Leroy Hopson
7e65be4cf9
Fix typo in deprecated color name 2022-08-26 12:23:39 +12:00
Leroy Hopson
4f24f2bd37
Bump version to 2.2.0 2022-08-26 10:02:09 +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
41525959e1
Deprecate undocumented get_master() method
This method was never officially documented and used only as a workaround for
issue #53. It also returns an instance of the undocumented and scruffily
implemented Pipe class that I would prefer to keep internal.

Now that #53 has been fixed, this method can be removed from the unofficial
public API, but deprecate it just in case. If someone was using it then it
is still possible (although not supported) to access the `_pipe` property of
`_pty_native`.
2022-08-22 10:05:41 +12:00
Leroy Hopson
6cd5facb98
Deprecate the cols and rows properties of Terminal
As cols and rows are read only (i.e. automatically determined by rect
and font size) there is no need for the properties to be exposed.
Instead, users can get the calculated cols and rows using the get_cols()
and get_rows() methods.
2022-08-22 10:05:36 +12:00
Leroy Hopson
f49410838c
Drop support for Godot 3.3.x 2022-08-22 10:02:50 +12:00
Leroy Hopson
6e9cd130a7
Bump version to 2.1.1 2022-08-15 17:12:36 +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
054c7c9ad4
Ensure initial PTY size matches Terminal (if any)
If a PTY has a terminal_path set to a valid Terminal, then ensure that
the initial cols and rows of PTY match the cols and rows of the Terminal
when calling fork() or open(), otherwise PTY will output wrong-sized
data for the Terminal until resized.

Fixes #56.
2022-08-15 17:09:25 +12:00