noxos (docs): documented tty

This commit is contained in:
antifallobst 2023-05-01 00:56:20 +02:00
parent 9e63f336cf
commit 0b5927f563
2 changed files with 56 additions and 7 deletions

View File

@ -0,0 +1,48 @@
---
title: "tty.h"
summary: "A virtual text output device"
---
The TTY is a virtual device, that acts as a text IO layer.
It prints keyboard input and process output to the screen.
The keyboard input can be directed to a processes stdin and the processes stdout can be printed to the screen.
Schematic:
```
+-------------------+
| Graphics Renderer |
+-------------------+
^ ^
| | +----------+ +-----------------+
| | | TTY | | Process (shell) |
| | | | | |
| |--|-[Input]--|-<----|-[stdout] |
| | | | |
-[Keyboard]----->-|-[Output]-|->----| [stdin] |
+----------+ +-----------------+
```
# `tty_T` - struct
| Name | Type | Description |
|-----------------|--------------------|---------------------------------------------------------------------------------------------------|
| graphics_buffer | graphics_buffer_T* | The graphics buffer where all output will be rendered to. |
| output | pipe_T* | Points to the linked processes stdin pipe. |
| input | pipe_T | This pipes content will be rendered to the screen. The linked processes stdout should point here. |
| cursor | position_T | The cursors position. |
| color | color_argb_T | The current drawing color. |
# `tty_init()` - function (void)
Initializes `g_tty`.
# `tty_update()` - function (void)
Renders the text from the ttys _input pipe_ onto the screen.
This will be automatically called when writing into the ttys _input pipe_.
# `tty_write(string)` - function (uint32_t)
Renders the text from **_string_** onto the screen.
This also writes **_string_** into the ttys _output pipe_.
# `g_tty` - global variable
This is the systems TTY.
Currently, there is no support planned for multiple ttys.

View File

@ -13,14 +13,15 @@ The size of a pipes stream buffer, in bytes.
# `pipe_T` - struct # `pipe_T` - struct
| Name | Type | Description | | Name | Type | Description |
|----------------|-------------------------------|---------------------------------------------------------| |----------------|-------------------------------|-----------------------------------------------------------------------------------------|
| stream | stream_T* | The stream, where the pipes data is saved. | | stream | stream_T* | The stream, where the pipes data is saved. |
| receiver | process_T* | The process which is allowed to read from the pipe. | | receiver | process_T* | The process which is allowed to read from the pipe. |
| senders | process_T* [PIPE_MAX_SENDERS] | The processes which are allowed to write to the pipe. | | senders | process_T* [PIPE_MAX_SENDERS] | The processes which are allowed to write to the pipe. |
| senders_bitmap | bitmap_T | Indicates which fields of _senders_ are currently used. | | senders_bitmap | bitmap_T | Indicates which fields of _senders_ are currently used. |
| on_write | void function pointer | If this is not NULL, this function will be called when data is written into the stream. |
# `pipe_init(pipe*, receiver*)` - function (void) # `pipe_init(pipe*, receiver*, (*on_write)())` - function (void)
Initializes **_pipe_** and allocates a stream for it. Initializes **_pipe_** and allocates a stream for it.
# `pipe_destruct(pipe*)` - function (void) # `pipe_destruct(pipe*)` - function (void)