diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2006-05-07 11:40:19 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2006-05-07 11:40:19 +0000 |
commit | b7ba64c744b052836a832598ce1348c0b0194244 (patch) | |
tree | 42ee6a59a1b44c994b6c9316ec7637531db0d5d1 | |
parent | 7d944ceca40df34e7df383a184912521c4e571d2 (diff) | |
download | weechat-b7ba64c744b052836a832598ce1348c0b0194244.zip |
Added some panel structures and functions
-rw-r--r-- | po/POTFILES.in | 44 | ||||
-rw-r--r-- | src/common/command.c | 12 | ||||
-rw-r--r-- | src/common/weechat.c | 6 | ||||
-rw-r--r-- | src/gui/Makefile.am | 8 | ||||
-rw-r--r-- | src/gui/curses/Makefile.am | 27 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-chat.c (renamed from src/gui/curses/gui-chat.c) | 103 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-color.c (renamed from weechat/src/gui/curses/gui-color.c) | 8 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-infobar.c (renamed from weechat/src/gui/curses/gui-infobar.c) | 48 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-input.c (renamed from weechat/src/gui/curses/gui-input.c) | 78 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-keyboard.c (renamed from src/gui/curses/gui-keyboard.c) | 167 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-nicklist.c (renamed from weechat/src/gui/curses/gui-nicklist.c) | 78 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-panel.c | 202 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-status.c (renamed from src/gui/curses/gui-status.c) | 232 | ||||
-rw-r--r-- | src/gui/curses/gui-curses.h | 41 | ||||
-rw-r--r-- | src/gui/gtk/Makefile.am | 27 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-chat.c (renamed from weechat/src/gui/gtk/gui-chat.c) | 10 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-color.c (renamed from weechat/src/gui/gtk/gui-color.c) | 4 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-infobar.c (renamed from src/gui/gtk/gui-infobar.c) | 4 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-input.c (renamed from src/gui/gtk/gui-input.c) | 4 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-keyboard.c | 172 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-main.c (renamed from src/gui/gtk/gui-main.c) | 10 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-nicklist.c (renamed from weechat/src/gui/gtk/gui-nicklist.c) | 4 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-panel.c | 61 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-status.c (renamed from src/gui/gtk/gui-status.c) | 4 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-window.c (renamed from src/gui/gtk/gui-window.c) | 150 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk.h | 25 | ||||
-rw-r--r-- | src/gui/gtk/gui-keyboard.c | 173 | ||||
-rw-r--r-- | src/gui/gui-action.c | 4 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 8 | ||||
-rw-r--r-- | src/gui/gui-buffer.h | 137 | ||||
-rw-r--r-- | src/gui/gui-color.h | 144 | ||||
-rw-r--r-- | src/gui/gui-common.c | 11 | ||||
-rw-r--r-- | src/gui/gui-keyboard.c | 106 | ||||
-rw-r--r-- | src/gui/gui-keyboard.h | 59 | ||||
-rw-r--r-- | src/gui/gui-panel.c | 113 | ||||
-rw-r--r-- | src/gui/gui-panel.h | 55 | ||||
-rw-r--r-- | src/gui/gui-window.c | 55 | ||||
-rw-r--r-- | src/gui/gui-window.h | 106 | ||||
-rw-r--r-- | src/gui/gui.h | 437 | ||||
-rw-r--r-- | weechat/po/POTFILES.in | 44 | ||||
-rw-r--r-- | weechat/src/common/command.c | 12 | ||||
-rw-r--r-- | weechat/src/common/weechat.c | 6 | ||||
-rw-r--r-- | weechat/src/gui/Makefile.am | 8 | ||||
-rw-r--r-- | weechat/src/gui/curses/Makefile.am | 27 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-curses-chat.c (renamed from weechat/src/gui/curses/gui-chat.c) | 103 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-curses-color.c (renamed from src/gui/curses/gui-color.c) | 8 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-curses-infobar.c (renamed from src/gui/curses/gui-infobar.c) | 48 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-curses-input.c (renamed from src/gui/curses/gui-input.c) | 78 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-curses-keyboard.c (renamed from weechat/src/gui/curses/gui-keyboard.c) | 167 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-curses-nicklist.c (renamed from src/gui/curses/gui-nicklist.c) | 78 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-curses-panel.c | 202 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-curses-status.c (renamed from weechat/src/gui/curses/gui-status.c) | 232 | ||||
-rw-r--r-- | weechat/src/gui/curses/gui-curses.h | 41 | ||||
-rw-r--r-- | weechat/src/gui/gtk/Makefile.am | 27 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-chat.c (renamed from src/gui/gtk/gui-chat.c) | 10 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-color.c (renamed from src/gui/gtk/gui-color.c) | 4 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-infobar.c (renamed from weechat/src/gui/gtk/gui-infobar.c) | 4 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-input.c (renamed from weechat/src/gui/gtk/gui-input.c) | 4 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-keyboard.c | 172 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-main.c (renamed from weechat/src/gui/gtk/gui-main.c) | 10 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-nicklist.c (renamed from src/gui/gtk/gui-nicklist.c) | 4 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-panel.c | 61 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-status.c (renamed from weechat/src/gui/gtk/gui-status.c) | 4 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk-window.c (renamed from weechat/src/gui/gtk/gui-window.c) | 150 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-gtk.h | 25 | ||||
-rw-r--r-- | weechat/src/gui/gtk/gui-keyboard.c | 173 | ||||
-rw-r--r-- | weechat/src/gui/gui-action.c | 4 | ||||
-rw-r--r-- | weechat/src/gui/gui-buffer.c | 8 | ||||
-rw-r--r-- | weechat/src/gui/gui-buffer.h | 137 | ||||
-rw-r--r-- | weechat/src/gui/gui-color.h | 144 | ||||
-rw-r--r-- | weechat/src/gui/gui-common.c | 11 | ||||
-rw-r--r-- | weechat/src/gui/gui-keyboard.c | 106 | ||||
-rw-r--r-- | weechat/src/gui/gui-keyboard.h | 59 | ||||
-rw-r--r-- | weechat/src/gui/gui-panel.c | 113 | ||||
-rw-r--r-- | weechat/src/gui/gui-panel.h | 55 | ||||
-rw-r--r-- | weechat/src/gui/gui-window.c | 55 | ||||
-rw-r--r-- | weechat/src/gui/gui-window.h | 106 | ||||
-rw-r--r-- | weechat/src/gui/gui.h | 437 |
78 files changed, 3560 insertions, 2314 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in index 3639a29cc..1b55f3360 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -14,32 +14,40 @@ ./src/plugins/plugins-config.h ./src/plugins/plugins-interface.c ./src/plugins/weechat-plugin.h -./src/gui/curses/gui-chat.c -./src/gui/curses/gui-color.c -./src/gui/curses/gui-infobar.c -./src/gui/curses/gui-input.c -./src/gui/curses/gui-keyboard.c -./src/gui/curses/gui-main.c -./src/gui/curses/gui-nicklist.c -./src/gui/curses/gui-status.c -./src/gui/curses/gui-window.c +./src/gui/curses/gui-curses-chat.c +./src/gui/curses/gui-curses-color.c +./src/gui/curses/gui-curses-infobar.c +./src/gui/curses/gui-curses-input.c +./src/gui/curses/gui-curses-keyboard.c +./src/gui/curses/gui-curses-main.c +./src/gui/curses/gui-curses-nicklist.c +./src/gui/curses/gui-curses-panel.c +./src/gui/curses/gui-curses-status.c +./src/gui/curses/gui-curses-window.c ./src/gui/curses/gui-curses.h -./src/gui/gtk/gui-chat.c -./src/gui/gtk/gui-color.c -./src/gui/gtk/gui-infobar.c -./src/gui/gtk/gui-input.c -./src/gui/gtk/gui-keyboard.c -./src/gui/gtk/gui-main.c -./src/gui/gtk/gui-nicklist.c -./src/gui/gtk/gui-status.c -./src/gui/gtk/gui-window.c +./src/gui/gtk/gui-gtk-chat.c +./src/gui/gtk/gui-gtk-color.c +./src/gui/gtk/gui-gtk-infobar.c +./src/gui/gtk/gui-gtk-input.c +./src/gui/gtk/gui-gtk-keyboard.c +./src/gui/gtk/gui-gtk-main.c +./src/gui/gtk/gui-gtk-nicklist.c +./src/gui/gtk/gui-gtk-panel.c +./src/gui/gtk/gui-gtk-status.c +./src/gui/gtk/gui-gtk-window.c ./src/gui/gtk/gui-gtk.h ./src/gui/gui-action.c ./src/gui/gui-buffer.c ./src/gui/gui-common.c ./src/gui/gui-keyboard.c +./src/gui/gui-panel.c ./src/gui/gui-window.c ./src/gui/gui.h +./src/gui/gui-buffer.h +./src/gui/gui-color.h +./src/gui/gui-keyboard.h +./src/gui/gui-panel.h +./src/gui/gui-window.h ./src/common/command.c ./src/common/command.h ./src/common/completion.c diff --git a/src/common/command.c b/src/common/command.c index 5d18619ab..1068b3d17 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -2433,7 +2433,7 @@ weechat_cmd_key_display (t_gui_key *key, int new_key) { char *expanded_name; - expanded_name = gui_key_get_expanded_name (key->key); + expanded_name = gui_keyboard_get_expanded_name (key->key); if (new_key) { irc_display_prefix (NULL, NULL, PREFIX_INFO); @@ -2446,7 +2446,7 @@ weechat_cmd_key_display (t_gui_key *key, int new_key) GUI_COLOR(COLOR_WIN_CHAT_DARK), GUI_COLOR(COLOR_WIN_CHAT), (key->function) ? - gui_key_function_search_by_ptr (key->function) : key->command); + gui_keyboard_function_search_by_ptr (key->function) : key->command); if (expanded_name) free (expanded_name); } @@ -2487,7 +2487,7 @@ weechat_cmd_key (t_irc_server *server, t_irc_channel *channel, arguments += 7; while (arguments[0] == ' ') arguments++; - if (gui_key_unbind (arguments)) + if (gui_keyboard_unbind (arguments)) { irc_display_prefix (NULL, NULL, PREFIX_INFO); gui_printf (NULL, _("Key \"%s\" unbinded\n"), arguments); @@ -2521,8 +2521,8 @@ weechat_cmd_key (t_irc_server *server, t_irc_channel *channel, arguments++; if (ascii_strcasecmp (arguments, "-yes") == 0) { - gui_key_free_all (); - gui_key_init (); + gui_keyboard_free_all (); + gui_keyboard_init (); irc_display_prefix (NULL, NULL, PREFIX_INFO); gui_printf (NULL, _("Default key bindings restored\n")); } @@ -2552,7 +2552,7 @@ weechat_cmd_key (t_irc_server *server, t_irc_channel *channel, pos++; while (pos[0] == ' ') pos++; - ptr_key = gui_key_bind (arguments, pos); + ptr_key = gui_keyboard_bind (arguments, pos); if (ptr_key) weechat_cmd_key_display (ptr_key, 1); else diff --git a/src/common/weechat.c b/src/common/weechat.c index 5963d89bf..6468bc6dc 100644 --- a/src/common/weechat.c +++ b/src/common/weechat.c @@ -564,10 +564,10 @@ weechat_display_keys () printf ("\n"); for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) { - expanded_name = gui_key_get_expanded_name (ptr_key->key); + expanded_name = gui_keyboard_get_expanded_name (ptr_key->key); printf ("* %s => %s\n", (expanded_name) ? expanded_name : ptr_key->key, - (ptr_key->function) ? gui_key_function_search_by_ptr (ptr_key->function) : ptr_key->command); + (ptr_key->function) ? gui_keyboard_function_search_by_ptr (ptr_key->function) : ptr_key->command); if (expanded_name) free (expanded_name); } @@ -1095,7 +1095,7 @@ main (int argc, char *argv[]) signal (SIGSEGV, weechat_sigsegv); /* crash dump when SIGSEGV received */ gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */ weechat_init_vars (); /* initialize some variables */ - gui_key_init (); /* init keyb. (default key bindings)*/ + gui_keyboard_init (); /* init keyb. (default key bindings)*/ weechat_parse_args (argc, argv); /* parse command line args */ weechat_create_home_dirs (); /* create WeeChat directories */ weechat_init_log (); /* init log file */ diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index b202250e2..6a1ea4fc1 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -24,7 +24,13 @@ lib_weechat_gui_common_a_SOURCES = gui-buffer.c \ gui-action.c \ gui-keyboard.c \ gui-window.c \ - gui.h + gui-panel.c \ + gui.h \ + gui-buffer.h \ + gui-color.h \ + gui-keyboard.h \ + gui-panel.h \ + gui-window.h if GUI_NCURSES curses_dir=curses diff --git a/src/gui/curses/Makefile.am b/src/gui/curses/Makefile.am index 0041d8080..283d89bfe 100644 --- a/src/gui/curses/Makefile.am +++ b/src/gui/curses/Makefile.am @@ -21,8 +21,8 @@ bin_PROGRAMS = weechat-curses if PLUGINS weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \ - ../gui-window.o ../gui-keyboard.o \ - ../gui-action.o \ + ../gui-window.o ../gui-panel.o \ + ../gui-keyboard.o ../gui-action.o \ ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ ../../plugins/lib_weechat_plugins.a \ @@ -31,8 +31,8 @@ weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \ $(GNUTLS_LFLAGS) else weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \ - ../gui-window.o ../gui-keyboard.o \ - ../gui-action.o \ + ../gui-window.o ../gui-panel.o \ + ../gui-keyboard.o ../gui-action.o \ ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ $(PLUGINS_LIBS) \ @@ -40,13 +40,14 @@ weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \ $(GNUTLS_LFLAGS) endif -weechat_curses_SOURCES = gui-chat.c \ - gui-color.c \ - gui-infobar.c \ - gui-input.c \ - gui-keyboard.c \ - gui-main.c \ - gui-nicklist.c \ - gui-status.c \ - gui-window.c \ +weechat_curses_SOURCES = gui-curses-chat.c \ + gui-curses-color.c \ + gui-curses-infobar.c \ + gui-curses-input.c \ + gui-curses-keyboard.c \ + gui-curses-main.c \ + gui-curses-nicklist.c \ + gui-curses-status.c \ + gui-curses-window.c \ + gui-curses-panel.c \ gui-curses.h diff --git a/src/gui/curses/gui-chat.c b/src/gui/curses/gui-curses-chat.c index e7bef1cd2..8493a4c1c 100644 --- a/src/gui/curses/gui-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-chat.c: chat display functions for Curses GUI */ +/* gui-curses-chat.c: chat display functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -28,12 +28,6 @@ #include <string.h> #include <ctype.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" @@ -50,7 +44,7 @@ void gui_chat_set_style (t_gui_window *window, int style) { - wattron (window->win_chat, style); + wattron (GUI_CURSES(window)->win_chat, style); } /* @@ -61,7 +55,7 @@ gui_chat_set_style (t_gui_window *window, int style) void gui_chat_remove_style (t_gui_window *window, int style) { - wattroff (window->win_chat, style); + wattroff (GUI_CURSES(window)->win_chat, style); } /* @@ -92,7 +86,7 @@ gui_chat_reset_style (t_gui_window *window) window->current_style_attr = 0; window->current_color_attr = 0; - gui_window_set_weechat_color (window->win_chat, COLOR_WIN_CHAT); + gui_window_set_weechat_color (GUI_CURSES(window)->win_chat, COLOR_WIN_CHAT); gui_chat_remove_style (window, A_BOLD | A_UNDERLINE | A_REVERSE); } @@ -105,7 +99,7 @@ void gui_chat_set_color_style (t_gui_window *window, int style) { window->current_color_attr |= style; - wattron (window->win_chat, style); + wattron (GUI_CURSES(window)->win_chat, style); } /* @@ -116,7 +110,7 @@ void gui_chat_remove_color_style (t_gui_window *window, int style) { window->current_color_attr &= !style; - wattroff (window->win_chat, style); + wattroff (GUI_CURSES(window)->win_chat, style); } /* @@ -126,7 +120,7 @@ gui_chat_remove_color_style (t_gui_window *window, int style) void gui_chat_reset_color_style (t_gui_window *window) { - wattroff (window->win_chat, window->current_color_attr); + wattroff (GUI_CURSES(window)->win_chat, window->current_color_attr); window->current_color_attr = 0; } @@ -139,14 +133,14 @@ gui_chat_set_color (t_gui_window *window, int fg, int bg) { if (((fg == -1) || (fg == 99)) && ((bg == -1) || (bg == 99))) - wattron (window->win_chat, COLOR_PAIR(63)); + wattron (GUI_CURSES(window)->win_chat, COLOR_PAIR(63)); else { if ((fg == -1) || (fg == 99)) fg = WEECHAT_COLOR_WHITE; if ((bg == -1) || (bg == 99)) bg = 0; - wattron (window->win_chat, COLOR_PAIR((bg * 8) + fg)); + wattron (GUI_CURSES(window)->win_chat, COLOR_PAIR((bg * 8) + fg)); } } @@ -183,9 +177,9 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase) if (ptr_win->buffer == buffer) { if (erase) - gui_window_curses_clear (ptr_win->win_title, COLOR_WIN_TITLE); + gui_window_curses_clear (GUI_CURSES(ptr_win)->win_title, COLOR_WIN_TITLE); - gui_window_set_weechat_color (ptr_win->win_title, COLOR_WIN_TITLE); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title, COLOR_WIN_TITLE); snprintf (format, 32, "%%-%ds", ptr_win->win_width); if (CHANNEL(buffer)) { @@ -195,28 +189,29 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase) buf2 = channel_iconv_decode (SERVER(buffer), CHANNEL(buffer), (buf) ? buf : CHANNEL(buffer)->topic); - mvwprintw (ptr_win->win_title, 0, 0, format, (buf2) ? buf2 : CHANNEL(buffer)->topic); + mvwprintw (GUI_CURSES(ptr_win)->win_title, 0, 0, + format, (buf2) ? buf2 : CHANNEL(buffer)->topic); if (buf) free (buf); if (buf2) free (buf2); } else - mvwprintw (ptr_win->win_title, 0, 0, format, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_title, 0, 0, format, " "); } else { if (buffer->type == BUFFER_TYPE_STANDARD) { - mvwprintw (ptr_win->win_title, 0, 0, + mvwprintw (GUI_CURSES(ptr_win)->win_title, 0, 0, format, PACKAGE_STRING " " WEECHAT_COPYRIGHT_DATE " - " WEECHAT_WEBSITE); } else - mvwprintw (ptr_win->win_title, 0, 0, format, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_title, 0, 0, format, " "); } - wnoutrefresh (ptr_win->win_title); + wnoutrefresh (GUI_CURSES(ptr_win)->win_title); refresh (); } } @@ -234,10 +229,10 @@ gui_chat_display_new_line (t_gui_window *window, int num_lines, int count, { if ((!simulate) && (window->win_chat_cursor_x <= window->win_chat_width - 1)) { - wmove (window->win_chat, + wmove (GUI_CURSES(window)->win_chat, window->win_chat_cursor_y, window->win_chat_cursor_x); - wclrtoeol (window->win_chat); + wclrtoeol (GUI_CURSES(window)->win_chat); } window->win_chat_cursor_y++; } @@ -423,7 +418,7 @@ gui_chat_display_word_raw (t_gui_window *window, char *string) { char *prev_char, *next_char, saved_char; - wmove (window->win_chat, + wmove (GUI_CURSES(window)->win_chat, window->win_chat_cursor_y, window->win_chat_cursor_x); @@ -438,7 +433,7 @@ gui_chat_display_word_raw (t_gui_window *window, char *string) { saved_char = next_char[0]; next_char[0] = '\0'; - wprintw (window->win_chat, "%s", prev_char); + wprintw (GUI_CURSES(window)->win_chat, "%s", prev_char); next_char[0] = saved_char; } @@ -488,10 +483,10 @@ gui_chat_display_word (t_gui_window *window, { if (!simulate) { - wmove (window->win_chat, + wmove (GUI_CURSES(window)->win_chat, window->win_chat_cursor_y, window->win_chat_cursor_x); - wclrtoeol (window->win_chat); + wclrtoeol (GUI_CURSES(window)->win_chat); } window->win_chat_cursor_x += line->length_align; } @@ -743,7 +738,7 @@ gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count, (window->buffer->last_read_line == line->prev_line)) { gui_chat_set_weechat_color (window, COLOR_WIN_CHAT_READ_MARKER); - mvwprintw (window->win_chat, read_marker_y, read_marker_x, + mvwprintw (GUI_CURSES(window)->win_chat, read_marker_y, read_marker_x, "%c", cfg_look_read_marker[0]); } } @@ -878,16 +873,16 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) { if (erase) { - gui_window_set_weechat_color (ptr_win->win_chat, COLOR_WIN_CHAT); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, COLOR_WIN_CHAT); snprintf (format_empty, 32, "%%-%ds", ptr_win->win_chat_width); for (i = 0; i < ptr_win->win_chat_height; i++) { - mvwprintw (ptr_win->win_chat, i, 0, format_empty, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_chat, i, 0, format_empty, " "); } } - gui_window_set_weechat_color (ptr_win->win_chat, COLOR_WIN_CHAT); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, COLOR_WIN_CHAT); if (buffer->type == BUFFER_TYPE_DCC) { @@ -900,57 +895,57 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) break; /* nickname and filename */ - gui_window_set_weechat_color (ptr_win->win_chat, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, (ptr_dcc == dcc_selected) ? COLOR_DCC_SELECTED : COLOR_WIN_CHAT); - mvwprintw (ptr_win->win_chat, i, 0, "%s %-16s ", + mvwprintw (GUI_CURSES(ptr_win)->win_chat, i, 0, "%s %-16s ", (ptr_dcc == dcc_selected) ? "***" : " ", ptr_dcc->nick); buf = channel_iconv_decode (SERVER(buffer), CHANNEL(buffer), (DCC_IS_CHAT(ptr_dcc->type)) ? _(ptr_dcc->filename) : ptr_dcc->filename); - wprintw (ptr_win->win_chat, "%s", buf); + wprintw (GUI_CURSES(ptr_win)->win_chat, "%s", buf); free (buf); if (DCC_IS_FILE(ptr_dcc->type)) { if (ptr_dcc->filename_suffix > 0) - wprintw (ptr_win->win_chat, " (.%d)", + wprintw (GUI_CURSES(ptr_win)->win_chat, " (.%d)", ptr_dcc->filename_suffix); } /* status */ - gui_window_set_weechat_color (ptr_win->win_chat, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, (ptr_dcc == dcc_selected) ? COLOR_DCC_SELECTED : COLOR_WIN_CHAT); - mvwprintw (ptr_win->win_chat, i + 1, 0, "%s %s ", + mvwprintw (GUI_CURSES(ptr_win)->win_chat, i + 1, 0, "%s %s ", (ptr_dcc == dcc_selected) ? "***" : " ", (DCC_IS_RECV(ptr_dcc->type)) ? "-->>" : "<<--"); - gui_window_set_weechat_color (ptr_win->win_chat, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, COLOR_DCC_WAITING + ptr_dcc->status); buf = channel_iconv_decode (SERVER(buffer), CHANNEL(buffer), _(dcc_status_string[ptr_dcc->status])); - wprintw (ptr_win->win_chat, "%-10s", buf); + wprintw (GUI_CURSES(ptr_win)->win_chat, "%-10s", buf); free (buf); /* other infos */ - gui_window_set_weechat_color (ptr_win->win_chat, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, (ptr_dcc == dcc_selected) ? COLOR_DCC_SELECTED : COLOR_WIN_CHAT); if (DCC_IS_FILE(ptr_dcc->type)) { - wprintw (ptr_win->win_chat, " ["); + wprintw (GUI_CURSES(ptr_win)->win_chat, " ["); if (ptr_dcc->size == 0) num_bars = 10; else num_bars = (int)((((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100) / 10); for (j = 0; j < num_bars - 1; j++) - wprintw (ptr_win->win_chat, "="); + wprintw (GUI_CURSES(ptr_win)->win_chat, "="); if (num_bars > 0) - wprintw (ptr_win->win_chat, ">"); + wprintw (GUI_CURSES(ptr_win)->win_chat, ">"); for (j = 0; j < 10 - num_bars; j++) - wprintw (ptr_win->win_chat, " "); + wprintw (GUI_CURSES(ptr_win)->win_chat, " "); if (ptr_dcc->size < 1024*10) num_unit = 0; @@ -960,12 +955,12 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) num_unit = 2; else num_unit = 3; - wprintw (ptr_win->win_chat, "] %3lu%% ", + wprintw (GUI_CURSES(ptr_win)->win_chat, "] %3lu%% ", (unsigned long)(((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100)); sprintf (format, "%s %%s / %s %%s", unit_format[num_unit], unit_format[num_unit]); - wprintw (ptr_win->win_chat, format, + wprintw (GUI_CURSES(ptr_win)->win_chat, format, ((long double)(ptr_dcc->pos)) / ((long double)(unit_divide[num_unit])), unit_name[num_unit], ((long double)(ptr_dcc->size)) / ((long double)(unit_divide[num_unit])), @@ -977,11 +972,11 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) num_unit = 2; else num_unit = 3; - wprintw (ptr_win->win_chat, " ("); + wprintw (GUI_CURSES(ptr_win)->win_chat, " ("); if (ptr_dcc->status == DCC_ACTIVE) { - wprintw (ptr_win->win_chat, _("ETA")); - wprintw (ptr_win->win_chat, ": %.2lu:%.2lu:%.2lu - ", + wprintw (GUI_CURSES(ptr_win)->win_chat, _("ETA")); + wprintw (GUI_CURSES(ptr_win)->win_chat, ": %.2lu:%.2lu:%.2lu - ", ptr_dcc->eta / 3600, (ptr_dcc->eta / 60) % 60, ptr_dcc->eta % 60); @@ -990,7 +985,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) buf = channel_iconv_decode (SERVER(buffer), CHANNEL(buffer), unit_name[num_unit]); - wprintw (ptr_win->win_chat, format, + wprintw (GUI_CURSES(ptr_win)->win_chat, format, ((long double) ptr_dcc->bytes_per_sec) / ((long double)(unit_divide[num_unit])), buf); free (buf); @@ -999,10 +994,10 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) { date_tmp = localtime (&(ptr_dcc->start_time)); strftime (date, sizeof (date) - 1, "%a, %d %b %Y %H:%M:%S", date_tmp); - wprintw (ptr_win->win_chat, " %s", date); + wprintw (GUI_CURSES(ptr_win)->win_chat, " %s", date); } - wclrtoeol (ptr_win->win_chat); + wclrtoeol (GUI_CURSES(ptr_win)->win_chat); ptr_win->dcc_last_displayed = ptr_dcc; i += 2; @@ -1078,7 +1073,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) ptr_win->win_chat_cursor_y = ptr_win->win_chat_height - 1; } } - wnoutrefresh (ptr_win->win_chat); + wnoutrefresh (GUI_CURSES(ptr_win)->win_chat); refresh (); } } diff --git a/weechat/src/gui/curses/gui-color.c b/src/gui/curses/gui-curses-color.c index 9fd1d85de..da8cee765 100644 --- a/weechat/src/gui/curses/gui-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-color.c: color functions for Curses GUI */ +/* gui-curses-color.c: color functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -28,12 +28,6 @@ #include <string.h> #include <ctype.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/weeconfig.h" diff --git a/weechat/src/gui/curses/gui-infobar.c b/src/gui/curses/gui-curses-infobar.c index 73abf75c0..f76ec0943 100644 --- a/weechat/src/gui/curses/gui-infobar.c +++ b/src/gui/curses/gui-curses-infobar.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-infobar.c: infobar display functions for Curses GUI */ +/* gui-curses-infobar.c: infobar display functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -27,12 +27,6 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" @@ -63,17 +57,17 @@ gui_infobar_draw_time (t_gui_buffer *buffer) local_time = localtime (&time_seconds); if (local_time) { - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); - mvwprintw (ptr_win->win_infobar, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); + mvwprintw (GUI_CURSES(ptr_win)->win_infobar, 0, 1, "%02d:%02d", local_time->tm_hour, local_time->tm_min); if (cfg_look_infobar_seconds) - wprintw (ptr_win->win_infobar, + wprintw (GUI_CURSES(ptr_win)->win_infobar, ":%02d", local_time->tm_sec); } - wnoutrefresh (ptr_win->win_infobar); + wnoutrefresh (GUI_CURSES(ptr_win)->win_infobar); } } @@ -98,40 +92,40 @@ gui_infobar_draw (t_gui_buffer *buffer, int erase) for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { if (erase) - gui_window_curses_clear (ptr_win->win_infobar, COLOR_WIN_INFOBAR); + gui_window_curses_clear (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); time_seconds = time (NULL); local_time = localtime (&time_seconds); if (local_time) { strftime (text_time, 1024, cfg_look_infobar_timestamp, local_time); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); - wprintw (ptr_win->win_infobar, "["); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); - wprintw (ptr_win->win_infobar, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); + wprintw (GUI_CURSES(ptr_win)->win_infobar, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); + wprintw (GUI_CURSES(ptr_win)->win_infobar, "%02d:%02d", local_time->tm_hour, local_time->tm_min); if (cfg_look_infobar_seconds) - wprintw (ptr_win->win_infobar, + wprintw (GUI_CURSES(ptr_win)->win_infobar, ":%02d", local_time->tm_sec); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); - wprintw (ptr_win->win_infobar, "]"); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); - wprintw (ptr_win->win_infobar, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); + wprintw (GUI_CURSES(ptr_win)->win_infobar, "]"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); + wprintw (GUI_CURSES(ptr_win)->win_infobar, " %s", text_time); } if (gui_infobar) { - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); - wprintw (ptr_win->win_infobar, " | "); - gui_window_set_weechat_color (ptr_win->win_infobar, gui_infobar->color); - wprintw (ptr_win->win_infobar, "%s", gui_infobar->text); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); + wprintw (GUI_CURSES(ptr_win)->win_infobar, " | "); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, gui_infobar->color); + wprintw (GUI_CURSES(ptr_win)->win_infobar, "%s", gui_infobar->text); } - wnoutrefresh (ptr_win->win_infobar); + wnoutrefresh (GUI_CURSES(ptr_win)->win_infobar); refresh (); } } diff --git a/weechat/src/gui/curses/gui-input.c b/src/gui/curses/gui-curses-input.c index 9e93c9a1a..f6ed316f1 100644 --- a/weechat/src/gui/curses/gui-input.c +++ b/src/gui/curses/gui-curses-input.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-input: input display functions for Curses GUI */ +/* gui-curses-input: input display functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -26,12 +26,6 @@ #include <stdlib.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" @@ -57,18 +51,18 @@ gui_input_set_color (t_gui_window *window, int irc_color) irc_color %= GUI_NUM_IRC_COLORS; if (gui_irc_colors[irc_color][1] & A_BOLD) - wattron (window->win_input, A_BOLD); + wattron (GUI_CURSES(window)->win_input, A_BOLD); if (((fg == -1) || (fg == 99)) && ((bg == -1) || (bg == 99))) - wattron (window->win_input, COLOR_PAIR(63)); + wattron (GUI_CURSES(window)->win_input, COLOR_PAIR(63)); else { if ((fg == -1) || (fg == 99)) fg = WEECHAT_COLOR_WHITE; if ((bg == -1) || (bg == 99)) bg = 0; - wattron (window->win_input, COLOR_PAIR((bg * 8) + fg)); + wattron (GUI_CURSES(window)->win_input, COLOR_PAIR((bg * 8) + fg)); } } @@ -158,7 +152,7 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) char *pos, saved_char, *modes; int char_size, mode_found; - wmove (window->win_input, 0, 0); + wmove (GUI_CURSES(window)->win_input, 0, 0); pos = cfg_look_input_format; while (pos && pos[0]) { @@ -171,18 +165,18 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) case 'c': if (CHANNEL(window->buffer)) { - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_CHANNEL); - wprintw (window->win_input, "%s", + wprintw (GUI_CURSES(window)->win_input, "%s", CHANNEL(window->buffer)->name); } else { if (SERVER(window->buffer)) { - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_SERVER); - wprintw (window->win_input, "%s", + wprintw (GUI_CURSES(window)->win_input, "%s", SERVER(window->buffer)->name); } } @@ -200,14 +194,14 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) } if (mode_found) { - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT); - wprintw (window->win_input, "+"); + wprintw (GUI_CURSES(window)->win_input, "+"); for (modes = SERVER(window->buffer)->nick_modes; modes && modes[0]; modes++) { if (modes[0] != ' ') - wprintw (window->win_input, "%c", + wprintw (GUI_CURSES(window)->win_input, "%c", modes[0]); } } @@ -215,9 +209,9 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) pos++; break; case 'n': - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_NICK); - wprintw (window->win_input, "%s", nick); + wprintw (GUI_CURSES(window)->win_input, "%s", nick); pos++; break; default: @@ -226,15 +220,15 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) char_size = utf8_char_size (pos); saved_char = pos[char_size]; pos[char_size] = '\0'; - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_DELIMITERS); - wprintw (window->win_input, "%%%s", pos); + wprintw (GUI_CURSES(window)->win_input, "%%%s", pos); pos[char_size] = saved_char; pos += char_size; } else { - wprintw (window->win_input, "%%"); + wprintw (GUI_CURSES(window)->win_input, "%%"); pos++; } break; @@ -244,9 +238,9 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) char_size = utf8_char_size (pos); saved_char = pos[char_size]; pos[char_size] = '\0'; - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_DELIMITERS); - wprintw (window->win_input, "%s", pos); + wprintw (GUI_CURSES(window)->win_input, "%s", pos); pos[char_size] = saved_char; pos += char_size; break; @@ -283,12 +277,12 @@ gui_input_draw_text (t_gui_window *window, int input_width) if (color != last_color) { if (color == -1) - gui_window_set_weechat_color (window->win_input, COLOR_WIN_INPUT); + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT); else gui_input_set_color (window, color); } last_color = color; - wprintw (window->win_input, "%s", ptr_start); + wprintw (GUI_CURSES(window)->win_input, "%s", ptr_start); ptr_next[0] = saved_char; ptr_start = ptr_next; pos_mask += size; @@ -320,7 +314,7 @@ gui_input_draw (t_gui_buffer *buffer, int erase) if (ptr_win->buffer == buffer) { if (erase) - gui_window_curses_clear (ptr_win->win_input, COLOR_WIN_INPUT); + gui_window_curses_clear (GUI_CURSES(ptr_win)->win_input, COLOR_WIN_INPUT); switch (buffer->type) { @@ -372,13 +366,13 @@ gui_input_draw (t_gui_buffer *buffer, int erase) if (display_prompt) gui_input_draw_prompt (ptr_win, ptr_nickname); - gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input, COLOR_WIN_INPUT); snprintf (format, 32, "%%-%ds", ptr_win->win_width - prompt_length); if (ptr_win == gui_current_window) gui_input_draw_text (ptr_win, ptr_win->win_width - prompt_length); else - wprintw (ptr_win->win_input, format, ""); - wclrtoeol (ptr_win->win_input); + wprintw (GUI_CURSES(ptr_win)->win_input, format, ""); + wclrtoeol (GUI_CURSES(ptr_win)->win_input); ptr_win->win_input_x = prompt_length + (buffer->input_buffer_pos - buffer->input_buffer_1st_display); if (ptr_win == gui_current_window) @@ -388,38 +382,38 @@ gui_input_draw (t_gui_buffer *buffer, int erase) break; case BUFFER_TYPE_DCC: dcc_selected = (ptr_win->dcc_selected) ? (t_irc_dcc *) ptr_win->dcc_selected : dcc_list; - wmove (ptr_win->win_input, 0, 0); + wmove (GUI_CURSES(ptr_win)->win_input, 0, 0); if (dcc_selected) { switch (dcc_selected->status) { case DCC_WAITING: if (DCC_IS_RECV(dcc_selected->type)) - wprintw (ptr_win->win_input, _(" [A] Accept")); - wprintw (ptr_win->win_input, _(" [C] Cancel")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [A] Accept")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [C] Cancel")); break; case DCC_CONNECTING: case DCC_ACTIVE: - wprintw (ptr_win->win_input, _(" [C] Cancel")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [C] Cancel")); break; case DCC_DONE: case DCC_FAILED: case DCC_ABORTED: - wprintw (ptr_win->win_input, _(" [R] Remove")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [R] Remove")); break; } } - wprintw (ptr_win->win_input, _(" [P] Purge old DCC")); - wprintw (ptr_win->win_input, _(" [Q] Close DCC view")); - wclrtoeol (ptr_win->win_input); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [P] Purge old DCC")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [Q] Close DCC view")); + wclrtoeol (GUI_CURSES(ptr_win)->win_input); ptr_win->win_input_x = 0; if (ptr_win == gui_current_window) move (ptr_win->win_y + ptr_win->win_height - 1, ptr_win->win_x); break; case BUFFER_TYPE_RAW_DATA: - mvwprintw (ptr_win->win_input, 0, 0, _(" [Q] Close raw data view")); - wclrtoeol (ptr_win->win_input); + mvwprintw (GUI_CURSES(ptr_win)->win_input, 0, 0, _(" [Q] Close raw data view")); + wclrtoeol (GUI_CURSES(ptr_win)->win_input); ptr_win->win_input_x = 0; if (ptr_win == gui_current_window) move (ptr_win->win_y + ptr_win->win_height - 1, @@ -427,7 +421,7 @@ gui_input_draw (t_gui_buffer *buffer, int erase) break; } doupdate (); - wrefresh (ptr_win->win_input); + wrefresh (GUI_CURSES(ptr_win)->win_input); refresh (); } } diff --git a/src/gui/curses/gui-keyboard.c b/src/gui/curses/gui-curses-keyboard.c index 25c4bedd6..02a1c2f6c 100644 --- a/src/gui/curses/gui-keyboard.c +++ b/src/gui/curses/gui-curses-keyboard.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-keyboard.c: keyboard functions for Curses GUI */ +/* gui-curses-keyboard.c: keyboard functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -27,15 +27,10 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" +#include "gui-curses.h" #ifdef PLUGINS #include "../../plugins/plugins.h" @@ -43,7 +38,7 @@ /* - * gui_keyboard__default_bindings: create default key bindings + * gui_keyboard_default_bindings: create default key bindings */ void @@ -53,90 +48,90 @@ gui_keyboard_default_bindings () char key_str[32], command[32]; /* keys binded with internal functions */ - gui_key_bind ( /* RC */ "ctrl-M", "return"); - gui_key_bind ( /* RC */ "ctrl-J", "return"); - gui_key_bind ( /* tab */ "ctrl-I", "tab"); - gui_key_bind ( /* basckp */ "ctrl-H", "backspace"); - gui_key_bind ( /* basckp */ "ctrl-?", "backspace"); - gui_key_bind ( /* del */ "meta2-3~", "delete"); - gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line"); - gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); - gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); - gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); - gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars"); - gui_key_bind ( /* home */ "meta2-1~", "home"); - gui_key_bind ( /* home */ "meta2-H", "home"); - gui_key_bind ( /* home */ "meta2-7~", "home"); - gui_key_bind ( /* ^A */ "ctrl-A", "home"); - gui_key_bind ( /* end */ "meta2-4~", "end"); - gui_key_bind ( /* end */ "meta2-F", "end"); - gui_key_bind ( /* end */ "meta2-8~", "end"); - gui_key_bind ( /* ^E */ "ctrl-E", "end"); - gui_key_bind ( /* left */ "meta2-D", "left"); - gui_key_bind ( /* right */ "meta2-C", "right"); - gui_key_bind ( /* up */ "meta2-A", "up"); - gui_key_bind ( /* ^up */ "meta-Oa", "up_global"); - gui_key_bind ( /* down */ "meta2-B", "down"); - gui_key_bind ( /* ^down */ "meta-Ob", "down_global"); - gui_key_bind ( /* pgup */ "meta2-5~", "page_up"); - gui_key_bind ( /* pgdn */ "meta2-6~", "page_down"); - gui_key_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up"); - gui_key_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down"); - gui_key_bind ( /* m-home */ "meta-meta2-1~", "scroll_top"); - gui_key_bind ( /* m-end */ "meta-meta2-4~", "scroll_bottom"); - gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear"); - gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up"); - gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down"); - gui_key_bind ( /* m-F11 */ "meta-meta2-23~", "nick_beginning"); - gui_key_bind ( /* m-F12 */ "meta-meta2-24~", "nick_end"); - gui_key_bind ( /* ^L */ "ctrl-L", "refresh"); - gui_key_bind ( /* m-a */ "meta-a", "jump_smart"); - gui_key_bind ( /* m-b */ "meta-b", "previous_word"); - gui_key_bind ( /* ^left */ "meta-Od", "previous_word"); - gui_key_bind ( /* m-d */ "meta-d", "delete_next_word"); - gui_key_bind ( /* m-f */ "meta-f", "next_word"); - gui_key_bind ( /* ^right */ "meta-Oc", "next_word"); - gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear"); - gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); - gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); - gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); - gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); - gui_key_bind ( /* m-j,m-r */ "meta-jmeta-r", "jump_raw_data"); - gui_key_bind ( /* m-k */ "meta-k", "grab_key"); - gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); - gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); - gui_key_bind ( /* m-r */ "meta-r", "delete_line"); - gui_key_bind ( /* m-s */ "meta-s", "switch_server"); - gui_key_bind ( /* m-u */ "meta-u", "scroll_unread"); + gui_keyboard_bind ( /* RC */ "ctrl-M", "return"); + gui_keyboard_bind ( /* RC */ "ctrl-J", "return"); + gui_keyboard_bind ( /* tab */ "ctrl-I", "tab"); + gui_keyboard_bind ( /* basckp */ "ctrl-H", "backspace"); + gui_keyboard_bind ( /* basckp */ "ctrl-?", "backspace"); + gui_keyboard_bind ( /* del */ "meta2-3~", "delete"); + gui_keyboard_bind ( /* ^K */ "ctrl-K", "delete_end_line"); + gui_keyboard_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); + gui_keyboard_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); + gui_keyboard_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); + gui_keyboard_bind ( /* ^T */ "ctrl-T", "transpose_chars"); + gui_keyboard_bind ( /* home */ "meta2-1~", "home"); + gui_keyboard_bind ( /* home */ "meta2-H", "home"); + gui_keyboard_bind ( /* home */ "meta2-7~", "home"); + gui_keyboard_bind ( /* ^A */ "ctrl-A", "home"); + gui_keyboard_bind ( /* end */ "meta2-4~", "end"); + gui_keyboard_bind ( /* end */ "meta2-F", "end"); + gui_keyboard_bind ( /* end */ "meta2-8~", "end"); + gui_keyboard_bind ( /* ^E */ "ctrl-E", "end"); + gui_keyboard_bind ( /* left */ "meta2-D", "left"); + gui_keyboard_bind ( /* right */ "meta2-C", "right"); + gui_keyboard_bind ( /* up */ "meta2-A", "up"); + gui_keyboard_bind ( /* ^up */ "meta-Oa", "up_global"); + gui_keyboard_bind ( /* down */ "meta2-B", "down"); + gui_keyboard_bind ( /* ^down */ "meta-Ob", "down_global"); + gui_keyboard_bind ( /* pgup */ "meta2-5~", "page_up"); + gui_keyboard_bind ( /* pgdn */ "meta2-6~", "page_down"); + gui_keyboard_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up"); + gui_keyboard_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down"); + gui_keyboard_bind ( /* m-home */ "meta-meta2-1~", "scroll_top"); + gui_keyboard_bind ( /* m-end */ "meta-meta2-4~", "scroll_bottom"); + gui_keyboard_bind ( /* F10 */ "meta2-21~", "infobar_clear"); + gui_keyboard_bind ( /* F11 */ "meta2-23~", "nick_page_up"); + gui_keyboard_bind ( /* F12 */ "meta2-24~", "nick_page_down"); + gui_keyboard_bind ( /* m-F11 */ "meta-meta2-23~", "nick_beginning"); + gui_keyboard_bind ( /* m-F12 */ "meta-meta2-24~", "nick_end"); + gui_keyboard_bind ( /* ^L */ "ctrl-L", "refresh"); + gui_keyboard_bind ( /* m-a */ "meta-a", "jump_smart"); + gui_keyboard_bind ( /* m-b */ "meta-b", "previous_word"); + gui_keyboard_bind ( /* ^left */ "meta-Od", "previous_word"); + gui_keyboard_bind ( /* m-d */ "meta-d", "delete_next_word"); + gui_keyboard_bind ( /* m-f */ "meta-f", "next_word"); + gui_keyboard_bind ( /* ^right */ "meta-Oc", "next_word"); + gui_keyboard_bind ( /* m-h */ "meta-h", "hotlist_clear"); + gui_keyboard_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); + gui_keyboard_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); + gui_keyboard_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); + gui_keyboard_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); + gui_keyboard_bind ( /* m-j,m-r */ "meta-jmeta-r", "jump_raw_data"); + gui_keyboard_bind ( /* m-k */ "meta-k", "grab_key"); + gui_keyboard_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); + gui_keyboard_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); + gui_keyboard_bind ( /* m-r */ "meta-r", "delete_line"); + gui_keyboard_bind ( /* m-s */ "meta-s", "switch_server"); + gui_keyboard_bind ( /* m-u */ "meta-u", "scroll_unread"); /* keys binded with commands */ - gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); - gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1"); - gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); - gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1"); - gui_key_bind ( /* F7 */ "meta2-18~", "/window -1"); - gui_key_bind ( /* F8 */ "meta2-19~", "/window +1"); - gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); - gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); - gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); - gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); - gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10"); - gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1"); - gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2"); - gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3"); - gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4"); - gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5"); - gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6"); - gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7"); - gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8"); - gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9"); + gui_keyboard_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); + gui_keyboard_bind ( /* F5 */ "meta2-15~", "/buffer -1"); + gui_keyboard_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); + gui_keyboard_bind ( /* F6 */ "meta2-17~", "/buffer +1"); + gui_keyboard_bind ( /* F7 */ "meta2-18~", "/window -1"); + gui_keyboard_bind ( /* F8 */ "meta2-19~", "/window +1"); + gui_keyboard_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); + gui_keyboard_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); + gui_keyboard_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); + gui_keyboard_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); + gui_keyboard_bind ( /* m-0 */ "meta-0", "/buffer 10"); + gui_keyboard_bind ( /* m-1 */ "meta-1", "/buffer 1"); + gui_keyboard_bind ( /* m-2 */ "meta-2", "/buffer 2"); + gui_keyboard_bind ( /* m-3 */ "meta-3", "/buffer 3"); + gui_keyboard_bind ( /* m-4 */ "meta-4", "/buffer 4"); + gui_keyboard_bind ( /* m-5 */ "meta-5", "/buffer 5"); + gui_keyboard_bind ( /* m-6 */ "meta-6", "/buffer 6"); + gui_keyboard_bind ( /* m-7 */ "meta-7", "/buffer 7"); + gui_keyboard_bind ( /* m-8 */ "meta-8", "/buffer 8"); + gui_keyboard_bind ( /* m-9 */ "meta-9", "/buffer 9"); /* bind meta-j + {01..99} to switch to buffers # > 10 */ for (i = 1; i < 100; i++) { sprintf (key_str, "meta-j%02d", i); sprintf (command, "/buffer %d", i); - gui_key_bind (key_str, command); + gui_keyboard_bind (key_str, command); } } @@ -152,7 +147,7 @@ gui_keyboard_grab_end () char *buffer_before_key; /* get expanded name (for example: ^U => ctrl-u) */ - expanded_key = gui_key_get_expanded_name (gui_key_buffer); + expanded_key = gui_keyboard_get_expanded_name (gui_key_buffer); if (expanded_key) { @@ -289,7 +284,7 @@ gui_keyboard_read () /*gui_printf (gui_current_window->buffer, "gui_input_read: key = %s (%d)\n", key_str, key);*/ - if ((gui_key_pressed (key_str) != 0) && (insert_ok)) + if ((gui_keyboard_pressed (key_str) != 0) && (insert_ok)) { if (strcmp (key_str, "^^") == 0) key_str[1] = '\0'; diff --git a/weechat/src/gui/curses/gui-nicklist.c b/src/gui/curses/gui-curses-nicklist.c index 2022df25c..4bfa95de0 100644 --- a/weechat/src/gui/curses/gui-nicklist.c +++ b/src/gui/curses/gui-curses-nicklist.c @@ -17,19 +17,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-nicklist.c: nicklist display functions for Curses GUI */ +/* gui-curses-nicklist.c: nicklist display functions for Curses GUI */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/weeconfig.h" @@ -60,28 +54,28 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase) if (gui_window_calculate_pos_size (ptr_win, 0)) { - delwin (ptr_win->win_chat); - delwin (ptr_win->win_nick); - ptr_win->win_chat = newwin (ptr_win->win_chat_height, - ptr_win->win_chat_width, - ptr_win->win_chat_y, - ptr_win->win_chat_x); - ptr_win->win_nick = newwin (ptr_win->win_nick_height, - ptr_win->win_nick_width, - ptr_win->win_nick_y, - ptr_win->win_nick_x); + delwin (GUI_CURSES(ptr_win)->win_chat); + delwin (GUI_CURSES(ptr_win)->win_nick); + GUI_CURSES(ptr_win)->win_chat = newwin (ptr_win->win_chat_height, + ptr_win->win_chat_width, + ptr_win->win_chat_y, + ptr_win->win_chat_x); + GUI_CURSES(ptr_win)->win_nick = newwin (ptr_win->win_nick_height, + ptr_win->win_nick_width, + ptr_win->win_nick_y, + ptr_win->win_nick_x); gui_chat_draw (buffer, 1); erase = 1; } if (erase) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK); snprintf (format_empty, 32, "%%-%ds", ptr_win->win_nick_width); for (i = 0; i < ptr_win->win_nick_height; i++) { - mvwprintw (ptr_win->win_nick, i, 0, format_empty, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, i, 0, format_empty, " "); } } @@ -99,33 +93,33 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase) if (has_colors ()) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_SEP); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_SEP); switch (cfg_look_nicklist_position) { case CFG_LOOK_NICKLIST_LEFT: - mvwvline (ptr_win->win_nick, + mvwvline (GUI_CURSES(ptr_win)->win_nick, 0, ptr_win->win_nick_width - 1, ACS_VLINE, ptr_win->win_chat_height); break; case CFG_LOOK_NICKLIST_RIGHT: - mvwvline (ptr_win->win_nick, + mvwvline (GUI_CURSES(ptr_win)->win_nick, 0, 0, ACS_VLINE, ptr_win->win_chat_height); break; case CFG_LOOK_NICKLIST_TOP: - mvwhline (ptr_win->win_nick, + mvwhline (GUI_CURSES(ptr_win)->win_nick, ptr_win->win_nick_height - 1, 0, ACS_HLINE, ptr_win->win_chat_width); break; case CFG_LOOK_NICKLIST_BOTTOM: - mvwhline (ptr_win->win_nick, + mvwhline (GUI_CURSES(ptr_win)->win_nick, 0, 0, ACS_HLINE, ptr_win->win_chat_width); break; } } - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK); x = 0; y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0; column = 0; @@ -163,53 +157,53 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase) if ( ((i == 0) && (ptr_win->win_nick_start > 0)) || ((i == nicks_displayed - 1) && (ptr_nick->next_nick)) ) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_MORE); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_MORE); j = (max_length + 1) >= 4 ? 4 : max_length + 1; for (x2 = 1; x2 <= j; x2++) - mvwprintw (ptr_win->win_nick, y, x + x2, "+"); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x + x2, "+"); } else { if (ptr_nick->flags & NICK_CHANOWNER) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANOWNER); - mvwprintw (ptr_win->win_nick, y, x, "~"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_CHANOWNER); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "~"); x++; } else if (ptr_nick->flags & NICK_CHANADMIN) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANADMIN); - mvwprintw (ptr_win->win_nick, y, x, "&"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_CHANADMIN); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "&"); x++; } else if (ptr_nick->flags & NICK_OP) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_OP); - mvwprintw (ptr_win->win_nick, y, x, "@"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_OP); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "@"); x++; } else if (ptr_nick->flags & NICK_HALFOP) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_HALFOP); - mvwprintw (ptr_win->win_nick, y, x, "%%"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_HALFOP); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "%%"); x++; } else if (ptr_nick->flags & NICK_VOICE) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_VOICE); - mvwprintw (ptr_win->win_nick, y, x, "+"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_VOICE); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "+"); x++; } else { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); - mvwprintw (ptr_win->win_nick, y, x, " "); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, " "); x++; } - gui_window_set_weechat_color (ptr_win->win_nick, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, ((cfg_irc_away_check > 0) && (ptr_nick->flags & NICK_AWAY)) ? COLOR_WIN_NICK_AWAY : COLOR_WIN_NICK); - mvwprintw (ptr_win->win_nick, y, x, format, ptr_nick->nick); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, format, ptr_nick->nick); ptr_nick = ptr_nick->next_nick; @@ -229,7 +223,7 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase) } } } - wnoutrefresh (ptr_win->win_nick); + wnoutrefresh (GUI_CURSES(ptr_win)->win_nick); refresh (); } } diff --git a/src/gui/curses/gui-curses-panel.c b/src/gui/curses/gui-curses-panel.c new file mode 100644 index 000000000..9e5f6b7f4 --- /dev/null +++ b/src/gui/curses/gui-curses-panel.c @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* gui-curses-panel.c: panel functions for Curses GUI */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> + +#include "../../common/weechat.h" +#include "../gui.h" +#include "../../irc/irc.h" +#include "gui-curses.h" + + +/* + * gui_panel_get_size: get total panel size for a position + */ + +int +gui_panel_get_size (t_gui_window *window, int position) +{ + t_gui_panel_window *ptr_panel_win; + int total_size; + + total_size = 0; + for (ptr_panel_win = GUI_CURSES(window)->panel_windows; ptr_panel_win; + ptr_panel_win = ptr_panel_win->next_panel_window) + { + if (ptr_panel_win->panel->position == position) + { + switch (position) + { + case GUI_PANEL_TOP: + case GUI_PANEL_BOTTOM: + total_size += ptr_panel_win->height; + break; + case GUI_PANEL_LEFT: + case GUI_PANEL_RIGHT: + total_size += ptr_panel_win->width; + break; + } + if (ptr_panel_win->panel->separator) + total_size++; + } + } + return total_size; +} + +/* + * gui_panel_window_new: create a new "window panel" for a panel, in screen or a window + * if window is not NULL, panel window will be in this window + */ + +int +gui_panel_window_new (t_gui_panel *panel, t_gui_window *window) +{ + t_gui_panel_window *new_panel_win; + int x1, y1, x2, y2; + + if (window) + { + x1 = window->win_x; + y1 = window->win_y + 1; + x2 = x1 + window->win_width - 1; + y2 = y1 + window->win_height - 1 - 4; + } + else + { + x1 = 0; + y1 = 0; + x2 = gui_window_get_width () - 1; + y2 = gui_window_get_height () - 1; + } + + if ((new_panel_win = (t_gui_panel_window *) malloc (sizeof (t_gui_panel_window)))) + { + new_panel_win->panel = panel; + if (window) + { + panel->panel_window = NULL; + new_panel_win->next_panel_window = GUI_CURSES(window)->panel_windows; + GUI_CURSES(window)->panel_windows = new_panel_win; + } + else + { + panel->panel_window = new_panel_win; + new_panel_win->next_panel_window = NULL; + } + switch (panel->position) + { + case GUI_PANEL_TOP: + new_panel_win->x = x1; + new_panel_win->y = y1; + new_panel_win->width = x2 - x1 + 1; + new_panel_win->height = panel->size; + break; + case GUI_PANEL_BOTTOM: + new_panel_win->x = x1; + new_panel_win->y = y2 - panel->size + 1; + new_panel_win->width = x2 - x1 + 1; + new_panel_win->height = panel->size; + break; + case GUI_PANEL_LEFT: + new_panel_win->x = x1; + new_panel_win->y = y1; + new_panel_win->width = panel->size; + new_panel_win->height = y2 - y1 + 1; + break; + case GUI_PANEL_RIGHT: + new_panel_win->x = x2 - panel->size + 1; + new_panel_win->y = y1; + new_panel_win->width = panel->size; + new_panel_win->height = y2 - y1 + 1; + break; + } + new_panel_win->win_panel = newwin (new_panel_win->height, + new_panel_win->width, + new_panel_win->y, + new_panel_win->x); + new_panel_win->win_separator = NULL; + if (new_panel_win->panel->separator) + { + switch (panel->position) + { + case GUI_PANEL_LEFT: + new_panel_win->win_separator = newwin (new_panel_win->height, + 1, + new_panel_win->y, + new_panel_win->x + new_panel_win->width); + break; + } + } + return 1; + } + else + return 0; +} + +/* + * gui_panel_window_free: delete a panel window + */ + +void +gui_panel_window_free (void *panel_win) +{ + t_gui_panel_window *ptr_panel_win; + + ptr_panel_win = (t_gui_panel_window *)panel_win; + + free (ptr_panel_win); +} + +/* + * gui_panel_redraw_buffer: redraw panels for windows displaying a buffer + */ + +void +gui_panel_redraw_buffer (t_gui_buffer *buffer) +{ + t_gui_window *ptr_win; + t_gui_panel_window *ptr_panel_win; + + if (!gui_ok) + return; + + for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + { + if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0)) + { + for (ptr_panel_win = GUI_CURSES(ptr_win)->panel_windows; + ptr_panel_win; + ptr_panel_win = ptr_panel_win->next_panel_window) + { + switch (ptr_panel_win->panel->position) + { + case GUI_PANEL_LEFT: + break; + } + } + } + } +} diff --git a/src/gui/curses/gui-status.c b/src/gui/curses/gui-curses-status.c index 5da5bb6ec..a8cd59a4d 100644 --- a/src/gui/curses/gui-status.c +++ b/src/gui/curses/gui-curses-status.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-status.c: status display functions for Curses GUI */ +/* gui-curses-status.c: status display functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -27,12 +27,6 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" @@ -62,84 +56,84 @@ gui_status_draw (t_gui_buffer *buffer, int erase) for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { if (erase) - gui_window_curses_clear (ptr_win->win_status, COLOR_WIN_STATUS); + gui_window_curses_clear (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); /* display number of buffers */ - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - mvwprintw (ptr_win->win_status, 0, 0, "["); - gui_window_set_weechat_color (ptr_win->win_status, + mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, 0, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", (last_gui_buffer) ? last_gui_buffer->number : 0); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "] "); + wprintw (GUI_CURSES(ptr_win)->win_status, "] "); /* display "<servers>" or current server */ if (ptr_win->buffer->all_servers) { - wprintw (ptr_win->win_status, "["); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, _("<servers>")); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, _("<servers>")); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "] "); + wprintw (GUI_CURSES(ptr_win)->win_status, "] "); } else if (SERVER(ptr_win->buffer) && SERVER(ptr_win->buffer)->name) { - wprintw (ptr_win->win_status, "["); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%s", SERVER(ptr_win->buffer)->name); + wprintw (GUI_CURSES(ptr_win)->win_status, "%s", SERVER(ptr_win->buffer)->name); if (SERVER(ptr_win->buffer)->is_away) - wprintw (ptr_win->win_status, _("(away)")); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, _("(away)")); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "] "); + wprintw (GUI_CURSES(ptr_win)->win_status, "] "); } /* infos about current server buffer */ if (SERVER(ptr_win->buffer) && !CHANNEL(ptr_win->buffer)) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_win->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_CHANNEL); if (SERVER(ptr_win->buffer)->is_connected) - wprintw (ptr_win->win_status, "[%s] ", + wprintw (GUI_CURSES(ptr_win)->win_status, "[%s] ", SERVER(ptr_win->buffer)->name); else - wprintw (ptr_win->win_status, "(%s) ", + wprintw (GUI_CURSES(ptr_win)->win_status, "(%s) ", SERVER(ptr_win->buffer)->name); if (ptr_win->buffer->all_servers) { server_get_number_buffer (SERVER(ptr_win->buffer), &server_pos, &server_total); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "("); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "("); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", server_pos); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", server_pos); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "/"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "/"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", server_total); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", server_total); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ") "); + wprintw (GUI_CURSES(ptr_win)->win_status, ") "); } } @@ -147,14 +141,14 @@ gui_status_draw (t_gui_buffer *buffer, int erase) /* infos about current channel/pv buffer */ if (SERVER(ptr_win->buffer) && CHANNEL(ptr_win->buffer)) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_win->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_CHANNEL); if (((CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_PRIVATE) && (CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_DCC_CHAT) @@ -162,20 +156,20 @@ gui_status_draw (t_gui_buffer *buffer, int erase) || ((CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT) && (CHANNEL(ptr_win->buffer)->dcc_chat) && (((t_irc_dcc *)(CHANNEL(ptr_win->buffer)->dcc_chat))->sock < 0))) - wprintw (ptr_win->win_status, "(%s)", + wprintw (GUI_CURSES(ptr_win)->win_status, "(%s)", CHANNEL(ptr_win->buffer)->name); else - wprintw (ptr_win->win_status, "%s", + wprintw (GUI_CURSES(ptr_win)->win_status, "%s", CHANNEL(ptr_win->buffer)->name); if (ptr_win->buffer == CHANNEL(ptr_win->buffer)->buffer) { /* display channel modes */ if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_CHANNEL) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "("); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "("); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); i = 0; first_mode = 1; @@ -185,63 +179,63 @@ gui_status_draw (t_gui_buffer *buffer, int erase) { if (first_mode) { - wprintw (ptr_win->win_status, "+"); + wprintw (GUI_CURSES(ptr_win)->win_status, "+"); first_mode = 0; } - wprintw (ptr_win->win_status, "%c", + wprintw (GUI_CURSES(ptr_win)->win_status, "%c", CHANNEL(ptr_win->buffer)->modes[i]); } i++; } if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_KEY] != ' ') - wprintw (ptr_win->win_status, ",%s", + wprintw (GUI_CURSES(ptr_win)->win_status, ",%s", CHANNEL(ptr_win->buffer)->key); if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_LIMIT] != ' ') - wprintw (ptr_win->win_status, ",%d", + wprintw (GUI_CURSES(ptr_win)->win_status, ",%d", CHANNEL(ptr_win->buffer)->limit); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ")"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ")"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); } /* display DCC if private is DCC CHAT */ if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "("); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "("); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_CHANNEL); - wprintw (ptr_win->win_status, "DCC"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "DCC"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ")"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ")"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); } } - wprintw (ptr_win->win_status, " "); + wprintw (GUI_CURSES(ptr_win)->win_status, " "); } if (!SERVER(ptr_win->buffer)) { - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_win->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_CHANNEL); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_CHANNEL); switch (ptr_win->buffer->type) { case BUFFER_TYPE_STANDARD: - wprintw (ptr_win->win_status, _("[not connected] ")); + wprintw (GUI_CURSES(ptr_win)->win_status, _("[not connected] ")); break; case BUFFER_TYPE_DCC: - wprintw (ptr_win->win_status, "<DCC> "); + wprintw (GUI_CURSES(ptr_win)->win_status, "<DCC> "); break; case BUFFER_TYPE_RAW_DATA: - wprintw (ptr_win->win_status, _("<RAW_IRC> ")); + wprintw (GUI_CURSES(ptr_win)->win_status, _("<RAW_IRC> ")); break; } } @@ -249,11 +243,11 @@ gui_status_draw (t_gui_buffer *buffer, int erase) /* display list of other active windows (if any) with numbers */ if (hotlist) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "["); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, _("Act: ")); + wprintw (GUI_CURSES(ptr_win)->win_status, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); + wprintw (GUI_CURSES(ptr_win)->win_status, _("Act: ")); names_count = 0; for (ptr_hotlist = hotlist; ptr_hotlist; @@ -262,22 +256,22 @@ gui_status_draw (t_gui_buffer *buffer, int erase) switch (ptr_hotlist->priority) { case HOTLIST_LOW: - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DATA_OTHER); display_name = ((cfg_look_hotlist_names_level & 1) != 0); break; case HOTLIST_MSG: - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DATA_MSG); display_name = ((cfg_look_hotlist_names_level & 2) != 0); break; case HOTLIST_PRIVATE: - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DATA_PRIVATE); display_name = ((cfg_look_hotlist_names_level & 4) != 0); break; case HOTLIST_HIGHLIGHT: - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DATA_HIGHLIGHT); display_name = ((cfg_look_hotlist_names_level & 8) != 0); break; @@ -288,7 +282,7 @@ gui_status_draw (t_gui_buffer *buffer, int erase) switch (ptr_hotlist->buffer->type) { case BUFFER_TYPE_STANDARD: - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_hotlist->buffer->number); if (display_name && (cfg_look_hotlist_names_count != 0) @@ -296,54 +290,54 @@ gui_status_draw (t_gui_buffer *buffer, int erase) { names_count++; - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); if (cfg_look_hotlist_names_length == 0) snprintf (format, sizeof (format) - 1, "%%s"); else snprintf (format, sizeof (format) - 1, "%%.%ds", cfg_look_hotlist_names_length); if (BUFFER_IS_SERVER(ptr_hotlist->buffer)) - wprintw (ptr_win->win_status, format, + wprintw (GUI_CURSES(ptr_win)->win_status, format, (ptr_hotlist->server) ? ptr_hotlist->server->name : SERVER(ptr_hotlist->buffer)->name); else if (BUFFER_IS_CHANNEL(ptr_hotlist->buffer) || BUFFER_IS_PRIVATE(ptr_hotlist->buffer)) - wprintw (ptr_win->win_status, format, CHANNEL(ptr_hotlist->buffer)->name); + wprintw (GUI_CURSES(ptr_win)->win_status, format, CHANNEL(ptr_hotlist->buffer)->name); } break; case BUFFER_TYPE_DCC: - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_hotlist->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "DCC"); + wprintw (GUI_CURSES(ptr_win)->win_status, "DCC"); break; case BUFFER_TYPE_RAW_DATA: - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_hotlist->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, _("RAW_IRC")); + wprintw (GUI_CURSES(ptr_win)->win_status, _("RAW_IRC")); break; } if (ptr_hotlist->next_hotlist) - wprintw (ptr_win->win_status, ","); + wprintw (GUI_CURSES(ptr_win)->win_status, ","); } - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "] "); + wprintw (GUI_CURSES(ptr_win)->win_status, "] "); } /* display lag */ @@ -351,15 +345,15 @@ gui_status_draw (t_gui_buffer *buffer, int erase) { if (SERVER(ptr_win->buffer)->lag / 1000 >= cfg_irc_lag_min_show) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "["); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, _("Lag: %.1f"), + wprintw (GUI_CURSES(ptr_win)->win_status, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); + wprintw (GUI_CURSES(ptr_win)->win_status, _("Lag: %.1f"), ((float)(SERVER(ptr_win->buffer)->lag)) / 1000); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "]"); + wprintw (GUI_CURSES(ptr_win)->win_status, "]"); } } @@ -375,28 +369,28 @@ gui_status_draw (t_gui_buffer *buffer, int erase) x -= strlen (more) - 1; if (x < 0) x = 0; - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_MORE); if (ptr_win->scroll) - mvwprintw (ptr_win->win_status, 0, x, "%s", more); + mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, x, "%s", more); else { snprintf (format, sizeof (format) - 1, "%%-%ds", (int)(strlen (more))); - mvwprintw (ptr_win->win_status, 0, x, format, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, x, format, " "); } if (BUFFER_HAS_NICKLIST(ptr_win->buffer)) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, " ["); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%s", str_nicks); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, " ["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); + wprintw (GUI_CURSES(ptr_win)->win_status, "%s", str_nicks); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "]"); + wprintw (GUI_CURSES(ptr_win)->win_status, "]"); } free (more); - wnoutrefresh (ptr_win->win_status); + wnoutrefresh (GUI_CURSES(ptr_win)->win_status); refresh (); } } diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 27dcdd372..1e7eee7da 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -21,6 +21,12 @@ #ifndef __WEECHAT_GUI_CURSES_H #define __WEECHAT_GUI_CURSES_H 1 +#ifdef HAVE_NCURSESW_CURSES_H +#include <ncursesw/ncurses.h> +#else +#include <ncurses.h> +#endif + /* shift ncurses colors for compatibility with colors in IRC messages (same as other IRC clients) */ @@ -33,8 +39,39 @@ #define WEECHAT_COLOR_CYAN COLOR_YELLOW #define WEECHAT_COLOR_WHITE COLOR_WHITE +#define GUI_CURSES(window) ((t_gui_curses_objects *)(window->gui_objects)) + +typedef struct t_gui_panel_window t_gui_panel_window; + +struct t_gui_panel_window +{ + t_gui_panel *panel; /* pointer to panel */ + int x, y; /* position of window */ + int width, height; /* window size */ + WINDOW *win_panel; /* panel Curses window */ + WINDOW *win_separator; /* separator (optional) */ + t_gui_panel_window *next_panel_window; + /* link to next panel window */ + /* (only used if panel is in windows) */ +}; + +typedef struct t_gui_curses_objects t_gui_curses_objects; + +struct t_gui_curses_objects +{ + WINDOW *win_title; /* title window */ + WINDOW *win_chat; /* chat window (example: channel) */ + WINDOW *win_nick; /* nick window */ + WINDOW *win_status; /* status window */ + WINDOW *win_infobar; /* info bar window */ + WINDOW *win_input; /* input window */ + WINDOW *win_separator; /* separation between 2 splited (V) win */ + t_gui_panel_window *panel_windows; /* panel windows */ +}; + extern t_gui_color gui_weechat_colors[]; extern int gui_irc_colors[GUI_NUM_IRC_COLORS][2]; +extern int gui_refresh_screen_needed; /* color functions */ extern int gui_color_get_pair (int); @@ -54,4 +91,8 @@ extern void gui_window_refresh_screen_sigwinch (); extern void gui_window_set_title (); extern void gui_window_reset_title (); +/* panel functions */ +extern int gui_panel_get_size (t_gui_window *, int); +extern void gui_panel_redraw_buffer (t_gui_buffer *); + #endif /* gui-curses.h */ diff --git a/src/gui/gtk/Makefile.am b/src/gui/gtk/Makefile.am index 46b5667dd..d4e09550c 100644 --- a/src/gui/gtk/Makefile.am +++ b/src/gui/gtk/Makefile.am @@ -21,8 +21,8 @@ bin_PROGRAMS = weechat-gtk if PLUGINS weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \ - ../gui-window.o ../gui-keyboard.o \ - ../gui-action.o \ + ../gui-window.o ../gui-panel.o \ + ../gui-keyboard.o ../gui-action.o \ ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ ../../plugins/lib_weechat_plugins.a \ @@ -31,8 +31,8 @@ weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \ $(GNUTLS_LFLAGS) else weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \ - ../gui-window.o ../gui-keyboard.o \ - ../gui-action.o \ + ../gui-window.o ../gui-panel.o \ + ../gui-keyboard.o ../gui-action.o \ ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ $(PLUGINS_LIBS) \ @@ -40,13 +40,14 @@ weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \ $(GNUTLS_LFLAGS) endif -weechat_gtk_SOURCES = gui-chat.c \ - gui-color.c \ - gui-infobar.c \ - gui-input.c \ - gui-keyboard.c \ - gui-main.c \ - gui-nicklist.c \ - gui-status.c \ - gui-window.c \ +weechat_gtk_SOURCES = gui-gtk-chat.c \ + gui-gtk-color.c \ + gui-gtk-infobar.c \ + gui-gtk-input.c \ + gui-gtk-keyboard.c \ + gui-gtk-main.c \ + gui-gtk-nicklist.c \ + gui-gtk-status.c \ + gui-gtk-window.c \ + gui-gtk-panel.c \ gui-gtk.h diff --git a/weechat/src/gui/gtk/gui-chat.c b/src/gui/gtk/gui-gtk-chat.c index 6773bcd33..15ed9dc63 100644 --- a/weechat/src/gui/gtk/gui-chat.c +++ b/src/gui/gtk/gui-gtk-chat.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-chat.c: chat display functions for Gtk GUI */ +/* gui-gtk-chat.c: chat display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -28,8 +28,6 @@ #include <string.h> #include <ctype.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" @@ -619,11 +617,11 @@ gui_chat_draw_line (t_gui_buffer *buffer, t_gui_line *line) text_without_color = gui_color_decode ((unsigned char *)(line->data), 0); if (text_without_color) { - gtk_text_buffer_insert_at_cursor (ptr_win->textbuffer_chat, + gtk_text_buffer_insert_at_cursor (GUI_GTK(ptr_win)->textbuffer_chat, (char *)text_without_color, -1); - gtk_text_buffer_insert_at_cursor (ptr_win->textbuffer_chat, + gtk_text_buffer_insert_at_cursor (GUI_GTK(ptr_win)->textbuffer_chat, "\n", -1); - gtk_text_buffer_get_bounds (ptr_win->textbuffer_chat, + gtk_text_buffer_get_bounds (GUI_GTK(ptr_win)->textbuffer_chat, &start, &end); /* TODO */ /*gtk_text_buffer_apply_tag (ptr_win->textbuffer_chat, ptr_win->texttag_chat, &start, &end);*/ diff --git a/weechat/src/gui/gtk/gui-color.c b/src/gui/gtk/gui-gtk-color.c index 852a2af5b..3536e6649 100644 --- a/weechat/src/gui/gtk/gui-color.c +++ b/src/gui/gtk/gui-gtk-color.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-color.c: color functions for Gtk GUI */ +/* gui-gtk-color.c: color functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -28,8 +28,6 @@ #include <string.h> #include <ctype.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/weeconfig.h" diff --git a/src/gui/gtk/gui-infobar.c b/src/gui/gtk/gui-gtk-infobar.c index f90eb8209..76b26b9c7 100644 --- a/src/gui/gtk/gui-infobar.c +++ b/src/gui/gtk/gui-gtk-infobar.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-infobar.c: infobar display functions for Gtk GUI */ +/* gui-gtk-infobar.c: infobar display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -27,8 +27,6 @@ #include <stdlib.h> #include <string.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" diff --git a/src/gui/gtk/gui-input.c b/src/gui/gtk/gui-gtk-input.c index e38089c36..b3ba16fdb 100644 --- a/src/gui/gtk/gui-input.c +++ b/src/gui/gtk/gui-gtk-input.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-input: user input functions for Gtk GUI */ +/* gui-gtk-input: user input functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -26,8 +26,6 @@ #include <stdlib.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" diff --git a/src/gui/gtk/gui-gtk-keyboard.c b/src/gui/gtk/gui-gtk-keyboard.c new file mode 100644 index 000000000..6e0e36095 --- /dev/null +++ b/src/gui/gtk/gui-gtk-keyboard.c @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* gui-gtk-keyboard.c: keyboard functions for Gtk GUI */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <string.h> + +#include "../../common/weechat.h" +#include "../gui.h" +#include "../../common/utf8.h" +#include "gui-gtk.h" + +#ifdef PLUGINS +#include "../../plugins/plugins.h" +#endif + + +/* + * gui_keyboard_default_bindings: create default key bindings + */ + +void +gui_keyboard_default_bindings () +{ + int i; + char key_str[32], command[32]; + + /* keys binded with internal functions */ + gui_keyboard_bind ( /* RC */ "ctrl-M", "return"); + gui_keyboard_bind ( /* RC */ "ctrl-J", "return"); + gui_keyboard_bind ( /* tab */ "ctrl-I", "tab"); + gui_keyboard_bind ( /* basckp */ "ctrl-H", "backspace"); + gui_keyboard_bind ( /* basckp */ "ctrl-?", "backspace"); + gui_keyboard_bind ( /* del */ "meta2-3~", "delete"); + gui_keyboard_bind ( /* ^K */ "ctrl-K", "delete_end_line"); + gui_keyboard_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); + gui_keyboard_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); + gui_keyboard_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); + gui_keyboard_bind ( /* ^T */ "ctrl-T", "transpose_chars"); + gui_keyboard_bind ( /* home */ "meta2-1~", "home"); + gui_keyboard_bind ( /* home */ "meta2-H", "home"); + gui_keyboard_bind ( /* home */ "meta2-7~", "home"); + gui_keyboard_bind ( /* ^A */ "ctrl-A", "home"); + gui_keyboard_bind ( /* end */ "meta2-4~", "end"); + gui_keyboard_bind ( /* end */ "meta2-F", "end"); + gui_keyboard_bind ( /* end */ "meta2-8~", "end"); + gui_keyboard_bind ( /* ^E */ "ctrl-E", "end"); + gui_keyboard_bind ( /* left */ "meta2-D", "left"); + gui_keyboard_bind ( /* right */ "meta2-C", "right"); + gui_keyboard_bind ( /* up */ "meta2-A", "up"); + gui_keyboard_bind ( /* ^up */ "meta-Oa", "up_global"); + gui_keyboard_bind ( /* down */ "meta2-B", "down"); + gui_keyboard_bind ( /* ^down */ "meta-Ob", "down_global"); + gui_keyboard_bind ( /* pgup */ "meta2-5~", "page_up"); + gui_keyboard_bind ( /* pgdn */ "meta2-6~", "page_down"); + gui_keyboard_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up"); + gui_keyboard_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down"); + gui_keyboard_bind ( /* F10 */ "meta2-21~", "infobar_clear"); + gui_keyboard_bind ( /* F11 */ "meta2-23~", "nick_page_up"); + gui_keyboard_bind ( /* F12 */ "meta2-24~", "nick_page_down"); + gui_keyboard_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning"); + gui_keyboard_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end"); + gui_keyboard_bind ( /* ^L */ "ctrl-L", "refresh"); + gui_keyboard_bind ( /* m-a */ "meta-a", "jump_smart"); + gui_keyboard_bind ( /* m-b */ "meta-b", "previous_word"); + gui_keyboard_bind ( /* ^left */ "meta-Od", "previous_word"); + gui_keyboard_bind ( /* m-d */ "meta-d", "delete_next_word"); + gui_keyboard_bind ( /* m-f */ "meta-f", "next_word"); + gui_keyboard_bind ( /* ^right */ "meta-Oc", "next_word"); + gui_keyboard_bind ( /* m-h */ "meta-h", "hotlist_clear"); + gui_keyboard_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); + gui_keyboard_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); + gui_keyboard_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); + gui_keyboard_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); + gui_keyboard_bind ( /* m-k */ "meta-k", "grab_key"); + gui_keyboard_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); + gui_keyboard_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); + gui_keyboard_bind ( /* m-r */ "meta-r", "delete_line"); + gui_keyboard_bind ( /* m-s */ "meta-s", "switch_server"); + gui_keyboard_bind ( /* m-u */ "meta-u", "scroll_unread"); + + /* keys binded with commands */ + gui_keyboard_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); + gui_keyboard_bind ( /* F5 */ "meta2-15~", "/buffer -1"); + gui_keyboard_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); + gui_keyboard_bind ( /* F6 */ "meta2-17~", "/buffer +1"); + gui_keyboard_bind ( /* F7 */ "meta2-18~", "/window -1"); + gui_keyboard_bind ( /* F8 */ "meta2-19~", "/window +1"); + gui_keyboard_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); + gui_keyboard_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); + gui_keyboard_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); + gui_keyboard_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); + gui_keyboard_bind ( /* m-0 */ "meta-0", "/buffer 10"); + gui_keyboard_bind ( /* m-1 */ "meta-1", "/buffer 1"); + gui_keyboard_bind ( /* m-2 */ "meta-2", "/buffer 2"); + gui_keyboard_bind ( /* m-3 */ "meta-3", "/buffer 3"); + gui_keyboard_bind ( /* m-4 */ "meta-4", "/buffer 4"); + gui_keyboard_bind ( /* m-5 */ "meta-5", "/buffer 5"); + gui_keyboard_bind ( /* m-6 */ "meta-6", "/buffer 6"); + gui_keyboard_bind ( /* m-7 */ "meta-7", "/buffer 7"); + gui_keyboard_bind ( /* m-8 */ "meta-8", "/buffer 8"); + gui_keyboard_bind ( /* m-9 */ "meta-9", "/buffer 9"); + + /* bind meta-j + {01..99} to switch to buffers # > 10 */ + for (i = 1; i < 100; i++) + { + sprintf (key_str, "meta-j%02d", i); + sprintf (command, "/buffer %d", i); + gui_keyboard_bind (key_str, command); + } +} + +/* + * gui_keyboard_grab_end: insert grabbed key in input buffer + */ + +void +gui_keyboard_grab_end () +{ + char *expanded_key; + + /* get expanded name (for example: ^U => ctrl-u) */ + expanded_key = gui_keyboard_get_expanded_name (gui_key_buffer); + + if (expanded_key) + { + if (gui_current_window->buffer->has_input) + { + gui_insert_string_input (gui_current_window, expanded_key, -1); + gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key); + gui_input_draw (gui_current_window->buffer, 1); + } + free (expanded_key); + } + + /* end grab mode */ + gui_key_grab = 0; + gui_key_grab_count = 0; + gui_key_buffer[0] = '\0'; +} + +/* + * gui_keyboard_read: read keyboard chars + */ + +void +gui_keyboard_read () +{ + /* TODO: write this function for Gtk */ +} diff --git a/src/gui/gtk/gui-main.c b/src/gui/gtk/gui-gtk-main.c index 01dc67d65..8c349d07d 100644 --- a/src/gui/gtk/gui-main.c +++ b/src/gui/gtk/gui-gtk-main.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-main.c: main loop and keyboard management for Gtk GUI */ +/* gui-gtk-main.c: main loop for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -30,8 +30,6 @@ #include <string.h> #include <signal.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/fifo.h" @@ -58,7 +56,7 @@ GtkWidget *label1; /* - * gui_main_loop: main loop for WeeChat with ncurses GUI + * gui_main_loop: main loop for WeeChat with Gtk GUI */ void @@ -190,6 +188,10 @@ gui_main_end () if (gui_input_clipboard) free(gui_input_clipboard); + /* delete all panels */ + while (gui_panels) + gui_panel_free (gui_panels); + /* delete all windows */ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { diff --git a/weechat/src/gui/gtk/gui-nicklist.c b/src/gui/gtk/gui-gtk-nicklist.c index eebdc5b51..494ef2b46 100644 --- a/weechat/src/gui/gtk/gui-nicklist.c +++ b/src/gui/gtk/gui-gtk-nicklist.c @@ -17,15 +17,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-nicklist.c: nicklist display functions for Gtk GUI */ +/* gui-gtk-nicklist.c: nicklist display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/weeconfig.h" diff --git a/src/gui/gtk/gui-gtk-panel.c b/src/gui/gtk/gui-gtk-panel.c new file mode 100644 index 000000000..c90694cbe --- /dev/null +++ b/src/gui/gtk/gui-gtk-panel.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* gui-gtk-panel.c: panel functions for Gtk GUI */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> + +#include "../../common/weechat.h" +#include "../gui.h" +#include "gui-gtk.h" + + +/* + * gui_panel_window_new: create a new "window panel" for a panel, in screen or a window + * if window is not NULL, panel window will be in this window + */ + +int +gui_panel_window_new (t_gui_panel *panel, t_gui_window *window) +{ + /* TODO: write this function for Gtk */ + (void) panel; + (void) window; + + return 1; +} + +/* + * gui_panel_window_free: delete a panel window + */ + +void +gui_panel_window_free (void *panel_win) +{ + t_gui_panel_window *ptr_panel_win; + + ptr_panel_win = (t_gui_panel_window *)panel_win; + + free (ptr_panel_win); +} diff --git a/src/gui/gtk/gui-status.c b/src/gui/gtk/gui-gtk-status.c index 436f7b7f9..48b149da5 100644 --- a/src/gui/gtk/gui-status.c +++ b/src/gui/gtk/gui-gtk-status.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-status.c: status display functions for Gtk GUI */ +/* gui-gtk-status.c: status display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -27,8 +27,6 @@ #include <stdlib.h> #include <string.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" diff --git a/src/gui/gtk/gui-window.c b/src/gui/gtk/gui-gtk-window.c index 72791d6c6..427b2627e 100644 --- a/src/gui/gtk/gui-window.c +++ b/src/gui/gtk/gui-gtk-window.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-window.c: window display functions for Gtk GUI */ +/* gui-gtk-window.c: window display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -27,8 +27,6 @@ #include <stdlib.h> #include <string.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" @@ -37,6 +35,62 @@ /* + * gui_window_get_width: get screen width + */ + +int +gui_window_get_width () +{ + return 0; +} + +/* + * gui_window_get_height: get screen height + */ + +int +gui_window_get_height () +{ + return 0; +} + +/* + * gui_window_objects_init: init Gtk widgets + */ + +int +gui_window_objects_init (t_gui_window *window) +{ + t_gui_gtk_objects *new_objects; + + if ((new_objects = (t_gui_gtk_objects *) malloc (sizeof (t_gui_gtk_objects)))) + { + window->gui_objects = new_objects; + GUI_GTK(window)->textview_chat = NULL; + GUI_GTK(window)->textbuffer_chat = NULL; + GUI_GTK(window)->texttag_chat = NULL; + GUI_GTK(window)->textview_nicklist = NULL; + GUI_GTK(window)->textbuffer_nicklist = NULL; + GUI_GTK(window)->panel_windows = NULL; + return 1; + } + else + return 0; +} + +/* + * gui_window_objects_free: free Gtk widgets for a window + */ + +void +gui_window_objects_free (t_gui_window *window, int free_separator) +{ + /* TODO: write this function for Gtk */ + (void) window; + (void) free_separator; +} + +/* * gui_window_set_weechat_color: set WeeChat color for window */ @@ -98,25 +152,8 @@ gui_window_draw_separator (t_gui_window *window) void gui_window_redraw_buffer (t_gui_buffer *buffer) { - t_gui_window *ptr_win; - - if (!gui_ok) - return; - - for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) - { - if (ptr_win->buffer == buffer) - { - gui_chat_draw_title (buffer, 1); - gui_chat_draw (buffer, 1); - if (ptr_win->win_nick) - gui_nicklist_draw (buffer, 1); - gui_status_draw (buffer, 1); - if (cfg_look_infobar) - gui_infobar_draw (buffer, 1); - gui_input_draw (buffer, 1); - } - } + /* TODO: write this function for Gtk */ + (void) buffer; } /* @@ -142,32 +179,32 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer) window->win_nick_start = 0; gui_window_calculate_pos_size (window, 1); - if (!window->textview_chat) + if (!GUI_GTK(window)->textview_chat) { - window->textview_chat = gtk_text_view_new (); - gtk_widget_show (window->textview_chat); - gtk_container_add (GTK_CONTAINER (scrolledwindow_chat), window->textview_chat); - gtk_widget_set_size_request (window->textview_chat, 300, -1); - gtk_text_view_set_editable (GTK_TEXT_VIEW (window->textview_chat), FALSE); - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (window->textview_chat), FALSE); + GUI_GTK(window)->textview_chat = gtk_text_view_new (); + gtk_widget_show (GUI_GTK(window)->textview_chat); + gtk_container_add (GTK_CONTAINER (scrolledwindow_chat), GUI_GTK(window)->textview_chat); + gtk_widget_set_size_request (GUI_GTK(window)->textview_chat, 300, -1); + gtk_text_view_set_editable (GTK_TEXT_VIEW (GUI_GTK(window)->textview_chat), FALSE); + gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (GUI_GTK(window)->textview_chat), FALSE); - window->textbuffer_chat = gtk_text_buffer_new (NULL); - gtk_text_view_set_buffer (GTK_TEXT_VIEW (window->textview_chat), window->textbuffer_chat); + GUI_GTK(window)->textbuffer_chat = gtk_text_buffer_new (NULL); + gtk_text_view_set_buffer (GTK_TEXT_VIEW (GUI_GTK(window)->textview_chat), GUI_GTK(window)->textbuffer_chat); - /*window->texttag_chat = gtk_text_buffer_create_tag(window->textbuffer_chat, "courier", "font_family", "lucida");*/ - gtk_text_buffer_get_bounds (window->textbuffer_chat, &start, &end); - gtk_text_buffer_apply_tag (window->textbuffer_chat, window->texttag_chat, &start, &end); + /*GUI_GTK(window)->texttag_chat = gtk_text_buffer_create_tag(GUI_GTK(window)->textbuffer_chat, "courier", "font_family", "lucida");*/ + gtk_text_buffer_get_bounds (GUI_GTK(window)->textbuffer_chat, &start, &end); + gtk_text_buffer_apply_tag (GUI_GTK(window)->textbuffer_chat, GUI_GTK(window)->texttag_chat, &start, &end); } - if (BUFFER_IS_CHANNEL(buffer) && !window->textbuffer_nicklist) + if (BUFFER_IS_CHANNEL(buffer) && !GUI_GTK(window)->textbuffer_nicklist) { - window->textview_nicklist = gtk_text_view_new (); - gtk_widget_show (window->textview_nicklist); - gtk_container_add (GTK_CONTAINER (scrolledwindow_nick), window->textview_nicklist); - gtk_text_view_set_editable (GTK_TEXT_VIEW (window->textview_nicklist), FALSE); - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (window->textview_nicklist), FALSE); + GUI_GTK(window)->textview_nicklist = gtk_text_view_new (); + gtk_widget_show (GUI_GTK(window)->textview_nicklist); + gtk_container_add (GTK_CONTAINER (scrolledwindow_nick), GUI_GTK(window)->textview_nicklist); + gtk_text_view_set_editable (GTK_TEXT_VIEW (GUI_GTK(window)->textview_nicklist), FALSE); + gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (GUI_GTK(window)->textview_nicklist), FALSE); - window->textbuffer_nicklist = gtk_text_buffer_new (NULL); - gtk_text_view_set_buffer (GTK_TEXT_VIEW (window->textview_nicklist), window->textbuffer_nicklist); + GUI_GTK(window)->textbuffer_nicklist = gtk_text_buffer_new (NULL); + gtk_text_view_set_buffer (GTK_TEXT_VIEW (GUI_GTK(window)->textview_nicklist), GUI_GTK(window)->textbuffer_nicklist); } window->start_line = NULL; @@ -430,20 +467,6 @@ gui_window_nick_page_down (t_gui_window *window) } /* - * gui_window_init_subwindows: init subwindows for a WeeChat window - */ - -void -gui_window_init_subwindows (t_gui_window *window) -{ - window->textview_chat = NULL; - window->textbuffer_chat = NULL; - window->texttag_chat = NULL; - window->textview_nicklist = NULL; - window->textbuffer_nicklist = NULL; -} - -/* * gui_window_auto_resize: auto-resize all windows, according to % of global size * This function is called after a terminal resize. * Returns 0 if ok, -1 if all window should be merged @@ -845,3 +868,18 @@ gui_window_reset_title () { /* This function does nothing in Gtk GUI */ } + +/* + * gui_window_objects_print_log: print Gtk objects infos in log + * (usually for crash dump) + */ + +void +gui_window_objects_print_log (t_gui_window *window) +{ + weechat_log_printf (" textview_chat . . . : 0x%X\n", GUI_GTK(window)->textview_chat); + weechat_log_printf (" textbuffer_chat . . : 0x%X\n", GUI_GTK(window)->textbuffer_chat); + weechat_log_printf (" texttag_chat. . . . : 0x%X\n", GUI_GTK(window)->texttag_chat); + weechat_log_printf (" textview_nicklist . : 0x%X\n", GUI_GTK(window)->textview_nicklist); + weechat_log_printf (" textbuffer_nicklist : 0x%X\n", GUI_GTK(window)->textbuffer_nicklist); +} diff --git a/src/gui/gtk/gui-gtk.h b/src/gui/gtk/gui-gtk.h index c8a44108f..9bfb18151 100644 --- a/src/gui/gtk/gui-gtk.h +++ b/src/gui/gtk/gui-gtk.h @@ -21,6 +21,8 @@ #ifndef __WEECHAT_GUI_GTK_H #define __WEECHAT_GUI_GTK_H 1 +#include <gtk/gtk.h> + /* TODO: remove these temporary defines */ #define A_BOLD 1 @@ -48,6 +50,29 @@ #define WEECHAT_COLOR_CYAN COLOR_YELLOW #define WEECHAT_COLOR_WHITE COLOR_WHITE +#define GUI_GTK(window) ((t_gui_gtk_objects *)(window->gui_objects)) + +typedef struct t_gui_panel_window t_gui_panel_window; + +struct t_gui_panel_window +{ + t_gui_panel *panel; /* pointer to panel */ + int x, y; /* position of window */ + int width, height; /* window size */ +}; + +typedef struct t_gui_gtk_objects t_gui_gtk_objects; + +struct t_gui_gtk_objects +{ + GtkWidget *textview_chat; /* textview widget for chat */ + GtkTextBuffer *textbuffer_chat; /* textbuffer widget for chat */ + GtkTextTag *texttag_chat; /* texttag widget for chat */ + GtkWidget *textview_nicklist; /* textview widget for nicklist */ + GtkTextBuffer *textbuffer_nicklist; /* textbuffer widget for nicklist */ + t_gui_panel_window *panel_windows; /* panel windows */ +}; + extern t_gui_color gui_weechat_colors[]; extern int gui_irc_colors[GUI_NUM_IRC_COLORS][2]; diff --git a/src/gui/gtk/gui-keyboard.c b/src/gui/gtk/gui-keyboard.c deleted file mode 100644 index 508a055eb..000000000 --- a/src/gui/gtk/gui-keyboard.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> - * See README for License detail, AUTHORS for developers list. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* gui-keyboard.c: keyboard functions for Gtk GUI */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdlib.h> -#include <string.h> - -#include <gtk/gtk.h> - -#include "../../common/weechat.h" -#include "../gui.h" -#include "../../common/utf8.h" - -#ifdef PLUGINS -#include "../../plugins/plugins.h" -#endif - - -/* - * gui_keyboard_default_bindings: create default key bindings - */ - -void -gui_keyboard_default_bindings () -{ - int i; - char key_str[32], command[32]; - - /* keys binded with internal functions */ - gui_key_bind ( /* RC */ "ctrl-M", "return"); - gui_key_bind ( /* RC */ "ctrl-J", "return"); - gui_key_bind ( /* tab */ "ctrl-I", "tab"); - gui_key_bind ( /* basckp */ "ctrl-H", "backspace"); - gui_key_bind ( /* basckp */ "ctrl-?", "backspace"); - gui_key_bind ( /* del */ "meta2-3~", "delete"); - gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line"); - gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); - gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); - gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); - gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars"); - gui_key_bind ( /* home */ "meta2-1~", "home"); - gui_key_bind ( /* home */ "meta2-H", "home"); - gui_key_bind ( /* home */ "meta2-7~", "home"); - gui_key_bind ( /* ^A */ "ctrl-A", "home"); - gui_key_bind ( /* end */ "meta2-4~", "end"); - gui_key_bind ( /* end */ "meta2-F", "end"); - gui_key_bind ( /* end */ "meta2-8~", "end"); - gui_key_bind ( /* ^E */ "ctrl-E", "end"); - gui_key_bind ( /* left */ "meta2-D", "left"); - gui_key_bind ( /* right */ "meta2-C", "right"); - gui_key_bind ( /* up */ "meta2-A", "up"); - gui_key_bind ( /* ^up */ "meta-Oa", "up_global"); - gui_key_bind ( /* down */ "meta2-B", "down"); - gui_key_bind ( /* ^down */ "meta-Ob", "down_global"); - gui_key_bind ( /* pgup */ "meta2-5~", "page_up"); - gui_key_bind ( /* pgdn */ "meta2-6~", "page_down"); - gui_key_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up"); - gui_key_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down"); - gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear"); - gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up"); - gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down"); - gui_key_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning"); - gui_key_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end"); - gui_key_bind ( /* ^L */ "ctrl-L", "refresh"); - gui_key_bind ( /* m-a */ "meta-a", "jump_smart"); - gui_key_bind ( /* m-b */ "meta-b", "previous_word"); - gui_key_bind ( /* ^left */ "meta-Od", "previous_word"); - gui_key_bind ( /* m-d */ "meta-d", "delete_next_word"); - gui_key_bind ( /* m-f */ "meta-f", "next_word"); - gui_key_bind ( /* ^right */ "meta-Oc", "next_word"); - gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear"); - gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); - gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); - gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); - gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); - gui_key_bind ( /* m-k */ "meta-k", "grab_key"); - gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); - gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); - gui_key_bind ( /* m-r */ "meta-r", "delete_line"); - gui_key_bind ( /* m-s */ "meta-s", "switch_server"); - gui_key_bind ( /* m-u */ "meta-u", "scroll_unread"); - - /* keys binded with commands */ - gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); - gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1"); - gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); - gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1"); - gui_key_bind ( /* F7 */ "meta2-18~", "/window -1"); - gui_key_bind ( /* F8 */ "meta2-19~", "/window +1"); - gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); - gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); - gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); - gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); - gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10"); - gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1"); - gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2"); - gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3"); - gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4"); - gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5"); - gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6"); - gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7"); - gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8"); - gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9"); - - /* bind meta-j + {01..99} to switch to buffers # > 10 */ - for (i = 1; i < 100; i++) - { - sprintf (key_str, "meta-j%02d", i); - sprintf (command, "/buffer %d", i); - gui_key_bind (key_str, command); - } -} - -/* - * gui_keyboard_grab_end: insert grabbed key in input buffer - */ - -void -gui_keyboard_grab_end () -{ - char *expanded_key; - - /* get expanded name (for example: ^U => ctrl-u) */ - expanded_key = gui_key_get_expanded_name (gui_key_buffer); - - if (expanded_key) - { - if (gui_current_window->buffer->has_input) - { - gui_insert_string_input (gui_current_window, expanded_key, -1); - gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key); - gui_input_draw (gui_current_window->buffer, 1); - } - free (expanded_key); - } - - /* end grab mode */ - gui_key_grab = 0; - gui_key_grab_count = 0; - gui_key_buffer[0] = '\0'; -} - -/* - * gui_keyboard_read: read keyboard chars - */ - -void -gui_keyboard_read () -{ - /* TODO: write this function for Gtk */ -} diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c index bbdd41cc7..b23d26354 100644 --- a/src/gui/gui-action.c +++ b/src/gui/gui-action.c @@ -622,7 +622,7 @@ gui_action_previous_word (t_gui_window *window) } /* - * gui_action_right: move to previous char + * gui_action_right: move to next char */ void @@ -1293,5 +1293,5 @@ void gui_action_grab_key (t_gui_window *window) { if (window->buffer->has_input) - gui_key_init_grab (); + gui_keyboard_init_grab (); } diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index c57207384..a3fdefd30 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -44,6 +44,13 @@ #include "../irc/irc.h" +t_gui_buffer *gui_buffers = NULL; /* pointer to first buffer */ +t_gui_buffer *last_gui_buffer = NULL; /* pointer to last buffer */ +t_gui_buffer *gui_buffer_before_dcc = NULL; /* buffer before dcc switch */ +t_gui_buffer *gui_buffer_raw_data = NULL; /* buffer with raw IRC data */ +t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buffer before raw switch*/ + + /* * gui_buffer_servers_search: search servers buffer * (when same buffer is used for all servers) @@ -140,7 +147,6 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int type, window->start_line = NULL; window->start_line_pos = 0; gui_window_calculate_pos_size (window, 1); - gui_window_init_subwindows (window); } /* init lines */ diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h new file mode 100644 index 000000000..518ae1045 --- /dev/null +++ b/src/gui/gui-buffer.h @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_BUFFER_H +#define __WEECHAT_GUI_BUFFER_H 1 + +#include "../common/completion.h" +#include "../common/history.h" + +#define BUFFER_TYPE_STANDARD 0 +#define BUFFER_TYPE_DCC 1 +#define BUFFER_TYPE_RAW_DATA 2 + +#define SERVER(buffer) ((t_irc_server *)(buffer->server)) +#define CHANNEL(buffer) ((t_irc_channel *)(buffer->channel)) + +#define BUFFER_IS_SERVER(buffer) ((SERVER(buffer) || (buffer->all_servers)) && !CHANNEL(buffer)) +#define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHANNEL_TYPE_CHANNEL)) +#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && \ + ((CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE) \ + || (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT))) + +#define BUFFER_HAS_NICKLIST(buffer) (BUFFER_IS_CHANNEL(buffer)) + +#define MSG_TYPE_TIME 1 +#define MSG_TYPE_PREFIX 2 +#define MSG_TYPE_NICK 4 +#define MSG_TYPE_INFO 8 +#define MSG_TYPE_MSG 16 +#define MSG_TYPE_HIGHLIGHT 32 +#define MSG_TYPE_NOLOG 64 + +#define NOTIFY_LEVEL_MIN 0 +#define NOTIFY_LEVEL_MAX 3 +#define NOTIFY_LEVEL_DEFAULT NOTIFY_LEVEL_MAX + +/* buffer structures */ + +typedef struct t_gui_line t_gui_line; + +struct t_gui_line +{ + int length; /* length of the line (in char) */ + int length_align; /* alignment length (time or time/nick) */ + int log_write; /* = 1 if line will be written to log */ + int line_with_message; /* line contains a message from a user? */ + int line_with_highlight; /* line contains highlight */ + char *nick; /* nickname for line (may be NULL) */ + char *data; /* line content */ + int ofs_after_date; /* offset to first char after date */ + int ofs_start_message; /* offset to first char after date/nick */ + t_gui_line *prev_line; /* link to previous line */ + t_gui_line *next_line; /* link to next line */ +}; + +typedef struct t_gui_buffer t_gui_buffer; + +struct t_gui_buffer +{ + int num_displayed; /* number of windows displaying buffer */ + + int number; /* buffer number (for jump/switch) */ + + /* server/channel */ + void *server; /* buffer's server */ + int all_servers; /* =1 if all servers are displayed here */ + void *channel; /* buffer's channel */ + int type; /* type: standard (server/channel/pv), */ + /* dcc or raw data */ + + /* chat content (lines, line is composed by many messages) */ + t_gui_line *lines; /* lines of chat window */ + t_gui_line *last_line; /* last line of chat window */ + t_gui_line *last_read_line; /* last read line before jump */ + int num_lines; /* number of lines in the window */ + int line_complete; /* current line complete ? (\n ending) */ + + /* notify level: when activity should be displayed? default: 3 (always) */ + int notify_level; /* 0 = never */ + /* 1 = highlight only */ + /* 2 = highlight + message */ + /* 3 = highlight + message + join/part */ + + /* file to save buffer content */ + char *log_filename; /* filename for saving buffer content */ + FILE *log_file; /* for logging buffer to file */ + + /* inupt buffer */ + int has_input; /* = 1 if buffer has input (DCC has not)*/ + char *input_buffer; /* input buffer */ + char *input_buffer_color_mask; /* color mask for input buffer */ + int input_buffer_alloc; /* input buffer: allocated size in mem */ + int input_buffer_size; /* buffer size in bytes */ + int input_buffer_length; /* number of chars in buffer */ + int input_buffer_pos; /* position into buffer */ + int input_buffer_1st_display; /* first char displayed on screen */ + + /* completion */ + t_completion completion; /* for cmds/nicks completion */ + + /* history */ + t_history *history; /* commands history */ + t_history *last_history; /* last command in history */ + t_history *ptr_history; /* current command in history */ + int num_history; /* number of commands in history */ + + /* link to previous/next buffer */ + t_gui_buffer *prev_buffer; /* link to previous buffer */ + t_gui_buffer *next_buffer; /* link to next buffer */ +}; + +/* buffer variables */ + +extern t_gui_buffer *gui_buffers; +extern t_gui_buffer *last_gui_buffer; +extern t_gui_buffer *gui_buffer_before_dcc; +extern t_gui_buffer *gui_buffer_raw_data; +extern t_gui_buffer *gui_buffer_before_raw_data; + +#endif /* gui-buffer.h */ diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h new file mode 100644 index 000000000..a9763e538 --- /dev/null +++ b/src/gui/gui-color.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_COLOR_H +#define __WEECHAT_GUI_COLOR_H 1 + +#define INPUT_BUFFER_BLOCK_SIZE 256 + +#define COLOR_WIN_NICK_NUMBER 10 + +typedef enum t_weechat_color t_weechat_color; + +enum t_weechat_color +{ + COLOR_WIN_SEPARATOR = 0, + COLOR_WIN_TITLE, + COLOR_WIN_CHAT, + COLOR_WIN_CHAT_TIME, + COLOR_WIN_CHAT_TIME_SEP, + COLOR_WIN_CHAT_PREFIX1, + COLOR_WIN_CHAT_PREFIX2, + COLOR_WIN_CHAT_SERVER, + COLOR_WIN_CHAT_JOIN, + COLOR_WIN_CHAT_PART, + COLOR_WIN_CHAT_NICK, + COLOR_WIN_CHAT_HOST, + COLOR_WIN_CHAT_CHANNEL, + COLOR_WIN_CHAT_DARK, + COLOR_WIN_CHAT_HIGHLIGHT, + COLOR_WIN_CHAT_READ_MARKER, + COLOR_WIN_STATUS, + COLOR_WIN_STATUS_DELIMITERS, + COLOR_WIN_STATUS_CHANNEL, + COLOR_WIN_STATUS_DATA_MSG, + COLOR_WIN_STATUS_DATA_PRIVATE, + COLOR_WIN_STATUS_DATA_HIGHLIGHT, + COLOR_WIN_STATUS_DATA_OTHER, + COLOR_WIN_STATUS_MORE, + COLOR_WIN_INFOBAR, + COLOR_WIN_INFOBAR_DELIMITERS, + COLOR_WIN_INFOBAR_HIGHLIGHT, + COLOR_WIN_INPUT, + COLOR_WIN_INPUT_CHANNEL, + COLOR_WIN_INPUT_NICK, + COLOR_WIN_INPUT_DELIMITERS, + COLOR_WIN_NICK, + COLOR_WIN_NICK_AWAY, + COLOR_WIN_NICK_CHANOWNER, + COLOR_WIN_NICK_CHANADMIN, + COLOR_WIN_NICK_OP, + COLOR_WIN_NICK_HALFOP, + COLOR_WIN_NICK_VOICE, + COLOR_WIN_NICK_MORE, + COLOR_WIN_NICK_SEP, + COLOR_WIN_NICK_SELF, + COLOR_WIN_NICK_PRIVATE, + COLOR_WIN_NICK_1, + COLOR_WIN_NICK_2, + COLOR_WIN_NICK_3, + COLOR_WIN_NICK_4, + COLOR_WIN_NICK_5, + COLOR_WIN_NICK_6, + COLOR_WIN_NICK_7, + COLOR_WIN_NICK_8, + COLOR_WIN_NICK_9, + COLOR_WIN_NICK_10, + COLOR_DCC_SELECTED, + COLOR_DCC_WAITING, + COLOR_DCC_CONNECTING, + COLOR_DCC_ACTIVE, + COLOR_DCC_DONE, + COLOR_DCC_FAILED, + COLOR_DCC_ABORTED, + COLOR_WIN_INPUT_SERVER, + GUI_NUM_COLORS +}; + +#define GUI_NUM_IRC_COLORS 16 + +/* attributes in IRC messages for color & style (bold, ..) */ + +#define GUI_ATTR_BOLD_CHAR '\x02' +#define GUI_ATTR_BOLD_STR "\x02" +#define GUI_ATTR_COLOR_CHAR '\x03' +#define GUI_ATTR_COLOR_STR "\x03" +#define GUI_ATTR_RESET_CHAR '\x0F' +#define GUI_ATTR_RESET_STR "\x0F" +#define GUI_ATTR_FIXED_CHAR '\x11' +#define GUI_ATTR_FIXED_STR "\x11" +#define GUI_ATTR_REVERSE_CHAR '\x12' +#define GUI_ATTR_REVERSE_STR "\x12" +#define GUI_ATTR_REVERSE2_CHAR '\x16' +#define GUI_ATTR_REVERSE2_STR "\x16" +#define GUI_ATTR_ITALIC_CHAR '\x1D' +#define GUI_ATTR_ITALIC_STR "\x1D" +#define GUI_ATTR_UNDERLINE_CHAR '\x1F' +#define GUI_ATTR_UNDERLINE_STR "\x1F" + +/* WeeChat internal attributes (should never be in IRC messages) */ + +#define GUI_ATTR_WEECHAT_COLOR_CHAR '\x19' +#define GUI_ATTR_WEECHAT_COLOR_STR "\x19" +#define GUI_ATTR_WEECHAT_SET_CHAR '\x1A' +#define GUI_ATTR_WEECHAT_SET_STR "\x1A" +#define GUI_ATTR_WEECHAT_REMOVE_CHAR '\x1B' +#define GUI_ATTR_WEECHAT_REMOVE_STR "\x1B" + +#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "") +#define GUI_NO_COLOR GUI_ATTR_RESET_STR + +/* color structure */ + +typedef struct t_gui_color t_gui_color; + +struct t_gui_color +{ + int foreground; /* foreground color */ + int background; /* background color */ + int attributes; /* attributes (bold, ..) */ + char *string; /* WeeChat color: "\x19??", ?? is #color*/ +}; + +/* color variables */ + +extern t_gui_color *gui_color[GUI_NUM_COLORS]; + +#endif /* gui-color.h */ diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index 12fb81d4c..300848222 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -50,17 +50,6 @@ int gui_ok = 0; /* = 1 if GUI is ok */ int gui_add_hotlist = 1; /* 0 is for temporarly disable */ /* hotlist add for all buffers */ -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_window_tree *gui_windows_tree = NULL; /* pointer to windows tree */ - -t_gui_buffer *gui_buffers = NULL; /* pointer to first buffer */ -t_gui_buffer *last_gui_buffer = NULL; /* pointer to last buffer */ -t_gui_buffer *gui_buffer_before_dcc = NULL; /* buffer before dcc switch */ -t_gui_buffer *gui_buffer_raw_data = NULL; /* buffer with raw IRC data */ -t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buffer before raw switch*/ t_gui_infobar *gui_infobar; /* pointer to infobar content */ char *gui_input_clipboard = NULL; /* clipboard content */ diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index 94662b956..d32bfda51 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -140,11 +140,11 @@ t_gui_key_function gui_key_functions[] = /* - * gui_key_init: init keyboard (create default key bindings) + * gui_keyboard_init: init keyboard (create default key bindings) */ void -gui_key_init () +gui_keyboard_init () { gui_key_buffer[0] = '\0'; gui_key_grab = 0; @@ -154,23 +154,23 @@ gui_key_init () } /* - * gui_key_init_show: init "show mode" + * gui_keyboard_init_show: init "show mode" */ void -gui_key_init_grab () +gui_keyboard_init_grab () { gui_key_grab = 1; gui_key_grab_count = 0; } /* - * gui_key_get_internal_code: get internal code from user key name - * for example: return "^R" for "ctrl-R" + * gui_keyboard_get_internal_code: get internal code from user key name + * for example: return "^R" for "ctrl-R" */ char * -gui_key_get_internal_code (char *key) +gui_keyboard_get_internal_code (char *key) { char *result; @@ -208,12 +208,12 @@ gui_key_get_internal_code (char *key) } /* - * gui_key_get_expanded_name: get expanded name from internal key code - * for example: return "ctrl-R" for "^R" + * gui_keyboard_get_expanded_name: get expanded name from internal key code + * for example: return "ctrl-R" for "^R" */ char * -gui_key_get_expanded_name (char *key) +gui_keyboard_get_expanded_name (char *key) { char *result; @@ -251,11 +251,11 @@ gui_key_get_expanded_name (char *key) } /* - * gui_key_find_pos: find position for a key (for sorting keys list) + * gui_keyboard_find_pos: find position for a key (for sorting keys list) */ t_gui_key * -gui_key_find_pos (t_gui_key *key) +gui_keyboard_find_pos (t_gui_key *key) { t_gui_key *ptr_key; @@ -268,17 +268,17 @@ gui_key_find_pos (t_gui_key *key) } /* - * gui_key_insert_sorted: insert key into sorted list + * gui_keyboard_insert_sorted: insert key into sorted list */ void -gui_key_insert_sorted (t_gui_key *key) +gui_keyboard_insert_sorted (t_gui_key *key) { t_gui_key *pos_key; if (gui_keys) { - pos_key = gui_key_find_pos (key); + pos_key = gui_keyboard_find_pos (key); if (pos_key) { @@ -310,24 +310,24 @@ gui_key_insert_sorted (t_gui_key *key) } /* - * gui_key_new: add a new key in keys list + * gui_keyboard_new: add a new key in keys list */ t_gui_key * -gui_key_new (char *key, char *command, void *function) +gui_keyboard_new (char *key, char *command, void *function) { t_gui_key *new_key; char *internal_code; if ((new_key = (t_gui_key *) malloc (sizeof (t_gui_key)))) { - internal_code = gui_key_get_internal_code (key); + internal_code = gui_keyboard_get_internal_code (key); new_key->key = (internal_code) ? strdup (internal_code) : strdup (key); if (internal_code) free (internal_code); new_key->command = (command) ? strdup (command) : NULL; new_key->function = function; - gui_key_insert_sorted (new_key); + gui_keyboard_insert_sorted (new_key); } else return NULL; @@ -336,11 +336,11 @@ gui_key_new (char *key, char *command, void *function) } /* - * gui_key_search: search a key + * gui_keyboard_search: search a key */ t_gui_key * -gui_key_search (char *key) +gui_keyboard_search (char *key) { t_gui_key *ptr_key; @@ -355,11 +355,11 @@ gui_key_search (char *key) } /* - * gui_key_cmp: compares 2 keys + * gui_keyboard_cmp: compares 2 keys */ int -gui_key_cmp (char *key, char *search) +gui_keyboard_cmp (char *key, char *search) { while (search[0]) { @@ -373,17 +373,17 @@ gui_key_cmp (char *key, char *search) } /* - * gui_key_search_part: search a key (maybe part of string) + * gui_keyboard_search_part: search a key (maybe part of string) */ t_gui_key * -gui_key_search_part (char *key) +gui_keyboard_search_part (char *key) { t_gui_key *ptr_key; for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) { - if (gui_key_cmp (ptr_key->key, key) == 0) + if (gui_keyboard_cmp (ptr_key->key, key) == 0) return ptr_key; } @@ -392,11 +392,11 @@ gui_key_search_part (char *key) } /* - * gui_key_function_search_by_name: search a function by name + * gui_keyboard_function_search_by_name: search a function by name */ void * -gui_key_function_search_by_name (char *name) +gui_keyboard_function_search_by_name (char *name) { int i; @@ -413,11 +413,11 @@ gui_key_function_search_by_name (char *name) } /* - * gui_key_function_search_by_ptr: search a function by pointer + * gui_keyboard_function_search_by_ptr: search a function by pointer */ char * -gui_key_function_search_by_ptr (void *function) +gui_keyboard_function_search_by_ptr (void *function) { int i; @@ -434,11 +434,11 @@ gui_key_function_search_by_ptr (void *function) } /* - * gui_key_bind: bind a key to a function (command or special function) + * gui_keyboard_bind: bind a key to a function (command or special function) */ t_gui_key * -gui_key_bind (char *key, char *command) +gui_keyboard_bind (char *key, char *command) { t_gui_key_function *ptr_function; t_gui_key *new_key; @@ -453,7 +453,7 @@ gui_key_bind (char *key, char *command) ptr_function = NULL; if (command[0] != '/') { - ptr_function = gui_key_function_search_by_name (command); + ptr_function = gui_keyboard_function_search_by_name (command); if (!ptr_function) { weechat_log_printf (_("%s unable to bind key \"%s\" (invalid function name: \"%s\")\n"), @@ -462,11 +462,11 @@ gui_key_bind (char *key, char *command) } } - gui_key_unbind (key); + gui_keyboard_unbind (key); - new_key = gui_key_new (key, - (ptr_function) ? NULL : command, - ptr_function); + new_key = gui_keyboard_new (key, + (ptr_function) ? NULL : command, + ptr_function); if (!new_key) { weechat_log_printf (_("%s not enough memory for key binding\n"), @@ -478,20 +478,20 @@ gui_key_bind (char *key, char *command) } /* - * gui_key_unbind: remove a key binding + * gui_keyboard_unbind: remove a key binding */ int -gui_key_unbind (char *key) +gui_keyboard_unbind (char *key) { t_gui_key *ptr_key; char *internal_code; - internal_code = gui_key_get_internal_code (key); + internal_code = gui_keyboard_get_internal_code (key); - ptr_key = gui_key_search ((internal_code) ? internal_code : key); + ptr_key = gui_keyboard_search ((internal_code) ? internal_code : key); if (ptr_key) - gui_key_free (ptr_key); + gui_keyboard_free (ptr_key); if (internal_code) free (internal_code); @@ -500,13 +500,13 @@ gui_key_unbind (char *key) } /* - * gui_key_pressed: treat new key pressed - * return: 1 if key should be added to input buffer - * 0 otherwise + * gui_keyboard_pressed: treat new key pressed + * return: 1 if key should be added to input buffer + * 0 otherwise */ int -gui_key_pressed (char *key_str) +gui_keyboard_pressed (char *key_str) { int first_key; t_gui_key *ptr_key; @@ -524,7 +524,7 @@ gui_key_pressed (char *key_str) } /* look for key combo in key table */ - ptr_key = gui_key_search_part (gui_key_buffer); + ptr_key = gui_keyboard_search_part (gui_key_buffer); if (ptr_key) { if (ascii_strcasecmp (ptr_key->key, gui_key_buffer) == 0) @@ -543,7 +543,7 @@ gui_key_pressed (char *key_str) #ifdef PLUGINS (void) plugin_keyboard_handler_exec ( (ptr_key->command) ? - ptr_key->command : gui_key_function_search_by_ptr (ptr_key->function), + ptr_key->command : gui_keyboard_function_search_by_ptr (ptr_key->function), buffer_before_key, gui_current_window->buffer->input_buffer); #endif @@ -561,11 +561,11 @@ gui_key_pressed (char *key_str) } /* - * key_free: delete a key binding + * gui_keyboard_free: delete a key binding */ void -gui_key_free (t_gui_key *key) +gui_keyboard_free (t_gui_key *key) { /* free memory */ if (key->key) @@ -587,12 +587,12 @@ gui_key_free (t_gui_key *key) } /* - * gui_key_free_all: delete all key bindings + * gui_keyboard_free_all: delete all key bindings */ void -gui_key_free_all () +gui_keyboard_free_all () { while (gui_keys) - gui_key_free (gui_keys); + gui_keyboard_free (gui_keys); } diff --git a/src/gui/gui-keyboard.h b/src/gui/gui-keyboard.h new file mode 100644 index 000000000..20e78bf7b --- /dev/null +++ b/src/gui/gui-keyboard.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_KEY_H +#define __WEECHAT_GUI_KEY_H 1 + +#define KEY_SHOW_MODE_DISPLAY 1 +#define KEY_SHOW_MODE_BIND 2 + +/* key structures */ + +typedef struct t_gui_key t_gui_key; + +struct t_gui_key +{ + char *key; /* key combo (ex: a, ^W, ^W^C, meta-a) */ + char *command; /* associated command (may be NULL) */ + void (*function)(t_gui_window *); + /* associated function (if cmd is NULL) */ + t_gui_key *prev_key; /* link to previous key */ + t_gui_key *next_key; /* link to next key */ +}; + +typedef struct t_gui_key_function t_gui_key_function; + +struct t_gui_key_function +{ + char *function_name; /* name of function */ + void (*function)(); /* associated function */ + char *description; /* description of function */ +}; + +/* key variables */ + +extern t_gui_key *gui_keys; +extern t_gui_key *last_gui_key; +extern t_gui_key_function gui_key_functions[]; +extern char gui_key_buffer[128]; +extern int gui_key_grab; +extern int gui_key_grab_count; + +#endif /* gui-key.h */ diff --git a/src/gui/gui-panel.c b/src/gui/gui-panel.c new file mode 100644 index 000000000..9b5f76519 --- /dev/null +++ b/src/gui/gui-panel.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* gui-panel.c: panel functions, used by all GUI */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> +#include <unistd.h> +#include <string.h> +#include <signal.h> +#include <time.h> +#include <ctype.h> + +#include "../common/weechat.h" +#include "gui.h" + + +t_gui_panel *gui_panels = NULL; /* pointer to first panel */ +t_gui_panel *last_gui_panel = NULL; /* pointer to last panel */ + + +/* + * gui_panel_new: create a new panel + */ + +t_gui_panel * +gui_panel_new (char *name, int position, int type, int size, int separator) +{ + t_gui_panel *new_panel; + t_gui_window *ptr_win; + + if (!name || !name[0]) + return NULL; + + if ((new_panel = (t_gui_panel *) malloc (sizeof (t_gui_panel)))) + { + new_panel->position = position; + new_panel->name = strdup (name); + new_panel->separator = separator; + new_panel->size = size; + if (type == GUI_PANEL_WINDOWS) + { + /* create panel window for all opened windows */ + for (ptr_win = gui_windows; ptr_win; + ptr_win = ptr_win->next_window) + gui_panel_window_new (new_panel, ptr_win); + } + else + /* create only one panel window (global) */ + gui_panel_window_new (new_panel, NULL); + + /* add panel to panels queue */ + new_panel->prev_panel = last_gui_panel; + if (gui_panels) + last_gui_panel->next_panel = new_panel; + else + gui_panels = new_panel; + last_gui_panel = new_panel; + new_panel->next_panel = NULL; + + return new_panel; + } + else + return NULL; +} + +/* + * gui_panel_free: delete a panel + */ + +void +gui_panel_free (t_gui_panel *panel) +{ + /* remove panel from panels list */ + if (panel->prev_panel) + panel->prev_panel->next_panel = panel->next_panel; + if (panel->next_panel) + panel->next_panel->prev_panel = panel->prev_panel; + if (gui_panels == panel) + gui_panels = panel->next_panel; + if (last_gui_panel == panel) + last_gui_panel = panel->prev_panel; + + /* free data */ + if (panel->name) + free (panel->name); + if (panel->panel_window) + gui_panel_window_free (panel->panel_window); + + free (panel); +} diff --git a/src/gui/gui-panel.h b/src/gui/gui-panel.h new file mode 100644 index 000000000..a4a8cac14 --- /dev/null +++ b/src/gui/gui-panel.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_PANEL_H +#define __WEECHAT_GUI_PANEL_H 1 + +#define GUI_PANEL_TOP 1 +#define GUI_PANEL_BOTTOM 2 +#define GUI_PANEL_LEFT 3 +#define GUI_PANEL_RIGHT 4 + +#define GUI_PANEL_GLOBAL 0 +#define GUI_PANEL_WINDOWS 1 + + +/* panel structure */ + +typedef struct t_gui_panel t_gui_panel; + +struct t_gui_panel +{ + int position; /* position (top, bottom, left, right) */ + char *name; /* panel name */ + void *panel_window; /* pointer to panel window, NULL if */ + /* displayed on each window (in this */ + /* case, pointers are in windows) */ + int separator; /* 1 if separator (line) displayed */ + int size; /* panel size */ + t_gui_panel *prev_panel; /* link to previous panel */ + t_gui_panel *next_panel; /* link to next panel */ +}; + +/* panel variables */ + +extern t_gui_panel *gui_panels; +extern t_gui_panel *last_gui_panel; + +#endif /* gui-panel.h */ diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index 7211e66b3..e6247149d 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -44,6 +44,13 @@ #include "../irc/irc.h" +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_window_tree *gui_windows_tree = NULL; /* pointer to windows tree */ + + /* * gui_window_tree_init: create first entry in windows tree */ @@ -115,6 +122,7 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height, { t_gui_window *new_window; t_gui_window_tree *ptr_tree, *child1, *child2, *ptr_leaf; + t_gui_panel *ptr_panel; #ifdef DEBUG weechat_log_printf ("Creating new window (x:%d, y:%d, width:%d, height:%d)\n", @@ -174,6 +182,11 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height, if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window))))) { + if (!gui_window_objects_init (new_window)) + { + free (new_window); + return NULL; + } new_window->win_x = x; new_window->win_y = y; new_window->win_width = width; @@ -199,23 +212,9 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height, new_window->win_nick_height = 0; new_window->win_nick_num_max = 0; new_window->win_nick_start = 0; - + new_window->win_input_x = 0; - - new_window->win_title = NULL; - new_window->win_chat = NULL; - new_window->win_nick = NULL; - new_window->win_status = NULL; - new_window->win_infobar = NULL; - new_window->win_input = NULL; - new_window->win_separator = NULL; - - new_window->textview_chat = NULL; - new_window->textbuffer_chat = NULL; - new_window->texttag_chat = NULL; - new_window->textview_nicklist = NULL; - new_window->textbuffer_nicklist = NULL; - + new_window->dcc_first = NULL; new_window->dcc_selected = NULL; new_window->dcc_last_displayed = NULL; @@ -229,6 +228,14 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height, new_window->ptr_tree = ptr_leaf; ptr_leaf->window = new_window; + + /* add panels to window */ + for (ptr_panel = gui_panels; ptr_panel; + ptr_panel = ptr_panel->next_panel) + { + if (!ptr_panel->panel_window) + gui_panel_window_new (ptr_panel, new_window); + } /* add window to windows queue */ new_window->prev_window = last_gui_window; @@ -255,6 +262,9 @@ gui_window_free (t_gui_window *window) if (window->buffer && (window->buffer->num_displayed > 0)) window->buffer->num_displayed--; + /* free data */ + gui_window_objects_free (window, 1); + /* remove window from windows list */ if (window->prev_window) window->prev_window->next_window = window->next_window; @@ -399,18 +409,7 @@ gui_window_print_log (t_gui_window *window) weechat_log_printf (" win_nick_width. . . : %d\n", window->win_nick_width); weechat_log_printf (" win_nick_height . . : %d\n", window->win_nick_height); weechat_log_printf (" win_nick_start. . . : %d\n", window->win_nick_start); - weechat_log_printf (" win_title . . . . . : 0x%X\n", window->win_title); - weechat_log_printf (" win_chat. . . . . . : 0x%X\n", window->win_chat); - weechat_log_printf (" win_nick. . . . . . : 0x%X\n", window->win_nick); - weechat_log_printf (" win_status. . . . . : 0x%X\n", window->win_status); - weechat_log_printf (" win_infobar . . . . : 0x%X\n", window->win_infobar); - weechat_log_printf (" win_input . . . . . : 0x%X\n", window->win_input); - weechat_log_printf (" win_separator . . . : 0x%X\n", window->win_separator); - weechat_log_printf (" textview_chat . . . : 0x%X\n", window->textview_chat); - weechat_log_printf (" textbuffer_chat . . : 0x%X\n", window->textbuffer_chat); - weechat_log_printf (" texttag_chat. . . . : 0x%X\n", window->texttag_chat); - weechat_log_printf (" textview_nicklist . : 0x%X\n", window->textview_nicklist); - weechat_log_printf (" textbuffer_nicklist : 0x%X\n", window->textbuffer_nicklist); + gui_window_objects_print_log (window); weechat_log_printf (" dcc_first . . . . . : 0x%X\n", window->dcc_first); weechat_log_printf (" dcc_selected. . . . : 0x%X\n", window->dcc_selected); weechat_log_printf (" dcc_last_displayed. : 0x%X\n", window->dcc_last_displayed); diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h new file mode 100644 index 000000000..63e796980 --- /dev/null +++ b/src/gui/gui-window.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_WINDOW_H +#define __WEECHAT_GUI_WINDOW_H 1 + +#define WINDOW_MIN_WIDTH 10 +#define WINDOW_MIN_HEIGHT 5 + +/* window structures */ + +typedef struct t_gui_window_tree t_gui_window_tree; +typedef struct t_gui_window t_gui_window; + +struct t_gui_window +{ + /* global position & size */ + int win_x, win_y; /* position of window */ + int win_width, win_height; /* window geometry */ + int win_width_pct; /* % of width (compared to term size) */ + int win_height_pct; /* % of height (compared to term size) */ + + int new_x, new_y; /* used for computing new position */ + int new_width, new_height; /* used for computing new size */ + + /* chat window settings */ + int win_chat_x, win_chat_y; /* chat window position */ + int win_chat_width; /* width of chat window */ + int win_chat_height; /* height of chat window */ + int win_chat_cursor_x; /* position of cursor in chat window */ + int win_chat_cursor_y; /* position of cursor in chat window */ + + /* nicklist window settings */ + int win_nick_x, win_nick_y; /* nick window position */ + int win_nick_width; /* width of nick window */ + int win_nick_height; /* height of nick window */ + int win_nick_num_max; /* maximum number of nicks displayed */ + int win_nick_start; /* # of 1st nick for display (scroll) */ + + /* input window settings */ + int win_input_x; /* position of cursor in input window */ + + /* GUI specific objects */ + void *gui_objects; /* pointer to a GUI specific struct */ + + int current_style_fg;; /* current color used for foreground */ + int current_style_bg;; /* current color used for background */ + int current_style_attr; /* current attributes (bold, ..) */ + int current_color_attr; /* attr sum of last color(s) displayed */ + + /* DCC */ + void *dcc_first; /* first dcc displayed */ + void *dcc_selected; /* selected dcc */ + void *dcc_last_displayed; /* last dcc displayed (for scroll) */ + + t_gui_buffer *buffer; /* buffer currently displayed in window */ + + int first_line_displayed; /* = 1 if first line is displayed */ + t_gui_line *start_line; /* pointer to line if scrolling */ + int start_line_pos; /* position in first line displayed */ + int scroll; /* = 1 if "MORE" should be displayed */ + t_gui_window_tree *ptr_tree; /* pointer to leaf in windows tree */ + + t_gui_window *prev_window; /* link to previous window */ + t_gui_window *next_window; /* link to next window */ +}; + +struct t_gui_window_tree +{ + t_gui_window_tree *parent_node; /* pointer to parent node */ + + /* node info */ + int split_horiz; /* 1 if horizontal, 0 if vertical */ + int split_pct; /* % of split size (represents child1) */ + t_gui_window_tree *child1; /* first child, NULL if a leaf */ + t_gui_window_tree *child2; /* second child, NULL if a leaf */ + + /* leaf info */ + t_gui_window *window; /* pointer to window, NULL if a node */ +}; + +/* window variables */ + +extern t_gui_window *gui_windows; +extern t_gui_window *last_gui_window; +extern t_gui_window *gui_current_window; +extern t_gui_window_tree *gui_windows_tree; + +#endif /* gui-window.h */ diff --git a/src/gui/gui.h b/src/gui/gui.h index bf63fbd9c..338066a54 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -21,131 +21,11 @@ #ifndef __WEECHAT_GUI_H #define __WEECHAT_GUI_H 1 -#include "../common/completion.h" -#include "../common/history.h" - -#define INPUT_BUFFER_BLOCK_SIZE 256 - -#define COLOR_WIN_NICK_NUMBER 10 - -typedef enum t_weechat_color t_weechat_color; - -enum t_weechat_color -{ - COLOR_WIN_SEPARATOR = 0, - COLOR_WIN_TITLE, - COLOR_WIN_CHAT, - COLOR_WIN_CHAT_TIME, - COLOR_WIN_CHAT_TIME_SEP, - COLOR_WIN_CHAT_PREFIX1, - COLOR_WIN_CHAT_PREFIX2, - COLOR_WIN_CHAT_SERVER, - COLOR_WIN_CHAT_JOIN, - COLOR_WIN_CHAT_PART, - COLOR_WIN_CHAT_NICK, - COLOR_WIN_CHAT_HOST, - COLOR_WIN_CHAT_CHANNEL, - COLOR_WIN_CHAT_DARK, - COLOR_WIN_CHAT_HIGHLIGHT, - COLOR_WIN_CHAT_READ_MARKER, - COLOR_WIN_STATUS, - COLOR_WIN_STATUS_DELIMITERS, - COLOR_WIN_STATUS_CHANNEL, - COLOR_WIN_STATUS_DATA_MSG, - COLOR_WIN_STATUS_DATA_PRIVATE, - COLOR_WIN_STATUS_DATA_HIGHLIGHT, - COLOR_WIN_STATUS_DATA_OTHER, - COLOR_WIN_STATUS_MORE, - COLOR_WIN_INFOBAR, - COLOR_WIN_INFOBAR_DELIMITERS, - COLOR_WIN_INFOBAR_HIGHLIGHT, - COLOR_WIN_INPUT, - COLOR_WIN_INPUT_CHANNEL, - COLOR_WIN_INPUT_NICK, - COLOR_WIN_INPUT_DELIMITERS, - COLOR_WIN_NICK, - COLOR_WIN_NICK_AWAY, - COLOR_WIN_NICK_CHANOWNER, - COLOR_WIN_NICK_CHANADMIN, - COLOR_WIN_NICK_OP, - COLOR_WIN_NICK_HALFOP, - COLOR_WIN_NICK_VOICE, - COLOR_WIN_NICK_MORE, - COLOR_WIN_NICK_SEP, - COLOR_WIN_NICK_SELF, - COLOR_WIN_NICK_PRIVATE, - COLOR_WIN_NICK_1, - COLOR_WIN_NICK_2, - COLOR_WIN_NICK_3, - COLOR_WIN_NICK_4, - COLOR_WIN_NICK_5, - COLOR_WIN_NICK_6, - COLOR_WIN_NICK_7, - COLOR_WIN_NICK_8, - COLOR_WIN_NICK_9, - COLOR_WIN_NICK_10, - COLOR_DCC_SELECTED, - COLOR_DCC_WAITING, - COLOR_DCC_CONNECTING, - COLOR_DCC_ACTIVE, - COLOR_DCC_DONE, - COLOR_DCC_FAILED, - COLOR_DCC_ABORTED, - COLOR_WIN_INPUT_SERVER, - GUI_NUM_COLORS -}; - -#define GUI_NUM_IRC_COLORS 16 - -/* attributes in IRC messages for color & style (bold, ..) */ - -#define GUI_ATTR_BOLD_CHAR '\x02' -#define GUI_ATTR_BOLD_STR "\x02" -#define GUI_ATTR_COLOR_CHAR '\x03' -#define GUI_ATTR_COLOR_STR "\x03" -#define GUI_ATTR_RESET_CHAR '\x0F' -#define GUI_ATTR_RESET_STR "\x0F" -#define GUI_ATTR_FIXED_CHAR '\x11' -#define GUI_ATTR_FIXED_STR "\x11" -#define GUI_ATTR_REVERSE_CHAR '\x12' -#define GUI_ATTR_REVERSE_STR "\x12" -#define GUI_ATTR_REVERSE2_CHAR '\x16' -#define GUI_ATTR_REVERSE2_STR "\x16" -#define GUI_ATTR_ITALIC_CHAR '\x1D' -#define GUI_ATTR_ITALIC_STR "\x1D" -#define GUI_ATTR_UNDERLINE_CHAR '\x1F' -#define GUI_ATTR_UNDERLINE_STR "\x1F" - -/* WeeChat internal attributes (should never be in IRC messages) */ - -#define GUI_ATTR_WEECHAT_COLOR_CHAR '\x19' -#define GUI_ATTR_WEECHAT_COLOR_STR "\x19" -#define GUI_ATTR_WEECHAT_SET_CHAR '\x1A' -#define GUI_ATTR_WEECHAT_SET_STR "\x1A" -#define GUI_ATTR_WEECHAT_REMOVE_CHAR '\x1B' -#define GUI_ATTR_WEECHAT_REMOVE_STR "\x1B" - -#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "") -#define GUI_NO_COLOR GUI_ATTR_RESET_STR - -#define SERVER(buffer) ((t_irc_server *)(buffer->server)) -#define CHANNEL(buffer) ((t_irc_channel *)(buffer->channel)) - -#define BUFFER_IS_SERVER(buffer) ((SERVER(buffer) || (buffer->all_servers)) && !CHANNEL(buffer)) -#define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHANNEL_TYPE_CHANNEL)) -#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && \ - ((CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE) \ - || (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT))) - -#define BUFFER_HAS_NICKLIST(buffer) (BUFFER_IS_CHANNEL(buffer)) - -#define MSG_TYPE_TIME 1 -#define MSG_TYPE_PREFIX 2 -#define MSG_TYPE_NICK 4 -#define MSG_TYPE_INFO 8 -#define MSG_TYPE_MSG 16 -#define MSG_TYPE_HIGHLIGHT 32 -#define MSG_TYPE_NOLOG 64 +#include "gui-color.h" +#include "gui-panel.h" +#include "gui-buffer.h" +#include "gui-window.h" +#include "gui-keyboard.h" #define gui_printf(buffer, fmt, argz...) \ gui_printf_internal(buffer, 1, MSG_TYPE_INFO, NULL, fmt, ##argz) @@ -162,30 +42,6 @@ enum t_weechat_color #define gui_printf_nolog_notime(buffer, fmt, argz...) \ gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, NULL, fmt, ##argz) -#define WINDOW_MIN_WIDTH 10 -#define WINDOW_MIN_HEIGHT 5 - -#define BUFFER_TYPE_STANDARD 0 -#define BUFFER_TYPE_DCC 1 -#define BUFFER_TYPE_RAW_DATA 2 - -#define NOTIFY_LEVEL_MIN 0 -#define NOTIFY_LEVEL_MAX 3 -#define NOTIFY_LEVEL_DEFAULT NOTIFY_LEVEL_MAX - -#define KEY_SHOW_MODE_DISPLAY 1 -#define KEY_SHOW_MODE_BIND 2 - -typedef struct t_gui_color t_gui_color; - -struct t_gui_color -{ - int foreground; /* foreground color */ - int background; /* background color */ - int attributes; /* attributes (bold, ..) */ - char *string; /* WeeChat color: "\x19??", ?? is #color*/ -}; - typedef struct t_gui_infobar t_gui_infobar; struct t_gui_infobar @@ -198,214 +54,18 @@ struct t_gui_infobar t_gui_infobar *next_infobar; /* next message for infobar */ }; -typedef struct t_gui_line t_gui_line; - -struct t_gui_line -{ - int length; /* length of the line (in char) */ - int length_align; /* alignment length (time or time/nick) */ - int log_write; /* = 1 if line will be written to log */ - int line_with_message; /* line contains a message from a user? */ - int line_with_highlight; /* line contains highlight */ - char *nick; /* nickname for line (may be NULL) */ - char *data; /* line content */ - int ofs_after_date; /* offset to first char after date */ - int ofs_start_message; /* offset to first char after date/nick */ - t_gui_line *prev_line; /* link to previous line */ - t_gui_line *next_line; /* link to next line */ -}; - -typedef struct t_gui_buffer t_gui_buffer; - -struct t_gui_buffer -{ - int num_displayed; /* number of windows displaying buffer */ - - int number; /* buffer number (for jump/switch) */ - - /* server/channel */ - void *server; /* buffer's server */ - int all_servers; /* =1 if all servers are displayed here */ - void *channel; /* buffer's channel */ - int type; /* type: standard (server/channel/pv), */ - /* dcc or raw data */ - - /* chat content (lines, line is composed by many messages) */ - t_gui_line *lines; /* lines of chat window */ - t_gui_line *last_line; /* last line of chat window */ - t_gui_line *last_read_line; /* last read line before jump */ - int num_lines; /* number of lines in the window */ - int line_complete; /* current line complete ? (\n ending) */ - - /* notify level: when activity should be displayed? default: 3 (always) */ - int notify_level; /* 0 = never */ - /* 1 = highlight only */ - /* 2 = highlight + message */ - /* 3 = highlight + message + join/part */ - - /* file to save buffer content */ - char *log_filename; /* filename for saving buffer content */ - FILE *log_file; /* for logging buffer to file */ - - /* inupt buffer */ - int has_input; /* = 1 if buffer has input (DCC has not)*/ - char *input_buffer; /* input buffer */ - char *input_buffer_color_mask; /* color mask for input buffer */ - int input_buffer_alloc; /* input buffer: allocated size in mem */ - int input_buffer_size; /* buffer size in bytes */ - int input_buffer_length; /* number of chars in buffer */ - int input_buffer_pos; /* position into buffer */ - int input_buffer_1st_display; /* first char displayed on screen */ - - /* completion */ - t_completion completion; /* for cmds/nicks completion */ - - /* history */ - t_history *history; /* commands history */ - t_history *last_history; /* last command in history */ - t_history *ptr_history; /* current command in history */ - int num_history; /* number of commands in history */ - - /* link to previous/next buffer */ - t_gui_buffer *prev_buffer; /* link to previous buffer */ - t_gui_buffer *next_buffer; /* link to next buffer */ -}; - -typedef struct t_gui_window_tree t_gui_window_tree; -typedef struct t_gui_window t_gui_window; - -struct t_gui_window -{ - /* global position & size */ - int win_x, win_y; /* position of window */ - int win_width, win_height; /* window geometry */ - int win_width_pct; /* % of width (compared to term size) */ - int win_height_pct; /* % of height (compared to term size) */ - - int new_x, new_y; /* used for computing new position */ - int new_width, new_height; /* used for computing new size */ - - /* chat window settings */ - int win_chat_x, win_chat_y; /* chat window position */ - int win_chat_width; /* width of chat window */ - int win_chat_height; /* height of chat window */ - int win_chat_cursor_x; /* position of cursor in chat window */ - int win_chat_cursor_y; /* position of cursor in chat window */ - - /* nicklist window settings */ - int win_nick_x, win_nick_y; /* nick window position */ - int win_nick_width; /* width of nick window */ - int win_nick_height; /* height of nick window */ - int win_nick_num_max; /* maximum number of nicks displayed */ - int win_nick_start; /* # of 1st nick for display (scroll) */ - - /* input window settings */ - int win_input_x; /* position of cursor in input window */ - - /* windows for Curses GUI */ - void *win_title; /* title window */ - void *win_chat; /* chat window (example: channel) */ - void *win_nick; /* nick window */ - void *win_status; /* status window */ - void *win_infobar; /* info bar window */ - void *win_input; /* input window */ - void *win_separator; /* separation between 2 splited (V) win */ - - /* 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 Qt GUI */ - /* TODO: declare Qt window */ - - int current_style_fg;; /* current color used for foreground */ - int current_style_bg;; /* current color used for background */ - int current_style_attr; /* current attributes (bold, ..) */ - int current_color_attr; /* attr sum of last color(s) displayed */ - - /* DCC */ - void *dcc_first; /* first dcc displayed */ - void *dcc_selected; /* selected dcc */ - void *dcc_last_displayed; /* last dcc displayed (for scroll) */ - - t_gui_buffer *buffer; /* buffer currently displayed in window */ - - int first_line_displayed; /* = 1 if first line is displayed */ - t_gui_line *start_line; /* pointer to line if scrolling */ - int start_line_pos; /* position in first line displayed */ - int scroll; /* = 1 if "MORE" should be displayed */ - t_gui_window_tree *ptr_tree; /* pointer to leaf in windows tree */ - - t_gui_window *prev_window; /* link to previous window */ - t_gui_window *next_window; /* link to next window */ -}; - -struct t_gui_window_tree -{ - t_gui_window_tree *parent_node; /* pointer to parent node */ - - /* node info */ - int split_horiz; /* 1 if horizontal, 0 if vertical */ - int split_pct; /* % of split size (represents child1) */ - t_gui_window_tree *child1; /* first child, NULL if a leaf */ - t_gui_window_tree *child2; /* second child, NULL if a leaf */ - - /* leaf info */ - t_gui_window *window; /* pointer to window, NULL if a node */ -}; - -typedef struct t_gui_key t_gui_key; - -struct t_gui_key -{ - char *key; /* key combo (ex: a, ^W, ^W^C, meta-a) */ - char *command; /* associated command (may be NULL) */ - void (*function)(t_gui_window *); - /* associated function (if cmd is NULL) */ - t_gui_key *prev_key; /* link to previous key */ - t_gui_key *next_key; /* link to next key */ -}; - -typedef struct t_gui_key_function t_gui_key_function; - -struct t_gui_key_function -{ - char *function_name; /* name of function */ - void (*function)(); /* associated function */ - char *description; /* description of function */ -}; - -/* variables */ +/* GUI variables */ extern int gui_init_ok; extern int gui_ok; extern int gui_add_hotlist; -extern t_gui_window *gui_windows; -extern t_gui_window *last_gui_window; -extern t_gui_window *gui_current_window; -extern t_gui_window_tree *gui_windows_tree; -extern t_gui_buffer *gui_buffers; -extern t_gui_buffer *last_gui_buffer; -extern t_gui_buffer *gui_buffer_before_dcc; -extern t_gui_buffer *gui_buffer_raw_data; -extern t_gui_buffer *gui_buffer_before_raw_data; extern t_gui_infobar *gui_infobar; -extern t_gui_key *gui_keys; -extern t_gui_key *last_gui_key; -extern t_gui_key_function gui_key_functions[]; -extern char gui_key_buffer[128]; -extern int gui_key_grab; -extern int gui_key_grab_count; extern char *gui_input_clipboard; extern time_t gui_last_activity_time; -extern t_gui_color *gui_color[GUI_NUM_COLORS]; - -/* GUI independent functions: windows */ +/* GUI independent functions */ +/* window */ extern int gui_window_tree_init (t_gui_window *); extern void gui_window_tree_node_to_leaf (t_gui_window_tree *, t_gui_window *); extern void gui_window_tree_free (t_gui_window_tree **); @@ -417,8 +77,7 @@ extern void gui_window_switch_next (t_gui_window *); extern void gui_window_switch_by_buffer (t_gui_window *, int); extern void gui_window_print_log (t_gui_window *); -/* GUI independent functions: buffers */ - +/* buffer */ extern t_gui_buffer *gui_buffer_servers_search (); extern t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int); extern t_gui_buffer *gui_buffer_search (char *, char *); @@ -438,8 +97,11 @@ extern t_gui_buffer *gui_buffer_switch_by_number (t_gui_window *, int); extern void gui_buffer_move_to_number (t_gui_buffer *, int); extern void gui_buffer_print_log (t_gui_buffer *); -/* GUI independent functions: actions */ +/* panel */ +extern t_gui_panel *gui_panel_new (char *, int, int, int, int); +extern void gui_panel_free (t_gui_panel *); +/* action */ extern void gui_action_clipboard_copy (char *, int); extern void gui_action_clipboard_paste (t_gui_window *); extern void gui_action_return (t_gui_window *); @@ -487,22 +149,20 @@ extern void gui_action_infobar_clear (t_gui_window *); extern void gui_action_refresh_screen (); extern void gui_action_grab_key (t_gui_window *); -/* GUI independent functions: keys */ - -extern void gui_key_init (); -extern void gui_key_init_grab (); -extern char *gui_key_get_internal_code (char *); -extern char *gui_key_get_expanded_name (char *); -extern void *gui_key_function_search_by_name (char *); -extern char *gui_key_function_search_by_ptr (void *); -extern t_gui_key *gui_key_bind (char *, char *); -extern int gui_key_unbind (char *); -extern int gui_key_pressed (char *); -extern void gui_key_free (t_gui_key *); -extern void gui_key_free_all (); - -/* other GUI independent functions */ - +/* key */ +extern void gui_keyboard_init (); +extern void gui_keyboard_init_grab (); +extern char *gui_keyboard_get_internal_code (char *); +extern char *gui_keyboard_get_expanded_name (char *); +extern void *gui_keyboard_function_search_by_name (char *); +extern char *gui_keyboard_function_search_by_ptr (void *); +extern t_gui_key *gui_keyboard_bind (char *, char *); +extern int gui_keyboard_unbind (char *); +extern int gui_keyboard_pressed (char *); +extern void gui_keyboard_free (t_gui_key *); +extern void gui_keyboard_free_all (); + +/* other */ extern void gui_infobar_printf (int, int, char *, ...); extern void gui_infobar_printf_from_buffer (t_gui_buffer *, int, int, char *, char *, ...); extern void gui_infobar_remove (); @@ -518,16 +178,9 @@ extern void gui_exec_action_dcc (t_gui_window *, char *); extern void gui_exec_action_raw_data (t_gui_window *, char *); extern int gui_insert_string_input (t_gui_window *, char *, int); -/* GUI dependant functions: keyboard */ +/* GUI dependent functions */ -extern void gui_keyboard_default_bindings (); - -/* GUI dependant functions: display */ - -extern void gui_chat_draw_title (t_gui_buffer *, int); -extern char *gui_chat_word_get_next_char (t_gui_window *, unsigned char *, int); -extern void gui_chat_draw (t_gui_buffer *, int); -extern void gui_chat_draw_line (t_gui_buffer *, t_gui_line *); +/* color */ extern int gui_color_assign (int *, char *); extern char *gui_color_get_name (int); extern unsigned char *gui_color_decode (unsigned char *, int); @@ -535,11 +188,34 @@ extern unsigned char *gui_color_decode_for_user_entry (unsigned char *); extern unsigned char *gui_color_encode (unsigned char *); extern void gui_color_init_pairs (); extern void gui_color_rebuild_weechat(); + +/* keyboard */ +extern void gui_keyboard_default_bindings (); + +/* chat */ +extern void gui_chat_draw_title (t_gui_buffer *, int); +extern char *gui_chat_word_get_next_char (t_gui_window *, unsigned char *, int); +extern void gui_chat_draw (t_gui_buffer *, int); +extern void gui_chat_draw_line (t_gui_buffer *, t_gui_line *); + +/* status bar */ extern void gui_infobar_draw_time (t_gui_buffer *); extern void gui_infobar_draw (t_gui_buffer *, int); + +/* info bar */ +extern void gui_status_draw (t_gui_buffer *, int); + +/* input */ extern void gui_input_draw (t_gui_buffer *, int); + +/* nicklist */ extern void gui_nicklist_draw (t_gui_buffer *, int); -extern void gui_status_draw (t_gui_buffer *, int); + +/* window */ +extern int gui_window_get_width (); +extern int gui_window_get_height (); +extern int gui_window_objects_init (t_gui_window *); +extern void gui_window_objects_free (t_gui_window *, int); extern int gui_window_calculate_pos_size (t_gui_window *, int); extern void gui_window_redraw_buffer (t_gui_buffer *); extern void gui_window_switch_to_buffer (t_gui_window *, t_gui_buffer *); @@ -567,6 +243,13 @@ extern void gui_window_switch_right (t_gui_window *); extern void gui_window_refresh_screen (); extern void gui_window_set_title (); extern void gui_window_reset_title (); +extern void gui_window_objects_print_log (t_gui_window *); + +/* panel */ +extern int gui_panel_window_new (t_gui_panel *, t_gui_window *); +extern void gui_panel_window_free (void *); + +/* main */ extern void gui_main_loop (); extern void gui_main_pre_init (int *, char **[]); extern void gui_main_init (); diff --git a/weechat/po/POTFILES.in b/weechat/po/POTFILES.in index 3639a29cc..1b55f3360 100644 --- a/weechat/po/POTFILES.in +++ b/weechat/po/POTFILES.in @@ -14,32 +14,40 @@ ./src/plugins/plugins-config.h ./src/plugins/plugins-interface.c ./src/plugins/weechat-plugin.h -./src/gui/curses/gui-chat.c -./src/gui/curses/gui-color.c -./src/gui/curses/gui-infobar.c -./src/gui/curses/gui-input.c -./src/gui/curses/gui-keyboard.c -./src/gui/curses/gui-main.c -./src/gui/curses/gui-nicklist.c -./src/gui/curses/gui-status.c -./src/gui/curses/gui-window.c +./src/gui/curses/gui-curses-chat.c +./src/gui/curses/gui-curses-color.c +./src/gui/curses/gui-curses-infobar.c +./src/gui/curses/gui-curses-input.c +./src/gui/curses/gui-curses-keyboard.c +./src/gui/curses/gui-curses-main.c +./src/gui/curses/gui-curses-nicklist.c +./src/gui/curses/gui-curses-panel.c +./src/gui/curses/gui-curses-status.c +./src/gui/curses/gui-curses-window.c ./src/gui/curses/gui-curses.h -./src/gui/gtk/gui-chat.c -./src/gui/gtk/gui-color.c -./src/gui/gtk/gui-infobar.c -./src/gui/gtk/gui-input.c -./src/gui/gtk/gui-keyboard.c -./src/gui/gtk/gui-main.c -./src/gui/gtk/gui-nicklist.c -./src/gui/gtk/gui-status.c -./src/gui/gtk/gui-window.c +./src/gui/gtk/gui-gtk-chat.c +./src/gui/gtk/gui-gtk-color.c +./src/gui/gtk/gui-gtk-infobar.c +./src/gui/gtk/gui-gtk-input.c +./src/gui/gtk/gui-gtk-keyboard.c +./src/gui/gtk/gui-gtk-main.c +./src/gui/gtk/gui-gtk-nicklist.c +./src/gui/gtk/gui-gtk-panel.c +./src/gui/gtk/gui-gtk-status.c +./src/gui/gtk/gui-gtk-window.c ./src/gui/gtk/gui-gtk.h ./src/gui/gui-action.c ./src/gui/gui-buffer.c ./src/gui/gui-common.c ./src/gui/gui-keyboard.c +./src/gui/gui-panel.c ./src/gui/gui-window.c ./src/gui/gui.h +./src/gui/gui-buffer.h +./src/gui/gui-color.h +./src/gui/gui-keyboard.h +./src/gui/gui-panel.h +./src/gui/gui-window.h ./src/common/command.c ./src/common/command.h ./src/common/completion.c diff --git a/weechat/src/common/command.c b/weechat/src/common/command.c index 5d18619ab..1068b3d17 100644 --- a/weechat/src/common/command.c +++ b/weechat/src/common/command.c @@ -2433,7 +2433,7 @@ weechat_cmd_key_display (t_gui_key *key, int new_key) { char *expanded_name; - expanded_name = gui_key_get_expanded_name (key->key); + expanded_name = gui_keyboard_get_expanded_name (key->key); if (new_key) { irc_display_prefix (NULL, NULL, PREFIX_INFO); @@ -2446,7 +2446,7 @@ weechat_cmd_key_display (t_gui_key *key, int new_key) GUI_COLOR(COLOR_WIN_CHAT_DARK), GUI_COLOR(COLOR_WIN_CHAT), (key->function) ? - gui_key_function_search_by_ptr (key->function) : key->command); + gui_keyboard_function_search_by_ptr (key->function) : key->command); if (expanded_name) free (expanded_name); } @@ -2487,7 +2487,7 @@ weechat_cmd_key (t_irc_server *server, t_irc_channel *channel, arguments += 7; while (arguments[0] == ' ') arguments++; - if (gui_key_unbind (arguments)) + if (gui_keyboard_unbind (arguments)) { irc_display_prefix (NULL, NULL, PREFIX_INFO); gui_printf (NULL, _("Key \"%s\" unbinded\n"), arguments); @@ -2521,8 +2521,8 @@ weechat_cmd_key (t_irc_server *server, t_irc_channel *channel, arguments++; if (ascii_strcasecmp (arguments, "-yes") == 0) { - gui_key_free_all (); - gui_key_init (); + gui_keyboard_free_all (); + gui_keyboard_init (); irc_display_prefix (NULL, NULL, PREFIX_INFO); gui_printf (NULL, _("Default key bindings restored\n")); } @@ -2552,7 +2552,7 @@ weechat_cmd_key (t_irc_server *server, t_irc_channel *channel, pos++; while (pos[0] == ' ') pos++; - ptr_key = gui_key_bind (arguments, pos); + ptr_key = gui_keyboard_bind (arguments, pos); if (ptr_key) weechat_cmd_key_display (ptr_key, 1); else diff --git a/weechat/src/common/weechat.c b/weechat/src/common/weechat.c index 5963d89bf..6468bc6dc 100644 --- a/weechat/src/common/weechat.c +++ b/weechat/src/common/weechat.c @@ -564,10 +564,10 @@ weechat_display_keys () printf ("\n"); for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) { - expanded_name = gui_key_get_expanded_name (ptr_key->key); + expanded_name = gui_keyboard_get_expanded_name (ptr_key->key); printf ("* %s => %s\n", (expanded_name) ? expanded_name : ptr_key->key, - (ptr_key->function) ? gui_key_function_search_by_ptr (ptr_key->function) : ptr_key->command); + (ptr_key->function) ? gui_keyboard_function_search_by_ptr (ptr_key->function) : ptr_key->command); if (expanded_name) free (expanded_name); } @@ -1095,7 +1095,7 @@ main (int argc, char *argv[]) signal (SIGSEGV, weechat_sigsegv); /* crash dump when SIGSEGV received */ gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */ weechat_init_vars (); /* initialize some variables */ - gui_key_init (); /* init keyb. (default key bindings)*/ + gui_keyboard_init (); /* init keyb. (default key bindings)*/ weechat_parse_args (argc, argv); /* parse command line args */ weechat_create_home_dirs (); /* create WeeChat directories */ weechat_init_log (); /* init log file */ diff --git a/weechat/src/gui/Makefile.am b/weechat/src/gui/Makefile.am index b202250e2..6a1ea4fc1 100644 --- a/weechat/src/gui/Makefile.am +++ b/weechat/src/gui/Makefile.am @@ -24,7 +24,13 @@ lib_weechat_gui_common_a_SOURCES = gui-buffer.c \ gui-action.c \ gui-keyboard.c \ gui-window.c \ - gui.h + gui-panel.c \ + gui.h \ + gui-buffer.h \ + gui-color.h \ + gui-keyboard.h \ + gui-panel.h \ + gui-window.h if GUI_NCURSES curses_dir=curses diff --git a/weechat/src/gui/curses/Makefile.am b/weechat/src/gui/curses/Makefile.am index 0041d8080..283d89bfe 100644 --- a/weechat/src/gui/curses/Makefile.am +++ b/weechat/src/gui/curses/Makefile.am @@ -21,8 +21,8 @@ bin_PROGRAMS = weechat-curses if PLUGINS weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \ - ../gui-window.o ../gui-keyboard.o \ - ../gui-action.o \ + ../gui-window.o ../gui-panel.o \ + ../gui-keyboard.o ../gui-action.o \ ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ ../../plugins/lib_weechat_plugins.a \ @@ -31,8 +31,8 @@ weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \ $(GNUTLS_LFLAGS) else weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \ - ../gui-window.o ../gui-keyboard.o \ - ../gui-action.o \ + ../gui-window.o ../gui-panel.o \ + ../gui-keyboard.o ../gui-action.o \ ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ $(PLUGINS_LIBS) \ @@ -40,13 +40,14 @@ weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \ $(GNUTLS_LFLAGS) endif -weechat_curses_SOURCES = gui-chat.c \ - gui-color.c \ - gui-infobar.c \ - gui-input.c \ - gui-keyboard.c \ - gui-main.c \ - gui-nicklist.c \ - gui-status.c \ - gui-window.c \ +weechat_curses_SOURCES = gui-curses-chat.c \ + gui-curses-color.c \ + gui-curses-infobar.c \ + gui-curses-input.c \ + gui-curses-keyboard.c \ + gui-curses-main.c \ + gui-curses-nicklist.c \ + gui-curses-status.c \ + gui-curses-window.c \ + gui-curses-panel.c \ gui-curses.h diff --git a/weechat/src/gui/curses/gui-chat.c b/weechat/src/gui/curses/gui-curses-chat.c index e7bef1cd2..8493a4c1c 100644 --- a/weechat/src/gui/curses/gui-chat.c +++ b/weechat/src/gui/curses/gui-curses-chat.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-chat.c: chat display functions for Curses GUI */ +/* gui-curses-chat.c: chat display functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -28,12 +28,6 @@ #include <string.h> #include <ctype.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" @@ -50,7 +44,7 @@ void gui_chat_set_style (t_gui_window *window, int style) { - wattron (window->win_chat, style); + wattron (GUI_CURSES(window)->win_chat, style); } /* @@ -61,7 +55,7 @@ gui_chat_set_style (t_gui_window *window, int style) void gui_chat_remove_style (t_gui_window *window, int style) { - wattroff (window->win_chat, style); + wattroff (GUI_CURSES(window)->win_chat, style); } /* @@ -92,7 +86,7 @@ gui_chat_reset_style (t_gui_window *window) window->current_style_attr = 0; window->current_color_attr = 0; - gui_window_set_weechat_color (window->win_chat, COLOR_WIN_CHAT); + gui_window_set_weechat_color (GUI_CURSES(window)->win_chat, COLOR_WIN_CHAT); gui_chat_remove_style (window, A_BOLD | A_UNDERLINE | A_REVERSE); } @@ -105,7 +99,7 @@ void gui_chat_set_color_style (t_gui_window *window, int style) { window->current_color_attr |= style; - wattron (window->win_chat, style); + wattron (GUI_CURSES(window)->win_chat, style); } /* @@ -116,7 +110,7 @@ void gui_chat_remove_color_style (t_gui_window *window, int style) { window->current_color_attr &= !style; - wattroff (window->win_chat, style); + wattroff (GUI_CURSES(window)->win_chat, style); } /* @@ -126,7 +120,7 @@ gui_chat_remove_color_style (t_gui_window *window, int style) void gui_chat_reset_color_style (t_gui_window *window) { - wattroff (window->win_chat, window->current_color_attr); + wattroff (GUI_CURSES(window)->win_chat, window->current_color_attr); window->current_color_attr = 0; } @@ -139,14 +133,14 @@ gui_chat_set_color (t_gui_window *window, int fg, int bg) { if (((fg == -1) || (fg == 99)) && ((bg == -1) || (bg == 99))) - wattron (window->win_chat, COLOR_PAIR(63)); + wattron (GUI_CURSES(window)->win_chat, COLOR_PAIR(63)); else { if ((fg == -1) || (fg == 99)) fg = WEECHAT_COLOR_WHITE; if ((bg == -1) || (bg == 99)) bg = 0; - wattron (window->win_chat, COLOR_PAIR((bg * 8) + fg)); + wattron (GUI_CURSES(window)->win_chat, COLOR_PAIR((bg * 8) + fg)); } } @@ -183,9 +177,9 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase) if (ptr_win->buffer == buffer) { if (erase) - gui_window_curses_clear (ptr_win->win_title, COLOR_WIN_TITLE); + gui_window_curses_clear (GUI_CURSES(ptr_win)->win_title, COLOR_WIN_TITLE); - gui_window_set_weechat_color (ptr_win->win_title, COLOR_WIN_TITLE); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title, COLOR_WIN_TITLE); snprintf (format, 32, "%%-%ds", ptr_win->win_width); if (CHANNEL(buffer)) { @@ -195,28 +189,29 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase) buf2 = channel_iconv_decode (SERVER(buffer), CHANNEL(buffer), (buf) ? buf : CHANNEL(buffer)->topic); - mvwprintw (ptr_win->win_title, 0, 0, format, (buf2) ? buf2 : CHANNEL(buffer)->topic); + mvwprintw (GUI_CURSES(ptr_win)->win_title, 0, 0, + format, (buf2) ? buf2 : CHANNEL(buffer)->topic); if (buf) free (buf); if (buf2) free (buf2); } else - mvwprintw (ptr_win->win_title, 0, 0, format, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_title, 0, 0, format, " "); } else { if (buffer->type == BUFFER_TYPE_STANDARD) { - mvwprintw (ptr_win->win_title, 0, 0, + mvwprintw (GUI_CURSES(ptr_win)->win_title, 0, 0, format, PACKAGE_STRING " " WEECHAT_COPYRIGHT_DATE " - " WEECHAT_WEBSITE); } else - mvwprintw (ptr_win->win_title, 0, 0, format, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_title, 0, 0, format, " "); } - wnoutrefresh (ptr_win->win_title); + wnoutrefresh (GUI_CURSES(ptr_win)->win_title); refresh (); } } @@ -234,10 +229,10 @@ gui_chat_display_new_line (t_gui_window *window, int num_lines, int count, { if ((!simulate) && (window->win_chat_cursor_x <= window->win_chat_width - 1)) { - wmove (window->win_chat, + wmove (GUI_CURSES(window)->win_chat, window->win_chat_cursor_y, window->win_chat_cursor_x); - wclrtoeol (window->win_chat); + wclrtoeol (GUI_CURSES(window)->win_chat); } window->win_chat_cursor_y++; } @@ -423,7 +418,7 @@ gui_chat_display_word_raw (t_gui_window *window, char *string) { char *prev_char, *next_char, saved_char; - wmove (window->win_chat, + wmove (GUI_CURSES(window)->win_chat, window->win_chat_cursor_y, window->win_chat_cursor_x); @@ -438,7 +433,7 @@ gui_chat_display_word_raw (t_gui_window *window, char *string) { saved_char = next_char[0]; next_char[0] = '\0'; - wprintw (window->win_chat, "%s", prev_char); + wprintw (GUI_CURSES(window)->win_chat, "%s", prev_char); next_char[0] = saved_char; } @@ -488,10 +483,10 @@ gui_chat_display_word (t_gui_window *window, { if (!simulate) { - wmove (window->win_chat, + wmove (GUI_CURSES(window)->win_chat, window->win_chat_cursor_y, window->win_chat_cursor_x); - wclrtoeol (window->win_chat); + wclrtoeol (GUI_CURSES(window)->win_chat); } window->win_chat_cursor_x += line->length_align; } @@ -743,7 +738,7 @@ gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count, (window->buffer->last_read_line == line->prev_line)) { gui_chat_set_weechat_color (window, COLOR_WIN_CHAT_READ_MARKER); - mvwprintw (window->win_chat, read_marker_y, read_marker_x, + mvwprintw (GUI_CURSES(window)->win_chat, read_marker_y, read_marker_x, "%c", cfg_look_read_marker[0]); } } @@ -878,16 +873,16 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) { if (erase) { - gui_window_set_weechat_color (ptr_win->win_chat, COLOR_WIN_CHAT); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, COLOR_WIN_CHAT); snprintf (format_empty, 32, "%%-%ds", ptr_win->win_chat_width); for (i = 0; i < ptr_win->win_chat_height; i++) { - mvwprintw (ptr_win->win_chat, i, 0, format_empty, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_chat, i, 0, format_empty, " "); } } - gui_window_set_weechat_color (ptr_win->win_chat, COLOR_WIN_CHAT); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, COLOR_WIN_CHAT); if (buffer->type == BUFFER_TYPE_DCC) { @@ -900,57 +895,57 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) break; /* nickname and filename */ - gui_window_set_weechat_color (ptr_win->win_chat, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, (ptr_dcc == dcc_selected) ? COLOR_DCC_SELECTED : COLOR_WIN_CHAT); - mvwprintw (ptr_win->win_chat, i, 0, "%s %-16s ", + mvwprintw (GUI_CURSES(ptr_win)->win_chat, i, 0, "%s %-16s ", (ptr_dcc == dcc_selected) ? "***" : " ", ptr_dcc->nick); buf = channel_iconv_decode (SERVER(buffer), CHANNEL(buffer), (DCC_IS_CHAT(ptr_dcc->type)) ? _(ptr_dcc->filename) : ptr_dcc->filename); - wprintw (ptr_win->win_chat, "%s", buf); + wprintw (GUI_CURSES(ptr_win)->win_chat, "%s", buf); free (buf); if (DCC_IS_FILE(ptr_dcc->type)) { if (ptr_dcc->filename_suffix > 0) - wprintw (ptr_win->win_chat, " (.%d)", + wprintw (GUI_CURSES(ptr_win)->win_chat, " (.%d)", ptr_dcc->filename_suffix); } /* status */ - gui_window_set_weechat_color (ptr_win->win_chat, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, (ptr_dcc == dcc_selected) ? COLOR_DCC_SELECTED : COLOR_WIN_CHAT); - mvwprintw (ptr_win->win_chat, i + 1, 0, "%s %s ", + mvwprintw (GUI_CURSES(ptr_win)->win_chat, i + 1, 0, "%s %s ", (ptr_dcc == dcc_selected) ? "***" : " ", (DCC_IS_RECV(ptr_dcc->type)) ? "-->>" : "<<--"); - gui_window_set_weechat_color (ptr_win->win_chat, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, COLOR_DCC_WAITING + ptr_dcc->status); buf = channel_iconv_decode (SERVER(buffer), CHANNEL(buffer), _(dcc_status_string[ptr_dcc->status])); - wprintw (ptr_win->win_chat, "%-10s", buf); + wprintw (GUI_CURSES(ptr_win)->win_chat, "%-10s", buf); free (buf); /* other infos */ - gui_window_set_weechat_color (ptr_win->win_chat, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, (ptr_dcc == dcc_selected) ? COLOR_DCC_SELECTED : COLOR_WIN_CHAT); if (DCC_IS_FILE(ptr_dcc->type)) { - wprintw (ptr_win->win_chat, " ["); + wprintw (GUI_CURSES(ptr_win)->win_chat, " ["); if (ptr_dcc->size == 0) num_bars = 10; else num_bars = (int)((((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100) / 10); for (j = 0; j < num_bars - 1; j++) - wprintw (ptr_win->win_chat, "="); + wprintw (GUI_CURSES(ptr_win)->win_chat, "="); if (num_bars > 0) - wprintw (ptr_win->win_chat, ">"); + wprintw (GUI_CURSES(ptr_win)->win_chat, ">"); for (j = 0; j < 10 - num_bars; j++) - wprintw (ptr_win->win_chat, " "); + wprintw (GUI_CURSES(ptr_win)->win_chat, " "); if (ptr_dcc->size < 1024*10) num_unit = 0; @@ -960,12 +955,12 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) num_unit = 2; else num_unit = 3; - wprintw (ptr_win->win_chat, "] %3lu%% ", + wprintw (GUI_CURSES(ptr_win)->win_chat, "] %3lu%% ", (unsigned long)(((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100)); sprintf (format, "%s %%s / %s %%s", unit_format[num_unit], unit_format[num_unit]); - wprintw (ptr_win->win_chat, format, + wprintw (GUI_CURSES(ptr_win)->win_chat, format, ((long double)(ptr_dcc->pos)) / ((long double)(unit_divide[num_unit])), unit_name[num_unit], ((long double)(ptr_dcc->size)) / ((long double)(unit_divide[num_unit])), @@ -977,11 +972,11 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) num_unit = 2; else num_unit = 3; - wprintw (ptr_win->win_chat, " ("); + wprintw (GUI_CURSES(ptr_win)->win_chat, " ("); if (ptr_dcc->status == DCC_ACTIVE) { - wprintw (ptr_win->win_chat, _("ETA")); - wprintw (ptr_win->win_chat, ": %.2lu:%.2lu:%.2lu - ", + wprintw (GUI_CURSES(ptr_win)->win_chat, _("ETA")); + wprintw (GUI_CURSES(ptr_win)->win_chat, ": %.2lu:%.2lu:%.2lu - ", ptr_dcc->eta / 3600, (ptr_dcc->eta / 60) % 60, ptr_dcc->eta % 60); @@ -990,7 +985,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) buf = channel_iconv_decode (SERVER(buffer), CHANNEL(buffer), unit_name[num_unit]); - wprintw (ptr_win->win_chat, format, + wprintw (GUI_CURSES(ptr_win)->win_chat, format, ((long double) ptr_dcc->bytes_per_sec) / ((long double)(unit_divide[num_unit])), buf); free (buf); @@ -999,10 +994,10 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) { date_tmp = localtime (&(ptr_dcc->start_time)); strftime (date, sizeof (date) - 1, "%a, %d %b %Y %H:%M:%S", date_tmp); - wprintw (ptr_win->win_chat, " %s", date); + wprintw (GUI_CURSES(ptr_win)->win_chat, " %s", date); } - wclrtoeol (ptr_win->win_chat); + wclrtoeol (GUI_CURSES(ptr_win)->win_chat); ptr_win->dcc_last_displayed = ptr_dcc; i += 2; @@ -1078,7 +1073,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase) ptr_win->win_chat_cursor_y = ptr_win->win_chat_height - 1; } } - wnoutrefresh (ptr_win->win_chat); + wnoutrefresh (GUI_CURSES(ptr_win)->win_chat); refresh (); } } diff --git a/src/gui/curses/gui-color.c b/weechat/src/gui/curses/gui-curses-color.c index 9fd1d85de..da8cee765 100644 --- a/src/gui/curses/gui-color.c +++ b/weechat/src/gui/curses/gui-curses-color.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-color.c: color functions for Curses GUI */ +/* gui-curses-color.c: color functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -28,12 +28,6 @@ #include <string.h> #include <ctype.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/weeconfig.h" diff --git a/src/gui/curses/gui-infobar.c b/weechat/src/gui/curses/gui-curses-infobar.c index 73abf75c0..f76ec0943 100644 --- a/src/gui/curses/gui-infobar.c +++ b/weechat/src/gui/curses/gui-curses-infobar.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-infobar.c: infobar display functions for Curses GUI */ +/* gui-curses-infobar.c: infobar display functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -27,12 +27,6 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" @@ -63,17 +57,17 @@ gui_infobar_draw_time (t_gui_buffer *buffer) local_time = localtime (&time_seconds); if (local_time) { - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); - mvwprintw (ptr_win->win_infobar, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); + mvwprintw (GUI_CURSES(ptr_win)->win_infobar, 0, 1, "%02d:%02d", local_time->tm_hour, local_time->tm_min); if (cfg_look_infobar_seconds) - wprintw (ptr_win->win_infobar, + wprintw (GUI_CURSES(ptr_win)->win_infobar, ":%02d", local_time->tm_sec); } - wnoutrefresh (ptr_win->win_infobar); + wnoutrefresh (GUI_CURSES(ptr_win)->win_infobar); } } @@ -98,40 +92,40 @@ gui_infobar_draw (t_gui_buffer *buffer, int erase) for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { if (erase) - gui_window_curses_clear (ptr_win->win_infobar, COLOR_WIN_INFOBAR); + gui_window_curses_clear (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); time_seconds = time (NULL); local_time = localtime (&time_seconds); if (local_time) { strftime (text_time, 1024, cfg_look_infobar_timestamp, local_time); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); - wprintw (ptr_win->win_infobar, "["); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); - wprintw (ptr_win->win_infobar, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); + wprintw (GUI_CURSES(ptr_win)->win_infobar, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); + wprintw (GUI_CURSES(ptr_win)->win_infobar, "%02d:%02d", local_time->tm_hour, local_time->tm_min); if (cfg_look_infobar_seconds) - wprintw (ptr_win->win_infobar, + wprintw (GUI_CURSES(ptr_win)->win_infobar, ":%02d", local_time->tm_sec); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); - wprintw (ptr_win->win_infobar, "]"); - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); - wprintw (ptr_win->win_infobar, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); + wprintw (GUI_CURSES(ptr_win)->win_infobar, "]"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR); + wprintw (GUI_CURSES(ptr_win)->win_infobar, " %s", text_time); } if (gui_infobar) { - gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); - wprintw (ptr_win->win_infobar, " | "); - gui_window_set_weechat_color (ptr_win->win_infobar, gui_infobar->color); - wprintw (ptr_win->win_infobar, "%s", gui_infobar->text); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); + wprintw (GUI_CURSES(ptr_win)->win_infobar, " | "); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, gui_infobar->color); + wprintw (GUI_CURSES(ptr_win)->win_infobar, "%s", gui_infobar->text); } - wnoutrefresh (ptr_win->win_infobar); + wnoutrefresh (GUI_CURSES(ptr_win)->win_infobar); refresh (); } } diff --git a/src/gui/curses/gui-input.c b/weechat/src/gui/curses/gui-curses-input.c index 9e93c9a1a..f6ed316f1 100644 --- a/src/gui/curses/gui-input.c +++ b/weechat/src/gui/curses/gui-curses-input.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-input: input display functions for Curses GUI */ +/* gui-curses-input: input display functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -26,12 +26,6 @@ #include <stdlib.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" @@ -57,18 +51,18 @@ gui_input_set_color (t_gui_window *window, int irc_color) irc_color %= GUI_NUM_IRC_COLORS; if (gui_irc_colors[irc_color][1] & A_BOLD) - wattron (window->win_input, A_BOLD); + wattron (GUI_CURSES(window)->win_input, A_BOLD); if (((fg == -1) || (fg == 99)) && ((bg == -1) || (bg == 99))) - wattron (window->win_input, COLOR_PAIR(63)); + wattron (GUI_CURSES(window)->win_input, COLOR_PAIR(63)); else { if ((fg == -1) || (fg == 99)) fg = WEECHAT_COLOR_WHITE; if ((bg == -1) || (bg == 99)) bg = 0; - wattron (window->win_input, COLOR_PAIR((bg * 8) + fg)); + wattron (GUI_CURSES(window)->win_input, COLOR_PAIR((bg * 8) + fg)); } } @@ -158,7 +152,7 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) char *pos, saved_char, *modes; int char_size, mode_found; - wmove (window->win_input, 0, 0); + wmove (GUI_CURSES(window)->win_input, 0, 0); pos = cfg_look_input_format; while (pos && pos[0]) { @@ -171,18 +165,18 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) case 'c': if (CHANNEL(window->buffer)) { - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_CHANNEL); - wprintw (window->win_input, "%s", + wprintw (GUI_CURSES(window)->win_input, "%s", CHANNEL(window->buffer)->name); } else { if (SERVER(window->buffer)) { - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_SERVER); - wprintw (window->win_input, "%s", + wprintw (GUI_CURSES(window)->win_input, "%s", SERVER(window->buffer)->name); } } @@ -200,14 +194,14 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) } if (mode_found) { - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT); - wprintw (window->win_input, "+"); + wprintw (GUI_CURSES(window)->win_input, "+"); for (modes = SERVER(window->buffer)->nick_modes; modes && modes[0]; modes++) { if (modes[0] != ' ') - wprintw (window->win_input, "%c", + wprintw (GUI_CURSES(window)->win_input, "%c", modes[0]); } } @@ -215,9 +209,9 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) pos++; break; case 'n': - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_NICK); - wprintw (window->win_input, "%s", nick); + wprintw (GUI_CURSES(window)->win_input, "%s", nick); pos++; break; default: @@ -226,15 +220,15 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) char_size = utf8_char_size (pos); saved_char = pos[char_size]; pos[char_size] = '\0'; - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_DELIMITERS); - wprintw (window->win_input, "%%%s", pos); + wprintw (GUI_CURSES(window)->win_input, "%%%s", pos); pos[char_size] = saved_char; pos += char_size; } else { - wprintw (window->win_input, "%%"); + wprintw (GUI_CURSES(window)->win_input, "%%"); pos++; } break; @@ -244,9 +238,9 @@ gui_input_draw_prompt (t_gui_window *window, char *nick) char_size = utf8_char_size (pos); saved_char = pos[char_size]; pos[char_size] = '\0'; - gui_window_set_weechat_color (window->win_input, + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT_DELIMITERS); - wprintw (window->win_input, "%s", pos); + wprintw (GUI_CURSES(window)->win_input, "%s", pos); pos[char_size] = saved_char; pos += char_size; break; @@ -283,12 +277,12 @@ gui_input_draw_text (t_gui_window *window, int input_width) if (color != last_color) { if (color == -1) - gui_window_set_weechat_color (window->win_input, COLOR_WIN_INPUT); + gui_window_set_weechat_color (GUI_CURSES(window)->win_input, COLOR_WIN_INPUT); else gui_input_set_color (window, color); } last_color = color; - wprintw (window->win_input, "%s", ptr_start); + wprintw (GUI_CURSES(window)->win_input, "%s", ptr_start); ptr_next[0] = saved_char; ptr_start = ptr_next; pos_mask += size; @@ -320,7 +314,7 @@ gui_input_draw (t_gui_buffer *buffer, int erase) if (ptr_win->buffer == buffer) { if (erase) - gui_window_curses_clear (ptr_win->win_input, COLOR_WIN_INPUT); + gui_window_curses_clear (GUI_CURSES(ptr_win)->win_input, COLOR_WIN_INPUT); switch (buffer->type) { @@ -372,13 +366,13 @@ gui_input_draw (t_gui_buffer *buffer, int erase) if (display_prompt) gui_input_draw_prompt (ptr_win, ptr_nickname); - gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input, COLOR_WIN_INPUT); snprintf (format, 32, "%%-%ds", ptr_win->win_width - prompt_length); if (ptr_win == gui_current_window) gui_input_draw_text (ptr_win, ptr_win->win_width - prompt_length); else - wprintw (ptr_win->win_input, format, ""); - wclrtoeol (ptr_win->win_input); + wprintw (GUI_CURSES(ptr_win)->win_input, format, ""); + wclrtoeol (GUI_CURSES(ptr_win)->win_input); ptr_win->win_input_x = prompt_length + (buffer->input_buffer_pos - buffer->input_buffer_1st_display); if (ptr_win == gui_current_window) @@ -388,38 +382,38 @@ gui_input_draw (t_gui_buffer *buffer, int erase) break; case BUFFER_TYPE_DCC: dcc_selected = (ptr_win->dcc_selected) ? (t_irc_dcc *) ptr_win->dcc_selected : dcc_list; - wmove (ptr_win->win_input, 0, 0); + wmove (GUI_CURSES(ptr_win)->win_input, 0, 0); if (dcc_selected) { switch (dcc_selected->status) { case DCC_WAITING: if (DCC_IS_RECV(dcc_selected->type)) - wprintw (ptr_win->win_input, _(" [A] Accept")); - wprintw (ptr_win->win_input, _(" [C] Cancel")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [A] Accept")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [C] Cancel")); break; case DCC_CONNECTING: case DCC_ACTIVE: - wprintw (ptr_win->win_input, _(" [C] Cancel")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [C] Cancel")); break; case DCC_DONE: case DCC_FAILED: case DCC_ABORTED: - wprintw (ptr_win->win_input, _(" [R] Remove")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [R] Remove")); break; } } - wprintw (ptr_win->win_input, _(" [P] Purge old DCC")); - wprintw (ptr_win->win_input, _(" [Q] Close DCC view")); - wclrtoeol (ptr_win->win_input); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [P] Purge old DCC")); + wprintw (GUI_CURSES(ptr_win)->win_input, _(" [Q] Close DCC view")); + wclrtoeol (GUI_CURSES(ptr_win)->win_input); ptr_win->win_input_x = 0; if (ptr_win == gui_current_window) move (ptr_win->win_y + ptr_win->win_height - 1, ptr_win->win_x); break; case BUFFER_TYPE_RAW_DATA: - mvwprintw (ptr_win->win_input, 0, 0, _(" [Q] Close raw data view")); - wclrtoeol (ptr_win->win_input); + mvwprintw (GUI_CURSES(ptr_win)->win_input, 0, 0, _(" [Q] Close raw data view")); + wclrtoeol (GUI_CURSES(ptr_win)->win_input); ptr_win->win_input_x = 0; if (ptr_win == gui_current_window) move (ptr_win->win_y + ptr_win->win_height - 1, @@ -427,7 +421,7 @@ gui_input_draw (t_gui_buffer *buffer, int erase) break; } doupdate (); - wrefresh (ptr_win->win_input); + wrefresh (GUI_CURSES(ptr_win)->win_input); refresh (); } } diff --git a/weechat/src/gui/curses/gui-keyboard.c b/weechat/src/gui/curses/gui-curses-keyboard.c index 25c4bedd6..02a1c2f6c 100644 --- a/weechat/src/gui/curses/gui-keyboard.c +++ b/weechat/src/gui/curses/gui-curses-keyboard.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-keyboard.c: keyboard functions for Curses GUI */ +/* gui-curses-keyboard.c: keyboard functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -27,15 +27,10 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" +#include "gui-curses.h" #ifdef PLUGINS #include "../../plugins/plugins.h" @@ -43,7 +38,7 @@ /* - * gui_keyboard__default_bindings: create default key bindings + * gui_keyboard_default_bindings: create default key bindings */ void @@ -53,90 +48,90 @@ gui_keyboard_default_bindings () char key_str[32], command[32]; /* keys binded with internal functions */ - gui_key_bind ( /* RC */ "ctrl-M", "return"); - gui_key_bind ( /* RC */ "ctrl-J", "return"); - gui_key_bind ( /* tab */ "ctrl-I", "tab"); - gui_key_bind ( /* basckp */ "ctrl-H", "backspace"); - gui_key_bind ( /* basckp */ "ctrl-?", "backspace"); - gui_key_bind ( /* del */ "meta2-3~", "delete"); - gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line"); - gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); - gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); - gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); - gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars"); - gui_key_bind ( /* home */ "meta2-1~", "home"); - gui_key_bind ( /* home */ "meta2-H", "home"); - gui_key_bind ( /* home */ "meta2-7~", "home"); - gui_key_bind ( /* ^A */ "ctrl-A", "home"); - gui_key_bind ( /* end */ "meta2-4~", "end"); - gui_key_bind ( /* end */ "meta2-F", "end"); - gui_key_bind ( /* end */ "meta2-8~", "end"); - gui_key_bind ( /* ^E */ "ctrl-E", "end"); - gui_key_bind ( /* left */ "meta2-D", "left"); - gui_key_bind ( /* right */ "meta2-C", "right"); - gui_key_bind ( /* up */ "meta2-A", "up"); - gui_key_bind ( /* ^up */ "meta-Oa", "up_global"); - gui_key_bind ( /* down */ "meta2-B", "down"); - gui_key_bind ( /* ^down */ "meta-Ob", "down_global"); - gui_key_bind ( /* pgup */ "meta2-5~", "page_up"); - gui_key_bind ( /* pgdn */ "meta2-6~", "page_down"); - gui_key_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up"); - gui_key_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down"); - gui_key_bind ( /* m-home */ "meta-meta2-1~", "scroll_top"); - gui_key_bind ( /* m-end */ "meta-meta2-4~", "scroll_bottom"); - gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear"); - gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up"); - gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down"); - gui_key_bind ( /* m-F11 */ "meta-meta2-23~", "nick_beginning"); - gui_key_bind ( /* m-F12 */ "meta-meta2-24~", "nick_end"); - gui_key_bind ( /* ^L */ "ctrl-L", "refresh"); - gui_key_bind ( /* m-a */ "meta-a", "jump_smart"); - gui_key_bind ( /* m-b */ "meta-b", "previous_word"); - gui_key_bind ( /* ^left */ "meta-Od", "previous_word"); - gui_key_bind ( /* m-d */ "meta-d", "delete_next_word"); - gui_key_bind ( /* m-f */ "meta-f", "next_word"); - gui_key_bind ( /* ^right */ "meta-Oc", "next_word"); - gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear"); - gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); - gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); - gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); - gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); - gui_key_bind ( /* m-j,m-r */ "meta-jmeta-r", "jump_raw_data"); - gui_key_bind ( /* m-k */ "meta-k", "grab_key"); - gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); - gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); - gui_key_bind ( /* m-r */ "meta-r", "delete_line"); - gui_key_bind ( /* m-s */ "meta-s", "switch_server"); - gui_key_bind ( /* m-u */ "meta-u", "scroll_unread"); + gui_keyboard_bind ( /* RC */ "ctrl-M", "return"); + gui_keyboard_bind ( /* RC */ "ctrl-J", "return"); + gui_keyboard_bind ( /* tab */ "ctrl-I", "tab"); + gui_keyboard_bind ( /* basckp */ "ctrl-H", "backspace"); + gui_keyboard_bind ( /* basckp */ "ctrl-?", "backspace"); + gui_keyboard_bind ( /* del */ "meta2-3~", "delete"); + gui_keyboard_bind ( /* ^K */ "ctrl-K", "delete_end_line"); + gui_keyboard_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); + gui_keyboard_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); + gui_keyboard_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); + gui_keyboard_bind ( /* ^T */ "ctrl-T", "transpose_chars"); + gui_keyboard_bind ( /* home */ "meta2-1~", "home"); + gui_keyboard_bind ( /* home */ "meta2-H", "home"); + gui_keyboard_bind ( /* home */ "meta2-7~", "home"); + gui_keyboard_bind ( /* ^A */ "ctrl-A", "home"); + gui_keyboard_bind ( /* end */ "meta2-4~", "end"); + gui_keyboard_bind ( /* end */ "meta2-F", "end"); + gui_keyboard_bind ( /* end */ "meta2-8~", "end"); + gui_keyboard_bind ( /* ^E */ "ctrl-E", "end"); + gui_keyboard_bind ( /* left */ "meta2-D", "left"); + gui_keyboard_bind ( /* right */ "meta2-C", "right"); + gui_keyboard_bind ( /* up */ "meta2-A", "up"); + gui_keyboard_bind ( /* ^up */ "meta-Oa", "up_global"); + gui_keyboard_bind ( /* down */ "meta2-B", "down"); + gui_keyboard_bind ( /* ^down */ "meta-Ob", "down_global"); + gui_keyboard_bind ( /* pgup */ "meta2-5~", "page_up"); + gui_keyboard_bind ( /* pgdn */ "meta2-6~", "page_down"); + gui_keyboard_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up"); + gui_keyboard_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down"); + gui_keyboard_bind ( /* m-home */ "meta-meta2-1~", "scroll_top"); + gui_keyboard_bind ( /* m-end */ "meta-meta2-4~", "scroll_bottom"); + gui_keyboard_bind ( /* F10 */ "meta2-21~", "infobar_clear"); + gui_keyboard_bind ( /* F11 */ "meta2-23~", "nick_page_up"); + gui_keyboard_bind ( /* F12 */ "meta2-24~", "nick_page_down"); + gui_keyboard_bind ( /* m-F11 */ "meta-meta2-23~", "nick_beginning"); + gui_keyboard_bind ( /* m-F12 */ "meta-meta2-24~", "nick_end"); + gui_keyboard_bind ( /* ^L */ "ctrl-L", "refresh"); + gui_keyboard_bind ( /* m-a */ "meta-a", "jump_smart"); + gui_keyboard_bind ( /* m-b */ "meta-b", "previous_word"); + gui_keyboard_bind ( /* ^left */ "meta-Od", "previous_word"); + gui_keyboard_bind ( /* m-d */ "meta-d", "delete_next_word"); + gui_keyboard_bind ( /* m-f */ "meta-f", "next_word"); + gui_keyboard_bind ( /* ^right */ "meta-Oc", "next_word"); + gui_keyboard_bind ( /* m-h */ "meta-h", "hotlist_clear"); + gui_keyboard_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); + gui_keyboard_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); + gui_keyboard_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); + gui_keyboard_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); + gui_keyboard_bind ( /* m-j,m-r */ "meta-jmeta-r", "jump_raw_data"); + gui_keyboard_bind ( /* m-k */ "meta-k", "grab_key"); + gui_keyboard_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); + gui_keyboard_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); + gui_keyboard_bind ( /* m-r */ "meta-r", "delete_line"); + gui_keyboard_bind ( /* m-s */ "meta-s", "switch_server"); + gui_keyboard_bind ( /* m-u */ "meta-u", "scroll_unread"); /* keys binded with commands */ - gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); - gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1"); - gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); - gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1"); - gui_key_bind ( /* F7 */ "meta2-18~", "/window -1"); - gui_key_bind ( /* F8 */ "meta2-19~", "/window +1"); - gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); - gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); - gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); - gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); - gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10"); - gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1"); - gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2"); - gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3"); - gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4"); - gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5"); - gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6"); - gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7"); - gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8"); - gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9"); + gui_keyboard_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); + gui_keyboard_bind ( /* F5 */ "meta2-15~", "/buffer -1"); + gui_keyboard_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); + gui_keyboard_bind ( /* F6 */ "meta2-17~", "/buffer +1"); + gui_keyboard_bind ( /* F7 */ "meta2-18~", "/window -1"); + gui_keyboard_bind ( /* F8 */ "meta2-19~", "/window +1"); + gui_keyboard_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); + gui_keyboard_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); + gui_keyboard_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); + gui_keyboard_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); + gui_keyboard_bind ( /* m-0 */ "meta-0", "/buffer 10"); + gui_keyboard_bind ( /* m-1 */ "meta-1", "/buffer 1"); + gui_keyboard_bind ( /* m-2 */ "meta-2", "/buffer 2"); + gui_keyboard_bind ( /* m-3 */ "meta-3", "/buffer 3"); + gui_keyboard_bind ( /* m-4 */ "meta-4", "/buffer 4"); + gui_keyboard_bind ( /* m-5 */ "meta-5", "/buffer 5"); + gui_keyboard_bind ( /* m-6 */ "meta-6", "/buffer 6"); + gui_keyboard_bind ( /* m-7 */ "meta-7", "/buffer 7"); + gui_keyboard_bind ( /* m-8 */ "meta-8", "/buffer 8"); + gui_keyboard_bind ( /* m-9 */ "meta-9", "/buffer 9"); /* bind meta-j + {01..99} to switch to buffers # > 10 */ for (i = 1; i < 100; i++) { sprintf (key_str, "meta-j%02d", i); sprintf (command, "/buffer %d", i); - gui_key_bind (key_str, command); + gui_keyboard_bind (key_str, command); } } @@ -152,7 +147,7 @@ gui_keyboard_grab_end () char *buffer_before_key; /* get expanded name (for example: ^U => ctrl-u) */ - expanded_key = gui_key_get_expanded_name (gui_key_buffer); + expanded_key = gui_keyboard_get_expanded_name (gui_key_buffer); if (expanded_key) { @@ -289,7 +284,7 @@ gui_keyboard_read () /*gui_printf (gui_current_window->buffer, "gui_input_read: key = %s (%d)\n", key_str, key);*/ - if ((gui_key_pressed (key_str) != 0) && (insert_ok)) + if ((gui_keyboard_pressed (key_str) != 0) && (insert_ok)) { if (strcmp (key_str, "^^") == 0) key_str[1] = '\0'; diff --git a/src/gui/curses/gui-nicklist.c b/weechat/src/gui/curses/gui-curses-nicklist.c index 2022df25c..4bfa95de0 100644 --- a/src/gui/curses/gui-nicklist.c +++ b/weechat/src/gui/curses/gui-curses-nicklist.c @@ -17,19 +17,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-nicklist.c: nicklist display functions for Curses GUI */ +/* gui-curses-nicklist.c: nicklist display functions for Curses GUI */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/weeconfig.h" @@ -60,28 +54,28 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase) if (gui_window_calculate_pos_size (ptr_win, 0)) { - delwin (ptr_win->win_chat); - delwin (ptr_win->win_nick); - ptr_win->win_chat = newwin (ptr_win->win_chat_height, - ptr_win->win_chat_width, - ptr_win->win_chat_y, - ptr_win->win_chat_x); - ptr_win->win_nick = newwin (ptr_win->win_nick_height, - ptr_win->win_nick_width, - ptr_win->win_nick_y, - ptr_win->win_nick_x); + delwin (GUI_CURSES(ptr_win)->win_chat); + delwin (GUI_CURSES(ptr_win)->win_nick); + GUI_CURSES(ptr_win)->win_chat = newwin (ptr_win->win_chat_height, + ptr_win->win_chat_width, + ptr_win->win_chat_y, + ptr_win->win_chat_x); + GUI_CURSES(ptr_win)->win_nick = newwin (ptr_win->win_nick_height, + ptr_win->win_nick_width, + ptr_win->win_nick_y, + ptr_win->win_nick_x); gui_chat_draw (buffer, 1); erase = 1; } if (erase) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK); snprintf (format_empty, 32, "%%-%ds", ptr_win->win_nick_width); for (i = 0; i < ptr_win->win_nick_height; i++) { - mvwprintw (ptr_win->win_nick, i, 0, format_empty, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, i, 0, format_empty, " "); } } @@ -99,33 +93,33 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase) if (has_colors ()) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_SEP); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_SEP); switch (cfg_look_nicklist_position) { case CFG_LOOK_NICKLIST_LEFT: - mvwvline (ptr_win->win_nick, + mvwvline (GUI_CURSES(ptr_win)->win_nick, 0, ptr_win->win_nick_width - 1, ACS_VLINE, ptr_win->win_chat_height); break; case CFG_LOOK_NICKLIST_RIGHT: - mvwvline (ptr_win->win_nick, + mvwvline (GUI_CURSES(ptr_win)->win_nick, 0, 0, ACS_VLINE, ptr_win->win_chat_height); break; case CFG_LOOK_NICKLIST_TOP: - mvwhline (ptr_win->win_nick, + mvwhline (GUI_CURSES(ptr_win)->win_nick, ptr_win->win_nick_height - 1, 0, ACS_HLINE, ptr_win->win_chat_width); break; case CFG_LOOK_NICKLIST_BOTTOM: - mvwhline (ptr_win->win_nick, + mvwhline (GUI_CURSES(ptr_win)->win_nick, 0, 0, ACS_HLINE, ptr_win->win_chat_width); break; } } - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK); x = 0; y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0; column = 0; @@ -163,53 +157,53 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase) if ( ((i == 0) && (ptr_win->win_nick_start > 0)) || ((i == nicks_displayed - 1) && (ptr_nick->next_nick)) ) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_MORE); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_MORE); j = (max_length + 1) >= 4 ? 4 : max_length + 1; for (x2 = 1; x2 <= j; x2++) - mvwprintw (ptr_win->win_nick, y, x + x2, "+"); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x + x2, "+"); } else { if (ptr_nick->flags & NICK_CHANOWNER) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANOWNER); - mvwprintw (ptr_win->win_nick, y, x, "~"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_CHANOWNER); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "~"); x++; } else if (ptr_nick->flags & NICK_CHANADMIN) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANADMIN); - mvwprintw (ptr_win->win_nick, y, x, "&"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_CHANADMIN); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "&"); x++; } else if (ptr_nick->flags & NICK_OP) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_OP); - mvwprintw (ptr_win->win_nick, y, x, "@"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_OP); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "@"); x++; } else if (ptr_nick->flags & NICK_HALFOP) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_HALFOP); - mvwprintw (ptr_win->win_nick, y, x, "%%"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_HALFOP); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "%%"); x++; } else if (ptr_nick->flags & NICK_VOICE) { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_VOICE); - mvwprintw (ptr_win->win_nick, y, x, "+"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK_VOICE); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "+"); x++; } else { - gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); - mvwprintw (ptr_win->win_nick, y, x, " "); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, COLOR_WIN_NICK); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, " "); x++; } - gui_window_set_weechat_color (ptr_win->win_nick, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, ((cfg_irc_away_check > 0) && (ptr_nick->flags & NICK_AWAY)) ? COLOR_WIN_NICK_AWAY : COLOR_WIN_NICK); - mvwprintw (ptr_win->win_nick, y, x, format, ptr_nick->nick); + mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, format, ptr_nick->nick); ptr_nick = ptr_nick->next_nick; @@ -229,7 +223,7 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase) } } } - wnoutrefresh (ptr_win->win_nick); + wnoutrefresh (GUI_CURSES(ptr_win)->win_nick); refresh (); } } diff --git a/weechat/src/gui/curses/gui-curses-panel.c b/weechat/src/gui/curses/gui-curses-panel.c new file mode 100644 index 000000000..9e5f6b7f4 --- /dev/null +++ b/weechat/src/gui/curses/gui-curses-panel.c @@ -0,0 +1,202 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* gui-curses-panel.c: panel functions for Curses GUI */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> + +#include "../../common/weechat.h" +#include "../gui.h" +#include "../../irc/irc.h" +#include "gui-curses.h" + + +/* + * gui_panel_get_size: get total panel size for a position + */ + +int +gui_panel_get_size (t_gui_window *window, int position) +{ + t_gui_panel_window *ptr_panel_win; + int total_size; + + total_size = 0; + for (ptr_panel_win = GUI_CURSES(window)->panel_windows; ptr_panel_win; + ptr_panel_win = ptr_panel_win->next_panel_window) + { + if (ptr_panel_win->panel->position == position) + { + switch (position) + { + case GUI_PANEL_TOP: + case GUI_PANEL_BOTTOM: + total_size += ptr_panel_win->height; + break; + case GUI_PANEL_LEFT: + case GUI_PANEL_RIGHT: + total_size += ptr_panel_win->width; + break; + } + if (ptr_panel_win->panel->separator) + total_size++; + } + } + return total_size; +} + +/* + * gui_panel_window_new: create a new "window panel" for a panel, in screen or a window + * if window is not NULL, panel window will be in this window + */ + +int +gui_panel_window_new (t_gui_panel *panel, t_gui_window *window) +{ + t_gui_panel_window *new_panel_win; + int x1, y1, x2, y2; + + if (window) + { + x1 = window->win_x; + y1 = window->win_y + 1; + x2 = x1 + window->win_width - 1; + y2 = y1 + window->win_height - 1 - 4; + } + else + { + x1 = 0; + y1 = 0; + x2 = gui_window_get_width () - 1; + y2 = gui_window_get_height () - 1; + } + + if ((new_panel_win = (t_gui_panel_window *) malloc (sizeof (t_gui_panel_window)))) + { + new_panel_win->panel = panel; + if (window) + { + panel->panel_window = NULL; + new_panel_win->next_panel_window = GUI_CURSES(window)->panel_windows; + GUI_CURSES(window)->panel_windows = new_panel_win; + } + else + { + panel->panel_window = new_panel_win; + new_panel_win->next_panel_window = NULL; + } + switch (panel->position) + { + case GUI_PANEL_TOP: + new_panel_win->x = x1; + new_panel_win->y = y1; + new_panel_win->width = x2 - x1 + 1; + new_panel_win->height = panel->size; + break; + case GUI_PANEL_BOTTOM: + new_panel_win->x = x1; + new_panel_win->y = y2 - panel->size + 1; + new_panel_win->width = x2 - x1 + 1; + new_panel_win->height = panel->size; + break; + case GUI_PANEL_LEFT: + new_panel_win->x = x1; + new_panel_win->y = y1; + new_panel_win->width = panel->size; + new_panel_win->height = y2 - y1 + 1; + break; + case GUI_PANEL_RIGHT: + new_panel_win->x = x2 - panel->size + 1; + new_panel_win->y = y1; + new_panel_win->width = panel->size; + new_panel_win->height = y2 - y1 + 1; + break; + } + new_panel_win->win_panel = newwin (new_panel_win->height, + new_panel_win->width, + new_panel_win->y, + new_panel_win->x); + new_panel_win->win_separator = NULL; + if (new_panel_win->panel->separator) + { + switch (panel->position) + { + case GUI_PANEL_LEFT: + new_panel_win->win_separator = newwin (new_panel_win->height, + 1, + new_panel_win->y, + new_panel_win->x + new_panel_win->width); + break; + } + } + return 1; + } + else + return 0; +} + +/* + * gui_panel_window_free: delete a panel window + */ + +void +gui_panel_window_free (void *panel_win) +{ + t_gui_panel_window *ptr_panel_win; + + ptr_panel_win = (t_gui_panel_window *)panel_win; + + free (ptr_panel_win); +} + +/* + * gui_panel_redraw_buffer: redraw panels for windows displaying a buffer + */ + +void +gui_panel_redraw_buffer (t_gui_buffer *buffer) +{ + t_gui_window *ptr_win; + t_gui_panel_window *ptr_panel_win; + + if (!gui_ok) + return; + + for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) + { + if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0)) + { + for (ptr_panel_win = GUI_CURSES(ptr_win)->panel_windows; + ptr_panel_win; + ptr_panel_win = ptr_panel_win->next_panel_window) + { + switch (ptr_panel_win->panel->position) + { + case GUI_PANEL_LEFT: + break; + } + } + } + } +} diff --git a/weechat/src/gui/curses/gui-status.c b/weechat/src/gui/curses/gui-curses-status.c index 5da5bb6ec..a8cd59a4d 100644 --- a/weechat/src/gui/curses/gui-status.c +++ b/weechat/src/gui/curses/gui-curses-status.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-status.c: status display functions for Curses GUI */ +/* gui-curses-status.c: status display functions for Curses GUI */ #ifdef HAVE_CONFIG_H @@ -27,12 +27,6 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_NCURSESW_CURSES_H -#include <ncursesw/ncurses.h> -#else -#include <ncurses.h> -#endif - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" @@ -62,84 +56,84 @@ gui_status_draw (t_gui_buffer *buffer, int erase) for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { if (erase) - gui_window_curses_clear (ptr_win->win_status, COLOR_WIN_STATUS); + gui_window_curses_clear (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); /* display number of buffers */ - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - mvwprintw (ptr_win->win_status, 0, 0, "["); - gui_window_set_weechat_color (ptr_win->win_status, + mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, 0, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", (last_gui_buffer) ? last_gui_buffer->number : 0); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "] "); + wprintw (GUI_CURSES(ptr_win)->win_status, "] "); /* display "<servers>" or current server */ if (ptr_win->buffer->all_servers) { - wprintw (ptr_win->win_status, "["); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, _("<servers>")); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, _("<servers>")); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "] "); + wprintw (GUI_CURSES(ptr_win)->win_status, "] "); } else if (SERVER(ptr_win->buffer) && SERVER(ptr_win->buffer)->name) { - wprintw (ptr_win->win_status, "["); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%s", SERVER(ptr_win->buffer)->name); + wprintw (GUI_CURSES(ptr_win)->win_status, "%s", SERVER(ptr_win->buffer)->name); if (SERVER(ptr_win->buffer)->is_away) - wprintw (ptr_win->win_status, _("(away)")); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, _("(away)")); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "] "); + wprintw (GUI_CURSES(ptr_win)->win_status, "] "); } /* infos about current server buffer */ if (SERVER(ptr_win->buffer) && !CHANNEL(ptr_win->buffer)) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_win->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_CHANNEL); if (SERVER(ptr_win->buffer)->is_connected) - wprintw (ptr_win->win_status, "[%s] ", + wprintw (GUI_CURSES(ptr_win)->win_status, "[%s] ", SERVER(ptr_win->buffer)->name); else - wprintw (ptr_win->win_status, "(%s) ", + wprintw (GUI_CURSES(ptr_win)->win_status, "(%s) ", SERVER(ptr_win->buffer)->name); if (ptr_win->buffer->all_servers) { server_get_number_buffer (SERVER(ptr_win->buffer), &server_pos, &server_total); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "("); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "("); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", server_pos); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", server_pos); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "/"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "/"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", server_total); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", server_total); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ") "); + wprintw (GUI_CURSES(ptr_win)->win_status, ") "); } } @@ -147,14 +141,14 @@ gui_status_draw (t_gui_buffer *buffer, int erase) /* infos about current channel/pv buffer */ if (SERVER(ptr_win->buffer) && CHANNEL(ptr_win->buffer)) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_win->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_CHANNEL); if (((CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_PRIVATE) && (CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_DCC_CHAT) @@ -162,20 +156,20 @@ gui_status_draw (t_gui_buffer *buffer, int erase) || ((CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT) && (CHANNEL(ptr_win->buffer)->dcc_chat) && (((t_irc_dcc *)(CHANNEL(ptr_win->buffer)->dcc_chat))->sock < 0))) - wprintw (ptr_win->win_status, "(%s)", + wprintw (GUI_CURSES(ptr_win)->win_status, "(%s)", CHANNEL(ptr_win->buffer)->name); else - wprintw (ptr_win->win_status, "%s", + wprintw (GUI_CURSES(ptr_win)->win_status, "%s", CHANNEL(ptr_win->buffer)->name); if (ptr_win->buffer == CHANNEL(ptr_win->buffer)->buffer) { /* display channel modes */ if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_CHANNEL) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "("); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "("); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); i = 0; first_mode = 1; @@ -185,63 +179,63 @@ gui_status_draw (t_gui_buffer *buffer, int erase) { if (first_mode) { - wprintw (ptr_win->win_status, "+"); + wprintw (GUI_CURSES(ptr_win)->win_status, "+"); first_mode = 0; } - wprintw (ptr_win->win_status, "%c", + wprintw (GUI_CURSES(ptr_win)->win_status, "%c", CHANNEL(ptr_win->buffer)->modes[i]); } i++; } if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_KEY] != ' ') - wprintw (ptr_win->win_status, ",%s", + wprintw (GUI_CURSES(ptr_win)->win_status, ",%s", CHANNEL(ptr_win->buffer)->key); if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_LIMIT] != ' ') - wprintw (ptr_win->win_status, ",%d", + wprintw (GUI_CURSES(ptr_win)->win_status, ",%d", CHANNEL(ptr_win->buffer)->limit); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ")"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ")"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); } /* display DCC if private is DCC CHAT */ if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "("); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "("); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_CHANNEL); - wprintw (ptr_win->win_status, "DCC"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, "DCC"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ")"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ")"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); } } - wprintw (ptr_win->win_status, " "); + wprintw (GUI_CURSES(ptr_win)->win_status, " "); } if (!SERVER(ptr_win->buffer)) { - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%d", + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_win->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_CHANNEL); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_CHANNEL); switch (ptr_win->buffer->type) { case BUFFER_TYPE_STANDARD: - wprintw (ptr_win->win_status, _("[not connected] ")); + wprintw (GUI_CURSES(ptr_win)->win_status, _("[not connected] ")); break; case BUFFER_TYPE_DCC: - wprintw (ptr_win->win_status, "<DCC> "); + wprintw (GUI_CURSES(ptr_win)->win_status, "<DCC> "); break; case BUFFER_TYPE_RAW_DATA: - wprintw (ptr_win->win_status, _("<RAW_IRC> ")); + wprintw (GUI_CURSES(ptr_win)->win_status, _("<RAW_IRC> ")); break; } } @@ -249,11 +243,11 @@ gui_status_draw (t_gui_buffer *buffer, int erase) /* display list of other active windows (if any) with numbers */ if (hotlist) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "["); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, _("Act: ")); + wprintw (GUI_CURSES(ptr_win)->win_status, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); + wprintw (GUI_CURSES(ptr_win)->win_status, _("Act: ")); names_count = 0; for (ptr_hotlist = hotlist; ptr_hotlist; @@ -262,22 +256,22 @@ gui_status_draw (t_gui_buffer *buffer, int erase) switch (ptr_hotlist->priority) { case HOTLIST_LOW: - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DATA_OTHER); display_name = ((cfg_look_hotlist_names_level & 1) != 0); break; case HOTLIST_MSG: - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DATA_MSG); display_name = ((cfg_look_hotlist_names_level & 2) != 0); break; case HOTLIST_PRIVATE: - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DATA_PRIVATE); display_name = ((cfg_look_hotlist_names_level & 4) != 0); break; case HOTLIST_HIGHLIGHT: - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DATA_HIGHLIGHT); display_name = ((cfg_look_hotlist_names_level & 8) != 0); break; @@ -288,7 +282,7 @@ gui_status_draw (t_gui_buffer *buffer, int erase) switch (ptr_hotlist->buffer->type) { case BUFFER_TYPE_STANDARD: - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_hotlist->buffer->number); if (display_name && (cfg_look_hotlist_names_count != 0) @@ -296,54 +290,54 @@ gui_status_draw (t_gui_buffer *buffer, int erase) { names_count++; - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); if (cfg_look_hotlist_names_length == 0) snprintf (format, sizeof (format) - 1, "%%s"); else snprintf (format, sizeof (format) - 1, "%%.%ds", cfg_look_hotlist_names_length); if (BUFFER_IS_SERVER(ptr_hotlist->buffer)) - wprintw (ptr_win->win_status, format, + wprintw (GUI_CURSES(ptr_win)->win_status, format, (ptr_hotlist->server) ? ptr_hotlist->server->name : SERVER(ptr_hotlist->buffer)->name); else if (BUFFER_IS_CHANNEL(ptr_hotlist->buffer) || BUFFER_IS_PRIVATE(ptr_hotlist->buffer)) - wprintw (ptr_win->win_status, format, CHANNEL(ptr_hotlist->buffer)->name); + wprintw (GUI_CURSES(ptr_win)->win_status, format, CHANNEL(ptr_hotlist->buffer)->name); } break; case BUFFER_TYPE_DCC: - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_hotlist->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "DCC"); + wprintw (GUI_CURSES(ptr_win)->win_status, "DCC"); break; case BUFFER_TYPE_RAW_DATA: - wprintw (ptr_win->win_status, "%d", + wprintw (GUI_CURSES(ptr_win)->win_status, "%d", ptr_hotlist->buffer->number); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, ":"); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, ":"); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, _("RAW_IRC")); + wprintw (GUI_CURSES(ptr_win)->win_status, _("RAW_IRC")); break; } if (ptr_hotlist->next_hotlist) - wprintw (ptr_win->win_status, ","); + wprintw (GUI_CURSES(ptr_win)->win_status, ","); } - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "] "); + wprintw (GUI_CURSES(ptr_win)->win_status, "] "); } /* display lag */ @@ -351,15 +345,15 @@ gui_status_draw (t_gui_buffer *buffer, int erase) { if (SERVER(ptr_win->buffer)->lag / 1000 >= cfg_irc_lag_min_show) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "["); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, _("Lag: %.1f"), + wprintw (GUI_CURSES(ptr_win)->win_status, "["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); + wprintw (GUI_CURSES(ptr_win)->win_status, _("Lag: %.1f"), ((float)(SERVER(ptr_win->buffer)->lag)) / 1000); - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "]"); + wprintw (GUI_CURSES(ptr_win)->win_status, "]"); } } @@ -375,28 +369,28 @@ gui_status_draw (t_gui_buffer *buffer, int erase) x -= strlen (more) - 1; if (x < 0) x = 0; - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_MORE); if (ptr_win->scroll) - mvwprintw (ptr_win->win_status, 0, x, "%s", more); + mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, x, "%s", more); else { snprintf (format, sizeof (format) - 1, "%%-%ds", (int)(strlen (more))); - mvwprintw (ptr_win->win_status, 0, x, format, " "); + mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, x, format, " "); } if (BUFFER_HAS_NICKLIST(ptr_win->buffer)) { - gui_window_set_weechat_color (ptr_win->win_status, + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, " ["); - gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); - wprintw (ptr_win->win_status, "%s", str_nicks); - gui_window_set_weechat_color (ptr_win->win_status, + wprintw (GUI_CURSES(ptr_win)->win_status, " ["); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS); + wprintw (GUI_CURSES(ptr_win)->win_status, "%s", str_nicks); + gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "]"); + wprintw (GUI_CURSES(ptr_win)->win_status, "]"); } free (more); - wnoutrefresh (ptr_win->win_status); + wnoutrefresh (GUI_CURSES(ptr_win)->win_status); refresh (); } } diff --git a/weechat/src/gui/curses/gui-curses.h b/weechat/src/gui/curses/gui-curses.h index 27dcdd372..1e7eee7da 100644 --- a/weechat/src/gui/curses/gui-curses.h +++ b/weechat/src/gui/curses/gui-curses.h @@ -21,6 +21,12 @@ #ifndef __WEECHAT_GUI_CURSES_H #define __WEECHAT_GUI_CURSES_H 1 +#ifdef HAVE_NCURSESW_CURSES_H +#include <ncursesw/ncurses.h> +#else +#include <ncurses.h> +#endif + /* shift ncurses colors for compatibility with colors in IRC messages (same as other IRC clients) */ @@ -33,8 +39,39 @@ #define WEECHAT_COLOR_CYAN COLOR_YELLOW #define WEECHAT_COLOR_WHITE COLOR_WHITE +#define GUI_CURSES(window) ((t_gui_curses_objects *)(window->gui_objects)) + +typedef struct t_gui_panel_window t_gui_panel_window; + +struct t_gui_panel_window +{ + t_gui_panel *panel; /* pointer to panel */ + int x, y; /* position of window */ + int width, height; /* window size */ + WINDOW *win_panel; /* panel Curses window */ + WINDOW *win_separator; /* separator (optional) */ + t_gui_panel_window *next_panel_window; + /* link to next panel window */ + /* (only used if panel is in windows) */ +}; + +typedef struct t_gui_curses_objects t_gui_curses_objects; + +struct t_gui_curses_objects +{ + WINDOW *win_title; /* title window */ + WINDOW *win_chat; /* chat window (example: channel) */ + WINDOW *win_nick; /* nick window */ + WINDOW *win_status; /* status window */ + WINDOW *win_infobar; /* info bar window */ + WINDOW *win_input; /* input window */ + WINDOW *win_separator; /* separation between 2 splited (V) win */ + t_gui_panel_window *panel_windows; /* panel windows */ +}; + extern t_gui_color gui_weechat_colors[]; extern int gui_irc_colors[GUI_NUM_IRC_COLORS][2]; +extern int gui_refresh_screen_needed; /* color functions */ extern int gui_color_get_pair (int); @@ -54,4 +91,8 @@ extern void gui_window_refresh_screen_sigwinch (); extern void gui_window_set_title (); extern void gui_window_reset_title (); +/* panel functions */ +extern int gui_panel_get_size (t_gui_window *, int); +extern void gui_panel_redraw_buffer (t_gui_buffer *); + #endif /* gui-curses.h */ diff --git a/weechat/src/gui/gtk/Makefile.am b/weechat/src/gui/gtk/Makefile.am index 46b5667dd..d4e09550c 100644 --- a/weechat/src/gui/gtk/Makefile.am +++ b/weechat/src/gui/gtk/Makefile.am @@ -21,8 +21,8 @@ bin_PROGRAMS = weechat-gtk if PLUGINS weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \ - ../gui-window.o ../gui-keyboard.o \ - ../gui-action.o \ + ../gui-window.o ../gui-panel.o \ + ../gui-keyboard.o ../gui-action.o \ ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ ../../plugins/lib_weechat_plugins.a \ @@ -31,8 +31,8 @@ weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \ $(GNUTLS_LFLAGS) else weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \ - ../gui-window.o ../gui-keyboard.o \ - ../gui-action.o \ + ../gui-window.o ../gui-panel.o \ + ../gui-keyboard.o ../gui-action.o \ ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ $(PLUGINS_LIBS) \ @@ -40,13 +40,14 @@ weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \ $(GNUTLS_LFLAGS) endif -weechat_gtk_SOURCES = gui-chat.c \ - gui-color.c \ - gui-infobar.c \ - gui-input.c \ - gui-keyboard.c \ - gui-main.c \ - gui-nicklist.c \ - gui-status.c \ - gui-window.c \ +weechat_gtk_SOURCES = gui-gtk-chat.c \ + gui-gtk-color.c \ + gui-gtk-infobar.c \ + gui-gtk-input.c \ + gui-gtk-keyboard.c \ + gui-gtk-main.c \ + gui-gtk-nicklist.c \ + gui-gtk-status.c \ + gui-gtk-window.c \ + gui-gtk-panel.c \ gui-gtk.h diff --git a/src/gui/gtk/gui-chat.c b/weechat/src/gui/gtk/gui-gtk-chat.c index 6773bcd33..15ed9dc63 100644 --- a/src/gui/gtk/gui-chat.c +++ b/weechat/src/gui/gtk/gui-gtk-chat.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-chat.c: chat display functions for Gtk GUI */ +/* gui-gtk-chat.c: chat display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -28,8 +28,6 @@ #include <string.h> #include <ctype.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" @@ -619,11 +617,11 @@ gui_chat_draw_line (t_gui_buffer *buffer, t_gui_line *line) text_without_color = gui_color_decode ((unsigned char *)(line->data), 0); if (text_without_color) { - gtk_text_buffer_insert_at_cursor (ptr_win->textbuffer_chat, + gtk_text_buffer_insert_at_cursor (GUI_GTK(ptr_win)->textbuffer_chat, (char *)text_without_color, -1); - gtk_text_buffer_insert_at_cursor (ptr_win->textbuffer_chat, + gtk_text_buffer_insert_at_cursor (GUI_GTK(ptr_win)->textbuffer_chat, "\n", -1); - gtk_text_buffer_get_bounds (ptr_win->textbuffer_chat, + gtk_text_buffer_get_bounds (GUI_GTK(ptr_win)->textbuffer_chat, &start, &end); /* TODO */ /*gtk_text_buffer_apply_tag (ptr_win->textbuffer_chat, ptr_win->texttag_chat, &start, &end);*/ diff --git a/src/gui/gtk/gui-color.c b/weechat/src/gui/gtk/gui-gtk-color.c index 852a2af5b..3536e6649 100644 --- a/src/gui/gtk/gui-color.c +++ b/weechat/src/gui/gtk/gui-gtk-color.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-color.c: color functions for Gtk GUI */ +/* gui-gtk-color.c: color functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -28,8 +28,6 @@ #include <string.h> #include <ctype.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/weeconfig.h" diff --git a/weechat/src/gui/gtk/gui-infobar.c b/weechat/src/gui/gtk/gui-gtk-infobar.c index f90eb8209..76b26b9c7 100644 --- a/weechat/src/gui/gtk/gui-infobar.c +++ b/weechat/src/gui/gtk/gui-gtk-infobar.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-infobar.c: infobar display functions for Gtk GUI */ +/* gui-gtk-infobar.c: infobar display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -27,8 +27,6 @@ #include <stdlib.h> #include <string.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" diff --git a/weechat/src/gui/gtk/gui-input.c b/weechat/src/gui/gtk/gui-gtk-input.c index e38089c36..b3ba16fdb 100644 --- a/weechat/src/gui/gtk/gui-input.c +++ b/weechat/src/gui/gtk/gui-gtk-input.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-input: user input functions for Gtk GUI */ +/* gui-gtk-input: user input functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -26,8 +26,6 @@ #include <stdlib.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/utf8.h" diff --git a/weechat/src/gui/gtk/gui-gtk-keyboard.c b/weechat/src/gui/gtk/gui-gtk-keyboard.c new file mode 100644 index 000000000..6e0e36095 --- /dev/null +++ b/weechat/src/gui/gtk/gui-gtk-keyboard.c @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* gui-gtk-keyboard.c: keyboard functions for Gtk GUI */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <string.h> + +#include "../../common/weechat.h" +#include "../gui.h" +#include "../../common/utf8.h" +#include "gui-gtk.h" + +#ifdef PLUGINS +#include "../../plugins/plugins.h" +#endif + + +/* + * gui_keyboard_default_bindings: create default key bindings + */ + +void +gui_keyboard_default_bindings () +{ + int i; + char key_str[32], command[32]; + + /* keys binded with internal functions */ + gui_keyboard_bind ( /* RC */ "ctrl-M", "return"); + gui_keyboard_bind ( /* RC */ "ctrl-J", "return"); + gui_keyboard_bind ( /* tab */ "ctrl-I", "tab"); + gui_keyboard_bind ( /* basckp */ "ctrl-H", "backspace"); + gui_keyboard_bind ( /* basckp */ "ctrl-?", "backspace"); + gui_keyboard_bind ( /* del */ "meta2-3~", "delete"); + gui_keyboard_bind ( /* ^K */ "ctrl-K", "delete_end_line"); + gui_keyboard_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); + gui_keyboard_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); + gui_keyboard_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); + gui_keyboard_bind ( /* ^T */ "ctrl-T", "transpose_chars"); + gui_keyboard_bind ( /* home */ "meta2-1~", "home"); + gui_keyboard_bind ( /* home */ "meta2-H", "home"); + gui_keyboard_bind ( /* home */ "meta2-7~", "home"); + gui_keyboard_bind ( /* ^A */ "ctrl-A", "home"); + gui_keyboard_bind ( /* end */ "meta2-4~", "end"); + gui_keyboard_bind ( /* end */ "meta2-F", "end"); + gui_keyboard_bind ( /* end */ "meta2-8~", "end"); + gui_keyboard_bind ( /* ^E */ "ctrl-E", "end"); + gui_keyboard_bind ( /* left */ "meta2-D", "left"); + gui_keyboard_bind ( /* right */ "meta2-C", "right"); + gui_keyboard_bind ( /* up */ "meta2-A", "up"); + gui_keyboard_bind ( /* ^up */ "meta-Oa", "up_global"); + gui_keyboard_bind ( /* down */ "meta2-B", "down"); + gui_keyboard_bind ( /* ^down */ "meta-Ob", "down_global"); + gui_keyboard_bind ( /* pgup */ "meta2-5~", "page_up"); + gui_keyboard_bind ( /* pgdn */ "meta2-6~", "page_down"); + gui_keyboard_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up"); + gui_keyboard_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down"); + gui_keyboard_bind ( /* F10 */ "meta2-21~", "infobar_clear"); + gui_keyboard_bind ( /* F11 */ "meta2-23~", "nick_page_up"); + gui_keyboard_bind ( /* F12 */ "meta2-24~", "nick_page_down"); + gui_keyboard_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning"); + gui_keyboard_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end"); + gui_keyboard_bind ( /* ^L */ "ctrl-L", "refresh"); + gui_keyboard_bind ( /* m-a */ "meta-a", "jump_smart"); + gui_keyboard_bind ( /* m-b */ "meta-b", "previous_word"); + gui_keyboard_bind ( /* ^left */ "meta-Od", "previous_word"); + gui_keyboard_bind ( /* m-d */ "meta-d", "delete_next_word"); + gui_keyboard_bind ( /* m-f */ "meta-f", "next_word"); + gui_keyboard_bind ( /* ^right */ "meta-Oc", "next_word"); + gui_keyboard_bind ( /* m-h */ "meta-h", "hotlist_clear"); + gui_keyboard_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); + gui_keyboard_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); + gui_keyboard_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); + gui_keyboard_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); + gui_keyboard_bind ( /* m-k */ "meta-k", "grab_key"); + gui_keyboard_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); + gui_keyboard_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); + gui_keyboard_bind ( /* m-r */ "meta-r", "delete_line"); + gui_keyboard_bind ( /* m-s */ "meta-s", "switch_server"); + gui_keyboard_bind ( /* m-u */ "meta-u", "scroll_unread"); + + /* keys binded with commands */ + gui_keyboard_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); + gui_keyboard_bind ( /* F5 */ "meta2-15~", "/buffer -1"); + gui_keyboard_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); + gui_keyboard_bind ( /* F6 */ "meta2-17~", "/buffer +1"); + gui_keyboard_bind ( /* F7 */ "meta2-18~", "/window -1"); + gui_keyboard_bind ( /* F8 */ "meta2-19~", "/window +1"); + gui_keyboard_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); + gui_keyboard_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); + gui_keyboard_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); + gui_keyboard_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); + gui_keyboard_bind ( /* m-0 */ "meta-0", "/buffer 10"); + gui_keyboard_bind ( /* m-1 */ "meta-1", "/buffer 1"); + gui_keyboard_bind ( /* m-2 */ "meta-2", "/buffer 2"); + gui_keyboard_bind ( /* m-3 */ "meta-3", "/buffer 3"); + gui_keyboard_bind ( /* m-4 */ "meta-4", "/buffer 4"); + gui_keyboard_bind ( /* m-5 */ "meta-5", "/buffer 5"); + gui_keyboard_bind ( /* m-6 */ "meta-6", "/buffer 6"); + gui_keyboard_bind ( /* m-7 */ "meta-7", "/buffer 7"); + gui_keyboard_bind ( /* m-8 */ "meta-8", "/buffer 8"); + gui_keyboard_bind ( /* m-9 */ "meta-9", "/buffer 9"); + + /* bind meta-j + {01..99} to switch to buffers # > 10 */ + for (i = 1; i < 100; i++) + { + sprintf (key_str, "meta-j%02d", i); + sprintf (command, "/buffer %d", i); + gui_keyboard_bind (key_str, command); + } +} + +/* + * gui_keyboard_grab_end: insert grabbed key in input buffer + */ + +void +gui_keyboard_grab_end () +{ + char *expanded_key; + + /* get expanded name (for example: ^U => ctrl-u) */ + expanded_key = gui_keyboard_get_expanded_name (gui_key_buffer); + + if (expanded_key) + { + if (gui_current_window->buffer->has_input) + { + gui_insert_string_input (gui_current_window, expanded_key, -1); + gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key); + gui_input_draw (gui_current_window->buffer, 1); + } + free (expanded_key); + } + + /* end grab mode */ + gui_key_grab = 0; + gui_key_grab_count = 0; + gui_key_buffer[0] = '\0'; +} + +/* + * gui_keyboard_read: read keyboard chars + */ + +void +gui_keyboard_read () +{ + /* TODO: write this function for Gtk */ +} diff --git a/weechat/src/gui/gtk/gui-main.c b/weechat/src/gui/gtk/gui-gtk-main.c index 01dc67d65..8c349d07d 100644 --- a/weechat/src/gui/gtk/gui-main.c +++ b/weechat/src/gui/gtk/gui-gtk-main.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-main.c: main loop and keyboard management for Gtk GUI */ +/* gui-gtk-main.c: main loop for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -30,8 +30,6 @@ #include <string.h> #include <signal.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/fifo.h" @@ -58,7 +56,7 @@ GtkWidget *label1; /* - * gui_main_loop: main loop for WeeChat with ncurses GUI + * gui_main_loop: main loop for WeeChat with Gtk GUI */ void @@ -190,6 +188,10 @@ gui_main_end () if (gui_input_clipboard) free(gui_input_clipboard); + /* delete all panels */ + while (gui_panels) + gui_panel_free (gui_panels); + /* delete all windows */ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { diff --git a/src/gui/gtk/gui-nicklist.c b/weechat/src/gui/gtk/gui-gtk-nicklist.c index eebdc5b51..494ef2b46 100644 --- a/src/gui/gtk/gui-nicklist.c +++ b/weechat/src/gui/gtk/gui-gtk-nicklist.c @@ -17,15 +17,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-nicklist.c: nicklist display functions for Gtk GUI */ +/* gui-gtk-nicklist.c: nicklist display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/weeconfig.h" diff --git a/weechat/src/gui/gtk/gui-gtk-panel.c b/weechat/src/gui/gtk/gui-gtk-panel.c new file mode 100644 index 000000000..c90694cbe --- /dev/null +++ b/weechat/src/gui/gtk/gui-gtk-panel.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* gui-gtk-panel.c: panel functions for Gtk GUI */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> + +#include "../../common/weechat.h" +#include "../gui.h" +#include "gui-gtk.h" + + +/* + * gui_panel_window_new: create a new "window panel" for a panel, in screen or a window + * if window is not NULL, panel window will be in this window + */ + +int +gui_panel_window_new (t_gui_panel *panel, t_gui_window *window) +{ + /* TODO: write this function for Gtk */ + (void) panel; + (void) window; + + return 1; +} + +/* + * gui_panel_window_free: delete a panel window + */ + +void +gui_panel_window_free (void *panel_win) +{ + t_gui_panel_window *ptr_panel_win; + + ptr_panel_win = (t_gui_panel_window *)panel_win; + + free (ptr_panel_win); +} diff --git a/weechat/src/gui/gtk/gui-status.c b/weechat/src/gui/gtk/gui-gtk-status.c index 436f7b7f9..48b149da5 100644 --- a/weechat/src/gui/gtk/gui-status.c +++ b/weechat/src/gui/gtk/gui-gtk-status.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-status.c: status display functions for Gtk GUI */ +/* gui-gtk-status.c: status display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -27,8 +27,6 @@ #include <stdlib.h> #include <string.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" diff --git a/weechat/src/gui/gtk/gui-window.c b/weechat/src/gui/gtk/gui-gtk-window.c index 72791d6c6..427b2627e 100644 --- a/weechat/src/gui/gtk/gui-window.c +++ b/weechat/src/gui/gtk/gui-gtk-window.c @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/* gui-window.c: window display functions for Gtk GUI */ +/* gui-gtk-window.c: window display functions for Gtk GUI */ #ifdef HAVE_CONFIG_H @@ -27,8 +27,6 @@ #include <stdlib.h> #include <string.h> -#include <gtk/gtk.h> - #include "../../common/weechat.h" #include "../gui.h" #include "../../common/hotlist.h" @@ -37,6 +35,62 @@ /* + * gui_window_get_width: get screen width + */ + +int +gui_window_get_width () +{ + return 0; +} + +/* + * gui_window_get_height: get screen height + */ + +int +gui_window_get_height () +{ + return 0; +} + +/* + * gui_window_objects_init: init Gtk widgets + */ + +int +gui_window_objects_init (t_gui_window *window) +{ + t_gui_gtk_objects *new_objects; + + if ((new_objects = (t_gui_gtk_objects *) malloc (sizeof (t_gui_gtk_objects)))) + { + window->gui_objects = new_objects; + GUI_GTK(window)->textview_chat = NULL; + GUI_GTK(window)->textbuffer_chat = NULL; + GUI_GTK(window)->texttag_chat = NULL; + GUI_GTK(window)->textview_nicklist = NULL; + GUI_GTK(window)->textbuffer_nicklist = NULL; + GUI_GTK(window)->panel_windows = NULL; + return 1; + } + else + return 0; +} + +/* + * gui_window_objects_free: free Gtk widgets for a window + */ + +void +gui_window_objects_free (t_gui_window *window, int free_separator) +{ + /* TODO: write this function for Gtk */ + (void) window; + (void) free_separator; +} + +/* * gui_window_set_weechat_color: set WeeChat color for window */ @@ -98,25 +152,8 @@ gui_window_draw_separator (t_gui_window *window) void gui_window_redraw_buffer (t_gui_buffer *buffer) { - t_gui_window *ptr_win; - - if (!gui_ok) - return; - - for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) - { - if (ptr_win->buffer == buffer) - { - gui_chat_draw_title (buffer, 1); - gui_chat_draw (buffer, 1); - if (ptr_win->win_nick) - gui_nicklist_draw (buffer, 1); - gui_status_draw (buffer, 1); - if (cfg_look_infobar) - gui_infobar_draw (buffer, 1); - gui_input_draw (buffer, 1); - } - } + /* TODO: write this function for Gtk */ + (void) buffer; } /* @@ -142,32 +179,32 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer) window->win_nick_start = 0; gui_window_calculate_pos_size (window, 1); - if (!window->textview_chat) + if (!GUI_GTK(window)->textview_chat) { - window->textview_chat = gtk_text_view_new (); - gtk_widget_show (window->textview_chat); - gtk_container_add (GTK_CONTAINER (scrolledwindow_chat), window->textview_chat); - gtk_widget_set_size_request (window->textview_chat, 300, -1); - gtk_text_view_set_editable (GTK_TEXT_VIEW (window->textview_chat), FALSE); - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (window->textview_chat), FALSE); + GUI_GTK(window)->textview_chat = gtk_text_view_new (); + gtk_widget_show (GUI_GTK(window)->textview_chat); + gtk_container_add (GTK_CONTAINER (scrolledwindow_chat), GUI_GTK(window)->textview_chat); + gtk_widget_set_size_request (GUI_GTK(window)->textview_chat, 300, -1); + gtk_text_view_set_editable (GTK_TEXT_VIEW (GUI_GTK(window)->textview_chat), FALSE); + gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (GUI_GTK(window)->textview_chat), FALSE); - window->textbuffer_chat = gtk_text_buffer_new (NULL); - gtk_text_view_set_buffer (GTK_TEXT_VIEW (window->textview_chat), window->textbuffer_chat); + GUI_GTK(window)->textbuffer_chat = gtk_text_buffer_new (NULL); + gtk_text_view_set_buffer (GTK_TEXT_VIEW (GUI_GTK(window)->textview_chat), GUI_GTK(window)->textbuffer_chat); - /*window->texttag_chat = gtk_text_buffer_create_tag(window->textbuffer_chat, "courier", "font_family", "lucida");*/ - gtk_text_buffer_get_bounds (window->textbuffer_chat, &start, &end); - gtk_text_buffer_apply_tag (window->textbuffer_chat, window->texttag_chat, &start, &end); + /*GUI_GTK(window)->texttag_chat = gtk_text_buffer_create_tag(GUI_GTK(window)->textbuffer_chat, "courier", "font_family", "lucida");*/ + gtk_text_buffer_get_bounds (GUI_GTK(window)->textbuffer_chat, &start, &end); + gtk_text_buffer_apply_tag (GUI_GTK(window)->textbuffer_chat, GUI_GTK(window)->texttag_chat, &start, &end); } - if (BUFFER_IS_CHANNEL(buffer) && !window->textbuffer_nicklist) + if (BUFFER_IS_CHANNEL(buffer) && !GUI_GTK(window)->textbuffer_nicklist) { - window->textview_nicklist = gtk_text_view_new (); - gtk_widget_show (window->textview_nicklist); - gtk_container_add (GTK_CONTAINER (scrolledwindow_nick), window->textview_nicklist); - gtk_text_view_set_editable (GTK_TEXT_VIEW (window->textview_nicklist), FALSE); - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (window->textview_nicklist), FALSE); + GUI_GTK(window)->textview_nicklist = gtk_text_view_new (); + gtk_widget_show (GUI_GTK(window)->textview_nicklist); + gtk_container_add (GTK_CONTAINER (scrolledwindow_nick), GUI_GTK(window)->textview_nicklist); + gtk_text_view_set_editable (GTK_TEXT_VIEW (GUI_GTK(window)->textview_nicklist), FALSE); + gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (GUI_GTK(window)->textview_nicklist), FALSE); - window->textbuffer_nicklist = gtk_text_buffer_new (NULL); - gtk_text_view_set_buffer (GTK_TEXT_VIEW (window->textview_nicklist), window->textbuffer_nicklist); + GUI_GTK(window)->textbuffer_nicklist = gtk_text_buffer_new (NULL); + gtk_text_view_set_buffer (GTK_TEXT_VIEW (GUI_GTK(window)->textview_nicklist), GUI_GTK(window)->textbuffer_nicklist); } window->start_line = NULL; @@ -430,20 +467,6 @@ gui_window_nick_page_down (t_gui_window *window) } /* - * gui_window_init_subwindows: init subwindows for a WeeChat window - */ - -void -gui_window_init_subwindows (t_gui_window *window) -{ - window->textview_chat = NULL; - window->textbuffer_chat = NULL; - window->texttag_chat = NULL; - window->textview_nicklist = NULL; - window->textbuffer_nicklist = NULL; -} - -/* * gui_window_auto_resize: auto-resize all windows, according to % of global size * This function is called after a terminal resize. * Returns 0 if ok, -1 if all window should be merged @@ -845,3 +868,18 @@ gui_window_reset_title () { /* This function does nothing in Gtk GUI */ } + +/* + * gui_window_objects_print_log: print Gtk objects infos in log + * (usually for crash dump) + */ + +void +gui_window_objects_print_log (t_gui_window *window) +{ + weechat_log_printf (" textview_chat . . . : 0x%X\n", GUI_GTK(window)->textview_chat); + weechat_log_printf (" textbuffer_chat . . : 0x%X\n", GUI_GTK(window)->textbuffer_chat); + weechat_log_printf (" texttag_chat. . . . : 0x%X\n", GUI_GTK(window)->texttag_chat); + weechat_log_printf (" textview_nicklist . : 0x%X\n", GUI_GTK(window)->textview_nicklist); + weechat_log_printf (" textbuffer_nicklist : 0x%X\n", GUI_GTK(window)->textbuffer_nicklist); +} diff --git a/weechat/src/gui/gtk/gui-gtk.h b/weechat/src/gui/gtk/gui-gtk.h index c8a44108f..9bfb18151 100644 --- a/weechat/src/gui/gtk/gui-gtk.h +++ b/weechat/src/gui/gtk/gui-gtk.h @@ -21,6 +21,8 @@ #ifndef __WEECHAT_GUI_GTK_H #define __WEECHAT_GUI_GTK_H 1 +#include <gtk/gtk.h> + /* TODO: remove these temporary defines */ #define A_BOLD 1 @@ -48,6 +50,29 @@ #define WEECHAT_COLOR_CYAN COLOR_YELLOW #define WEECHAT_COLOR_WHITE COLOR_WHITE +#define GUI_GTK(window) ((t_gui_gtk_objects *)(window->gui_objects)) + +typedef struct t_gui_panel_window t_gui_panel_window; + +struct t_gui_panel_window +{ + t_gui_panel *panel; /* pointer to panel */ + int x, y; /* position of window */ + int width, height; /* window size */ +}; + +typedef struct t_gui_gtk_objects t_gui_gtk_objects; + +struct t_gui_gtk_objects +{ + GtkWidget *textview_chat; /* textview widget for chat */ + GtkTextBuffer *textbuffer_chat; /* textbuffer widget for chat */ + GtkTextTag *texttag_chat; /* texttag widget for chat */ + GtkWidget *textview_nicklist; /* textview widget for nicklist */ + GtkTextBuffer *textbuffer_nicklist; /* textbuffer widget for nicklist */ + t_gui_panel_window *panel_windows; /* panel windows */ +}; + extern t_gui_color gui_weechat_colors[]; extern int gui_irc_colors[GUI_NUM_IRC_COLORS][2]; diff --git a/weechat/src/gui/gtk/gui-keyboard.c b/weechat/src/gui/gtk/gui-keyboard.c deleted file mode 100644 index 508a055eb..000000000 --- a/weechat/src/gui/gtk/gui-keyboard.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> - * See README for License detail, AUTHORS for developers list. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* gui-keyboard.c: keyboard functions for Gtk GUI */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdlib.h> -#include <string.h> - -#include <gtk/gtk.h> - -#include "../../common/weechat.h" -#include "../gui.h" -#include "../../common/utf8.h" - -#ifdef PLUGINS -#include "../../plugins/plugins.h" -#endif - - -/* - * gui_keyboard_default_bindings: create default key bindings - */ - -void -gui_keyboard_default_bindings () -{ - int i; - char key_str[32], command[32]; - - /* keys binded with internal functions */ - gui_key_bind ( /* RC */ "ctrl-M", "return"); - gui_key_bind ( /* RC */ "ctrl-J", "return"); - gui_key_bind ( /* tab */ "ctrl-I", "tab"); - gui_key_bind ( /* basckp */ "ctrl-H", "backspace"); - gui_key_bind ( /* basckp */ "ctrl-?", "backspace"); - gui_key_bind ( /* del */ "meta2-3~", "delete"); - gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line"); - gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); - gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); - gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); - gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars"); - gui_key_bind ( /* home */ "meta2-1~", "home"); - gui_key_bind ( /* home */ "meta2-H", "home"); - gui_key_bind ( /* home */ "meta2-7~", "home"); - gui_key_bind ( /* ^A */ "ctrl-A", "home"); - gui_key_bind ( /* end */ "meta2-4~", "end"); - gui_key_bind ( /* end */ "meta2-F", "end"); - gui_key_bind ( /* end */ "meta2-8~", "end"); - gui_key_bind ( /* ^E */ "ctrl-E", "end"); - gui_key_bind ( /* left */ "meta2-D", "left"); - gui_key_bind ( /* right */ "meta2-C", "right"); - gui_key_bind ( /* up */ "meta2-A", "up"); - gui_key_bind ( /* ^up */ "meta-Oa", "up_global"); - gui_key_bind ( /* down */ "meta2-B", "down"); - gui_key_bind ( /* ^down */ "meta-Ob", "down_global"); - gui_key_bind ( /* pgup */ "meta2-5~", "page_up"); - gui_key_bind ( /* pgdn */ "meta2-6~", "page_down"); - gui_key_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up"); - gui_key_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down"); - gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear"); - gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up"); - gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down"); - gui_key_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning"); - gui_key_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end"); - gui_key_bind ( /* ^L */ "ctrl-L", "refresh"); - gui_key_bind ( /* m-a */ "meta-a", "jump_smart"); - gui_key_bind ( /* m-b */ "meta-b", "previous_word"); - gui_key_bind ( /* ^left */ "meta-Od", "previous_word"); - gui_key_bind ( /* m-d */ "meta-d", "delete_next_word"); - gui_key_bind ( /* m-f */ "meta-f", "next_word"); - gui_key_bind ( /* ^right */ "meta-Oc", "next_word"); - gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear"); - gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); - gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); - gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); - gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); - gui_key_bind ( /* m-k */ "meta-k", "grab_key"); - gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); - gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); - gui_key_bind ( /* m-r */ "meta-r", "delete_line"); - gui_key_bind ( /* m-s */ "meta-s", "switch_server"); - gui_key_bind ( /* m-u */ "meta-u", "scroll_unread"); - - /* keys binded with commands */ - gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); - gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1"); - gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); - gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1"); - gui_key_bind ( /* F7 */ "meta2-18~", "/window -1"); - gui_key_bind ( /* F8 */ "meta2-19~", "/window +1"); - gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); - gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); - gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); - gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); - gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10"); - gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1"); - gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2"); - gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3"); - gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4"); - gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5"); - gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6"); - gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7"); - gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8"); - gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9"); - - /* bind meta-j + {01..99} to switch to buffers # > 10 */ - for (i = 1; i < 100; i++) - { - sprintf (key_str, "meta-j%02d", i); - sprintf (command, "/buffer %d", i); - gui_key_bind (key_str, command); - } -} - -/* - * gui_keyboard_grab_end: insert grabbed key in input buffer - */ - -void -gui_keyboard_grab_end () -{ - char *expanded_key; - - /* get expanded name (for example: ^U => ctrl-u) */ - expanded_key = gui_key_get_expanded_name (gui_key_buffer); - - if (expanded_key) - { - if (gui_current_window->buffer->has_input) - { - gui_insert_string_input (gui_current_window, expanded_key, -1); - gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key); - gui_input_draw (gui_current_window->buffer, 1); - } - free (expanded_key); - } - - /* end grab mode */ - gui_key_grab = 0; - gui_key_grab_count = 0; - gui_key_buffer[0] = '\0'; -} - -/* - * gui_keyboard_read: read keyboard chars - */ - -void -gui_keyboard_read () -{ - /* TODO: write this function for Gtk */ -} diff --git a/weechat/src/gui/gui-action.c b/weechat/src/gui/gui-action.c index bbdd41cc7..b23d26354 100644 --- a/weechat/src/gui/gui-action.c +++ b/weechat/src/gui/gui-action.c @@ -622,7 +622,7 @@ gui_action_previous_word (t_gui_window *window) } /* - * gui_action_right: move to previous char + * gui_action_right: move to next char */ void @@ -1293,5 +1293,5 @@ void gui_action_grab_key (t_gui_window *window) { if (window->buffer->has_input) - gui_key_init_grab (); + gui_keyboard_init_grab (); } diff --git a/weechat/src/gui/gui-buffer.c b/weechat/src/gui/gui-buffer.c index c57207384..a3fdefd30 100644 --- a/weechat/src/gui/gui-buffer.c +++ b/weechat/src/gui/gui-buffer.c @@ -44,6 +44,13 @@ #include "../irc/irc.h" +t_gui_buffer *gui_buffers = NULL; /* pointer to first buffer */ +t_gui_buffer *last_gui_buffer = NULL; /* pointer to last buffer */ +t_gui_buffer *gui_buffer_before_dcc = NULL; /* buffer before dcc switch */ +t_gui_buffer *gui_buffer_raw_data = NULL; /* buffer with raw IRC data */ +t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buffer before raw switch*/ + + /* * gui_buffer_servers_search: search servers buffer * (when same buffer is used for all servers) @@ -140,7 +147,6 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int type, window->start_line = NULL; window->start_line_pos = 0; gui_window_calculate_pos_size (window, 1); - gui_window_init_subwindows (window); } /* init lines */ diff --git a/weechat/src/gui/gui-buffer.h b/weechat/src/gui/gui-buffer.h new file mode 100644 index 000000000..518ae1045 --- /dev/null +++ b/weechat/src/gui/gui-buffer.h @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_BUFFER_H +#define __WEECHAT_GUI_BUFFER_H 1 + +#include "../common/completion.h" +#include "../common/history.h" + +#define BUFFER_TYPE_STANDARD 0 +#define BUFFER_TYPE_DCC 1 +#define BUFFER_TYPE_RAW_DATA 2 + +#define SERVER(buffer) ((t_irc_server *)(buffer->server)) +#define CHANNEL(buffer) ((t_irc_channel *)(buffer->channel)) + +#define BUFFER_IS_SERVER(buffer) ((SERVER(buffer) || (buffer->all_servers)) && !CHANNEL(buffer)) +#define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHANNEL_TYPE_CHANNEL)) +#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && \ + ((CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE) \ + || (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT))) + +#define BUFFER_HAS_NICKLIST(buffer) (BUFFER_IS_CHANNEL(buffer)) + +#define MSG_TYPE_TIME 1 +#define MSG_TYPE_PREFIX 2 +#define MSG_TYPE_NICK 4 +#define MSG_TYPE_INFO 8 +#define MSG_TYPE_MSG 16 +#define MSG_TYPE_HIGHLIGHT 32 +#define MSG_TYPE_NOLOG 64 + +#define NOTIFY_LEVEL_MIN 0 +#define NOTIFY_LEVEL_MAX 3 +#define NOTIFY_LEVEL_DEFAULT NOTIFY_LEVEL_MAX + +/* buffer structures */ + +typedef struct t_gui_line t_gui_line; + +struct t_gui_line +{ + int length; /* length of the line (in char) */ + int length_align; /* alignment length (time or time/nick) */ + int log_write; /* = 1 if line will be written to log */ + int line_with_message; /* line contains a message from a user? */ + int line_with_highlight; /* line contains highlight */ + char *nick; /* nickname for line (may be NULL) */ + char *data; /* line content */ + int ofs_after_date; /* offset to first char after date */ + int ofs_start_message; /* offset to first char after date/nick */ + t_gui_line *prev_line; /* link to previous line */ + t_gui_line *next_line; /* link to next line */ +}; + +typedef struct t_gui_buffer t_gui_buffer; + +struct t_gui_buffer +{ + int num_displayed; /* number of windows displaying buffer */ + + int number; /* buffer number (for jump/switch) */ + + /* server/channel */ + void *server; /* buffer's server */ + int all_servers; /* =1 if all servers are displayed here */ + void *channel; /* buffer's channel */ + int type; /* type: standard (server/channel/pv), */ + /* dcc or raw data */ + + /* chat content (lines, line is composed by many messages) */ + t_gui_line *lines; /* lines of chat window */ + t_gui_line *last_line; /* last line of chat window */ + t_gui_line *last_read_line; /* last read line before jump */ + int num_lines; /* number of lines in the window */ + int line_complete; /* current line complete ? (\n ending) */ + + /* notify level: when activity should be displayed? default: 3 (always) */ + int notify_level; /* 0 = never */ + /* 1 = highlight only */ + /* 2 = highlight + message */ + /* 3 = highlight + message + join/part */ + + /* file to save buffer content */ + char *log_filename; /* filename for saving buffer content */ + FILE *log_file; /* for logging buffer to file */ + + /* inupt buffer */ + int has_input; /* = 1 if buffer has input (DCC has not)*/ + char *input_buffer; /* input buffer */ + char *input_buffer_color_mask; /* color mask for input buffer */ + int input_buffer_alloc; /* input buffer: allocated size in mem */ + int input_buffer_size; /* buffer size in bytes */ + int input_buffer_length; /* number of chars in buffer */ + int input_buffer_pos; /* position into buffer */ + int input_buffer_1st_display; /* first char displayed on screen */ + + /* completion */ + t_completion completion; /* for cmds/nicks completion */ + + /* history */ + t_history *history; /* commands history */ + t_history *last_history; /* last command in history */ + t_history *ptr_history; /* current command in history */ + int num_history; /* number of commands in history */ + + /* link to previous/next buffer */ + t_gui_buffer *prev_buffer; /* link to previous buffer */ + t_gui_buffer *next_buffer; /* link to next buffer */ +}; + +/* buffer variables */ + +extern t_gui_buffer *gui_buffers; +extern t_gui_buffer *last_gui_buffer; +extern t_gui_buffer *gui_buffer_before_dcc; +extern t_gui_buffer *gui_buffer_raw_data; +extern t_gui_buffer *gui_buffer_before_raw_data; + +#endif /* gui-buffer.h */ diff --git a/weechat/src/gui/gui-color.h b/weechat/src/gui/gui-color.h new file mode 100644 index 000000000..a9763e538 --- /dev/null +++ b/weechat/src/gui/gui-color.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_COLOR_H +#define __WEECHAT_GUI_COLOR_H 1 + +#define INPUT_BUFFER_BLOCK_SIZE 256 + +#define COLOR_WIN_NICK_NUMBER 10 + +typedef enum t_weechat_color t_weechat_color; + +enum t_weechat_color +{ + COLOR_WIN_SEPARATOR = 0, + COLOR_WIN_TITLE, + COLOR_WIN_CHAT, + COLOR_WIN_CHAT_TIME, + COLOR_WIN_CHAT_TIME_SEP, + COLOR_WIN_CHAT_PREFIX1, + COLOR_WIN_CHAT_PREFIX2, + COLOR_WIN_CHAT_SERVER, + COLOR_WIN_CHAT_JOIN, + COLOR_WIN_CHAT_PART, + COLOR_WIN_CHAT_NICK, + COLOR_WIN_CHAT_HOST, + COLOR_WIN_CHAT_CHANNEL, + COLOR_WIN_CHAT_DARK, + COLOR_WIN_CHAT_HIGHLIGHT, + COLOR_WIN_CHAT_READ_MARKER, + COLOR_WIN_STATUS, + COLOR_WIN_STATUS_DELIMITERS, + COLOR_WIN_STATUS_CHANNEL, + COLOR_WIN_STATUS_DATA_MSG, + COLOR_WIN_STATUS_DATA_PRIVATE, + COLOR_WIN_STATUS_DATA_HIGHLIGHT, + COLOR_WIN_STATUS_DATA_OTHER, + COLOR_WIN_STATUS_MORE, + COLOR_WIN_INFOBAR, + COLOR_WIN_INFOBAR_DELIMITERS, + COLOR_WIN_INFOBAR_HIGHLIGHT, + COLOR_WIN_INPUT, + COLOR_WIN_INPUT_CHANNEL, + COLOR_WIN_INPUT_NICK, + COLOR_WIN_INPUT_DELIMITERS, + COLOR_WIN_NICK, + COLOR_WIN_NICK_AWAY, + COLOR_WIN_NICK_CHANOWNER, + COLOR_WIN_NICK_CHANADMIN, + COLOR_WIN_NICK_OP, + COLOR_WIN_NICK_HALFOP, + COLOR_WIN_NICK_VOICE, + COLOR_WIN_NICK_MORE, + COLOR_WIN_NICK_SEP, + COLOR_WIN_NICK_SELF, + COLOR_WIN_NICK_PRIVATE, + COLOR_WIN_NICK_1, + COLOR_WIN_NICK_2, + COLOR_WIN_NICK_3, + COLOR_WIN_NICK_4, + COLOR_WIN_NICK_5, + COLOR_WIN_NICK_6, + COLOR_WIN_NICK_7, + COLOR_WIN_NICK_8, + COLOR_WIN_NICK_9, + COLOR_WIN_NICK_10, + COLOR_DCC_SELECTED, + COLOR_DCC_WAITING, + COLOR_DCC_CONNECTING, + COLOR_DCC_ACTIVE, + COLOR_DCC_DONE, + COLOR_DCC_FAILED, + COLOR_DCC_ABORTED, + COLOR_WIN_INPUT_SERVER, + GUI_NUM_COLORS +}; + +#define GUI_NUM_IRC_COLORS 16 + +/* attributes in IRC messages for color & style (bold, ..) */ + +#define GUI_ATTR_BOLD_CHAR '\x02' +#define GUI_ATTR_BOLD_STR "\x02" +#define GUI_ATTR_COLOR_CHAR '\x03' +#define GUI_ATTR_COLOR_STR "\x03" +#define GUI_ATTR_RESET_CHAR '\x0F' +#define GUI_ATTR_RESET_STR "\x0F" +#define GUI_ATTR_FIXED_CHAR '\x11' +#define GUI_ATTR_FIXED_STR "\x11" +#define GUI_ATTR_REVERSE_CHAR '\x12' +#define GUI_ATTR_REVERSE_STR "\x12" +#define GUI_ATTR_REVERSE2_CHAR '\x16' +#define GUI_ATTR_REVERSE2_STR "\x16" +#define GUI_ATTR_ITALIC_CHAR '\x1D' +#define GUI_ATTR_ITALIC_STR "\x1D" +#define GUI_ATTR_UNDERLINE_CHAR '\x1F' +#define GUI_ATTR_UNDERLINE_STR "\x1F" + +/* WeeChat internal attributes (should never be in IRC messages) */ + +#define GUI_ATTR_WEECHAT_COLOR_CHAR '\x19' +#define GUI_ATTR_WEECHAT_COLOR_STR "\x19" +#define GUI_ATTR_WEECHAT_SET_CHAR '\x1A' +#define GUI_ATTR_WEECHAT_SET_STR "\x1A" +#define GUI_ATTR_WEECHAT_REMOVE_CHAR '\x1B' +#define GUI_ATTR_WEECHAT_REMOVE_STR "\x1B" + +#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "") +#define GUI_NO_COLOR GUI_ATTR_RESET_STR + +/* color structure */ + +typedef struct t_gui_color t_gui_color; + +struct t_gui_color +{ + int foreground; /* foreground color */ + int background; /* background color */ + int attributes; /* attributes (bold, ..) */ + char *string; /* WeeChat color: "\x19??", ?? is #color*/ +}; + +/* color variables */ + +extern t_gui_color *gui_color[GUI_NUM_COLORS]; + +#endif /* gui-color.h */ diff --git a/weechat/src/gui/gui-common.c b/weechat/src/gui/gui-common.c index 12fb81d4c..300848222 100644 --- a/weechat/src/gui/gui-common.c +++ b/weechat/src/gui/gui-common.c @@ -50,17 +50,6 @@ int gui_ok = 0; /* = 1 if GUI is ok */ int gui_add_hotlist = 1; /* 0 is for temporarly disable */ /* hotlist add for all buffers */ -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_window_tree *gui_windows_tree = NULL; /* pointer to windows tree */ - -t_gui_buffer *gui_buffers = NULL; /* pointer to first buffer */ -t_gui_buffer *last_gui_buffer = NULL; /* pointer to last buffer */ -t_gui_buffer *gui_buffer_before_dcc = NULL; /* buffer before dcc switch */ -t_gui_buffer *gui_buffer_raw_data = NULL; /* buffer with raw IRC data */ -t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buffer before raw switch*/ t_gui_infobar *gui_infobar; /* pointer to infobar content */ char *gui_input_clipboard = NULL; /* clipboard content */ diff --git a/weechat/src/gui/gui-keyboard.c b/weechat/src/gui/gui-keyboard.c index 94662b956..d32bfda51 100644 --- a/weechat/src/gui/gui-keyboard.c +++ b/weechat/src/gui/gui-keyboard.c @@ -140,11 +140,11 @@ t_gui_key_function gui_key_functions[] = /* - * gui_key_init: init keyboard (create default key bindings) + * gui_keyboard_init: init keyboard (create default key bindings) */ void -gui_key_init () +gui_keyboard_init () { gui_key_buffer[0] = '\0'; gui_key_grab = 0; @@ -154,23 +154,23 @@ gui_key_init () } /* - * gui_key_init_show: init "show mode" + * gui_keyboard_init_show: init "show mode" */ void -gui_key_init_grab () +gui_keyboard_init_grab () { gui_key_grab = 1; gui_key_grab_count = 0; } /* - * gui_key_get_internal_code: get internal code from user key name - * for example: return "^R" for "ctrl-R" + * gui_keyboard_get_internal_code: get internal code from user key name + * for example: return "^R" for "ctrl-R" */ char * -gui_key_get_internal_code (char *key) +gui_keyboard_get_internal_code (char *key) { char *result; @@ -208,12 +208,12 @@ gui_key_get_internal_code (char *key) } /* - * gui_key_get_expanded_name: get expanded name from internal key code - * for example: return "ctrl-R" for "^R" + * gui_keyboard_get_expanded_name: get expanded name from internal key code + * for example: return "ctrl-R" for "^R" */ char * -gui_key_get_expanded_name (char *key) +gui_keyboard_get_expanded_name (char *key) { char *result; @@ -251,11 +251,11 @@ gui_key_get_expanded_name (char *key) } /* - * gui_key_find_pos: find position for a key (for sorting keys list) + * gui_keyboard_find_pos: find position for a key (for sorting keys list) */ t_gui_key * -gui_key_find_pos (t_gui_key *key) +gui_keyboard_find_pos (t_gui_key *key) { t_gui_key *ptr_key; @@ -268,17 +268,17 @@ gui_key_find_pos (t_gui_key *key) } /* - * gui_key_insert_sorted: insert key into sorted list + * gui_keyboard_insert_sorted: insert key into sorted list */ void -gui_key_insert_sorted (t_gui_key *key) +gui_keyboard_insert_sorted (t_gui_key *key) { t_gui_key *pos_key; if (gui_keys) { - pos_key = gui_key_find_pos (key); + pos_key = gui_keyboard_find_pos (key); if (pos_key) { @@ -310,24 +310,24 @@ gui_key_insert_sorted (t_gui_key *key) } /* - * gui_key_new: add a new key in keys list + * gui_keyboard_new: add a new key in keys list */ t_gui_key * -gui_key_new (char *key, char *command, void *function) +gui_keyboard_new (char *key, char *command, void *function) { t_gui_key *new_key; char *internal_code; if ((new_key = (t_gui_key *) malloc (sizeof (t_gui_key)))) { - internal_code = gui_key_get_internal_code (key); + internal_code = gui_keyboard_get_internal_code (key); new_key->key = (internal_code) ? strdup (internal_code) : strdup (key); if (internal_code) free (internal_code); new_key->command = (command) ? strdup (command) : NULL; new_key->function = function; - gui_key_insert_sorted (new_key); + gui_keyboard_insert_sorted (new_key); } else return NULL; @@ -336,11 +336,11 @@ gui_key_new (char *key, char *command, void *function) } /* - * gui_key_search: search a key + * gui_keyboard_search: search a key */ t_gui_key * -gui_key_search (char *key) +gui_keyboard_search (char *key) { t_gui_key *ptr_key; @@ -355,11 +355,11 @@ gui_key_search (char *key) } /* - * gui_key_cmp: compares 2 keys + * gui_keyboard_cmp: compares 2 keys */ int -gui_key_cmp (char *key, char *search) +gui_keyboard_cmp (char *key, char *search) { while (search[0]) { @@ -373,17 +373,17 @@ gui_key_cmp (char *key, char *search) } /* - * gui_key_search_part: search a key (maybe part of string) + * gui_keyboard_search_part: search a key (maybe part of string) */ t_gui_key * -gui_key_search_part (char *key) +gui_keyboard_search_part (char *key) { t_gui_key *ptr_key; for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key) { - if (gui_key_cmp (ptr_key->key, key) == 0) + if (gui_keyboard_cmp (ptr_key->key, key) == 0) return ptr_key; } @@ -392,11 +392,11 @@ gui_key_search_part (char *key) } /* - * gui_key_function_search_by_name: search a function by name + * gui_keyboard_function_search_by_name: search a function by name */ void * -gui_key_function_search_by_name (char *name) +gui_keyboard_function_search_by_name (char *name) { int i; @@ -413,11 +413,11 @@ gui_key_function_search_by_name (char *name) } /* - * gui_key_function_search_by_ptr: search a function by pointer + * gui_keyboard_function_search_by_ptr: search a function by pointer */ char * -gui_key_function_search_by_ptr (void *function) +gui_keyboard_function_search_by_ptr (void *function) { int i; @@ -434,11 +434,11 @@ gui_key_function_search_by_ptr (void *function) } /* - * gui_key_bind: bind a key to a function (command or special function) + * gui_keyboard_bind: bind a key to a function (command or special function) */ t_gui_key * -gui_key_bind (char *key, char *command) +gui_keyboard_bind (char *key, char *command) { t_gui_key_function *ptr_function; t_gui_key *new_key; @@ -453,7 +453,7 @@ gui_key_bind (char *key, char *command) ptr_function = NULL; if (command[0] != '/') { - ptr_function = gui_key_function_search_by_name (command); + ptr_function = gui_keyboard_function_search_by_name (command); if (!ptr_function) { weechat_log_printf (_("%s unable to bind key \"%s\" (invalid function name: \"%s\")\n"), @@ -462,11 +462,11 @@ gui_key_bind (char *key, char *command) } } - gui_key_unbind (key); + gui_keyboard_unbind (key); - new_key = gui_key_new (key, - (ptr_function) ? NULL : command, - ptr_function); + new_key = gui_keyboard_new (key, + (ptr_function) ? NULL : command, + ptr_function); if (!new_key) { weechat_log_printf (_("%s not enough memory for key binding\n"), @@ -478,20 +478,20 @@ gui_key_bind (char *key, char *command) } /* - * gui_key_unbind: remove a key binding + * gui_keyboard_unbind: remove a key binding */ int -gui_key_unbind (char *key) +gui_keyboard_unbind (char *key) { t_gui_key *ptr_key; char *internal_code; - internal_code = gui_key_get_internal_code (key); + internal_code = gui_keyboard_get_internal_code (key); - ptr_key = gui_key_search ((internal_code) ? internal_code : key); + ptr_key = gui_keyboard_search ((internal_code) ? internal_code : key); if (ptr_key) - gui_key_free (ptr_key); + gui_keyboard_free (ptr_key); if (internal_code) free (internal_code); @@ -500,13 +500,13 @@ gui_key_unbind (char *key) } /* - * gui_key_pressed: treat new key pressed - * return: 1 if key should be added to input buffer - * 0 otherwise + * gui_keyboard_pressed: treat new key pressed + * return: 1 if key should be added to input buffer + * 0 otherwise */ int -gui_key_pressed (char *key_str) +gui_keyboard_pressed (char *key_str) { int first_key; t_gui_key *ptr_key; @@ -524,7 +524,7 @@ gui_key_pressed (char *key_str) } /* look for key combo in key table */ - ptr_key = gui_key_search_part (gui_key_buffer); + ptr_key = gui_keyboard_search_part (gui_key_buffer); if (ptr_key) { if (ascii_strcasecmp (ptr_key->key, gui_key_buffer) == 0) @@ -543,7 +543,7 @@ gui_key_pressed (char *key_str) #ifdef PLUGINS (void) plugin_keyboard_handler_exec ( (ptr_key->command) ? - ptr_key->command : gui_key_function_search_by_ptr (ptr_key->function), + ptr_key->command : gui_keyboard_function_search_by_ptr (ptr_key->function), buffer_before_key, gui_current_window->buffer->input_buffer); #endif @@ -561,11 +561,11 @@ gui_key_pressed (char *key_str) } /* - * key_free: delete a key binding + * gui_keyboard_free: delete a key binding */ void -gui_key_free (t_gui_key *key) +gui_keyboard_free (t_gui_key *key) { /* free memory */ if (key->key) @@ -587,12 +587,12 @@ gui_key_free (t_gui_key *key) } /* - * gui_key_free_all: delete all key bindings + * gui_keyboard_free_all: delete all key bindings */ void -gui_key_free_all () +gui_keyboard_free_all () { while (gui_keys) - gui_key_free (gui_keys); + gui_keyboard_free (gui_keys); } diff --git a/weechat/src/gui/gui-keyboard.h b/weechat/src/gui/gui-keyboard.h new file mode 100644 index 000000000..20e78bf7b --- /dev/null +++ b/weechat/src/gui/gui-keyboard.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_KEY_H +#define __WEECHAT_GUI_KEY_H 1 + +#define KEY_SHOW_MODE_DISPLAY 1 +#define KEY_SHOW_MODE_BIND 2 + +/* key structures */ + +typedef struct t_gui_key t_gui_key; + +struct t_gui_key +{ + char *key; /* key combo (ex: a, ^W, ^W^C, meta-a) */ + char *command; /* associated command (may be NULL) */ + void (*function)(t_gui_window *); + /* associated function (if cmd is NULL) */ + t_gui_key *prev_key; /* link to previous key */ + t_gui_key *next_key; /* link to next key */ +}; + +typedef struct t_gui_key_function t_gui_key_function; + +struct t_gui_key_function +{ + char *function_name; /* name of function */ + void (*function)(); /* associated function */ + char *description; /* description of function */ +}; + +/* key variables */ + +extern t_gui_key *gui_keys; +extern t_gui_key *last_gui_key; +extern t_gui_key_function gui_key_functions[]; +extern char gui_key_buffer[128]; +extern int gui_key_grab; +extern int gui_key_grab_count; + +#endif /* gui-key.h */ diff --git a/weechat/src/gui/gui-panel.c b/weechat/src/gui/gui-panel.c new file mode 100644 index 000000000..9b5f76519 --- /dev/null +++ b/weechat/src/gui/gui-panel.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* gui-panel.c: panel functions, used by all GUI */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <stdio.h> +#include <stdarg.h> +#include <unistd.h> +#include <string.h> +#include <signal.h> +#include <time.h> +#include <ctype.h> + +#include "../common/weechat.h" +#include "gui.h" + + +t_gui_panel *gui_panels = NULL; /* pointer to first panel */ +t_gui_panel *last_gui_panel = NULL; /* pointer to last panel */ + + +/* + * gui_panel_new: create a new panel + */ + +t_gui_panel * +gui_panel_new (char *name, int position, int type, int size, int separator) +{ + t_gui_panel *new_panel; + t_gui_window *ptr_win; + + if (!name || !name[0]) + return NULL; + + if ((new_panel = (t_gui_panel *) malloc (sizeof (t_gui_panel)))) + { + new_panel->position = position; + new_panel->name = strdup (name); + new_panel->separator = separator; + new_panel->size = size; + if (type == GUI_PANEL_WINDOWS) + { + /* create panel window for all opened windows */ + for (ptr_win = gui_windows; ptr_win; + ptr_win = ptr_win->next_window) + gui_panel_window_new (new_panel, ptr_win); + } + else + /* create only one panel window (global) */ + gui_panel_window_new (new_panel, NULL); + + /* add panel to panels queue */ + new_panel->prev_panel = last_gui_panel; + if (gui_panels) + last_gui_panel->next_panel = new_panel; + else + gui_panels = new_panel; + last_gui_panel = new_panel; + new_panel->next_panel = NULL; + + return new_panel; + } + else + return NULL; +} + +/* + * gui_panel_free: delete a panel + */ + +void +gui_panel_free (t_gui_panel *panel) +{ + /* remove panel from panels list */ + if (panel->prev_panel) + panel->prev_panel->next_panel = panel->next_panel; + if (panel->next_panel) + panel->next_panel->prev_panel = panel->prev_panel; + if (gui_panels == panel) + gui_panels = panel->next_panel; + if (last_gui_panel == panel) + last_gui_panel = panel->prev_panel; + + /* free data */ + if (panel->name) + free (panel->name); + if (panel->panel_window) + gui_panel_window_free (panel->panel_window); + + free (panel); +} diff --git a/weechat/src/gui/gui-panel.h b/weechat/src/gui/gui-panel.h new file mode 100644 index 000000000..a4a8cac14 --- /dev/null +++ b/weechat/src/gui/gui-panel.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_PANEL_H +#define __WEECHAT_GUI_PANEL_H 1 + +#define GUI_PANEL_TOP 1 +#define GUI_PANEL_BOTTOM 2 +#define GUI_PANEL_LEFT 3 +#define GUI_PANEL_RIGHT 4 + +#define GUI_PANEL_GLOBAL 0 +#define GUI_PANEL_WINDOWS 1 + + +/* panel structure */ + +typedef struct t_gui_panel t_gui_panel; + +struct t_gui_panel +{ + int position; /* position (top, bottom, left, right) */ + char *name; /* panel name */ + void *panel_window; /* pointer to panel window, NULL if */ + /* displayed on each window (in this */ + /* case, pointers are in windows) */ + int separator; /* 1 if separator (line) displayed */ + int size; /* panel size */ + t_gui_panel *prev_panel; /* link to previous panel */ + t_gui_panel *next_panel; /* link to next panel */ +}; + +/* panel variables */ + +extern t_gui_panel *gui_panels; +extern t_gui_panel *last_gui_panel; + +#endif /* gui-panel.h */ diff --git a/weechat/src/gui/gui-window.c b/weechat/src/gui/gui-window.c index 7211e66b3..e6247149d 100644 --- a/weechat/src/gui/gui-window.c +++ b/weechat/src/gui/gui-window.c @@ -44,6 +44,13 @@ #include "../irc/irc.h" +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_window_tree *gui_windows_tree = NULL; /* pointer to windows tree */ + + /* * gui_window_tree_init: create first entry in windows tree */ @@ -115,6 +122,7 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height, { t_gui_window *new_window; t_gui_window_tree *ptr_tree, *child1, *child2, *ptr_leaf; + t_gui_panel *ptr_panel; #ifdef DEBUG weechat_log_printf ("Creating new window (x:%d, y:%d, width:%d, height:%d)\n", @@ -174,6 +182,11 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height, if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window))))) { + if (!gui_window_objects_init (new_window)) + { + free (new_window); + return NULL; + } new_window->win_x = x; new_window->win_y = y; new_window->win_width = width; @@ -199,23 +212,9 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height, new_window->win_nick_height = 0; new_window->win_nick_num_max = 0; new_window->win_nick_start = 0; - + new_window->win_input_x = 0; - - new_window->win_title = NULL; - new_window->win_chat = NULL; - new_window->win_nick = NULL; - new_window->win_status = NULL; - new_window->win_infobar = NULL; - new_window->win_input = NULL; - new_window->win_separator = NULL; - - new_window->textview_chat = NULL; - new_window->textbuffer_chat = NULL; - new_window->texttag_chat = NULL; - new_window->textview_nicklist = NULL; - new_window->textbuffer_nicklist = NULL; - + new_window->dcc_first = NULL; new_window->dcc_selected = NULL; new_window->dcc_last_displayed = NULL; @@ -229,6 +228,14 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height, new_window->ptr_tree = ptr_leaf; ptr_leaf->window = new_window; + + /* add panels to window */ + for (ptr_panel = gui_panels; ptr_panel; + ptr_panel = ptr_panel->next_panel) + { + if (!ptr_panel->panel_window) + gui_panel_window_new (ptr_panel, new_window); + } /* add window to windows queue */ new_window->prev_window = last_gui_window; @@ -255,6 +262,9 @@ gui_window_free (t_gui_window *window) if (window->buffer && (window->buffer->num_displayed > 0)) window->buffer->num_displayed--; + /* free data */ + gui_window_objects_free (window, 1); + /* remove window from windows list */ if (window->prev_window) window->prev_window->next_window = window->next_window; @@ -399,18 +409,7 @@ gui_window_print_log (t_gui_window *window) weechat_log_printf (" win_nick_width. . . : %d\n", window->win_nick_width); weechat_log_printf (" win_nick_height . . : %d\n", window->win_nick_height); weechat_log_printf (" win_nick_start. . . : %d\n", window->win_nick_start); - weechat_log_printf (" win_title . . . . . : 0x%X\n", window->win_title); - weechat_log_printf (" win_chat. . . . . . : 0x%X\n", window->win_chat); - weechat_log_printf (" win_nick. . . . . . : 0x%X\n", window->win_nick); - weechat_log_printf (" win_status. . . . . : 0x%X\n", window->win_status); - weechat_log_printf (" win_infobar . . . . : 0x%X\n", window->win_infobar); - weechat_log_printf (" win_input . . . . . : 0x%X\n", window->win_input); - weechat_log_printf (" win_separator . . . : 0x%X\n", window->win_separator); - weechat_log_printf (" textview_chat . . . : 0x%X\n", window->textview_chat); - weechat_log_printf (" textbuffer_chat . . : 0x%X\n", window->textbuffer_chat); - weechat_log_printf (" texttag_chat. . . . : 0x%X\n", window->texttag_chat); - weechat_log_printf (" textview_nicklist . : 0x%X\n", window->textview_nicklist); - weechat_log_printf (" textbuffer_nicklist : 0x%X\n", window->textbuffer_nicklist); + gui_window_objects_print_log (window); weechat_log_printf (" dcc_first . . . . . : 0x%X\n", window->dcc_first); weechat_log_printf (" dcc_selected. . . . : 0x%X\n", window->dcc_selected); weechat_log_printf (" dcc_last_displayed. : 0x%X\n", window->dcc_last_displayed); diff --git a/weechat/src/gui/gui-window.h b/weechat/src/gui/gui-window.h new file mode 100644 index 000000000..63e796980 --- /dev/null +++ b/weechat/src/gui/gui-window.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef __WEECHAT_GUI_WINDOW_H +#define __WEECHAT_GUI_WINDOW_H 1 + +#define WINDOW_MIN_WIDTH 10 +#define WINDOW_MIN_HEIGHT 5 + +/* window structures */ + +typedef struct t_gui_window_tree t_gui_window_tree; +typedef struct t_gui_window t_gui_window; + +struct t_gui_window +{ + /* global position & size */ + int win_x, win_y; /* position of window */ + int win_width, win_height; /* window geometry */ + int win_width_pct; /* % of width (compared to term size) */ + int win_height_pct; /* % of height (compared to term size) */ + + int new_x, new_y; /* used for computing new position */ + int new_width, new_height; /* used for computing new size */ + + /* chat window settings */ + int win_chat_x, win_chat_y; /* chat window position */ + int win_chat_width; /* width of chat window */ + int win_chat_height; /* height of chat window */ + int win_chat_cursor_x; /* position of cursor in chat window */ + int win_chat_cursor_y; /* position of cursor in chat window */ + + /* nicklist window settings */ + int win_nick_x, win_nick_y; /* nick window position */ + int win_nick_width; /* width of nick window */ + int win_nick_height; /* height of nick window */ + int win_nick_num_max; /* maximum number of nicks displayed */ + int win_nick_start; /* # of 1st nick for display (scroll) */ + + /* input window settings */ + int win_input_x; /* position of cursor in input window */ + + /* GUI specific objects */ + void *gui_objects; /* pointer to a GUI specific struct */ + + int current_style_fg;; /* current color used for foreground */ + int current_style_bg;; /* current color used for background */ + int current_style_attr; /* current attributes (bold, ..) */ + int current_color_attr; /* attr sum of last color(s) displayed */ + + /* DCC */ + void *dcc_first; /* first dcc displayed */ + void *dcc_selected; /* selected dcc */ + void *dcc_last_displayed; /* last dcc displayed (for scroll) */ + + t_gui_buffer *buffer; /* buffer currently displayed in window */ + + int first_line_displayed; /* = 1 if first line is displayed */ + t_gui_line *start_line; /* pointer to line if scrolling */ + int start_line_pos; /* position in first line displayed */ + int scroll; /* = 1 if "MORE" should be displayed */ + t_gui_window_tree *ptr_tree; /* pointer to leaf in windows tree */ + + t_gui_window *prev_window; /* link to previous window */ + t_gui_window *next_window; /* link to next window */ +}; + +struct t_gui_window_tree +{ + t_gui_window_tree *parent_node; /* pointer to parent node */ + + /* node info */ + int split_horiz; /* 1 if horizontal, 0 if vertical */ + int split_pct; /* % of split size (represents child1) */ + t_gui_window_tree *child1; /* first child, NULL if a leaf */ + t_gui_window_tree *child2; /* second child, NULL if a leaf */ + + /* leaf info */ + t_gui_window *window; /* pointer to window, NULL if a node */ +}; + +/* window variables */ + +extern t_gui_window *gui_windows; +extern t_gui_window *last_gui_window; +extern t_gui_window *gui_current_window; +extern t_gui_window_tree *gui_windows_tree; + +#endif /* gui-window.h */ diff --git a/weechat/src/gui/gui.h b/weechat/src/gui/gui.h index bf63fbd9c..338066a54 100644 --- a/weechat/src/gui/gui.h +++ b/weechat/src/gui/gui.h @@ -21,131 +21,11 @@ #ifndef __WEECHAT_GUI_H #define __WEECHAT_GUI_H 1 -#include "../common/completion.h" -#include "../common/history.h" - -#define INPUT_BUFFER_BLOCK_SIZE 256 - -#define COLOR_WIN_NICK_NUMBER 10 - -typedef enum t_weechat_color t_weechat_color; - -enum t_weechat_color -{ - COLOR_WIN_SEPARATOR = 0, - COLOR_WIN_TITLE, - COLOR_WIN_CHAT, - COLOR_WIN_CHAT_TIME, - COLOR_WIN_CHAT_TIME_SEP, - COLOR_WIN_CHAT_PREFIX1, - COLOR_WIN_CHAT_PREFIX2, - COLOR_WIN_CHAT_SERVER, - COLOR_WIN_CHAT_JOIN, - COLOR_WIN_CHAT_PART, - COLOR_WIN_CHAT_NICK, - COLOR_WIN_CHAT_HOST, - COLOR_WIN_CHAT_CHANNEL, - COLOR_WIN_CHAT_DARK, - COLOR_WIN_CHAT_HIGHLIGHT, - COLOR_WIN_CHAT_READ_MARKER, - COLOR_WIN_STATUS, - COLOR_WIN_STATUS_DELIMITERS, - COLOR_WIN_STATUS_CHANNEL, - COLOR_WIN_STATUS_DATA_MSG, - COLOR_WIN_STATUS_DATA_PRIVATE, - COLOR_WIN_STATUS_DATA_HIGHLIGHT, - COLOR_WIN_STATUS_DATA_OTHER, - COLOR_WIN_STATUS_MORE, - COLOR_WIN_INFOBAR, - COLOR_WIN_INFOBAR_DELIMITERS, - COLOR_WIN_INFOBAR_HIGHLIGHT, - COLOR_WIN_INPUT, - COLOR_WIN_INPUT_CHANNEL, - COLOR_WIN_INPUT_NICK, - COLOR_WIN_INPUT_DELIMITERS, - COLOR_WIN_NICK, - COLOR_WIN_NICK_AWAY, - COLOR_WIN_NICK_CHANOWNER, - COLOR_WIN_NICK_CHANADMIN, - COLOR_WIN_NICK_OP, - COLOR_WIN_NICK_HALFOP, - COLOR_WIN_NICK_VOICE, - COLOR_WIN_NICK_MORE, - COLOR_WIN_NICK_SEP, - COLOR_WIN_NICK_SELF, - COLOR_WIN_NICK_PRIVATE, - COLOR_WIN_NICK_1, - COLOR_WIN_NICK_2, - COLOR_WIN_NICK_3, - COLOR_WIN_NICK_4, - COLOR_WIN_NICK_5, - COLOR_WIN_NICK_6, - COLOR_WIN_NICK_7, - COLOR_WIN_NICK_8, - COLOR_WIN_NICK_9, - COLOR_WIN_NICK_10, - COLOR_DCC_SELECTED, - COLOR_DCC_WAITING, - COLOR_DCC_CONNECTING, - COLOR_DCC_ACTIVE, - COLOR_DCC_DONE, - COLOR_DCC_FAILED, - COLOR_DCC_ABORTED, - COLOR_WIN_INPUT_SERVER, - GUI_NUM_COLORS -}; - -#define GUI_NUM_IRC_COLORS 16 - -/* attributes in IRC messages for color & style (bold, ..) */ - -#define GUI_ATTR_BOLD_CHAR '\x02' -#define GUI_ATTR_BOLD_STR "\x02" -#define GUI_ATTR_COLOR_CHAR '\x03' -#define GUI_ATTR_COLOR_STR "\x03" -#define GUI_ATTR_RESET_CHAR '\x0F' -#define GUI_ATTR_RESET_STR "\x0F" -#define GUI_ATTR_FIXED_CHAR '\x11' -#define GUI_ATTR_FIXED_STR "\x11" -#define GUI_ATTR_REVERSE_CHAR '\x12' -#define GUI_ATTR_REVERSE_STR "\x12" -#define GUI_ATTR_REVERSE2_CHAR '\x16' -#define GUI_ATTR_REVERSE2_STR "\x16" -#define GUI_ATTR_ITALIC_CHAR '\x1D' -#define GUI_ATTR_ITALIC_STR "\x1D" -#define GUI_ATTR_UNDERLINE_CHAR '\x1F' -#define GUI_ATTR_UNDERLINE_STR "\x1F" - -/* WeeChat internal attributes (should never be in IRC messages) */ - -#define GUI_ATTR_WEECHAT_COLOR_CHAR '\x19' -#define GUI_ATTR_WEECHAT_COLOR_STR "\x19" -#define GUI_ATTR_WEECHAT_SET_CHAR '\x1A' -#define GUI_ATTR_WEECHAT_SET_STR "\x1A" -#define GUI_ATTR_WEECHAT_REMOVE_CHAR '\x1B' -#define GUI_ATTR_WEECHAT_REMOVE_STR "\x1B" - -#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "") -#define GUI_NO_COLOR GUI_ATTR_RESET_STR - -#define SERVER(buffer) ((t_irc_server *)(buffer->server)) -#define CHANNEL(buffer) ((t_irc_channel *)(buffer->channel)) - -#define BUFFER_IS_SERVER(buffer) ((SERVER(buffer) || (buffer->all_servers)) && !CHANNEL(buffer)) -#define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHANNEL_TYPE_CHANNEL)) -#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && \ - ((CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE) \ - || (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT))) - -#define BUFFER_HAS_NICKLIST(buffer) (BUFFER_IS_CHANNEL(buffer)) - -#define MSG_TYPE_TIME 1 -#define MSG_TYPE_PREFIX 2 -#define MSG_TYPE_NICK 4 -#define MSG_TYPE_INFO 8 -#define MSG_TYPE_MSG 16 -#define MSG_TYPE_HIGHLIGHT 32 -#define MSG_TYPE_NOLOG 64 +#include "gui-color.h" +#include "gui-panel.h" +#include "gui-buffer.h" +#include "gui-window.h" +#include "gui-keyboard.h" #define gui_printf(buffer, fmt, argz...) \ gui_printf_internal(buffer, 1, MSG_TYPE_INFO, NULL, fmt, ##argz) @@ -162,30 +42,6 @@ enum t_weechat_color #define gui_printf_nolog_notime(buffer, fmt, argz...) \ gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, NULL, fmt, ##argz) -#define WINDOW_MIN_WIDTH 10 -#define WINDOW_MIN_HEIGHT 5 - -#define BUFFER_TYPE_STANDARD 0 -#define BUFFER_TYPE_DCC 1 -#define BUFFER_TYPE_RAW_DATA 2 - -#define NOTIFY_LEVEL_MIN 0 -#define NOTIFY_LEVEL_MAX 3 -#define NOTIFY_LEVEL_DEFAULT NOTIFY_LEVEL_MAX - -#define KEY_SHOW_MODE_DISPLAY 1 -#define KEY_SHOW_MODE_BIND 2 - -typedef struct t_gui_color t_gui_color; - -struct t_gui_color -{ - int foreground; /* foreground color */ - int background; /* background color */ - int attributes; /* attributes (bold, ..) */ - char *string; /* WeeChat color: "\x19??", ?? is #color*/ -}; - typedef struct t_gui_infobar t_gui_infobar; struct t_gui_infobar @@ -198,214 +54,18 @@ struct t_gui_infobar t_gui_infobar *next_infobar; /* next message for infobar */ }; -typedef struct t_gui_line t_gui_line; - -struct t_gui_line -{ - int length; /* length of the line (in char) */ - int length_align; /* alignment length (time or time/nick) */ - int log_write; /* = 1 if line will be written to log */ - int line_with_message; /* line contains a message from a user? */ - int line_with_highlight; /* line contains highlight */ - char *nick; /* nickname for line (may be NULL) */ - char *data; /* line content */ - int ofs_after_date; /* offset to first char after date */ - int ofs_start_message; /* offset to first char after date/nick */ - t_gui_line *prev_line; /* link to previous line */ - t_gui_line *next_line; /* link to next line */ -}; - -typedef struct t_gui_buffer t_gui_buffer; - -struct t_gui_buffer -{ - int num_displayed; /* number of windows displaying buffer */ - - int number; /* buffer number (for jump/switch) */ - - /* server/channel */ - void *server; /* buffer's server */ - int all_servers; /* =1 if all servers are displayed here */ - void *channel; /* buffer's channel */ - int type; /* type: standard (server/channel/pv), */ - /* dcc or raw data */ - - /* chat content (lines, line is composed by many messages) */ - t_gui_line *lines; /* lines of chat window */ - t_gui_line *last_line; /* last line of chat window */ - t_gui_line *last_read_line; /* last read line before jump */ - int num_lines; /* number of lines in the window */ - int line_complete; /* current line complete ? (\n ending) */ - - /* notify level: when activity should be displayed? default: 3 (always) */ - int notify_level; /* 0 = never */ - /* 1 = highlight only */ - /* 2 = highlight + message */ - /* 3 = highlight + message + join/part */ - - /* file to save buffer content */ - char *log_filename; /* filename for saving buffer content */ - FILE *log_file; /* for logging buffer to file */ - - /* inupt buffer */ - int has_input; /* = 1 if buffer has input (DCC has not)*/ - char *input_buffer; /* input buffer */ - char *input_buffer_color_mask; /* color mask for input buffer */ - int input_buffer_alloc; /* input buffer: allocated size in mem */ - int input_buffer_size; /* buffer size in bytes */ - int input_buffer_length; /* number of chars in buffer */ - int input_buffer_pos; /* position into buffer */ - int input_buffer_1st_display; /* first char displayed on screen */ - - /* completion */ - t_completion completion; /* for cmds/nicks completion */ - - /* history */ - t_history *history; /* commands history */ - t_history *last_history; /* last command in history */ - t_history *ptr_history; /* current command in history */ - int num_history; /* number of commands in history */ - - /* link to previous/next buffer */ - t_gui_buffer *prev_buffer; /* link to previous buffer */ - t_gui_buffer *next_buffer; /* link to next buffer */ -}; - -typedef struct t_gui_window_tree t_gui_window_tree; -typedef struct t_gui_window t_gui_window; - -struct t_gui_window -{ - /* global position & size */ - int win_x, win_y; /* position of window */ - int win_width, win_height; /* window geometry */ - int win_width_pct; /* % of width (compared to term size) */ - int win_height_pct; /* % of height (compared to term size) */ - - int new_x, new_y; /* used for computing new position */ - int new_width, new_height; /* used for computing new size */ - - /* chat window settings */ - int win_chat_x, win_chat_y; /* chat window position */ - int win_chat_width; /* width of chat window */ - int win_chat_height; /* height of chat window */ - int win_chat_cursor_x; /* position of cursor in chat window */ - int win_chat_cursor_y; /* position of cursor in chat window */ - - /* nicklist window settings */ - int win_nick_x, win_nick_y; /* nick window position */ - int win_nick_width; /* width of nick window */ - int win_nick_height; /* height of nick window */ - int win_nick_num_max; /* maximum number of nicks displayed */ - int win_nick_start; /* # of 1st nick for display (scroll) */ - - /* input window settings */ - int win_input_x; /* position of cursor in input window */ - - /* windows for Curses GUI */ - void *win_title; /* title window */ - void *win_chat; /* chat window (example: channel) */ - void *win_nick; /* nick window */ - void *win_status; /* status window */ - void *win_infobar; /* info bar window */ - void *win_input; /* input window */ - void *win_separator; /* separation between 2 splited (V) win */ - - /* 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 Qt GUI */ - /* TODO: declare Qt window */ - - int current_style_fg;; /* current color used for foreground */ - int current_style_bg;; /* current color used for background */ - int current_style_attr; /* current attributes (bold, ..) */ - int current_color_attr; /* attr sum of last color(s) displayed */ - - /* DCC */ - void *dcc_first; /* first dcc displayed */ - void *dcc_selected; /* selected dcc */ - void *dcc_last_displayed; /* last dcc displayed (for scroll) */ - - t_gui_buffer *buffer; /* buffer currently displayed in window */ - - int first_line_displayed; /* = 1 if first line is displayed */ - t_gui_line *start_line; /* pointer to line if scrolling */ - int start_line_pos; /* position in first line displayed */ - int scroll; /* = 1 if "MORE" should be displayed */ - t_gui_window_tree *ptr_tree; /* pointer to leaf in windows tree */ - - t_gui_window *prev_window; /* link to previous window */ - t_gui_window *next_window; /* link to next window */ -}; - -struct t_gui_window_tree -{ - t_gui_window_tree *parent_node; /* pointer to parent node */ - - /* node info */ - int split_horiz; /* 1 if horizontal, 0 if vertical */ - int split_pct; /* % of split size (represents child1) */ - t_gui_window_tree *child1; /* first child, NULL if a leaf */ - t_gui_window_tree *child2; /* second child, NULL if a leaf */ - - /* leaf info */ - t_gui_window *window; /* pointer to window, NULL if a node */ -}; - -typedef struct t_gui_key t_gui_key; - -struct t_gui_key -{ - char *key; /* key combo (ex: a, ^W, ^W^C, meta-a) */ - char *command; /* associated command (may be NULL) */ - void (*function)(t_gui_window *); - /* associated function (if cmd is NULL) */ - t_gui_key *prev_key; /* link to previous key */ - t_gui_key *next_key; /* link to next key */ -}; - -typedef struct t_gui_key_function t_gui_key_function; - -struct t_gui_key_function -{ - char *function_name; /* name of function */ - void (*function)(); /* associated function */ - char *description; /* description of function */ -}; - -/* variables */ +/* GUI variables */ extern int gui_init_ok; extern int gui_ok; extern int gui_add_hotlist; -extern t_gui_window *gui_windows; -extern t_gui_window *last_gui_window; -extern t_gui_window *gui_current_window; -extern t_gui_window_tree *gui_windows_tree; -extern t_gui_buffer *gui_buffers; -extern t_gui_buffer *last_gui_buffer; -extern t_gui_buffer *gui_buffer_before_dcc; -extern t_gui_buffer *gui_buffer_raw_data; -extern t_gui_buffer *gui_buffer_before_raw_data; extern t_gui_infobar *gui_infobar; -extern t_gui_key *gui_keys; -extern t_gui_key *last_gui_key; -extern t_gui_key_function gui_key_functions[]; -extern char gui_key_buffer[128]; -extern int gui_key_grab; -extern int gui_key_grab_count; extern char *gui_input_clipboard; extern time_t gui_last_activity_time; -extern t_gui_color *gui_color[GUI_NUM_COLORS]; - -/* GUI independent functions: windows */ +/* GUI independent functions */ +/* window */ extern int gui_window_tree_init (t_gui_window *); extern void gui_window_tree_node_to_leaf (t_gui_window_tree *, t_gui_window *); extern void gui_window_tree_free (t_gui_window_tree **); @@ -417,8 +77,7 @@ extern void gui_window_switch_next (t_gui_window *); extern void gui_window_switch_by_buffer (t_gui_window *, int); extern void gui_window_print_log (t_gui_window *); -/* GUI independent functions: buffers */ - +/* buffer */ extern t_gui_buffer *gui_buffer_servers_search (); extern t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int); extern t_gui_buffer *gui_buffer_search (char *, char *); @@ -438,8 +97,11 @@ extern t_gui_buffer *gui_buffer_switch_by_number (t_gui_window *, int); extern void gui_buffer_move_to_number (t_gui_buffer *, int); extern void gui_buffer_print_log (t_gui_buffer *); -/* GUI independent functions: actions */ +/* panel */ +extern t_gui_panel *gui_panel_new (char *, int, int, int, int); +extern void gui_panel_free (t_gui_panel *); +/* action */ extern void gui_action_clipboard_copy (char *, int); extern void gui_action_clipboard_paste (t_gui_window *); extern void gui_action_return (t_gui_window *); @@ -487,22 +149,20 @@ extern void gui_action_infobar_clear (t_gui_window *); extern void gui_action_refresh_screen (); extern void gui_action_grab_key (t_gui_window *); -/* GUI independent functions: keys */ - -extern void gui_key_init (); -extern void gui_key_init_grab (); -extern char *gui_key_get_internal_code (char *); -extern char *gui_key_get_expanded_name (char *); -extern void *gui_key_function_search_by_name (char *); -extern char *gui_key_function_search_by_ptr (void *); -extern t_gui_key *gui_key_bind (char *, char *); -extern int gui_key_unbind (char *); -extern int gui_key_pressed (char *); -extern void gui_key_free (t_gui_key *); -extern void gui_key_free_all (); - -/* other GUI independent functions */ - +/* key */ +extern void gui_keyboard_init (); +extern void gui_keyboard_init_grab (); +extern char *gui_keyboard_get_internal_code (char *); +extern char *gui_keyboard_get_expanded_name (char *); +extern void *gui_keyboard_function_search_by_name (char *); +extern char *gui_keyboard_function_search_by_ptr (void *); +extern t_gui_key *gui_keyboard_bind (char *, char *); +extern int gui_keyboard_unbind (char *); +extern int gui_keyboard_pressed (char *); +extern void gui_keyboard_free (t_gui_key *); +extern void gui_keyboard_free_all (); + +/* other */ extern void gui_infobar_printf (int, int, char *, ...); extern void gui_infobar_printf_from_buffer (t_gui_buffer *, int, int, char *, char *, ...); extern void gui_infobar_remove (); @@ -518,16 +178,9 @@ extern void gui_exec_action_dcc (t_gui_window *, char *); extern void gui_exec_action_raw_data (t_gui_window *, char *); extern int gui_insert_string_input (t_gui_window *, char *, int); -/* GUI dependant functions: keyboard */ +/* GUI dependent functions */ -extern void gui_keyboard_default_bindings (); - -/* GUI dependant functions: display */ - -extern void gui_chat_draw_title (t_gui_buffer *, int); -extern char *gui_chat_word_get_next_char (t_gui_window *, unsigned char *, int); -extern void gui_chat_draw (t_gui_buffer *, int); -extern void gui_chat_draw_line (t_gui_buffer *, t_gui_line *); +/* color */ extern int gui_color_assign (int *, char *); extern char *gui_color_get_name (int); extern unsigned char *gui_color_decode (unsigned char *, int); @@ -535,11 +188,34 @@ extern unsigned char *gui_color_decode_for_user_entry (unsigned char *); extern unsigned char *gui_color_encode (unsigned char *); extern void gui_color_init_pairs (); extern void gui_color_rebuild_weechat(); + +/* keyboard */ +extern void gui_keyboard_default_bindings (); + +/* chat */ +extern void gui_chat_draw_title (t_gui_buffer *, int); +extern char *gui_chat_word_get_next_char (t_gui_window *, unsigned char *, int); +extern void gui_chat_draw (t_gui_buffer *, int); +extern void gui_chat_draw_line (t_gui_buffer *, t_gui_line *); + +/* status bar */ extern void gui_infobar_draw_time (t_gui_buffer *); extern void gui_infobar_draw (t_gui_buffer *, int); + +/* info bar */ +extern void gui_status_draw (t_gui_buffer *, int); + +/* input */ extern void gui_input_draw (t_gui_buffer *, int); + +/* nicklist */ extern void gui_nicklist_draw (t_gui_buffer *, int); -extern void gui_status_draw (t_gui_buffer *, int); + +/* window */ +extern int gui_window_get_width (); +extern int gui_window_get_height (); +extern int gui_window_objects_init (t_gui_window *); +extern void gui_window_objects_free (t_gui_window *, int); extern int gui_window_calculate_pos_size (t_gui_window *, int); extern void gui_window_redraw_buffer (t_gui_buffer *); extern void gui_window_switch_to_buffer (t_gui_window *, t_gui_buffer *); @@ -567,6 +243,13 @@ extern void gui_window_switch_right (t_gui_window *); extern void gui_window_refresh_screen (); extern void gui_window_set_title (); extern void gui_window_reset_title (); +extern void gui_window_objects_print_log (t_gui_window *); + +/* panel */ +extern int gui_panel_window_new (t_gui_panel *, t_gui_window *); +extern void gui_panel_window_free (void *); + +/* main */ extern void gui_main_loop (); extern void gui_main_pre_init (int *, char **[]); extern void gui_main_init (); |