diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2019-01-07 20:02:46 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2019-01-07 20:02:46 +0100 |
commit | 0b58079fc74e87afb8473d93a8d9814fc48ef932 (patch) | |
tree | 1c0462901dcbc7b4cb6ea73903988a2dde6070c0 | |
parent | 8834bf3171080d133d250d42b4301bb8f9c777ae (diff) | |
download | termgl-0b58079fc74e87afb8473d93a8d9814fc48ef932.tar.gz |
included gotoxy() in escape sequence before char printing
Cursor position handling is now done together with setting the color and
printing the char
-rw-r--r-- | cRender.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/cRender.cpp b/cRender.cpp index 5354f1d..366e86f 100644 --- a/cRender.cpp +++ b/cRender.cpp @@ -153,25 +153,23 @@ int cRender::render(void) for (int i = 0; i < sizeY; i++) { for (int o = 0; o < sizeX; o++) { - gotoxy(o,i); //Moving this out of if fixed Render problem... Not optimal, though better for performance if(bChanged[o][i]) { #ifdef _WIN32 - + #error "Implement gotoxy!!" SetConsoleTextAttribute(hstdout, wColor[o][i] | _COL_INTENSITY); //cout << cScreen[o][i]; printf("%c", cScreen[o][i]); #elif __linux__ - //cout << "\033["<< wColor[o][i] <<"m"<< cScreen[o][i]; - printf("\033[%im%c", wColor[o][i], cScreen[o][i]); + //gotoxy(x,y) now included!! + printf("\e[%i;%iH\033[%im%c\n", i + 1, o + 1, wColor[o][i], cScreen[o][i]); + // Position Color #endif } bChanged[o][i] = false; } - } - return 0; } @@ -252,23 +250,14 @@ void cRender::gotoxy( int x, int y ) #elif __linux__ -void cRender::gotoxy( int x, int y ) -{ - int err; - if (!cur_term) - setupterm( NULL, STDOUT_FILENO, &err ); - putp( tparm( tigetstr( "cup" ), y, x, 0, 0, 0, 0, 0, 0, 0 ) ); -} - sPos cRender::getConsoleWindowSize() { struct winsize w; ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); - return {w.ws_col, w.ws_row}; + return {w.ws_col, w.ws_row - 1}; } #endif - void cRender::setBufferSize(sPos _size) { if(_size.x == sizeX && _size.y == sizeY) |