From 616951a353caf398908e6e6ce7dddf34a65513e5 Mon Sep 17 00:00:00 2001 From: jonas Date: Wed, 26 Dec 2018 21:18:09 +0100 Subject: Added cInput input handler class cRender: +setConsoleCursor(bool) to disable console cursor main: Example workign with cInput cInput: Input handler class --- AmpelJonas/cRender.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'AmpelJonas/cRender.cpp') diff --git a/AmpelJonas/cRender.cpp b/AmpelJonas/cRender.cpp index bc271b8..6d7a70a 100644 --- a/AmpelJonas/cRender.cpp +++ b/AmpelJonas/cRender.cpp @@ -23,6 +23,8 @@ cRender::cRender(char _backound, WORD _color, int _sx, int _sy) if(sizeX < _sx || sizeY < _sy) //Notify Program tha screen is too small for desired Size iLastError = _ERR_SCREEN_TOO_SMALL_; + setConsoleCursor(false); + #elif _WIN32 //Windows Specific Code hstdout = GetStdHandle(STD_OUTPUT_HANDLE); //get handle @@ -54,6 +56,12 @@ cRender::~cRender() free(cScreen); free(wColor); free(bChanged); + + setConsoleEcho(true); + + #ifdef __linux__ + setConsoleCursor(true); + #endif } int cRender::drawPoint(char _c, sPos _pos, bool _overrideCollision, WORD _color) @@ -185,7 +193,7 @@ int cRender::clear(bool _forceReRender) int cRender::clear() { - return clear(false); //false doesn't work! + return clear(false); } @@ -336,3 +344,8 @@ void cRender::setConsoleEcho(bool _enable) (void) tcsetattr(STDIN_FILENO, TCSANOW, &tty); #endif } + +void cRender::setConsoleCursor(bool _enable) +{ + _enable ? write (STDOUT_FILENO, "\e[?25h", 6) : write (STDOUT_FILENO, "\e[?25l", 6); +} -- cgit v1.2.3