From 163d9e65cb5f6269d731dc059693e1d1932655a5 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 16 Jul 2014 21:39:11 -0400 Subject: [PATCH] Added sources to gemfile.lock. Main now has two windows being created --- Gemfile.lock | 1 + source/main.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2f577eb..7248244 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,4 +1,5 @@ GEM + remote: https://rubygems.org/ specs: json (1.8.1) rake (10.3.2) diff --git a/source/main.c b/source/main.c index 45366f2..094a679 100644 --- a/source/main.c +++ b/source/main.c @@ -1,23 +1,49 @@ #include #include -bool Running = true; +static bool Running = true; +static WINDOW* WindowLeft; +static WINDOW* WindowRight; void handle_input(char ch) { if(ch == 'q') Running = false; } +WINDOW* create_window(int x, int y, int height, int width) { + WINDOW* p_win = newwin(height, width, y, x); + box(p_win, 0, 0); + wrefresh(p_win); + return p_win; +} + +void destroy_window(WINDOW* p_win) { + /* Erase remnants of the window */ + wborder(p_win, ' ', ' ', ' ',' ',' ',' ',' ',' '); + wrefresh(p_win); + /* Delete the window */ + delwin(p_win); +} + int main(int argc, char** argv) { + /* Initialize ncurses and user input settings */ initscr(); raw(); keypad(stdscr, TRUE); noecho(); - printw("Hello, World! Please Press 'q' to quit."); + refresh(); + /* Create the left and right windows */ + WindowLeft = create_window(0,0,20,20); + WindowRight = create_window(20,0,20,20); while(Running) { - refresh(); + wprintw(WindowLeft, "Left"); + wprintw(WindowRight, "Right"); + wrefresh(WindowLeft); + wrefresh(WindowRight); handle_input(getch()); } + destroy_window(WindowLeft); + destroy_window(WindowRight); endwin(); return 0; } -- 2.49.0