mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Split out window functions
This commit is contained in:
parent
129f0fb0ae
commit
134e5d1701
3
Makefile
3
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
|
||||
|
1
log.h
1
log.h
@ -1,7 +1,6 @@
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
// log
|
||||
FILE *logp;
|
||||
|
||||
xmpp_log_t *xmpp_get_file_logger();
|
||||
|
59
profanity.c
59
profanity.c
@ -6,6 +6,7 @@
|
||||
#include <strophe/strophe.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
47
windows.c
Normal file
47
windows.c
Normal file
@ -0,0 +1,47 @@
|
||||
#include <ncurses.h>
|
||||
|
||||
#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);
|
||||
}
|
16
windows.h
Normal file
16
windows.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user