updates.
[crypto.git] / apps / irssi / src / fe-common / core / fe-windows.h
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 typedef struct {
15         char *servertag;
16         char *name;
17         unsigned int sticky:1;
18 } WINDOW_BIND_REC;
19
20 struct _WINDOW_REC {
21         int refnum;
22         char *name;
23
24         int width, height;
25
26         GSList *items;
27         WI_ITEM_REC *active;
28         SERVER_REC *active_server;
29         char *servertag; /* active_server must be either NULL or have this tag (unless there's items in this window) */
30
31         int level; /* message level */
32         GSList *bound_items; /* list of WINDOW_BIND_RECs */
33
34         unsigned int immortal:1;
35         unsigned int sticky_refnum:1;
36         unsigned int destroying:1;
37
38         /* window-specific command line history */
39         HISTORY_REC *history;
40         char *history_name;
41
42         int data_level; /* current data level */
43         char *hilight_color; /* current hilight color in %format */
44
45         time_t last_timestamp; /* When was last timestamp printed */
46         time_t last_line; /* When was last line printed */
47
48         char *theme_name; /* active theme in window, NULL = default */
49         void *theme; /* THEME_REC */
50
51         void *gui_data;
52 };
53
54 extern GSList *windows;
55 extern WINDOW_REC *active_win;
56
57 WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic);
58 void window_destroy(WINDOW_REC *window);
59
60 void window_auto_destroy(WINDOW_REC *window);
61
62 void window_set_active(WINDOW_REC *window);
63 void window_change_server(WINDOW_REC *window, void *server);
64
65 void window_set_refnum(WINDOW_REC *window, int refnum);
66 void window_set_name(WINDOW_REC *window, const char *name);
67 void window_set_history(WINDOW_REC *window, const char *name);
68 void window_set_level(WINDOW_REC *window, int level);
69 void window_set_immortal(WINDOW_REC *window, int immortal);
70
71 /* return active item's name, or if none is active, window's name */
72 char *window_get_active_name(WINDOW_REC *window);
73
74 WINDOW_REC *window_find_level(void *server, int level);
75 WINDOW_REC *window_find_closest(void *server, const char *name, int level);
76 WINDOW_REC *window_find_refnum(int refnum);
77 WINDOW_REC *window_find_name(const char *name);
78 WINDOW_REC *window_find_item(SERVER_REC *server, const char *name);
79
80 int window_refnum_prev(int refnum, int wrap);
81 int window_refnum_next(int refnum, int wrap);
82 int windows_refnum_last(void);
83
84 int window_refnum_cmp(WINDOW_REC *w1, WINDOW_REC *w2);
85 GSList *windows_get_sorted(void);
86
87 /* Add a new bind to window - if duplicate is found it's returned */
88 WINDOW_BIND_REC *window_bind_add(WINDOW_REC *window, const char *servertag,
89                                  const char *name);
90 void window_bind_destroy(WINDOW_REC *window, WINDOW_BIND_REC *rec);
91
92 WINDOW_BIND_REC *window_bind_find(WINDOW_REC *window, const char *servertag,
93                                   const char *name);
94 void window_bind_remove_unsticky(WINDOW_REC *window);
95
96 void windows_init(void);
97 void windows_deinit(void);
98
99 #endif