diff options
author | Alexis211 <alexis211@gmail.com> | 2009-08-22 21:44:32 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-08-22 21:44:32 +0200 |
commit | 2582a11c37ccc22d64974b20b0793e5ba873fe1f (patch) | |
tree | 485565c0950f0355290690d3396bcb4c22774fd0 /Source/Kernel/VTManager | |
parent | 74e721676ddd5d996ccf2e1d35da57320f658609 (diff) | |
download | Melon-2582a11c37ccc22d64974b20b0793e5ba873fe1f.tar.gz Melon-2582a11c37ccc22d64974b20b0793e5ba873fe1f.zip |
Lots of stuff added : heap, timer, device managment, ...
Diffstat (limited to 'Source/Kernel/VTManager')
-rw-r--r-- | Source/Kernel/VTManager/VT.ns.cpp | 32 | ||||
-rw-r--r-- | Source/Kernel/VTManager/VT.ns.h | 14 | ||||
-rw-r--r-- | Source/Kernel/VTManager/VirtualTerminal.class.cpp | 18 | ||||
-rw-r--r-- | Source/Kernel/VTManager/VirtualTerminal.class.h | 1 |
4 files changed, 61 insertions, 4 deletions
diff --git a/Source/Kernel/VTManager/VT.ns.cpp b/Source/Kernel/VTManager/VT.ns.cpp new file mode 100644 index 0000000..76aeb47 --- /dev/null +++ b/Source/Kernel/VTManager/VT.ns.cpp @@ -0,0 +1,32 @@ +#include "VT.ns.h" +#include <Library/Vector.class.h> +#include <DeviceManager/Disp.ns.h> + +namespace VT { + +Vector<VirtualTerminal*> mappedVTs; + +void map(VirtualTerminal* vt) { + unmap(vt); //Bad things might happen + mappedVTs.push(vt); +} + +void unmap(VirtualTerminal* vt) { + for (u32int i = 0; i < mappedVTs.size(); i++) { + if (mappedVTs[i] == vt) { + mappedVTs[i] = mappedVTs.back(); + mappedVTs.pop(); + redrawScreen(); + return; + } + } +} + +void redrawScreen() { + Disp::clear(); + for (u32int i = 0; i < mappedVTs.size(); i++) { + mappedVTs[i]->redraw(); + } +} + +} diff --git a/Source/Kernel/VTManager/VT.ns.h b/Source/Kernel/VTManager/VT.ns.h new file mode 100644 index 0000000..9e6d3ba --- /dev/null +++ b/Source/Kernel/VTManager/VT.ns.h @@ -0,0 +1,14 @@ +#ifndef DEF_VT_NS_H +#define DEF_VT_NS_H + +#include <Core/common.wtf.h> +#include <VTManager/VirtualTerminal.class.h> + +namespace VT { + //These should be called only from inside class VirtualTerminal + void map(VirtualTerminal* vt); + void unmap(VirtualTerminal* vt); + void redrawScreen(); +} + +#endif diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.cpp b/Source/Kernel/VTManager/VirtualTerminal.class.cpp index 6478be4..a0c920b 100644 --- a/Source/Kernel/VTManager/VirtualTerminal.class.cpp +++ b/Source/Kernel/VTManager/VirtualTerminal.class.cpp @@ -1,7 +1,8 @@ #include "VirtualTerminal.class.h" -#include <DisplayManager/Disp.ns.h> +#include <DeviceManager/Disp.ns.h> +#include <VTManager/VT.ns.h> -#define BUFCHR(l, c) m_buff[(l * m_rows) + c] +#define BUFCHR(l, c) m_buff[((l) * m_cols) + (c)] VirtualTerminal::VirtualTerminal(u32int rows, u32int cols, u8int fgcolor, u8int bgcolor) { m_buff = new chr[rows * cols]; @@ -15,6 +16,11 @@ VirtualTerminal::VirtualTerminal(u32int rows, u32int cols, u8int fgcolor, u8int m_csrlin = 0; } +VirtualTerminal::~VirtualTerminal() { + if (m_mapped) VT::unmap(this); + delete [] m_buff; +} + void VirtualTerminal::setColor(u8int fgcolor, u8int bgcolor) { if (bgcolor == 0xFF) { m_color = (m_color & 0xF0) | fgcolor; @@ -24,6 +30,7 @@ void VirtualTerminal::setColor(u8int fgcolor, u8int bgcolor) { } void VirtualTerminal::putChar(u32int row, u32int col, char c) { + if (row >= m_rows or col >= m_cols) return; chr* ch = &BUFCHR(row, col); ch->c = c; ch->color = m_color; @@ -44,10 +51,12 @@ void VirtualTerminal::map(s32int row, s32int col) { m_mapcol = (col == -1 ? (Disp::textCols() / 2) - (m_cols / 2) : col); m_mapped = true; redraw(); + VT::map(this); } void VirtualTerminal::unmap() { m_mapped = false; + VT::unmap(this); } void VirtualTerminal::redraw() { @@ -68,7 +77,8 @@ void VirtualTerminal::scroll() { for (u32int c = 0; c < m_cols; c++) { BUFCHR(m_rows - 1, c).c = ' '; BUFCHR(m_rows - 1, c).color = m_color; - } + } + if (m_mapped) redraw(); } void VirtualTerminal::updateCursor() { @@ -112,7 +122,7 @@ void VirtualTerminal::put(char c, bool updatecsr) { m_csrcol = 0; m_csrlin++; } - if (m_csrlin >= m_rows) { + while (m_csrlin >= m_rows) { scroll(); m_csrlin--; } diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.h b/Source/Kernel/VTManager/VirtualTerminal.class.h index 801d009..61e78a7 100644 --- a/Source/Kernel/VTManager/VirtualTerminal.class.h +++ b/Source/Kernel/VTManager/VirtualTerminal.class.h @@ -21,6 +21,7 @@ class VirtualTerminal { public: VirtualTerminal(u32int rows, u32int cols, u8int fgcolor = 7, u8int bgcolor = 0); + ~VirtualTerminal(); void setColor(u8int fgcolor, u8int bgcolor = 0xFF); void putChar(u32int row, u32int col, char c); |