Mercurial > hg > nnchat
comparison ui.h @ 513:ef5a2aa8382b
Refactor input handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 05 Jun 2012 22:16:42 +0300 |
parents | 942eea564b15 |
children | 44f67ec5e945 |
comparison
equal
deleted
inserted
replaced
512:93c8ba1ef55f | 513:ef5a2aa8382b |
---|---|
5 */ | 5 */ |
6 #ifndef LIBNNUI_H | 6 #ifndef LIBNNUI_H |
7 #define LIBNNUI_H | 7 #define LIBNNUI_H |
8 | 8 |
9 #ifdef __WIN32 | 9 #ifdef __WIN32 |
10 #define SET_DELAY (0) | |
10 // Undefine because both windows.h and curses.h #define it | 11 // Undefine because both windows.h and curses.h #define it |
11 #undef MOUSE_MOVED | 12 #undef MOUSE_MOVED |
13 #else | |
14 #define SET_DELAY (5) | |
12 #endif | 15 #endif |
16 | |
13 #ifdef HAVE_NCURSES_H | 17 #ifdef HAVE_NCURSES_H |
14 #include <ncurses.h> | 18 #include <ncurses.h> |
15 #else | 19 #else |
16 #include <curses.h> | 20 #include <curses.h> |
17 #endif | 21 #endif |
18 #include "th_types.h" | 22 #include "th_types.h" |
19 #include "th_string.h" | 23 #include "th_string.h" |
20 | 24 #include "network.h" |
21 | 25 |
22 #define SET_MAX_WINDOWS (32) | 26 #define SET_MAX_WINDOWS (32) |
23 #define NN_BACKBUF_LEN (512) // Backbuffer size (in lines) | 27 #define NN_BACKBUF_LEN (512) // Backbuffer size (in lines) |
24 | 28 |
25 | 29 |
41 | 45 |
42 nn_line_t *line; | 46 nn_line_t *line; |
43 } nn_window_t; | 47 } nn_window_t; |
44 | 48 |
45 | 49 |
50 typedef struct | |
51 { | |
52 time_t prevKeepAlive; | |
53 BOOL insertMode, exitProg, isError, update, mask, done; | |
54 nn_conn_t *conn; | |
55 void (*debugMsg)(const char *fmt, ...); | |
56 } nn_editstate_t; | |
57 | |
58 | |
46 extern nn_window_t *currWin; | 59 extern nn_window_t *currWin; |
47 extern BOOL cursesInit; | 60 extern BOOL cursesInit; |
48 extern int scrHeight, scrWidth; | 61 extern int scrHeight, scrWidth; |
49 | 62 |
50 BOOL nnwin_init(int delay); | 63 BOOL nnwin_init(int delay); |
51 void nnwin_shutdown(); | 64 void nnwin_shutdown(); |
52 void nnwin_reset(void); | 65 void nnwin_reset(void); |
53 | 66 |
54 void nnwin_update(BOOL force, nn_editbuf_t *ebuf, char *optUserName, int optUserColor); | 67 void nnwin_update(BOOL force, BOOL mask, nn_editbuf_t *ebuf, char *optUserName, int optUserColor); |
55 | 68 |
56 nn_window_t * nnwin_main_window(); | 69 nn_window_t * nnwin_main_window(); |
57 nn_window_t * nnwin_get(const int index); | 70 nn_window_t * nnwin_get(const int index); |
58 nn_window_t * nnwin_find(const char *id); | 71 nn_window_t * nnwin_find(const char *id); |
59 void nnwin_set_current(nn_window_t *); | 72 void nnwin_set_current(nn_window_t *); |
60 | 73 |
61 BOOL nnwin_open(const char *name, BOOL curwin); | 74 BOOL nnwin_open(const char *name, BOOL curwin); |
62 void nnwin_close(nn_window_t *win); | 75 void nnwin_close(nn_window_t *win); |
63 | 76 |
64 int nnwin_print(nn_window_t *win, const char *fmt); | 77 int nnwin_print(nn_window_t *win, const char *fmt); |
65 char * nnwin_prompt_requester(const char *info, BOOL allowEmpty); | 78 |
79 void nnwin_input_process(nn_editbuf_t *editBuf, nn_editstate_t *editState, | |
80 BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *)); | |
81 | |
82 char * nnwin_prompt_requester(BOOL allowEmpty, nn_editstate_t *, | |
83 BOOL (*callback)(int, nn_editbuf_t *, nn_editstate_t *), | |
84 void (*update)(nn_editbuf_t *, nn_editstate_t *)); | |
66 | 85 |
67 #endif | 86 #endif |