static void scrollback_goto_pos(WINDOW_REC *window, GList *pos) { GUI_WINDOW_REC *gui; g_return_if_fail(window != NULL); g_return_if_fail(pos != NULL); gui = WINDOW_GUI(window); if (g_list_find(gui->bottom_startline, pos->data) == NULL) { gui->startline = pos; gui->subline = 0; gui_window_update_ypos(gui); gui->bottom = is_window_bottom(gui); } else { /* reached the last line */ if (gui->bottom) return; gui->startline = gui->bottom_startline; gui->subline = gui->bottom_subline; gui->ypos = gui->parent->lines-1; gui->bottom = TRUE; } if (is_window_visible(window)) gui_window_redraw(window); signal_emit("gui page scrolled", 1, window); }
static void remove_first_line(WINDOW_REC *window) { GUI_WINDOW_REC *gui; TEXT_CHUNK_REC *chunk; g_return_if_fail(window != NULL); gui = WINDOW_GUI(window); chunk = gui->text_chunks->data; if (--chunk->lines == 0) text_chunk_free(gui, chunk); if (gui->startline->prev == NULL) { /* first line in screen removed */ gui->startline = gui->startline->next; gui->subline = 0; gui->ypos--; } if (gui->bottom_startline->prev == NULL) { /* bottom line removed (shouldn't happen?) */ gui->bottom_startline = gui->bottom_startline->next; gui->bottom_subline = 0; } window->lines--; g_mem_chunk_free(gui->line_chunk, gui->lines->data); gui->lines = g_list_remove(gui->lines, gui->lines->data); if (gui->startline->prev == NULL && is_window_visible(window)) gui_window_redraw(window); }
static void sig_printtext_finished(WINDOW_REC *window) { GUI_WINDOW_REC *gui; gui = WINDOW_GUI(window); if (gui->cur_line == NULL) return; if (format->len > 0) { /* save format of the line */ linebuf_add(gui, format->str, format->len); g_string_truncate(format, 0); } linebuf_add(gui, "\0\200", 2); /* mark EOL */ gui->eol_marked = TRUE; if (is_window_visible(window)) { #ifdef USE_CURSES_WINDOWS screen_refresh(gui->parent->curses_win); #else screen_refresh(NULL); #endif } }
/* SYNTAX: WINDOW HIDE [<number>|<name>] */ static void cmd_window_hide(const char *data) { WINDOW_REC *window; if (mainwindows->next == NULL) { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_CANT_HIDE_LAST); return; } if (*data == '\0') window = active_win; else if (is_numeric(data, 0)) window = window_find_refnum(atoi(data)); else window = window_find_item(active_win, data); if (window == NULL) return; if (!is_window_visible(window)) return; mainwindow_destroy(WINDOW_GUI(window)->parent); if (active_mainwin == NULL) { active_mainwin = WINDOW_GUI(active_win)->parent; window_set_active(active_mainwin->active); } }
static void signal_window_changed(WINDOW_REC *window) { MAIN_WINDOW_REC *parent; g_return_if_fail(window != NULL); if (quitting) return; parent = WINDOW_GUI(window)->parent; if (is_window_visible(window)) { /* already visible */ active_mainwin = parent; } else if (active_mainwin == NULL) { /* no main window set yet */ active_mainwin = parent; } else if (g_slist_find(parent->sticky_windows, window) != NULL) { /* window is sticky, switch to correct main window */ if (parent != active_mainwin) active_mainwin = parent; } else { /* move window to active main window */ if (active_mainwin->sticky_windows != NULL) { /* active mainwindow is sticky, we'll need to set the window active somewhere else */ active_mainwin = mainwindow_find_unsticky(); } gui_window_reparent(window, active_mainwin); } active_mainwin->active = window; screen_refresh_freeze(); window_update_prompt(); gui_window_redraw(window); screen_refresh_thaw(); }
static void sig_statusbar_channel_redraw_window_item(WI_ITEM_REC *item) { WINDOW_REC *window; window = window_item_window(item); if (window->active == item && is_window_visible(window)) statusbar_item_redraw(channel_item); }
static void sig_statusbar_more_check_remove(WINDOW_REC *window) { g_return_if_fail(window != NULL); if (!is_window_visible(window)) return; if (more_item != NULL && WINDOW_GUI(window)->bottom) { statusbar_item_remove(more_item); more_item = NULL; } }
static void window_clear(WINDOW_REC *window) { GUI_WINDOW_REC *gui = WINDOW_GUI(window); if (is_window_visible(window)) window_clear_screen(gui); gui->ypos = -1; gui->bottom_startline = gui->startline = g_list_last(gui->lines); gui->bottom_subline = gui->subline = gui->last_subline+1; gui->empty_linecount = gui->parent->lines; gui->bottom = TRUE; }
void gui_window_clear(WINDOW_REC *window) { MAIN_WINDOW_REC *parent; g_return_if_fail(window != NULL); parent = WINDOW_GUI(window)->parent; gui_window_deinit(WINDOW_GUI(window)); window->gui_data = gui_window_init(window, parent); window->lines = 0; if (is_window_visible(window)) gui_window_redraw(window); }
static void cmd_clear(void) { GUI_WINDOW_REC *gui; gui = WINDOW_GUI(active_win); if (is_window_visible(active_win)) window_clear(gui); gui->ypos = -1; gui->bottom_startline = gui->startline = g_list_last(gui->lines); gui->bottom_subline = gui->subline = gui->last_subline+1; gui->empty_linecount = gui->parent->last_line-gui->parent->first_line+1; gui->bottom = TRUE; }
/* SYNTAX: SCROLLBACK END */ static void cmd_scrollback_end(const char *data) { GUI_WINDOW_REC *gui; gui = WINDOW_GUI(active_win); if (gui->bottom) return; gui->startline = gui->bottom_startline; gui->subline = gui->bottom_subline; gui->ypos = gui->parent->lines-1; gui->bottom = TRUE; if (is_window_visible(active_win)) gui_window_redraw(active_win); signal_emit("gui page scrolled", 1, active_win); }
void gui_window_scroll(WINDOW_REC *window, int lines) { GUI_WINDOW_REC *gui; g_return_if_fail(window != NULL); gui = WINDOW_GUI(window); if (lines < 0) gui_window_scroll_up(gui, -lines); else gui_window_scroll_down(gui, lines); if (is_window_visible(window)) gui_window_redraw(window); signal_emit("gui page scrolled", 1, window); }
static void sig_statusbar_more_check(WINDOW_REC *window) { g_return_if_fail(window != NULL); if (!is_window_visible(window)) return; if (!WINDOW_GUI(window)->bottom) { if (more_item == NULL) { more_item = statusbar_item_create(mainbar, 10, FALSE, statusbar_more); statusbar_redraw(mainbar); } } else if (more_item != NULL) { statusbar_item_remove(more_item); more_item = NULL; } }
/* Don't send window activity if window is already visible in another mainwindow */ static void sig_activity(WINDOW_REC *window) { GSList *tmp; if (!is_window_visible(window) || window->data_level == 0) return; window->data_level = 0; window->hilight_color = 0; for (tmp = window->items; tmp != NULL; tmp = tmp->next) { WI_ITEM_REC *item = tmp->data; item->data_level = 0; item->hilight_color = 0; } signal_stop(); }
/* SYNTAX: SCROLLBACK HOME */ static void cmd_scrollback_home(const char *data) { GUI_WINDOW_REC *gui; gui = WINDOW_GUI(active_win); if (gui->startline == gui->lines) return; gui->startline = gui->lines; gui->subline = 0; gui_window_update_ypos(gui); gui->bottom = is_window_bottom(gui); if (is_window_visible(active_win)) gui_window_redraw(active_win); signal_emit("gui page scrolled", 1, active_win); }
/* SYNTAX: WINDOW SHOW <number>|<name> */ static void cmd_window_show(const char *data) { WINDOW_REC *window; if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS); window = is_numeric(data, 0) ? window_find_refnum(atoi(data)) : window_find_item(active_win, data); if (window == NULL) return; if (is_window_visible(window)) return; WINDOW_GUI(window)->parent = mainwindow_create(); WINDOW_GUI(window)->parent->active = window; active_mainwin = NULL; window_set_active(window); }
static void signal_window_changed(WINDOW_REC *window) { MAIN_WINDOW_REC *parent; WINDOW_REC *old_window; g_return_if_fail(window != NULL); if (quitting) return; parent = WINDOW_MAIN(window); if (is_window_visible(window)) { /* already visible */ active_mainwin = parent; } else if (active_mainwin == NULL) { /* no main window set yet */ active_mainwin = parent; } else if (WINDOW_GUI(window)->sticky) { /* window is sticky, switch to correct main window */ if (parent != active_mainwin) active_mainwin = parent; } else { /* move window to active main window */ if (active_mainwin->sticky_windows) { /* active mainwindow is sticky, we'll need to set the window active somewhere else */ active_mainwin = mainwindow_find_unsticky(); } gui_window_reparent(window, active_mainwin); } old_window = active_mainwin->active; if (old_window != NULL && old_window != window) textbuffer_view_set_window(WINDOW_GUI(old_window)->view, NULL); active_mainwin->active = window; textbuffer_view_set_window(WINDOW_GUI(window)->view, active_mainwin->screen_win); if (WINDOW_GUI(window)->view->dirty) active_mainwin->dirty = TRUE; }
/* Don't send window activity if window is already visible in another mainwindow */ static void sig_activity(WINDOW_REC *window) { GSList *tmp; if (!is_window_visible(window) || window->data_level == 0) return; if (!settings_get_bool("activity_hide_visible")) return; window->data_level = 0; g_free_and_null(window->hilight_color); for (tmp = window->items; tmp != NULL; tmp = tmp->next) { WI_ITEM_REC *item = tmp->data; item->data_level = 0; g_free_and_null(item->hilight_color); } signal_stop(); }
void gui_window_scroll(WINDOW_REC *window, int lines) { GUI_WINDOW_REC *gui; g_return_if_fail(window != NULL); gui = WINDOW_GUI(window); if (lines < 0) { if (gui->startline == NULL || gui->startline->prev == NULL) return; gui_window_scroll_up(gui, -lines); } else { if (is_scrolled_bottom(gui)) return; gui_window_scroll_down(gui, lines); } if (is_window_visible(window)) gui_window_redraw(window); signal_emit("gui page scrolled", 1, window); }
/* SYNTAX: WINDOW HIDE [<number>|<name>] */ static void cmd_window_hide(const char *data) { WINDOW_REC *window; if (mainwindows->next == NULL) { printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, TXT_CANT_HIDE_LAST); return; } if (*data == '\0') window = active_win; else if (is_numeric(data, 0)) { window = window_find_refnum(atoi(data)); if (window == NULL) { printformat_window(active_win, MSGLEVEL_CLIENTERROR, TXT_REFNUM_NOT_FOUND, data); } } else { window = window_find_item(active_win->active_server, data); } if (window == NULL || !is_window_visible(window)) return; if (WINDOW_MAIN(window)->sticky_windows) { printformat_window(active_win, MSGLEVEL_CLIENTERROR, TXT_CANT_HIDE_STICKY_WINDOWS); return; } mainwindow_destroy(WINDOW_MAIN(window)); if (active_mainwin == NULL) { active_mainwin = WINDOW_MAIN(active_win); window_set_active(active_mainwin->active); } }
static void signal_window_changed(WINDOW_REC *window) { g_return_if_fail(window != NULL); if (quitting) return; if (is_window_visible(window)) { /* already visible, great! */ active_mainwin = WINDOW_GUI(window)->parent; } else { /* move it to active main window */ if (active_mainwin == NULL) active_mainwin = WINDOW_GUI(window)->parent; else gui_window_reparent(window, active_mainwin); active_mainwin->active = window; } screen_refresh_freeze(); window_update_prompt(window); gui_window_redraw(window); screen_refresh_thaw(); }
/* SYNTAX: WINDOW SHOW <number>|<name> */ static void cmd_window_show(const char *data) { MAIN_WINDOW_REC *parent; WINDOW_REC *window; if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS); if (is_numeric(data, '\0')) { window = window_find_refnum(atoi(data)); if (window == NULL) { printformat_window(active_win, MSGLEVEL_CLIENTERROR, TXT_REFNUM_NOT_FOUND, data); } } else { window = window_find_item(active_win->active_server, data); } if (window == NULL || is_window_visible(window)) return; if (WINDOW_MAIN(window)->sticky_windows) { printformat_window(active_win, MSGLEVEL_CLIENTERROR, TXT_CANT_SHOW_STICKY_WINDOWS); return; } parent = mainwindow_create(); parent->active = window; gui_window_reparent(window, parent); if (settings_get_bool("autostick_split_windows")) gui_window_set_sticky(window); active_mainwin = NULL; window_set_active(window); }
void gui_window_line_remove(WINDOW_REC *window, LINE_REC *line, int redraw) { GUI_WINDOW_REC *gui; GList *last; int screenchange; g_return_if_fail(window != NULL); g_return_if_fail(line != NULL); gui = WINDOW_GUI(window); screenchange = g_list_find(gui->startline, line) != NULL; if (screenchange) gui->ypos -= gui_window_get_linecount(gui, line); gui_window_cache_remove(gui, line); gui_window_line_text_free(gui, line); if (gui->lastlog_last_check != NULL && gui->lastlog_last_check->data == line) gui->lastlog_last_check = NULL; if (gui->lastlog_last_away != NULL && gui->lastlog_last_away->data == line) gui->lastlog_last_away = NULL; last = g_list_last(gui->bottom_startline); if (last->data == line) { /* removing last line */ gui->last_subline = gui_window_get_linecount(gui, last->prev->data)-1; } if (gui->bottom_startline->data == line) { /* bottom line removed */ if (gui->bottom_startline->next != NULL) { gui->bottom_startline = gui->bottom_startline->next; gui->bottom_subline = 0; } else { gui->bottom_startline = gui->bottom_startline->prev; gui->bottom_subline = gui->last_subline+1; } } if (gui->startline->data == line) { /* first line in screen removed */ if (gui->startline->next != NULL) { gui->startline = gui->startline->next; gui->subline = 0; } else { gui->startline = gui->startline->prev; gui->subline = gui->last_subline+1; gui->ypos = -1; gui->empty_linecount = gui->parent->lines; gui->bottom = TRUE; } } window->lines--; g_mem_chunk_free(gui->line_chunk, line); gui->lines = g_list_remove(gui->lines, line); if (window->lines == 0) gui_window_clear(window); if (redraw && screenchange && is_window_visible(window)) gui_window_redraw(window); }
static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, void *bgcolor, void *pflags, char *str, void *level) { GUI_WINDOW_REC *gui; LINE_REC *line; int fg, bg, flags, new_lines, n, visible, ypos, subline; flags = GPOINTER_TO_INT(pflags); fg = GPOINTER_TO_INT(fgcolor); bg = GPOINTER_TO_INT(bgcolor); get_colors(flags, &fg, &bg); if (window == NULL && next_xpos != -1) { wmove(stdscr, next_ypos, next_xpos); set_color(stdscr, fg | (bg << 4)); addstr(str); next_xpos += strlen(str); return; } g_return_if_fail(window != NULL); gui = WINDOW_GUI(window); visible = is_window_visible(window) && gui->bottom; if (gui->cur_text == NULL) create_text_chunk(gui); /* newline can be only at the start of the line.. */ if (flags & PRINTFLAG_NEWLINE) { remove_old_lines(window); if (!gui->eol_marked) { if (format->len > 0 || gui->temp_line != NULL) { /* mark format continuing to next line */ char tmp[2] = { 0, (char)LINE_CMD_FORMAT_CONT }; linebuf_add(gui, tmp, 2); } linebuf_add(gui, "\0\200", 2); /* mark EOL */ } gui->eol_marked = FALSE; line = create_line(gui, 0); if (gui->temp_line == NULL || g_list_find(gui->startline, gui->temp_line) != NULL) gui_window_newline(gui, visible); gui->last_subline = 0; } else { line = gui->temp_line != NULL ? gui->temp_line : gui->cur_line != NULL ? gui->cur_line : create_line(gui, 0); if (line->level == 0) line->level = GPOINTER_TO_INT(level); } line_add_colors(gui, fg, bg, flags); linebuf_add(gui, str, strlen(str)); mark_temp_eol(gui->cur_text); gui_window_cache_remove(gui, line); if (gui->temp_line != NULL) { /* updating existing line - don't even try to print it to screen */ return; } new_lines = gui_window_get_linecount(gui, line)-1 - gui->last_subline; for (n = 0; n < new_lines; n++) gui_window_newline(gui, visible); if (visible) { /* draw the line to screen. */ ypos = gui->ypos-new_lines; if (new_lines > 0) { #ifdef USE_CURSES_WINDOWS set_color(gui->parent->curses_win, 0); wmove(gui->parent->curses_win, ypos, 0); wclrtoeol(gui->parent->curses_win); #else set_color(stdscr, 0); move(ypos + gui->parent->first_line, 0); wclrtoeol(stdscr); #endif } if (ypos >= 0) subline = gui->last_subline; else { /* *LONG* line - longer than screen height */ subline = -ypos+gui->last_subline; ypos = 0; } gui_window_line_draw(gui, line, ypos, subline, -1); } gui->last_subline += new_lines; }
static void sig_statusbar_channel_redraw_window(WINDOW_REC *window) { if (is_window_visible(window)) statusbar_item_redraw(channel_item); }
static void sig_printtext_finished(WINDOW_REC *window) { if (is_window_visible(window)) screen_refresh(); }
static void gui_printtext(WINDOW_REC *window, gpointer fgcolor, gpointer bgcolor, gpointer pflags, char *str, gpointer level) { GUI_WINDOW_REC *gui; LINE_REC *line; int fg, bg, flags, new_lines, n, visible, ypos, subline; g_return_if_fail(window != NULL); remove_old_lines(window); gui = WINDOW_GUI(window); visible = is_window_visible(window) && gui->bottom; flags = GPOINTER_TO_INT(pflags); fg = GPOINTER_TO_INT(fgcolor); bg = GPOINTER_TO_INT(bgcolor); if (gui->cur_text == NULL) create_text_chunk(gui); /* \n can be only at the start of the line.. */ if (*str == '\n') { str++; linebuf_add(gui, "\0\x80", 2); /* mark EOL */ line = create_line(gui, 0); gui_window_newline(gui, visible); gui->cur_text->lines++; gui->last_subline = 0; } else { line = gui->cur_line != NULL ? gui->cur_line : create_line(gui, 0); if (line->level == 0) line->level = GPOINTER_TO_INT(level); } get_colors(flags, &fg, &bg); line_add_colors(gui, fg, bg, flags); linebuf_add(gui, str, strlen(str)); mark_temp_eol(gui->cur_text); gui_window_cache_remove(gui, line); new_lines = gui_window_get_linecount(gui, line)-1 - gui->last_subline; for (n = 0; n < new_lines; n++) gui_window_newline(gui, visible); if (visible) { /* draw the line to screen. */ ypos = gui->ypos-new_lines; if (new_lines > 0) { set_color(0); move(gui->parent->first_line+ypos, 0); clrtoeol(); } if (ypos >= 0) subline = gui->last_subline; else { /* *LONG* line - longer than screen height */ subline = -ypos+gui->last_subline; ypos = 0; } ypos += gui->parent->first_line; gui_window_line_draw(gui, line, ypos, subline, -1); } gui->last_subline += new_lines; }