**Note**: If you are looking for the purely gdscript version of this plugin which was based on Xterm.js, it turned out to be too buggy and slow so is no longer being developed or maintained but can still be found in the [gdscript-unmaintaned](https://github.com/lihop/godot-xterm/tree/gdscript-unmaintained) branch.
![Screenshot of Main Menu Scene](./docs/screenshot.png)
- An online demo of an HTML5 export of this repo (using the GDNative export type, available since Godot 3.3) can be found [here](https://demo.godot-xterm.nix.nz).
Make sure you click the screen at least once after loading.
- A Linux, MacOS, and Windows demo, which uses GodotXterm in conjunction with [Godot Python](https://github.com/touilleMan/godot-python) can be downloaded [here](https://lihop.itch.io/xterminate).
To install, copy (or symlink) the `addons/godot_xterm` directory in this repo to the `addons` directory of your Godot project. You will then need to setup the gdnative components, by either downloading the precompiled binaries or building from source.
**Note**: If you are running the demo project, it is recommended that you build or install the gdnative binaries before opening it, otherwise the Godot editor will disconnect some signals when it fails to find the gdnative nodes meaning that the project won't run correctly when they _are_ installed. If in doubt, use `git status` to see if any of the `.tscn` files have been changed automatically by the editor.
Precompiled binaries can be downloaded from the GitHub releases page. Download the `libgodot-xterm-release.zip` (or `libgodot-xterm-debug.zip`) file and extract it to the `addons/godot_xterm/native/bin` directory. This will install the gdnative libraries for all supported platforms.
This plugin follows the standard format of a GDNative plugin as shown in [GDNative C++ Example](https://docs.godotengine.org/en/stable/tutorials/plugins/gdnative/gdnative-cpp-example.html), including the use of the SCons build tool.
Therefore, referring to the following documentation on compiling a GDNative plugin and compiling the Godot engine itself may be useful:
- [GDNative C++ Example: Compiling the plugin](https://docs.godotengine.org/en/stable/tutorials/plugins/gdnative/gdnative-cpp-example.html#compiling-the-plugin).
- [Compiling for X11 (Linux, \*BSD)](https://docs.godotengine.org/en/stable/development/compiling/compiling_for_x11.html)
This plugin does not have any special dependencies beyond those used to compile Godot or the GDNative C++ example. If you can compile those then you should be able to compile this plugin. When in doubt, see the documentation above.
The [build.sh] script in `addons/godot_xterm/native` is provided for convenience and can be used on Linux to perform the steps below using the default scons options. On NixOS it will use the `shell.nix` file in the same directory to bring in all dependencies to the build environment.
This step only needs to be performed once per platform/target/bits combination your are targeting, and possibly more if you are targeting different versions of Godot. See [GDNative C++ Example: Building the C++ bindings](https://docs.godotengine.org/en/stable/tutorials/plugins/gdnative/gdnative-cpp-example.html#building-the-c-bindings) for more info.
```
# From the top-level directory of this git repo...
The same options should be used as in the previous step. If the options are omitted, scons will auto-detect the platform and architecture of the current machine and `target` will default to `debug`.
An incomplete helper class based on the [tput](https://invisible-island.net/ncurses/man/tput.1.html) utility.
Example: On the command line you can use `tput cup 5 5` to position the cursor at row 5 col 5.
In GDScript this utility can be used to similar effect by doing:
```gdscript
tput.cup(5, 5)
```
Other commands include `tput setaf` to set a foreground color, `tput setab` to set a background color, and many more.
But only a few of these have been implemented.
Its usage is demonstrated in the script for the [menu scene](examples/menu).
- ### Asciicast (.cast) file importer plugin
[Asciinema](https://asciinema.org) recordings saved with the `.cast` extension will be automatically imported as animations. They can then be added to AnimationPlayer which is a child of a Terminal node. Playing the animation will play the terminal session recording in the parent Terminal.
See the [asciicast scene](examples/asciicast) for an example.
## Examples
There are three example scenes included in this project which you can study to learn more.
[bell.wav](/examples/bell.wav) by InspectorJ (<www.jshaw.co.uk>), downloaded from [freesound.org](https://freesound.org/people/InspectorJ/sounds/484344/), released under [CC-BY-3.0](https://creativecommons.org/licenses/by/3.0/).