109 lines
1.7 KiB
C
109 lines
1.7 KiB
C
#include <curses.h>
|
|
#include <unistd.h>
|
|
|
|
#include "hacks.h"
|
|
|
|
/*
|
|
* Execute actual code and draw on the window.
|
|
* Should be called by a function that creates a window.
|
|
* Returns 0 if successful.
|
|
*/
|
|
int
|
|
dostuff(void)
|
|
{
|
|
/*
|
|
* Using unsafe strings right now, but should change this later to use
|
|
* malloc(), strcpy, the like.
|
|
*/
|
|
lstring_t msg;
|
|
|
|
struct xy max;
|
|
struct xy center;
|
|
|
|
getmaxyx(stdscr, max.y, max.x);
|
|
|
|
center.y = max.y * 0.5;
|
|
center.x = max.x * 0.5;
|
|
|
|
msg.s = "Hello, World!";
|
|
msg.l = 14;
|
|
//mvwprintw(stdscr, center.y, center.x - (msg.l * 0.5), msg.s); // gross
|
|
midprint(center.y, center.x, msg.l, msg.s);
|
|
refresh();
|
|
|
|
sleep(3);
|
|
|
|
msg.s = "You can leave in 3...";
|
|
msg.l = 21;
|
|
midprint(center.y, center.x, msg.l, msg.s);
|
|
refresh();
|
|
|
|
sleep(1);
|
|
|
|
msg.s = "You can leave in 2...";
|
|
msg.l = 21;
|
|
midprint(center.y, center.x, msg.l, msg.s);
|
|
refresh();
|
|
|
|
sleep(1);
|
|
|
|
msg.s = "You can leave in 1...";
|
|
msg.l = 21;
|
|
midprint(center.y, center.x, msg.l, msg.s);
|
|
refresh();
|
|
|
|
sleep(1);
|
|
|
|
msg.s = "Press Any Key to Leave";
|
|
msg.l = 22;
|
|
midprint(center.y, center.x, msg.l, msg.s);
|
|
refresh();
|
|
|
|
getch();
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Full lifetime of main window happens here.
|
|
* Returns 0 if successful after window closes.
|
|
*/
|
|
int
|
|
homewin(void)
|
|
{
|
|
int err, ret;
|
|
err = ret = 0;
|
|
|
|
initscr();
|
|
noecho();
|
|
cbreak();
|
|
keypad(stdscr, TRUE);
|
|
curs_set(0);
|
|
|
|
if (!has_colors()) {
|
|
endwin();
|
|
puts("err: no color");
|
|
return 1;
|
|
}
|
|
|
|
start_color();
|
|
init_pair(1, COLOR_BLACK, COLOR_MAGENTA);
|
|
|
|
attron(COLOR_PAIR(1));
|
|
|
|
/* Window Title */
|
|
mvwprintw(stdscr, 2, 2, "Test Program");
|
|
|
|
err = dostuff();
|
|
|
|
attroff(COLOR_PAIR(1));
|
|
endwin();
|
|
|
|
if (err) {
|
|
puts("err in dostuff()");
|
|
ret = 1;
|
|
}
|
|
|
|
return ret;
|
|
}
|