45 lines
671 B
C
45 lines
671 B
C
|
|
#include <math.h>
|
||
|
|
#include <unistd.h>
|
||
|
|
|
||
|
|
#include <ncurses.h>
|
||
|
|
|
||
|
|
#define BASE_DELAY 1000000
|
||
|
|
|
||
|
|
int main(int argc, char *argv[]) {
|
||
|
|
// Curses init
|
||
|
|
WINDOW *screen = initscr();
|
||
|
|
start_color();
|
||
|
|
nodelay(screen, 1);
|
||
|
|
cbreak();
|
||
|
|
noecho();
|
||
|
|
curs_set(0);
|
||
|
|
keypad(screen, TRUE);
|
||
|
|
|
||
|
|
// Color pairs
|
||
|
|
init_pair(1, COLOR_BLACK, COLOR_CYAN);
|
||
|
|
|
||
|
|
// Set background
|
||
|
|
wbkgd(screen, COLOR_PAIR(1));
|
||
|
|
|
||
|
|
attron(COLOR_PAIR(1));
|
||
|
|
attron(A_BOLD);
|
||
|
|
int counter = 0;
|
||
|
|
while (1) {
|
||
|
|
mvprintw(0, 0, "COUNTER %d", counter++);
|
||
|
|
refresh();
|
||
|
|
|
||
|
|
switch (getch()) {
|
||
|
|
case 'q':
|
||
|
|
goto end;
|
||
|
|
default:
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
usleep(BASE_DELAY);
|
||
|
|
}
|
||
|
|
|
||
|
|
end:
|
||
|
|
endwin();
|
||
|
|
return 0;
|
||
|
|
}
|