This repository has been archived on 2023-09-28. You can view files and clone it, but cannot push or open issues or pull requests.
homepage/content/projects/noxos/docs/codebase/drivers/tty.h.md

49 lines
2.2 KiB
Markdown

---
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.