FreeNOS
Terminal.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __TERMINAL_TERMINAL_H
19#define __TERMINAL_TERMINAL_H
20
21#include <FreeNOS/Config.h>
22#include <Device.h>
23#include <Macros.h>
24#include <Types.h>
25#include <teken.h>
26
38#define BANNER \
39 "FreeNOS " RELEASE " [" ARCH "/" SYSTEM "] (" BUILDUSER "@" BUILDHOST ") (" COMPILER_VERSION ") " DATETIME "\r\n"
40
44class Terminal : public Device
45{
46 public:
47
58 Terminal(const u32 inode,
59 const char *inputFile,
60 const char *outputFile,
61 const Size width = 80,
62 const Size height = 25);
63
67 virtual ~Terminal();
68
74 Size getWidth();
75
82
88 int getInput();
89
95 int getOutput();
96
102 u16 * getBuffer();
103
110
114 void hideCursor();
115
121 void setCursor(const teken_pos_t *pos);
122
126 void showCursor();
127
134
146 Size & size,
147 const Size offset);
148
160 Size & size,
161 const Size offset);
162
163 private:
164
174 const Size size);
175
176 private:
177
180
183
186
189
192
196 const char *inputFile, *outputFile;
197
202
205};
206
212void bell(Terminal *term);
213
222void putchar(Terminal *term, const teken_pos_t *pos,
223 teken_char_t ch, const teken_attr_t *attr);
224
231void cursor(Terminal *term, const teken_pos_t *pos);
232
241void fill(Terminal *ctx, const teken_rect_t *rect,
242 teken_char_t ch, const teken_attr_t *attr);
243
251void copy(Terminal *ctx, const teken_rect_t *rect,
252 const teken_pos_t *pos);
253
261void param(Terminal *ctx, int key, int value);
262
266void respond(Terminal *ctx, const void *buf, size_t size);
267
273#endif /* __TERMINAL_TERMINAL_H */
Abstract device class interface.
Definition Device.h:36
Abstract Input/Output buffer.
Definition IOBuffer.h:38
A Terminal enables user to interact with the system.
Definition Terminal.h:45
void setCursor(const teken_pos_t *pos)
Sets the new position of the cursor.
Definition Terminal.cpp:211
const Size height
Definition Terminal.h:201
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Write bytes to the Terminal.
Definition Terminal.cpp:166
teken_t state
Terminal state.
Definition Terminal.h:179
FileSystem::Result writeTerminal(const u8 *bytes, const Size size)
Write bytes to the output device.
Definition Terminal.cpp:173
void hideCursor()
Hides the cursor from the VGA screen.
Definition Terminal.cpp:202
const char * outputFile
Definition Terminal.h:196
teken_pos_t cursorPos
Saved cursor position.
Definition Terminal.h:188
u16 * buffer
Buffer for local Terminal updates.
Definition Terminal.h:185
u16 * getCursorValue()
Saved byte and attribute value at cursor position.
Definition Terminal.cpp:140
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read bytes from the Terminal.
Definition Terminal.cpp:145
const char * inputFile
Path to the input and output files.
Definition Terminal.h:196
virtual FileSystem::Result initialize()
Initialize the Terminal.
Definition Terminal.cpp:57
teken_funcs_t funcs
Terminal function handlers.
Definition Terminal.h:182
int input
Input and output file descriptors.
Definition Terminal.h:204
int getInput()
Retrieve file descriptor of the input source.
Definition Terminal.cpp:125
const Size width
Width and height of the Terminal.
Definition Terminal.h:201
Size getWidth()
Retrieve the width of the Terminal.
Definition Terminal.cpp:115
u16 cursorValue
Saved value at cursor position.
Definition Terminal.h:191
int output
Definition Terminal.h:204
Size getHeight()
Retrieve the height of the Terminal.
Definition Terminal.cpp:120
void showCursor()
Show the VGA cursor.
Definition Terminal.cpp:218
u16 * getBuffer()
Retrieve a pointer to the local buffer.
Definition Terminal.cpp:135
virtual ~Terminal()
Class destructor.
Definition Terminal.cpp:108
int getOutput()
Retrieve file descriptor of the output source.
Definition Terminal.cpp:130
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned short u16
Unsigned 16-bit number.
Definition Types.h:56
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
unsigned char u8
Unsigned 8-bit number.
Definition Types.h:59
void respond(Terminal *ctx, const void *buf, size_t size)
Unused.
Definition Terminal.cpp:310
void param(Terminal *ctx, int key, int value)
Set terminal parameters.
Definition Terminal.cpp:305
void bell(Terminal *term)
Makes a sound (bell).
Definition Terminal.cpp:230
void cursor(Terminal *term, const teken_pos_t *pos)
Sets the Terminal cursor.
Definition Terminal.cpp:253
void copy(Terminal *ctx, const teken_rect_t *rect, const teken_pos_t *pos)
Copy bytes to the terminal.
Definition Terminal.cpp:282
void putchar(Terminal *term, const teken_pos_t *pos, teken_char_t ch, const teken_attr_t *attr)
Output a new character.
Definition Terminal.cpp:235
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.
Definition Terminal.cpp:260
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
unsigned char teken_char_t
Definition teken.h:49