Created
February 3, 2017 19:31
-
-
Save bitnetwork/5a22d33ba4178578f24646bc8a441611 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <curses.h> | |
#include <term.h> | |
static char term_buffer[2048]; | |
void initTerminalData (void) { | |
char *termtype = getenv("TERM"); | |
int success; | |
success = tgetent(term_buffer, termtype); | |
if (termtype == NULL || success <= 0) { | |
printf("Error! $TERM isn't defined."); | |
} | |
} | |
void redraw (void) { | |
lines = tgetnum("li"); | |
for (int i=0; i<lines; i++) { | |
printf("\r\e[A"); | |
} | |
} | |
void reflash (void) { | |
lines = tgetnum("li"); | |
columns = tgetnum("co"); | |
for (int i=0; i<lines; i++) { | |
printf("\r\e[A"); | |
for (int j=0; j<columns; j++) { | |
printf(" "); | |
} | |
} | |
} | |
int main () { | |
initTerminalData(); | |
reflash(); | |
printf ("Got: Lines: %d, Columns: %d\n", tgetnum("li"), tgetnum("co")); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment