Add pre-commit config and auto-format files

This commit is contained in:
Leroy Hopson 2024-02-13 09:50:18 +13:00
parent af16cb8653
commit bd817eb0ce
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
22 changed files with 370 additions and 349 deletions

1
.gitattributes vendored
View file

@ -30,6 +30,7 @@
/.import export-ignore
/LICENSE.md export-ignore
/misc export-ignore
/.pre-commit-config.yaml export-ignore
/project.godot export-ignore
/README.md export-ignore
/requirements.txt export-ignore

View file

@ -1,4 +1,4 @@
name: 'Build and Test'
name: "Build and Test"
on:
push:
@ -14,13 +14,13 @@ env:
jobs:
build_docker:
name: 'Build Docker (linux, ${{ matrix.target }}, ${{ matrix.bits }})'
name: "Build Docker (linux, ${{ matrix.target }}, ${{ matrix.bits }})"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
target: [ release, debug ]
bits: [ 64, 32 ]
target: [release, debug]
bits: [64, 32]
steps:
- uses: actions/checkout@v3
with:
@ -59,14 +59,14 @@ jobs:
addons/godot_xterm/native/bin/*.so
build_native:
name: 'Build Native'
name: "Build Native"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
platform: [ javascript, osx, windows ]
target: [ release, debug ]
bits: [ 64, 32 ]
platform: [javascript, osx, windows]
target: [release, debug]
bits: [64, 32]
include:
- platform: javascript
os: ubuntu-22.04
@ -129,7 +129,7 @@ jobs:
if: steps.cache-submodules.outputs.cache-hit != 'true'
uses: jwlawson/actions-setup-cmake@v1
with:
cmake-version: '3.23.2'
cmake-version: "3.23.2"
use-32bit: ${{ matrix.bits == 32 && matrix.os == 'windows-2022' }}
- name: Build libuv
if: steps.cache-submodules.outputs.cache-hit != 'true'
@ -171,70 +171,70 @@ jobs:
addons/godot_xterm/native/bin/*.dll
html5_export:
name: 'HTML5 Export'
needs: [ build_docker, build_native ]
name: "HTML5 Export"
needs: [build_docker, build_native]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup Godot
uses: lihop/setup-godot@v2
with:
export-templates: true
- name: Install binary build artifacts
uses: actions/download-artifact@v3
with:
name: libgodot-xterm-release
path: addons/godot_xterm/native/bin
- name: Import assets
uses: nick-fields/retry@v2
with:
command: godot --editor .github/import_assets.tscn
retry_on: error
timeout_minutes: 5
max_attempts: 6
- name: Export HTML5
uses: nick-fields/retry@v2
with:
command: godot --no-window --export HTML5
retry_on: error
timeout_minutes: 5
max_attempts: 6
- name: NPM cache
uses: actions/setup-node@v3
with:
cache: 'npm'
cache-dependency-path: test/html5/package-lock.json
- name: Smoke test HTML5 export
shell: bash
working-directory: test/html5
run: |
npm ci
npx serve ../../docs/demo -p 3000 &
npx cypress run
- name: Upload cypress artifacts (on failure)
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: cypress-artifacts
path: |-
test/html5/cypress/screenshots
test/html5/cypress/videos
- name: Upload export
uses: actions/upload-artifact@v3
with:
name: html5-demo
path: docs/demo
- uses: actions/checkout@v3
- name: Setup Godot
uses: lihop/setup-godot@v2
with:
export-templates: true
- name: Install binary build artifacts
uses: actions/download-artifact@v3
with:
name: libgodot-xterm-release
path: addons/godot_xterm/native/bin
- name: Import assets
uses: nick-fields/retry@v2
with:
command: godot --editor .github/import_assets.tscn
retry_on: error
timeout_minutes: 5
max_attempts: 6
- name: Export HTML5
uses: nick-fields/retry@v2
with:
command: godot --no-window --export HTML5
retry_on: error
timeout_minutes: 5
max_attempts: 6
- name: NPM cache
uses: actions/setup-node@v3
with:
cache: "npm"
cache-dependency-path: test/html5/package-lock.json
- name: Smoke test HTML5 export
shell: bash
working-directory: test/html5
run: |
npm ci
npx serve ../../docs/demo -p 3000 &
npx cypress run
- name: Upload cypress artifacts (on failure)
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: cypress-artifacts
path: |-
test/html5/cypress/screenshots
test/html5/cypress/videos
- name: Upload export
uses: actions/upload-artifact@v3
with:
name: html5-demo
path: docs/demo
test:
name: 'Test'
needs: [ build_docker, build_native ]
name: "Test"
needs: [build_docker, build_native]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-2022, macos-12, ubuntu-22.04 ]
bits: [ 64, 32 ]
godot_version: [ 'v3.4.5-stable', 'v3.5-stable' ]
os: [windows-2022, macos-12, ubuntu-22.04]
bits: [64, 32]
godot_version: ["v3.4.5-stable", "v3.5-stable"]
exclude:
- os: macos-12
bits: 32
@ -267,51 +267,50 @@ jobs:
timeout_minutes: 5
max_attempts: 6
# Git archive should only include addons/godot_xterm directory.
check-archive:
name: 'Check Archive'
name: "Check Archive"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Create git archive
run: git archive -o archive.zip HEAD
- name: Extract archive
run: mkdir -p /tmp/unzipped && unzip archive.zip -d /tmp/unzipped
- name: Check that archive only contains addons directory
run: |
shopt -s nullglob dotglob
ls -lR /tmp/unzipped
files=(/tmp/unzipped/*)
if [ ${#files[@]} -ne 1 ]; then
echo "Wrong number of files in archive (${#files[@]}) expected 1."
exit 1
fi
if [ ! -d "/tmp/unzipped/addons" ]; then
echo "Expected directory (addons) not found."
exit 1
fi
files=(/tmp/unzipped/addons)
if [ ${#files[@]} -ne 1 ]; then
echo "Wrong number of files in addons directory (${#files[@]}) expected 1."
exit 1
fi
if [ ! -d "/tmp/unzipped/addons/godot_xterm" ]; then
echo "Expected directory (addons/godot_xterm) not found."
exit 1
fi
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Create git archive
run: git archive -o archive.zip HEAD
- name: Extract archive
run: mkdir -p /tmp/unzipped && unzip archive.zip -d /tmp/unzipped
- name: Check that archive only contains addons directory
run: |
shopt -s nullglob dotglob
ls -lR /tmp/unzipped
files=(/tmp/unzipped/*)
if [ ${#files[@]} -ne 1 ]; then
echo "Wrong number of files in archive (${#files[@]}) expected 1."
exit 1
fi
if [ ! -d "/tmp/unzipped/addons" ]; then
echo "Expected directory (addons) not found."
exit 1
fi
files=(/tmp/unzipped/addons)
if [ ${#files[@]} -ne 1 ]; then
echo "Wrong number of files in addons directory (${#files[@]}) expected 1."
exit 1
fi
if [ ! -d "/tmp/unzipped/addons/godot_xterm" ]; then
echo "Expected directory (addons/godot_xterm) not found."
exit 1
fi
check-code-format:
name: 'Check Code Format'
name: "Check Code Format"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: GDFormat Check
run: |
python -m pip install -r requirements.txt
gdformat -c .
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: GDFormat Check
run: |
python -m pip install -r requirements.txt
gdformat -c .

15
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: none
# SPDX-License-Identifier: CC0-1.0
ci:
autofix_commit_msg: "fix: auto fixes"
autoupdate_commit_msg: "chore: autoupdate"
exclude: "^addons/gut/"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier

View file

@ -1,27 +1,32 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased](https://github.com/lihop/godot-xterm/compare/v2.2.0...HEAD)
### Changed
- Custom export templates are no longer required when exporting to HTML5 from Godot v3.5.x.
### Removed
- Removed support for deprecated theme item names.
- Removed deprecated get_master() method of PTY.
- Removed deprecated cols/rows properties of Terminal.
## [v2.2.0](https://github.com/lihop/godot-xterm/compare/v2.1.1...v2.2.0) - 2022-08-26
### Changed
- Changed theme item names to be compatible with Godot version 3.5 (no spaces),
consistent with other theme item names (snake_case), and to match the ANSI
color names listed on the [ANSI escape code Wikipedia page](https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit).
### Deprecated
- Deprecated the `cols` and `rows` properties of Terminal.
These properties will be removed in a future version.
Please use `get_cols()` and `get_rows()` instead.
@ -58,21 +63,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Bold Italic` -> `bold_italic`
### Removed
- Removed support for Godot version 3.3.x. GodotXterm *might* still work with this
- Removed support for Godot version 3.3.x. GodotXterm _might_ still work with this
version of Godot if compiled with the correct version of godot-cpp, but compatibility
is no longer officially supported.
### Fixed
- [#57][i57]: Screen is no longer erased on resize when using a custom theme.
- [#58][i58]: Screen is no longer erased when changing themes.
[i57]: https://github.com/lihop/godot-xterm/issues/57
[i58]: https://github.com/lihop/godot-xterm/issues/58
## [v2.1.1](https://github.com/lihop/godot-xterm/compare/v2.1.0...v2.1.1) - 2022-08-15
### Fixed
Thanks to [@ConteZero](https://github.com/contezero) for reporting and providing feedback on these issues:
- [#51][i51]: Fixed issue where terminal would lose focus on Tab/Arrow key presses
when in a scene with other input nodes.
- [#53][i53]: Fixed issue where terminal was not updating when there was no GUI
@ -85,14 +94,16 @@ Thanks to [@ConteZero](https://github.com/contezero) for reporting and providing
[i55]: https://github.com/lihop/godot-xterm/issues/55
[i56]: https://github.com/lihop/godot-xterm/issues/56
## [v2.1.0](https://github.com/lihop/godot-xterm/compare/v2.0.0...v2.1.0) - 2022-07-11
### Added
- Support for macOS universal (x86_64/arm64) binaries. The macOS binary
`libgodot-xterm.osx.64.dylib` is now a universal binary that runs natively
on both x86_64 and arm64.
### Changed
- Linux binaries now support systems with older GLIBC versions. By building the
binaries inside a docker container with an older GLIBC version, the minimum
required GLIBC version is now 2.17 which was released in 2012.
@ -105,11 +116,13 @@ Thanks to [@ConteZero](https://github.com/contezero) for reporting and providing
pressing modifier keys in isolation or when copying text using the shortcut Ctrl+Shift+C.
### Removed
- Removed custom TerminalSettings Resource type.
This Resource was not being used but would still appear in every resource dropdown.
(Related issue [godotengine/godot#24643](https://github.com/godotengine/godot/issues/24643)).
### Fixed
- The `kill()` method of unix PTY node can now be called without error as the underlying
`pipe.close()` method of the gdnative library is now registered.
- Fixed 'Condition "!obj" is true.' error that would often print to console when
@ -120,9 +133,10 @@ Thanks to [@ConteZero](https://github.com/contezero) for reporting and providing
sometimes occur when closing a Terminal after calling `write()` but before VisualServer
had finished drawing the current frame.
## [v2.0.0](https://github.com/lihop/godot-xterm/compare/v1.2.1...v2.0.0) - 2021-07-25
### Added
- Terminal editor plugin. Adds integrated terminal to Godot editor.
- Xresources import plugin.
- [#39][i39]: Support for the bell "\u0007" character.
@ -130,6 +144,7 @@ Thanks to [@ConteZero](https://github.com/contezero) for reporting and providing
- [#24][i24]: Support for Windows 32-bit (Terminal node only).
### Changed
- [#44][i44]: Default theme to match Godot's default theme.
- Supported Godot version -> 3.3.2.
- Set a default theme if no theme property has been set.
@ -137,6 +152,7 @@ Thanks to [@ConteZero](https://github.com/contezero) for reporting and providing
- TPut no longer registered as a unique global class (i.e. removed `class_name TPut`).
### Fixed
- [#40][i40]: Vim related bugs, caused by incorrectly handled control sequences.
- Don't swap red and blue channels of theme colors.
- Use "Light Cyan" color from theme. Previously ignored.
@ -146,37 +162,44 @@ Thanks to [@ConteZero](https://github.com/contezero) for reporting and providing
[i40]: https://github.com/lihop/godot-xterm/issues/40
[i44]: https://github.com/lihop/godot-xterm/issues/44
## [v1.2.1](https://github.com/lihop/godot-xterm/compare/v1.2.0...v1.2.1) - 2020-11-23
### Changed
- GitHub Actions workflow now produces both a release and debug zip archive.
### Fixed
- Release binary for Windows 64-bit export.
## [v1.2.0](https://github.com/lihop/godot-xterm/compare/v1.0.0...v1.2.0) - 2020-11-21
### Added
- Support for macOS 64-bit including Pseudoterminal.
- Partial support for Windows 64-bit and compiling on Windows using MSVC. Pseudoterminal not yet supported. 32-bit builds might be possible but not yet built/tested.
### Changed
- Updated build script. On Linux `./build.sh` will create a debug build of the gdnative library for the current platform.
- Removed all pre-compiled binaries using BFG [Repo-Cleaner](https://rtyley.github.io/bfg-repo-cleaner/), thus re-writing git history.
### Fixed
- Fixed bug where incorrect data would sometimes be written to the terminal when passing a string to the Terminal's `write()` method.
- Positioned background rect at 0,0 so it is no longer offset if a margin is added when Terminal is a child of a Container node.
- Passed correct argv to the execvp call of Pseudoterminal. Previously argv[0] was not set to the program's name which caused the Pseudoterminal node not to work on macOS with the zsh shell.
## [v1.0.0](https://github.com/lihop/godot-xterm/releases/tag/v1.0.0) - 2020-10-05
### Added
- Changelog.
- Asciicast importer plugin. Enables the import of .cast ([asciicast files v2](https://github.com/asciinema/asciinema/blob/master/doc/asciicast-v2.md)) that can be made using the [asciinema](https://asciinema.org/) terminal session recorder. See the [asciicast scene](/examples/asciicast) for example usage.
- Pre-built binary for x11 platform.
### Changed
- Implementation of Terminal node from GDScript to GDNative using [Aetf's patched version of libtsm](https://github.com/Aetf/libtsm).
- Move input handling to the Terminal node itself, rather than handling it in a seperate Control node.
- The Terminal `write()` method now accepts both String and PoolByteArray.

View file

@ -1,6 +1,7 @@
<img align="left" width="64" height="64" src="./media/icon.png">
# GodotXterm - Terminal Emulator
<br/>
[![Godot Version](https://img.shields.io/badge/Godot-3.4.x-blue.svg)](#supported-godot-versions)
@ -25,6 +26,7 @@ https://user-images.githubusercontent.com/3696783/126894061-a69eb6ad-9979-4723-a
[![View it on GitHub](./media/view_it_on_github_button.png)](https://github.com/lihop/godot-xterm)
#### Table of Contents
1. [Features](#features)
2. [Screenshots](#screenshots)
3. [Demos and Examples](#demos-and-examples)
@ -36,13 +38,15 @@ https://user-images.githubusercontent.com/3696783/126894061-a69eb6ad-9979-4723-a
## Features
- ### [Terminal](https://lihop.github.io/godot-xterm/api/terminal)
A Terminal emulator Control node.
Supports ANSI and (some) XTerm Control Sequences which can be used to do things such as clear the screen, move the cursor, change printed text color, ring a bell, and so on.
For an exhaustive list of terminal control sequences (not all of which are supported by GodotXterm) see ["XTerm Control Sequences"](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html).
- ### [PTY](https://lihop.github.io/godot-xterm/api/pty)
*Linux and macOS only.*
_Linux and macOS only._
Node for forking processes (e.g. bash, nodejs, python) with pseudoterminal file descriptors.
Can be used with the Terminal node to get an actual shell.
@ -51,12 +55,14 @@ https://user-images.githubusercontent.com/3696783/126894061-a69eb6ad-9979-4723-a
See issue [\#25](https://github.com/lihop/godot-xterm/issues/25).
- ### Terminal Editor Plugin
*Linux and macOS only.*
_Linux and macOS only._
Adds a panel to the Editor's bottom panel that can be used to spawn terminals in the editor.
Similar to VSCode's integrated terminal and IntelliJ's embedded terminal.
- ### Asciicast Import Plugin
Adds support for importing asciinema v2 `.cast` files as animations that can be played by an AnimationPlayer that is a child of a Terminal node.
Example `.cast` files can be downloaded from the [asciinema website](https://asciinema.org).
@ -67,10 +73,10 @@ https://user-images.githubusercontent.com/3696783/126894061-a69eb6ad-9979-4723-a
## Screenshots
| | |
|--------------------------------------|--------------------------------------|
|![](./media/screenshot_editor.png) |![](./media/screenshot_the_guest.png) |
|![](./media/screenshot_retro_term.jpg)|![](./media/screenshot_xterminate.png)|
| | |
| -------------------------------------- | -------------------------------------- |
| ![](./media/screenshot_editor.png) | ![](./media/screenshot_the_guest.png) |
| ![](./media/screenshot_retro_term.jpg) | ![](./media/screenshot_xterminate.png) |
## Demos and Examples
@ -93,7 +99,7 @@ Are you using GodotXterm in your project and want it listed here? Please [open a
GodotXterm aims to support the current stable release of Godot, but may lag slightly.
Currently, Godot versions 3.5.x and 3.4.x are supported, but custom export templates
are required for HTML5 exports from versions < 3.5.
Versions 3.3.x are no longer officially supported but *may* work if the GDNative libraries are
Versions 3.3.x are no longer officially supported but _may_ work if the GDNative libraries are
compiled using an older version of godot-cpp.
## Installation
@ -122,10 +128,9 @@ The GDNative source code incorporates code snippets and source code from many th
- The Hack regular font is bundled with GodotXterm as the default Terminal font. This is also the default monospace font of the Godot editor. See the [full license](https://github.com/lihop/godot-xterm/blob/stable/addons/godot_xterm/themes/fonts/hack/LICENSE.md).
### Nonbundled Resources
The following resources are not bundled with GodotXterm (i.e. are not included in the `addons/godot_xterm` directory) but are included in this repository for demo and testing purposes. They are:
The following resources are not bundled with GodotXterm (i.e. are not included in the `addons/godot_xterm` directory) but are included in this repository for demo and testing purposes. They are:
#### Sounds
@ -133,7 +138,7 @@ The following resources are not bundled with GodotXterm (i.e. are not included i
#### Fonts
- The **bold**, *italic*, and ***bold italic*** styles of the Hack font which are covered by the same license as above.
- The **bold**, _italic_, and **_bold italic_** styles of the Hack font which are covered by the same license as above.
- Nerd Fonts. Combines symbols from a multitude of other fonts. See [license information](https://github.com/lihop/godot-xterm/blob/stable/themes/fonts/nerd_fonts/README.md).
- Noto Color Emoji. Released under the [SIL Open Font License](https://github.com/lihop/godot-xterm/blob/stable/themes/fonts/noto_color_emoji/LICENSE_OFL.txt).
- Unifont. Dual-licensed (since version 13.0.04) under the GNU GPL 2+ with the GNU font embedding exception and the SIL Open Font License (OFL) version 1.1. This project uses it under the terms of the [SIL Open Font License](https://github.com/lihop/godot-xterm/blob/stable/themes/fonts/unifont/LICENSE_OFL-1.1.txt).

View file

@ -1 +1,3 @@
#video-preview { display: none; }
#video-preview {
display: none;
}

View file

@ -10,7 +10,7 @@ permalink: /api/pty
**Inherits:** [Node] < [Object]
*Linux and macOS only.*
_Linux and macOS only._
Node for forking processes (e.g. bash, nodejs, python) with pseudoterminal file descriptors.
Can be used with the [Terminal] node to get an actual shell.
@ -18,36 +18,32 @@ Can be used with the [Terminal] node to get an actual shell.
Not currently supported on Windows, but it could be in the future using [ConPTY](https://docs.microsoft.com/en-us/windows/console) or [WinPTY](https://github.com/rprichard/winpty).
See issue [\#25](https://github.com/lihop/godot-xterm/issues/25).
## Overview
![PTY Diagram](../media/pty_diagram.png)
<sub>"PTY Diagram" is a derivative of [Termios-script-diagram.svg](https://commons.wikimedia.org/wiki/File:Termios-script-diagram.svg) by [Krishnavedala](https://en.wikipedia.org/wiki/User:Krishnavedala?rdfrom=commons:User:Krishnavedala), used under [CC0](https://creativecommons.org/share-your-work/public-domain/cc0/).
## Properties
| Type | Name | Default |
|--------------|--------------------------------------|--------------------------------------------------------|
| ------------ | ------------------------------------ | ------------------------------------------------------ |
| [NodePath] | [terminal_path](#prop-terminal_path) | None |
| [int] | [cols](#prop-cols) | `80` |
| [int] | [rows](#prop-rows) | `24` |
| [Dictionary] | [env](#prop-env) | `{ COLORTERM = "truecolor", TERM = "xterm-256color" }` |
| [bool] | [use_os_env](#prop-use_os_env) | `true` |
## Methods
| Returns | Signature |
|---------|-------------------------------------------------------------------------------------------------------------------------------------|
| ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| [Error] | [fork](#mthd-fork) **(** [String] file=`$SHELL`, [PoolStringArray] args=[], [String] cwd=`$PWD`, [int] cols=80, [int] rows=24 **)** |
| void | [kill](#mthd-kill) **(** [int] signum **)** |
| [Error] | [open](#mthd-open) **(** [int] cols=80, [int] rows=24 **)** |
| void | [resize](#mthd-resize) **(** [int] cols, [int] rows **)** |
| void | [resize](#mthd-resize) **(** [int] cols, [int] rows **)** |
| void | [resizev](#mthd-resizev) **(** [Vector2] size **)** |
| void | [write](#mthd-write) **(** [String]\|[PoolByteArray] data **)** |
## Signals
- <a name="sgnl-data_received" /> **data_received** **(** [PoolByteArray] data **)**
@ -77,28 +73,27 @@ See issue [\#25](https://github.com/lihop/godot-xterm/issues/25).
- **SIGALRM** = 14 --- Alarm clock.
- **SIGTERM** = 15 --- Termination signal.
## Property Descriptions
### <a name="prop-terminal_path" /> [NodePath] **terminal_path**
| | |
|-----------|--------------------------|
| *Default* | None |
| *Setter* | set_terminal_path(value) |
| *Getter* | None |
| | |
| --------- | ------------------------ |
| _Default_ | None |
| _Setter_ | set_terminal_path(value) |
| _Getter_ | None |
[NodePath] to a [Terminal]. Setting this path will automatically connect the appropriate signals of both nodes for standard operation. It will also disconnected the signals of the previously set terminal, if any.
[NodePath] to a [Terminal]. Setting this path will automatically connect the appropriate signals of both nodes for standard operation. It will also disconnected the signals of the previously set terminal, if any.
---
- <a name="prop-cols" /> [int] **cols**
| | |
|-----------|--------------------------|
| *Default* | `80` |
| *Setter* | set_cols(value) |
| *Getter* | None |
| | |
| --------- | --------------- |
| _Default_ | `80` |
| _Setter_ | set_cols(value) |
| _Getter_ | None |
The column size in characters.
@ -106,11 +101,11 @@ See issue [\#25](https://github.com/lihop/godot-xterm/issues/25).
- <a name="prop-rows" /> [int] **rows**
| | |
|-----------|--------------------------|
| *Default* | `24` |
| *Setter* | set_rows(value) |
| *Getter* | None |
| | |
| --------- | --------------- |
| _Default_ | `24` |
| _Setter_ | set_rows(value) |
| _Getter_ | None |
The row size in characters.
@ -119,10 +114,10 @@ See issue [\#25](https://github.com/lihop/godot-xterm/issues/25).
- <a name="prop-env" /> [Dictionary] **env**
| | |
|-----------|--------------------------------------------------------|
| *Default* | `{ COLORTERM = "truecolor", TERM = "xterm-256color" }` |
| *Setter* | None |
| *Getter* | None |
| --------- | ------------------------------------------------------ |
| _Default_ | `{ COLORTERM = "truecolor", TERM = "xterm-256color" }` |
| _Setter_ | None |
| _Getter_ | None |
Environment variables to be set for the child program.
@ -131,14 +126,13 @@ See issue [\#25](https://github.com/lihop/godot-xterm/issues/25).
- <a name="prop-use_os_env" /> [bool] **use_os_env**
| | |
|-----------|--------|
| *Default* | `true` |
| *Setter* | None |
| *Getter* | None |
| --------- | ------ |
| _Default_ | `true` |
| _Setter_ | None |
| _Getter_ | None |
If `true` the environment variables from `env` will be merged with the environment variables of the current program (i.e. Godot), with the variables from `env` taking precedence over the environment variables of the current program.
## Method Descriptions
- <a name="mthd-fork" /> [Error] **fork** **(** [String] file=`$SHELL`, [PoolStringArray] args=[], [String] cwd=`$PWD`, [int] cols=80, [int] rows=24 **)**
@ -184,7 +178,6 @@ See issue [\#25](https://github.com/lihop/godot-xterm/issues/25).
Writes data to the pseudoterminal master device.
[Dictionary]: https://docs.godotengine.org/en/stable/classes/class_dictionary.html
[Error]: https://docs.godotengine.org/en/stable/classes/class_%40globalscope.html#enum-globalscope-error
[Node]: https://docs.godotengine.org/en/stable/classes/class_node.html

View file

@ -15,8 +15,8 @@ A Terminal emulator Control node.
Supports ANSI and (some) XTerm Control Sequences which can be used to do things such as clear the screen, move the cursor, change printed text color, ring a bell, and so on.
For an exhaustive list of terminal control sequences (not all of which are supported by GodotXterm) see ["XTerm Control Sequences"](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html).
## Overview
![Terminal Flow Diagram](../media/flow_diagram.svg)
<sub>"Terminal Flow Diagram" is a derivative of ["computer keyboard 2"](https://openclipart.org/detail/2396/computer-keyboard-2) and ["monitor"](https://openclipart.org/detail/1637/monitor), from U.S. patent drawings, uploaded by [johnny_automatic](https://openclipart.org/artist/johnny_automatic), used under [CC0](https://creativecommons.org/share-your-work/public-domain/cc0/).<sub/>
@ -40,20 +40,18 @@ In the other direction, data can be sent to the terminal. This corresponds to th
The input from (3) is then interpreted by the terminal state machine and drawn to the screen.
For example if the string `"\u001b[38;2;0;255;0;mA"` was written to the terminal, then it would draw a green colored capital letter 'A' on the screen.
## Properties
| Type | Name | Default |
|--------------|--------------------------------------|---------|
| ------------ | ------------------------------------ | ------- |
| [bool] | [bell_muted](#prop-bell_muted) | `false` |
| [float] | [bell_cooldown](#prop-bell_cooldown) | `0.1` |
| [UpdateMode] | [update_mode](#prop-update_mode) | `AUTO` |
## Methods
| Returns | Signature |
|----------|-------------------------------------------------------------------|
| -------- | ----------------------------------------------------------------- |
| void | [clear](#mthd-clear) **()** |
| [String] | [copy_all](#mthd-copy_all) **()** |
| [String] | [copy_selection](#mthd-copy_selection) **()** |
@ -61,7 +59,6 @@ For example if the string `"\u001b[38;2;0;255;0;mA"` was written to the terminal
| [int] | [get_rows](#mthd-get_rows) **()** |
| void | [write](#mthd-write) **(** [String] \| [PoolByteArray] data **)** |
## Signals
- <a name="sgnl-bell" /> **bell** **()**
@ -92,27 +89,24 @@ For example if the string `"\u001b[38;2;0;255;0;mA"` was written to the terminal
`new_size.x` will be the number of columns and `new_size.y` will be the number of rows.
This information should be forwarded to a pseudoterminal, if it is connected, so that it can update its size accordingly.
## Enumerations
<a name="enum-update_mode" /> enum **UpdateMode**:
- **DISABLED** = **0** --- The terminal's `update()` method will never be called. No new cells will be drawn.
- **AUTO** = **1** --- Only changed cells will be drawn after `update()` is called, but will switch to **ALL_NEXT_FRAME** when mass redraws are required.
- **ALL** = **2** --- Every cell will be drawn on every `update()` call.
- **DISABLED** = **0** --- The terminal's `update()` method will never be called. No new cells will be drawn.
- **AUTO** = **1** --- Only changed cells will be drawn after `update()` is called, but will switch to **ALL_NEXT_FRAME** when mass redraws are required.
- **ALL** = **2** --- Every cell will be drawn on every `update()` call.
- **ALL_NEXT_FRAME** = **3** --- Draws every cell afetr the next `update()` call, then returns to **AUTO**.
## Property Descriptions
- <a name="prop-bell_muted" /> [bool] **bell_muted**
| | |
|-----------|---------|
| *Default* | `false` |
| *Setter* | None |
| *Getter* | None |
| --------- | ------- |
| _Default_ | `false` |
| _Setter_ | None |
| _Getter_ | None |
If muted, no [`bell`](#sgnl-bell) signal will be emitted when the bell character (`"\u0007"`) is written to the terminal.
@ -121,10 +115,10 @@ For example if the string `"\u001b[38;2;0;255;0;mA"` was written to the terminal
- <a name="prop-bell_cooldown" /> [float] **bell_cooldown**
| | |
|-----------|-------|
| *Default* | `0.1` |
| *Setter* | None |
| *Getter* | None |
| --------- | ----- |
| _Default_ | `0.1` |
| _Setter_ | None |
| _Getter_ | None |
The minimum amount of time to wait before emitting another [`bell`](#sgnl-bell) signal on subsequent writes of the bell character.
Writing the bell character too frequently, for example by running the command `while true; do echo -e "\a"; done`,
@ -136,17 +130,16 @@ For example if the string `"\u001b[38;2;0;255;0;mA"` was written to the terminal
- <a name="prop-update_mode" /> [UpdateMode] **update_mode**
| | |
|-----------|------------------------|
| *Default* | `AUTO` |
| *Setter* | set_update_mode(value) |
| *Getter* | None |
| --------- | ---------------------- |
| _Default_ | `AUTO` |
| _Setter_ | set_update_mode(value) |
| _Getter_ | None |
Determines which cells of the terminal will be updated when its state changes.
By default `AUTO` will only update cells that changed, but will update all cells (i.e. the entire screen) on major changes,
such as terminal resize.
If you are having trouble with the terminal not updating correctly or exhibiting artifacts, you can try remedying this by setting `update_mode` to `ALL`, however, this will have a negative impact on performance.
## Method Descriptions
- <a name="mthd-clear" /> void **clear** **()**
@ -190,6 +183,7 @@ For example if the string `"\u001b[38;2;0;255;0;mA"` was written to the terminal
Typically it would be connected to the output of a [PTY]'s [`data_received()`](/api/pty#sgnl-data_received) signal.
Example:
```gdscript
$Terminal.write("Hello World")
$Terminal.write("Hello World".to_utf8())

View file

@ -27,10 +27,12 @@ This plugin follows the same format as the [GDNative C++ Example](https://docs.g
## The Easy Way
Run the build script in `addons/godot-xterm/native`:
```
cd addons/godot_xterm/native
./build.sh
```
On Windows you can use `git-bash` to run this script.
Provided the dependencies above are installed then it should "just work™".

View file

@ -7,6 +7,7 @@ permalink: /setup/precompiled-binaries
---
# Precompiled Binaries
{: .no_toc }
Installing GodotXterm using precompiled binaries means that you wont be required
@ -15,7 +16,7 @@ of copying files to the correct location in your project. These files can be
installed from several sources:
1. TOC
{:toc}
{:toc}
**Note:** precompiled binaries will only work with certain versions of Godot
(usually the current stable release). If you need binaries for a different or
@ -23,26 +24,33 @@ custom Godot version, or want to make modifications to the C/C++ code, please
refer to the section on [Building From Source](/setup/building-from-source).
## Godot Asset Library
GodotXterm can be installed from the [Godot Asset Library](https://godotengine.org/asset-library/asset/1007).
See the [Godot Asset Library documentation](https://docs.godotengine.org/en/stable/community/asset_library/using_assetlib.html) for more info on how to use it.
## Gd-plug Plugin Manager
If you are using the gd-plug plugin manager you can add the following line to your `plug.gd` file:
```
plug("lihop/godot-xterm-dist", {commit = "a1131a562e8e8f0c57b0ddf61de7fa015d463ba0", include = ["addons/godot_xterm"]})
```
Replace the commit hash with the hash of the GodotXterm version you wish to install.
See [tags](https://github.com/lihop/godot-xterm-dist/tags) for a list of versions and their corresponding commit hashes.
See the [gd-plug documentation](https://github.com/imjp94/gd-plug/blob/master/README.md) for more info on how to use it.
## Manual Installation
Alternatively, GodotXterm can be installed manually in two steps:
1. Copy the [`addons/godot_xterm`](https://github.com/lihop/godot-xterm/tree/stable/addons/godot_xterm) directory to the `addons` directory of your Godot project.
2. Copy the GDNative binaries into `addons/godot_xterm/native/bin` directory.
The easiest way to obtain the GDNative binaries is to download them from [the Releases page](https://github.com/lihop/godot-xterm/releases).
Download the zip archive named `libgodot-xterm-release.zip` and extract its contents into the `/addons/godot_xterm/native/bin` directory of your project.
After this your `addons/godot_xterm/native/bin` directory should contain the following files:
- `libgodot-xterm.javascript.32.wasm`
- `libgodot-xterm.linux.32.so`
- `libgodot-xterm.linux.64.so`

View file

@ -1,88 +1,80 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Main (gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/run/current-system/sw/bin/godot",
"args": ["${workspaceFolder}/examples/menu/menu.tscn"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"name": "Main (gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/run/current-system/sw/bin/godot",
"args": [
"${workspaceFolder}/examples/menu/menu.tscn",
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true,
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true,
},
],
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
},
{
"name": "Editor (gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/run/current-system/sw/bin/godot",
"args": ["--editor"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"name": "Editor (gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/run/current-system/sw/bin/godot",
"args": [
"--editor",
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true,
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true,
},
{
"description": "Debug forked child process",
"text": "-gdb-set follow-fork-mode child",
},
],
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"name": "Test (gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/run/current-system/sw/bin/godot",
"args": [
"--no-window",
"-s",
"addons/gut/gut_cmdln.gd"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true,
},
],
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
},
],
{
"description": "Debug forked child process",
"text": "-gdb-set follow-fork-mode child"
}
]
},
{
"name": "Test (gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/run/current-system/sw/bin/godot",
"args": ["--no-window", "-s", "addons/gut/gut_cmdln.gd"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

View file

@ -1,23 +1,23 @@
{
"editor.formatOnSave": true,
"clang-format.executable": "/run/current-system/sw/bin/clang-format",
"gut-extension.additionalOptions": "-d --no-window",
"nixEnvSelector.nixShellConfig": "NOT_MODIFIED_ENV",
"files.associations": {
"array": "cpp",
"istream": "cpp",
"limits": "cpp",
"numeric": "cpp",
"sstream": "cpp",
"streambuf": "cpp",
"utility": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"system_error": "cpp",
"functional": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"*.inc": "cpp"
}
"editor.formatOnSave": true,
"clang-format.executable": "/run/current-system/sw/bin/clang-format",
"gut-extension.additionalOptions": "-d --no-window",
"nixEnvSelector.nixShellConfig": "NOT_MODIFIED_ENV",
"files.associations": {
"array": "cpp",
"istream": "cpp",
"limits": "cpp",
"numeric": "cpp",
"sstream": "cpp",
"streambuf": "cpp",
"utility": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"system_error": "cpp",
"functional": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"*.inc": "cpp"
}
}

View file

@ -1,24 +1,17 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/addons/godot_xterm/native",
},
"command": "nix-shell",
"args": [
"-I",
"nixpkgs=~/nixpkgs",
"-p",
"scons",
"--run",
"./build.sh"
],
"problemMatcher": []
}
]
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"options": {
"cwd": "${workspaceFolder}/addons/godot_xterm/native"
},
"command": "nix-shell",
"args": ["-I", "nixpkgs=~/nixpkgs", "-p", "scons", "--run", "./build.sh"],
"problemMatcher": []
}
]
}

View file

@ -1,8 +1,5 @@
{
"dirs": [
"res://test/unit",
"res://test/integration"
],
"dirs": ["res://test/unit", "res://test/integration"],
"prefix": "",
"suffix": ".test.gd",
"include_subdirs": true,

View file

@ -1,7 +1,5 @@
{
"dirs": [
"res://test/platform/unix"
],
"dirs": ["res://test/platform/unix"],
"prefix": "",
"suffix": ".test.gd",
"include_subdirs": true,

View file

@ -1,11 +1,8 @@
{
"dirs": [
"res://platform/windows"
],
"dirs": ["res://platform/windows"],
"prefix": "",
"suffix": ".test.gd",
"include_subdirs": true,
"log_level": 2,
"should_exit": true
}
}

View file

@ -1,5 +1,5 @@
const { defineConfig } = require("cypress");
const getCompareSnapshotsPlugin = require('cypress-image-diff-js/dist/plugin');
const getCompareSnapshotsPlugin = require("cypress-image-diff-js/dist/plugin");
module.exports = defineConfig({
e2e: {

View file

@ -1,21 +1,23 @@
Cypress.on('window:before:load', win => {
cy.spy(win.console, 'error')
cy.spy(win.console, 'warn')
cy.spy(win.console, 'log')
})
Cypress.on("window:before:load", (win) => {
cy.spy(win.console, "error");
cy.spy(win.console, "warn");
cy.spy(win.console, "log");
});
describe('GodotXterm HTML5 export', () => {
it('Loads and runs without error', () => {
cy.visit('http://localhost:3000')
cy.compareSnapshot('menu', 0.9, {
limit: 100, delay: 200, timeout: 20000,
})
cy.get('body').type('{downArrow}{enter}')
cy.get('body').type('window.console.log("It works!"){enter}')
cy.window().then(win => {
cy.expect(win.console.error).to.have.callCount(0)
cy.expect(win.console.warn).to.have.callCount(0)
cy.expect(win.console.log).to.be.calledWith("It works!")
})
})
})
describe("GodotXterm HTML5 export", () => {
it("Loads and runs without error", () => {
cy.visit("http://localhost:3000");
cy.compareSnapshot("menu", 0.9, {
limit: 100,
delay: 200,
timeout: 20000,
});
cy.get("body").type("{downArrow}{enter}");
cy.get("body").type('window.console.log("It works!"){enter}');
cy.window().then((win) => {
cy.expect(win.console.error).to.have.callCount(0);
cy.expect(win.console.warn).to.have.callCount(0);
cy.expect(win.console.log).to.be.calledWith("It works!");
});
});
});

View file

@ -1,2 +1,2 @@
import compareSnapshotCommand from 'cypress-image-diff-js/dist/command';
import compareSnapshotCommand from "cypress-image-diff-js/dist/command";
compareSnapshotCommand();

View file

@ -1 +1 @@
import './commands'
import "./commands";