diff --git a/Makefile b/Makefile index 21034d3..4894efc 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ $(BUILD) $(BIN): $(BUILD)/dorne.o: $(addprefix $(CLI)/, main.c) $(call mkobj,-Icursetree) -$(BUILD)/cursetree.o: $(addprefix $(CT)/, cursetree.c curse.c) +$(BUILD)/cursetree.o: $(addprefix $(CT)/, cursetree.c ncrswrap.c) $(call mkobj,) $(BUILD)/epty.o: $(addprefix $(CT)/, pty/child.c pty/epty.c pty/_pty.c) $(call mkobj,) diff --git a/cursetree/cursetree.c b/cursetree/cursetree.c index b179f86..8d80831 100644 --- a/cursetree/cursetree.c +++ b/cursetree/cursetree.c @@ -2,8 +2,7 @@ #include #include -#include "curse.h" -#include "ncurses.h" +#include "ncrswrap.h" #include "cursetree.h" /* Internal allocator method for crs_node structures. diff --git a/cursetree/cursetree.h b/cursetree/cursetree.h index 3418a0f..74d804f 100644 --- a/cursetree/cursetree.h +++ b/cursetree/cursetree.h @@ -1,5 +1,5 @@ -#ifndef DORNE_TREE_H -#define DORNE_TREE_H +#ifndef CURSETREE_CURSETREE_H +#define CURSETREE_CURSETREE_H #ifndef __NCURSES_H typedef struct _win_st WINDOW; @@ -60,4 +60,4 @@ void bifurcate_window_node(struct crs_node **const node, const enum crs_axis axis, const int invert_axis, const float ratio); -#endif /* DORNE_TREE_H */ +#endif /* CURSETREE_CURSETREE_H */ diff --git a/cursetree/curse.c b/cursetree/ncrswrap.c similarity index 97% rename from cursetree/curse.c rename to cursetree/ncrswrap.c index 0549c9a..9623447 100644 --- a/cursetree/curse.c +++ b/cursetree/ncrswrap.c @@ -1,9 +1,8 @@ #include #include -#include "curse.h" +#include "ncrswrap.h" -#define BASE_DELAY 1000000 #define CRS_LOCALE "en_US.UTF-8" /* Set ncurses terminal mode (buffering, character processing, diff --git a/cursetree/curse.h b/cursetree/ncrswrap.h similarity index 87% rename from cursetree/curse.h rename to cursetree/ncrswrap.h index f08d891..b73f4b5 100644 --- a/cursetree/curse.h +++ b/cursetree/ncrswrap.h @@ -1,5 +1,5 @@ -#ifndef DORNE_CURSE_H -#define DORNE_CURSE_H +#ifndef CURSETREE_NCRSWRAP_H +#define CURSETREE_NCRSWRAP_H /* libncurses with wide-character support. */ #include @@ -26,4 +26,4 @@ WINDOW *root_window(void); int resizemv_window(const int x, const int y, const int width, const int height, WINDOW *const win); -#endif /* DORNE_CURSE_H */ +#endif /* CURSETREE_NCRSWRAP_H */ diff --git a/cursetree/node.h b/cursetree/node.h new file mode 100644 index 0000000..bf789c3 --- /dev/null +++ b/cursetree/node.h @@ -0,0 +1,51 @@ +#ifndef CURSETREE_NODE_H +#define CURSETREE_NODE_H + +#ifndef __NCURSES_H +typedef struct _win_st WINDOW; +#endif /* __NCURSES_H */ + +#define NODE_CHILD_N 2 + +/* MACRO: + * Get widnow node start x,y coordinates, width, & height. + * void NODEDIMS(struct crs_node *node, struct crs_nodedims dims); + */ +#define GET_WNODEDIMS(dims, node) \ + (getbegyx((node)->win, dims.y, dims.x)); \ + getmaxyx((node)->win, dims.y, dims.x) + +enum crs_nodetype { + NODE_WINDOW, + NODE_ABSTRACT, +}; + +/* Stores a node's starting x,y coordinates, width, & height. + * NOTE: Intended for interfunction communication. + */ +struct crs_nodedims { + int x, y, width, height; +}; + +enum crs_axis { + AXIS_X, + AXIS_Y, +}; + +struct crs_node { + enum crs_nodetype type; + // union value depends on crs_node.type + union { + WINDOW *win; + struct { + enum crs_axis axis; + float ratio; + struct crs_nodedims *dims; + struct crs_node *child[NODE_CHILD_N]; + }; + }; +}; + +/* === External Interface === */ + +#endif /* CURSETREE_NODE_H */ diff --git a/cursetree/pty/_pty.h b/cursetree/pty/_pty.h index 3c80b95..652178f 100644 --- a/cursetree/pty/_pty.h +++ b/cursetree/pty/_pty.h @@ -1,5 +1,5 @@ -#ifndef DORNE_MKPTY_H -#define DORNE_MKPTY_H +#ifndef CURSETREE_PTY_H +#define CURSETREE_PTY_H #include #include @@ -27,4 +27,4 @@ int setptsxy(const unsigned short rows, const unsigned short cols, const int fds); int getptsxy(unsigned short *rows, unsigned short *cols, const int fds); -#endif /* DORNE_MKPTY_H */ +#endif /* CURSETREE_PTY_H */ diff --git a/cursetree/pty/child.h b/cursetree/pty/child.h index 6ec3978..294b1c3 100644 --- a/cursetree/pty/child.h +++ b/cursetree/pty/child.h @@ -1,5 +1,5 @@ -#ifndef DORNE_CHILD_H -#define DORNE_CHILD_H +#ifndef CURSETREE_CHILD_H +#define CURSETREE_CHILD_H #include @@ -11,4 +11,4 @@ struct d_child { int spawnchild(struct d_child *child); -#endif /* DORNE_CHILD_H */ +#endif /* CURSETREE_CHILD_H */ diff --git a/cursetree/pty/epty.h b/cursetree/pty/epty.h index 8dd18e4..fa013bb 100644 --- a/cursetree/pty/epty.h +++ b/cursetree/pty/epty.h @@ -1,8 +1,8 @@ -#ifndef DORNE_EPTY_H -#define DORNE_EPTY_H +#ifndef CURSETREE_EPTY_H +#define CURSETREE_EPTY_H #include pid_t forkepty(int *fdmx, int *fderr); -#endif /* DORNE_EPTY_H */ +#endif /* CURSETREE_EPTY_H */