]> git.mdlowis.com Git - archive/afm.git/commitdiff
separate aardvark module added
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 19 Jul 2014 17:47:04 +0000 (13:47 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 19 Jul 2014 17:47:04 +0000 (13:47 -0400)
source/aardvark.c [new file with mode: 0644]
source/aardvark.h [new file with mode: 0644]
source/main.c

diff --git a/source/aardvark.c b/source/aardvark.c
new file mode 100644 (file)
index 0000000..dee7a15
--- /dev/null
@@ -0,0 +1,36 @@
+#include "aardvark.h"
+#include <ncurses.h>
+
+typedef struct {
+    char a, b, c;
+} Triplet_T;
+
+static Triplet_T aadata[77] = {
+    {  0, 34, 14 }, {  1, 30, 22 }, {  2, 17,  2 }, {  2, 28, 26 },
+    {  3,  3,  2 }, {  3, 16,  4 }, {  3, 26, 30 }, {  4,  3,  3 }, {  4, 15,  5 }, {  4, 24, 33 },
+    {  5,  4,  3 }, {  5, 15,  5 }, {  5, 22, 37 }, {  6,  4,  5 }, {  6, 15, 45 },
+    {  7,  5,  5 }, {  7, 14, 47 }, {  8,  6,  5 }, {  8, 14, 48 }, {  9,  7,  6 }, {  9, 14, 48 },
+    { 10,  9, 54 }, { 11,  9, 54 }, { 12,  8, 56 }, { 13,  7,  5 }, { 13, 14, 50 },
+    { 14,  6, 58 }, { 15,  6, 59 }, { 16,  5, 60 }, { 17,  4, 12 }, { 17, 19, 39 }, { 17, 59,  6 },
+    { 18,  3, 10 }, { 18, 20, 17 }, { 18, 39,  9 }, { 18, 49,  7 }, { 18, 60,  5 },
+    { 19,  1, 10 }, { 19, 20, 17 }, { 19, 40,  8 }, { 19, 50,  6 }, { 19, 61,  5 },
+    { 20,  0,  8 }, { 20, 21, 15 }, { 20, 42,  6 }, { 20, 50,  6 }, { 20, 62,  4 },
+    { 21,  0,  7 }, { 21, 22,  5 }, { 21, 29,  7 }, { 21, 42,  5 }, { 21, 50,  5 }, { 21, 63,  4 },
+    { 22,  2,  3 }, { 22, 22,  5 }, { 22, 30,  6 }, { 22, 41,  5 }, { 22, 50,  6 }, { 22, 64,  3 },
+    { 23, 23,  5 }, { 23, 30,  7 }, { 23, 40,  5 }, { 23, 50,  6 }, { 23, 65,  4 },
+    { 24, 23,  5 }, { 24, 31,  6 }, { 24, 38,  7 }, { 24, 50,  6 }, { 24, 66,  4 },
+    { 25, 21,  6 }, { 25, 30, 14 }, { 25, 49,  7 }, { 25, 68,  2 },
+    { 26, 18,  8 }, { 26, 27, 15 }, { 26, 49,  7 }, { 27, 26,  6 }
+};
+
+void aardvark_draw(void) {
+    int row, col;
+    getmaxyx(stdscr, row, col);
+    int i;
+    int trips=sizeof(aadata)/sizeof(Triplet_T);
+    char* aardvark="############################################################";
+    for(i=0; i<trips; i++)
+        mvaddnstr(((row-28)/2)+aadata[i].a, (col-70)/2+aadata[i].b, aardvark, aadata[i].c);
+    refresh();
+}
+
diff --git a/source/aardvark.h b/source/aardvark.h
new file mode 100644 (file)
index 0000000..65f99eb
--- /dev/null
@@ -0,0 +1,12 @@
+/**
+  @file aardvark.h
+  @brief TODO: Describe this file
+  $Revision$
+  $HeadURL$
+  */
+#ifndef AARDVARK_H
+#define AARDVARK_H
+
+void aardvark_draw(void);
+
+#endif /* AARDVARK_H */
index ffd7ad686dd69f00a3ad1d96d09d25df772a572a..561f14b448d3182d6831ce3997b6eddbcc0f209c 100644 (file)
@@ -6,6 +6,8 @@
 #include <string.h>
 #include <sys/stat.h>
 
+#include "aardvark.h"
+
 typedef struct {
     int idx;
     char cwd[1024];
@@ -15,10 +17,6 @@ typedef struct {
     char* title;
 } Window_T;
 
-typedef struct {
-       char a, b, c;
-} Triplet_T;
-
 static bool Running = true;
 static bool Screen_Dirty = true;
 static bool Resized = true;
@@ -31,35 +29,7 @@ static bool AardvarkOn = false;
 static int TopBuffer = 2;
 static int BotBuffer = 2;
 
-static Triplet_T aadata[77] = {
-       {  0, 34, 14 }, {  1, 30, 22 }, {  2, 17,  2 }, {  2, 28, 26 },
-       {  3,  3,  2 }, {  3, 16,  4 }, {  3, 26, 30 }, {  4,  3,  3 }, {  4, 15,  5 }, {  4, 24, 33 },
-       {  5,  4,  3 }, {  5, 15,  5 }, {  5, 22, 37 }, {  6,  4,  5 }, {  6, 15, 45 },
-       {  7,  5,  5 }, {  7, 14, 47 }, {  8,  6,  5 }, {  8, 14, 48 }, {  9,  7,  6 }, {  9, 14, 48 },
-       { 10,  9, 54 }, { 11,  9, 54 }, { 12,  8, 56 }, { 13,  7,  5 }, { 13, 14, 50 },
-       { 14,  6, 58 }, { 15,  6, 59 }, { 16,  5, 60 }, { 17,  4, 12 }, { 17, 19, 39 }, { 17, 59,  6 },
-       { 18,  3, 10 }, { 18, 20, 17 }, { 18, 39,  9 }, { 18, 49,  7 }, { 18, 60,  5 },
-       { 19,  1, 10 }, { 19, 20, 17 }, { 19, 40,  8 }, { 19, 50,  6 }, { 19, 61,  5 },
-       { 20,  0,  8 }, { 20, 21, 15 }, { 20, 42,  6 }, { 20, 50,  6 }, { 20, 62,  4 },
-       { 21,  0,  7 }, { 21, 22,  5 }, { 21, 29,  7 }, { 21, 42,  5 }, { 21, 50,  5 }, { 21, 63,  4 },
-       { 22,  2,  3 }, { 22, 22,  5 }, { 22, 30,  6 }, { 22, 41,  5 }, { 22, 50,  6 }, { 22, 64,  3 },
-       { 23, 23,  5 }, { 23, 30,  7 }, { 23, 40,  5 }, { 23, 50,  6 }, { 23, 65,  4 },
-       { 24, 23,  5 }, { 24, 31,  6 }, { 24, 38,  7 }, { 24, 50,  6 }, { 24, 66,  4 },
-       { 25, 21,  6 }, { 25, 30, 14 }, { 25, 49,  7 }, { 25, 68,  2 },
-       { 26, 18,  8 }, { 26, 27, 15 }, { 26, 49,  7 }, { 27, 26,  6 }
-};
-
-void draw_aardvark(){
-       int row, col;
-       getmaxyx(stdscr, row, col);
-       int i;
-       int trips=sizeof(aadata)/sizeof(Triplet_T);
-       char* aardvark="############################################################";
-       for(i=0; i<trips; i++)
-               mvaddnstr(((row-28)/2)+aadata[i].a, (col-70)/2+aadata[i].b, aardvark, aadata[i].c);
-       refresh();
-}
-bool is_dir(char* path){
+bool is_dir(char* path) {
     struct stat s;
     if( stat(path, &s) == 0){
         return (s.st_mode & S_IFDIR);
@@ -136,7 +106,7 @@ void list_files(int windex) {
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
     attron(A_UNDERLINE);
-    mvaddnstr(1, 1, &Windows[windex].cwd, cols-2);
+    mvaddnstr(1, 1, Windows[windex].cwd, cols-2);
     attroff(A_UNDERLINE);
     while (Windows[windex].files[i] != 0){
         if(i==Windows[windex].idx){
@@ -182,7 +152,7 @@ void update_screen(void) {
     clear();
     //should probably redraw all, but since only one window exists, it doesn't matter
     list_files(FocusedWindex);
-    if(AardvarkOn) draw_aardvark();
+    if(AardvarkOn) aardvark_draw();
     /* Draw the Border */
     mvaddch(0,       0,      ACS_ULCORNER);
     mvhline(0,       1,      ACS_HLINE, COLS-2);
@@ -227,11 +197,11 @@ void init_window_t(windex){
     Windows[windex].idx = 0;
     getcwd(Windows[windex].cwd, 1024);
 }
-    
+
 int main(int argc, char** argv) {
     init_window_t(0);
     /* Handle terminal resizing */
-    signal(SIGWINCH, handle_signal);
+    //signal(SIGWINCH, handle_signal);
     /* Initialize ncurses and user input settings */
     initscr();
     raw();