1 /* 2 * window.h: header file for window.c 3 * 4 * Copyright 1990 Michael Sandrof 5 * Copyright 1997 EPIC Software Labs 6 * 7 * See the COPYRIGHT file, or do a HELP IRCII COPYRIGHT 8 */ 9 10 #ifndef __window_h__ 11 #define __window_h__ 12 13 /* To get the definition of Lastlog */ 14 #include "lastlog.h" 15 16 /* To get the definition of Status */ 17 #include "status.h" 18 19 /* 20 * Screen and Window are mutually referencial. 21 * That means we cant include "screen.h", so we kind of fake it. 22 */ 23 struct ScreenStru; 24 25 /* var_settings indexes */ 26 #define OFF 0 27 #define ON 1 28 #define TOGGLE 2 29 30 /* Flags for "misc" */ 31 #define WINDOW_NOTIFY 1 << 0 32 #define WINDOW_NOTIFIED 1 << 1 33 34 35 /* Should be a way to make static to window.c */ 36 typedef struct DisplayStru 37 { 38 size_t count; 39 char *line; 40 struct DisplayStru *prev; 41 struct DisplayStru *next; 42 } Display; 43 44 typedef struct WNickListStru 45 { 46 struct WNickListStru *next; 47 char *nick; 48 } WNickList; 49 50 51 typedef struct WindowStru 52 { 53 unsigned refnum; /* Unique refnum for window */ 54 char *name; /* Logical name for window */ 55 int server; /* Server that win is connected to */ 56 int last_server; /* Last server connected to */ 57 int priority; /* "Current window Priority" */ 58 int top; /* SCREEN line for top of window */ 59 int bottom; /* SCREEN line for bottom of window */ 60 int cursor; /* WINDOW line where the cursor is */ 61 int noscrollcursor; /* Where the next line goes */ 62 int absolute_size; /* True if window doesnt rebalance */ 63 int scroll; /* True if the window scrolls */ 64 int change_line; /* True if this is a scratch window */ 65 int old_size; /* 66 * Usu. same as display_size except 67 * right after a screen resize, and 68 * is used as a flag for resize_display 69 */ 70 int update; /* True if window display is dirty */ 71 unsigned miscflags; /* Miscellaneous flags. */ 72 int beep_always; /* True if a beep to win always beeps */ 73 int notify_level; /* the notify level.. */ 74 int window_level; /* Lastlog level for the window */ 75 int skip; /* Whether window should be skipped */ 76 int columns; /* How wide we are when hidden */ 77 int swappable; /* Can it be swapped in or out? */ 78 int scrolladj; /* Push back top-of-win on grow? */ 79 80 /* Input and Status stuff */ 81 char *prompt; /* Current EXEC prompt for window */ 82 Status status; /* Current status line info */ 83 84 /* Display stuff */ 85 /* 86 * The "scrollback" buffer is a linked list of lines that have 87 * appeared, are appearing, or will appear on the visible window. 88 * The "top" of the scrollback buffer usually floats forward in 89 * the line as items are added. The visible part of the screen is 90 * always somewhere in the buffer (usually at the bottom), unless 91 * the user is in "scrollback mode" or "hold mode". When the user 92 * is in either of these modes, then the top of the scrollback buffer 93 * is frozen (so as not to disrupt the current contents of the screen) 94 * and the bottom of the buffer floats as is neccesary. When the user 95 * ends these modes, the buffer is reset to the "scrollback_point" and 96 * then is floated to its original dimensions from there. The lastlog 97 * has nothing to do with scrollback any longer. 98 * 99 * The "display_ip" is always a blank line where the NEXT displayable 100 * line will go. When the user does a /clear, the screen is scrolled 101 * up until display_ip is the top_of_display. "display_size" is the 102 * number of rows that can appear on the screen at a given time. 103 */ 104 Display *top_of_scrollback; /* Start of the scrollback buffer */ 105 Display *display_ip; /* End of the scrollback buffer */ 106 int display_buffer_size; /* How big the scrollback buffer is */ 107 int display_buffer_max; /* How big its supposed to be */ 108 int display_size; /* How big the window is - status */ 109 110 Display *scrolling_top_of_display; 111 int scrolling_distance_from_display_ip; 112 113 Display *holding_top_of_display; 114 int holding_distance_from_display_ip; 115 116 Display *scrollback_top_of_display; 117 int scrollback_distance_from_display_ip; 118 119 int display_counter; 120 int hold_slider; 121 122 #if 0 123 *top_of_display, /* Where the viewport starts */ 124 *display_ip, /* Where next line goes in rite() */ 125 *scrollback_point; /* Where we went into scrollback */ 126 127 int hold_mode; /* True if we want to hold stuff */ 128 int autohold; /* True if we are in temp hold mode */ 129 130 int lines_held; /* Lines currently being held */ 131 int distance_from_display_ip; /* How far t_o_d is from d_ip */ 132 #endif 133 134 int hold_interval; /* How often to update status bar */ 135 int last_lines_held; /* Last time we updated "lines held" */ 136 137 /* Channel stuff */ 138 char *waiting_channel; /* 139 * When you JOIN or reconnect, if this 140 * is set, a JOIN to that channel will 141 * put that channel into this win. 142 */ 143 char *bind_channel; /* Current bound channel for win */ 144 char *query_nick; /* Current default target for win */ 145 WNickList *nicks; /* List of nick-queries for this win */ 146 147 148 /* /LASTLOG stuff */ 149 Lastlog *lastlog_newest; /* pointer to top of lastlog list */ 150 Lastlog *lastlog_oldest; /* pointer to bottom of lastlog list */ 151 int lastlog_level; /* The LASTLOG_LEVEL, determines what 152 * messages go to lastlog */ 153 int lastlog_size; /* number of messages in lastlog. */ 154 int lastlog_max; /* Max number of messages in lastlog */ 155 156 157 /* /WINDOW LOG stuff */ 158 int log; /* True if file logging is on */ 159 char *logfile; /* window's logfile name */ 160 FILE *log_fp; /* file pointer for the log file */ 161 162 /* List stuff */ 163 struct ScreenStru *screen; /* The screen we belong to */ 164 struct WindowStru *next; /* Window below us on screen */ 165 struct WindowStru *prev; /* Window above us on screen */ 166 167 /* XXX - Help stuff */ 168 struct HelpStru *helper; /* Info about current /help */ 169 170 int deceased; /* Set when the window is killed */ 171 } Window; 172 173 /* 174 * WindowStack: The structure for the POP, PUSH, and STACK functions. A 175 * simple linked list with window refnums as the data 176 */ 177 typedef struct window_stack_stru 178 { 179 unsigned int refnum; 180 struct window_stack_stru *next; 181 } WindowStack; 182 183 extern Window *current_window; 184 extern Window *to_window; 185 extern Window *invisible_list; 186 extern int who_level; 187 extern const char *who_from; 188 #if 0 189 extern int in_window_command; 190 #endif 191 extern unsigned window_display; 192 extern unsigned current_window_priority; 193 194 195 BUILT_IN_COMMAND(windowcmd); 196 197 Window *new_window (struct ScreenStru *); 198 void delete_window (Window *); 199 void delete_all_windows (void); 200 int traverse_all_windows (Window **); 201 void add_to_invisible_list (Window *); 202 Window *add_to_window_list (struct ScreenStru *, Window *); 203 void recalculate_window_positions (struct ScreenStru *); 204 void window_statusbar_needs_update (Window *); 205 void window_statusbar_needs_redraw (Window *); 206 void window_body_needs_redraw (Window *); 207 void redraw_all_windows (void); 208 void recalculate_windows (struct ScreenStru *); 209 void rebalance_windows (struct ScreenStru *); 210 void update_all_windows (void); 211 void set_current_window (Window *); 212 void hide_window (Window *); 213 void swap_last_window (char, char *); 214 void next_window (char, char *); 215 void swap_next_window (char, char *); 216 void previous_window (char, char *); 217 void swap_previous_window (char, char *); 218 void back_window (void); 219 Window *get_window_by_refnum (unsigned); 220 Window *get_window_by_name (const char *); 221 Window *get_window_by_desc (const char *); 222 char *get_refnum_by_window (const Window *); 223 int is_window_visible (char *); 224 char *get_status_by_refnum (unsigned, int); 225 #if 0 226 void redraw_window_statusbar (Window *); 227 void update_window_statusbar (Window *); 228 #endif 229 void update_all_status (void); 230 void set_prompt_by_refnum (unsigned, char *); 231 char *get_prompt_by_refnum (unsigned); 232 const char *get_target_by_refnum (unsigned); 233 const char *query_nick (void); 234 void set_query_nick (char *); 235 int is_current_channel (const char *, int); 236 const char * set_channel_by_refnum (unsigned, const char *); 237 const char *get_echannel_by_refnum (unsigned); 238 char *get_channel_by_refnum (unsigned); 239 int is_bound_to_window (const Window *, const char *); 240 Window *get_window_bound_channel (const char *); 241 int is_bound_anywhere (const char *); 242 int is_bound (const char *, int); 243 void unbind_channel (const char *, int); 244 char *get_bound_channel (Window *); 245 void destroy_waiting_channels (int); 246 int get_window_server (unsigned); 247 int get_window_oldserver (unsigned); 248 void set_window_server (int, int, int); 249 void change_window_server (int, int); 250 void reclaim_windows (int, int); 251 void window_check_servers (void); 252 void set_level_by_refnum (unsigned, int); 253 void message_to (int); 254 void save_message_from (const char **, int *); 255 void restore_message_from (const char *, int); 256 void message_from (const char *, int); 257 int message_from_level (int); 258 void clear_all_windows (int, int, int); 259 void clear_window_by_refnum (unsigned, int); 260 void unclear_all_windows (int, int, int); 261 void unclear_window_by_refnum (unsigned, int); 262 void set_scrollback_size (const void *); 263 void set_scroll_lines (const void *); 264 void set_continued_line (const void *); 265 unsigned current_refnum (void); 266 int number_of_windows_on_screen (Window *); 267 void delete_display_line (Display *); 268 int add_to_scrollback (Window *, const unsigned char *); 269 int trim_scrollback (Window *); 270 int flush_scrollback_after (Window *); 271 void scrollback_backwards (char, char *); 272 void scrollback_forwards (char, char *); 273 void scrollback_end (char, char *); 274 void scrollback_start (char, char *); 275 void unstop_all_windows (char, char *); 276 void toggle_stop_screen (char, char *); 277 void flush_everything_being_held (Window *); 278 int window_is_holding (Window *); 279 int unhold_a_window (Window *); 280 void recalculate_window_cursor_and_display_ip (Window *); 281 char *get_nicklist_by_window (Window *); /* XXX */ 282 void make_window_current_by_refnum (int); 283 void make_window_current (Window *); 284 Window *window_query (Window *, char **); 285 Window *window_rejoin (Window *, char **); 286 Window *window_scroll (Window *, char **); 287 Window *window_server (Window *, char **); 288 int unhold_windows (void); 289 int channel_going_away (Window *, const char *); 290 void window_check_channels (void); 291 292 int add_to_scratch_window_scrollback (Window *, const unsigned char *); 293 void check_window_cursor (Window *); 294 void unhold_window (Window *); 295 int get_geom_by_winref (const char *, int *, int *); 296 int get_winref_by_servref (int); 297 298 int is_window_waiting_for_channel (unsigned, const char *); 299 void move_waiting_channel (unsigned oldref, unsigned newref); 300 int get_winref_by_bound_channel (const char *channel, int server); 301 const char * get_bound_channel_by_refnum (unsigned refnum); 302 303 char * windowctl (char *); 304 305 #endif /* __window_h__ */ 306