Commit graph

74 commits

Author SHA1 Message Date
Leroy Hopson
4c4e61cf99 feat(term): make cursor hollow when un-focused
Closes #29.
2024-04-28 23:26:02 +12:00
Leroy Hopson
d6a4adf6aa
feat(terminal): and stylebox support
Adds support for 'normal' and 'focus' Style Boxes to Terminal node.
Changes default background color to transparent, with background to be
set by StyleBox.

If background color is not transparent, will draw a background color
rect to cover the entire control over the top of any stylebox. This is
consistent with the behavior of the TextEdit node with regards to theme
colors and styleboxes.
2024-04-28 18:09:21 +12:00
Leroy Hopson
e816396d60
feat(pty): add terminal_path property to pty
Property can be set to the NodePath of a Terminal node. Doing so will
conveniently set up the neccessary signals between Terminal and PTY for
them to function together.
2024-04-28 17:29:40 +12:00
Leroy Hopson
fa49834347
feat(theme): update themes 2024-04-28 17:29:40 +12:00
Leroy Hopson
dd118d72f3 feat(term): add select method
Adds select() method to Terminal. Method behaves the same way as
TextEdit's select method.
2024-04-28 17:22:26 +12:00
Leroy Hopson
43303a51bf fix(term): copy_selection() when nothing selected
Fixes the copy_selection() method so that it returns and empty string
when called and nothing is selected. Previously printed an error.
2024-04-28 17:22:26 +12:00
Leroy Hopson
3ca272c615
feat(test): add visual regression testing
Will upload screenshots on failure.
2024-04-07 00:45:49 +13:00
Leroy Hopson
898d49e392
fix(theme): fix regular font resource 2024-04-06 23:56:01 +13:00
Leroy Hopson
6c8be30e7f
fix(pty): initialize exit_code to 0
Uninitialized exit_code variable was causing tests to fail on x86_32
arch due to returning an arbitrary int where 0 was expected.
2024-04-01 10:12:16 +13:00
Leroy Hopson
ff95b60a56 feat(web): re-enable web exports 2024-03-30 22:52:39 +13:00
Leroy Hopson
fcad5d64b9
fix: use correct bits
Turns out the 32bit tests were actually using 64bit Godot and testing
the 64bit binaries.

This commit ensures that the tests use the correct builds and adds
32bit linux to the gdextension file.
2024-03-30 20:49:15 +13:00
Leroy Hopson
5cd298c124
chore(imports): automatic editor import updates 2024-03-30 01:36:15 +13:00
Leroy Hopson
0bd0d39f41
feat(pty): add cols/rows methods and resize tests 2024-03-29 01:27:42 +13:00
Leroy Hopson
d00a31fb45
feat(term): implement clear() method
Clears all but the bottommost row of the terminal (including scrollback
buffer) and moves the bottommost row to the top.
2024-03-03 22:39:51 +13:00
Leroy Hopson
71df1e71bd
feat(term): implement copy_all()
Implements the copy_all() method which copies all text in the screen
including text in the scrollback buffer.

Includes a fix to an upstream bug in libtsm that resulted in double the
number of '\n' characters being copied for each row.
2024-03-03 21:04:42 +13:00
Leroy Hopson
fa28b7d6c2
fix(term): remove selection mode enum from tests
The SelectionMode enum is only used internally, so it can be removed
from tests of the public interface.
2024-03-03 21:04:16 +13:00
Leroy Hopson
13cf5ba023
feat(term): implement copy_selection()
Implements the copy_selection() method, which returns the selected text.

Adds a copy_on_selection property. When this property is enabled, the
selected text will automatically be copied to the primary clipboard
(Linux X11/Wayland only).
2024-03-03 21:04:16 +13:00
Leroy Hopson
7f03761fb2
fix(pty): remove non-portable signal enums
Remove signal enum members which do not use portable numbers, and
therefore may be different on different operating systems.
2024-03-03 21:04:16 +13:00
Leroy Hopson
b78bdf3136
feat(pty): rename get_pts() -> get_pts_name() 2024-03-03 21:04:16 +13:00
Leroy Hopson
1a5f0f96da
chore(test): update tests
Adds additional tests for the interface. Creates a new base test class
GodotXtermTest that adds some additional assert methods. Tests
inheriting from this should override the got_described_class() method.
Add instance of the described class named 'subject' will be created and
added to the scene tree before each test.
2024-03-03 15:41:30 +13:00
Leroy Hopson
a0c9777264
feat(pty): add multithread support
Adds the option `use_threads` to PTY (enabled by default) which improves
performance when enabled. For example, running `time cat file.txt` where
file is ~4.5MB will take ~0.250s with threads enabled, versus >20s when
disabled.
2024-03-02 22:49:48 +13:00
Leroy Hopson
8cd11fdae6
fix(term): prevent double keyboard input
Disconnects the "gui_input" signal as the _gui_input() override is
working as expected now. Having this signal connected was causing it to
be called twice for every input.
2024-02-25 22:06:58 +13:00
Leroy Hopson
988788fc68
feat(term): implement data_sent signal 2024-02-25 21:14:03 +13:00
Leroy Hopson
43634affa3
chore(just): update test recipe
Updates the test recipe to use the os_family() function to determine
which test files to include.

Renames 'test_unix.gd' -> 'test_nix.gd'.
2024-02-25 20:51:29 +13:00
Leroy Hopson
05b19c1336
feat(term): implement "key_pressed" signal
Also adds tests for write response as code relating to this was
modified.
2024-02-25 20:25:32 +13:00
Leroy Hopson
c36500615d
feat(pty): further pty development 2024-02-25 17:55:31 +13:00
Leroy Hopson
1514f42b54
feat(pty): add initial pty node 2024-02-25 11:48:47 +13:00
Leroy Hopson
aa6b447c6c
Wait 5 more frames in rendering test
When using opengl3 rendering driver on macos, we need to wait a few more
frames in order for the test to pass.
2024-02-24 16:58:52 +13:00
Leroy Hopson
4771a3c9a7
Fix rendering according to test 2024-02-18 20:31:08 +13:00
Leroy Hopson
685884965e
Fix bell behaviour according to tests 2024-02-18 20:24:27 +13:00
Leroy Hopson
dc97c56b17
Use type Vector2i for get_cursor_pos()
Cursor position is always integer.
2024-02-18 14:06:30 +13:00
Leroy Hopson
db3564f0cc
Setup tests
- Install Gut using gd-plug.
- Add some basic tests.
- Update workflow to run tests.
- Add test and gd-plug install/uninstall recipes to Justfile.
- Re-enable debug builds as these are used by editor when testing.
2024-02-18 14:06:25 +13:00
Leroy Hopson
002e7aacc7
Auto-format files using new pre-commit config 2024-02-13 10:52:22 +13:00
Leroy Hopson
14db14679f
chore: add .import files 2024-02-06 23:56:06 +13:00
Leroy Hopson
cea41d6567
Update GUT to version 9.1.1 2024-01-06 23:33:15 +13:00
Leroy Hopson
893c768f75
Update gdtoolkit to version 4.2.2 2024-01-06 23:11:04 +13:00
Leroy Hopson
98b42733fb
Fix tests
Part of #66. Many tests still failing.
2023-01-21 15:36:03 +13:00
Leroy Hopson
15e5b2b8c7
Remove references to terminal.gd 2023-01-21 15:33:56 +13:00
Leroy Hopson
e563a15ce2
Format files using GDScript Toolkit 2023-01-21 15:33:25 +13:00
Leroy Hopson
4490296d4d
Update .import files 2022-12-28 11:43:36 +13:00
Daniel Inkpen
cdbf3f2adc Godot 4 automatic changes 2022-11-09 20:57:46 +00: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
b2f190d29a
Remove support for deprecated theme item names 2022-08-26 12:30:07 +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
344c04f9d8
Move terminal bell tests from unit -> integration
The bell tests rely on timers and yields, so are too slow to run as part
of the unit test suite.
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
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
Leroy Hopson
d558b07fd4 Prevent loss of focus on Tab/Arrow key press
Prevents Terminal losing focus when in a scene with other inputs and
the Tab or Arrow keys are pressed.

Fixes #51.
2022-08-05 10:55:24 +12:00