diff --git a/FemMonitor/bool.c b/FemMonitor/bool.c new file mode 100644 index 0000000..0f58f83 --- /dev/null +++ b/FemMonitor/bool.c @@ -0,0 +1,47 @@ +#include +#include + +#include "common.h" +#include "bool.h" + + +static WINDOW* window = NULL; +static int height; +static int width; +static int counter = 0; + +const double MAX_X = 38.13428976038013; +const double MIN_Y = -122.61858623117328; +const double MIN_X = 37.22568446282394; +const double MAX_Y = -121.59685781209097; + +void bool_init(WINDOW* win, int h, int w) +{ + window = win; + height = h; + width = w; + + mvwprintw(window, 0, START_COL, " Bool Ideas "); + wrefresh(window); +} + +double drand(double low,double high) +{ + srand((unsigned) time(NULL)); + return ((double)rand() * (high - low)) / (double)RAND_MAX + low; +} + +void* bool_refresh(void* arg) +{ + if (counter++ % 10 == 0) + { + double x = drand(MIN_X, MAX_X); + double y = drand(MIN_Y, MAX_Y); + mvwprintw(window, 2, START_COL, "%f, %f", x, y); + wrefresh(window); + } +} + +void bool_destroy() +{ +} diff --git a/FemMonitor/bool.h b/FemMonitor/bool.h new file mode 100644 index 0000000..172d46f --- /dev/null +++ b/FemMonitor/bool.h @@ -0,0 +1,10 @@ +#ifndef bool_h +#define bool_h + +#include + +void bool_init(WINDOW* win, int h, int w); +void* bool_refresh(void* arg); +void bool_destroy(void); + +#endif /* bool_h */ diff --git a/FemMonitor/company.c b/FemMonitor/company.c index ae7f5c1..fbf9684 100644 --- a/FemMonitor/company.c +++ b/FemMonitor/company.c @@ -104,12 +104,18 @@ void* company_refresh(void* arg) // clear line for (int i = START_COL; i < width - 1; ++i) mvwprintw(window, START_ROW+5, i, " "); - // print the funny reference - mvwprintw(window, START_ROW+5, START_COL, "%s", tagline); // say the funny reference char buf[1024]; sprintf(buf, "espeak \"%s\" >/dev/null 2>&1", tagline); system(buf); + // truncate reference + int max_length = width - 2*START_COL; + if (strlen(tagline) > max_length) + { + tagline[max_length] = 0; + } + // print the funny reference + mvwprintw(window, START_ROW+5, START_COL, "%s", tagline); } diff --git a/FemMonitor/main.c b/FemMonitor/main.c index 96ee6bb..e11ad68 100644 --- a/FemMonitor/main.c +++ b/FemMonitor/main.c @@ -13,6 +13,7 @@ #include #include +#include "bool.h" #include "booru.h" #include "common.h" #include "company.h" @@ -64,12 +65,15 @@ int main(int argc, const char* argv[]) // setup various status windows // the bottom windows will be one row shorter to fit the status line at the end - WINDOW* topleft = create_newwin(LINES/2, COLS, 0, 0); - WINDOW* botleft = create_newwin(LINES/2 - 1, COLS/2, LINES/2, 0); + WINDOW* topleft = create_newwin(LINES/3, COLS/2, 0, 0); + WINDOW* midleft = create_newwin(LINES/3, COLS/2, LINES/3, 0); + WINDOW* botleft = create_newwin(LINES/3 - 1, COLS/2, LINES*2/3, 0); + WINDOW* topright = create_newwin(LINES/2, COLS/2, 0, COLS/2); WINDOW* botright = create_newwin(LINES/2 - 1, COLS/2, LINES/2, COLS/2); - company_init(topleft, LINES/2, COLS); - mail_init(botleft, LINES/2 - 1, COLS/2); + company_init(topleft, LINES/3, COLS/2); + bool_init(midleft, LINES/3, COLS/2); + mail_init(botleft, LINES/3 - 1, COLS/2); booru_init(botright, LINES/2 - 1, COLS/2); time_t t; @@ -77,6 +81,7 @@ int main(int argc, const char* argv[]) char ch; while ((ch = tolower(getch())) != KEY_QUIT) { + bool_refresh(NULL); booru_refresh(NULL); mail_refresh(NULL); company_refresh(NULL); @@ -96,6 +101,7 @@ int main(int argc, const char* argv[]) } // cleanup everything + bool_destroy(); booru_destroy(); mail_destroy(); company_destroy();