summaryrefslogtreecommitdiff
path: root/Source/Kernel/VTManager
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-09-20 15:39:34 +0200
committerAlexis211 <alexis211@gmail.com>2009-09-20 15:39:34 +0200
commita1ffeb45b310b2e0dd9ae6a40b13ccc447eb0ef6 (patch)
treec3bab20d08df521f2ffac84fdda628ee315e5b09 /Source/Kernel/VTManager
parente7fad609d7d7694ebd19212623a0334bd949c741 (diff)
downloadMelon-a1ffeb45b310b2e0dd9ae6a40b13ccc447eb0ef6.tar.gz
Melon-a1ffeb45b310b2e0dd9ae6a40b13ccc447eb0ef6.zip
Implemented PipeVT.
Diffstat (limited to 'Source/Kernel/VTManager')
-rw-r--r--Source/Kernel/VTManager/PipeVT.class.cpp35
-rw-r--r--Source/Kernel/VTManager/PipeVT.class.h18
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp2
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.proto.h2
4 files changed, 56 insertions, 1 deletions
diff --git a/Source/Kernel/VTManager/PipeVT.class.cpp b/Source/Kernel/VTManager/PipeVT.class.cpp
new file mode 100644
index 0000000..bcaa531
--- /dev/null
+++ b/Source/Kernel/VTManager/PipeVT.class.cpp
@@ -0,0 +1,35 @@
+#include "PipeVT.class.h"
+
+PipeVT::PipeVT() {
+ m_col = 0;
+}
+
+void PipeVT::setCursorCol(u32int col) {
+ while (col > m_col) {
+ put(' ');
+ }
+}
+
+void PipeVT::put(WChar c, bool updatecsr) {
+ Kbd::keypress_t kp;
+ if (c.value == '\t') {
+ m_col = (m_col + 8) &~(8 - 1);
+ kp.hascmd = true;
+ kp.command = KBDC_TAB;
+ } else if (c.value == '\n' or c.value == '\r') {
+ m_col = 0;
+ kp.hascmd = true;
+ kp.command = KBDC_ENTER;
+ } else if (c.value == '\b') {
+ kp.hascmd = true;
+ kp.command = KBDC_BACKSPACE;
+ } else {
+ kp.hascmd = false;
+ kp.haschar = true;
+ kp.character = c;
+ m_col++;
+ }
+ m_kbdbuffMutex.waitLock();
+ m_kbdbuff.push(kp);
+ m_kbdbuffMutex.unlock();
+}
diff --git a/Source/Kernel/VTManager/PipeVT.class.h b/Source/Kernel/VTManager/PipeVT.class.h
new file mode 100644
index 0000000..3c9521d
--- /dev/null
+++ b/Source/Kernel/VTManager/PipeVT.class.h
@@ -0,0 +1,18 @@
+#ifndef DEF_PIPEVT_CLASS_H
+#define DEF_PIPEVT_CLASS_H
+
+#include <VTManager/VirtualTerminal.proto.h>
+
+class PipeVT : public VirtualTerminal {
+ protected:
+ u32int m_col;
+
+ public:
+ PipeVT();
+
+ bool isBoxed() { return false; }
+ void setCursorCol(u32int col);
+ void put(WChar c, bool updatecsr = true);
+};
+
+#endif
diff --git a/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp
index 1797554..ef95615 100644
--- a/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp
+++ b/Source/Kernel/VTManager/VirtualTerminal-kbd.proto.cpp
@@ -63,6 +63,8 @@ String VirtualTerminal::readLine(bool show) {
if (tmp.hascmd && !tmp.haschar && tmp.command == KBDC_BACKSPACE) {
if (!ret.empty()) ret = ret.substr(0, ret.size() - 1);
else put(" "); //Put a space so that cursor stays at same place
+ } else if (tmp.hascmd && !tmp.haschar && tmp.command == KBDC_TAB) {
+ ret += "\t";
} else if (tmp.haschar && !tmp.hascmd) {
ret += tmp.character;
}
diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.h b/Source/Kernel/VTManager/VirtualTerminal.proto.h
index bd38d89..ea6284f 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.proto.h
+++ b/Source/Kernel/VTManager/VirtualTerminal.proto.h
@@ -44,7 +44,7 @@ class VirtualTerminal {
//Keyboard functions
virtual void keyPress(Kbd::keypress_t kp); //Called by Kbd:: when a key is pressed, overloaded by ScrollableVT
- Kbd::keypress_t getKeypress(bool show = true, bool block = true); //Block : must we wait for a key to be pressed ?
+ virtual Kbd::keypress_t getKeypress(bool show = true, bool block = true); //Block : must we wait for a key to be pressed ?
String readLine(bool show = true);
};