Text UI: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m linkfix |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
(27 intermediate revisions by 19 users not shown) | |||
Line 1:
A
== Popularity and Use ==
Back in the DOS days before GUIs were widespread, almost all applications used some sort of text UI. Some of these were simple, showing a menu or unmovable panels, but others included a fully featured windowing system, like the [https://en.wikipedia.org/wiki/Turbo_Pascal Turbo Pascal IDE] or the MS-DOS edit application (you can't tell from the screenshot on the wiki, but file windows were actually resizable and movable and they were stacked).
With the rise of graphical UI's, text based user interfaces still remain practical in hobbyist operating system projects, as they are the most easier type of interface to implement, and are still in use in larger and commerical operating systems where a graphical user interface is unneccesary, for example, in large servers. A text user interface is also easy for quickly outputing results or debug data, and inputing commands to test new features, rather than writing complicated graphical applications.▼
▲With the rise of graphical UI's, text based user interfaces still remain practical in hobbyist operating system projects, as they are the most
These days text based UI is mostly used over pseudo-ttys, using [[Terminals|VT escape sequences]] rather than direct VGA buffers. Most notable examples are Midnight Commander (a Linux clone of the Norton Commander under DOS), and [https://vtm.netxs.online/ VTM] (a fully featured desktop environment). The biggest advantage of these UIs that they can be used over simple tty-based SSH tunnels, no additional protocol needed. Details on curses based text interfaces are out of the scope of this page, which only focuses on [[VGA Hardware|VGA]] buffer text interfaces.
== Input ==
Input in a text user interface primarily involves the use of a [[Command_Line|command line]] [[shell]], usually through entering commands via a [[keyboard]]. Other methods do exist, such as text-based menus that can scroll up and down, and prompts asking a user to press a specific key for a specific event to occur.
== Video Mode ==
The most used VGA video mode for a text UI is
== Video Memory ==
In
position = (y_position * characters_per_line) + x_position;
Each character takes up two bytes of space in memory. The first byte is split into two segments, the forecolour, and the backcolour. The second byte is
== Colours ==
Each character has a
The layout of the byte, using the standard colour palette:
<pre>
Bit 76543210
||||||||
|||||^^^-
||||^----
|^^^-----
^--------
</pre>
Its easy to write
For Example:<br>
0x01 sets the background to
0x10 sets the background to
0x11 sets both to blue.
The default display colours set by the [[BIOS]] upon booting are
<br>
In text mode 0, the following standard colour
{| border="1" cellspacing="0"
! Number
Line 53 ⟶ 56:
| Black
| 0+8=8
| style="background: #
| Dark Gray
|-
| 1
| style="background: #
| Blue
| 1+8=9
| style="background: #
| Light Blue
|-
| 2
| style="background: #
| Green
| 2+8=A
| style="background: #
| Light Green
|-
| 3
| style="background: #
| Cyan
| 3+8=B
| style="background: #
| Light Cyan
|-
| 4
| style="background: #
| Red
| 4+8=C
| style="background: #
| Light Red
|-
| 5
| style="background: #
| Magenta
|
| style="background: #
| Light Magenta
|-
| 6
| style="background: #
| Brown
| 6
| style="background: #
| Yellow
|-
| 7
| style="background: #
| Light Gray
| 7+8=F
| style="background: #
| White
|-
Line 108 ⟶ 111:
== Example Console Class ==
A heavily documented and easy to understand example of a text console class is taken from Brandon's Kernel Tutorial,
== C Code for Print a Character ==
The following C code will print a character at X and Y coordinates:
<syntaxhighlight lang="c">
void WriteCharacter(unsigned char c, unsigned char forecolour, unsigned char backcolour, int x, int y)
{
volatile
where = (volatile uint16_t *)0xB8000 + (y * 80 + x) ;
*where = c | (attrib << 8);
}
</syntaxhighlight>
== Scrolling ==
Line 127 ⟶ 130:
== Virtual Terminals ==
Virtual terminals are much the same as physical screens, but instead of writing to the linear text buffer referring to the screen, text is written to a linear text buffer stored in memory. Each virtual terminal has it's own text buffer, and the terminal currently being displayed on screen has it's buffer copied into the video buffer to display on screen. Having more than one virtual text buffer has other advantages, such as only having parts of multiple
== Buffering Data ==
When working with a text-based interface, writing text directly into the video memory may eventually begin to create issues, especially when handling keyboard input, processing input from menus or dealing with multiple text mode consoles. This problem can usually be overcome by writing characters and colour data into a separate buffer (unparsed), and periodically flushing the buffer to the screen. There are multiple ways to implement a text buffer; a simple solution might feature a flat block of memory in which text and colour bytes are stored before being copied to the screen, though more a more advanced approach may include a per-line buffer, planar-buffer or a system of tracking updated lines or portions of the screen.
==See Also==
* [[VGA Hardware]]
* [[Text Mode Cursor]]
===External Links===
* [https://vtm.netxs.online/ VTM] Text-based Desktop Environment that uses curses and VT codes
[[Category:
[[Category:Video]]
|