From a1ffeb45b310b2e0dd9ae6a40b13ccc447eb0ef6 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sun, 20 Sep 2009 15:39:34 +0200 Subject: Implemented PipeVT. --- Source/Kernel/VTManager/PipeVT.class.cpp | 35 ++++++++++++++++++++++ Source/Kernel/VTManager/PipeVT.class.h | 18 +++++++++++ .../Kernel/VTManager/VirtualTerminal-kbd.proto.cpp | 2 ++ Source/Kernel/VTManager/VirtualTerminal.proto.h | 2 +- 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 Source/Kernel/VTManager/PipeVT.class.cpp create mode 100644 Source/Kernel/VTManager/PipeVT.class.h (limited to 'Source/Kernel/VTManager') 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 + +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); }; -- cgit v1.2.3