From 2d3c5a9c47d99c8f4f5561f9eae16497c1cde63a Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sun, 20 Dec 2009 16:13:44 +0100 Subject: Added file streams and string streams --- Source/Library/Userland/Binding/VirtualTerminal.class.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Source/Library/Userland/Binding') diff --git a/Source/Library/Userland/Binding/VirtualTerminal.class.h b/Source/Library/Userland/Binding/VirtualTerminal.class.h index 6576c1c..54bdc53 100644 --- a/Source/Library/Userland/Binding/VirtualTerminal.class.h +++ b/Source/Library/Userland/Binding/VirtualTerminal.class.h @@ -11,6 +11,9 @@ #include class VirtualTerminal : public RessourceCaller, public OStream, public IStream { + private: + bool m_eof; + public: static VirtualTerminal getIn() { u32int id = RessourceCaller::sCall(VTIF_OBJTYPE, VTIF_SGETPRINVT); @@ -20,7 +23,7 @@ class VirtualTerminal : public RessourceCaller, public OStream, public IStream { u32int id = RessourceCaller::sCall(VTIF_OBJTYPE, VTIF_SGETPROUTVT); return VirtualTerminal(id); } - VirtualTerminal(u32int id) : RessourceCaller(id, VTIF_OBJTYPE) {} + VirtualTerminal(u32int id) : RessourceCaller(id, VTIF_OBJTYPE) { m_eof = false; } /*void writeHex(u32int number) { doCall(VTIF_WRITEHEX, number); @@ -32,7 +35,13 @@ class VirtualTerminal : public RessourceCaller, public OStream, public IStream { doCall(VTIF_WRITE, (u32int)&s); } String read() { - return String::unserialize(doCall(VTIF_READLINE, 1)) += "\n"; + if (m_eof) return ""; + String ret = String::unserialize(doCall(VTIF_READLINE, 1)); + if (ret[ret.size() - 1] == WChar(EOF)) { + ret = ret.substr(0, ret.size() - 1); + m_eof = true; + } + return ret += "\n"; } keypress_t getKeypress(bool show = true, bool block = true) { keypress_t* ptr = (keypress_t*)doCall(VTIF_GETKEYPRESS, (show ? 1 : 0) | (block ? 2 : 0)); -- cgit v1.2.3