1 #ifndef __WINDOWS_H
2 #define __WINDOWS_H
3 
4 #include "window-item-def.h"
5 #include "command-history.h"
6 
7 enum {
8         DATA_LEVEL_NONE = 0,
9 	DATA_LEVEL_TEXT,
10 	DATA_LEVEL_MSG,
11         DATA_LEVEL_HILIGHT
12 };
13 
14 enum {
15 	MAIN_WINDOW_TYPE_NONE = -1,
16 	MAIN_WINDOW_TYPE_DEFAULT = 0,
17 	MAIN_WINDOW_TYPE_HIDDEN = 1,
18 	MAIN_WINDOW_TYPE_SPLIT = 2,
19 	MAIN_WINDOW_TYPE_RSPLIT = 3
20 };
21 
22 typedef struct {
23 	char *servertag;
24         char *name;
25 	int type;
26 	unsigned int sticky:1;
27 } WINDOW_BIND_REC;
28 
29 struct _WINDOW_REC {
30 	int refnum;
31 	char *name;
32 
33         int width, height;
34 
35 	GSList *items;
36 	WI_ITEM_REC *active;
37 	SERVER_REC *active_server;
38 	SERVER_REC *connect_server;
39         char *servertag; /* active_server must be either NULL or have this tag (unless there's items in this window) */
40 
41 	int level; /* message level */
42 	GSList *bound_items; /* list of WINDOW_BIND_RECs */
43 
44 	unsigned int immortal:1;
45 	unsigned int sticky_refnum:1;
46 	unsigned int destroying:1;
47 
48 	/* window-specific command line history */
49 	HISTORY_REC *history;
50 	char *history_name;
51 
52 	int data_level; /* current data level */
53 	char *hilight_color; /* current hilight color in %format */
54 
55 	time_t last_timestamp; /* When was last timestamp printed */
56 	time_t last_line; /* When was last line printed */
57 
58         char *theme_name; /* active theme in window, NULL = default */
59 	void *theme; /* THEME_REC */
60 
61 	void *gui_data;
62 };
63 
64 extern GSList *windows;
65 extern WINDOW_REC *active_win;
66 
67 WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic);
68 void window_destroy(WINDOW_REC *window);
69 
70 void window_auto_destroy(WINDOW_REC *window);
71 
72 void window_set_active(WINDOW_REC *window);
73 void window_change_server(WINDOW_REC *window, void *server);
74 
75 void window_set_refnum(WINDOW_REC *window, int refnum);
76 void window_set_name(WINDOW_REC *window, const char *name);
77 void window_set_history(WINDOW_REC *window, const char *name);
78 void window_clear_history(WINDOW_REC *window, const char *name);
79 void window_set_level(WINDOW_REC *window, int level);
80 void window_set_immortal(WINDOW_REC *window, int immortal);
81 
82 /* return active item's name, or if none is active, window's name */
83 const char *window_get_active_name(WINDOW_REC *window);
84 
85 WINDOW_REC *window_find_level(void *server, int level);
86 WINDOW_REC *window_find_closest(void *server, const char *name, int level);
87 WINDOW_REC *window_find_refnum(int refnum);
88 WINDOW_REC *window_find_name(const char *name);
89 WINDOW_REC *window_find_item(SERVER_REC *server, const char *name);
90 
91 int window_refnum_prev(int refnum, int wrap);
92 int window_refnum_next(int refnum, int wrap);
93 int windows_refnum_last(void);
94 
95 int window_refnum_cmp(WINDOW_REC *w1, WINDOW_REC *w2);
96 GSList *windows_get_sorted(void);
97 
98 /* Add a new bind to window - if duplicate is found it's returned */
99 WINDOW_BIND_REC *window_bind_add(WINDOW_REC *window, const char *servertag,
100 				 const char *name);
101 void window_bind_destroy(WINDOW_REC *window, WINDOW_BIND_REC *rec);
102 
103 WINDOW_BIND_REC *window_bind_find(WINDOW_REC *window, const char *servertag,
104 				  const char *name);
105 void window_bind_remove_unsticky(WINDOW_REC *window);
106 
107 void windows_init(void);
108 void windows_deinit(void);
109 
110 short color_24bit_256(const unsigned char rgb[]);
111 
112 #endif
113