summaryrefslogtreecommitdiff
path: root/Source/Kernel/VTManager
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel/VTManager')
-rw-r--r--Source/Kernel/VTManager/FileVT.class.cpp8
-rw-r--r--Source/Kernel/VTManager/FileVT.class.h2
-rw-r--r--Source/Kernel/VTManager/PipeVT.class.cpp8
-rw-r--r--Source/Kernel/VTManager/PipeVT.class.h2
-rw-r--r--Source/Kernel/VTManager/ScrollableVT.class.h7
-rw-r--r--Source/Kernel/VTManager/SimpleVT.class.cpp62
-rw-r--r--Source/Kernel/VTManager/SimpleVT.class.h19
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp44
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.proto.cpp13
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.proto.h16
10 files changed, 82 insertions, 99 deletions
diff --git a/Source/Kernel/VTManager/FileVT.class.cpp b/Source/Kernel/VTManager/FileVT.class.cpp
index 24a1b63..d0f564f 100644
--- a/Source/Kernel/VTManager/FileVT.class.cpp
+++ b/Source/Kernel/VTManager/FileVT.class.cpp
@@ -11,10 +11,12 @@ FileVT::FileVT(String filename, u8int mode, FSNode *start, u8int encoding) :
}
}
-void FileVT::setCursorCol(u32int col) {
+void FileVT::handleEscape(mvt_esc_cmd_t cmd) {
if (!m_isWriting) return;
- while (m_buffer.size() < col) {
- put(" ");
+ if (cmd.cmd == MVTCMD_SETCSRCOL) {
+ while ((int)m_buffer.size() < cmd.a) {
+ put(" ");
+ }
}
}
diff --git a/Source/Kernel/VTManager/FileVT.class.h b/Source/Kernel/VTManager/FileVT.class.h
index a246ce0..407297c 100644
--- a/Source/Kernel/VTManager/FileVT.class.h
+++ b/Source/Kernel/VTManager/FileVT.class.h
@@ -15,7 +15,7 @@ class FileVT : public VirtualTerminal {
FileVT(String filename, u8int mode = FM_READ, FSNode* start = 0, u8int encoding = UE_UTF8);
bool isBoxed() { return false; }
- void setCursorCol(u32int col);
+ void handleEscape(mvt_esc_cmd_t cmd);
void put(WChar c, bool updatecsr = true);
keypress_t getKeypress(bool show = true, bool block = true);
diff --git a/Source/Kernel/VTManager/PipeVT.class.cpp b/Source/Kernel/VTManager/PipeVT.class.cpp
index f4a5ca9..e6384f5 100644
--- a/Source/Kernel/VTManager/PipeVT.class.cpp
+++ b/Source/Kernel/VTManager/PipeVT.class.cpp
@@ -5,9 +5,11 @@ PipeVT::PipeVT() {
m_col = 0;
}
-void PipeVT::setCursorCol(u32int col) {
- while (col > m_col) {
- put(" ");
+void PipeVT::handleEscape(mvt_esc_cmd_t cmd) {
+ if (cmd.cmd == MVTCMD_SETCSRCOL) {
+ while (cmd.a > (int)m_col) {
+ put(" ");
+ }
}
}
diff --git a/Source/Kernel/VTManager/PipeVT.class.h b/Source/Kernel/VTManager/PipeVT.class.h
index 3c9521d..e39589f 100644
--- a/Source/Kernel/VTManager/PipeVT.class.h
+++ b/Source/Kernel/VTManager/PipeVT.class.h
@@ -11,7 +11,7 @@ class PipeVT : public VirtualTerminal {
PipeVT();
bool isBoxed() { return false; }
- void setCursorCol(u32int col);
+ void handleEscape(mvt_esc_cmd_t cmd);
void put(WChar c, bool updatecsr = true);
};
diff --git a/Source/Kernel/VTManager/ScrollableVT.class.h b/Source/Kernel/VTManager/ScrollableVT.class.h
index 6d29645..ce31225 100644
--- a/Source/Kernel/VTManager/ScrollableVT.class.h
+++ b/Source/Kernel/VTManager/ScrollableVT.class.h
@@ -9,14 +9,15 @@ class ScrollableVT : public SimpleVT {
u32int m_keeprows;
u32int m_linesup;
+ void updateCursor();
+ void redraw();
+ void scroll();
+
public:
ScrollableVT(u32int rows, u32int cols, u32int keepRows, u8int fgcolor = 7, u8int bgcolor = 0);
virtual ~ScrollableVT();
virtual void putChar(u32int row, u32int col, WChar c);
- void updateCursor();
- void redraw();
- void scroll();
void keyPress(keypress_t kp);
};
diff --git a/Source/Kernel/VTManager/SimpleVT.class.cpp b/Source/Kernel/VTManager/SimpleVT.class.cpp
index 28f9f98..a3e9600 100644
--- a/Source/Kernel/VTManager/SimpleVT.class.cpp
+++ b/Source/Kernel/VTManager/SimpleVT.class.cpp
@@ -10,7 +10,7 @@ SimpleVT::SimpleVT(u32int rows, u32int cols, u8int fgcolor, u8int bgcolor) : Vir
m_cols = cols;
m_mapped = false;
m_hideCursor = false;
- setColor(fgcolor, bgcolor);
+ m_color = ((bgcolor & 0x0F) << 4) | (fgcolor & 0x0F);
clear();
m_csrcol = 0;
@@ -22,14 +22,6 @@ SimpleVT::~SimpleVT() {
delete [] m_buff;
}
-void SimpleVT::setColor(u8int fgcolor, u8int bgcolor) {
- if (bgcolor == 0xFF) {
- m_color = (m_color & 0xF0) | fgcolor;
- } else {
- m_color = (bgcolor << 4) | fgcolor;
- }
-}
-
void SimpleVT::putChar(u32int row, u32int col, WChar c) {
if (row >= m_rows or col >= m_cols) return;
vtchr* ch = &BUFCHR(row, col);
@@ -92,23 +84,45 @@ void SimpleVT::updateCursor() {
Disp::moveCursor(m_csrlin + m_maprow, m_csrcol + m_mapcol);
}
-void SimpleVT::moveCursor(u32int row, u32int col) {
- m_csrlin = row;
- m_csrcol = col;
- updateCursor();
-}
-
-void SimpleVT::setCursorLine(u32int line) {
- m_csrlin = line;
- updateCursor();
-}
-
-void SimpleVT::setCursorCol(u32int col) {
- m_csrcol = col;
- updateCursor();
+//Command handling
+void SimpleVT::handleEscape(mvt_esc_cmd_t cmd) {
+ switch (cmd.cmd) {
+ case MVTCMD_CLEAR:
+ clear();
+ break;
+ case MVTCMD_SCROLL:
+ scroll();
+ break;
+ case MVTCMD_SETFGCOLOR:
+ m_color = (m_color & 0xF0) | (cmd.a & 0x0F);
+ break;
+ case MVTCMD_SETBGCOLOR:
+ m_color = (m_color & 0x0F) | ((cmd.a & 0x0F) << 4);
+ break;
+ case MVTCMD_SETCOLOR:
+ m_color = ((cmd.b & 0x0F) << 4) | (cmd.a & 0x0F);
+ break;
+ case MVTCMD_MOVECSR:
+ m_csrlin = cmd.a; m_csrcol = cmd.b;
+ updateCursor();
+ break;
+ case MVTCMD_SETCSRLIN:
+ m_csrlin = cmd.a;
+ updateCursor();
+ break;
+ case MVTCMD_SETCSRCOL:
+ m_csrcol = cmd.a;
+ updateCursor();
+ break;
+ case MVTCMD_HIDECSR:
+ m_hideCursor = true;
+ break;
+ case MVTCMD_SHOWCSR:
+ m_hideCursor = false;
+ break;
+ }
}
-
// Display functionn
void SimpleVT::put(WChar c, bool updatecsr) {
if (c.value == '\b') {
diff --git a/Source/Kernel/VTManager/SimpleVT.class.h b/Source/Kernel/VTManager/SimpleVT.class.h
index 8639a82..645e4c2 100644
--- a/Source/Kernel/VTManager/SimpleVT.class.h
+++ b/Source/Kernel/VTManager/SimpleVT.class.h
@@ -14,30 +14,27 @@ class SimpleVT : public VirtualTerminal {
u32int m_csrlin, m_csrcol;
+ virtual void updateCursor();
+ virtual void clear();
+ virtual void redraw();
+ virtual void scroll(); //Scrolls 1 line
+
public:
SimpleVT(u32int rows, u32int cols, u8int fgcolor = 7, u8int bgcolor = 0);
virtual ~SimpleVT();
virtual void putChar(u32int row, u32int col, WChar c);
- void clear();
- void setColor(u8int fgcolor, u8int bgcolor = 0xFF);
+
+ virtual void handleEscape(mvt_esc_cmd_t cmd);
+
bool isBoxed() { return true; }
u8int height() { return m_rows; }
u8int width() { return m_cols; }
u8int csrlin() { return m_csrlin; }
u8int csrcol() { return m_csrcol; }
- void hideCursor(bool hide = true) { m_hideCursor = hide; }
-
void map(s32int row = -1, s32int col = -1);
void unmap();
- virtual void redraw();
- virtual void scroll(); //Scrolls 1 line
-
- virtual void updateCursor();
- void moveCursor(u32int row, u32int col);
- void setCursorLine(u32int line);
- void setCursorCol(u32int col);
void put(WChar c, bool updatecsr = true);
diff --git a/Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp
index 47941c6..f8cf138 100644
--- a/Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp
+++ b/Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp
@@ -3,19 +3,13 @@
#include <TaskManager/Task.ns.h>
call_t VirtualTerminal::m_callTable[] = {
- CALL1(VTIF_WRITEHEX, &VirtualTerminal::writeHexSC),
- CALL2(VTIF_WRITEDEC, &VirtualTerminal::writeDecSC),
CALL1(VTIF_WRITE, &VirtualTerminal::writeSC),
CALL1(VTIF_PUT, &VirtualTerminal::putSC),
CALL1(VTIF_READLINE, &VirtualTerminal::readLineSC),
CALL1(VTIF_GETKEYPRESS, &VirtualTerminal::getKeypressSC),
- CALL1(VTIF_SETCOLOR, &VirtualTerminal::setColorSC),
- CALL1(VTIF_SETCSRLINE, &VirtualTerminal::setCursorLineSC),
- CALL1(VTIF_SETCSRCOL, &VirtualTerminal::setCursorColSC),
CALL0(VTIF_ISBOXED, &VirtualTerminal::isBoxedSC),
CALL0(VTIF_GETHEIGHT, &VirtualTerminal::getHeightSC),
CALL0(VTIF_GETWIDTH, &VirtualTerminal::getWidthSC),
- CALL2(VTIF_LOCATE, &VirtualTerminal::locateSC),
CALL0(0, 0)
};
@@ -25,19 +19,9 @@ u32int VirtualTerminal::scall(u8int wat, u32int a, u32int b, u32int c, u32int d)
return (u32int) - 1;
}
-u32int VirtualTerminal::writeHexSC(u32int number) {
- writeHex(number);
- return 0;
-}
-
-u32int VirtualTerminal::writeDecSC(u32int n_hi, u32int n_lo) {
- s64int n = ((u64int)n_hi << 32) | n_lo;
- writeDec(n);
- return 0;
-}
-
u32int VirtualTerminal::writeSC(u32int wat) {
String *s = (String*)wat;
+ //hexDump((u8int*)s->serialize(), s->size());
write(*s);
return 0;
}
@@ -59,21 +43,6 @@ u32int VirtualTerminal::getKeypressSC(u32int flags) {
return (u32int)ptr;
}
-u32int VirtualTerminal::setColorSC(u32int x) {
- setColor((x >> 8) & 0xFF, x & 0xFF);
- return 0;
-}
-
-u32int VirtualTerminal::setCursorLineSC(u32int l) {
- setCursorLine(l);
- return 0;
-}
-
-u32int VirtualTerminal::setCursorColSC(u32int c) {
- setCursorCol(c);
- return 0;
-}
-
u32int VirtualTerminal::isBoxedSC() {
return (isBoxed() ? 1 : 0);
}
@@ -85,14 +54,3 @@ u32int VirtualTerminal::getHeightSC() {
u32int VirtualTerminal::getWidthSC() {
return width();
}
-
-u32int VirtualTerminal::locateSC(u32int line, u32int col) {
- if (line < 1000 and col < 1000) {
- moveCursor(line, col);
- } else if (line < 1000) {
- setCursorLine(line);
- } else if (col < 1000) {
- setCursorCol(line);
- }
- return 0;
-}
diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp
index 34c10d0..39c21e3 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.proto.cpp
+++ b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp
@@ -3,8 +3,6 @@
#include <VTManager/VT.ns.h>
#include <TaskManager/Task.ns.h>
-#include <VirtualTerminal.iface.h>
-
VirtualTerminal::VirtualTerminal() :
Ressource(VTIF_OBJTYPE, m_callTable), m_kbdMutex(false), m_kbdbuff() {
m_kbdbuffStart = 0;
@@ -16,7 +14,16 @@ VirtualTerminal::~VirtualTerminal() {
void VirtualTerminal::write(const String& s, bool updatecsr) {
for (u32int i = 0; i < s.size(); i++) {
- put(s[i], false);
+ if (s[i] == WChar(MVT_ESC)) {
+ mvt_esc_cmd_t cmd;
+ cmd.cmd = s[i + 1];
+ cmd.a = s[i + 2];
+ cmd.b = s[i + 3];
+ i += 3;
+ handleEscape(cmd);
+ } else {
+ put(s[i], false);
+ }
}
if (updatecsr) updateCursor();
}
diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.h b/Source/Kernel/VTManager/VirtualTerminal.proto.h
index ceb994c..1505d3b 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.proto.h
+++ b/Source/Kernel/VTManager/VirtualTerminal.proto.h
@@ -7,6 +7,8 @@
#include <DeviceManager/Kbd.ns.h>
#include <Vector.class.h>
+#include <VirtualTerminal.iface.h>
+
#include <SyscallManager/Ressource.class.h>
struct vtchr {
@@ -39,34 +41,34 @@ class VirtualTerminal : public Ressource {
u32int locateSC(u32int, u32int);
bool accessible() { return true; }
+ //Internal use
+ virtual void updateCursor() {}
+
public:
static u32int scall(u8int, u32int, u32int, u32int, u32int);
VirtualTerminal();
virtual ~VirtualTerminal();
- virtual void setColor(u8int fgcolor, u8int bgcolor = 0xFF) {} //For a pipe/file VT, this will do nothing.
virtual bool isBoxed() = 0;
virtual u8int height() { return 0; }
virtual u8int width() { return 0; }
- virtual void updateCursor() {}
- virtual void moveCursor(u32int row, u32int col) {} //These are not implemented for pipe/file VTs
- virtual void setCursorLine(u32int line) {}
- virtual void setCursorCol(u32int col) {} //This one could be, and should be. It's used a lot for tabulating, etc.
+ virtual void handleEscape(mvt_esc_cmd_t cmd) = 0;
//Display functions
virtual void put(WChar c, bool updatecsr = true) = 0;
void write(const String& s, bool updatecsr = true);
+
+ //Display functions for kernel use
void writeDec(s64int num, bool updatecsr = true);
void writeHex(u32int i, bool updatecsr = true);
-
virtual void hexDump(u8int* ptr, u32int sz, bool addnl = true); //Always ignore parameter addnl
-
inline VirtualTerminal& operator<<(const String& s) { write(s); return *this; }
inline VirtualTerminal& operator<<(s32int i) { writeDec(i); return *this; }
inline VirtualTerminal& operator<<(s64int i) { writeDec(i); return *this; }
inline VirtualTerminal& operator<<(u32int i) { writeHex(i); return *this; }
+ inline VirtualTerminal& operator<<(mvt_esc_cmd_t cmd) { handleEscape(cmd); return *this; }
//Keyboard functions
virtual void keyPress(keypress_t kp); //Called by Kbd:: when a key is pressed, overloaded by ScrollableVT