diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2004-01-21 15:29:43 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2004-01-21 15:29:43 +0000 |
commit | 84677f2835ef78e408d1fa179a30a60c72522682 (patch) | |
tree | 29abbf205c964ef261b1235494060e58876538af /src/gui | |
parent | c20a3fdfa4f71bd750d1b58ab0673e376ec52c6c (diff) | |
download | weechat-84677f2835ef78e408d1fa179a30a60c72522682.zip |
Added IRC::print_infobar Perl function
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-display.c | 9 | ||||
-rw-r--r-- | src/gui/curses/gui-input.c | 24 | ||||
-rw-r--r-- | src/gui/gui-common.c | 54 | ||||
-rw-r--r-- | src/gui/gui.h | 15 |
4 files changed, 86 insertions, 16 deletions
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index b5090c529..39528997a 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -888,7 +888,7 @@ gui_draw_window_status (t_gui_window *window) } } - /* display "*MORE*" if last line is not displayed */ + /* display "-MORE-" if last line is not displayed */ gui_window_set_color (window->win_status, COLOR_WIN_STATUS_MORE); if (window->sub_lines > 0) mvwprintw (window->win_status, 0, COLS - 7, _("-MORE-")); @@ -944,7 +944,10 @@ gui_draw_window_infobar (t_gui_window *window) time_seconds = time (NULL); local_time = localtime (&time_seconds); strftime (text, 1024, cfg_look_infobar_timestamp, local_time); - wprintw (window->win_infobar, "%s", text); + if (gui_infobar) + wprintw (window->win_infobar, "%s | %s", text, gui_infobar->text); + else + wprintw (window->win_infobar, "%s", text); wrefresh (window->win_infobar); refresh (); @@ -1482,6 +1485,8 @@ gui_init () gui_init_colors (); + gui_infobar = NULL; + /* create a new window */ gui_current_window = gui_window_new (NULL, NULL, 1 /*0, 0, COLS, LINES*/); diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c index 53baeb2d4..26a881428 100644 --- a/src/gui/curses/gui-input.c +++ b/src/gui/curses/gui-input.c @@ -69,6 +69,10 @@ gui_read_keyb () case KEY_F(7): gui_switch_to_next_window (); break; + /* remove last infobar message */ + case KEY_F(10): + gui_infobar_remove (); + break; /* cursor up */ case KEY_UP: if (gui_current_window->ptr_history) @@ -353,22 +357,38 @@ gui_main_loop () fd_set read_fd; static struct timeval timeout; t_irc_server *ptr_server; - int old_min; + int old_min, old_sec; time_t new_time; struct tm *local_time; quit_weechat = 0; - old_min = 0; + old_min = -1; + old_sec = -1; while (!quit_weechat) { new_time = time (NULL); local_time = localtime (&new_time); + + /* minute has changed ? => redraw infobar */ if (local_time->tm_min != old_min) { old_min = local_time->tm_min; gui_redraw_window_infobar (gui_current_window); } + /* second has changed ? => count down time for infobar, if needed */ + if (local_time->tm_sec != old_sec) + { + old_sec = local_time->tm_sec; + /* TODO: manage splitted windows! */ + if (gui_infobar && gui_infobar->remaining_time > 0) + { + gui_infobar->remaining_time--; + if (gui_infobar->remaining_time == 0) + gui_infobar_remove (); + } + } + timeout.tv_sec = 0; timeout.tv_usec = 10000; FD_ZERO (&read_fd); diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index 397e3c3c3..4fbe8633c 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -42,6 +42,7 @@ int gui_ready; /* = 1 if GUI is initialized */ t_gui_window *gui_windows = NULL; /* pointer to first window */ t_gui_window *last_gui_window = NULL; /* pointer to last window */ t_gui_window *gui_current_window = NULL; /* pointer to current window */ +t_gui_infobar *gui_infobar; /* pointer to infobar content */ /* @@ -96,10 +97,6 @@ gui_window_new (void *server, void *channel, int switch_to_window new_window->line_complete = 1; new_window->unread_data = 0; - /* init infobar */ - new_window->infobar = NULL; - new_window->infobar_length = new_window->win_width + 1; - /* init input buffer */ new_window->input_buffer_alloc = INPUT_BUFFER_BLOCK_SIZE; new_window->input_buffer = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE); @@ -186,6 +183,55 @@ gui_window_clear_all () gui_window_clear (ptr_win); } +/* + * gui_infobar_print: display message in infobar + */ + +void +gui_infobar_print (char *message, int time_displayed) +{ + t_gui_infobar *ptr_infobar; + char *pos; + + ptr_infobar = (t_gui_infobar *)malloc (sizeof (t_gui_infobar)); + if (ptr_infobar) + { + ptr_infobar->text = strdup (message); + pos = strchr (ptr_infobar->text, '\n'); + if (pos) + pos[0] = '\0'; + ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed; + ptr_infobar->next_infobar = gui_infobar; + gui_infobar = ptr_infobar; + /* TODO: manage splitted windows! */ + gui_redraw_window_infobar (gui_current_window); + } + else + wee_log_printf (_("%s not enough memory for infobar message\n"), + WEECHAT_ERROR); +} + +/* + * gui_infobar_remove: remove last displayed message in infobar + */ + +void +gui_infobar_remove () +{ + t_gui_infobar *new_infobar; + + if (gui_infobar) + { + new_infobar = gui_infobar->next_infobar; + if (gui_infobar->text) + free (gui_infobar->text); + free (gui_infobar); + gui_infobar = new_infobar; + /* TODO: manage splitted windows! */ + gui_redraw_window_infobar (gui_current_window); + } +} + /* * gui_window_free: delete a window */ diff --git a/src/gui/gui.h b/src/gui/gui.h index 63505a4bd..37c01d788 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -113,8 +113,8 @@ typedef struct t_gui_infobar t_gui_infobar; struct t_gui_infobar { char *text; /* infobar text */ - int time_displayed; /* delay (ms) before erasing this text */ - /* if 0, text is never erased (except */ + int remaining_time; /* delay (sec) before erasing this text */ + /* if < 0, text is never erased (except */ /* by user action to erase it) */ t_gui_infobar *next_infobar; /* next message for infobar */ }; @@ -153,14 +153,14 @@ struct t_gui_window void *win_infobar; /* info bar window */ void *win_input; /* input window */ - /* windows for Curses GUI */ + /* windows for Gtk GUI */ void *textview_chat; /* textview widget for chat */ void *textbuffer_chat; /* textbuffer widget for chat */ void *texttag_chat; /* texttag widget for chat */ void *textview_nicklist; /* textview widget for nicklist */ void *textbuffer_nicklist; /* textbuffer widget for nicklist */ - /* windows for Curses GUI */ + /* windows for Qt GUI */ /* TODO: declare Qt window */ /* chat content (lines, line is composed by many messages) */ @@ -171,10 +171,6 @@ struct t_gui_window int line_complete; /* current line complete ? (\n ending) */ int unread_data; /* highlight windows with unread data */ - /* infobar content */ - t_gui_infobar *infobar; /* infobar content (stack of messages) */ - int infobar_length; /* length of infobar (width of win + 1) */ - /* inupt buffer */ char *input_buffer; /* input buffer */ int input_buffer_alloc; /* input buffer: allocated size in mem */ @@ -200,6 +196,7 @@ extern int gui_ready; extern t_gui_window *gui_windows; extern t_gui_window *last_gui_window; extern t_gui_window *gui_current_window; +extern t_gui_infobar *gui_infobar; /* prototypes */ @@ -207,6 +204,8 @@ extern t_gui_window *gui_current_window; extern t_gui_window *gui_window_new (void *, void *, int /*int, int, int, int*/); /* TODO: add coordinates and size */ extern void gui_window_clear (t_gui_window *); extern void gui_window_clear_all (); +extern void gui_infobar_print (char *, int); +extern void gui_infobar_remove (); extern t_gui_line *gui_new_line (t_gui_window *); extern t_gui_message *gui_new_message (t_gui_window *); extern void gui_optimize_input_buffer_size (t_gui_window *); |