FreeNOS
|
A Terminal enables user to interact with the system. More...
#include <Terminal.h>
Public Member Functions | |
Terminal (const u32 inode, const char *inputFile, const char *outputFile, const Size width=80, const Size height=25) | |
Class constructor. More... | |
virtual | ~Terminal () |
Class destructor. More... | |
Size | getWidth () |
Retrieve the width of the Terminal. More... | |
Size | getHeight () |
Retrieve the height of the Terminal. More... | |
int | getInput () |
Retrieve file descriptor of the input source. More... | |
int | getOutput () |
Retrieve file descriptor of the output source. More... | |
u16 * | getBuffer () |
Retrieve a pointer to the local buffer. More... | |
u16 * | getCursorValue () |
Saved byte and attribute value at cursor position. More... | |
void | hideCursor () |
Hides the cursor from the VGA screen. More... | |
void | setCursor (const teken_pos_t *pos) |
Sets the new position of the cursor. More... | |
void | showCursor () |
Show the VGA cursor. More... | |
virtual FileSystem::Result | initialize () |
Initialize the Terminal. More... | |
virtual FileSystem::Result | read (IOBuffer &buffer, Size &size, const Size offset) |
Read bytes from the Terminal. More... | |
virtual FileSystem::Result | write (IOBuffer &buffer, Size &size, const Size offset) |
Write bytes to the Terminal. More... | |
Public Member Functions inherited from Device | |
Device (const u32 inode, const FileSystem::FileType type) | |
Constructor. More... | |
virtual | ~Device () |
Destructor. More... | |
virtual const String & | getIdentifier () const |
Get unique device identifier. More... | |
virtual FileSystem::Result | interrupt (const Size vector) |
Called when an interrupt has been triggered for this device. More... | |
Public Member Functions inherited from File | |
File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO) | |
Constructor function. More... | |
virtual | ~File () |
Destructor function. More... | |
u32 | getInode () const |
Get inode number. More... | |
FileSystem::FileType | getType () const |
Retrieve our filetype. More... | |
virtual FileSystem::Result | status (FileSystem::FileStat &st) |
Retrieve file statistics. More... | |
virtual bool | canRead () const |
Check if the File has data ready for reading. More... | |
virtual bool | canWrite () const |
Check if the File can be written to. More... | |
Private Member Functions | |
FileSystem::Result | writeTerminal (const u8 *bytes, const Size size) |
Write bytes to the output device. More... | |
Private Attributes | |
teken_t | state |
Terminal state. More... | |
teken_funcs_t | funcs |
Terminal function handlers. More... | |
u16 * | buffer |
Buffer for local Terminal updates. More... | |
teken_pos_t | cursorPos |
Saved cursor position. More... | |
u16 | cursorValue |
Saved value at cursor position. More... | |
const char * | inputFile |
Path to the input and output files. More... | |
const char * | outputFile |
const Size | width |
Width and height of the Terminal. More... | |
const Size | height |
int | input |
Input and output file descriptors. More... | |
int | output |
Additional Inherited Members | |
Protected Attributes inherited from Device | |
String | m_identifier |
Unique identifier for this Device. More... | |
Protected Attributes inherited from File | |
const u32 | m_inode |
Inode number. More... | |
const FileSystem::FileType | m_type |
Type of this file. More... | |
UserID | m_uid |
Owner of the file. More... | |
GroupID | m_gid |
Group of the file. More... | |
FileSystem::FileModes | m_access |
Access permissions. More... | |
Size | m_size |
Size of the file, in bytes. More... | |
A Terminal enables user to interact with the system.
Definition at line 44 of file Terminal.h.
Terminal::Terminal | ( | const u32 | inode, |
const char * | inputFile, | ||
const char * | outputFile, | ||
const Size | width = 80 , |
||
const Size | height = 25 |
||
) |
Class constructor.
inode | Inode number |
inputFile | Path to the (device) file to use as input source. |
outputFile | Path to the (device) file to use as an output source. |
width | Width of the Terminal. |
height | Height of the Terminal. |
Definition at line 42 of file Terminal.cpp.
References buffer, height, Device::m_identifier, and width.
|
virtual |
u16 * Terminal::getBuffer | ( | ) |
u16 * Terminal::getCursorValue | ( | ) |
Saved byte and attribute value at cursor position.
Definition at line 140 of file Terminal.cpp.
References cursorValue.
Size Terminal::getHeight | ( | ) |
Retrieve the height of the Terminal.
Definition at line 120 of file Terminal.cpp.
References height.
int Terminal::getInput | ( | ) |
Retrieve file descriptor of the input source.
Definition at line 125 of file Terminal.cpp.
References input.
int Terminal::getOutput | ( | ) |
Retrieve file descriptor of the output source.
Definition at line 130 of file Terminal.cpp.
References output.
Size Terminal::getWidth | ( | ) |
void Terminal::hideCursor | ( | ) |
Hides the cursor from the VGA screen.
Definition at line 202 of file Terminal.cpp.
References buffer, cursorPos, cursorValue, teken_pos_t::tp_col, teken_pos_t::tp_row, and width.
|
virtual |
Initialize the Terminal.
Reimplemented from Device.
Definition at line 57 of file Terminal.cpp.
References BANNER, bell(), close(), copy(), cursor(), cursorPos, errno, fill(), funcs, input, inputFile, FileSystem::IOError, memset(), O_RDONLY, O_RDWR, open(), output, outputFile, param(), printf(), putchar(), respond(), state, strerror(), strlen(), FileSystem::Success, teken_init(), teken_set_winsize(), teken_funcs_t::tf_bell, teken_funcs_t::tf_copy, teken_funcs_t::tf_cursor, teken_funcs_t::tf_fill, teken_funcs_t::tf_param, teken_funcs_t::tf_putchar, teken_funcs_t::tf_respond, teken_pos_t::tp_col, teken_pos_t::tp_row, and writeTerminal().
|
virtual |
Read bytes from the Terminal.
buffer | Input/Output buffer to output bytes to. |
size | Maximum number of bytes to read on input. On output, the actual number of bytes read. |
offset | Offset inside the file to start reading. |
Reimplemented from File.
Definition at line 145 of file Terminal.cpp.
References buffer, input, FileSystem::IOError, and FileSystem::Success.
Referenced by writeTerminal().
void Terminal::setCursor | ( | const teken_pos_t * | pos | ) |
Sets the new position of the cursor.
pos | New position coordinates. |
Definition at line 211 of file Terminal.cpp.
References buffer, cursorPos, cursorValue, teken_pos_t::tp_col, teken_pos_t::tp_row, and width.
Referenced by cursor(), and showCursor().
void Terminal::showCursor | ( | ) |
Show the VGA cursor.
Definition at line 218 of file Terminal.cpp.
References buffer, cursorPos, LIGHTGREY, setCursor(), teken_pos_t::tp_col, teken_pos_t::tp_row, VGA_ATTR, and width.
|
virtual |
Write bytes to the Terminal.
buffer | Input/Output buffer to input bytes from. |
size | Maximum number of bytes to write on input. On output, the actual number of bytes written. |
offset | Offset inside the file to start writing. |
Reimplemented from File.
Definition at line 166 of file Terminal.cpp.
References buffer, and writeTerminal().
Referenced by writeTerminal().
|
private |
Write bytes to the output device.
bytes | Input bytes |
size | Number of input bytes |
Definition at line 173 of file Terminal.cpp.
References buffer, height, lseek(), output, read(), SEEK_SET, state, FileSystem::Success, teken_input(), width, and write().
Referenced by initialize(), and write().
|
private |
Buffer for local Terminal updates.
Definition at line 185 of file Terminal.h.
Referenced by getBuffer(), hideCursor(), read(), setCursor(), showCursor(), Terminal(), write(), writeTerminal(), and ~Terminal().
|
private |
Saved cursor position.
Definition at line 188 of file Terminal.h.
Referenced by hideCursor(), initialize(), setCursor(), and showCursor().
|
private |
Saved value at cursor position.
Definition at line 191 of file Terminal.h.
Referenced by getCursorValue(), hideCursor(), and setCursor().
|
private |
|
private |
Definition at line 201 of file Terminal.h.
Referenced by getHeight(), Terminal(), and writeTerminal().
|
private |
Input and output file descriptors.
Definition at line 204 of file Terminal.h.
Referenced by getInput(), initialize(), read(), and ~Terminal().
|
private |
Path to the input and output files.
Definition at line 196 of file Terminal.h.
Referenced by initialize().
|
private |
Definition at line 204 of file Terminal.h.
Referenced by getOutput(), initialize(), writeTerminal(), and ~Terminal().
|
private |
Definition at line 196 of file Terminal.h.
Referenced by initialize().
|
private |
Terminal state.
Definition at line 179 of file Terminal.h.
Referenced by initialize(), and writeTerminal().
|
private |
Width and height of the Terminal.
Definition at line 201 of file Terminal.h.
Referenced by getWidth(), hideCursor(), setCursor(), showCursor(), Terminal(), and writeTerminal().