Mercurial > hg > nnchat
diff ui.h @ 466:796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 26 May 2012 06:56:18 +0300 |
parents | |
children | 607bd4491e79 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui.h Sat May 26 06:56:18 2012 +0300 @@ -0,0 +1,63 @@ +/* + * NNChat - Custom chat client for NewbieNudes.com chatrooms + * Written by Matti 'ccr' Hämäläinen + * (C) Copyright 2008-2012 Tecnic Software productions (TNSP) + */ +#ifndef LIBNNUI_H +#define LIBNNUI_H + +#include "th_types.h" +#include "th_string.h" + +#ifdef HAVE_NCURSES_H +#include <ncurses.h> +#else +#include <curses.h> +#endif + + +#define SET_MAX_WINDOWS (32) +#define NN_BACKBUF_LEN (512) // Backbuffer size (in lines) + +typedef struct +{ + qringbuf_t *data; // "Backbuffer" data for this window + int pos; // Current position in the window, 0 = real time + BOOL dirty; + + char *id; // Chatter ID, NULL = main window + int num; // Window number + + char *buf; + size_t len, bufsize; + size_t chlen; +} nn_window_t; + + +extern nn_window_t *currWin; +extern BOOL cursesInit; +extern WINDOW *mainWin, *statusWin, *editWin; + +BOOL nnwin_init(int delay); +void nnwin_shutdown(); + +BOOL nnwin_init_windows(void); +void nnwin_close_windows(void); + +nn_window_t *nnwin_main_window(); +nn_window_t *nnwin_get(const int index); +nn_window_t *nnwin_find(const char *id); + +BOOL nnwin_open(const char *name, BOOL curwin); +void nnwin_close(nn_window_t *win); + +void nnwin_update_statusline(char *optUserName, int optUserColor); +void nnwin_update_editbuf(nn_editbuf_t *buf); +int nnwin_print(WINDOW *win, const char *fmt); +int nnwin_print_buf(nn_window_t *win, const char *fmt); +void nnwin_update_all(void); +char * nnwin_prompt_requester(WINDOW *win, const char *info, BOOL allowEmpty); +BOOL nnwin_update_main(BOOL force); + + +#endif