Mercurial > hg > nnchat
annotate ui.h @ 528:4c06bc545b1a dev-1_2_2
Bump version.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 06 Jun 2012 00:00:03 +0300 |
parents | ef5a2aa8382b |
children | 44f67ec5e945 |
rev | line source |
---|---|
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * NNChat - Custom chat client for NewbieNudes.com chatrooms |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Written by Matti 'ccr' Hämäläinen |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * (C) Copyright 2008-2012 Tecnic Software productions (TNSP) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 */ |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 #ifndef LIBNNUI_H |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 #define LIBNNUI_H |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
468 | 9 #ifdef __WIN32 |
513 | 10 #define SET_DELAY (0) |
468 | 11 // Undefine because both windows.h and curses.h #define it |
12 #undef MOUSE_MOVED | |
513 | 13 #else |
14 #define SET_DELAY (5) | |
468 | 15 #endif |
513 | 16 |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 #ifdef HAVE_NCURSES_H |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 #include <ncurses.h> |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 #else |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 #include <curses.h> |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 #endif |
468 | 22 #include "th_types.h" |
23 #include "th_string.h" | |
513 | 24 #include "network.h" |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
26 #define SET_MAX_WINDOWS (32) |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 #define NN_BACKBUF_LEN (512) // Backbuffer size (in lines) |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
29 |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
30 typedef struct |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
31 { |
504
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
32 int *buf; |
60e04709ce0f
Refactor window backbuffer to use integer as internal storage to simplify
Matti Hamalainen <ccr@tnsp.org>
parents:
501
diff
changeset
|
33 size_t len, bufsize; |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
34 } nn_line_t; |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
35 |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
36 |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 typedef struct |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 { |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 qringbuf_t *data; // "Backbuffer" data for this window |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 int pos; // Current position in the window, 0 = real time |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 BOOL dirty; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
43 int num; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 char *id; // Chatter ID, NULL = main window |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
46 nn_line_t *line; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 } nn_window_t; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 |
513 | 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 | |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 extern nn_window_t *currWin; |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 extern BOOL cursesInit; |
509
942eea564b15
Fix backbuffer offset manipulation, prevents a segfault.
Matti Hamalainen <ccr@tnsp.org>
parents:
504
diff
changeset
|
61 extern int scrHeight, scrWidth; |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
63 BOOL nnwin_init(int delay); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
64 void nnwin_shutdown(); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
65 void nnwin_reset(void); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 |
513 | 67 void nnwin_update(BOOL force, BOOL mask, nn_editbuf_t *ebuf, char *optUserName, int optUserColor); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
69 nn_window_t * nnwin_main_window(); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
70 nn_window_t * nnwin_get(const int index); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
71 nn_window_t * nnwin_find(const char *id); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
72 void nnwin_set_current(nn_window_t *); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
74 BOOL nnwin_open(const char *name, BOOL curwin); |
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
75 void nnwin_close(nn_window_t *win); |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 |
501
ca88945d8eda
Begin work on integrating the removal of ncurses "windowing" and transition
Matti Hamalainen <ccr@tnsp.org>
parents:
493
diff
changeset
|
77 int nnwin_print(nn_window_t *win, const char *fmt); |
513 | 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 *)); | |
466
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 |
796508f828f6
Refactor much of the "windowing" UI code into a new module, ui.[ch]
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 #endif |