68 printf(
"failed to open `%s': %s\r\n",
76 printf(
"failed to open `%s': %s\r\n",
152 n =
::read(
input, tmp, size <
sizeof(tmp) ? size :
sizeof(tmp));
184 for (
Size i = 0; i < size; i++)
186 if (bytes[i] ==
'\n')
299 numCols + (numRows * width) *
sizeof(
u16));
Abstract device class interface.
String m_identifier
Unique identifier for this Device.
Abstract Input/Output buffer.
A Terminal enables user to interact with the system.
void setCursor(const teken_pos_t *pos)
Sets the new position of the cursor.
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Write bytes to the Terminal.
teken_t state
Terminal state.
FileSystem::Result writeTerminal(const u8 *bytes, const Size size)
Write bytes to the output device.
void hideCursor()
Hides the cursor from the VGA screen.
teken_pos_t cursorPos
Saved cursor position.
u16 * buffer
Buffer for local Terminal updates.
u16 * getCursorValue()
Saved byte and attribute value at cursor position.
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read bytes from the Terminal.
const char * inputFile
Path to the input and output files.
virtual FileSystem::Result initialize()
Initialize the Terminal.
teken_funcs_t funcs
Terminal function handlers.
int input
Input and output file descriptors.
int getInput()
Retrieve file descriptor of the input source.
const Size width
Width and height of the Terminal.
Size getWidth()
Retrieve the width of the Terminal.
u16 cursorValue
Saved value at cursor position.
Size getHeight()
Retrieve the height of the Terminal.
void showCursor()
Show the VGA cursor.
u16 * getBuffer()
Retrieve a pointer to the local buffer.
virtual ~Terminal()
Class destructor.
int getOutput()
Retrieve file descriptor of the output source.
Terminal(const u32 inode, const char *inputFile, const char *outputFile, const Size width=80, const Size height=25)
Class constructor.
#define SEEK_SET
Seek relative to start-of-file.
C size_t strlen(const char *str)
Calculate the length of a string.
C int open(const char *path, int oflag,...)
Open file relative to directory file descriptor.
C char * strerror(int errnum)
The strerror function maps the number in errnum to a message string.
C int close(int fildes)
Close a file descriptor.
C int errno
The lvalue errno is used by many functions to return error values.
C void * memset(void *dest, int ch, size_t count)
Fill memory with a constant byte.
C off_t lseek(int fildes, off_t offset, int whence)
Move the read/write file offset.
C void * memcpy(void *dest, const void *src, size_t count)
Copy memory from one place to another.
#define O_RDONLY
Open for reading only.
C int printf(const char *format,...)
Output a formatted string to standard output.
#define O_RDWR
Open for reading and writing.
unsigned int u32
Unsigned 32-bit number.
unsigned short u16
Unsigned 16-bit number.
unsigned int Size
Any sane size indicator cannot go negative.
unsigned char u8
Unsigned 8-bit number.
void respond(Terminal *ctx, const void *buf, size_t size)
Unused.
void param(Terminal *ctx, int key, int value)
Set terminal parameters.
#define BANNER
Print this banner per default on new Terminals.
void bell(Terminal *term)
Makes a sound (bell).
void cursor(Terminal *term, const teken_pos_t *pos)
Sets the Terminal cursor.
void copy(Terminal *ctx, const teken_rect_t *rect, const teken_pos_t *pos)
Copy bytes to the terminal.
void putchar(Terminal *term, const teken_pos_t *pos, teken_char_t ch, const teken_attr_t *attr)
Output a new character.
void fill(Terminal *ctx, const teken_rect_t *rect, teken_char_t ch, const teken_attr_t *attr)
Fills the Terminal buffer with a character.
#define VGA_ATTR(front, back)
Encodes VGA attributes.
#define VGA_CHAR(ch, front, back)
Encodes a character for VGA output.
Result
Result code for filesystem Actions.
tf_putchar_t * tf_putchar
tf_respond_t * tf_respond
void teken_init(teken_t *t, const teken_funcs_t *tf, void *softc)
void teken_input(teken_t *t, const void *buf, size_t len)
void teken_set_winsize(teken_t *t, const teken_pos_t *p)
void tf_param_t(void *, int, unsigned int)
void tf_respond_t(void *, const void *, size_t)
void tf_fill_t(void *, const teken_rect_t *, teken_char_t, const teken_attr_t *)
unsigned char teken_char_t
void tf_cursor_t(void *, const teken_pos_t *)
void tf_copy_t(void *, const teken_rect_t *, const teken_pos_t *)
void tf_putchar_t(void *, const teken_pos_t *, teken_char_t, const teken_attr_t *)