Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ncurses.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define FALSE 0
- #define TRUE 1
- /*
- * GLOBAL VARIABLES
- */
- WINDOW *layer1, *layer2, *layertop, *layerbottom;
- char *TEXT_LIBRARY[2] =
- {
- "All Contacts",
- "Press tab to move the cursor across the program."
- };
- int scrX;
- int scrY;
- /*
- * FUNCTION DECLARATIONS
- */
- int checkScrSize();
- /* Prints the text at center of Window/Layer. Parameters: WINDOW*, the row number and the string */
- void wprintwc(WINDOW*, int, const char*);
- /*
- * FUNCTION DEFINATIONS
- */
- int checkScrSize()
- {
- getmaxyx(stdscr, scrY, scrX);
- if(scrX < 80 || scrY < 24)
- {
- printw("Please change you terminal size to atleast 80x24 and restart the program");
- return FALSE;
- }
- return TRUE;
- }
- void wprintwc(WINDOW *win, int textY, const char *text)
- {
- int length = strlen(text);
- int winX, winY, textX;
- getmaxyx(win, winY, winX);
- textX = (winX/2)-(length/2);
- mvwprintw(win, textY,textX, "%s", *text);
- }
- int main()
- {
- initscr();
- if (checkScrSize() == FALSE)
- {
- getch();
- endwin();
- exit(0);
- }
- refresh();
- /* Window/Layer Properties */
- layer1 = newwin(scrY-3, scrX/2, 1,0);
- box(layer1,0,0);
- layer2 = newwin(scrY-3, (scrX/2)-1, 1,(scrX/2)+1);
- box(layer2,0,0);
- wprintwc(layer1, 0, TEXT_LIBRARY[0]);
- /* Window/Layer Initialization */
- wrefresh(layer1);
- wrefresh(layer2);
- getch();
- endwin();
- }
Advertisement
Add Comment
Please, Sign In to add comment