Commit graph

154 commits

Author SHA1 Message Date
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
Leroy Hopson
041e7a445f Request redraw after write if terminal visible
Requests a redraw after writing to terminal if it is visible, otherwise
terminal will not be updated if there are no other redraw requests.

Fixes #53.
2022-08-08 10:13:53 +12:00
Leroy Hopson
9896a362c3
Automatic editor updates
Automatic updates applied to scenes after opening in Godot editor
v3.4.4-stable.
2022-08-06 20:32:58 +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
Leroy Hopson
8a3adbbe68
Fix GitHub Actions godot-cpp-linux Docker build 2022-08-03 22:41:12 +12:00
Leroy Hopson
3b7bdfc5ca
Bump version to 2.1.0 2022-07-11 09:33:01 +12:00
Leroy Hopson
df32ee3c18
Refactor PTY
PTY now provides a public interface to an underlying instance of
PTYNative. The PTYNative class can be extended as appropriate for
each platform and the platform-specific implementation will be
selected by PTY at runtime.
2022-07-11 09:33:01 +12:00
Leroy Hopson
b76f8d0939
Prevent scrollback buffer reset when using copy shortcut
Prevents scrollback buffer reset (i.e. scrolling to the bottom of
terminal output) when pressing modifier keys in isolation or when
copying text using the shortcut Ctrl+Shift+C.
2022-07-11 09:33:01 +12:00
Leroy Hopson
cf613708c4
Fix resume after yield error
Fixes error that would sometimes occur when closing the Terminal after
calling write() but before the VisualServer had finished drawing the
current frame.
2022-07-11 09:33:01 +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
6ec3c93c55
Prevent editor shortcuts while terminal is focused 2022-07-11 09:33:00 +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
d124f20f36
Remove custom TerminalSettings Resource type
There is no current public use for this type and it would appear in every
resource dropdown.

While this type is no longer exposed publically by the plugin it is still
used internally by terminal_panel.
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
deb68e323c
Reformat existing gdscript code 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
99c3b1b452
Automatic editor updates v3.4.4-stable
- Add `.import` files automatically updated after opening project in new
  target version of the editor.
2022-05-31 18:34:51 +07:00
Leroy Hopson
2a9ecb524e
Bump version to 2.0.0
How it started...
```gdscript
extends TextEdit
```
How it's going...
```c++
```
2021-07-26 00:56:54 +07:00
Leroy Hopson
9d15420df3
Move terminal.gd and pty.gd to godot_xterm directory
Makes for pretty paths when extending scripts:
`extends "res://addons/godot_xterm/terminal.gd"`
vs.
`extends "res://addons/godot_xterm/nodes/terminal/terminal.gd"`

Currently "res://addons/godot_xterm/pty.gd" is acutally `pty_unix.gd`.
This is okay for now as the PTY node is only supported on Unix
platforms. However, we will need to sort it out when adding Windows
support as part of #25.

Also remove the GDXterm namespace.
2021-07-26 00:39:48 +07:00
Leroy Hopson
e6db81615e
Automatic .tscn file updates
Automatically changed by the editor.
2021-07-25 23:09:37 +07:00
Leroy Hopson
082ce8f199
Use only default settings for terminal panel
Until settings have been properly defined, documented and implemented.
2021-07-25 23:09:37 +07:00
Leroy Hopson
14dd045b66
Update PTY to match publically documented API
Remove unused variables and enums and make private what's not documented
as public.
2021-07-25 23:09:37 +07:00
Leroy Hopson
d75c26cec6
Update documentation
- Remove contributor license agreement:

  The terms are same as the standard "inbound=outbound" norm for open
  source projects which is covered by GitHub's terms of service
  which every GitHub user has already agreed to:
  https://docs.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license

- Add wiki as submodule and move documentation to it.

- Update README and replace screenshot with video
2021-07-25 23:08:45 +07:00
Leroy Hopson
1083c13276
Fallback to Regular Terminal font before using default 2021-07-24 17:37:04 +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
55b0a0577d
Update bell
- Don't add the bell to the archive to keep it small a simplify
  licensing. Also bells seem to be rarely used with terminal emulators.
- Don't play the bell directly from the Terminal node by adding an
  AudioStreamPlayer, but make it easy to tune the "bell" signal behavior
  from the Terminal node so that only an AudioStreamPlayer node's play()
  method needs to be connected to it.
- Keep the bell.wav sound around for testing/demo.
2021-07-23 08:37:49 +07:00
Leroy Hopson
d702021d02
Add only Hack Regular font and default themes to archive
Keeps the archive small and licensing simpler.
Keep around the fancy fonts such as Noto Color Emoji and Unifont as they
are useful for testing.
With the xrdb import plugin making it easy to import themes, there is
little point in keeping other pre-defined themes around, so remove
these.
2021-07-23 08:37:48 +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
7c3d5f76f3
Make compatible with Godot v3.2
But still only officially support v3.3+
2021-07-20 14:26:34 +07:00
Leroy Hopson
10983653c6
Fix macOS builds 2021-07-20 11:18:52 +07:00
Leroy Hopson
3e67cfd877
Add export ignored files to .gitattributes
Move THIRDPARTY_NOTICE files to addons/godot_xterm so they will be
included with asset-lib downloads.
2021-07-19 00:49:37 +07:00
Leroy Hopson
3e2162d366
Add basic .xrdb/.Xresources import plugin
Adds basic support for importing .Xresources and .xrdb files as Theme
resources.

Examples of terminal color schemes in .xrdb format can be found here:
https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/xrdb

Examples of terminal themes in .Xresources format can be found here:
https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/Xresources

https://terminal.sexy also supports exporting themes is Xresources
format.
2021-07-19 00:10:16 +07:00
Leroy Hopson
7b63079594
Change default theme
Replaces default.tres, default_dark.tres, and default_light.tres, with
default.tres and default_light.tres based on Godot's default dark and
light editor themes respectively.

Closes #44
2021-07-18 23:39:22 +07:00
Leroy Hopson
b08d218a59
Run tests in CI environment
Currently tests only run on X11.64 platform.
But other platforms can be supported with a bit of effort.
Remove default bell sound as it does not play nicely with CI environment
that does not have sound card.
2021-07-18 23:05:17 +07:00