cogentcore / core

A free and open source framework for building powerful, fast, and elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the Web with a single pure Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.31k stars 71 forks source link

terminal emulator widget #959

Open rcoreilly opened 1 month ago

rcoreilly commented 1 month ago

Describe the feature

Need to add a Terminal widget. This is a tracking issue for discussing design and impl.

Key design principles

  1. Critical difference between line-mode vs. block-mode or term-mode: https://en.wikipedia.org/wiki/Computer_terminal#Modes -- need to support both, with completely different implementations for each. there is some key escape code that switches modes, and you either see one or the other. Will just use a Stacked layout and switch between the two.

  2. line-mode will wrap a texteditor, with constraint that restricts input to the last row. when enter is pressed, the new line is sent to the stdin of whatever shell is running, and output is always added to history etc. should be fairly simple.

  3. block-mode requires an entirely new widget that represents individual characters in an X,Y grid, sized according to the size of the widget. this implements all the escape control sequences.

These go programs have all the terminfo control sequences etc: https://github.com/nsf/termbox-go -- https://github.com/gdamore/tcell

xterm-256 https://en.wikipedia.org/wiki/Xterm is reasonable target to support -- we only want to support one type (initially at least) -- goal is just to support cosh, not reinvent the whole world of terminals at this point. looks like this is the relevant standard: https://en.wikipedia.org/wiki/ANSI_escape_code

Relevant code

No response