]> git.mdlowis.com Git - archive/afm.git/commitdiff
Tweaked drawing code
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 18 Jul 2014 22:26:00 +0000 (18:26 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 18 Jul 2014 22:26:00 +0000 (18:26 -0400)
source/main.c

index f01f251c37be45c92d7acc9ed85e0fec9739c517..9f67b1e8fd773ce20cf59d22493c1f599a429ab6 100644 (file)
@@ -1,5 +1,6 @@
 #include <ncurses.h>
 #include <stdbool.h>
+#include <stdlib.h>
 #include <signal.h>
 
 typedef struct {
@@ -8,76 +9,28 @@ typedef struct {
 
 static bool Running = true;
 static bool Screen_Dirty = true;
-Window_T Windows[2] = {
-    { "Left" },
-    { "Right" }
-};
-
-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);
-}
-
-/*
- * This routine draws a frame around a specified part of the console
- * screen, using special characters such as ACS_ULCORNER and ACS_VLINE.
- * The frame extends from startrow to endrow vertically and from
- * startcol to endcol horizontally.  (Rows and columns are numbered
- * starting from 0.)  Note that the interior of the frame extends
- * from startrow+1 to endrow-1 vertically and from startcol+1 to
- * endcol-1 horizontally.
- */
-void drawFrame(char* p_label, int startrow, int startcol, int endrow, int endcol) {
-   //int saverow, savecol;
-   //getyx(stdscr,saverow,savecol);
-   //mvaddch(startrow,startcol,ACS_ULCORNER);
-   //for (int i = startcol + 1; i < endcol; i++)
-   //   addch(ACS_HLINE);
-   //addch(ACS_URCORNER);
-   //for (int i = startrow +1; i < endrow; i++) {
-   //   mvaddch(i,startcol,ACS_VLINE);
-   //   mvaddch(i,endcol,ACS_VLINE);
-   //}
-   //mvaddch(endrow,startcol,ACS_LLCORNER);
-   //for (int i = startcol + 1; i < endcol; i++)
-   //   addch(ACS_HLINE);
-   //addch(ACS_LRCORNER);
-   //move(saverow,savecol);
-   //refresh();
-}
-
 void update_screen(void) {
-    int rows, cols;
+    /* Clear screen and update LINES and COLS */
     endwin();
     clear();
-    getmaxyx(stdscr,rows,cols);
-    //move(5,5);      printw("%d %d",rows,cols);
-    mvaddch(0,      0,      ACS_ULCORNER);
-    mvhline(0,      1,      ACS_HLINE, cols-2);
-    mvaddch(0,      cols-1, ACS_URCORNER);
-    mvvline(1,      0,      ACS_VLINE, rows-2);
-    mvaddch(rows-1, 0,      ACS_LLCORNER);
-    mvhline(rows-1, 1,      ACS_HLINE, cols-2);
-    mvaddch(rows-1, cols-1, ACS_LRCORNER);
-    mvvline(1,      cols-1, ACS_VLINE, rows-2);
+    /* Draw the Contents */
+    // TODO
+    /* Draw the Border */
+    mvaddch(0,       0,      ACS_ULCORNER);
+    mvhline(0,       1,      ACS_HLINE, COLS-2);
+    mvaddch(0,       COLS-1, ACS_URCORNER);
+    mvvline(1,       0,      ACS_VLINE, LINES-2);
+    mvaddch(LINES-1, 0,      ACS_LLCORNER);
+    mvhline(LINES-1, 1,      ACS_HLINE, COLS-2);
+    mvaddch(LINES-1, COLS-1, ACS_LRCORNER);
+    mvvline(1,       COLS-1, ACS_VLINE, LINES-2);
+    /* Refresh and mark complete */
     refresh();
     Screen_Dirty = false;
 }
@@ -101,8 +54,6 @@ int main(int argc, char** argv) {
         if(Screen_Dirty) update_screen();
         handle_input(getch());
     }
-    destroy_window(WindowLeft);
-    destroy_window(WindowRight);
     endwin();
     return 0;
 }