Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a Terminal Emulator #41

Closed
thejpster opened this issue May 21, 2023 · 9 comments
Closed

Implement a Terminal Emulator #41

thejpster opened this issue May 21, 2023 · 9 comments

Comments

@thejpster
Copy link
Member

The Terminal Emulator will interpret ANSI sequences and draw on the text buffer appropriately.

If the serial terminal is enabled, they are passed straight through.

The OS will also handle "raw" and "cooked" mode. Cooked mode only supplies a line to the application after Enter is pressed. Line editing (backspace, etc) is done before they application sees the string. Raw mode supplies each character as it is received (as UTF-8 encoded bytes), backspace and all. You can use an I/O Control (ioctl) to change modes. The raw/cooked is in the OS and will work with either terminal (VGA/KB or Serial).

Function Keys and other special characters would be sent to the application as ANSI strings.

Note to self: need to have a timeout ioctl so you can make read calls timeout if nothing has been received otherwise you could lock a program up, and it can't do anything whilst waiting for keys.

Examples of programs using raw mode:

  • games like snake or tetris
  • a full screen editor

Our VGA/KB based terminal should work like a common serial terminal, like pyserial's microcom, or like PuTTY with its default configuration.

@thejpster
Copy link
Member Author

Reminder that the console-traits crate exists.

@thejpster
Copy link
Member Author

Also, what happens if you have serial and VGA terminals and the application asks for the screen size? Who responds? Both? Only serial? What if serial isn't connected?

Maybe you can only pick one, but you can hold V on startup for VGA mode, or blast S over serial for serial mode. But I guess that involves getting the UART working.

@tingox
Copy link

tingox commented Jul 4, 2023

One way to handle this (not necessarily a good way) is to assign the terminal with first input as console or "active" terminal. If you want to use both (but not simultaneously) you just update the console attribute whenever you get input from one of them.

@thejpster
Copy link
Member Author

That's a really interesting idea. Thanks!

@thejpster
Copy link
Member Author

https://docs.rs/vte/0.11.1/vte/ is useful here.

@thejpster thejpster mentioned this issue Jul 13, 2023
@thejpster
Copy link
Member Author

Started in #55

@thejpster
Copy link
Member Author

Need to think any how to share this Virtual Terminal object with the Application callbacks.

@thejpster
Copy link
Member Author

Wrote a refcell that uses the bios to provide a critical section. Used this for standard input and for console output.

ANSI decoder handles colours, cursor on/off, and basic position updates, so that's enough for this ticket.

@jonathanpallant
Copy link
Contributor

Done in v0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants