Git Product home page Git Product logo

godot-xterm's Introduction

GodotXterm - Terminal Emulator


Godot Version License Build and Test

GDNative terminal for Godot. Built using libtsm, libuv, and node-pty. Primarily developed and tested on Linux, it also supports macOS with partial support for Windows and HTML5. See the Features section of the documentation for more detail.

The plugin currently supports Godot 3.x, with a Godot 4 (GDExtension) version under development on the main branch. The latest code for the Godot 3 version can be found on the godot-3.x branch.

GodotXterm.mp4

Live Demo View Documentation

godot-xterm's People

Contributors

dan2552 avatar dependabot[bot] avatar lihop avatar richard-hajek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

godot-xterm's Issues

Shrinking the terminal removes upper rows

When the terminal is enlarged blank space is added below the buffered row. However, when the terminal is shrunk, this blank space is not removed but rather the buffered rows starting at the top.

Compare this behavior with the behavior of xterm:

Actual (godot-xterm):
resize_issue

Expected (xterm):
xterm

This can causes issues when the Terminal is placed inside a TabContainer as it is actually resized (enlarged by two rows and then shrunk back to the original size) when switching tabs, which results in the output being hidden:
tab_bug

PTY output not shown without GUI activity

I also encountered another problem, but I don't know if it can be related to this one.

With the same setup (scene with Terminal,Pty and other input nodes) if I execute a command with sudo the terminal screen do not show the command output, to force a refresh I need to press a key or click on other input field to switch focus.

The same command executed without sudo works as expected, the screen show the output.

ping www.google.com works
sudo ping www.google.com doesn't work

Originally posted by @ConteZero in #51 (comment)

Change the default theme

Some colors are barely legible. Especially the dark blue.
2021-07-02-233400_781x184_scrot

Making a color scheme similar to Godot's script editor could be a good idea, especially as a default theme for #43:
2021-07-02-233547_496x344_scrot

"Unicode error: no space left" cause strange behaviors

While executing some commands the following errors appear in the logs:

Unicode error: no space left
Unicode error: invalid skip

Some texts are not displayed in the terminal and sometimes strange behaviors appear on the screen.
test-2022-08-09.zip

I've uploaded a zipped mp4 file because github do not recognize it as valid mp4 file.
I've used Godot 3.5 and man scout is not the only command that has this problem, in my system it happens with other commands too, here are some examples:

man -Len -Tutf8 virt-edit
man -Len -Tutf8 dialog
man -Len -Tutf8 systemd-xdg-autostart-generator
man -Len -Tutf8 firewall-cmd

[Godot 4] Fix editor terminal shortcuts

Default shortcuts:

  • Copy: Ctrl+Shift+C
  • Paste: Ctrl+Shift+P
  • Kill focused terminal: Ctrl+Shift+X
  • Open new terminal: Ctrl+Shift+T
  • Tab left: Ctrl+Shift+PgUp
  • Tab right: Ctrl+Shift+PgDown

All of these use the Shift modifier as to not conflict with control character input. For example, Ctrl+C is used to write the "end of text" control character.

These shortcuts should also be shown (in brackets) in the "right-click" popup menu:

2023-01-15-105027_281x235_scrot

As a bonus, these shortcuts should be configurable in editor settings (see #64). Shortcut settings are not currently exposed by the engine, but it looks like there are plans to expose them in the future. In the meantime, we could use string representations of the shortcuts and parse them using OS.find_keycode_from_string().

Characters disappear after resizing window when using a custom theme

When using a custom theme (i.e. the 'theme' property of Terminal is not null), visible characters disappear after resizing the window.

Expected: Visible characters continue to be displayed, but in the colors of the new theme.
issue-expected

Actual: Visible characters disappear, but the cursor remains in the correct position.
issue-actual

Wrong colors

Steps to reproduce:

  1. In the inspector set foreground color to red:
    2020-11-09-113405_218x308_scrot
  2. Run the app.
    2020-11-09-113414_482x95_scrot
    It's blue!
  3. In the inspector set foreground color to blue:
    2020-11-09-113427_227x305_scrot
  4. Run the app.
    2020-11-09-113434_479x94_scrot
    It's red!

Expected: the opposite.

vim plugin

Hello, first let me say specialist thanks to you for this great plugin.
next, I have a question, please guide me.
why do not you create a vim plugin for the Godot editor? I mean things like the vim plugin for Atom.
is it difficult? if I want to start creating a vim plugin for Godot editor like the existing vim plugin for Atom, where can I start?
do you know it? could you help me?

P.S.
sorry, I'm not good in english.

Characters disappear when changing theme

When changing Terminal theme visible characters disappear.

Expected: Visible characters are redrawn with the new theme colors.

Actual: Visible characters disappear, but the background color updates correctly.

issue-other

Make better use of space for wide characters

Now that #17 is fixed, the full emojis are shown. But they make very poor use of available space.
For example:
2021-07-12-230509_309x160_scrot
Highlighted is the complete space (two cells) dedicated to this character however, there are at least 4 pixels on the right and top, 2 pixels on the left and 1pixel on the bottom that this emoji could be use.

Godot 4 functionality.

Is the Godot 4 branch supposed to be working? I'm interested in getting this to work specifically for Windows.

Terminal lose focus in scenes with other input nodes

I'm using the Terminal node in a scene together with some LineEdit nodes.
When the focus is on the terminal, focus will switch to other LineEdit nodes after pressing some keys (KEY_UP, KEY_DOWN, KEY_TAB).

In terminal.gd I've changed:

func _gui_input(event):
	_native_terminal._gui_input(event)

	if event is InputEventKey and event.pressed:
		# Return to bottom of scrollback buffer if we scrolled up. Ignore modifier
		# keys pressed in isolation or if Ctrl+Shift modifier keys are pressed.
		if (
			not event.scancode in [KEY_ALT, KEY_SHIFT, KEY_CONTROL, KEY_META, KEY_MASK_CMD]
			and not (event.control and event.shift)
		):
			_native_terminal.sb_reset()

	_handle_mouse_wheel(event)
	_handle_selection(event)

with this:

func _input(event):
	if has_focus():
		_native_terminal._gui_input(event)

		if event is InputEventKey and event.pressed:
		# Return to bottom of scrollback buffer if we scrolled up. Ignore modifier
		# keys pressed in isolation or if Ctrl+Shift modifier keys are pressed.
			if (
				not event.scancode in [KEY_ALT, KEY_SHIFT, KEY_CONTROL, KEY_META, KEY_MASK_CMD]
				and not (event.control and event.shift)
			):
				_native_terminal.sb_reset()
			if event.scancode in [KEY_DOWN, KEY_UP, KEY_TAB]:
				get_tree().set_input_as_handled()

		_handle_mouse_wheel(event)
		_handle_selection(event)

This code solves the focus switch problem, but it is not the right fix because from my tests sometimes it causes some key press to be lost.

Encoding error on terminal write

Steps to reproduce:

  1. Create a simple scene with a Control node and Terminal as child (don't forget to set a theme for Terminal!):
    2020-11-02-204019_264x81_scrot
  2. Attach the following script to the Control node:
extends Control

func _process(delta):
	var string = "\u001b[0m\u001b[?7h\u001b[0ma\u001b[0m\r\r\n\u001b[0m"
	$Terminal.write(string)
  1. Run the scene.

Expected: A repeating column of the letter 'a' along the left side of the terminal.

2020-11-02-204413_251x440_scrot

Actual: Unexpected characters.

2020-11-02-204307_260x499_scrot

Resizing the terminal a few times results in a "Unicode error: invalid skip" error.

2020-11-02-204458_329x220_scrot

[Godot 4] Highlight editor terminal border on focus

Draw an outline around the editor terminal when it is focused.

blue-border

Although this feature is currently lacking in GodotXterm, the bright blue border of Godot 4's default theme makes the lack of this feature more obvious.

Implementing #29 would also help indicate that the editor terminal is or isn't focused.

UpdateMode.AUTO doesn't always refresh screen on resize

UpdateMode.AUTO usually only draws changed cells, but is supposed to redraw the entire screen when the Terminal's parent viewport is cleared (i.e. on resize). But it doesn't always work.

Setting update_mode to UpdateMode.ALL (which redraws the entire screen on every update) does not have this problem, but is bad for performance (more than doubling or tripling the frame time).

resize-update

[Godot 4] Use EditorSettings to configure editor terminal

Using EditorSettings we can create a new section in the editor settings modal ("Editor" -> "Editor Settings" -> "General") for configuration of the integrated terminal.

This will allow the user to set things such as font, font size, theme, bell settings, bell sound, etc. and re-use these settings across projects.

Incorrect intial PTY size when used with Terminal

When running the terminal example scene the initial PTY size does not match the Terminal size but rather the default of 24x80.

Expected:
2022-08-11-094307_398x65_scrot

Actual:
2022-08-11-094243_464x103_scrot

This results in some undesirable behaviour:
2022-08-11-094211_798x529_scrot
2022-08-11-094204_798x529_scrot

This is fixed after resizing the Terminal (for example, by resizing the application window) so it emits the size_changed() signal, causing PTY to update to the correct size:
2022-08-11-094313_798x529_scrot
2022-08-11-094326_798x529_scrot

Add built-in terminal to editor's bottom panel

Although GodotXterm was originally created for use in-game, the pieces are almost in place such that it would be quite easy to add it as an editor plugin to the bottom panel.

Reasons to do this:

  1. It's a feature I want, and would use a lot.
  2. It's a great way to battle test and harden GodotXterm by using it frequently with real-world terminal applications and commands.

Related godot proposal which goes into more detail godotengine/godot-proposals#1379

Rudimentary terminal panel added by #48:

2021-07-11-230710_591x257_scrot

Features to add (using vscode terminal as a reference):

  • Ctrl+Shift+C copy and Ctrl+Shift+V paste
  • Shortcut to spawn new terminal (default Ctrl+Shift+T)
  • Right click menu:
    2021-07-11-231428_304x214_scrot
  • Re-arrangable tabs
  • Right click tab options (kill instead of close):
    2021-07-11-231647_185x124_scrot
  • Customisable theme.
  • Customisable bell.
  • Customisable cursor.
  • Visual bell (show visually on tab when bell is rung).
  • Customisable font size, with ctrl+mouse wheel up/down to increase/decrease size.
  • Settings support to set all the customisable things and modify behavior.
    All of these customisable settings should update as soon as possible, without having to restart terminal sessions.

Things to fix:

  • Prevent crashing.
  • Tabs close when clicking on right side:
    Peek 2021-07-11 23-19

Use as code editor - replace Script

Hi, wonderful people ๐Ÿ˜ƒ

I plan to use Godot with F#, that is currently being worked on, to be supported.
Haxe, Lua, Javascript and a couple of other languages also work on Godot 4 compatibility.

I am one of the maintainers of that wonderful list, if you are interested about other language support.

So, do you help us, by letting us use your wonderful terminal as Script replacement?

People could start their own Helix/NeoVim or Emacs there, and develop at the same place, game and code. ๐Ÿฅณ

Draw hollow cursor when terminal not focused

Currently the terminal always draws the cursor as a block.
We should follow xterm and draw a hollow cursor when Terminal.has_focus() is false.
i.e:

  • Terminal.has_focus() == true:
    2020-11-24-153911_74x29_scrot

  • Terminal.has_focus() == false:
    2020-11-24-154015_76x28_scrot

Remove binaries from master branch

Storing pre-compiled binaries in the master branches uses too much space.
A previously added debug binary takes up ~75M and release binaries are ~5M which will use a lot of space on subsequent releases and when support for more platforms is added.

Therefore, I will be removing existing binaries from the master branch using BFG Repo-Cleaner which will rewrite history.

Making pre-compiled binaries available is still useful however, so going forwards I will either add them to the GitHub release or create and tag a new anonymous branch which contains the binaries as detailed here: https://stackoverflow.com/questions/50974474/how-to-save-dist-build-files-on-github-release-but-not-in-master.

Build Windows 32-bit

Currently the GitHub action workflow only builds 64-bit windows.
We should build 32-bit too.

Failure to enable

When attempted enable is performed, file godot_xterm/buffer/buffer_line.gd throws error at line 135

image

[Godot 4] Fix tests

GUT has been upgraded to a version that supports Godot 4, however many of the tests in /test are still broken.

Support transparency

It would be nice to be able to set the alpha for terminal theme colors and have the terminal drawn with transparency.

Please expose current cursor position and current character attributes

So first I need the ability to read the current cursor position from the terminal.

A couple of ideas for how it could be done:

  • Expose a function from terminal.cpp that returns the cursor position.
  • Implement CSI 6 n (DSR) to output CSI r ; c R (CPR). Perhaps this could be done by having write() return a string (or PoolByteArray). So if the input contains that sequence (or any other implemented reporting sequence), write() returns the response to its caller.

Both of those would be useful in different ways, but I think either one could do the job.

The other request is a way to read the current character attributes (SGR). That is, the fg/bg/bold/etc values that are in effect and will be used on the next write().

As above, this could be done by:

  • One or more functions to read the data.
  • Implement DCS $ q m ST (DECRQSS) to output a CSI SGR string. Again, this might mean write() returning that data.

Of course, the implementation ideas above are just my uninformed thoughts. There's a lot I really don't understand about how this is implemented, so you might easily have a better approach.

Godot 4

Is this somehow supposed to become ported to Godot 4?

๐Ÿ˜ƒ

Try libtmt as an alternative to libtsm

libtmt has a similar purpose to libtsm, but it is smaller and simpler.
Some current issues such as wide character support (#17) might be resolved by switching to libtmt.
But there are some limitations such as lack of mouse support (#4).
In any case, I think it is worth plugging in and trying.

Support wide character unicode/emoji

There is already support for unicode/emoji, but wide characters such as ๐Ÿ‘จ are drawn cut-off.

Expected: X๐Ÿ‘จ๐Ÿ‘จX
Actual: 2020-11-09-112410_117x51_scrot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.