diff --git a/Makefile b/Makefile index 59b5879b..50af9839 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,13 @@ CC = gcc WARNS = -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-but-set-variable LIBS = -lxml2 -lssl -lresolv -lncurses -lstrophe CFLAGS = -O3 $(WARNS) $(LIBS) -OBJS = log.o profanity.o +OBJS = log.o windows.o profanity.o profanity: $(OBJS) $(CC) -o profanity $(OBJS) $(LIBS) log.o: log.h +windows.o: windows.h profanity.o: log.h .PHONY: clean diff --git a/log.h b/log.h index c8763cd6..1a5dad60 100644 --- a/log.h +++ b/log.h @@ -1,7 +1,6 @@ #ifndef LOG_H #define LOG_H -// log FILE *logp; xmpp_log_t *xmpp_get_file_logger(); diff --git a/profanity.c b/profanity.c index f770f2bf..732b8304 100644 --- a/profanity.c +++ b/profanity.c @@ -6,6 +6,7 @@ #include #include "log.h" +#include "windows.h" // refernce to log extern FILE *logp; @@ -13,11 +14,11 @@ extern FILE *logp; // area for log message in profanity static const char *prof = "prof"; -// static windows -static WINDOW *title_bar; -static WINDOW *cmd_bar; -static WINDOW *cmd_win; -static WINDOW *main_win; +// window references +extern WINDOW *title_bar; +extern WINDOW *cmd_bar; +extern WINDOW *cmd_win; +extern WINDOW *main_win; // message handlers int in_message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, @@ -30,18 +31,8 @@ void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status, // curses functions void init(void); -void create_title_bar(void); -void create_command_bar(void); -void create_command_window(void); -void create_main_window(void); - void event_loop(xmpp_ctx_t *ctx, xmpp_conn_t *conn); -struct receiver { - xmpp_ctx_t *ctx; - xmpp_conn_t *conn; -}; - int main(void) { char cmd[50]; @@ -269,41 +260,3 @@ void init(void) attron(A_BOLD); attron(COLOR_PAIR(1)); } - -void create_title_bar(void) -{ - char *title = "Profanity"; - - int rows, cols; - getmaxyx(stdscr, rows, cols); - - title_bar = newwin(1, cols, 0, 0); - wbkgd(title_bar, COLOR_PAIR(3)); - mvwprintw(title_bar, 0, 0, title); -} - -void create_command_bar(void) -{ - int rows, cols; - getmaxyx(stdscr, rows, cols); - - cmd_bar = newwin(1, cols, rows-2, 0); - wbkgd(cmd_bar, COLOR_PAIR(3)); -} - -void create_command_window(void) -{ - int rows, cols; - getmaxyx(stdscr, rows, cols); - - cmd_win = newwin(1, cols, rows-1, 0); -} - -void create_main_window(void) -{ - int rows, cols; - getmaxyx(stdscr, rows, cols); - - main_win = newwin(rows-3, cols, 1, 0); - scrollok(main_win, TRUE); -} diff --git a/windows.c b/windows.c new file mode 100644 index 00000000..967e0a4d --- /dev/null +++ b/windows.c @@ -0,0 +1,47 @@ +#include + +#include "windows.h" + +// window references +extern WINDOW *title_bar; +extern WINDOW *cmd_bar; +extern WINDOW *cmd_win; +extern WINDOW *main_win; + +void create_title_bar(void) +{ + char *title = "Profanity"; + + int rows, cols; + getmaxyx(stdscr, rows, cols); + + title_bar = newwin(1, cols, 0, 0); + wbkgd(title_bar, COLOR_PAIR(3)); + mvwprintw(title_bar, 0, 0, title); +} + +void create_command_bar(void) +{ + int rows, cols; + getmaxyx(stdscr, rows, cols); + + cmd_bar = newwin(1, cols, rows-2, 0); + wbkgd(cmd_bar, COLOR_PAIR(3)); +} + +void create_command_window(void) +{ + int rows, cols; + getmaxyx(stdscr, rows, cols); + + cmd_win = newwin(1, cols, rows-1, 0); +} + +void create_main_window(void) +{ + int rows, cols; + getmaxyx(stdscr, rows, cols); + + main_win = newwin(rows-3, cols, 1, 0); + scrollok(main_win, TRUE); +} diff --git a/windows.h b/windows.h new file mode 100644 index 00000000..e9960bb0 --- /dev/null +++ b/windows.h @@ -0,0 +1,16 @@ +#ifndef WINDOWS_H +#define WINDOWS_h + +// windows +WINDOW *title_bar; +WINDOW *cmd_bar; +WINDOW *cmd_win; +WINDOW *main_win; + +// window creation +void create_title_bar(void); +void create_command_bar(void); +void create_command_window(void); +void create_main_window(void); + +#endif