summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/CMakeLists.txt9
-rw-r--r--src/gui/Makefile.am35
-rw-r--r--src/gui/curses/CMakeLists.txt5
-rw-r--r--src/gui/curses/Makefile.am12
-rw-r--r--src/gui/curses/gui-curses-chat.c691
-rw-r--r--src/gui/curses/gui-curses-color.c667
-rw-r--r--src/gui/curses/gui-curses-infobar.c56
-rw-r--r--src/gui/curses/gui-curses-input.c304
-rw-r--r--src/gui/curses/gui-curses-keyboard.c38
-rw-r--r--src/gui/curses/gui-curses-main.c334
-rw-r--r--src/gui/curses/gui-curses-nicklist.c112
-rw-r--r--src/gui/curses/gui-curses-panel.c216
-rw-r--r--src/gui/curses/gui-curses-status.c345
-rw-r--r--src/gui/curses/gui-curses-window.c306
-rw-r--r--src/gui/curses/gui-curses.h41
-rw-r--r--src/gui/gtk/CMakeLists.txt5
-rw-r--r--src/gui/gtk/Makefile.am10
-rw-r--r--src/gui/gtk/gui-gtk-chat.c258
-rw-r--r--src/gui/gtk/gui-gtk-color.c359
-rw-r--r--src/gui/gtk/gui-gtk-infobar.c16
-rw-r--r--src/gui/gtk/gui-gtk-input.c100
-rw-r--r--src/gui/gtk/gui-gtk-keyboard.c12
-rw-r--r--src/gui/gtk/gui-gtk-main.c67
-rw-r--r--src/gui/gtk/gui-gtk-nicklist.c18
-rw-r--r--src/gui/gtk/gui-gtk-status.c21
-rw-r--r--src/gui/gtk/gui-gtk-window.c132
-rw-r--r--src/gui/gtk/gui-gtk.h18
-rw-r--r--src/gui/gui-action.c935
-rw-r--r--src/gui/gui-action.h79
-rw-r--r--src/gui/gui-buffer.c1382
-rw-r--r--src/gui/gui-buffer.h225
-rw-r--r--src/gui/gui-chat.c566
-rw-r--r--src/gui/gui-chat.h63
-rw-r--r--src/gui/gui-color.c113
-rw-r--r--src/gui/gui-color.h216
-rw-r--r--src/gui/gui-common.c875
-rw-r--r--src/gui/gui-completion.c846
-rw-r--r--src/gui/gui-completion.h67
-rw-r--r--src/gui/gui-history.c112
-rw-r--r--src/gui/gui-history.h31
-rw-r--r--src/gui/gui-hotlist.c157
-rw-r--r--src/gui/gui-hotlist.h58
-rw-r--r--src/gui/gui-infobar.c109
-rw-r--r--src/gui/gui-infobar.h52
-rw-r--r--src/gui/gui-input.c522
-rw-r--r--src/gui/gui-input.h (renamed from src/gui/gtk/gui-gtk-panel.c)49
-rw-r--r--src/gui/gui-keyboard.c89
-rw-r--r--src/gui/gui-keyboard.h32
-rw-r--r--src/gui/gui-log.c156
-rw-r--r--src/gui/gui-log.h31
-rw-r--r--src/gui/gui-main.h35
-rw-r--r--src/gui/gui-nicklist.c296
-rw-r--r--src/gui/gui-nicklist.h41
-rw-r--r--src/gui/gui-panel.c173
-rw-r--r--src/gui/gui-panel.h55
-rw-r--r--src/gui/gui-status.h29
-rw-r--r--src/gui/gui-window.c538
-rw-r--r--src/gui/gui-window.h181
-rw-r--r--src/gui/gui.h300
59 files changed, 5804 insertions, 6796 deletions
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 9370c41d4..fd9483960 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -18,9 +18,12 @@ IF(NOT DISABLE_NCURSES)
SUBDIRS( curses )
ENDIF(NOT DISABLE_NCURSES)
-SET(LIB_GUI_COMMON_SRC gui-buffer.c gui-common.c gui-action.c gui-keyboard.c
-gui-log.c gui-window.c gui-panel.c gui.h gui-buffer.h gui-color.h gui-keyboard.h
-gui-panel.h gui-window.h)
+SET(LIB_GUI_COMMON_SRC gui-action.c gui-action.h gui-buffer.c gui-buffer.h
+gui-chat.c gui-chat.h gui-color.c gui-color.h gui-completion.c gui-completion.h
+gui-history.c gui-history.h gui-hotlist.c gui-hotlist.h gui-infobar.c
+gui-infobar.h gui-input.c gui-input.h gui-keyboard.c gui-keyboard.h gui-log.c
+gui-log.h gui-main.h gui-nicklist.c gui-nicklist.h gui-status.h gui-window.c
+gui-window.h)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_LIBRARY(weechat_gui_common STATIC ${LIB_GUI_COMMON_SRC})
diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am
index 85cc1719e..65bd8b7ab 100644
--- a/src/gui/Makefile.am
+++ b/src/gui/Makefile.am
@@ -18,19 +18,34 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
noinst_LIBRARIES = lib_weechat_gui_common.a
-lib_weechat_gui_common_a_SOURCES = gui-buffer.c \
- gui-common.c \
- gui-action.c \
- gui-keyboard.c \
- gui-log.c \
- gui-window.c \
- gui-panel.c \
- gui.h \
+lib_weechat_gui_common_a_SOURCES = gui-action.c \
+ gui-action.h \
+ gui-buffer.c \
gui-buffer.h \
+ gui-chat.c \
+ gui-chat.h \
+ gui-color.c \
gui-color.h \
+ gui-completion.c \
+ gui-completion.h \
+ gui-history.c \
+ gui-history.h \
+ gui-hotlist.c \
+ gui-hotlist.h \
+ gui-infobar.c \
+ gui-infobar.h \
+ gui-input.c \
+ gui-input.h \
+ gui-keyboard.c \
gui-keyboard.h \
- gui-panel.h \
- gui-window.h
+ gui-log.c \
+ gui-log.h \
+ gui-main.h \
+ gui-status.h \
+ gui-window.c \
+ gui-window.h \
+ gui-nicklist.c \
+ gui-nicklist.h
if GUI_NCURSES
curses_dir=curses
diff --git a/src/gui/curses/CMakeLists.txt b/src/gui/curses/CMakeLists.txt
index 53c5bb4ee..b57d4e780 100644
--- a/src/gui/curses/CMakeLists.txt
+++ b/src/gui/curses/CMakeLists.txt
@@ -16,7 +16,7 @@
SET(WEECHAT_CURSES_SRC 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)
+gui-curses-status.c gui-curses-window.c gui-curses.h)
SET(EXECUTABLE weechat-curses)
@@ -40,8 +40,7 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
ADD_EXECUTABLE(${EXECUTABLE} ${WEECHAT_CURSES_SRC})
-INCLUDE_DIRECTORIES(.. ../../common ../../protocols ../../protocols/irc
-../../plugins)
+INCLUDE_DIRECTORIES(.. ../../core ../../plugins)
TARGET_LINK_LIBRARIES(${EXECUTABLE} ${STATIC_LIBS} ${EXTRA_LIBS})
INSTALL(TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin)
diff --git a/src/gui/curses/Makefile.am b/src/gui/curses/Makefile.am
index ac5290a16..89e5e2011 100644
--- a/src/gui/curses/Makefile.am
+++ b/src/gui/curses/Makefile.am
@@ -14,14 +14,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
+INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(NCURSES_CFLAGS)
bin_PROGRAMS = weechat-curses
-weechat_curses_LDADD = $(WEECHAT_STATIC_LIBS) \
- $(PLUGINS_LIBS) \
- $(NCURSES_LIBS) \
- $(GNUTLS_LFLAGS)
+weechat_curses_LDADD = ../../core/lib_weechat_core.a \
+ ../../plugins/lib_weechat_plugins.a \
+ ../lib_weechat_gui_common.a \
+ $(PLUGINS_LFLAGS) \
+ $(NCURSES_LFLAGS)
weechat_curses_SOURCES = gui-curses-chat.c \
gui-curses-color.c \
@@ -32,5 +33,4 @@ weechat_curses_SOURCES = gui-curses-chat.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-curses-chat.c b/src/gui/curses/gui-curses-chat.c
index 6f5a0f41a..da1663421 100644
--- a/src/gui/curses/gui-curses-chat.c
+++ b/src/gui/curses/gui-curses-chat.c
@@ -27,12 +27,13 @@
#include <string.h>
#include <ctype.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/utf8.h"
-#include "../../common/util.h"
-#include "../../common/weeconfig.h"
-#include "../../protocols/irc/irc.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-string.h"
+#include "../../core/wee-utf8.h"
+#include "../gui-chat.h"
+#include "../gui-main.h"
+#include "../gui-window.h"
#include "gui-curses.h"
@@ -42,7 +43,7 @@
*/
void
-gui_chat_set_style (t_gui_window *window, int style)
+gui_chat_set_style (struct t_gui_window *window, int style)
{
wattron (GUI_CURSES(window)->win_chat, style);
}
@@ -53,7 +54,7 @@ gui_chat_set_style (t_gui_window *window, int style)
*/
void
-gui_chat_remove_style (t_gui_window *window, int style)
+gui_chat_remove_style (struct t_gui_window *window, int style)
{
wattroff (GUI_CURSES(window)->win_chat, style);
}
@@ -64,7 +65,7 @@ gui_chat_remove_style (t_gui_window *window, int style)
*/
void
-gui_chat_toggle_style (t_gui_window *window, int style)
+gui_chat_toggle_style (struct t_gui_window *window, int style)
{
window->current_style_attr ^= style;
if (window->current_style_attr & style)
@@ -79,14 +80,14 @@ gui_chat_toggle_style (t_gui_window *window, int style)
*/
void
-gui_chat_reset_style (t_gui_window *window)
+gui_chat_reset_style (struct t_gui_window *window)
{
window->current_style_fg = -1;
window->current_style_bg = -1;
window->current_style_attr = 0;
window->current_color_attr = 0;
- gui_window_set_weechat_color (GUI_CURSES(window)->win_chat, GUI_COLOR_WIN_CHAT);
+ gui_window_set_weechat_color (GUI_CURSES(window)->win_chat, GUI_COLOR_CHAT);
gui_chat_remove_style (window,
A_BOLD | A_UNDERLINE | A_REVERSE);
}
@@ -96,7 +97,7 @@ gui_chat_reset_style (t_gui_window *window)
*/
void
-gui_chat_set_color_style (t_gui_window *window, int style)
+gui_chat_set_color_style (struct t_gui_window *window, int style)
{
window->current_color_attr |= style;
wattron (GUI_CURSES(window)->win_chat, style);
@@ -107,7 +108,7 @@ gui_chat_set_color_style (t_gui_window *window, int style)
*/
void
-gui_chat_remove_color_style (t_gui_window *window, int style)
+gui_chat_remove_color_style (struct t_gui_window *window, int style)
{
window->current_color_attr &= !style;
wattroff (GUI_CURSES(window)->win_chat, style);
@@ -118,7 +119,7 @@ gui_chat_remove_color_style (t_gui_window *window, int style)
*/
void
-gui_chat_reset_color_style (t_gui_window *window)
+gui_chat_reset_color_style (struct t_gui_window *window)
{
wattroff (GUI_CURSES(window)->win_chat, window->current_color_attr);
window->current_color_attr = 0;
@@ -129,7 +130,7 @@ gui_chat_reset_color_style (t_gui_window *window)
*/
void
-gui_chat_set_color (t_gui_window *window, int fg, int bg)
+gui_chat_set_color (struct t_gui_window *window, int fg, int bg)
{
if (((fg == -1) || (fg == 99))
&& ((bg == -1) || (bg == 99)))
@@ -137,7 +138,7 @@ gui_chat_set_color (t_gui_window *window, int fg, int bg)
else
{
if ((fg == -1) || (fg == 99))
- fg = WEECHAT_COLOR_WHITE;
+ fg = COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
wattron (GUI_CURSES(window)->win_chat, COLOR_PAIR((bg * 8) + fg));
@@ -149,7 +150,7 @@ gui_chat_set_color (t_gui_window *window, int fg, int bg)
*/
void
-gui_chat_set_weechat_color (t_gui_window *window, int weechat_color)
+gui_chat_set_weechat_color (struct t_gui_window *window, int weechat_color)
{
gui_chat_reset_style (window);
gui_chat_set_style (window,
@@ -164,10 +165,10 @@ gui_chat_set_weechat_color (t_gui_window *window, int weechat_color)
*/
void
-gui_chat_draw_title (t_gui_buffer *buffer, int erase)
+gui_chat_draw_title (struct t_gui_buffer *buffer, int erase)
{
- t_gui_window *ptr_win;
- char format[32], *buf, *buf2, *ptr_topic;
+ struct t_gui_window *ptr_win;
+ char format[32], *buf, *buf2, *ptr_title;
if (!gui_ok)
return;
@@ -177,74 +178,64 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase)
if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0))
{
if (erase)
- gui_window_curses_clear (GUI_CURSES(ptr_win)->win_title, GUI_COLOR_WIN_TITLE);
+ gui_window_curses_clear (GUI_CURSES(ptr_win)->win_title, GUI_COLOR_TITLE);
snprintf (format, 32, "%%-%ds", ptr_win->win_title_width);
wmove (GUI_CURSES(ptr_win)->win_title, 0, 0);
- if (GUI_CHANNEL(buffer))
+ if (buffer->title)
{
- if (GUI_CHANNEL(buffer)->topic)
+ buf = (char *)gui_color_decode ((unsigned char *)buffer->title);
+ ptr_title = utf8_add_offset ((buf) ? buf : buffer->title,
+ ptr_win->win_title_start);
+ if (!ptr_title || !ptr_title[0])
{
- buf = (char *)gui_color_decode ((unsigned char *)(GUI_CHANNEL(buffer)->topic), 0, 0);
- ptr_topic = utf8_add_offset ((buf) ? buf : GUI_CHANNEL(buffer)->topic,
- ptr_win->win_title_start);
- if (!ptr_topic || !ptr_topic[0])
- {
- ptr_win->win_title_start = 0;
- ptr_topic = (buf) ? buf : GUI_CHANNEL(buffer)->topic;
- }
- buf2 = weechat_iconv_from_internal (NULL,
- ptr_topic);
-
- if (ptr_win->win_title_start > 0)
- {
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
- GUI_COLOR_WIN_TITLE_MORE);
- wprintw (GUI_CURSES(ptr_win)->win_title, "%s", "++");
- }
-
- if (utf8_width_screen (ptr_topic) > ptr_win->win_width)
- {
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title, GUI_COLOR_WIN_TITLE);
- wprintw (GUI_CURSES(ptr_win)->win_title, "%s", (buf2) ? buf2 : ptr_topic);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
- GUI_COLOR_WIN_TITLE_MORE);
- mvwprintw (GUI_CURSES(ptr_win)->win_title, 0, ptr_win->win_width - 2,
- "%s", "++");
- }
- else
- {
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title, GUI_COLOR_WIN_TITLE);
- wprintw (GUI_CURSES(ptr_win)->win_title, "%s", (buf2) ? buf2 : ptr_topic);
- }
- if (buf)
- free (buf);
- if (buf2)
- free (buf2);
+ ptr_win->win_title_start = 0;
+ ptr_title = (buf) ? buf : buffer->title;
}
- else
+ buf2 = string_iconv_from_internal (NULL,
+ ptr_title);
+
+ if (ptr_win->win_title_start > 0)
{
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title, GUI_COLOR_WIN_TITLE);
- wprintw (GUI_CURSES(ptr_win)->win_title, format, " ");
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
+ GUI_COLOR_TITLE_MORE);
+ wprintw (GUI_CURSES(ptr_win)->win_title, "%s", "++");
}
- }
- else
- {
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title, GUI_COLOR_WIN_TITLE);
- if (buffer->type == GUI_BUFFER_TYPE_STANDARD)
+
+ if (utf8_strlen_screen (ptr_title) > ptr_win->win_width)
{
- wprintw (GUI_CURSES(ptr_win)->win_title,
- format,
- PACKAGE_STRING " " WEECHAT_COPYRIGHT_DATE " - "
- WEECHAT_WEBSITE);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
+ GUI_COLOR_TITLE);
+ wprintw (GUI_CURSES(ptr_win)->win_title, "%s",
+ (buf2) ? buf2 : ptr_title);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
+ GUI_COLOR_TITLE_MORE);
+ mvwprintw (GUI_CURSES(ptr_win)->win_title, 0,
+ ptr_win->win_width - 2,
+ "%s", "++");
}
else
- wprintw (GUI_CURSES(ptr_win)->win_title, format, " ");
+ {
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
+ GUI_COLOR_TITLE);
+ wprintw (GUI_CURSES(ptr_win)->win_title, "%s",
+ (buf2) ? buf2 : ptr_title);
+ }
+ if (buf)
+ free (buf);
+ if (buf2)
+ free (buf2);
}
- wnoutrefresh (GUI_CURSES(ptr_win)->win_title);
- refresh ();
}
+ else
+ {
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
+ GUI_COLOR_TITLE);
+ wprintw (GUI_CURSES(ptr_win)->win_title, format, " ");
+ }
+ wnoutrefresh (GUI_CURSES(ptr_win)->win_title);
+ refresh ();
}
}
@@ -254,7 +245,7 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase)
*/
int
-gui_chat_get_real_width (t_gui_window *window)
+gui_chat_get_real_width (struct t_gui_window *window)
{
if (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_RIGHT)
return window->win_chat_width - 1;
@@ -267,7 +258,7 @@ gui_chat_get_real_width (t_gui_window *window)
*/
void
-gui_chat_display_new_line (t_gui_window *window, int num_lines, int count,
+gui_chat_display_new_line (struct t_gui_window *window, int num_lines, int count,
int *lines_displayed, int simulate)
{
if ((count == 0) || (*lines_displayed >= num_lines - count))
@@ -287,99 +278,28 @@ gui_chat_display_new_line (t_gui_window *window, int num_lines, int count,
}
/*
- * gui_chat_word_get_next_char: returns next char of a word
- * special chars like colors, bold, .. are skipped
+ * gui_chat_string_next_char: returns next char of a word (for display)
+ * special chars like colors, bold, .. are skipped
+ * and optionaly applied
*/
char *
-gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
- int apply_style, int *width_screen)
+gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
+ int apply_style)
{
- char str_fg[3], str_bg[3], utf_char[16];
- int fg, bg, weechat_color, char_size;
-
- if (width_screen)
- *width_screen = 0;
+ char str_fg[3];
+ int weechat_color;
while (string[0])
{
switch (string[0])
{
- case GUI_ATTR_BOLD_CHAR:
- string++;
- if (apply_style)
- gui_chat_toggle_style (window, A_BOLD);
- break;
- case GUI_ATTR_COLOR_CHAR:
- string++;
- str_fg[0] = '\0';
- str_bg[0] = '\0';
- fg = 99;
- bg = 99;
- if (isdigit (string[0]))
- {
- str_fg[0] = string[0];
- str_fg[1] = '\0';
- string++;
- if (isdigit (string[0]))
- {
- str_fg[1] = string[0];
- str_fg[2] = '\0';
- string++;
- }
- }
- if (string[0] == ',')
- {
- string++;
- if (isdigit (string[0]))
- {
- str_bg[0] = string[0];
- str_bg[1] = '\0';
- string++;
- if (isdigit (string[0]))
- {
- str_bg[1] = string[0];
- str_bg[2] = '\0';
- string++;
- }
- }
- }
- if (apply_style)
- {
- if (str_fg[0] || str_bg[0])
- {
- if (str_fg[0])
- sscanf (str_fg, "%d", &fg);
- else
- fg = window->current_style_fg;
- if (str_bg[0])
- sscanf (str_bg, "%d", &bg);
- else
- bg = window->current_style_bg;
- }
- if (!str_fg[0] && !str_bg[0])
- gui_chat_reset_color_style (window);
- window->current_style_fg = fg;
- window->current_style_bg = bg;
- gui_chat_set_color (window, fg, bg);
- }
- break;
- case GUI_ATTR_RESET_CHAR:
- case GUI_ATTR_WEECHAT_RESET_CHAR:
+ case GUI_COLOR_RESET_CHAR:
string++;
if (apply_style)
gui_chat_reset_style (window);
break;
- case GUI_ATTR_FIXED_CHAR:
- string++;
- break;
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
- string++;
- if (apply_style)
- gui_chat_toggle_style (window, A_REVERSE);
- break;
- case GUI_ATTR_WEECHAT_COLOR_CHAR:
+ case GUI_COLOR_COLOR_CHAR:
string++;
if (isdigit (string[0]) && isdigit (string[1]))
{
@@ -394,74 +314,62 @@ gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
}
}
break;
- case GUI_ATTR_WEECHAT_SET_CHAR:
+ case GUI_COLOR_SET_CHAR:
string++;
switch (string[0])
{
- case GUI_ATTR_BOLD_CHAR:
+ case GUI_COLOR_ATTR_BOLD_CHAR:
string++;
if (apply_style)
gui_chat_set_color_style (window, A_BOLD);
break;
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
+ case GUI_COLOR_ATTR_REVERSE_CHAR:
string++;
if (apply_style)
gui_chat_set_color_style (window, A_REVERSE);
break;
- case GUI_ATTR_UNDERLINE_CHAR:
+ case GUI_COLOR_ATTR_ITALIC_CHAR:
+ /* not available in Curses GUI */
+ string++;
+ break;
+ case GUI_COLOR_ATTR_UNDERLINE_CHAR:
string++;
if (apply_style)
gui_chat_set_color_style (window, A_UNDERLINE);
break;
}
break;
- case GUI_ATTR_WEECHAT_REMOVE_CHAR:
+ case GUI_COLOR_REMOVE_CHAR:
string++;
switch (string[0])
{
- case GUI_ATTR_BOLD_CHAR:
+ case GUI_COLOR_ATTR_BOLD_CHAR:
string++;
if (apply_style)
gui_chat_remove_color_style (window, A_BOLD);
break;
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
+ case GUI_COLOR_ATTR_REVERSE_CHAR:
string++;
if (apply_style)
gui_chat_remove_color_style (window, A_REVERSE);
break;
- case GUI_ATTR_UNDERLINE_CHAR:
+ case GUI_COLOR_ATTR_ITALIC_CHAR:
+ /* not available in Curses GUI */
+ string++;
+ break;
+ case GUI_COLOR_ATTR_UNDERLINE_CHAR:
string++;
if (apply_style)
gui_chat_remove_color_style (window, A_UNDERLINE);
break;
}
break;
- case GUI_ATTR_ITALIC_CHAR:
- string++;
- break;
- case GUI_ATTR_UNDERLINE_CHAR:
- string++;
- if (apply_style)
- gui_chat_toggle_style (window, A_UNDERLINE);
- break;
default:
if (string[0] < 32)
string++;
else
- {
- char_size = utf8_char_size ((char *) string);
- if (width_screen)
- {
- memcpy (utf_char, string, char_size);
- utf_char[char_size] = '\0';
- *width_screen = utf8_width_screen (utf_char);
- if (*width_screen < 0)
- *width_screen = char_size;
- }
- return (char *)string + char_size;
- }
+ return (char *)string;
+ break;
}
}
@@ -476,10 +384,11 @@ gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
*/
void
-gui_chat_display_word_raw (t_gui_window *window, char *string, int display)
+gui_chat_display_word_raw (struct t_gui_window *window, char *string,
+ int display)
{
- char *prev_char, *next_char, saved_char, *output;
-
+ char *next_char, *output, utf_char[16];
+
if (display)
wmove (GUI_CURSES(window)->win_chat,
window->win_chat_cursor_y,
@@ -487,27 +396,30 @@ gui_chat_display_word_raw (t_gui_window *window, char *string, int display)
while (string && string[0])
{
- next_char = gui_chat_word_get_next_char (window, (unsigned char *)string, 1, NULL);
- if (!next_char)
+ string = gui_chat_string_next_char (window,
+ (unsigned char *)string, 1);
+ if (!string)
return;
- prev_char = utf8_prev_char (string, next_char);
- if (display && prev_char)
+ next_char = utf8_next_char (string);
+ if (display && next_char)
{
- saved_char = next_char[0];
- next_char[0] = '\0';
- if ((((unsigned char)(prev_char[0]) == 146)
- || ((unsigned char)(prev_char[0]) == 0x7F))
- && (!prev_char[1]))
+ memcpy (utf_char, string, next_char - string);
+ utf_char[next_char - string] = '\0';
+ if ((((unsigned char)(utf_char[0]) == 146)
+ || ((unsigned char)(utf_char[0]) == 0x7F))
+ && (!utf_char[1]))
+ {
wprintw (GUI_CURSES(window)->win_chat, ".");
+ }
else
{
- output = weechat_iconv_from_internal (NULL, prev_char);
- wprintw (GUI_CURSES(window)->win_chat, "%s", (output) ? output : prev_char);
+ output = string_iconv_from_internal (NULL, utf_char);
+ wprintw (GUI_CURSES(window)->win_chat,
+ "%s", (output) ? output : utf_char);
if (output)
free (output);
}
- next_char[0] = saved_char;
}
string = next_char;
@@ -519,11 +431,11 @@ gui_chat_display_word_raw (t_gui_window *window, char *string, int display)
*/
void
-gui_chat_display_word (t_gui_window *window,
- t_gui_line *line,
- char *data,
- char *end_offset,
- int num_lines, int count, int *lines_displayed, int simulate)
+gui_chat_display_word (struct t_gui_window *window,
+ struct t_gui_line *line,
+ char *data, char *end_offset,
+ int prefix, int num_lines, int count,
+ int *lines_displayed, int simulate)
{
char *end_line, saved_char_end, saved_char;
int pos_saved_char, chars_to_display, num_displayed;
@@ -535,7 +447,7 @@ gui_chat_display_word (t_gui_window *window,
end_line = data + strlen (data);
- if (end_offset[0])
+ if (end_offset && end_offset[0])
{
saved_char_end = end_offset[1];
end_offset[1] = '\0';
@@ -549,7 +461,7 @@ gui_chat_display_word (t_gui_window *window,
while (data && data[0])
{
/* insert spaces for align text under time/nick */
- length_align = GUI_LINE_LENGTH_ALIGN(line);
+ length_align = gui_chat_get_line_align (window->buffer, line);
if ((length_align > 0) &&
(window->win_chat_cursor_x == 0) &&
(*lines_displayed > 0) &&
@@ -566,13 +478,13 @@ gui_chat_display_word (t_gui_window *window,
window->win_chat_cursor_x += length_align;
}
- chars_to_display = gui_word_strlen (window, data);
+ chars_to_display = gui_chat_strlen_screen (data);
/* too long for current line */
if (window->win_chat_cursor_x + chars_to_display > gui_chat_get_real_width (window))
{
num_displayed = gui_chat_get_real_width (window) - window->win_chat_cursor_x;
- pos_saved_char = gui_word_real_pos (window, data, num_displayed);
+ pos_saved_char = gui_chat_string_real_pos (data, num_displayed);
saved_char = data[pos_saved_char];
data[pos_saved_char] = '\0';
if (!simulate)
@@ -601,14 +513,14 @@ gui_chat_display_word (t_gui_window *window,
window->win_chat_cursor_x += num_displayed;
/* display new line? */
- if ((data >= end_line) ||
+ if ((!prefix && (data >= end_line)) ||
(((simulate) ||
- (window->win_chat_cursor_y <= window->win_chat_height - 1)) &&
- (window->win_chat_cursor_x > (gui_chat_get_real_width (window) - 1))))
+ (window->win_chat_cursor_y <= window->win_chat_height - 1)) &&
+ (window->win_chat_cursor_x > (gui_chat_get_real_width (window) - 1))))
gui_chat_display_new_line (window, num_lines, count,
lines_displayed, simulate);
- if ((data >= end_line) ||
+ if ((!prefix && (data >= end_line)) ||
((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height)))
data = NULL;
}
@@ -618,61 +530,117 @@ gui_chat_display_word (t_gui_window *window,
}
/*
- * gui_chat_get_word_info: returns info about next word: beginning, end, length
+ * gui_chat_display_time_and_prefix: display time and prefix for a line
*/
void
-gui_chat_get_word_info (t_gui_window *window,
- char *data,
- int *word_start_offset, int *word_end_offset,
- int *word_length_with_spaces, int *word_length)
+gui_chat_display_time_and_prefix (struct t_gui_window *window,
+ struct t_gui_line *line,
+ int num_lines, int count,
+ int *lines_displayed,
+ int simulate)
{
- char *start_data, *prev_char, *next_char;
- int leading_spaces, char_size;
-
- *word_start_offset = 0;
- *word_end_offset = 0;
- *word_length_with_spaces = 0;
- *word_length = 0;
+ char str_space[] = " ", str_plus[] = "+";
+ int i, length_allowed, num_spaces;
- start_data = data;
+ /* display time */
+ if (line->str_time && line->str_time[0])
+ {
+ if (!simulate)
+ gui_chat_reset_style (window);
+
+ gui_chat_display_word (window, line, line->str_time,
+ NULL, 1, num_lines, count, lines_displayed,
+ simulate);
+ gui_chat_display_word (window, line, str_space,
+ NULL, 1, num_lines, count, lines_displayed,
+ simulate);
+ }
- leading_spaces = 1;
- while (data && data[0])
+ /* display prefix */
+ if (line->prefix
+ && (line->prefix[0]
+ || (cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE)))
{
- next_char = gui_chat_word_get_next_char (window, (unsigned char *)data, 0, NULL);
- if (next_char)
+ if (!simulate)
+ gui_chat_reset_style (window);
+
+ if (cfg_look_prefix_align_max > 0)
+ {
+ length_allowed =
+ (window->buffer->prefix_max_length <= cfg_look_prefix_align_max) ?
+ window->buffer->prefix_max_length : cfg_look_prefix_align_max;
+ }
+ else
+ length_allowed = window->buffer->prefix_max_length;
+
+ num_spaces = length_allowed - line->prefix_length;
+
+ if (cfg_look_prefix_align == CFG_LOOK_PREFIX_ALIGN_RIGHT)
{
- prev_char = utf8_prev_char (data, next_char);
- if (prev_char)
+ for (i = 0; i < num_spaces; i++)
{
- if (prev_char[0] != ' ')
- {
- if (leading_spaces)
- *word_start_offset = prev_char - start_data;
- leading_spaces = 0;
- char_size = next_char - prev_char;
- *word_end_offset = next_char - start_data - 1;
- (*word_length_with_spaces) += char_size;
- (*word_length) += char_size;
- }
- else
- {
- if (leading_spaces)
- (*word_length_with_spaces)++;
- else
- {
- *word_end_offset = prev_char - start_data - 1;
- return;
- }
- }
- data = next_char;
+ gui_chat_display_word (window, line, str_space,
+ NULL, 1, num_lines, count,
+ lines_displayed,simulate);
}
}
+ /* not enough space to display full prefix ? => truncate it! */
+ if ((cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE)
+ && (num_spaces < 0))
+ {
+ gui_chat_display_word (window, line, line->prefix,
+ line->prefix +
+ gui_chat_string_real_pos (line->prefix,
+ length_allowed - 1),
+ 1, num_lines, count, lines_displayed,
+ simulate);
+ }
else
{
- *word_end_offset = data + strlen (data) - start_data - 1;
- return;
+ gui_chat_display_word (window, line, line->prefix,
+ NULL, 1, num_lines, count, lines_displayed,
+ simulate);
+ }
+
+ if (!simulate)
+ gui_chat_reset_style (window);
+
+ if (cfg_look_prefix_align == CFG_LOOK_PREFIX_ALIGN_LEFT)
+ {
+ for (i = 0; i < num_spaces; i++)
+ {
+ gui_chat_display_word (window, line, str_space,
+ NULL, 1, num_lines, count, lines_displayed,
+ simulate);
+ }
+ }
+ if ((cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE)
+ && (num_spaces < 0))
+ {
+ if (!simulate)
+ gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_PREFIX_MORE);
+ gui_chat_display_word (window, line, str_plus,
+ NULL, 1, num_lines, count, lines_displayed,
+ simulate);
+ }
+ else
+ {
+ gui_chat_display_word (window, line, str_space,
+ NULL, 1, num_lines, count, lines_displayed,
+ simulate);
+ }
+ if ((cfg_look_prefix_align != CFG_LOOK_PREFIX_ALIGN_NONE)
+ && (cfg_look_prefix_suffix && cfg_look_prefix_suffix[0]))
+ {
+ if (!simulate)
+ gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_PREFIX_SUFFIX);
+ gui_chat_display_word (window, line, cfg_look_prefix_suffix,
+ NULL, 1, num_lines, count,
+ lines_displayed, simulate);
+ gui_chat_display_word (window, line, str_space,
+ NULL, 1, num_lines, count,
+ lines_displayed, simulate);
}
}
}
@@ -689,14 +657,14 @@ gui_chat_get_word_info (t_gui_window *window,
*/
int
-gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count,
- int simulate)
+gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
+ int count, int simulate)
{
- int num_lines, x, y, lines_displayed;
+ int num_lines, x, y, lines_displayed, line_align;
int read_marker_x, read_marker_y;
int word_start_offset, word_end_offset;
int word_length_with_spaces, word_length;
- char *ptr_data, *ptr_end_offset, *next_char, *prev_char;
+ char *ptr_data, *ptr_end_offset, *next_char;
char *ptr_style, saved_char;
if (simulate)
@@ -719,95 +687,106 @@ gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count,
}
/* calculate marker position (maybe not used for this line!) */
- if (line->ofs_after_date > 0)
- {
- saved_char = line->data[line->ofs_after_date - 1];
- line->data[line->ofs_after_date - 1] = '\0';
- read_marker_x = x + gui_word_strlen (NULL, line->data);
- line->data[line->ofs_after_date - 1] = saved_char;
- }
+ if (line->str_time)
+ read_marker_x = x + gui_chat_strlen_screen (line->str_time);
else
read_marker_x = x;
read_marker_y = y;
+ lines_displayed = 0;
+
+ /* display time and prefix */
+ gui_chat_display_time_and_prefix (window, line, num_lines, count,
+ &lines_displayed, simulate);
+
/* reset color & style for a new line */
- gui_chat_reset_style (window);
+ if (!simulate)
+ gui_chat_reset_style (window);
- lines_displayed = 0;
- ptr_data = line->data;
- while (ptr_data && ptr_data[0])
+ if (!line->message || !line->message[0])
+ gui_chat_display_new_line (window, num_lines, count,
+ &lines_displayed, simulate);
+ else
{
- gui_chat_get_word_info (window,
- ptr_data,
- &word_start_offset,
- &word_end_offset,
- &word_length_with_spaces, &word_length);
-
- ptr_end_offset = ptr_data + word_end_offset;
-
- if (word_length > 0)
+ ptr_data = line->message;
+ while (ptr_data && ptr_data[0])
{
- /* spaces + word too long for current line but ok for next line */
- if ((window->win_chat_cursor_x + word_length_with_spaces > gui_chat_get_real_width (window))
- && (word_length <= gui_chat_get_real_width (window) - GUI_LINE_LENGTH_ALIGN(line)))
+ gui_chat_get_word_info (window,
+ ptr_data,
+ &word_start_offset,
+ &word_end_offset,
+ &word_length_with_spaces, &word_length);
+
+ ptr_end_offset = ptr_data + word_end_offset;
+
+ if (word_length > 0)
{
- gui_chat_display_new_line (window, num_lines, count,
- &lines_displayed, simulate);
- /* apply styles before jumping to start of word */
- if (!simulate && (word_start_offset > 0))
+ /* spaces + word too long for current line but ok for next line */
+ line_align = gui_chat_get_line_align (window->buffer, line);
+ if ((window->win_chat_cursor_x + word_length_with_spaces > gui_chat_get_real_width (window))
+ && (word_length <= gui_chat_get_real_width (window) - line_align))
{
- saved_char = ptr_data[word_start_offset];
- ptr_data[word_start_offset] = '\0';
- ptr_style = ptr_data;
- while ((ptr_style = gui_chat_word_get_next_char (window,
- (unsigned char *)ptr_style,
- 1, NULL)) != NULL)
+ gui_chat_display_new_line (window, num_lines, count,
+ &lines_displayed, simulate);
+ /* apply styles before jumping to start of word */
+ if (!simulate && (word_start_offset > 0))
{
- /* loop until no style/char available */
+ saved_char = ptr_data[word_start_offset];
+ ptr_data[word_start_offset] = '\0';
+ ptr_style = ptr_data;
+ while (ptr_style)
+ {
+ /* loop until no style/char available */
+ ptr_style = gui_chat_string_next_char (window,
+ (unsigned char *)ptr_style,
+ 1);
+ if (!ptr_style)
+ break;
+ ptr_style = utf8_next_char (ptr_style);
+ }
+ ptr_data[word_start_offset] = saved_char;
}
- ptr_data[word_start_offset] = saved_char;
+ /* jump to start of word */
+ ptr_data += word_start_offset;
}
- /* jump to start of word */
- ptr_data += word_start_offset;
- }
-
- /* display word */
- gui_chat_display_word (window, line, ptr_data,
- ptr_end_offset,
- num_lines, count, &lines_displayed, simulate);
-
- if ((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height))
- ptr_data = NULL;
- else
- {
- /* move pointer after end of word */
- ptr_data = ptr_end_offset + 1;
- if (*(ptr_data - 1) == '\0')
- ptr_data = NULL;
- if (window->win_chat_cursor_x == 0)
+ /* display word */
+ gui_chat_display_word (window, line, ptr_data,
+ ptr_end_offset,
+ 0, num_lines, count, &lines_displayed,
+ simulate);
+
+ if ((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height))
+ ptr_data = NULL;
+ else
{
- while (ptr_data && (ptr_data[0] == ' '))
+ /* move pointer after end of word */
+ ptr_data = ptr_end_offset + 1;
+ if (*(ptr_data - 1) == '\0')
+ ptr_data = NULL;
+
+ if (window->win_chat_cursor_x == 0)
{
- next_char = gui_chat_word_get_next_char (window,
- (unsigned char *)ptr_data,
- 0, NULL);
- if (!next_char)
- break;
- prev_char = utf8_prev_char (ptr_data, next_char);
- if (prev_char && (prev_char[0] == ' '))
- ptr_data = next_char;
- else
- break;
+ while (ptr_data && (ptr_data[0] == ' '))
+ {
+ next_char = utf8_next_char (ptr_data);
+ if (!next_char)
+ break;
+ ptr_data = gui_chat_string_next_char (window,
+ (unsigned char *)next_char,
+ 0);
+ if (!ptr_data || (ptr_data[0] != ' '))
+ break;
+ }
}
}
}
- }
- else
- {
- gui_chat_display_new_line (window, num_lines, count,
- &lines_displayed, simulate);
- ptr_data = NULL;
+ else
+ {
+ gui_chat_display_new_line (window, num_lines, count,
+ &lines_displayed, simulate);
+ ptr_data = NULL;
+ }
}
}
@@ -823,11 +802,13 @@ gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count,
/* display marker if line is matching user search */
if (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
{
- if (gui_buffer_line_search (line, window->buffer->input_buffer,
- window->buffer->text_search_exact))
+ if (gui_chat_line_search (line, window->buffer->input_buffer,
+ window->buffer->text_search_exact))
{
- gui_chat_set_weechat_color (window, GUI_COLOR_WIN_CHAT_READ_MARKER);
- mvwprintw (GUI_CURSES(window)->win_chat, read_marker_y, read_marker_x,
+ gui_chat_set_weechat_color (window,
+ GUI_COLOR_CHAT_READ_MARKER);
+ mvwprintw (GUI_CURSES(window)->win_chat,
+ read_marker_y, read_marker_x,
"%c", cfg_look_read_marker[0]);
}
}
@@ -837,8 +818,10 @@ gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count,
if (window->buffer->last_read_line &&
(window->buffer->last_read_line == line->prev_line))
{
- gui_chat_set_weechat_color (window, GUI_COLOR_WIN_CHAT_READ_MARKER);
- mvwprintw (GUI_CURSES(window)->win_chat, read_marker_y, read_marker_x,
+ gui_chat_set_weechat_color (window,
+ GUI_COLOR_CHAT_READ_MARKER);
+ mvwprintw (GUI_CURSES(window)->win_chat,
+ read_marker_y, read_marker_x,
"%c", cfg_look_read_marker[0]);
}
}
@@ -854,7 +837,7 @@ gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count,
*/
void
-gui_chat_calculate_line_diff (t_gui_window *window, t_gui_line **line,
+gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **line,
int *line_pos, int difference)
{
int backward, current_size;
@@ -952,20 +935,21 @@ gui_chat_calculate_line_diff (t_gui_window *window, t_gui_line **line,
*/
void
-gui_chat_draw (t_gui_buffer *buffer, int erase)
+gui_chat_draw (struct t_gui_buffer *buffer, int erase)
{
- t_gui_window *ptr_win;
- t_gui_line *ptr_line;
- t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc;
+ struct t_gui_window *ptr_win;
+ struct t_gui_line *ptr_line;
+ /*t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc;*/
char format_empty[32];
- int i, j, line_pos, count, num_bars;
+ int i, line_pos, count;
+ /*int j, num_bars;
unsigned long pct_complete;
char *unit_name[] = { N_("bytes"), N_("KB"), N_("MB"), N_("GB") };
char *unit_format[] = { "%.0f", "%.1f", "%.02f", "%.02f" };
float unit_divide[] = { 1, 1024, 1024*1024, 1024*1024*1024 };
int num_unit;
char format[32], date[128], *buf;
- struct tm *date_tmp;
+ struct tm *date_tmp;*/
if (!gui_ok)
return;
@@ -976,18 +960,21 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
{
if (erase)
{
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, GUI_COLOR_WIN_CHAT);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat,
+ GUI_COLOR_CHAT);
snprintf (format_empty, 32, "%%-%ds", ptr_win->win_chat_width);
for (i = 0; i < ptr_win->win_chat_height; i++)
{
- mvwprintw (GUI_CURSES(ptr_win)->win_chat, i, 0, format_empty, " ");
+ mvwprintw (GUI_CURSES(ptr_win)->win_chat, i, 0,
+ format_empty, " ");
}
}
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat, GUI_COLOR_WIN_CHAT);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat,
+ GUI_COLOR_CHAT);
- if (buffer->type == GUI_BUFFER_TYPE_DCC)
+ /*if (buffer->type == GUI_BUFFER_TYPE_DCC)
{
i = 0;
dcc_first = (ptr_win->dcc_first) ? (t_irc_dcc *) ptr_win->dcc_first : irc_dcc_list;
@@ -997,7 +984,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
if (i >= ptr_win->win_chat_height - 1)
break;
- /* nickname and filename */
+ // nickname and filename
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat,
(ptr_dcc == dcc_selected) ?
GUI_COLOR_DCC_SELECTED : GUI_COLOR_WIN_CHAT);
@@ -1019,7 +1006,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
ptr_dcc->filename_suffix);
}
- /* status */
+ // status
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat,
(ptr_dcc == dcc_selected) ?
GUI_COLOR_DCC_SELECTED : GUI_COLOR_WIN_CHAT);
@@ -1034,7 +1021,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
if (buf)
free (buf);
- /* other infos */
+ // other infos
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_chat,
(ptr_dcc == dcc_selected) ?
GUI_COLOR_DCC_SELECTED : GUI_COLOR_WIN_CHAT);
@@ -1121,7 +1108,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
i += 2;
}
}
- else
+ else*/
{
ptr_win->win_chat_cursor_x = 0;
ptr_win->win_chat_cursor_y = 0;
@@ -1198,7 +1185,7 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
*/
void
-gui_chat_draw_line (t_gui_buffer *buffer, t_gui_line *line)
+gui_chat_draw_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
{
/* This function does nothing in Curses GUI,
line will be displayed by gui_buffer_draw_chat() */
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c
index de88c56b6..35bee21a4 100644
--- a/src/gui/curses/gui-curses-color.c
+++ b/src/gui/curses/gui-curses-color.c
@@ -27,54 +27,98 @@
#include <string.h>
#include <ctype.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/utf8.h"
-#include "../../common/util.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-string.h"
+#include "../../core/wee-utf8.h"
+#include "../gui-color.h"
#include "gui-curses.h"
-t_gui_color gui_weechat_colors[] =
-{ { -1, 0, 0, "default" },
- { WEECHAT_COLOR_BLACK, 0, 0, "black" },
- { WEECHAT_COLOR_RED, 0, 0, "red" },
- { WEECHAT_COLOR_RED, 0, A_BOLD, "lightred" },
- { WEECHAT_COLOR_GREEN, 0, 0, "green" },
- { WEECHAT_COLOR_GREEN, 0, A_BOLD, "lightgreen" },
- { WEECHAT_COLOR_YELLOW, 0, 0, "brown" },
- { WEECHAT_COLOR_YELLOW, 0, A_BOLD, "yellow" },
- { WEECHAT_COLOR_BLUE, 0, 0, "blue" },
- { WEECHAT_COLOR_BLUE, 0, A_BOLD, "lightblue" },
- { WEECHAT_COLOR_MAGENTA, 0, 0, "magenta" },
- { WEECHAT_COLOR_MAGENTA, 0, A_BOLD, "lightmagenta" },
- { WEECHAT_COLOR_CYAN, 0, 0, "cyan" },
- { WEECHAT_COLOR_CYAN, 0, A_BOLD, "lightcyan" },
- { WEECHAT_COLOR_WHITE, 0, A_BOLD, "white" },
- { 0, 0, 0, NULL }
+struct t_gui_color gui_weechat_colors[] =
+{ { -1, 0, 0, "default" },
+ { COLOR_BLACK, 0, 0, "black" },
+ { COLOR_RED, 0, 0, "red" },
+ { COLOR_RED, 0, A_BOLD, "lightred" },
+ { COLOR_GREEN, 0, 0, "green" },
+ { COLOR_GREEN, 0, A_BOLD, "lightgreen" },
+ { COLOR_YELLOW, 0, 0, "brown" },
+ { COLOR_YELLOW, 0, A_BOLD, "yellow" },
+ { COLOR_BLUE, 0, 0, "blue" },
+ { COLOR_BLUE, 0, A_BOLD, "lightblue" },
+ { COLOR_MAGENTA, 0, 0, "magenta" },
+ { COLOR_MAGENTA, 0, A_BOLD, "lightmagenta" },
+ { COLOR_CYAN, 0, 0, "cyan" },
+ { COLOR_CYAN, 0, A_BOLD, "lightcyan" },
+ { COLOR_WHITE, 0, A_BOLD, "white" },
+ { 0, 0, 0, NULL }
};
-int gui_irc_colors[GUI_NUM_IRC_COLORS][2] =
-{ { /* 0 */ WEECHAT_COLOR_WHITE, A_BOLD },
- { /* 1 */ WEECHAT_COLOR_BLACK, 0 },
- { /* 2 */ WEECHAT_COLOR_BLUE, 0 },
- { /* 3 */ WEECHAT_COLOR_GREEN, 0 },
- { /* 4 */ WEECHAT_COLOR_RED, A_BOLD },
- { /* 5 */ WEECHAT_COLOR_RED, 0 },
- { /* 6 */ WEECHAT_COLOR_MAGENTA, 0 },
- { /* 7 */ WEECHAT_COLOR_YELLOW, 0 },
- { /* 8 */ WEECHAT_COLOR_YELLOW, A_BOLD },
- { /* 9 */ WEECHAT_COLOR_GREEN, A_BOLD },
- { /* 10 */ WEECHAT_COLOR_CYAN, 0 },
- { /* 11 */ WEECHAT_COLOR_CYAN, A_BOLD },
- { /* 12 */ WEECHAT_COLOR_BLUE, A_BOLD },
- { /* 13 */ WEECHAT_COLOR_MAGENTA, A_BOLD },
- { /* 14 */ WEECHAT_COLOR_WHITE, 0 },
- { /* 15 */ WEECHAT_COLOR_WHITE, A_BOLD }
-};
+struct t_gui_color *gui_color[GUI_NUM_COLORS];
+
+
+/*
+ * gui_color_search: search a color by name
+ * Return: number of color in WeeChat colors table
+ */
-t_gui_color *gui_color[GUI_NUM_COLORS];
+int
+gui_color_search (char *color_name)
+{
+ int i;
+
+ for (i = 0; gui_weechat_colors[i].string; i++)
+ {
+ if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
+ return i;
+ }
+ /* color not found */
+ return -1;
+}
+
+/*
+ * gui_color_get_fg_bg: get foreground and background from a string with format:
+ * foreground,background
+ */
+
+/*void
+gui_color_get_fg_bg (char *string, char **fg, char **bg)
+{
+ char *pos, *pos_end_fg;
+
+ pos = strchr (string, ',');
+ if (pos)
+ {
+ if (pos > string)
+ {
+ pos_end_fg = pos - 1;
+ while ((pos_end_fg > string) && (pos_end_fg == ' '))
+ {
+ pos_end_fg--;
+ }
+ *fg = strndup (string, pos_end_fg - string + 1);
+ }
+ else
+ *fg = strudp ("default");
+ if (pos[1])
+ {
+ pos++;
+ while (pos[0] && (pos[0] == ' '))
+ {
+ pos++;
+ }
+ *bg = strdup (pos);
+ }
+ else
+ *bg = strdup ("default");
+ }
+ else
+ {
+ *fg = strdup (string);
+ *bg = strdup ("default");
+ }
+}*/
/*
* gui_color_assign: assign a WeeChat color (read from config)
@@ -89,7 +133,7 @@ gui_color_assign (int *color, char *color_name)
i = 0;
while (gui_weechat_colors[i].string)
{
- if (ascii_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
+ if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
{
*color = i;
return 1;
@@ -102,324 +146,117 @@ gui_color_assign (int *color, char *color_name)
}
/*
- * gui_color_get_name: get color name
- */
-
-char *
-gui_color_get_name (int num_color)
-{
- return gui_weechat_colors[num_color].string;
-}
-
-/*
- * gui_color_decode: parses a message (coming from IRC server),
- * if keep_colors == 0: remove any color/style in message
- * otherwise change colors by internal WeeChat color codes
- * if wkeep_eechat_attr == 0: remove any weechat color/style attribute
- * After use, string returned has to be free()
+ * gui_color_assign: assign a WeeChat color (read from config)
*/
-unsigned char *
-gui_color_decode (unsigned char *string, int keep_irc_colors, int keep_weechat_attr)
+/*void
+gui_color_assign (t_gui_color **color, char *fg_and_bg)
{
- unsigned char *out;
- int out_length, out_pos, length;
- char str_fg[3], str_bg[3];
- int fg, bg, attr;
-
- out_length = (strlen ((char *)string) * 2) + 1;
- out = (unsigned char *)malloc (out_length);
- if (!out)
- return NULL;
+ char *color_fg, *color_bg, *color_fg2, *color_bg2;
+ int value_fg, value_bg;
+ t_config_option *ptr_option;
- out_pos = 0;
- while (string && string[0] && (out_pos < out_length - 1))
+ if (!(*color))
{
- switch (string[0])
- {
- case GUI_ATTR_BOLD_CHAR:
- case GUI_ATTR_RESET_CHAR:
- case GUI_ATTR_FIXED_CHAR:
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
- case GUI_ATTR_ITALIC_CHAR:
- case GUI_ATTR_UNDERLINE_CHAR:
- if (keep_irc_colors)
- out[out_pos++] = string[0];
- string++;
- break;
- case GUI_ATTR_COLOR_CHAR:
- string++;
- str_fg[0] = '\0';
- str_bg[0] = '\0';
- if (isdigit (string[0]))
- {
- str_fg[0] = string[0];
- str_fg[1] = '\0';
- string++;
- if (isdigit (string[0]))
- {
- str_fg[1] = string[0];
- str_fg[2] = '\0';
- string++;
- }
- }
- if (string[0] == ',')
- {
- string++;
- if (isdigit (string[0]))
- {
- str_bg[0] = string[0];
- str_bg[1] = '\0';
- string++;
- if (isdigit (string[0]))
- {
- str_bg[1] = string[0];
- str_bg[2] = '\0';
- string++;
- }
- }
- }
- if (keep_irc_colors)
- {
- if (!str_fg[0] && !str_bg[0])
- out[out_pos++] = GUI_ATTR_COLOR_CHAR;
- else
- {
- attr = 0;
- if (str_fg[0])
- {
- sscanf (str_fg, "%d", &fg);
- fg %= GUI_NUM_IRC_COLORS;
- attr |= gui_irc_colors[fg][1];
- }
- if (str_bg[0])
- {
- sscanf (str_bg, "%d", &bg);
- bg %= GUI_NUM_IRC_COLORS;
- attr |= gui_irc_colors[bg][1];
- }
- if (attr & A_BOLD)
- {
- out[out_pos++] = GUI_ATTR_WEECHAT_SET_CHAR;
- out[out_pos++] = GUI_ATTR_BOLD_CHAR;
- }
- else
- {
- out[out_pos++] = GUI_ATTR_WEECHAT_REMOVE_CHAR;
- out[out_pos++] = GUI_ATTR_BOLD_CHAR;
- }
- out[out_pos++] = GUI_ATTR_COLOR_CHAR;
- if (str_fg[0])
- {
- out[out_pos++] = (gui_irc_colors[fg][0] / 10) + '0';
- out[out_pos++] = (gui_irc_colors[fg][0] % 10) + '0';
- }
- if (str_bg[0])
- {
- out[out_pos++] = ',';
- out[out_pos++] = (gui_irc_colors[bg][0] / 10) + '0';
- out[out_pos++] = (gui_irc_colors[bg][0] % 10) + '0';
- }
- }
- }
- break;
- case GUI_ATTR_WEECHAT_COLOR_CHAR:
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]) && isdigit (string[1]))
- {
- if (keep_weechat_attr)
- {
- out[out_pos++] = string[0];
- out[out_pos++] = string[1];
- }
- string += 2;
- }
- break;
- case GUI_ATTR_WEECHAT_SET_CHAR:
- case GUI_ATTR_WEECHAT_REMOVE_CHAR:
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- if (string[0])
- {
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- }
- break;
- case GUI_ATTR_WEECHAT_RESET_CHAR:
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- break;
- default:
- length = utf8_char_size ((char *)string);
- if (length == 0)
- length = 1;
- memcpy (out + out_pos, string, length);
- out_pos += length;
- string += length;
- }
+ *color = (t_gui_color *)malloc (sizeof (t_gui_color));
+ if (!(*color))
+ return;
+ *color->foreground = 0;
+ *color->background = 0;
+ *color->attributes = 0;
+ *color->string = NULL;
}
- out[out_pos] = '\0';
- return out;
-}
-/*
- * gui_color_decode_for_user_entry: parses a message (coming from IRC server),
- * and replaces colors/bold/.. by ^C, ^B, ..
- * After use, string returned has to be free()
- */
+ gui_color_get_fg_bg (fg_and_bg, &color_fg, &color_bg);
-unsigned char *
-gui_color_decode_for_user_entry (unsigned char *string)
-{
- unsigned char *out;
- int out_length, out_pos, length;
-
- out_length = (strlen ((char *)string) * 2) + 1;
- out = (unsigned char *)malloc (out_length);
- if (!out)
- return NULL;
-
- out_pos = 0;
- while (string && string[0] && (out_pos < out_length - 1))
+ if (color_fg && color_bg)
{
- switch (string[0])
+ // look for curses colors in table
+ value_fg = gui_color_search (color_fg);
+ value_bg = gui_color_search (color_bg);
+
+ if (value_fg < 0)
{
- case GUI_ATTR_BOLD_CHAR:
- out[out_pos++] = 0x02; /* ^B */
- string++;
- break;
- case GUI_ATTR_FIXED_CHAR:
- string++;
- break;
- case GUI_ATTR_RESET_CHAR:
- out[out_pos++] = 0x0F; /* ^O */
- string++;
- break;
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
- out[out_pos++] = 0x12; /* ^R */
- string++;
- break;
- case GUI_ATTR_ITALIC_CHAR:
- string++;
- break;
- case GUI_ATTR_UNDERLINE_CHAR:
- out[out_pos++] = 0x15; /* ^U */
- string++;
- break;
- case GUI_ATTR_COLOR_CHAR:
- out[out_pos++] = 0x03; /* ^C */
- string++;
- break;
- default:
- length = utf8_char_size ((char *)string);
- if (length == 0)
- length = 1;
- memcpy (out + out_pos, string, length);
- out_pos += length;
- string += length;
+ // it's not a known value for foreground, maybe it's reference to
+ // another config option ?
+ value_fg = 0;
+ ptr_option = config_option_section_option_search (weechat_config_sections,
+ weechat_config_options,
+ color_fg);
+ if (ptr_option && *(ptr_option->ptr_color)
+ && *(ptr_option->ptr_string))
+ {
+ gui_color_get_fg_bg (*(ptr_option->ptr_string),
+ &color_fg2, &color_bg2);
+ if (color_fg2)
+ value_fg = gui_color_search (color_fg2);
+
+ if (color_fg2)
+ free (color_fg2);
+ if (color_bg2)
+ free (color_bg2);
+ }
}
+
+ if (value_bg < 0)
+ {
+ // it's not a known value for background, maybe it's reference to
+ // another config option ?
+ value_bg = 0;
+ ptr_option = config_option_section_option_search (weechat_config_sections,
+ weechat_config_options,
+ color_bg);
+ if (ptr_option && *(ptr_option->ptr_color)
+ && *(ptr_option->ptr_string))
+ {
+ gui_color_get_fg_bg (*(ptr_option->ptr_string),
+ &color_fg2, &color_bg2);
+ if (color_bg2)
+ value_bg = gui_color_search (color_bg2);
+
+ if (color_fg2)
+ free (color_fg2);
+ if (color_bg2)
+ free (color_bg2);
+ }
+ }
+
+ *color->foreground = gui_weechat_colors[value_fg].foreground;
+ *color->background = gui_weechat_colors[value_bg].background;
+ *color->attributes = gui_weechat_colors[value_fg].attributes;
+
+ if (*color->string)
+ free (*color->string);
+ *color->string = (char *)malloc (4);
+ if (*color->string)
+ snprintf (*color->string, 4,
+ "%s%02d",
+ GUI_COLOR_COLOR_STR, number);
}
- out[out_pos] = '\0';
- return out;
-}
+ else
+ {
+ *color->foreground = 0;
+ *color->background = 0;
+ *color->attributes = 0;
+ if (*color->string)
+ free (*color->string);
+ *color->string = NULL;
+ }
+
+ if (color_fg)
+ free (color_fg);
+ if (color_bg)
+ free (color_bg);
+}*/
/*
- * gui_color_encode: parses a message (entered by user), and
- * encode special chars (^Cb, ^Cc, ..) in IRC colors
- * if keep_colors == 0: remove any color/style in message
- * otherwise: keep colors
- * After use, string returned has to be free()
+ * gui_color_get_name: get color name
*/
-unsigned char *
-gui_color_encode (unsigned char *string, int keep_colors)
+char *
+gui_color_get_name (int num_color)
{
- unsigned char *out;
- int out_length, out_pos, length;
-
- out_length = (strlen ((char *)string) * 2) + 1;
- out = (unsigned char *)malloc (out_length);
- if (!out)
- return NULL;
-
- out_pos = 0;
- while (string && string[0] && (out_pos < out_length - 1))
- {
- switch (string[0])
- {
- case 0x02: /* ^B */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_BOLD_CHAR;
- string++;
- break;
- case 0x03: /* ^C */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_COLOR_CHAR;
- string++;
- if (isdigit (string[0]))
- {
- if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
- {
- if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- }
- }
- if (string[0] == ',')
- {
- if (keep_colors)
- out[out_pos++] = ',';
- string++;
- if (isdigit (string[0]))
- {
- if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
- {
- if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- }
- }
- }
- break;
- case 0x0F: /* ^O */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_RESET_CHAR;
- string++;
- break;
- case 0x12: /* ^R */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
- string++;
- break;
- case 0x15: /* ^U */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
- string++;
- break;
- default:
- length = utf8_char_size ((char *)string);
- if (length == 0)
- length = 1;
- memcpy (out + out_pos, string, length);
- out_pos += length;
- string += length;
- }
- }
- out[out_pos] = '\0';
- return out;
+ return gui_weechat_colors[num_color].string;
}
/*
@@ -428,12 +265,12 @@ gui_color_encode (unsigned char *string, int keep_colors)
* given with foreground color, with a OR)
*/
-t_gui_color *
+struct t_gui_color *
gui_color_build (int number, int foreground, int background)
{
- t_gui_color *new_color;
+ struct t_gui_color *new_color;
- new_color = (t_gui_color *)malloc (sizeof (t_gui_color));
+ new_color = (struct t_gui_color *)malloc (sizeof (struct t_gui_color));
if (!new_color)
return NULL;
@@ -444,7 +281,7 @@ gui_color_build (int number, int foreground, int background)
if (new_color->string)
snprintf (new_color->string, 4,
"%s%02d",
- GUI_ATTR_WEECHAT_COLOR_STR, number);
+ GUI_COLOR_COLOR_STR, number);
return new_color;
}
@@ -459,7 +296,7 @@ gui_color_get_pair (int num_color)
int fg, bg;
if ((num_color < 0) || (num_color > GUI_NUM_COLORS - 1))
- return WEECHAT_COLOR_WHITE;
+ return COLOR_WHITE;
fg = gui_color[num_color]->foreground;
bg = gui_color[num_color]->background;
@@ -468,7 +305,7 @@ gui_color_get_pair (int num_color)
&& ((bg == -1) || (bg == 99)))
return 63;
if ((fg == -1) || (fg == 99))
- fg = WEECHAT_COLOR_WHITE;
+ fg = COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
@@ -483,19 +320,18 @@ void
gui_color_init_pairs ()
{
int i;
- char shift_colors[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
if (has_colors ())
{
for (i = 1; i < 64; i++)
- init_pair (i, shift_colors[i % 8], (i < 8) ? -1 : shift_colors[i / 8]);
+ init_pair (i, i % 8, (i < 8) ? -1 : i / 8);
/* disable white on white, replaced by black on white */
init_pair (63, -1, -1);
/* white on default bg is default (-1) */
- if (!cfg_col_real_white)
- init_pair (WEECHAT_COLOR_WHITE, -1, -1);
+ if (!cfg_look_color_real_white)
+ init_pair (COLOR_WHITE, -1, -1);
}
}
@@ -508,66 +344,75 @@ gui_color_init_weechat ()
{
int i;
- gui_color[GUI_COLOR_WIN_SEPARATOR] = gui_color_build (GUI_COLOR_WIN_SEPARATOR, cfg_col_separator, cfg_col_separator);
- gui_color[GUI_COLOR_WIN_TITLE] = gui_color_build (GUI_COLOR_WIN_TITLE, cfg_col_title, cfg_col_title_bg);
- gui_color[GUI_COLOR_WIN_TITLE_MORE] = gui_color_build (GUI_COLOR_WIN_TITLE_MORE, cfg_col_title_more, cfg_col_title_bg);
- gui_color[GUI_COLOR_WIN_CHAT] = gui_color_build (GUI_COLOR_WIN_CHAT, cfg_col_chat, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_TIME] = gui_color_build (GUI_COLOR_WIN_CHAT_TIME, cfg_col_chat_time, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_TIME_SEP] = gui_color_build (GUI_COLOR_WIN_CHAT_TIME_SEP, cfg_col_chat_time_sep, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_PREFIX1] = gui_color_build (GUI_COLOR_WIN_CHAT_PREFIX1, cfg_col_chat_prefix1, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_PREFIX2] = gui_color_build (GUI_COLOR_WIN_CHAT_PREFIX2, cfg_col_chat_prefix2, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_SERVER] = gui_color_build (GUI_COLOR_WIN_CHAT_SERVER, cfg_col_chat_server, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_JOIN] = gui_color_build (GUI_COLOR_WIN_CHAT_JOIN, cfg_col_chat_join, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_PART] = gui_color_build (GUI_COLOR_WIN_CHAT_PART, cfg_col_chat_part, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_NICK] = gui_color_build (GUI_COLOR_WIN_CHAT_NICK, cfg_col_chat_nick, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_HOST] = gui_color_build (GUI_COLOR_WIN_CHAT_HOST, cfg_col_chat_host, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_CHANNEL] = gui_color_build (GUI_COLOR_WIN_CHAT_CHANNEL, cfg_col_chat_channel, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_DARK] = gui_color_build (GUI_COLOR_WIN_CHAT_DARK, cfg_col_chat_dark, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_HIGHLIGHT] = gui_color_build (GUI_COLOR_WIN_CHAT_HIGHLIGHT, cfg_col_chat_highlight, cfg_col_chat_bg);
- gui_color[GUI_COLOR_WIN_CHAT_READ_MARKER] = gui_color_build (GUI_COLOR_WIN_CHAT_READ_MARKER, cfg_col_chat_read_marker, cfg_col_chat_read_marker_bg);
- gui_color[GUI_COLOR_WIN_STATUS] = gui_color_build (GUI_COLOR_WIN_STATUS, cfg_col_status, cfg_col_status_bg);
- gui_color[GUI_COLOR_WIN_STATUS_DELIMITERS] = gui_color_build (GUI_COLOR_WIN_STATUS_DELIMITERS, cfg_col_status_delimiters, cfg_col_status_bg);
- gui_color[GUI_COLOR_WIN_STATUS_CHANNEL] = gui_color_build (GUI_COLOR_WIN_STATUS_CHANNEL, cfg_col_status_channel, cfg_col_status_bg);
- gui_color[GUI_COLOR_WIN_STATUS_DATA_MSG] = gui_color_build (GUI_COLOR_WIN_STATUS_DATA_MSG, cfg_col_status_data_msg, cfg_col_status_bg);
- gui_color[GUI_COLOR_WIN_STATUS_DATA_PRIVATE] = gui_color_build (GUI_COLOR_WIN_STATUS_DATA_PRIVATE, cfg_col_status_data_private, cfg_col_status_bg);
- gui_color[GUI_COLOR_WIN_STATUS_DATA_HIGHLIGHT] = gui_color_build (GUI_COLOR_WIN_STATUS_DATA_HIGHLIGHT, cfg_col_status_data_highlight, cfg_col_status_bg);
- gui_color[GUI_COLOR_WIN_STATUS_DATA_OTHER] = gui_color_build (GUI_COLOR_WIN_STATUS_DATA_OTHER, cfg_col_status_data_other, cfg_col_status_bg);
- gui_color[GUI_COLOR_WIN_STATUS_MORE] = gui_color_build (GUI_COLOR_WIN_STATUS_MORE, cfg_col_status_more, cfg_col_status_bg);
- gui_color[GUI_COLOR_WIN_INFOBAR] = gui_color_build (GUI_COLOR_WIN_INFOBAR, cfg_col_infobar, cfg_col_infobar_bg);
- gui_color[GUI_COLOR_WIN_INFOBAR_DELIMITERS] = gui_color_build (GUI_COLOR_WIN_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg);
- gui_color[GUI_COLOR_WIN_INFOBAR_HIGHLIGHT] = gui_color_build (GUI_COLOR_WIN_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg);
- gui_color[GUI_COLOR_WIN_INPUT] = gui_color_build (GUI_COLOR_WIN_INPUT, cfg_col_input, cfg_col_input_bg);
- gui_color[GUI_COLOR_WIN_INPUT_SERVER] = gui_color_build (GUI_COLOR_WIN_INPUT_SERVER, cfg_col_input_server, cfg_col_input_bg);
- gui_color[GUI_COLOR_WIN_INPUT_CHANNEL] = gui_color_build (GUI_COLOR_WIN_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg);
- gui_color[GUI_COLOR_WIN_INPUT_NICK] = gui_color_build (GUI_COLOR_WIN_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg);
- gui_color[GUI_COLOR_WIN_INPUT_DELIMITERS] = gui_color_build (GUI_COLOR_WIN_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg);
- gui_color[GUI_COLOR_WIN_INPUT_TEXT_NOT_FOUND] = gui_color_build (GUI_COLOR_WIN_INPUT_TEXT_NOT_FOUND, cfg_col_input_text_not_found, cfg_col_input_bg);
- gui_color[GUI_COLOR_WIN_INPUT_ACTIONS] = gui_color_build (GUI_COLOR_WIN_INPUT_ACTIONS, cfg_col_input_actions, cfg_col_input_bg);
- gui_color[GUI_COLOR_WIN_NICK] = gui_color_build (GUI_COLOR_WIN_NICK, cfg_col_nick, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_AWAY] = gui_color_build (GUI_COLOR_WIN_NICK_AWAY, cfg_col_nick_away, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_CHANOWNER] = gui_color_build (GUI_COLOR_WIN_NICK_CHANOWNER, cfg_col_nick_chanowner, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_CHANADMIN] = gui_color_build (GUI_COLOR_WIN_NICK_CHANADMIN, cfg_col_nick_chanadmin, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_OP] = gui_color_build (GUI_COLOR_WIN_NICK_OP, cfg_col_nick_op, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_HALFOP] = gui_color_build (GUI_COLOR_WIN_NICK_HALFOP, cfg_col_nick_halfop, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_VOICE] = gui_color_build (GUI_COLOR_WIN_NICK_VOICE, cfg_col_nick_voice, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_CHANUSER] = gui_color_build (GUI_COLOR_WIN_NICK_CHANUSER, cfg_col_nick_user, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_MORE] = gui_color_build (GUI_COLOR_WIN_NICK_MORE, cfg_col_nick_more, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_SEP] = gui_color_build (GUI_COLOR_WIN_NICK_SEP, cfg_col_nick_sep, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_SELF] = gui_color_build (GUI_COLOR_WIN_NICK_SELF, cfg_col_nick_self, cfg_col_nick_bg);
- gui_color[GUI_COLOR_WIN_NICK_PRIVATE] = gui_color_build (GUI_COLOR_WIN_NICK_PRIVATE, cfg_col_nick_private, cfg_col_nick_bg);
-
- for (i = 0; i < GUI_COLOR_WIN_NICK_NUMBER; i++)
+ gui_color[GUI_COLOR_SEPARATOR] = gui_color_build (GUI_COLOR_SEPARATOR, cfg_col_separator, cfg_col_separator);
+
+ gui_color[GUI_COLOR_TITLE] = gui_color_build (GUI_COLOR_TITLE, cfg_col_title, cfg_col_title_bg);
+ gui_color[GUI_COLOR_TITLE_MORE] = gui_color_build (GUI_COLOR_TITLE_MORE, cfg_col_title_more, cfg_col_title_bg);
+
+ gui_color[GUI_COLOR_CHAT] = gui_color_build (GUI_COLOR_CHAT, cfg_col_chat, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_TIME] = gui_color_build (GUI_COLOR_CHAT_TIME, cfg_col_chat_time, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_TIME_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_TIME_DELIMITERS, cfg_col_chat_time_delimiters, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_PREFIX_INFO] = gui_color_build (GUI_COLOR_CHAT_PREFIX_INFO, cfg_col_chat_prefix[GUI_CHAT_PREFIX_INFO], cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_PREFIX_ERROR] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ERROR, cfg_col_chat_prefix[GUI_CHAT_PREFIX_ERROR], cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_PREFIX_NETWORK] = gui_color_build (GUI_COLOR_CHAT_PREFIX_NETWORK, cfg_col_chat_prefix[GUI_CHAT_PREFIX_NETWORK], cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_PREFIX_ACTION] = gui_color_build (GUI_COLOR_CHAT_PREFIX_ACTION, cfg_col_chat_prefix[GUI_CHAT_PREFIX_ACTION], cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_PREFIX_JOIN] = gui_color_build (GUI_COLOR_CHAT_PREFIX_JOIN, cfg_col_chat_prefix[GUI_CHAT_PREFIX_JOIN], cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_PREFIX_QUIT] = gui_color_build (GUI_COLOR_CHAT_PREFIX_QUIT, cfg_col_chat_prefix[GUI_CHAT_PREFIX_QUIT], cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_PREFIX_MORE] = gui_color_build (GUI_COLOR_CHAT_PREFIX_MORE, cfg_col_chat_prefix_more, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_PREFIX_SUFFIX] = gui_color_build (GUI_COLOR_CHAT_PREFIX_SUFFIX, cfg_col_chat_prefix_suffix, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_BUFFER] = gui_color_build (GUI_COLOR_CHAT_BUFFER, cfg_col_chat_buffer, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_SERVER] = gui_color_build (GUI_COLOR_CHAT_SERVER, cfg_col_chat_server, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_CHANNEL] = gui_color_build (GUI_COLOR_CHAT_CHANNEL, cfg_col_chat_channel, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_NICK] = gui_color_build (GUI_COLOR_CHAT_NICK, cfg_col_chat_nick, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_NICK_SELF] = gui_color_build (GUI_COLOR_CHAT_NICK_SELF, cfg_col_chat_nick_self, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_NICK_OTHER] = gui_color_build (GUI_COLOR_CHAT_NICK_OTHER, cfg_col_chat_nick_other, cfg_col_chat_bg);
+ for (i = 0; i < GUI_COLOR_NICK_NUMBER; i++)
{
- gui_color[GUI_COLOR_WIN_NICK_1 + i] = gui_color_build (GUI_COLOR_WIN_NICK_1 + i, cfg_col_nick_colors[i], cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_NICK1 + i] = gui_color_build (GUI_COLOR_CHAT_NICK1 + i, cfg_col_chat_nick_colors[i], cfg_col_chat_bg);
}
-
- gui_color[GUI_COLOR_DCC_SELECTED] = gui_color_build (GUI_COLOR_DCC_SELECTED, cfg_col_dcc_selected, cfg_col_chat_bg);
- gui_color[GUI_COLOR_DCC_WAITING] = gui_color_build (GUI_COLOR_DCC_WAITING, cfg_col_dcc_waiting, cfg_col_chat_bg);
- gui_color[GUI_COLOR_DCC_CONNECTING] = gui_color_build (GUI_COLOR_DCC_CONNECTING, cfg_col_dcc_connecting, cfg_col_chat_bg);
- gui_color[GUI_COLOR_DCC_ACTIVE] = gui_color_build (GUI_COLOR_DCC_ACTIVE, cfg_col_dcc_active, cfg_col_chat_bg);
- gui_color[GUI_COLOR_DCC_DONE] = gui_color_build (GUI_COLOR_DCC_DONE, cfg_col_dcc_done, cfg_col_chat_bg);
- gui_color[GUI_COLOR_DCC_FAILED] = gui_color_build (GUI_COLOR_DCC_FAILED, cfg_col_dcc_failed, cfg_col_chat_bg);
- gui_color[GUI_COLOR_DCC_ABORTED] = gui_color_build (GUI_COLOR_DCC_ABORTED, cfg_col_dcc_aborted, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_HOST] = gui_color_build (GUI_COLOR_CHAT_HOST, cfg_col_chat_host, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_DELIMITERS] = gui_color_build (GUI_COLOR_CHAT_DELIMITERS, cfg_col_chat_delimiters, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_HIGHLIGHT] = gui_color_build (GUI_COLOR_CHAT_HIGHLIGHT, cfg_col_chat_highlight, cfg_col_chat_bg);
+ gui_color[GUI_COLOR_CHAT_READ_MARKER] = gui_color_build (GUI_COLOR_CHAT_READ_MARKER, cfg_col_chat_read_marker, cfg_col_chat_read_marker_bg);
+
+ gui_color[GUI_COLOR_STATUS] = gui_color_build (GUI_COLOR_STATUS, cfg_col_status, cfg_col_status_bg);
+ gui_color[GUI_COLOR_STATUS_DELIMITERS] = gui_color_build (GUI_COLOR_STATUS_DELIMITERS, cfg_col_status_delimiters, cfg_col_status_bg);
+ gui_color[GUI_COLOR_STATUS_CHANNEL] = gui_color_build (GUI_COLOR_STATUS_CHANNEL, cfg_col_status_channel, cfg_col_status_bg);
+ gui_color[GUI_COLOR_STATUS_DATA_MSG] = gui_color_build (GUI_COLOR_STATUS_DATA_MSG, cfg_col_status_data_msg, cfg_col_status_bg);
+ gui_color[GUI_COLOR_STATUS_DATA_PRIVATE] = gui_color_build (GUI_COLOR_STATUS_DATA_PRIVATE, cfg_col_status_data_private, cfg_col_status_bg);
+ gui_color[GUI_COLOR_STATUS_DATA_HIGHLIGHT] = gui_color_build (GUI_COLOR_STATUS_DATA_HIGHLIGHT, cfg_col_status_data_highlight, cfg_col_status_bg);
+ gui_color[GUI_COLOR_STATUS_DATA_OTHER] = gui_color_build (GUI_COLOR_STATUS_DATA_OTHER, cfg_col_status_data_other, cfg_col_status_bg);
+ gui_color[GUI_COLOR_STATUS_MORE] = gui_color_build (GUI_COLOR_STATUS_MORE, cfg_col_status_more, cfg_col_status_bg);
+
+ gui_color[GUI_COLOR_INFOBAR] = gui_color_build (GUI_COLOR_INFOBAR, cfg_col_infobar, cfg_col_infobar_bg);
+ gui_color[GUI_COLOR_INFOBAR_DELIMITERS] = gui_color_build (GUI_COLOR_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg);
+ gui_color[GUI_COLOR_INFOBAR_HIGHLIGHT] = gui_color_build (GUI_COLOR_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg);
+
+ gui_color[GUI_COLOR_INPUT] = gui_color_build (GUI_COLOR_INPUT, cfg_col_input, cfg_col_input_bg);
+ gui_color[GUI_COLOR_INPUT_SERVER] = gui_color_build (GUI_COLOR_INPUT_SERVER, cfg_col_input_server, cfg_col_input_bg);
+ gui_color[GUI_COLOR_INPUT_CHANNEL] = gui_color_build (GUI_COLOR_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg);
+ gui_color[GUI_COLOR_INPUT_NICK] = gui_color_build (GUI_COLOR_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg);
+ gui_color[GUI_COLOR_INPUT_DELIMITERS] = gui_color_build (GUI_COLOR_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg);
+ gui_color[GUI_COLOR_INPUT_TEXT_NOT_FOUND] = gui_color_build (GUI_COLOR_INPUT_TEXT_NOT_FOUND, cfg_col_input_text_not_found, cfg_col_input_bg);
+ gui_color[GUI_COLOR_INPUT_ACTIONS] = gui_color_build (GUI_COLOR_INPUT_ACTIONS, cfg_col_input_actions, cfg_col_input_bg);
+
+ gui_color[GUI_COLOR_NICKLIST] = gui_color_build (GUI_COLOR_NICKLIST, cfg_col_nicklist, cfg_col_nicklist_bg);
+ gui_color[GUI_COLOR_NICKLIST_AWAY] = gui_color_build (GUI_COLOR_NICKLIST_AWAY, cfg_col_nicklist_away, cfg_col_nicklist_bg);
+ gui_color[GUI_COLOR_NICKLIST_PREFIX1] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX1, cfg_col_nicklist_prefix1, cfg_col_nicklist_bg);
+ gui_color[GUI_COLOR_NICKLIST_PREFIX2] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX2, cfg_col_nicklist_prefix2, cfg_col_nicklist_bg);
+ gui_color[GUI_COLOR_NICKLIST_PREFIX3] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX3, cfg_col_nicklist_prefix3, cfg_col_nicklist_bg);
+ gui_color[GUI_COLOR_NICKLIST_PREFIX4] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX4, cfg_col_nicklist_prefix4, cfg_col_nicklist_bg);
+ gui_color[GUI_COLOR_NICKLIST_PREFIX5] = gui_color_build (GUI_COLOR_NICKLIST_PREFIX5, cfg_col_nicklist_prefix5, cfg_col_nicklist_bg);
+ gui_color[GUI_COLOR_NICKLIST_MORE] = gui_color_build (GUI_COLOR_NICKLIST_MORE, cfg_col_nicklist_more, cfg_col_nicklist_bg);
+ gui_color[GUI_COLOR_NICKLIST_SEPARATOR] = gui_color_build (GUI_COLOR_NICKLIST_SEPARATOR, cfg_col_nicklist_separator, cfg_col_nicklist_bg);
+
+ gui_color[GUI_COLOR_INFO] = gui_color_build (GUI_COLOR_INFO, cfg_col_info, cfg_col_info_bg);
+ gui_color[GUI_COLOR_INFO_WAITING] = gui_color_build (GUI_COLOR_INFO_WAITING, cfg_col_info_waiting, cfg_col_info_bg);
+ gui_color[GUI_COLOR_INFO_CONNECTING] = gui_color_build (GUI_COLOR_INFO_CONNECTING, cfg_col_info_connecting, cfg_col_info_bg);
+ gui_color[GUI_COLOR_INFO_ACTIVE] = gui_color_build (GUI_COLOR_INFO_ACTIVE, cfg_col_info_active, cfg_col_info_bg);
+ gui_color[GUI_COLOR_INFO_DONE] = gui_color_build (GUI_COLOR_INFO_DONE, cfg_col_info_done, cfg_col_info_bg);
+ gui_color[GUI_COLOR_INFO_FAILED] = gui_color_build (GUI_COLOR_INFO_FAILED, cfg_col_info_failed, cfg_col_info_bg);
+ gui_color[GUI_COLOR_INFO_ABORTED] = gui_color_build (GUI_COLOR_INFO_ABORTED, cfg_col_info_aborted, cfg_col_info_bg);
}
/*
diff --git a/src/gui/curses/gui-curses-infobar.c b/src/gui/curses/gui-curses-infobar.c
index 0e7a3ce9b..1ff4dc925 100644
--- a/src/gui/curses/gui-curses-infobar.c
+++ b/src/gui/curses/gui-curses-infobar.c
@@ -26,11 +26,12 @@
#include <stdlib.h>
#include <string.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/hotlist.h"
-#include "../../common/util.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-string.h"
+#include "../gui-infobar.h"
+#include "../gui-main.h"
+#include "../gui-window.h"
#include "gui-curses.h"
@@ -39,9 +40,9 @@
*/
void
-gui_infobar_draw_time (t_gui_buffer *buffer)
+gui_infobar_draw_time (struct t_gui_buffer *buffer)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
time_t time_seconds;
struct tm *local_time;
@@ -57,7 +58,8 @@ gui_infobar_draw_time (t_gui_buffer *buffer)
local_time = localtime (&time_seconds);
if (local_time)
{
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, GUI_COLOR_WIN_INFOBAR);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
+ GUI_COLOR_INFOBAR);
mvwprintw (GUI_CURSES(ptr_win)->win_infobar,
0, 1,
"%02d:%02d",
@@ -76,12 +78,12 @@ gui_infobar_draw_time (t_gui_buffer *buffer)
*/
void
-gui_infobar_draw (t_gui_buffer *buffer, int erase)
+gui_infobar_draw (struct t_gui_buffer *buffer, int erase)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
time_t time_seconds;
struct tm *local_time;
- char text_time[1024 + 1], *buf;
+ char text_time[1024], *buf;
/* make C compiler happy */
(void) buffer;
@@ -92,18 +94,23 @@ 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 (GUI_CURSES(ptr_win)->win_infobar, GUI_COLOR_WIN_INFOBAR);
+ gui_window_curses_clear (GUI_CURSES(ptr_win)->win_infobar,
+ GUI_COLOR_INFOBAR);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, GUI_COLOR_WIN_INFOBAR);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
+ GUI_COLOR_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 (GUI_CURSES(ptr_win)->win_infobar, GUI_COLOR_WIN_INFOBAR_DELIMITERS);
+ strftime (text_time, sizeof (text_time),
+ cfg_look_infobar_time_format, local_time);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
+ GUI_COLOR_INFOBAR_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_infobar, "[");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, GUI_COLOR_WIN_INFOBAR);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
+ GUI_COLOR_INFOBAR);
wprintw (GUI_CURSES(ptr_win)->win_infobar,
"%02d:%02d",
local_time->tm_hour, local_time->tm_min);
@@ -111,19 +118,24 @@ gui_infobar_draw (t_gui_buffer *buffer, int erase)
wprintw (GUI_CURSES(ptr_win)->win_infobar,
":%02d",
local_time->tm_sec);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, GUI_COLOR_WIN_INFOBAR_DELIMITERS);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
+ GUI_COLOR_INFOBAR_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_infobar, "]");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, GUI_COLOR_WIN_INFOBAR);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
+ GUI_COLOR_INFOBAR);
wprintw (GUI_CURSES(ptr_win)->win_infobar,
" %s", text_time);
}
if (gui_infobar)
{
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, GUI_COLOR_WIN_INFOBAR_DELIMITERS);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
+ GUI_COLOR_INFOBAR_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_infobar, " | ");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar, gui_infobar->color);
- buf = weechat_iconv_from_internal (NULL, gui_infobar->text);
- wprintw (GUI_CURSES(ptr_win)->win_infobar, "%s", (buf) ? buf : gui_infobar->text);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_infobar,
+ gui_infobar->color);
+ buf = string_iconv_from_internal (NULL, gui_infobar->text);
+ wprintw (GUI_CURSES(ptr_win)->win_infobar, "%s",
+ (buf) ? buf : gui_infobar->text);
if (buf)
free (buf);
}
diff --git a/src/gui/curses/gui-curses-input.c b/src/gui/curses/gui-curses-input.c
index 9f076bbd3..174865096 100644
--- a/src/gui/curses/gui-curses-input.c
+++ b/src/gui/curses/gui-curses-input.c
@@ -26,32 +26,31 @@
#include <stdlib.h>
#include <string.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/utf8.h"
-#include "../../common/util.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-string.h"
+#include "../../core/wee-utf8.h"
+#include "../../plugins/plugin.h"
+#include "../gui-input.h"
+#include "../gui-keyboard.h"
+#include "../gui-main.h"
+#include "../gui-window.h"
#include "gui-curses.h"
-#ifdef PLUGINS
-#include "../../plugins/plugins.h"
-#endif
-
/*
* gui_input_set_color: set color for an input window
*/
void
-gui_input_set_color (t_gui_window *window, int irc_color)
+gui_input_set_color (struct t_gui_window *window, int color)
{
int fg, bg;
- fg = gui_irc_colors[irc_color][0];
- bg = gui_color[GUI_COLOR_WIN_INPUT]->background;
+ fg = gui_weechat_colors[color].foreground;
+ bg = gui_color[GUI_COLOR_INPUT]->background;
- irc_color %= GUI_NUM_IRC_COLORS;
- if (gui_irc_colors[irc_color][1] & A_BOLD)
+ if (gui_weechat_colors[color].attributes & A_BOLD)
wattron (GUI_CURSES(window)->win_input, A_BOLD);
if (((fg == -1) || (fg == 99))
@@ -60,7 +59,7 @@ gui_input_set_color (t_gui_window *window, int irc_color)
else
{
if ((fg == -1) || (fg == 99))
- fg = WEECHAT_COLOR_WHITE;
+ fg = COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
wattron (GUI_CURSES(window)->win_input, COLOR_PAIR((bg * 8) + fg));
@@ -68,92 +67,13 @@ gui_input_set_color (t_gui_window *window, int irc_color)
}
/*
- * gui_input_get_prompt_length: return input prompt length (displayed on screen)
- */
-
-int
-gui_input_get_prompt_length (t_gui_window *window, char *nick)
-{
- char *pos, saved_char;
- int char_size, length;
-
- if (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
- {
- if (window->buffer->text_search_exact)
- return utf8_width_screen (_("Text search (exact): "));
- else
- return utf8_width_screen (_("Text search: "));
- }
-
- length = 0;
- pos = cfg_look_input_format;
- while (pos && pos[0])
- {
- switch (pos[0])
- {
- case '%':
- pos++;
- switch (pos[0])
- {
- case 'c': /* channel or server name */
- if (GUI_CHANNEL(window->buffer))
- length += utf8_width_screen (GUI_CHANNEL(window->buffer)->name);
- else
- {
- if (GUI_SERVER(window->buffer))
- length += utf8_width_screen (GUI_SERVER(window->buffer)->name);
- }
- pos++;
- break;
- case 'm': /* nick modes */
- if (GUI_SERVER(window->buffer) && GUI_SERVER(window->buffer)->is_connected)
- {
- if (GUI_SERVER(window->buffer)->nick_modes
- && GUI_SERVER(window->buffer)->nick_modes[0])
- length += strlen (GUI_SERVER(window->buffer)->nick_modes);
- }
- pos++;
- break;
- case 'n': /* nick */
- length += utf8_width_screen (nick);
- pos++;
- break;
- default:
- length++;
- if (pos[0])
- {
- if (pos[0] == '%')
- pos++;
- else
- {
- length++;
- pos += utf8_char_size (pos);
- }
- }
- break;
- }
- break;
- default:
- char_size = utf8_char_size (pos);
- saved_char = pos[char_size];
- pos[char_size] = '\0';
- length += utf8_width_screen (pos);
- pos[char_size] = saved_char;
- pos += char_size;
- break;
- }
- }
- return length;
-}
-
-/*
* gui_input_draw_prompt: display input prompt
* return: # chars displayed on screen (one UTF-8 char
* may be displayed on more than 1 char on screen)
*/
void
-gui_input_draw_prompt (t_gui_window *window, char *nick)
+gui_input_draw_prompt (struct t_gui_window *window)
{
char *pos, saved_char, *buf;
int char_size;
@@ -163,7 +83,7 @@ gui_input_draw_prompt (t_gui_window *window, char *nick)
if (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
{
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
- GUI_COLOR_WIN_INPUT);
+ GUI_COLOR_INPUT);
wprintw (GUI_CURSES(window)->win_input, "%s",
(window->buffer->text_search_exact) ?
_("Text search (exact): ") : _("Text search: "));
@@ -179,36 +99,22 @@ gui_input_draw_prompt (t_gui_window *window, char *nick)
pos++;
switch (pos[0])
{
- case 'c': /* channel or server name */
- if (GUI_CHANNEL(window->buffer))
+ case 'c': /* buffer name */
+ if (window->buffer->name)
{
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
- GUI_COLOR_WIN_INPUT_CHANNEL);
- buf = weechat_iconv_from_internal (NULL,
- GUI_CHANNEL(window->buffer)->name);
+ GUI_COLOR_INPUT_CHANNEL);
+ buf = string_iconv_from_internal (NULL,
+ window->buffer->name);
wprintw (GUI_CURSES(window)->win_input, "%s",
- (buf) ? buf : GUI_CHANNEL(window->buffer)->name);
+ (buf) ? buf : window->buffer->name);
if (buf)
free (buf);
}
- else
- {
- if (GUI_SERVER(window->buffer))
- {
- gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
- GUI_COLOR_WIN_INPUT_SERVER);
- buf = weechat_iconv_from_internal (NULL,
- GUI_SERVER(window->buffer)->name);
- wprintw (GUI_CURSES(window)->win_input, "%s",
- (buf) ? buf : GUI_SERVER(window->buffer)->name);
- if (buf)
- free (buf);
- }
- }
pos++;
break;
case 'm': /* nick modes */
- if (GUI_SERVER(window->buffer) && GUI_SERVER(window->buffer)->is_connected)
+ /*if (GUI_SERVER(window->buffer) && GUI_SERVER(window->buffer)->is_connected)
{
if (GUI_SERVER(window->buffer)->nick_modes
&& GUI_SERVER(window->buffer)->nick_modes[0])
@@ -218,16 +124,21 @@ gui_input_draw_prompt (t_gui_window *window, char *nick)
wprintw (GUI_CURSES(window)->win_input, "%s",
GUI_SERVER(window->buffer)->nick_modes);
}
- }
+ }*/
pos++;
break;
case 'n': /* nick */
- gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
- GUI_COLOR_WIN_INPUT_NICK);
- buf = weechat_iconv_from_internal (NULL, nick);
- wprintw (GUI_CURSES(window)->win_input, "%s", (buf) ? buf : nick);
- if (buf)
- free (buf);
+ if (window->buffer->input_nick)
+ {
+ gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
+ GUI_COLOR_INPUT_NICK);
+ buf = string_iconv_from_internal (NULL,
+ window->buffer->input_nick);
+ wprintw (GUI_CURSES(window)->win_input, "%s",
+ (buf) ? buf : window->buffer->input_nick);
+ if (buf)
+ free (buf);
+ }
pos++;
break;
default:
@@ -237,7 +148,7 @@ gui_input_draw_prompt (t_gui_window *window, char *nick)
saved_char = pos[char_size];
pos[char_size] = '\0';
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
- GUI_COLOR_WIN_INPUT_DELIMITERS);
+ GUI_COLOR_INPUT_DELIMITERS);
wprintw (GUI_CURSES(window)->win_input, "%%%s", pos);
pos[char_size] = saved_char;
pos += char_size;
@@ -255,7 +166,7 @@ gui_input_draw_prompt (t_gui_window *window, char *nick)
saved_char = pos[char_size];
pos[char_size] = '\0';
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
- GUI_COLOR_WIN_INPUT_DELIMITERS);
+ GUI_COLOR_INPUT_DELIMITERS);
wprintw (GUI_CURSES(window)->win_input, "%s", pos);
pos[char_size] = saved_char;
pos += char_size;
@@ -271,7 +182,7 @@ gui_input_draw_prompt (t_gui_window *window, char *nick)
*/
int
-gui_input_draw_text (t_gui_window *window, int input_width)
+gui_input_draw_text (struct t_gui_window *window, int input_width)
{
char *ptr_start, *ptr_next, saved_char, *output, *ptr_string;
int pos_mask, size, last_color, color, count_cursor, offset_cursor;
@@ -287,10 +198,10 @@ gui_input_draw_text (t_gui_window *window, int input_width)
{
if (window->buffer->text_search_found)
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
- GUI_COLOR_WIN_INPUT);
+ GUI_COLOR_INPUT);
else
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
- GUI_COLOR_WIN_INPUT_TEXT_NOT_FOUND);
+ GUI_COLOR_INPUT_TEXT_NOT_FOUND);
}
while ((input_width > 0) && ptr_start && ptr_start[0])
{
@@ -309,13 +220,14 @@ gui_input_draw_text (t_gui_window *window, int input_width)
if (color != last_color)
{
if (color == -1)
- gui_window_set_weechat_color (GUI_CURSES(window)->win_input, GUI_COLOR_WIN_INPUT);
+ gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
+ GUI_COLOR_INPUT);
else
gui_input_set_color (window, color);
}
last_color = color;
}
- output = weechat_iconv_from_internal (NULL, ptr_start);
+ output = string_iconv_from_internal (NULL, ptr_start);
ptr_string = (output) ? output : ptr_start;
@@ -336,7 +248,7 @@ gui_input_draw_text (t_gui_window *window, int input_width)
wprintw (GUI_CURSES(window)->win_input, "%s", ptr_string);
if (count_cursor > 0)
{
- offset_cursor += utf8_width_screen (ptr_start);
+ offset_cursor += utf8_strlen_screen (ptr_start);
count_cursor--;
}
}
@@ -360,13 +272,12 @@ gui_input_draw_text (t_gui_window *window, int input_width)
*/
void
-gui_input_draw (t_gui_buffer *buffer, int erase)
+gui_input_draw (struct t_gui_buffer *buffer, int erase)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
char format[32];
- char *ptr_nickname;
int prompt_length, display_prompt, offset_cursor;
- t_irc_dcc *dcc_selected;
+ /*t_irc_dcc *dcc_selected;*/
if (!gui_ok)
return;
@@ -376,15 +287,17 @@ gui_input_draw (t_gui_buffer *buffer, int erase)
if (ptr_win->buffer == buffer)
{
if (erase)
- gui_window_curses_clear (GUI_CURSES(ptr_win)->win_input, GUI_COLOR_WIN_INPUT);
+ gui_window_curses_clear (GUI_CURSES(ptr_win)->win_input,
+ GUI_COLOR_INPUT);
if (gui_keyboard_paste_pending)
{
wmove (GUI_CURSES(ptr_win)->win_input, 0, 0);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input,
- GUI_COLOR_WIN_INPUT_ACTIONS);
+ GUI_COLOR_INPUT_ACTIONS);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_input,
- _(" Paste %d lines ? [ctrl-Y] Yes [ctrl-N] No"),
+ _(" Paste %d lines ? [ctrl-Y] Yes "
+ "[ctrl-N] No"),
gui_keyboard_get_paste_lines ());
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
ptr_win->win_input_cursor_x = 0;
@@ -393,71 +306,64 @@ gui_input_draw (t_gui_buffer *buffer, int erase)
}
else
{
- switch (buffer->type)
+ if (buffer->input)
{
- case GUI_BUFFER_TYPE_STANDARD:
- if (buffer->has_input)
+ if (buffer->input_buffer_length == 0)
+ buffer->input_buffer[0] = '\0';
+
+ prompt_length = gui_input_get_prompt_length (ptr_win->buffer);
+
+ if (ptr_win->win_input_width - prompt_length < 3)
+ {
+ prompt_length = 0;
+ display_prompt = 0;
+ }
+ else
+ display_prompt = 1;
+
+ if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
+ ptr_win->win_input_width - prompt_length)
+ buffer->input_buffer_1st_display = buffer->input_buffer_pos -
+ (ptr_win->win_input_width - prompt_length) + 1;
+ else
+ {
+ if (buffer->input_buffer_pos < buffer->input_buffer_1st_display)
+ buffer->input_buffer_1st_display = buffer->input_buffer_pos;
+ else
{
- if (buffer->input_buffer_length == 0)
- buffer->input_buffer[0] = '\0';
-
- if (GUI_SERVER(buffer) && GUI_SERVER(buffer)->is_connected)
- ptr_nickname = (GUI_SERVER(buffer)->nick) ?
- GUI_SERVER(buffer)->nick : cfg_look_no_nickname;
- else
- ptr_nickname = cfg_look_no_nickname;
-
- prompt_length = gui_input_get_prompt_length (ptr_win, ptr_nickname);
-
- if (ptr_win->win_input_width - prompt_length < 3)
+ if ((buffer->input_buffer_1st_display > 0) &&
+ (buffer->input_buffer_pos -
+ buffer->input_buffer_1st_display + 1)
+ < ptr_win->win_input_width - prompt_length)
{
- prompt_length = 0;
- display_prompt = 0;
- }
- else
- display_prompt = 1;
-
- if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
- ptr_win->win_input_width - prompt_length)
- buffer->input_buffer_1st_display = buffer->input_buffer_pos -
+ buffer->input_buffer_1st_display =
+ buffer->input_buffer_pos -
(ptr_win->win_input_width - prompt_length) + 1;
- else
- {
- if (buffer->input_buffer_pos < buffer->input_buffer_1st_display)
- buffer->input_buffer_1st_display = buffer->input_buffer_pos;
- else
- {
- if ((buffer->input_buffer_1st_display > 0) &&
- (buffer->input_buffer_pos -
- buffer->input_buffer_1st_display + 1)
- < ptr_win->win_input_width - prompt_length)
- {
- buffer->input_buffer_1st_display =
- buffer->input_buffer_pos -
- (ptr_win->win_input_width - prompt_length) + 1;
- if (buffer->input_buffer_1st_display < 0)
- buffer->input_buffer_1st_display = 0;
- }
- }
+ if (buffer->input_buffer_1st_display < 0)
+ buffer->input_buffer_1st_display = 0;
}
- if (display_prompt)
- gui_input_draw_prompt (ptr_win, ptr_nickname);
-
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input, GUI_COLOR_WIN_INPUT);
- snprintf (format, 32, "%%-%ds", ptr_win->win_input_width - prompt_length);
- offset_cursor = 0;
- if (ptr_win == gui_current_window)
- offset_cursor = gui_input_draw_text (ptr_win,
- ptr_win->win_input_width - prompt_length);
- else
- wprintw (GUI_CURSES(ptr_win)->win_input, format, "");
- wclrtoeol (GUI_CURSES(ptr_win)->win_input);
- ptr_win->win_input_cursor_x = prompt_length + offset_cursor;
- if (ptr_win == gui_current_window)
- move (ptr_win->win_input_y,
- ptr_win->win_input_x + ptr_win->win_input_cursor_x);
}
- break;
+ }
+ if (display_prompt)
+ gui_input_draw_prompt (ptr_win);
+
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input,
+ GUI_COLOR_INPUT);
+ snprintf (format, 32, "%%-%ds",
+ ptr_win->win_input_width - prompt_length);
+ offset_cursor = 0;
+ if (ptr_win == gui_current_window)
+ offset_cursor = gui_input_draw_text (ptr_win,
+ ptr_win->win_input_width - prompt_length);
+ else
+ wprintw (GUI_CURSES(ptr_win)->win_input, format, "");
+ wclrtoeol (GUI_CURSES(ptr_win)->win_input);
+ ptr_win->win_input_cursor_x = prompt_length + offset_cursor;
+ if (ptr_win == gui_current_window)
+ move (ptr_win->win_input_y,
+ ptr_win->win_input_x + ptr_win->win_input_cursor_x);
+ }
+ /*
case GUI_BUFFER_TYPE_DCC:
dcc_selected = (ptr_win->dcc_selected) ? (t_irc_dcc *) ptr_win->dcc_selected : irc_dcc_list;
wmove (GUI_CURSES(ptr_win)->win_input, 0, 0);
@@ -509,7 +415,7 @@ gui_input_draw (t_gui_buffer *buffer, int erase)
if (ptr_win == gui_current_window)
move (ptr_win->win_input_y, ptr_win->win_input_x);
break;
- }
+ }*/
}
wrefresh (GUI_CURSES(ptr_win)->win_input);
refresh ();
diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c
index 249eb46ee..fb53780c1 100644
--- a/src/gui/curses/gui-curses-keyboard.c
+++ b/src/gui/curses/gui-curses-keyboard.c
@@ -26,11 +26,14 @@
#include <stdlib.h>
#include <string.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/utf8.h"
-#include "../../common/util.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-utf8.h"
+#include "../../core/wee-string.h"
+#include "../gui-keyboard.h"
+#include "../gui-input.h"
+#include "../gui-completion.h"
+#include "../gui-window.h"
#include "gui-curses.h"
@@ -240,7 +243,7 @@ gui_keyboard_flush ()
if (!gui_keyboard_paste_pending)
{
if (gui_keyboard_buffer_size > 0)
- gui_last_activity_time = time (NULL);
+ gui_keyboard_last_activity_time = time (NULL);
if (gui_key_grab && (gui_key_grab_count > 0))
gui_keyboard_grab_end ();
@@ -337,7 +340,7 @@ gui_keyboard_flush ()
/* convert input to UTF-8 is user is not using UTF-8 as locale */
if (!local_utf8)
{
- key_utf = weechat_iconv_to_internal (NULL, key_str);
+ key_utf = string_iconv_to_internal (NULL, key_str);
strncpy (key_str, key_utf, sizeof (key_str));
key_str[sizeof (key_str) - 1] = '\0';
}
@@ -350,7 +353,8 @@ gui_keyboard_flush ()
key_str[2] = '\0';
}
- /*gui_printf (gui_current_window->buffer, "gui_input_read: key = %s (%d)\n", key_str, key);*/
+ /*gui_printf (gui_current_window->buffer,
+ "gui_input_read: key = %s (%d)\n", key_str, key);*/
if (gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
input_old = (gui_current_window->buffer->input_buffer) ?
@@ -365,20 +369,22 @@ gui_keyboard_flush ()
if (strcmp (key_str, "^^") == 0)
key_str[1] = '\0';
- switch (gui_current_window->buffer->type)
+ /*switch (gui_current_window->buffer->type)
{
- case GUI_BUFFER_TYPE_STANDARD:
- gui_insert_string_input (gui_current_window, key_str, -1);
- gui_current_window->buffer->completion.position = -1;
+ case GUI_BUFFER_TYPE_STANDARD:*/
+ gui_input_insert_string (gui_current_window->buffer,
+ key_str, -1);
+ if (gui_current_window->buffer->completion)
+ gui_current_window->buffer->completion->position = -1;
input_draw = 1;
- break;
- case GUI_BUFFER_TYPE_DCC:
+ //break;
+ /*case GUI_BUFFER_TYPE_DCC:
gui_exec_action_dcc (gui_current_window, key_str);
break;
case GUI_BUFFER_TYPE_RAW_DATA:
gui_exec_action_raw_data (gui_current_window, key_str);
break;
- }
+ }*/
}
/* incremental text search in buffer */
@@ -386,7 +392,7 @@ gui_keyboard_flush ()
&& ((input_old == NULL) || (gui_current_window->buffer->input_buffer == NULL)
|| (strcmp (input_old, gui_current_window->buffer->input_buffer) != 0)))
{
- gui_buffer_search_restart (gui_current_window);
+ gui_window_search_restart (gui_current_window);
input_draw = 1;
}
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c
index db62058f4..c4870167b 100644
--- a/src/gui/curses/gui-curses-main.c
+++ b/src/gui/curses/gui-curses-main.c
@@ -29,22 +29,88 @@
#include <string.h>
#include <signal.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/fifo.h"
-#include "../../common/utf8.h"
-#include "../../common/util.h"
-#include "../../common/weeconfig.h"
-#include "../../protocols/irc/irc.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-hook.h"
+#include "../../core/wee-string.h"
+#include "../../core/wee-utf8.h"
+#include "../../core/wee-util.h"
+#include "../../plugins/plugin.h"
+#include "../gui-infobar.h"
+#include "../gui-input.h"
+#include "../gui-history.h"
+#include "../gui-hotlist.h"
+#include "../gui-keyboard.h"
+#include "../gui-main.h"
+#include "../gui-window.h"
#include "gui-curses.h"
-#ifdef PLUGINS
-#include "../../plugins/plugins.h"
-#endif
+/*
+ * gui_main_pre_init: pre-initialize GUI (called before gui_init)
+ */
-int send_irc_quit = 0;
+void
+gui_main_pre_init (int *argc, char **argv[])
+{
+ /* nothing for Curses interface */
+ (void) argc;
+ (void) argv;
+}
+
+/*
+ * gui_main_init: init GUI
+ */
+void
+gui_main_init ()
+{
+ struct t_gui_buffer *ptr_buffer;
+
+ initscr ();
+
+ curs_set (1);
+ noecho ();
+ nodelay (stdscr, TRUE);
+ raw ();
+
+ gui_color_init ();
+ gui_chat_prefix_build ();
+
+ gui_infobar = NULL;
+
+ gui_ok = ((COLS > WINDOW_MIN_WIDTH) && (LINES > WINDOW_MIN_HEIGHT));
+
+ refresh ();
+
+ /* init clipboard buffer */
+ gui_input_clipboard = NULL;
+
+ /* get time length */
+ gui_chat_time_length = util_get_time_length (cfg_look_buffer_time_format);
+
+ /* create new window/buffer */
+ if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
+ {
+ gui_current_window = gui_windows;
+ ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat");
+ if (ptr_buffer)
+ {
+ gui_init_ok = 1;
+ gui_buffer_set_title (ptr_buffer,
+ PACKAGE_STRING " " WEECHAT_COPYRIGHT_DATE
+ " - " WEECHAT_WEBSITE);
+ gui_window_redraw_buffer (ptr_buffer);
+ }
+ else
+ gui_init_ok = 0;
+
+ if (cfg_look_set_title)
+ gui_window_title_set ();
+
+ signal (SIGWINCH, gui_window_refresh_screen_sigwinch);
+ }
+}
/*
* gui_main_quit: quit weechat (signal received)
@@ -54,7 +120,6 @@ void
gui_main_quit ()
{
quit_weechat = 1;
- send_irc_quit = 1;
}
/*
@@ -64,26 +129,23 @@ gui_main_quit ()
void
gui_main_loop ()
{
- fd_set read_fd;
- static struct timeval timeout, tv;
- t_irc_server *ptr_server;
- t_gui_buffer *ptr_buffer;
- int old_day, old_min, old_sec, diff;
+ fd_set read_fds, write_fds, except_fds;
+ static struct timeval timeout;
+ struct t_gui_buffer *ptr_buffer;
+ int old_day, old_min, old_sec;
char text_time[1024], *text_time2;
- time_t new_time;
+ struct timeval tv_time;
struct tm *local_time;
quit_weechat = 0;
- send_irc_quit = 0;
-
- new_time = time (NULL);
- gui_last_activity_time = new_time;
- local_time = localtime (&new_time);
+
+ gettimeofday (&tv_time, NULL);
+ gui_keyboard_last_activity_time = tv_time.tv_sec;
+ local_time = localtime (&tv_time.tv_sec);
old_day = local_time->tm_mday;
old_min = -1;
old_sec = -1;
- irc_check_away = 0;
/* if SIGTERM or SIGHUP received => quit */
signal (SIGTERM, gui_main_quit);
@@ -94,9 +156,22 @@ gui_main_loop ()
/* refresh needed ? */
if (gui_refresh_screen_needed)
gui_window_refresh_screen (0);
+
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer->chat_refresh_needed)
+ {
+ gui_chat_draw (ptr_buffer, 0);
+ ptr_buffer->chat_refresh_needed = 0;
+ }
+ }
- new_time = time (NULL);
- local_time = localtime (&new_time);
+ gettimeofday (&tv_time, NULL);
+ local_time = localtime (&tv_time.tv_sec);
+
+ /* execute hook timers */
+ hook_timer_exec (&tv_time);
/* minute has changed ? => redraw infobar */
if (local_time->tm_min != old_min)
@@ -108,17 +183,17 @@ gui_main_loop ()
&& (local_time->tm_mday != old_day))
{
strftime (text_time, sizeof (text_time),
- cfg_look_day_change_timestamp, local_time);
- text_time2 = weechat_iconv_to_internal (NULL, text_time);
+ cfg_look_day_change_time_format, local_time);
+ text_time2 = string_iconv_to_internal (NULL, text_time);
gui_add_hotlist = 0;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- if (ptr_buffer->type == GUI_BUFFER_TYPE_STANDARD)
- gui_printf_nolog_notime (ptr_buffer,
- _("Day changed to %s\n"),
- (text_time2) ?
- text_time2 : text_time);
+ if (ptr_buffer->type == GUI_BUFFER_TYPE_FORMATED)
+ gui_chat_printf (ptr_buffer,
+ _("\t\tDay changed to %s"),
+ (text_time2) ?
+ text_time2 : text_time);
}
if (text_time2)
free (text_time2);
@@ -131,16 +206,6 @@ gui_main_loop ()
if (local_time->tm_sec != old_sec)
{
old_sec = local_time->tm_sec;
-
- /* send queued messages */
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (ptr_server->is_connected)
- {
- irc_server_outqueue_send (ptr_server);
- }
- }
/* display time in infobar (if seconds displayed) */
if (cfg_look_infobar_seconds)
@@ -161,22 +226,6 @@ gui_main_loop ()
gui_infobar_draw (gui_current_window->buffer, 1);
}
}
-
- /* away check */
- if (cfg_irc_away_check != 0)
- {
- irc_check_away++;
- if (irc_check_away >= (cfg_irc_away_check * 60))
- {
- irc_check_away = 0;
- irc_server_check_away ();
- }
- }
-
-#ifdef PLUGINS
- /* call timer handlers */
- plugin_timer_handler_exec ();
-#endif
}
/* read keyboard */
@@ -184,15 +233,15 @@ gui_main_loop ()
/* on GNU/Hurd 2 select() are causing troubles with keyboard */
/* waiting for a fix, we use only one select() */
#ifndef __GNU__
- FD_ZERO (&read_fd);
+ FD_ZERO (&read_fds);
timeout.tv_sec = 0;
timeout.tv_usec = 8000;
- FD_SET (STDIN_FILENO, &read_fd);
+ FD_SET (STDIN_FILENO, &read_fds);
- if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
+ if (select (FD_SETSIZE, &read_fds, NULL, NULL, &timeout) > 0)
{
- if (FD_ISSET (STDIN_FILENO, &read_fd))
+ if (FD_ISSET (STDIN_FILENO, &read_fds))
{
gui_keyboard_read ();
}
@@ -201,163 +250,30 @@ gui_main_loop ()
gui_keyboard_flush ();
#endif
- /* read sockets (servers, child process when connecting, FIFO pipe) */
-
- FD_ZERO (&read_fd);
+ /* read sockets/files/pipes */
+ hook_fd_set (&read_fds, &write_fds, &except_fds);
#ifdef __GNU__
timeout.tv_sec = 0;
timeout.tv_usec = 10000;
- FD_SET (STDIN_FILENO, &read_fd);
+ FD_SET (STDIN_FILENO, &read_fds);
#else
timeout.tv_sec = 0;
timeout.tv_usec = 2000;
#endif
- if (weechat_fifo != -1)
- FD_SET (weechat_fifo, &read_fd);
-
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- /* check if reconnection is pending */
- if ((!ptr_server->is_connected)
- && (ptr_server->reconnect_start > 0)
- && (new_time >= (ptr_server->reconnect_start + ptr_server->autoreconnect_delay)))
- irc_server_reconnect (ptr_server);
- else
- {
- if (ptr_server->is_connected)
- {
- /* check for lag */
- if ((ptr_server->lag_check_time.tv_sec == 0)
- && (new_time >= ptr_server->lag_next_check))
- {
- irc_server_sendf (ptr_server, "PING %s", ptr_server->address);
- gettimeofday (&(ptr_server->lag_check_time), NULL);
- }
-
- /* lag timeout => disconnect */
- if ((ptr_server->lag_check_time.tv_sec != 0)
- && (cfg_irc_lag_disconnect > 0))
- {
- gettimeofday (&tv, NULL);
- diff = (int) get_timeval_diff (&(ptr_server->lag_check_time), &tv);
- if (diff / 1000 > cfg_irc_lag_disconnect * 60)
- {
- irc_display_prefix (ptr_server, ptr_server->buffer, GUI_PREFIX_ERROR);
- gui_printf (ptr_server->buffer,
- _("%s lag is high, disconnecting from server...\n"),
- WEECHAT_WARNING);
- irc_server_disconnect (ptr_server, 1);
- continue;
- }
- }
-
- /* check if it's time to autojoin channels (after command delay) */
- if ((ptr_server->command_time != 0)
- && (new_time >= ptr_server->command_time + ptr_server->command_delay))
- {
- irc_server_autojoin_channels (ptr_server);
- ptr_server->command_time = 0;
- }
- }
-
- if (!ptr_server->is_connected && (ptr_server->child_pid > 0))
- FD_SET (ptr_server->child_read, &read_fd);
- else
- {
- if (ptr_server->sock >= 0)
- FD_SET (ptr_server->sock, &read_fd);
- }
- }
- }
-
- if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
+ if (select (FD_SETSIZE,
+ &read_fds, &write_fds, &except_fds,
+ &timeout) > 0)
{
#ifdef __GNU__
- if (FD_ISSET (STDIN_FILENO, &read_fd))
+ if (FD_ISSET (STDIN_FILENO, &read_fds))
{
gui_keyboard_read ();
}
#endif
- if ((weechat_fifo != -1) && (FD_ISSET (weechat_fifo, &read_fd)))
- {
- fifo_read ();
- }
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (!ptr_server->is_connected && (ptr_server->child_pid > 0))
- {
- if (FD_ISSET (ptr_server->child_read, &read_fd))
- irc_server_child_read (ptr_server);
- }
- else
- {
- if ((ptr_server->sock >= 0) &&
- (FD_ISSET (ptr_server->sock, &read_fd)))
- irc_server_recv (ptr_server);
- }
- }
+ hook_fd_exec (&read_fds, &write_fds, &except_fds);
}
-
- /* manages active DCC */
- irc_dcc_handle ();
- }
- if (send_irc_quit)
- irc_send_cmd_quit (NULL, NULL, NULL);
-}
-
-/*
- * gui_main_pre_init: pre-initialize GUI (called before gui_init)
- */
-
-void
-gui_main_pre_init (int *argc, char **argv[])
-{
- /* nothing for Curses interface */
- (void) argc;
- (void) argv;
-}
-
-/*
- * gui_main_init: init GUI
- */
-
-void
-gui_main_init ()
-{
- initscr ();
-
- curs_set (1);
- noecho ();
- nodelay (stdscr, TRUE);
- raw ();
-
- gui_color_init ();
-
- gui_infobar = NULL;
-
- gui_ok = ((COLS > WINDOW_MIN_WIDTH) && (LINES > WINDOW_MIN_HEIGHT));
-
- refresh ();
-
- /* init clipboard buffer */
- gui_input_clipboard = NULL;
-
- /* create new window/buffer */
- if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
- {
- gui_current_window = gui_windows;
- gui_buffer_new (gui_windows, NULL, NULL, GUI_BUFFER_TYPE_STANDARD, 1);
-
- if (cfg_look_set_title)
- gui_window_set_title ();
-
- gui_init_ok = 1;
-
- signal (SIGWINCH, gui_window_refresh_screen_sigwinch);
}
}
@@ -371,11 +287,7 @@ gui_main_end ()
/* free clipboard buffer */
if (gui_input_clipboard)
free (gui_input_clipboard);
-
- /* delete all panels */
- while (gui_panels)
- gui_panel_free (gui_panels);
-
+
/* delete all windows */
while (gui_windows)
gui_window_free (gui_windows);
@@ -386,7 +298,7 @@ gui_main_end ()
gui_buffer_free (gui_buffers, 0);
/* delete global history */
- history_global_free ();
+ gui_history_global_free ();
/* delete infobar messages */
while (gui_infobar)
@@ -394,7 +306,7 @@ gui_main_end ()
/* reset title */
if (cfg_look_set_title)
- gui_window_reset_title ();
+ gui_window_title_reset ();
/* end of Curses output */
refresh ();
diff --git a/src/gui/curses/gui-curses-nicklist.c b/src/gui/curses/gui-curses-nicklist.c
index d688a5571..1a748561d 100644
--- a/src/gui/curses/gui-curses-nicklist.c
+++ b/src/gui/curses/gui-curses-nicklist.c
@@ -25,12 +25,13 @@
#include <stdlib.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/utf8.h"
-#include "../../common/util.h"
-#include "../../common/weeconfig.h"
-#include "../../protocols/irc/irc.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-string.h"
+#include "../../core/wee-utf8.h"
+#include "../gui-nicklist.h"
+#include "../gui-main.h"
+#include "../gui-window.h"
#include "gui-curses.h"
@@ -39,46 +40,52 @@
*/
void
-gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
+gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
{
- t_gui_window *ptr_win;
- int i, j, k, x, y, x2, max_y, column, max_length, max_chars, nicks_displayed;
+ struct t_gui_window *ptr_win;
+ struct t_gui_nick *ptr_nick;
+ int i, j, k, x, y, x2, max_y, column, max_length, max_chars;
+ int nicks_displayed;
char format_empty[32], *buf, *ptr_buf, *ptr_next, saved_char;
- t_irc_nick *ptr_nick;
- if (!gui_ok || !GUI_BUFFER_HAS_NICKLIST(buffer))
+ if (!gui_ok || (!buffer->nicklist))
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0))
{
- max_length = irc_nick_get_max_length (GUI_CHANNEL(buffer));
-
- if (calculate_size && (gui_window_calculate_pos_size (ptr_win, 0)))
+ max_length = gui_nicklist_get_max_length (buffer);
+ if (max_length != buffer->nick_max_length)
{
- 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;
+ buffer->nick_max_length = max_length;
+ if (gui_window_calculate_pos_size (ptr_win, 0))
+ {
+ 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 (GUI_CURSES(ptr_win)->win_nick, GUI_COLOR_WIN_NICK);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ GUI_COLOR_NICKLIST);
snprintf (format_empty, 32, "%%-%ds", ptr_win->win_nick_width);
for (i = 0; i < ptr_win->win_nick_height; i++)
{
- mvwprintw (GUI_CURSES(ptr_win)->win_nick, i, 0, format_empty, " ");
+ mvwprintw (GUI_CURSES(ptr_win)->win_nick, i, 0,
+ format_empty, " ");
}
}
@@ -95,7 +102,8 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
if (cfg_look_nicklist_separator && has_colors ())
{
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, GUI_COLOR_WIN_NICK_SEP);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ GUI_COLOR_NICKLIST_SEPARATOR);
switch (cfg_look_nicklist_position)
{
case CFG_LOOK_NICKLIST_LEFT:
@@ -121,9 +129,12 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
}
}
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, GUI_COLOR_WIN_NICK);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ GUI_COLOR_NICKLIST);
x = 0;
- y = (cfg_look_nicklist_separator && (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) ? 1 : 0;
+ y = (cfg_look_nicklist_separator
+ && (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) ?
+ 1 : 0;
max_y = 0;
switch (cfg_look_nicklist_position)
{
@@ -132,7 +143,8 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
max_y = 0;
break;
case CFG_LOOK_NICKLIST_TOP:
- max_y = ptr_win->win_nick_height - cfg_look_nicklist_separator;
+ max_y = ptr_win->win_nick_height -
+ cfg_look_nicklist_separator;
break;
case CFG_LOOK_NICKLIST_BOTTOM:
max_y = ptr_win->win_nick_height;
@@ -142,11 +154,12 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
- nicks_displayed = (ptr_win->win_width / (max_length + 2)) * (ptr_win->win_nick_height - cfg_look_nicklist_separator);
+ nicks_displayed = (ptr_win->win_width / (max_length + 2)) *
+ (ptr_win->win_nick_height - cfg_look_nicklist_separator);
else
nicks_displayed = ptr_win->win_nick_height;
- ptr_nick = GUI_CHANNEL(buffer)->nicks;
+ ptr_nick = buffer->nicks;
for (i = 0; i < ptr_win->win_nick_start; i++)
{
if (!ptr_nick)
@@ -173,16 +186,25 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
if ( ((i == 0) && (ptr_win->win_nick_start > 0))
|| ((i == nicks_displayed - 1) && (ptr_nick->next_nick)) )
{
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, GUI_COLOR_WIN_NICK_MORE);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ GUI_COLOR_NICKLIST_MORE);
j = (max_length + 1) >= 4 ? 4 : max_length + 1;
for (x2 = 1; x2 <= j; x2++)
- mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x + x2, "+");
+ mvwprintw (GUI_CURSES(ptr_win)->win_nick,
+ y, x + x2, "+");
}
else
{
- if (ptr_nick->flags & IRC_NICK_CHANOWNER)
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ ptr_nick->color_prefix);
+ mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "%c",
+ ptr_nick->prefix);
+ x++;
+
+ /*if (ptr_nick->flags & IRC_NICK_CHANOWNER)
{
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick, GUI_COLOR_WIN_NICK_CHANOWNER);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ GUI_COLOR_WIN_NICK_CHANOWNER);
mvwprintw (GUI_CURSES(ptr_win)->win_nick, y, x, "~");
x++;
}
@@ -230,7 +252,10 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
}
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
((cfg_irc_away_check > 0) && (ptr_nick->flags & IRC_NICK_AWAY)) ?
- GUI_COLOR_WIN_NICK_AWAY : GUI_COLOR_WIN_NICK);
+ GUI_COLOR_WIN_NICK_AWAY : GUI_COLOR_WIN_NICK);*/
+
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
+ ptr_nick->color_nick);
wmove (GUI_CURSES(ptr_win)->win_nick, y, x);
ptr_buf = ptr_nick->nick;
saved_char = '\0';
@@ -244,8 +269,10 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
saved_char = ptr_next[0];
ptr_next[0] = '\0';
}
- buf = weechat_iconv_from_internal (NULL, ptr_buf);
- wprintw (GUI_CURSES(ptr_win)->win_nick, "%s", (buf) ? buf : "?");
+ buf = string_iconv_from_internal (NULL,
+ ptr_buf);
+ wprintw (GUI_CURSES(ptr_win)->win_nick, "%s",
+ (buf) ? buf : "?");
if (buf)
free (buf);
if (ptr_next)
@@ -268,7 +295,8 @@ gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
if (y >= max_y)
{
column += max_length + 2;
- y = (cfg_look_nicklist_separator && (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) ?
+ y = (cfg_look_nicklist_separator
+ && (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) ?
1 : 0;
}
}
diff --git a/src/gui/curses/gui-curses-panel.c b/src/gui/curses/gui-curses-panel.c
deleted file mode 100644
index a73834cf4..000000000
--- a/src/gui/curses/gui-curses-panel.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-/* 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 "../../protocols/irc/irc.h"
-#include "gui-curses.h"
-
-
-/*
- * gui_panel_windows_get_size: get total panel size (window panels) for a position
- * panel is optional, if not NULL, size is computed
- * from panel 1 to panel # - 1
- */
-
-int
-gui_panel_window_get_size (t_gui_panel *panel, 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)
- {
- /* stop before panel */
- if ((panel) && (ptr_panel_win->panel == panel))
- return total_size;
-
- 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;
- int add_top, add_bottom, add_left, add_right;
-
- if (window)
- {
- x1 = window->win_x;
- y1 = window->win_y + 1;
- x2 = x1 + window->win_width - 1;
- y2 = y1 + window->win_height - 1 - 4;
- add_left = gui_panel_window_get_size (panel, window, GUI_PANEL_LEFT);
- add_right = gui_panel_window_get_size (panel, window, GUI_PANEL_RIGHT);
- add_top = gui_panel_window_get_size (panel, window, GUI_PANEL_TOP);
- add_bottom = gui_panel_window_get_size (panel, window, GUI_PANEL_BOTTOM);
- }
- else
- {
- x1 = 0;
- y1 = 0;
- x2 = gui_window_get_width () - 1;
- y2 = gui_window_get_height () - 1;
- add_left = gui_panel_global_get_size (panel, GUI_PANEL_LEFT);
- add_right = gui_panel_global_get_size (panel, GUI_PANEL_RIGHT);
- add_top = gui_panel_global_get_size (panel, GUI_PANEL_TOP);
- add_bottom = gui_panel_global_get_size (panel, GUI_PANEL_BOTTOM);
- }
-
- 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 + add_left;
- new_panel_win->y = y1 + add_top;
- 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-curses-status.c b/src/gui/curses/gui-curses-status.c
index f5b1821fb..6b975edda 100644
--- a/src/gui/curses/gui-curses-status.c
+++ b/src/gui/curses/gui-curses-status.c
@@ -26,11 +26,13 @@
#include <stdlib.h>
#include <string.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/hotlist.h"
-#include "../../common/utf8.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-utf8.h"
+#include "../gui-status.h"
+#include "../gui-main.h"
+#include "../gui-hotlist.h"
+#include "../gui-window.h"
#include "gui-curses.h"
@@ -39,12 +41,12 @@
*/
void
-gui_status_draw (t_gui_buffer *buffer, int erase)
+gui_status_draw (struct t_gui_buffer *buffer, int erase)
{
- t_gui_window *ptr_win;
- t_weechat_hotlist *ptr_hotlist;
- char format[32], str_nicks[32], *more;
- int x, server_pos, server_total;
+ struct t_gui_window *ptr_win;
+ struct t_gui_hotlist *ptr_hotlist;
+ char format[32], *more;
+ int x;
int display_name, names_count;
/* make C compiler happy */
@@ -56,325 +58,158 @@ 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 (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_WIN_STATUS);
+ gui_window_curses_clear (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_WIN_STATUS);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS);
/* display number of buffers */
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
+ GUI_COLOR_STATUS_DELIMITERS);
mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, 0, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
+ GUI_COLOR_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
(last_gui_buffer) ? last_gui_buffer->number : 0);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
+ GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
- /* display "<servers>" or current server */
- if (ptr_win->buffer->all_servers)
- {
- wprintw (GUI_CURSES(ptr_win)->win_status, "[");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, _("<servers>"));
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
- }
- else if (GUI_SERVER(ptr_win->buffer) && GUI_SERVER(ptr_win->buffer)->name)
+ /* display buffer category */
+ if (ptr_win->buffer->category)
{
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
+ GUI_COLOR_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%s",
- GUI_SERVER(ptr_win->buffer)->name);
- if (GUI_SERVER(ptr_win->buffer)->is_away)
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, _("(away)"));
+ ptr_win->buffer->category);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
+ GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
}
- /* infos about current server buffer */
- if (GUI_SERVER(ptr_win->buffer) && !GUI_CHANNEL(ptr_win->buffer))
- {
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
- ptr_win->buffer->number);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, ":");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_CHANNEL);
- if (GUI_SERVER(ptr_win->buffer)->is_connected)
- {
- if ((ptr_win->buffer->all_servers) && (GUI_SERVER(ptr_win->buffer)->is_away))
- {
- wprintw (GUI_CURSES(ptr_win)->win_status, "[%s",
- GUI_SERVER(ptr_win->buffer)->name);
- wprintw (GUI_CURSES(ptr_win)->win_status, _("(away)"));
- wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
- }
- else
- wprintw (GUI_CURSES(ptr_win)->win_status, "[%s] ",
- GUI_SERVER(ptr_win->buffer)->name);
- }
- else
- wprintw (GUI_CURSES(ptr_win)->win_status, "(%s) ",
- GUI_SERVER(ptr_win->buffer)->name);
- if (ptr_win->buffer->all_servers)
- {
- irc_server_get_number_buffer (GUI_SERVER(ptr_win->buffer),
- &server_pos,
- &server_total);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "(");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "%d", server_pos);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "/");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "%d", server_total);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, ") ");
-
- }
- }
-
- /* infos about current channel/pv buffer */
- if (GUI_SERVER(ptr_win->buffer) && GUI_CHANNEL(ptr_win->buffer))
- {
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
- ptr_win->buffer->number);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, ":");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_CHANNEL);
- if (((GUI_CHANNEL(ptr_win->buffer)->type == IRC_CHANNEL_TYPE_CHANNEL)
- && (!GUI_CHANNEL(ptr_win->buffer)->nicks))
- || ((GUI_CHANNEL(ptr_win->buffer)->type == IRC_CHANNEL_TYPE_DCC_CHAT)
- && (GUI_CHANNEL(ptr_win->buffer)->dcc_chat)
- && (((t_irc_dcc *)(GUI_CHANNEL(ptr_win->buffer)->dcc_chat))->sock < 0)))
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, "(%s)",
- GUI_CHANNEL(ptr_win->buffer)->name);
- else
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, "%s",
- GUI_CHANNEL(ptr_win->buffer)->name);
- if (ptr_win->buffer == GUI_CHANNEL(ptr_win->buffer)->buffer)
- {
- /* display channel modes */
- if (GUI_CHANNEL(ptr_win->buffer)->type == IRC_CHANNEL_TYPE_CHANNEL)
- {
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "(");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- if (GUI_CHANNEL(ptr_win->buffer)->modes
- && (strcmp (GUI_CHANNEL(ptr_win->buffer)->modes, "+") != 0))
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, "%s",
- GUI_CHANNEL(ptr_win->buffer)->modes);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, ")");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- }
-
- /* display DCC if private is DCC CHAT */
- if (GUI_CHANNEL(ptr_win->buffer)->type == IRC_CHANNEL_TYPE_DCC_CHAT)
- {
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "(");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_CHANNEL);
- wprintw (GUI_CURSES(ptr_win)->win_status, "DCC");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, ")");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- }
- }
- wprintw (GUI_CURSES(ptr_win)->win_status, " ");
- }
- if (!GUI_SERVER(ptr_win->buffer))
- {
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
- ptr_win->buffer->number);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, ":");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_CHANNEL);
- switch (ptr_win->buffer->type)
- {
- case GUI_BUFFER_TYPE_STANDARD:
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
- _("[not connected] "));
- break;
- case GUI_BUFFER_TYPE_DCC:
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
- "<DCC> ");
- break;
- case GUI_BUFFER_TYPE_RAW_DATA:
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
- _("<RAW_IRC> "));
- break;
- }
- }
+ /* display buffer name */
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS);
+ wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
+ ptr_win->buffer->number);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS_DELIMITERS);
+ wprintw (GUI_CURSES(ptr_win)->win_status, ":");
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS_CHANNEL);
+ gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, "%s ",
+ ptr_win->buffer->name);
/* display list of other active windows (if any) with numbers */
- if (weechat_hotlist)
+ if (gui_hotlist)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
+ GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_WIN_STATUS);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, _("Act: "));
names_count = 0;
- for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
+ for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
switch (ptr_hotlist->priority)
{
- case HOTLIST_LOW:
+ case GUI_HOTLIST_LOW:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DATA_OTHER);
+ GUI_COLOR_STATUS_DATA_OTHER);
display_name = ((cfg_look_hotlist_names_level & 1) != 0);
break;
- case HOTLIST_MSG:
+ case GUI_HOTLIST_MSG:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DATA_MSG);
+ GUI_COLOR_STATUS_DATA_MSG);
display_name = ((cfg_look_hotlist_names_level & 2) != 0);
break;
- case HOTLIST_PRIVATE:
+ case GUI_HOTLIST_PRIVATE:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DATA_PRIVATE);
+ GUI_COLOR_STATUS_DATA_PRIVATE);
display_name = ((cfg_look_hotlist_names_level & 4) != 0);
break;
- case HOTLIST_HIGHLIGHT:
+ case GUI_HOTLIST_HIGHLIGHT:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DATA_HIGHLIGHT);
+ GUI_COLOR_STATUS_DATA_HIGHLIGHT);
display_name = ((cfg_look_hotlist_names_level & 8) != 0);
break;
default:
display_name = 0;
break;
}
- switch (ptr_hotlist->buffer->type)
+
+ wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
+ ptr_hotlist->buffer->number);
+
+ if (display_name && (cfg_look_hotlist_names_count != 0)
+ && (names_count < cfg_look_hotlist_names_count))
{
- case GUI_BUFFER_TYPE_STANDARD:
- wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
- ptr_hotlist->buffer->number);
-
- if (display_name && (cfg_look_hotlist_names_count != 0)
- && (names_count < cfg_look_hotlist_names_count))
- {
- names_count++;
-
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, ":");
-
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_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 (GUI_BUFFER_IS_SERVER(ptr_hotlist->buffer))
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
- format,
- (ptr_hotlist->server) ?
- ptr_hotlist->server->name :
- GUI_SERVER(ptr_hotlist->buffer)->name);
- else if (GUI_BUFFER_IS_CHANNEL(ptr_hotlist->buffer)
- || GUI_BUFFER_IS_PRIVATE(ptr_hotlist->buffer))
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
- format,
- GUI_CHANNEL(ptr_hotlist->buffer)->name);
- }
- break;
- case GUI_BUFFER_TYPE_DCC:
- wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
- ptr_hotlist->buffer->number);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, ":");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
- "DCC");
- break;
- case GUI_BUFFER_TYPE_RAW_DATA:
- wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
- ptr_hotlist->buffer->number);
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
- wprintw (GUI_CURSES(ptr_win)->win_status, ":");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS);
- gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
- _("RAW_IRC"));
- break;
+ names_count++;
+
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS_DELIMITERS);
+ wprintw (GUI_CURSES(ptr_win)->win_status, ":");
+
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_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);
+ gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
+ format,
+ ptr_hotlist->buffer->name);
}
if (ptr_hotlist->next_hotlist)
wprintw (GUI_CURSES(ptr_win)->win_status, ",");
}
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
+ GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
}
/* display lag */
- if (GUI_SERVER(ptr_win->buffer))
+ /*if (GUI_SERVER(ptr_win->buffer))
{
if (GUI_SERVER(ptr_win->buffer)->lag / 1000 >= cfg_irc_lag_min_show)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
+ GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_WIN_STATUS);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
_("Lag: %.1f"),
((float)(GUI_SERVER(ptr_win->buffer)->lag)) / 1000);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
+ GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "]");
}
- }
+ }*/
/* display "-MORE-" (if last line is not displayed) & nicks count */
- if (GUI_BUFFER_HAS_NICKLIST(ptr_win->buffer))
+ /*if (ptr_win->buffer->attribs & GUI_BUFFER_ATTRIB_NICKLIST)
{
snprintf (str_nicks, sizeof (str_nicks) - 1, "%d",
GUI_CHANNEL(ptr_win->buffer)->nicks_count);
x = ptr_win->win_status_width - utf8_strlen (str_nicks) - 4;
}
- else
+ else*/
x = ptr_win->win_status_width - 2;
more = strdup (_("-MORE-"));
x -= utf8_strlen (more) - 1;
if (x < 0)
x = 0;
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_WIN_STATUS_MORE);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS_MORE);
if (ptr_win->scroll)
{
wmove (GUI_CURSES(ptr_win)->win_status, 0, x);
@@ -382,21 +217,23 @@ gui_status_draw (t_gui_buffer *buffer, int erase)
}
else
{
- snprintf (format, sizeof (format) - 1, "%%-%ds", (int)(utf8_strlen (more)));
+ snprintf (format, sizeof (format) - 1,
+ "%%-%ds", (int)(utf8_strlen (more)));
wmove (GUI_CURSES(ptr_win)->win_status, 0, x);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, format, " ");
}
- if (GUI_BUFFER_HAS_NICKLIST(ptr_win->buffer))
+ /*if (ptr_win->buffer->attribs & GUI_BUFFER_ATTRIB_NICKLIST)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
+ GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, " [");
- gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status, GUI_COLOR_WIN_STATUS);
+ gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
+ GUI_COLOR_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%s", str_nicks);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
- GUI_COLOR_WIN_STATUS_DELIMITERS);
+ GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "]");
- }
+ }*/
free (more);
wnoutrefresh (GUI_CURSES(ptr_win)->win_status);
diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c
index 4d3cb509a..2161496fc 100644
--- a/src/gui/curses/gui-curses-window.c
+++ b/src/gui/curses/gui-curses-window.c
@@ -29,12 +29,17 @@
#include <signal.h>
#include <libgen.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/hotlist.h"
-#include "../../common/log.h"
-#include "../../common/util.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-log.h"
+#include "../../core/wee-string.h"
+#include "../gui-window.h"
+#include "../gui-hotlist.h"
+#include "../gui-infobar.h"
+#include "../gui-input.h"
+#include "../gui-main.h"
+#include "../gui-nicklist.h"
+#include "../gui-status.h"
#include "gui-curses.h"
@@ -66,11 +71,11 @@ gui_window_get_height ()
*/
int
-gui_window_objects_init (t_gui_window *window)
+gui_window_objects_init (struct t_gui_window *window)
{
- t_gui_curses_objects *new_objects;
+ struct t_gui_curses_objects *new_objects;
- if ((new_objects = (t_gui_curses_objects *) malloc (sizeof (t_gui_curses_objects))))
+ if ((new_objects = (struct t_gui_curses_objects *) malloc (sizeof (struct t_gui_curses_objects))))
{
window->gui_objects = new_objects;
GUI_CURSES(window)->win_title = NULL;
@@ -80,7 +85,6 @@ gui_window_objects_init (t_gui_window *window)
GUI_CURSES(window)->win_infobar = NULL;
GUI_CURSES(window)->win_input = NULL;
GUI_CURSES(window)->win_separator = NULL;
- GUI_CURSES(window)->panel_windows = NULL;
return 1;
}
else
@@ -92,7 +96,7 @@ gui_window_objects_init (t_gui_window *window)
*/
void
-gui_window_objects_free (t_gui_window *window, int free_separator)
+gui_window_objects_free (struct t_gui_window *window, int free_separator)
{
if (GUI_CURSES(window)->win_title)
{
@@ -146,7 +150,7 @@ gui_window_wprintw (WINDOW *window, char *data, ...)
vsnprintf (buf, sizeof (buf) - 1, data, argptr);
va_end (argptr);
- buf2 = weechat_iconv_from_internal (NULL, buf);
+ buf2 = string_iconv_from_internal (NULL, buf);
wprintw (window, "%s", (buf2) ? buf2 : buf);
if (buf2)
free (buf2);
@@ -188,24 +192,17 @@ gui_window_set_weechat_color (WINDOW *window, int num_color)
*/
int
-gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
+gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
{
int max_length, max_height, lines, width_used;
- int num_nicks, num_op, num_halfop, num_voice, num_normal;
- int add_right, add_left, add_top, add_bottom;
if (!gui_ok)
return 0;
- add_left = gui_panel_window_get_size (NULL, window, GUI_PANEL_LEFT);
- add_right = gui_panel_window_get_size (NULL, window, GUI_PANEL_RIGHT);
- add_top = gui_panel_window_get_size (NULL, window, GUI_PANEL_TOP);
- add_bottom = gui_panel_window_get_size (NULL, window, GUI_PANEL_BOTTOM);
-
/* init chat & nicklist settings */
- if (cfg_look_nicklist && GUI_BUFFER_IS_CHANNEL(window->buffer))
+ if (cfg_look_nicklist && window->buffer->nicklist)
{
- max_length = irc_nick_get_max_length (GUI_CHANNEL(window->buffer));
+ max_length = gui_nicklist_get_max_length (window->buffer);
lines = 0;
@@ -218,119 +215,122 @@ gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
else if ((cfg_look_nicklist_max_size > 0)
&& (max_length > cfg_look_nicklist_max_size))
max_length = cfg_look_nicklist_max_size;
- if (!force_calculate && (window->win_nick_width == max_length + 1 + cfg_look_nicklist_separator))
+ if (!force_calculate
+ && (window->win_nick_width ==
+ max_length + 1 + cfg_look_nicklist_separator))
return 0;
}
else
{
- irc_nick_count (GUI_CHANNEL(window->buffer), &num_nicks, &num_op,
- &num_halfop, &num_voice, &num_normal);
- width_used = (window->win_width - add_left - add_right)
- - ((window->win_width - add_left - add_right) % (max_length + 2));
- if (((max_length + 2) * num_nicks) % width_used == 0)
- lines = ((max_length + 2) * num_nicks) / width_used;
+ width_used = window->win_width - (window->win_width % (max_length + 2));
+ if (((max_length + 2) * window->buffer->nicks_count) % width_used == 0)
+ lines = ((max_length + 2) * window->buffer->nicks_count) / width_used;
else
- lines = (((max_length + 2) * num_nicks) / width_used) + 1;
- if ((cfg_look_nicklist_max_size > 0) && (lines > cfg_look_nicklist_max_size))
+ lines = (((max_length + 2) * window->buffer->nicks_count) / width_used) + 1;
+ if ((cfg_look_nicklist_max_size > 0)
+ && (lines > cfg_look_nicklist_max_size))
lines = cfg_look_nicklist_max_size;
- if ((cfg_look_nicklist_min_size > 0) && (lines < cfg_look_nicklist_min_size))
+ if ((cfg_look_nicklist_min_size > 0)
+ && (lines < cfg_look_nicklist_min_size))
lines = cfg_look_nicklist_min_size;
max_height = (cfg_look_infobar) ?
- window->win_height - add_top - add_bottom - 3 - 4 :
- window->win_height - add_top - add_bottom - 2 - 4;
+ window->win_height - 3 - 4 :
+ window->win_height - 2 - 4;
if (lines > max_height)
lines = max_height;
- if (!force_calculate && (window->win_nick_height == lines + cfg_look_nicklist_separator))
+ if (!force_calculate
+ && (window->win_nick_height ==
+ lines + cfg_look_nicklist_separator))
return 0;
}
switch (cfg_look_nicklist_position)
{
case CFG_LOOK_NICKLIST_LEFT:
- window->win_chat_x = window->win_x + add_left + max_length + 1 + cfg_look_nicklist_separator;
- window->win_chat_y = window->win_y + add_top + 1;
- window->win_chat_width = window->win_width - add_left - add_right - max_length - 1 - cfg_look_nicklist_separator;
- window->win_nick_x = window->win_x + add_left + 0;
- window->win_nick_y = window->win_y + add_top + 1;
+ window->win_chat_x = window->win_x + max_length + 1 + cfg_look_nicklist_separator;
+ window->win_chat_y = window->win_y + 1;
+ window->win_chat_width = window->win_width - max_length - 1 - cfg_look_nicklist_separator;
+ window->win_nick_x = window->win_x + 0;
+ window->win_nick_y = window->win_y + 1;
window->win_nick_width = max_length + 1 + cfg_look_nicklist_separator;
if (cfg_look_infobar)
{
- window->win_chat_height = window->win_height - add_top - add_bottom - 4;
- window->win_nick_height = window->win_height - add_top - add_bottom - 4;
+ window->win_chat_height = window->win_height - 4;
+ window->win_nick_height = window->win_height - 4;
}
else
{
- window->win_chat_height = window->win_height - add_top - add_bottom - 3;
- window->win_nick_height = window->win_height - add_top - add_bottom - 3;
+ window->win_chat_height = window->win_height - 3;
+ window->win_nick_height = window->win_height - 3;
}
window->win_nick_num_max = window->win_nick_height;
break;
case CFG_LOOK_NICKLIST_RIGHT:
- window->win_chat_x = window->win_x + add_left;
- window->win_chat_y = window->win_y + add_top + 1;
- window->win_chat_width = window->win_width - add_left - add_right - max_length - 1 - cfg_look_nicklist_separator;
- window->win_nick_x = window->win_x + window->win_width - add_right - max_length - 1 - cfg_look_nicklist_separator;
- window->win_nick_y = window->win_y + add_top + 1;
+ window->win_chat_x = window->win_x;
+ window->win_chat_y = window->win_y + 1;
+ window->win_chat_width = window->win_width - max_length - 1 - cfg_look_nicklist_separator;
+ window->win_nick_x = window->win_x + window->win_width - max_length - 1 - cfg_look_nicklist_separator;
+ window->win_nick_y = window->win_y + 1;
window->win_nick_width = max_length + 1 + cfg_look_nicklist_separator;
if (cfg_look_infobar)
{
- window->win_chat_height = window->win_height - add_top - add_bottom - 4;
- window->win_nick_height = window->win_height - add_top - add_bottom - 4;
+ window->win_chat_height = window->win_height - 4;
+ window->win_nick_height = window->win_height - 4;
}
else
{
- window->win_chat_height = window->win_height - add_top - add_bottom - 3;
- window->win_nick_height = window->win_height - add_top - add_bottom - 3;
+ window->win_chat_height = window->win_height - 3;
+ window->win_nick_height = window->win_height - 3;
}
window->win_nick_num_max = window->win_nick_height;
break;
case CFG_LOOK_NICKLIST_TOP:
- window->win_chat_x = window->win_x + add_left;
- window->win_chat_y = window->win_y + add_top + 1 + lines + cfg_look_nicklist_separator;
- window->win_chat_width = window->win_width - add_left - add_right;
+ window->win_chat_x = window->win_x;
+ window->win_chat_y = window->win_y + 1 + lines + cfg_look_nicklist_separator;
+ window->win_chat_width = window->win_width;
if (cfg_look_infobar)
- window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines - cfg_look_nicklist_separator - 1;
+ window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator - 1;
else
- window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines - cfg_look_nicklist_separator;
- window->win_nick_x = window->win_x + add_left;
- window->win_nick_y = window->win_y + add_top + 1;
- window->win_nick_width = window->win_width - add_left - add_right;
+ window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator;
+ window->win_nick_x = window->win_x;
+ window->win_nick_y = window->win_y + 1;
+ window->win_nick_width = window->win_width;
window->win_nick_height = lines + cfg_look_nicklist_separator;
window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 2));
break;
case CFG_LOOK_NICKLIST_BOTTOM:
- window->win_chat_x = window->win_x + add_left;
- window->win_chat_y = window->win_y + add_top + 1;
- window->win_chat_width = window->win_width - add_left - add_right;
+ window->win_chat_x = window->win_x;
+ window->win_chat_y = window->win_y + 1;
+ window->win_chat_width = window->win_width;
if (cfg_look_infobar)
- window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines - cfg_look_nicklist_separator - 1;
+ window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator - 1;
else
- window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines - cfg_look_nicklist_separator;
- window->win_nick_x = window->win_x + add_left;
+ window->win_chat_height = window->win_height - 3 - lines - cfg_look_nicklist_separator;
+ window->win_nick_x = window->win_x;
if (cfg_look_infobar)
- window->win_nick_y = window->win_y + window->win_height - add_bottom - 2 - lines - cfg_look_nicklist_separator - 1;
+ window->win_nick_y = window->win_y + window->win_height - 2 - lines - cfg_look_nicklist_separator - 1;
else
- window->win_nick_y = window->win_y + window->win_height - add_bottom - 2 - lines - cfg_look_nicklist_separator;
- window->win_nick_width = window->win_width - add_left - add_right;
+ window->win_nick_y = window->win_y + window->win_height - 2 - lines - cfg_look_nicklist_separator;
+ window->win_nick_width = window->win_width;
window->win_nick_height = lines + cfg_look_nicklist_separator;
window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 2));
break;
}
- window->win_chat_cursor_x = window->win_x + add_left;
- window->win_chat_cursor_y = window->win_y + add_top;
+ window->win_chat_cursor_x = window->win_x;
+ window->win_chat_cursor_y = window->win_y;
}
else
{
- window->win_chat_x = window->win_x + add_left;
- window->win_chat_y = window->win_y + add_top + 1;
- window->win_chat_width = window->win_width - add_left - add_right;
+ window->win_chat_x = window->win_x;
+ window->win_chat_y = window->win_y + 1;
+ window->win_chat_width = window->win_width;
if (cfg_look_infobar)
- window->win_chat_height = window->win_height - add_top - add_bottom - 4;
+ window->win_chat_height = window->win_height - 4;
else
- window->win_chat_height = window->win_height - add_top - add_bottom - 3;
- window->win_chat_cursor_x = window->win_x + add_left;
- window->win_chat_cursor_y = window->win_y + add_top;
+ window->win_chat_height = window->win_height - 3;
+ window->win_chat_cursor_x = window->win_x;
+ window->win_chat_cursor_y = window->win_y;
window->win_nick_x = -1;
window->win_nick_y = -1;
window->win_nick_width = -1;
@@ -383,7 +383,7 @@ gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
*/
void
-gui_window_draw_separator (t_gui_window *window)
+gui_window_draw_separator (struct t_gui_window *window)
{
if (GUI_CURSES(window)->win_separator)
delwin (GUI_CURSES(window)->win_separator);
@@ -394,8 +394,10 @@ gui_window_draw_separator (t_gui_window *window)
1,
window->win_y,
window->win_x - 1);
- gui_window_set_weechat_color (GUI_CURSES(window)->win_separator, GUI_COLOR_WIN_SEPARATOR);
- wborder (GUI_CURSES(window)->win_separator, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
+ gui_window_set_weechat_color (GUI_CURSES(window)->win_separator,
+ GUI_COLOR_SEPARATOR);
+ wborder (GUI_CURSES(window)->win_separator,
+ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
wnoutrefresh (GUI_CURSES(window)->win_separator);
refresh ();
}
@@ -406,9 +408,9 @@ gui_window_draw_separator (t_gui_window *window)
*/
void
-gui_window_redraw_buffer (t_gui_buffer *buffer)
+gui_window_redraw_buffer (struct t_gui_buffer *buffer)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
if (!gui_ok)
return;
@@ -420,14 +422,13 @@ gui_window_redraw_buffer (t_gui_buffer *buffer)
gui_chat_draw_title (buffer, 1);
gui_chat_draw (buffer, 1);
if (GUI_CURSES(ptr_win)->win_nick)
- gui_nicklist_draw (buffer, 1, 0);
+ gui_nicklist_draw (buffer, 1);
gui_status_draw (buffer, 1);
if (cfg_look_infobar)
gui_infobar_draw (buffer, 1);
gui_input_draw (buffer, 1);
}
}
- gui_panel_redraw_buffer (buffer);
}
/*
@@ -437,7 +438,7 @@ gui_window_redraw_buffer (t_gui_buffer *buffer)
void
gui_window_redraw_all_buffers ()
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
@@ -450,7 +451,8 @@ gui_window_redraw_all_buffers ()
*/
void
-gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
+gui_window_switch_to_buffer (struct t_gui_window *window,
+ struct t_gui_buffer *buffer)
{
if (!gui_ok)
return;
@@ -484,7 +486,7 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
window->win_input_width,
window->win_input_y,
window->win_input_x);
- if (GUI_BUFFER_IS_CHANNEL(buffer))
+ if (buffer->nicklist)
{
if (GUI_CURSES(window)->win_chat)
delwin (GUI_CURSES(window)->win_chat);
@@ -500,7 +502,7 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
else
GUI_CURSES(window)->win_nick = NULL;
}
- if (!GUI_BUFFER_IS_CHANNEL(buffer))
+ else
{
if (GUI_CURSES(window)->win_chat)
delwin (GUI_CURSES(window)->win_chat);
@@ -527,7 +529,7 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
buffer->num_displayed++;
- hotlist_remove_buffer (buffer);
+ gui_hotlist_remove_buffer (buffer);
}
/*
@@ -535,7 +537,7 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
*/
void
-gui_window_page_up (t_gui_window *window)
+gui_window_page_up (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -562,9 +564,9 @@ gui_window_page_up (t_gui_window *window)
*/
void
-gui_window_page_down (t_gui_window *window)
+gui_window_page_down (struct t_gui_window *window)
{
- t_gui_line *ptr_line;
+ struct t_gui_line *ptr_line;
int line_pos;
if (!gui_ok)
@@ -593,7 +595,7 @@ gui_window_page_down (t_gui_window *window)
{
window->start_line = NULL;
window->start_line_pos = 0;
- hotlist_remove_buffer (window->buffer);
+ gui_hotlist_remove_buffer (window->buffer);
}
gui_status_draw (window->buffer, 1);
}
@@ -604,7 +606,7 @@ gui_window_page_down (t_gui_window *window)
*/
void
-gui_window_scroll_up (t_gui_window *window)
+gui_window_scroll_up (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -631,9 +633,9 @@ gui_window_scroll_up (t_gui_window *window)
*/
void
-gui_window_scroll_down (t_gui_window *window)
+gui_window_scroll_down (struct t_gui_window *window)
{
- t_gui_line *ptr_line;
+ struct t_gui_line *ptr_line;
int line_pos;
if (!gui_ok)
@@ -663,7 +665,7 @@ gui_window_scroll_down (t_gui_window *window)
{
window->start_line = NULL;
window->start_line_pos = 0;
- hotlist_remove_buffer (window->buffer);
+ gui_hotlist_remove_buffer (window->buffer);
}
gui_status_draw (window->buffer, 1);
}
@@ -674,7 +676,7 @@ gui_window_scroll_down (t_gui_window *window)
*/
void
-gui_window_scroll_top (t_gui_window *window)
+gui_window_scroll_top (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -698,7 +700,7 @@ gui_window_scroll_top (t_gui_window *window)
*/
void
-gui_window_scroll_bottom (t_gui_window *window)
+gui_window_scroll_bottom (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -712,7 +714,7 @@ gui_window_scroll_bottom (t_gui_window *window)
{
window->start_line = NULL;
window->start_line_pos = 0;
- hotlist_remove_buffer (window->buffer);
+ gui_hotlist_remove_buffer (window->buffer);
}
gui_status_draw (window->buffer, 1);
}
@@ -723,7 +725,7 @@ gui_window_scroll_bottom (t_gui_window *window)
*/
void
-gui_window_scroll_topic_left (t_gui_window *window)
+gui_window_scroll_topic_left (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -740,7 +742,7 @@ gui_window_scroll_topic_left (t_gui_window *window)
*/
void
-gui_window_scroll_topic_right (t_gui_window *window)
+gui_window_scroll_topic_right (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -754,17 +756,17 @@ gui_window_scroll_topic_right (t_gui_window *window)
*/
void
-gui_window_nick_beginning (t_gui_window *window)
+gui_window_nick_beginning (struct t_gui_window *window)
{
if (!gui_ok)
return;
- if (GUI_BUFFER_HAS_NICKLIST(window->buffer))
+ if (window->buffer->nicklist)
{
if (window->win_nick_start > 0)
{
window->win_nick_start = 0;
- gui_nicklist_draw (window->buffer, 1, 0);
+ gui_nicklist_draw (window->buffer, 1);
}
}
}
@@ -774,17 +776,17 @@ gui_window_nick_beginning (t_gui_window *window)
*/
void
-gui_window_nick_end (t_gui_window *window)
+gui_window_nick_end (struct t_gui_window *window)
{
int new_start;
if (!gui_ok)
return;
- if (GUI_BUFFER_HAS_NICKLIST(window->buffer))
+ if (window->buffer->nicklist)
{
new_start =
- GUI_CHANNEL(window->buffer)->nicks_count - window->win_nick_num_max;
+ window->buffer->nicks_count - window->win_nick_num_max;
if (new_start < 0)
new_start = 0;
else if (new_start >= 1)
@@ -793,7 +795,7 @@ gui_window_nick_end (t_gui_window *window)
if (new_start != window->win_nick_start)
{
window->win_nick_start = new_start;
- gui_nicklist_draw (window->buffer, 1, 0);
+ gui_nicklist_draw (window->buffer, 1);
}
}
}
@@ -803,19 +805,19 @@ gui_window_nick_end (t_gui_window *window)
*/
void
-gui_window_nick_page_up (t_gui_window *window)
+gui_window_nick_page_up (struct t_gui_window *window)
{
if (!gui_ok)
return;
- if (GUI_BUFFER_HAS_NICKLIST(window->buffer))
+ if (window->buffer->nicklist)
{
if (window->win_nick_start > 0)
{
window->win_nick_start -= (window->win_nick_num_max - 1);
if (window->win_nick_start <= 1)
window->win_nick_start = 0;
- gui_nicklist_draw (window->buffer, 1, 0);
+ gui_nicklist_draw (window->buffer, 1);
}
}
}
@@ -825,22 +827,22 @@ gui_window_nick_page_up (t_gui_window *window)
*/
void
-gui_window_nick_page_down (t_gui_window *window)
+gui_window_nick_page_down (struct t_gui_window *window)
{
if (!gui_ok)
return;
- if (GUI_BUFFER_HAS_NICKLIST(window->buffer))
+ if (window->buffer->nicklist)
{
- if ((GUI_CHANNEL(window->buffer)->nicks_count > window->win_nick_num_max)
+ if ((window->buffer->nicks_count > window->win_nick_num_max)
&& (window->win_nick_start + window->win_nick_num_max - 1
- < GUI_CHANNEL(window->buffer)->nicks_count))
+ < window->buffer->nicks_count))
{
if (window->win_nick_start == 0)
window->win_nick_start += (window->win_nick_num_max - 1);
else
window->win_nick_start += (window->win_nick_num_max - 2);
- gui_nicklist_draw (window->buffer, 1, 0);
+ gui_nicklist_draw (window->buffer, 1);
}
}
}
@@ -853,7 +855,7 @@ gui_window_nick_page_down (t_gui_window *window)
*/
int
-gui_window_auto_resize (t_gui_window_tree *tree,
+gui_window_auto_resize (struct t_gui_window_tree *tree,
int x, int y, int width, int height,
int simulate)
{
@@ -909,7 +911,7 @@ gui_window_auto_resize (t_gui_window_tree *tree,
void
gui_window_refresh_windows ()
{
- t_gui_window *ptr_win, *old_current_window;
+ struct t_gui_window *ptr_win, *old_current_window;
if (gui_ok)
{
@@ -940,9 +942,9 @@ gui_window_refresh_windows ()
*/
void
-gui_window_split_horiz (t_gui_window *window, int pourcentage)
+gui_window_split_horiz (struct t_gui_window *window, int pourcentage)
{
- t_gui_window *new_window;
+ struct t_gui_window *new_window;
int height1, height2;
if (!gui_ok)
@@ -982,9 +984,9 @@ gui_window_split_horiz (t_gui_window *window, int pourcentage)
*/
void
-gui_window_split_vertic (t_gui_window *window, int pourcentage)
+gui_window_split_vertic (struct t_gui_window *window, int pourcentage)
{
- t_gui_window *new_window;
+ struct t_gui_window *new_window;
int width1, width2;
if (!gui_ok)
@@ -1026,9 +1028,9 @@ gui_window_split_vertic (t_gui_window *window, int pourcentage)
*/
void
-gui_window_resize (t_gui_window *window, int pourcentage)
+gui_window_resize (struct t_gui_window *window, int pourcentage)
{
- t_gui_window_tree *parent;
+ struct t_gui_window_tree *parent;
int old_split_pct;
parent = window->ptr_tree->parent_node;
@@ -1054,9 +1056,9 @@ gui_window_resize (t_gui_window *window, int pourcentage)
*/
int
-gui_window_merge (t_gui_window *window)
+gui_window_merge (struct t_gui_window *window)
{
- t_gui_window_tree *parent, *sister;
+ struct t_gui_window_tree *parent, *sister;
parent = window->ptr_tree->parent_node;
if (parent)
@@ -1099,7 +1101,7 @@ gui_window_merge (t_gui_window *window)
*/
void
-gui_window_merge_all (t_gui_window *window)
+gui_window_merge_all (struct t_gui_window *window)
{
int num_deleted;
@@ -1137,7 +1139,7 @@ gui_window_merge_all (t_gui_window *window)
*/
int
-gui_window_side_by_side (t_gui_window *win1, t_gui_window *win2)
+gui_window_side_by_side (struct t_gui_window *win1, struct t_gui_window *win2)
{
/* win2 over win1 ? */
if (win2->win_y + win2->win_height == win1->win_y)
@@ -1187,9 +1189,9 @@ gui_window_side_by_side (t_gui_window *win1, t_gui_window *win2)
*/
void
-gui_window_switch_up (t_gui_window *window)
+gui_window_switch_up (struct t_gui_window *window)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
@@ -1210,9 +1212,9 @@ gui_window_switch_up (t_gui_window *window)
*/
void
-gui_window_switch_down (t_gui_window *window)
+gui_window_switch_down (struct t_gui_window *window)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
@@ -1233,9 +1235,9 @@ gui_window_switch_down (t_gui_window *window)
*/
void
-gui_window_switch_left (t_gui_window *window)
+gui_window_switch_left (struct t_gui_window *window)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
@@ -1256,9 +1258,9 @@ gui_window_switch_left (t_gui_window *window)
*/
void
-gui_window_switch_right (t_gui_window *window)
+gui_window_switch_right (struct t_gui_window *window)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
@@ -1317,11 +1319,11 @@ gui_window_refresh_screen_sigwinch ()
}
/*
- * gui_window_set_title: set terminal title
+ * gui_window_title_set: set terminal title
*/
void
-gui_window_set_title ()
+gui_window_title_set ()
{
char *envterm = getenv ("TERM");
@@ -1351,11 +1353,11 @@ gui_window_set_title ()
}
/*
- * gui_window_reset_title: reset terminal title
+ * gui_window_title_reset: reset terminal title
*/
void
-gui_window_reset_title ()
+gui_window_title_reset ()
{
char *envterm = getenv ("TERM");
char *envshell = getenv ("SHELL");
@@ -1403,10 +1405,8 @@ gui_window_reset_title ()
*/
void
-gui_window_objects_print_log (t_gui_window *window)
+gui_window_objects_print_log (struct t_gui_window *window)
{
- t_gui_panel_window *ptr_panel_win;
-
weechat_log_printf (" win_title . . . . . : 0x%X\n", GUI_CURSES(window)->win_title);
weechat_log_printf (" win_chat. . . . . . : 0x%X\n", GUI_CURSES(window)->win_chat);
weechat_log_printf (" win_nick. . . . . . : 0x%X\n", GUI_CURSES(window)->win_nick);
@@ -1414,18 +1414,4 @@ gui_window_objects_print_log (t_gui_window *window)
weechat_log_printf (" win_infobar . . . . : 0x%X\n", GUI_CURSES(window)->win_infobar);
weechat_log_printf (" win_input . . . . . : 0x%X\n", GUI_CURSES(window)->win_input);
weechat_log_printf (" win_separator . . . : 0x%X\n", GUI_CURSES(window)->win_separator);
- for (ptr_panel_win = GUI_CURSES(window)->panel_windows;
- ptr_panel_win; ptr_panel_win = ptr_panel_win->next_panel_window)
- {
- weechat_log_printf ("\n");
- weechat_log_printf (" [window panel (addr:0x%X)]\n", ptr_panel_win);
- weechat_log_printf (" panel . . . . . . : 0x%X\n", ptr_panel_win->panel);
- weechat_log_printf (" x . . . . . . . . : %d\n", ptr_panel_win->x);
- weechat_log_printf (" y . . . . . . . . : %d\n", ptr_panel_win->y);
- weechat_log_printf (" width . . . . . . : %d\n", ptr_panel_win->width);
- weechat_log_printf (" height. . . . . . : %d\n", ptr_panel_win->height);
- weechat_log_printf (" win_panel . . . . : 0x%X\n", ptr_panel_win->win_panel);
- weechat_log_printf (" win_separator . . : 0x%X\n", ptr_panel_win->win_separator);
- weechat_log_printf (" next_panel_window : 0x%X\n", ptr_panel_win->next_panel_window);
- }
}
diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h
index 190a29143..2801b6862 100644
--- a/src/gui/curses/gui-curses.h
+++ b/src/gui/curses/gui-curses.h
@@ -28,37 +28,11 @@
#include <curses.h>
#endif
-/* shift ncurses colors for compatibility with colors
- in IRC messages (same as other IRC clients) */
-
-#define WEECHAT_COLOR_BLACK COLOR_BLACK
-#define WEECHAT_COLOR_RED COLOR_BLUE
-#define WEECHAT_COLOR_GREEN COLOR_GREEN
-#define WEECHAT_COLOR_YELLOW COLOR_CYAN
-#define WEECHAT_COLOR_BLUE COLOR_RED
-#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
-#define WEECHAT_COLOR_CYAN COLOR_YELLOW
-#define WEECHAT_COLOR_WHITE COLOR_WHITE
-
#define WINDOW_MIN_WIDTH 10
#define WINDOW_MIN_HEIGHT 5
#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
@@ -70,11 +44,9 @@ struct t_gui_curses_objects
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 struct t_gui_color gui_weechat_colors[];
extern int gui_refresh_screen_needed;
/* color functions */
@@ -82,7 +54,8 @@ extern int gui_color_get_pair (int);
extern void gui_color_init ();
/* chat functions */
-extern void gui_chat_calculate_line_diff (t_gui_window *, t_gui_line **, int *, int);
+extern void gui_chat_calculate_line_diff (struct t_gui_window *,
+ struct t_gui_line **, int *, int);
/* keyboard functions */
extern void gui_keyboard_default_bindings ();
@@ -94,11 +67,7 @@ extern void gui_window_wprintw (WINDOW *, char *, ...);
extern void gui_window_curses_clear (WINDOW *, int);
extern void gui_window_set_weechat_color (WINDOW *, int);
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_window_get_size (t_gui_panel *, t_gui_window *, int);
-extern void gui_panel_redraw_buffer (t_gui_buffer *);
+extern void gui_window_title_set ();
+extern void gui_window_title_reset ();
#endif /* gui-curses.h */
diff --git a/src/gui/gtk/CMakeLists.txt b/src/gui/gtk/CMakeLists.txt
index 68704769e..7b3523b0b 100644
--- a/src/gui/gtk/CMakeLists.txt
+++ b/src/gui/gtk/CMakeLists.txt
@@ -16,7 +16,7 @@
SET(WEECHAT_GTK_SRC 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)
+gui-gtk-status.c gui-gtk-window.c gui-gtk.h)
SET(EXECUTABLE weechat-gtk)
@@ -32,8 +32,7 @@ IF(PKG_CONFIG_FOUND)
ENDIF(PKG_CONFIG_FOUND)
ADD_EXECUTABLE(${EXECUTABLE} ${WEECHAT_GTK_SRC})
-INCLUDE_DIRECTORIES(.. ../../common ../../protocols ../../protocols/irc
-../../plugins)
+INCLUDE_DIRECTORIES(.. ../../core ../../plugins)
TARGET_LINK_LIBRARIES(${EXECUTABLE} ${STATIC_LIBS} ${EXTRA_LIBS})
INSTALL(TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin)
diff --git a/src/gui/gtk/Makefile.am b/src/gui/gtk/Makefile.am
index c6968762f..aec706d7a 100644
--- a/src/gui/gtk/Makefile.am
+++ b/src/gui/gtk/Makefile.am
@@ -18,10 +18,11 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(GTK_CFLAGS)
bin_PROGRAMS = weechat-gtk
-weechat_gtk_LDADD = $(WEECHAT_STATIC_LIBS) \
- $(PLUGINS_LIBS) \
- $(GTK_LIBS) \
- $(GNUTLS_LFLAGS)
+weechat_gtk_LDADD = ../../core/lib_weechat_core.a \
+ ../../plugins/lib_weechat_plugins.a \
+ ../lib_weechat_gui_common.a \
+ $(PLUGINS_LFLAGS) \
+ $(GTK_LFLAGS)
weechat_gtk_SOURCES = gui-gtk-chat.c \
gui-gtk-color.c \
@@ -32,5 +33,4 @@ weechat_gtk_SOURCES = gui-gtk-chat.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-gtk-chat.c b/src/gui/gtk/gui-gtk-chat.c
index 6dae777e4..c3f6f409f 100644
--- a/src/gui/gtk/gui-gtk-chat.c
+++ b/src/gui/gtk/gui-gtk-chat.c
@@ -27,11 +27,12 @@
#include <string.h>
#include <ctype.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/utf8.h"
-#include "../../common/weeconfig.h"
-#include "../../protocols/irc/irc.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-utf8.h"
+#include "../gui-chat.h"
+#include "../gui-main.h"
+#include "../gui-window.h"
#include "gui-gtk.h"
@@ -41,7 +42,7 @@
*/
void
-gui_chat_set_style (t_gui_window *window, int style)
+gui_chat_set_style (struct t_gui_window *window, int style)
{
/* TODO: write this function for Gtk */
/*wattron (window->win_chat, style);*/
@@ -55,7 +56,7 @@ gui_chat_set_style (t_gui_window *window, int style)
*/
void
-gui_chat_remove_style (t_gui_window *window, int style)
+gui_chat_remove_style (struct t_gui_window *window, int style)
{
/* TODO: write this function for Gtk */
/*wattroff (window->win_chat, style);*/
@@ -69,7 +70,7 @@ gui_chat_remove_style (t_gui_window *window, int style)
*/
void
-gui_chat_toggle_style (t_gui_window *window, int style)
+gui_chat_toggle_style (struct t_gui_window *window, int style)
{
window->current_style_attr ^= style;
if (window->current_style_attr & style)
@@ -84,7 +85,7 @@ gui_chat_toggle_style (t_gui_window *window, int style)
*/
void
-gui_chat_reset_style (t_gui_window *window)
+gui_chat_reset_style (struct t_gui_window *window)
{
window->current_style_fg = -1;
window->current_style_bg = -1;
@@ -102,7 +103,7 @@ gui_chat_reset_style (t_gui_window *window)
*/
void
-gui_chat_set_color_style (t_gui_window *window, int style)
+gui_chat_set_color_style (struct t_gui_window *window, int style)
{
window->current_color_attr |= style;
/* TODO: change following function call */
@@ -114,7 +115,7 @@ gui_chat_set_color_style (t_gui_window *window, int style)
*/
void
-gui_chat_remove_color_style (t_gui_window *window, int style)
+gui_chat_remove_color_style (struct t_gui_window *window, int style)
{
window->current_color_attr &= !style;
/* TODO: change following function call */
@@ -126,7 +127,7 @@ gui_chat_remove_color_style (t_gui_window *window, int style)
*/
void
-gui_chat_reset_color_style (t_gui_window *window)
+gui_chat_reset_color_style (struct t_gui_window *window)
{
/* TODO: change following function call */
/*wattroff (window->win_chat, window->current_color_attr);*/
@@ -138,7 +139,7 @@ gui_chat_reset_color_style (t_gui_window *window)
*/
void
-gui_chat_set_color (t_gui_window *window, int fg, int bg)
+gui_chat_set_color (struct t_gui_window *window, int fg, int bg)
{
/* TODO: write this function for Gtk */
/*if (((fg == -1) || (fg == 99))
@@ -162,7 +163,7 @@ gui_chat_set_color (t_gui_window *window, int fg, int bg)
*/
void
-gui_chat_set_weechat_color (t_gui_window *window, int weechat_color)
+gui_chat_set_weechat_color (struct t_gui_window *window, int weechat_color)
{
gui_chat_reset_style (window);
gui_chat_set_style (window,
@@ -177,7 +178,7 @@ gui_chat_set_weechat_color (t_gui_window *window, int weechat_color)
*/
void
-gui_chat_draw_title (t_gui_buffer *buffer, int erase)
+gui_chat_draw_title (struct t_gui_buffer *buffer, int erase)
{
/* TODO: write this function for Gtk */
(void) buffer;
@@ -185,99 +186,28 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase)
}
/*
- * gui_chat_word_get_next_char: returns next char of a word
- * special chars like colors, bold, .. are skipped
+ * gui_chat_string_next_char: returns next char of a word (for display)
+ * special chars like colors, bold, .. are skipped
+ * and optionaly applied
*/
char *
-gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
- int apply_style, int *width_screen)
+gui_chat_string_next_char (struct t_gui_window *window, unsigned char *string,
+ int apply_style)
{
- char str_fg[3], str_bg[3], utf_char[16];
- int fg, bg, weechat_color, char_size;
-
- if (width_screen)
- *width_screen = 0;
+ char str_fg[3];
+ int weechat_color;
while (string[0])
{
switch (string[0])
{
- case GUI_ATTR_BOLD_CHAR:
- string++;
- if (apply_style)
- gui_chat_toggle_style (window, A_BOLD);
- break;
- case GUI_ATTR_COLOR_CHAR:
- string++;
- str_fg[0] = '\0';
- str_bg[0] = '\0';
- fg = 99;
- bg = 99;
- if (isdigit (string[0]))
- {
- str_fg[0] = string[0];
- str_fg[1] = '\0';
- string++;
- if (isdigit (string[0]))
- {
- str_fg[1] = string[0];
- str_fg[2] = '\0';
- string++;
- }
- }
- if (string[0] == ',')
- {
- string++;
- if (isdigit (string[0]))
- {
- str_bg[0] = string[0];
- str_bg[1] = '\0';
- string++;
- if (isdigit (string[0]))
- {
- str_bg[1] = string[0];
- str_bg[2] = '\0';
- string++;
- }
- }
- }
- if (apply_style)
- {
- if (str_fg[0] || str_bg[0])
- {
- if (str_fg[0])
- sscanf (str_fg, "%d", &fg);
- else
- fg = window->current_style_fg;
- if (str_bg[0])
- sscanf (str_bg, "%d", &bg);
- else
- bg = window->current_style_bg;
- }
- if (!str_fg[0] && !str_bg[0])
- gui_chat_reset_color_style (window);
- window->current_style_fg = fg;
- window->current_style_bg = bg;
- gui_chat_set_color (window, fg, bg);
- }
- break;
- case GUI_ATTR_RESET_CHAR:
- case GUI_ATTR_WEECHAT_RESET_CHAR:
+ case GUI_COLOR_RESET_CHAR:
string++;
if (apply_style)
gui_chat_reset_style (window);
break;
- case GUI_ATTR_FIXED_CHAR:
- string++;
- break;
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
- string++;
- if (apply_style)
- gui_chat_toggle_style (window, A_REVERSE);
- break;
- case GUI_ATTR_WEECHAT_COLOR_CHAR:
+ case GUI_COLOR_COLOR_CHAR:
string++;
if (isdigit (string[0]) && isdigit (string[1]))
{
@@ -292,72 +222,62 @@ gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
}
}
break;
- case GUI_ATTR_WEECHAT_SET_CHAR:
+ case GUI_COLOR_SET_CHAR:
string++;
switch (string[0])
{
- case GUI_ATTR_BOLD_CHAR:
+ case GUI_COLOR_ATTR_BOLD_CHAR:
string++;
if (apply_style)
gui_chat_set_color_style (window, A_BOLD);
break;
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
+ case GUI_COLOR_ATTR_REVERSE_CHAR:
string++;
if (apply_style)
gui_chat_set_color_style (window, A_REVERSE);
break;
- case GUI_ATTR_UNDERLINE_CHAR:
+ case GUI_COLOR_ATTR_ITALIC_CHAR:
+ /* not available in Curses GUI */
+ string++;
+ break;
+ case GUI_COLOR_ATTR_UNDERLINE_CHAR:
string++;
if (apply_style)
gui_chat_set_color_style (window, A_UNDERLINE);
break;
}
break;
- case GUI_ATTR_WEECHAT_REMOVE_CHAR:
+ case GUI_COLOR_REMOVE_CHAR:
string++;
switch (string[0])
{
- case GUI_ATTR_BOLD_CHAR:
+ case GUI_COLOR_ATTR_BOLD_CHAR:
string++;
if (apply_style)
gui_chat_remove_color_style (window, A_BOLD);
break;
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
+ case GUI_COLOR_ATTR_REVERSE_CHAR:
string++;
if (apply_style)
gui_chat_remove_color_style (window, A_REVERSE);
break;
- case GUI_ATTR_UNDERLINE_CHAR:
+ case GUI_COLOR_ATTR_ITALIC_CHAR:
+ /* not available in Curses GUI */
+ string++;
+ break;
+ case GUI_COLOR_ATTR_UNDERLINE_CHAR:
string++;
if (apply_style)
gui_chat_remove_color_style (window, A_UNDERLINE);
break;
}
break;
- case GUI_ATTR_ITALIC_CHAR:
- string++;
- break;
- case GUI_ATTR_UNDERLINE_CHAR:
- string++;
- if (apply_style)
- gui_chat_toggle_style (window, A_UNDERLINE);
- break;
default:
if (string[0] < 32)
string++;
else
- {
- char_size = utf8_char_size ((char *) string);
- if (width_screen)
- {
- memcpy (utf_char, string, char_size);
- utf_char[char_size] = '\0';
- *width_screen = utf8_width_screen (utf_char);
- }
- return (char *)string + char_size;
- }
+ return (char *)string;
+ break;
}
}
@@ -372,7 +292,7 @@ gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
*/
void
-gui_chat_display_word_raw (t_gui_window *window, char *string)
+gui_chat_display_word_raw (struct t_gui_window *window, char *string)
{
/*char *prev_char, *next_char, saved_char;*/
@@ -386,8 +306,8 @@ gui_chat_display_word_raw (t_gui_window *window, char *string)
*/
void
-gui_chat_display_word (t_gui_window *window,
- t_gui_line *line,
+gui_chat_display_word (struct t_gui_window *window,
+ struct t_gui_line *line,
char *data,
char *end_offset,
int num_lines, int count, int *lines_displayed, int simulate)
@@ -407,68 +327,6 @@ gui_chat_display_word (t_gui_window *window,
}
/*
- * gui_chat_get_word_info: returns info about next word: beginning, end, length
- */
-
-void
-gui_chat_get_word_info (t_gui_window *window,
- char *data,
- int *word_start_offset, int *word_end_offset,
- int *word_length_with_spaces, int *word_length)
-{
- char *start_data, *prev_char, *next_char;
- int leading_spaces, char_size;
-
- *word_start_offset = 0;
- *word_end_offset = 0;
- *word_length_with_spaces = 0;
- *word_length = 0;
-
- start_data = data;
-
- leading_spaces = 1;
- while (data && data[0])
- {
- next_char = gui_chat_word_get_next_char (window,
- (unsigned char *)data,
- 0, NULL);
- if (next_char)
- {
- prev_char = utf8_prev_char (data, next_char);
- if (prev_char)
- {
- if (prev_char[0] != ' ')
- {
- if (leading_spaces)
- *word_start_offset = prev_char - start_data;
- leading_spaces = 0;
- char_size = next_char - prev_char;
- *word_end_offset = next_char - start_data - 1;
- (*word_length_with_spaces) += char_size;
- (*word_length) += char_size;
- }
- else
- {
- if (leading_spaces)
- (*word_length_with_spaces)++;
- else
- {
- *word_end_offset = prev_char - start_data - 1;
- return;
- }
- }
- data = next_char;
- }
- }
- else
- {
- *word_end_offset = data + strlen (data) - start_data - 1;
- return;
- }
- }
-}
-
-/*
* gui_chat_display_line: display a line in the chat window
* if count == 0, display whole line
* if count > 0, display 'count' lines (beginning from the end)
@@ -478,7 +336,7 @@ gui_chat_get_word_info (t_gui_window *window,
*/
int
-gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count,
+gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, int count,
int simulate)
{
/* TODO: write this function for Gtk */
@@ -495,7 +353,7 @@ gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count,
*/
void
-gui_chat_calculate_line_diff (t_gui_window *window, t_gui_line **line,
+gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **line,
int *line_pos, int difference)
{
int backward, current_size;
@@ -593,10 +451,10 @@ gui_chat_calculate_line_diff (t_gui_window *window, t_gui_line **line,
*/
void
-gui_chat_draw (t_gui_buffer *buffer, int erase)
+gui_chat_draw (struct t_gui_buffer *buffer, int erase)
{
- /*t_gui_window *ptr_win;
- t_gui_line *ptr_line;
+ /*struct t_gui_window *ptr_win;
+ struct t_gui_line *ptr_line;
t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc;
char format_empty[32];
int i, j, line_pos, count, num_bars;
@@ -620,27 +478,27 @@ gui_chat_draw (t_gui_buffer *buffer, int erase)
*/
void
-gui_chat_draw_line (t_gui_buffer *buffer, t_gui_line *line)
+gui_chat_draw_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
{
- t_gui_window *ptr_win;
- unsigned char *text_without_color;
+ struct t_gui_window *ptr_win;
+ unsigned char *message_without_color;
GtkTextIter start, end;
ptr_win = gui_buffer_find_window (buffer);
if (ptr_win)
{
- text_without_color = gui_color_decode ((unsigned char *)(line->data), 0, 0);
- if (text_without_color)
+ message_without_color = gui_color_decode ((unsigned char *)(line->message));
+ if (message_without_color)
{
gtk_text_buffer_insert_at_cursor (GUI_GTK(ptr_win)->textbuffer_chat,
- (char *)text_without_color, -1);
+ (char *)message_without_color, -1);
gtk_text_buffer_insert_at_cursor (GUI_GTK(ptr_win)->textbuffer_chat,
"\n", -1);
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);*/
- free (text_without_color);
+ free (message_without_color);
}
}
}
diff --git a/src/gui/gtk/gui-gtk-color.c b/src/gui/gtk/gui-gtk-color.c
index f7ff20ed2..3107ae391 100644
--- a/src/gui/gtk/gui-gtk-color.c
+++ b/src/gui/gtk/gui-gtk-color.c
@@ -27,14 +27,14 @@
#include <string.h>
#include <ctype.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/util.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-string.h"
+#include "../gui-color.h"
#include "gui-gtk.h"
-t_gui_color gui_weechat_colors[] =
+struct t_gui_color gui_weechat_colors[] =
{ { -1, 0, 0, "default" },
{ WEECHAT_COLOR_BLACK, 0, 0, "black" },
{ WEECHAT_COLOR_RED, 0, 0, "red" },
@@ -53,26 +53,7 @@ t_gui_color gui_weechat_colors[] =
{ 0, 0, 0, NULL }
};
-int gui_irc_colors[GUI_NUM_IRC_COLORS][2] =
-{ { /* 0 */ WEECHAT_COLOR_WHITE, A_BOLD },
- { /* 1 */ WEECHAT_COLOR_BLACK, 0 },
- { /* 2 */ WEECHAT_COLOR_BLUE, 0 },
- { /* 3 */ WEECHAT_COLOR_GREEN, 0 },
- { /* 4 */ WEECHAT_COLOR_RED, A_BOLD },
- { /* 5 */ WEECHAT_COLOR_RED, 0 },
- { /* 6 */ WEECHAT_COLOR_MAGENTA, 0 },
- { /* 7 */ WEECHAT_COLOR_YELLOW, 0 },
- { /* 8 */ WEECHAT_COLOR_YELLOW, A_BOLD },
- { /* 9 */ WEECHAT_COLOR_GREEN, A_BOLD },
- { /* 10 */ WEECHAT_COLOR_CYAN, 0 },
- { /* 11 */ WEECHAT_COLOR_CYAN, A_BOLD },
- { /* 12 */ WEECHAT_COLOR_BLUE, A_BOLD },
- { /* 13 */ WEECHAT_COLOR_MAGENTA, A_BOLD },
- { /* 14 */ WEECHAT_COLOR_WHITE, 0 },
- { /* 15 */ WEECHAT_COLOR_WHITE, A_BOLD }
-};
-
-t_gui_color *gui_color[GUI_NUM_COLORS];
+struct t_gui_color *gui_color[GUI_NUM_COLORS];
/*
@@ -88,7 +69,7 @@ gui_color_assign (int *color, char *color_name)
i = 0;
while (gui_weechat_colors[i].string)
{
- if (ascii_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
+ if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
{
*color = i;
return 1;
@@ -111,332 +92,6 @@ gui_color_get_name (int num_color)
}
/*
- * gui_color_decode: parses a message (coming from IRC server),
- * if keep_colors == 0: remove any color/style in message
- * otherwise change colors by internal WeeChat color codes
- * if wkeep_eechat_attr == 0: remove any weechat color/style attribute
- * After use, string returned has to be free()
- */
-
-unsigned char *
-gui_color_decode (unsigned char *string, int keep_irc_colors, int keep_weechat_attr)
-{
- unsigned char *out;
- int out_length, out_pos;
- char str_fg[3], str_bg[3];
- int fg, bg, attr;
-
- out_length = (strlen ((char *)string) * 2) + 1;
- out = (unsigned char *)malloc (out_length);
- if (!out)
- return NULL;
-
- out_pos = 0;
- while (string && string[0] && (out_pos < out_length - 1))
- {
- switch (string[0])
- {
- case GUI_ATTR_BOLD_CHAR:
- case GUI_ATTR_RESET_CHAR:
- case GUI_ATTR_FIXED_CHAR:
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
- case GUI_ATTR_ITALIC_CHAR:
- case GUI_ATTR_UNDERLINE_CHAR:
- if (keep_irc_colors)
- out[out_pos++] = string[0];
- string++;
- break;
- case GUI_ATTR_COLOR_CHAR:
- string++;
- str_fg[0] = '\0';
- str_bg[0] = '\0';
- if (isdigit (string[0]))
- {
- str_fg[0] = string[0];
- str_fg[1] = '\0';
- string++;
- if (isdigit (string[0]))
- {
- str_fg[1] = string[0];
- str_fg[2] = '\0';
- string++;
- }
- }
- if (string[0] == ',')
- {
- string++;
- if (isdigit (string[0]))
- {
- str_bg[0] = string[0];
- str_bg[1] = '\0';
- string++;
- if (isdigit (string[0]))
- {
- str_bg[1] = string[0];
- str_bg[2] = '\0';
- string++;
- }
- }
- }
- if (keep_irc_colors)
- {
- if (!str_fg[0] && !str_bg[0])
- out[out_pos++] = GUI_ATTR_COLOR_CHAR;
- else
- {
- attr = 0;
- if (str_fg[0])
- {
- sscanf (str_fg, "%d", &fg);
- fg %= GUI_NUM_IRC_COLORS;
- attr |= gui_irc_colors[fg][1];
- }
- if (str_bg[0])
- {
- sscanf (str_bg, "%d", &bg);
- bg %= GUI_NUM_IRC_COLORS;
- attr |= gui_irc_colors[bg][1];
- }
- if (attr & A_BOLD)
- {
- out[out_pos++] = GUI_ATTR_WEECHAT_SET_CHAR;
- out[out_pos++] = GUI_ATTR_BOLD_CHAR;
- }
- else
- {
- out[out_pos++] = GUI_ATTR_WEECHAT_REMOVE_CHAR;
- out[out_pos++] = GUI_ATTR_BOLD_CHAR;
- }
- out[out_pos++] = GUI_ATTR_COLOR_CHAR;
- if (str_fg[0])
- {
- out[out_pos++] = (gui_irc_colors[fg][0] / 10) + '0';
- out[out_pos++] = (gui_irc_colors[fg][0] % 10) + '0';
- }
- if (str_bg[0])
- {
- out[out_pos++] = ',';
- out[out_pos++] = (gui_irc_colors[bg][0] / 10) + '0';
- out[out_pos++] = (gui_irc_colors[bg][0] % 10) + '0';
- }
- }
- }
- break;
- case GUI_ATTR_WEECHAT_COLOR_CHAR:
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]) && isdigit (string[1]))
- {
- if (keep_weechat_attr)
- {
- out[out_pos++] = string[0];
- out[out_pos++] = string[1];
- }
- string += 2;
- }
- break;
- case GUI_ATTR_WEECHAT_SET_CHAR:
- case GUI_ATTR_WEECHAT_REMOVE_CHAR:
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- if (string[0])
- {
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- }
- break;
- case GUI_ATTR_WEECHAT_RESET_CHAR:
- if (keep_weechat_attr)
- out[out_pos++] = string[0];
- string++;
- break;
- default:
- out[out_pos++] = string[0];
- string++;
- }
- }
- out[out_pos] = '\0';
- return out;
-}
-
-/*
- * gui_color_decode_for_user_entry: parses a message (coming from IRC server),
- * and replaces colors/bold/.. by ^C, ^B, ..
- * After use, string returned has to be free()
- */
-
-unsigned char *
-gui_color_decode_for_user_entry (unsigned char *string)
-{
- unsigned char *out;
- int out_length, out_pos;
-
- out_length = (strlen ((char *)string) * 2) + 1;
- out = (unsigned char *)malloc (out_length);
- if (!out)
- return NULL;
-
- out_pos = 0;
- while (string && string[0] && (out_pos < out_length - 1))
- {
- switch (string[0])
- {
- case GUI_ATTR_BOLD_CHAR:
- out[out_pos++] = 0x02; /* ^B */
- string++;
- break;
- case GUI_ATTR_FIXED_CHAR:
- string++;
- break;
- case GUI_ATTR_RESET_CHAR:
- out[out_pos++] = 0x0F; /* ^O */
- string++;
- break;
- case GUI_ATTR_REVERSE_CHAR:
- case GUI_ATTR_REVERSE2_CHAR:
- out[out_pos++] = 0x12; /* ^R */
- string++;
- break;
- case GUI_ATTR_ITALIC_CHAR:
- string++;
- break;
- case GUI_ATTR_UNDERLINE_CHAR:
- out[out_pos++] = 0x15; /* ^U */
- string++;
- break;
- case GUI_ATTR_COLOR_CHAR:
- out[out_pos++] = 0x03; /* ^C */
- string++;
- break;
- default:
- out[out_pos++] = string[0];
- string++;
- }
- }
- out[out_pos] = '\0';
- return out;
-}
-
-/*
- * gui_color_encode: parses a message (entered by user), and
- * encode special chars (^Cb, ^Cc, ..) in IRC colors
- * if keep_colors == 0: remove any color/style in message
- * otherwise: keep colors
- * After use, string returned has to be free()
- */
-
-unsigned char *
-gui_color_encode (unsigned char *string, int keep_colors)
-{
- unsigned char *out;
- int out_length, out_pos;
-
- out_length = (strlen ((char *)string) * 2) + 1;
- out = (unsigned char *)malloc (out_length);
- if (!out)
- return NULL;
-
- out_pos = 0;
- while (string && string[0] && (out_pos < out_length - 1))
- {
- switch (string[0])
- {
- case 0x02: /* ^B */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_BOLD_CHAR;
- string++;
- break;
- case 0x03: /* ^C */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_COLOR_CHAR;
- string++;
- if (isdigit (string[0]))
- {
- if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
- {
- if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- }
- }
- if (string[0] == ',')
- {
- if (keep_colors)
- out[out_pos++] = ',';
- string++;
- if (isdigit (string[0]))
- {
- if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- if (isdigit (string[0]))
- {
- if (keep_colors)
- out[out_pos++] = string[0];
- string++;
- }
- }
- }
- break;
- case 0x0F: /* ^O */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_RESET_CHAR;
- string++;
- break;
- case 0x12: /* ^R */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
- string++;
- break;
- case 0x15: /* ^U */
- if (keep_colors)
- out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
- string++;
- break;
- default:
- out[out_pos++] = string[0];
- string++;
- }
- }
- out[out_pos] = '\0';
- return out;
-}
-
-/*
- * gui_color_build: build a WeeChat color with foreground,
- * background and attributes (attributes are
- * given with foreground color, with a OR)
- */
-
-t_gui_color *
-gui_color_build (int number, int foreground, int background)
-{
- t_gui_color *new_color;
-
- new_color = (t_gui_color *)malloc (sizeof (t_gui_color));
- if (!new_color)
- return NULL;
-
- new_color->foreground = gui_weechat_colors[foreground].foreground;
- new_color->background = gui_weechat_colors[background].foreground;
- new_color->attributes = gui_weechat_colors[foreground].attributes;
- new_color->string = (char *)malloc (4);
- if (new_color->string)
- snprintf (new_color->string, 4,
- "%s%02d",
- GUI_ATTR_WEECHAT_COLOR_STR, number);
-
- return new_color;
-}
-
-/*
* gui_color_get_pair: get color pair with a WeeChat color number
*/
diff --git a/src/gui/gtk/gui-gtk-infobar.c b/src/gui/gtk/gui-gtk-infobar.c
index f1556f8c7..f546cbf97 100644
--- a/src/gui/gtk/gui-gtk-infobar.c
+++ b/src/gui/gtk/gui-gtk-infobar.c
@@ -26,10 +26,10 @@
#include <stdlib.h>
#include <string.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/hotlist.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../gui-infobar.h"
+#include "../gui-main.h"
#include "gui-gtk.h"
@@ -38,9 +38,9 @@
*/
void
-gui_infobar_draw_time (t_gui_buffer *buffer)
+gui_infobar_draw_time (struct t_gui_buffer *buffer)
{
- /*t_gui_window *ptr_win;
+ /*struct t_gui_window *ptr_win;
time_t time_seconds;
struct tm *local_time;*/
@@ -59,9 +59,9 @@ gui_infobar_draw_time (t_gui_buffer *buffer)
*/
void
-gui_infobar_draw (t_gui_buffer *buffer, int erase)
+gui_infobar_draw (struct t_gui_buffer *buffer, int erase)
{
- /*t_gui_window *ptr_win;
+ /*struct t_gui_window *ptr_win;
time_t time_seconds;
struct tm *local_time;
char text_time[1024 + 1];*/
diff --git a/src/gui/gtk/gui-gtk-input.c b/src/gui/gtk/gui-gtk-input.c
index 30c7c9318..35111c01c 100644
--- a/src/gui/gtk/gui-gtk-input.c
+++ b/src/gui/gtk/gui-gtk-input.c
@@ -25,23 +25,21 @@
#include <stdlib.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/utf8.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-utf8.h"
+#include "../../plugins/plugin.h"
+#include "../gui-input.h"
+#include "../gui-main.h"
#include "gui-gtk.h"
-#ifdef PLUGINS
-#include "../../plugins/plugins.h"
-#endif
-
/*
* gui_input_set_color: set color for an input window
*/
void
-gui_input_set_color (t_gui_window *window, int irc_color)
+gui_input_set_color (struct t_gui_window *window, int irc_color)
{
/*int fg, bg;*/
@@ -51,87 +49,11 @@ gui_input_set_color (t_gui_window *window, int irc_color)
}
/*
- * gui_input_get_prompt_length: return input prompt length
- */
-
-int
-gui_input_get_prompt_length (t_gui_window *window, char *nick)
-{
- char *pos, *modes;
- int length, mode_found;
-
- length = 0;
- pos = cfg_look_input_format;
- while (pos && pos[0])
- {
- switch (pos[0])
- {
- case '%':
- pos++;
- switch (pos[0])
- {
- case 'c':
- if (GUI_CHANNEL(window->buffer))
- length += utf8_strlen (GUI_CHANNEL(window->buffer)->name);
- else
- {
- if (GUI_SERVER(window->buffer))
- length += utf8_strlen (GUI_SERVER(window->buffer)->name);
- }
- pos++;
- break;
- case 'm':
- if (GUI_SERVER(window->buffer))
- {
- mode_found = 0;
- for (modes = GUI_SERVER(window->buffer)->nick_modes;
- modes && modes[0]; modes++)
- {
- if (modes[0] != ' ')
- {
- length++;
- mode_found = 1;
- }
- }
- if (mode_found)
- length++;
- }
- pos++;
- break;
- case 'n':
- length += utf8_strlen (nick);
- pos++;
- break;
- default:
- length++;
- if (pos[0])
- {
- if (pos[0] == '%')
- pos++;
- else
- {
- length++;
- pos += utf8_char_size (pos);
- }
- }
- break;
- }
- break;
- default:
- length++;
- pos += utf8_char_size (pos);
- break;
- }
- }
- return length;
-}
-
-/*
* gui_input_draw_prompt: display input prompt
*/
void
-gui_input_draw_prompt (t_gui_window *window, char *nick)
+gui_input_draw_prompt (struct t_gui_window *window, char *nick)
{
/*char *pos, saved_char, *modes;
int char_size, mode_found;*/
@@ -146,7 +68,7 @@ gui_input_draw_prompt (t_gui_window *window, char *nick)
*/
void
-gui_input_draw_text (t_gui_window *window, int input_width)
+gui_input_draw_text (struct t_gui_window *window, int input_width)
{
/*char *ptr_start, *ptr_next, saved_char;
int pos_mask, size, last_color, color;*/
@@ -161,9 +83,9 @@ gui_input_draw_text (t_gui_window *window, int input_width)
*/
void
-gui_input_draw (t_gui_buffer *buffer, int erase)
+gui_input_draw (struct t_gui_buffer *buffer, int erase)
{
- /*t_gui_window *ptr_win;
+ /*struct t_gui_window *ptr_win;
char format[32];
char *ptr_nickname;
int input_width;
diff --git a/src/gui/gtk/gui-gtk-keyboard.c b/src/gui/gtk/gui-gtk-keyboard.c
index 4436d93c0..8610f6767 100644
--- a/src/gui/gtk/gui-gtk-keyboard.c
+++ b/src/gui/gtk/gui-gtk-keyboard.c
@@ -26,15 +26,13 @@
#include <stdlib.h>
#include <string.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/utf8.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-utf8.h"
+#include "../../plugins/plugin.h"
+#include "../gui-keyboard.h"
+#include "../gui-buffer.h"
#include "gui-gtk.h"
-#ifdef PLUGINS
-#include "../../plugins/plugins.h"
-#endif
-
/*
* gui_keyboard_default_bindings: create default key bindings
diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c
index ed0d9cb63..bee6ff971 100644
--- a/src/gui/gtk/gui-gtk-main.c
+++ b/src/gui/gtk/gui-gtk-main.c
@@ -29,17 +29,17 @@
#include <string.h>
#include <signal.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/fifo.h"
-#include "../../common/utf8.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-utf8.h"
+#include "../../plugins/plugin.h"
+#include "../gui-main.h"
+#include "../gui-history.h"
+#include "../gui-infobar.h"
+#include "../gui-input.h"
+#include "../gui-window.h"
#include "gui-gtk.h"
-#ifdef PLUGINS
-#include "../../plugins/plugins.h"
-#endif
-
GtkWidget *gui_gtk_main_window;
GtkWidget *gui_gtk_vbox1;
@@ -55,17 +55,6 @@ GtkWidget *gui_gtk_label1;
/*
- * gui_main_loop: main loop for WeeChat with Gtk GUI
- */
-
-void
-gui_main_loop ()
-{
- /* TODO: write this function for Gtk */
- gtk_main ();
-}
-
-/*
* gui_main_pre_init: pre-initialize GUI (called before gui_init)
*/
@@ -83,6 +72,7 @@ gui_main_pre_init (int *argc, char **argv[])
void
gui_main_init ()
{
+ struct t_gui_buffer *ptr_buffer;
GdkColor color_fg, color_bg;
gui_color_init ();
@@ -172,31 +162,46 @@ gui_main_init ()
if (gui_window_new (NULL, 0, 0, 0, 0, 100, 100))
{
gui_current_window = gui_windows;
- gui_buffer_new (gui_windows, NULL, NULL, 0, 1);
+ ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat");
+ if (ptr_buffer)
+ {
+ gui_init_ok = 1;
+ gui_buffer_set_title (ptr_buffer,
+ PACKAGE_STRING " " WEECHAT_COPYRIGHT_DATE
+ " - " WEECHAT_WEBSITE);
+ gui_window_redraw_buffer (ptr_buffer);
+ }
+ else
+ gui_init_ok = 0;
if (cfg_look_set_title)
- gui_window_set_title ();
-
- gui_init_ok = 1;
+ gui_window_title_set ();
}
}
/*
+ * gui_main_loop: main loop for WeeChat with Gtk GUI
+ */
+
+void
+gui_main_loop ()
+{
+ /* TODO: write this function for Gtk */
+ gtk_main ();
+}
+
+/*
* gui_main_end: GUI end
*/
void
gui_main_end ()
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
/* free clipboard buffer */
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)
@@ -214,7 +219,7 @@ gui_main_end ()
gui_window_tree_free (&gui_windows_tree);
/* delete global history */
- history_global_free ();
+ gui_history_global_free ();
/* delete infobar messages */
while (gui_infobar)
@@ -222,5 +227,5 @@ gui_main_end ()
/* reset title */
if (cfg_look_set_title)
- gui_window_reset_title ();
+ gui_window_title_reset ();
}
diff --git a/src/gui/gtk/gui-gtk-nicklist.c b/src/gui/gtk/gui-gtk-nicklist.c
index a1f597cf5..bcb1d61bd 100644
--- a/src/gui/gtk/gui-gtk-nicklist.c
+++ b/src/gui/gtk/gui-gtk-nicklist.c
@@ -23,10 +23,9 @@
#include "config.h"
#endif
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/weeconfig.h"
-#include "../../protocols/irc/irc.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../gui-nicklist.h"
#include "gui-gtk.h"
@@ -35,18 +34,9 @@
*/
void
-gui_nicklist_draw (t_gui_buffer *buffer, int erase, int calculate_size)
+gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
{
- /*t_gui_window *ptr_win;
- int i, j, x, y, column, max_length, nicks_displayed;
- char format[32], format_empty[32];
- t_irc_nick *ptr_nick;*/
-
- if (!gui_ok || !GUI_BUFFER_HAS_NICKLIST(buffer))
- return;
-
/* TODO: write this function for Gtk */
(void) buffer;
(void) erase;
- (void) calculate_size;
}
diff --git a/src/gui/gtk/gui-gtk-status.c b/src/gui/gtk/gui-gtk-status.c
index 16b4565a4..d39aeb041 100644
--- a/src/gui/gtk/gui-gtk-status.c
+++ b/src/gui/gtk/gui-gtk-status.c
@@ -26,10 +26,9 @@
#include <stdlib.h>
#include <string.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/hotlist.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../gui-status.h"
#include "gui-gtk.h"
@@ -38,20 +37,8 @@
*/
void
-gui_status_draw (t_gui_buffer *buffer, int erase)
+gui_status_draw (struct t_gui_buffer *buffer, int erase)
{
- /*t_gui_window *ptr_win;
- t_weechat_hotlist *ptr_hotlist;
- char format[32], str_nicks[32], *more;
- int i, first_mode, x, server_pos, server_total;
- int display_name, names_count;*/
-
- /* make C compiler happy */
- (void) buffer;
-
- if (!gui_ok)
- return;
-
/* TODO: write this function for Gtk */
(void) buffer;
(void) erase;
diff --git a/src/gui/gtk/gui-gtk-window.c b/src/gui/gtk/gui-gtk-window.c
index 28f7ff03d..4af1d2c5a 100644
--- a/src/gui/gtk/gui-gtk-window.c
+++ b/src/gui/gtk/gui-gtk-window.c
@@ -26,11 +26,14 @@
#include <stdlib.h>
#include <string.h>
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "../../common/hotlist.h"
-#include "../../common/log.h"
-#include "../../common/weeconfig.h"
+#include "../../core/weechat.h"
+#include "../../core/wee-config.h"
+#include "../../core/wee-log.h"
+#include "../gui-window.h"
+#include "../gui-hotlist.h"
+#include "../gui-nicklist.h"
+#include "../gui-main.h"
+#include "../gui-status.h"
#include "gui-gtk.h"
@@ -59,11 +62,11 @@ gui_window_get_height ()
*/
int
-gui_window_objects_init (t_gui_window *window)
+gui_window_objects_init (struct t_gui_window *window)
{
- t_gui_gtk_objects *new_objects;
+ struct t_gui_gtk_objects *new_objects;
- if ((new_objects = (t_gui_gtk_objects *) malloc (sizeof (t_gui_gtk_objects))))
+ if ((new_objects = (struct t_gui_gtk_objects *) malloc (sizeof (struct t_gui_gtk_objects))))
{
window->gui_objects = new_objects;
GUI_GTK(window)->textview_chat = NULL;
@@ -71,7 +74,6 @@ gui_window_objects_init (t_gui_window *window)
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
@@ -83,7 +85,7 @@ gui_window_objects_init (t_gui_window *window)
*/
void
-gui_window_objects_free (t_gui_window *window, int free_separator)
+gui_window_objects_free (struct t_gui_window *window, int free_separator)
{
/* TODO: write this function for Gtk */
(void) window;
@@ -111,7 +113,7 @@ gui_window_set_weechat_color (WINDOW *window, int num_color)
*/
int
-gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
+gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
{
/* TODO: write this function for Gtk */
(void) window;
@@ -125,7 +127,7 @@ gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
*/
void
-gui_window_draw_separator (t_gui_window *window)
+gui_window_draw_separator (struct t_gui_window *window)
{
/* TODO: write this function for Gtk */
/*if (window->win_separator)
@@ -150,7 +152,7 @@ gui_window_draw_separator (t_gui_window *window)
*/
void
-gui_window_redraw_buffer (t_gui_buffer *buffer)
+gui_window_redraw_buffer (struct t_gui_buffer *buffer)
{
/* TODO: write this function for Gtk */
(void) buffer;
@@ -171,7 +173,7 @@ gui_window_redraw_all_buffers ()
*/
void
-gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
+gui_window_switch_to_buffer (struct t_gui_window *window, struct t_gui_buffer *buffer)
{
GtkTextIter start, end;
@@ -205,7 +207,7 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
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 (GUI_BUFFER_IS_CHANNEL(buffer) && !GUI_GTK(window)->textbuffer_nicklist)
+ if (buffer->nicklist && !GUI_GTK(window)->textbuffer_nicklist)
{
GUI_GTK(window)->textview_nicklist = gtk_text_view_new ();
gtk_widget_show (GUI_GTK(window)->textview_nicklist);
@@ -222,7 +224,7 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
buffer->num_displayed++;
- hotlist_remove_buffer (buffer);
+ gui_hotlist_remove_buffer (buffer);
}
/*
@@ -230,7 +232,7 @@ gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
*/
void
-gui_window_page_up (t_gui_window *window)
+gui_window_page_up (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -252,9 +254,9 @@ gui_window_page_up (t_gui_window *window)
*/
void
-gui_window_page_down (t_gui_window *window)
+gui_window_page_down (struct t_gui_window *window)
{
- t_gui_line *ptr_line;
+ struct t_gui_line *ptr_line;
int line_pos;
if (!gui_ok)
@@ -288,7 +290,7 @@ gui_window_page_down (t_gui_window *window)
*/
void
-gui_window_scroll_up (t_gui_window *window)
+gui_window_scroll_up (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -310,9 +312,9 @@ gui_window_scroll_up (t_gui_window *window)
*/
void
-gui_window_scroll_down (t_gui_window *window)
+gui_window_scroll_down (struct t_gui_window *window)
{
- t_gui_line *ptr_line;
+ struct t_gui_line *ptr_line;
int line_pos;
if (!gui_ok)
@@ -347,7 +349,7 @@ gui_window_scroll_down (t_gui_window *window)
*/
void
-gui_window_scroll_top (t_gui_window *window)
+gui_window_scroll_top (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -366,7 +368,7 @@ gui_window_scroll_top (t_gui_window *window)
*/
void
-gui_window_scroll_bottom (t_gui_window *window)
+gui_window_scroll_bottom (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -385,7 +387,7 @@ gui_window_scroll_bottom (t_gui_window *window)
*/
void
-gui_window_scroll_topic_left (t_gui_window *window)
+gui_window_scroll_topic_left (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -402,7 +404,7 @@ gui_window_scroll_topic_left (t_gui_window *window)
*/
void
-gui_window_scroll_topic_right (t_gui_window *window)
+gui_window_scroll_topic_right (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -416,17 +418,17 @@ gui_window_scroll_topic_right (t_gui_window *window)
*/
void
-gui_window_nick_beginning (t_gui_window *window)
+gui_window_nick_beginning (struct t_gui_window *window)
{
if (!gui_ok)
return;
- if (GUI_BUFFER_HAS_NICKLIST(window->buffer))
+ if (window->buffer->nicklist)
{
if (window->win_nick_start > 0)
{
window->win_nick_start = 0;
- gui_nicklist_draw (window->buffer, 1, 0);
+ gui_nicklist_draw (window->buffer, 1);
}
}
}
@@ -436,17 +438,17 @@ gui_window_nick_beginning (t_gui_window *window)
*/
void
-gui_window_nick_end (t_gui_window *window)
+gui_window_nick_end (struct t_gui_window *window)
{
int new_start;
if (!gui_ok)
return;
- if (GUI_BUFFER_HAS_NICKLIST(window->buffer))
+ if (window->buffer->nicklist)
{
new_start =
- GUI_CHANNEL(window->buffer)->nicks_count - window->win_nick_height;
+ window->buffer->nicks_count - window->win_nick_height;
if (new_start < 0)
new_start = 0;
else if (new_start >= 1)
@@ -455,7 +457,7 @@ gui_window_nick_end (t_gui_window *window)
if (new_start != window->win_nick_start)
{
window->win_nick_start = new_start;
- gui_nicklist_draw (window->buffer, 1, 0);
+ gui_nicklist_draw (window->buffer, 1);
}
}
}
@@ -465,19 +467,19 @@ gui_window_nick_end (t_gui_window *window)
*/
void
-gui_window_nick_page_up (t_gui_window *window)
+gui_window_nick_page_up (struct t_gui_window *window)
{
if (!gui_ok)
return;
- if (GUI_BUFFER_HAS_NICKLIST(window->buffer))
+ if (window->buffer->nicklist)
{
if (window->win_nick_start > 0)
{
window->win_nick_start -= (window->win_nick_height - 1);
if (window->win_nick_start <= 1)
window->win_nick_start = 0;
- gui_nicklist_draw (window->buffer, 1, 0);
+ gui_nicklist_draw (window->buffer, 1);
}
}
}
@@ -487,22 +489,22 @@ gui_window_nick_page_up (t_gui_window *window)
*/
void
-gui_window_nick_page_down (t_gui_window *window)
+gui_window_nick_page_down (struct t_gui_window *window)
{
if (!gui_ok)
return;
- if (GUI_BUFFER_HAS_NICKLIST(window->buffer))
+ if (window->buffer->nicklist)
{
- if ((GUI_CHANNEL(window->buffer)->nicks_count > window->win_nick_height)
+ if ((window->buffer->nicks_count > window->win_nick_height)
&& (window->win_nick_start + window->win_nick_height - 1
- < GUI_CHANNEL(window->buffer)->nicks_count))
+ < window->buffer->nicks_count))
{
if (window->win_nick_start == 0)
window->win_nick_start += (window->win_nick_height - 1);
else
window->win_nick_start += (window->win_nick_height - 2);
- gui_nicklist_draw (window->buffer, 1, 0);
+ gui_nicklist_draw (window->buffer, 1);
}
}
}
@@ -515,7 +517,7 @@ gui_window_nick_page_down (t_gui_window *window)
*/
int
-gui_window_auto_resize (t_gui_window_tree *tree,
+gui_window_auto_resize (struct t_gui_window_tree *tree,
int x, int y, int width, int height,
int simulate)
{
@@ -569,7 +571,7 @@ gui_window_auto_resize (t_gui_window_tree *tree,
void
gui_window_refresh_windows ()
{
- /*t_gui_window *ptr_win, *old_current_window;*/
+ /*struct t_gui_window *ptr_win, *old_current_window;*/
if (gui_ok)
{
@@ -582,9 +584,9 @@ gui_window_refresh_windows ()
*/
void
-gui_window_split_horiz (t_gui_window *window, int pourcentage)
+gui_window_split_horiz (struct t_gui_window *window, int pourcentage)
{
- t_gui_window *new_window;
+ struct t_gui_window *new_window;
int height1, height2;
if (!gui_ok)
@@ -623,9 +625,9 @@ gui_window_split_horiz (t_gui_window *window, int pourcentage)
*/
void
-gui_window_split_vertic (t_gui_window *window, int pourcentage)
+gui_window_split_vertic (struct t_gui_window *window, int pourcentage)
{
- t_gui_window *new_window;
+ struct t_gui_window *new_window;
int width1, width2;
if (!gui_ok)
@@ -666,7 +668,7 @@ gui_window_split_vertic (t_gui_window *window, int pourcentage)
*/
void
-gui_window_resize (t_gui_window *window, int pourcentage)
+gui_window_resize (struct t_gui_window *window, int pourcentage)
{
/* TODO: write this function for Gtk */
(void) window;
@@ -678,9 +680,9 @@ gui_window_resize (t_gui_window *window, int pourcentage)
*/
int
-gui_window_merge (t_gui_window *window)
+gui_window_merge (struct t_gui_window *window)
{
- t_gui_window_tree *parent, *sister;
+ struct t_gui_window_tree *parent, *sister;
parent = window->ptr_tree->parent_node;
if (parent)
@@ -723,7 +725,7 @@ gui_window_merge (t_gui_window *window)
*/
void
-gui_window_merge_all (t_gui_window *window)
+gui_window_merge_all (struct t_gui_window *window)
{
/* TODO: write this function for Gtk */
(void) window;
@@ -739,7 +741,7 @@ gui_window_merge_all (t_gui_window *window)
*/
int
-gui_window_side_by_side (t_gui_window *win1, t_gui_window *win2)
+gui_window_side_by_side (struct t_gui_window *win1, struct t_gui_window *win2)
{
/* win2 over win1 ? */
if (win2->win_y + win2->win_height == win1->win_y)
@@ -789,9 +791,9 @@ gui_window_side_by_side (t_gui_window *win1, t_gui_window *win2)
*/
void
-gui_window_switch_up (t_gui_window *window)
+gui_window_switch_up (struct t_gui_window *window)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
@@ -812,9 +814,9 @@ gui_window_switch_up (t_gui_window *window)
*/
void
-gui_window_switch_down (t_gui_window *window)
+gui_window_switch_down (struct t_gui_window *window)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
@@ -835,9 +837,9 @@ gui_window_switch_down (t_gui_window *window)
*/
void
-gui_window_switch_left (t_gui_window *window)
+gui_window_switch_left (struct t_gui_window *window)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
@@ -858,9 +860,9 @@ gui_window_switch_left (t_gui_window *window)
*/
void
-gui_window_switch_right (t_gui_window *window)
+gui_window_switch_right (struct t_gui_window *window)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
for (ptr_win = gui_windows; ptr_win;
ptr_win = ptr_win->next_window)
@@ -887,21 +889,21 @@ gui_window_refresh_screen ()
}
/*
- * gui_window_set_title: set terminal title
+ * gui_window_title_set: set terminal title
*/
void
-gui_window_set_title ()
+gui_window_title_set ()
{
/* TODO: write this function for Gtk */
}
/*
- * gui_window_reset_title: reset terminal title
+ * gui_window_title_reset: reset terminal title
*/
void
-gui_window_reset_title ()
+gui_window_title_reset ()
{
/* This function does nothing in Gtk GUI */
}
@@ -912,7 +914,7 @@ gui_window_reset_title ()
*/
void
-gui_window_objects_print_log (t_gui_window *window)
+gui_window_objects_print_log (struct 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);
diff --git a/src/gui/gtk/gui-gtk.h b/src/gui/gtk/gui-gtk.h
index cd04a0c9d..e88e0ae2e 100644
--- a/src/gui/gtk/gui-gtk.h
+++ b/src/gui/gtk/gui-gtk.h
@@ -51,15 +51,6 @@
#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
@@ -69,11 +60,10 @@ struct t_gui_gtk_objects
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];
+//extern t_gui_color gui_weechat_colors[];
+//extern int gui_irc_colors[GUI_NUM_IRC_COLORS][2];
extern GtkWidget *gui_gtk_main_window;
extern GtkWidget *gui_gtk_vbox1;
@@ -92,11 +82,13 @@ extern int gui_color_get_pair (int);
extern void gui_color_init ();
/* chat functions */
-extern void gui_chat_calculate_line_diff (t_gui_window *, t_gui_line **, int *, int);
+extern void gui_chat_calculate_line_diff (struct t_gui_window *,
+ struct t_gui_line **, int *, int);
/* keyboard functions */
extern void gui_keyboard_default_bindings ();
extern void gui_keyboard_read ();
+extern void gui_keyboard_flush ();
/* window functions */
extern void gui_window_set_title ();
diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c
index 59aa40445..55b45e44a 100644
--- a/src/gui/gui-action.c
+++ b/src/gui/gui-action.c
@@ -31,16 +31,22 @@
#include <signal.h>
#include <time.h>
-#include "../common/weechat.h"
-#include "gui.h"
-#include "../common/command.h"
-#include "../common/weeconfig.h"
-#include "../common/history.h"
-#include "../common/hotlist.h"
-#include "../common/log.h"
-#include "../common/utf8.h"
-#include "../common/util.h"
-#include "../protocols/irc/irc.h"
+#include "../core/weechat.h"
+#include "../core/wee-command.h"
+#include "../core/wee-config.h"
+#include "../core/wee-input.h"
+#include "../core/wee-log.h"
+#include "../core/wee-string.h"
+#include "../core/wee-utf8.h"
+#include "gui-buffer.h"
+#include "gui-completion.h"
+#include "gui-history.h"
+#include "gui-hotlist.h"
+#include "gui-infobar.h"
+#include "gui-input.h"
+#include "gui-keyboard.h"
+#include "gui-status.h"
+#include "gui-window.h"
/*
@@ -70,16 +76,18 @@ gui_action_clipboard_copy (char *buffer, int size)
*/
void
-gui_action_clipboard_paste (t_gui_window *window, char *args)
+gui_action_clipboard_paste (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input && gui_input_clipboard)
+ if ((gui_current_window->buffer->input)
+ && gui_input_clipboard)
{
- gui_insert_string_input (window, gui_input_clipboard, -1);
- window->buffer->completion.position = -1;
- gui_input_draw (window->buffer, 0);
+ gui_input_insert_string (gui_current_window->buffer,
+ gui_input_clipboard, -1);
+ gui_current_window->buffer->completion->position = -1;
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
@@ -88,38 +96,38 @@ gui_action_clipboard_paste (t_gui_window *window, char *args)
*/
void
-gui_action_return (t_gui_window *window, char *args)
+gui_action_return (char *args)
{
char *command;
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
- gui_buffer_search_stop (window);
- else if (window->buffer->input_buffer_size > 0)
+ if (gui_current_window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
+ gui_window_search_stop (gui_current_window);
+ else if (gui_current_window->buffer->input_buffer_size > 0)
{
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- command = strdup (window->buffer->input_buffer);
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0';
+ command = strdup (gui_current_window->buffer->input_buffer);
if (!command)
return;
- history_buffer_add (window->buffer, window->buffer->input_buffer);
- history_global_add (window->buffer->input_buffer);
- window->buffer->input_buffer[0] = '\0';
- window->buffer->input_buffer_color_mask[0] = '\0';
- window->buffer->input_buffer_size = 0;
- window->buffer->input_buffer_length = 0;
- window->buffer->input_buffer_pos = 0;
- window->buffer->input_buffer_1st_display = 0;
- window->buffer->completion.position = -1;
- window->buffer->ptr_history = NULL;
- gui_input_optimize_size (window->buffer);
- gui_input_draw (window->buffer, 0);
- user_command (GUI_SERVER(window->buffer), GUI_CHANNEL(window->buffer),
- command, 0);
+ gui_history_buffer_add (gui_current_window->buffer,
+ gui_current_window->buffer->input_buffer);
+ gui_history_global_add (gui_current_window->buffer->input_buffer);
+ gui_current_window->buffer->input_buffer[0] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[0] = '\0';
+ gui_current_window->buffer->input_buffer_size = 0;
+ gui_current_window->buffer->input_buffer_length = 0;
+ gui_current_window->buffer->input_buffer_pos = 0;
+ gui_current_window->buffer->input_buffer_1st_display = 0;
+ gui_current_window->buffer->completion->position = -1;
+ gui_current_window->buffer->ptr_history = NULL;
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
+ input_data (gui_current_window->buffer, command, 0);
free (command);
}
}
@@ -130,20 +138,21 @@ gui_action_return (t_gui_window *window, char *args)
*/
void
-gui_action_tab (t_gui_window *window, char *args)
+gui_action_tab (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input
- && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
+ if ((gui_current_window->buffer->input)
+ && (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
- completion_search (&(window->buffer->completion), 1,
- window->buffer->input_buffer,
- window->buffer->input_buffer_size,
- utf8_real_pos (window->buffer->input_buffer,
- window->buffer->input_buffer_pos));
- gui_input_complete (window);
+ gui_completion_search (gui_current_window->buffer->completion,
+ 1,
+ gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_size,
+ utf8_real_pos (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos));
+ gui_input_complete (gui_current_window->buffer);
}
}
@@ -152,20 +161,21 @@ gui_action_tab (t_gui_window *window, char *args)
*/
void
-gui_action_tab_previous (t_gui_window *window, char *args)
+gui_action_tab_previous (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input
- && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
+ if ((gui_current_window->buffer->input)
+ && (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
- completion_search (&(window->buffer->completion), -1,
- window->buffer->input_buffer,
- window->buffer->input_buffer_size,
- utf8_real_pos (window->buffer->input_buffer,
- window->buffer->input_buffer_pos));
- gui_input_complete (window);
+ gui_completion_search (gui_current_window->buffer->completion,
+ -1,
+ gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_size,
+ utf8_real_pos (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos));
+ gui_input_complete (gui_current_window->buffer);
}
}
@@ -174,7 +184,7 @@ gui_action_tab_previous (t_gui_window *window, char *args)
*/
void
-gui_action_backspace (t_gui_window *window, char *args)
+gui_action_backspace (char *args)
{
char *pos, *pos_last;
int char_size, size_to_move;
@@ -182,24 +192,24 @@ gui_action_backspace (t_gui_window *window, char *args)
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos > 0)
+ if (gui_current_window->buffer->input_buffer_pos > 0)
{
- pos = utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos);
- pos_last = utf8_prev_char (window->buffer->input_buffer, pos);
+ pos = utf8_add_offset (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos);
+ pos_last = utf8_prev_char (gui_current_window->buffer->input_buffer, pos);
char_size = pos - pos_last;
size_to_move = strlen (pos);
- gui_input_move (window->buffer, pos_last, pos, size_to_move);
- window->buffer->input_buffer_size -= char_size;
- window->buffer->input_buffer_length--;
- window->buffer->input_buffer_pos--;
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- gui_input_optimize_size (window->buffer);
- gui_input_draw (window->buffer, 0);
- window->buffer->completion.position = -1;
+ gui_input_move (gui_current_window->buffer, pos_last, pos, size_to_move);
+ gui_current_window->buffer->input_buffer_size -= char_size;
+ gui_current_window->buffer->input_buffer_length--;
+ gui_current_window->buffer->input_buffer_pos--;
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
+ gui_current_window->buffer->completion->position = -1;
}
}
}
@@ -209,7 +219,7 @@ gui_action_backspace (t_gui_window *window, char *args)
*/
void
-gui_action_delete (t_gui_window *window, char *args)
+gui_action_delete (char *args)
{
char *pos, *pos_next;
int char_size, size_to_move;
@@ -217,24 +227,24 @@ gui_action_delete (t_gui_window *window, char *args)
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos <
- window->buffer->input_buffer_length)
+ if (gui_current_window->buffer->input_buffer_pos <
+ gui_current_window->buffer->input_buffer_length)
{
- pos = utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos);
+ pos = utf8_add_offset (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos);
pos_next = utf8_next_char (pos);
char_size = pos_next - pos;
size_to_move = strlen (pos_next);
- gui_input_move (window->buffer, pos, pos_next, size_to_move);
- window->buffer->input_buffer_size -= char_size;
- window->buffer->input_buffer_length--;
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- gui_input_optimize_size (window->buffer);
- gui_input_draw (window->buffer, 0);
- window->buffer->completion.position = -1;
+ gui_input_move (gui_current_window->buffer, pos, pos_next, size_to_move);
+ gui_current_window->buffer->input_buffer_size -= char_size;
+ gui_current_window->buffer->input_buffer_length--;
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
+ gui_current_window->buffer->completion->position = -1;
}
}
}
@@ -244,7 +254,7 @@ gui_action_delete (t_gui_window *window, char *args)
*/
void
-gui_action_delete_previous_word (t_gui_window *window, char *args)
+gui_action_delete_previous_word (char *args)
{
int length_deleted, size_deleted;
char *start, *string;
@@ -252,28 +262,28 @@ gui_action_delete_previous_word (t_gui_window *window, char *args)
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos > 0)
+ if (gui_current_window->buffer->input_buffer_pos > 0)
{
- start = utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos - 1);
+ start = utf8_add_offset (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos - 1);
string = start;
while (string && (string[0] == ' '))
{
- string = utf8_prev_char (window->buffer->input_buffer, string);
+ string = utf8_prev_char (gui_current_window->buffer->input_buffer, string);
}
if (string)
{
while (string && (string[0] != ' '))
{
- string = utf8_prev_char (window->buffer->input_buffer, string);
+ string = utf8_prev_char (gui_current_window->buffer->input_buffer, string);
}
if (string)
{
while (string && (string[0] == ' '))
{
- string = utf8_prev_char (window->buffer->input_buffer, string);
+ string = utf8_prev_char (gui_current_window->buffer->input_buffer, string);
}
}
}
@@ -281,23 +291,23 @@ gui_action_delete_previous_word (t_gui_window *window, char *args)
if (string)
string = utf8_next_char (utf8_next_char (string));
else
- string = window->buffer->input_buffer;
+ string = gui_current_window->buffer->input_buffer;
size_deleted = utf8_next_char (start) - string;
length_deleted = utf8_strnlen (string, size_deleted);
gui_action_clipboard_copy (string, size_deleted);
- gui_input_move (window->buffer, string, string + size_deleted, strlen (string + size_deleted));
+ gui_input_move (gui_current_window->buffer, string, string + size_deleted, strlen (string + size_deleted));
- window->buffer->input_buffer_size -= size_deleted;
- window->buffer->input_buffer_length -= length_deleted;
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_pos -= length_deleted;
- gui_input_optimize_size (window->buffer);
- gui_input_draw (window->buffer, 0);
- window->buffer->completion.position = -1;
+ gui_current_window->buffer->input_buffer_size -= size_deleted;
+ gui_current_window->buffer->input_buffer_length -= length_deleted;
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_pos -= length_deleted;
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
+ gui_current_window->buffer->completion->position = -1;
}
}
}
@@ -307,7 +317,7 @@ gui_action_delete_previous_word (t_gui_window *window, char *args)
*/
void
-gui_action_delete_next_word (t_gui_window *window, char *args)
+gui_action_delete_next_word (char *args)
{
int size_deleted, length_deleted;
char *start, *string;
@@ -315,10 +325,10 @@ gui_action_delete_next_word (t_gui_window *window, char *args)
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- start = utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos);
+ start = utf8_add_offset (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos);
string = start;
length_deleted = 0;
while (string[0])
@@ -332,15 +342,15 @@ gui_action_delete_next_word (t_gui_window *window, char *args)
gui_action_clipboard_copy(start, size_deleted);
- gui_input_move (window->buffer, start, string, strlen (string));
+ gui_input_move (gui_current_window->buffer, start, string, strlen (string));
- window->buffer->input_buffer_size -= size_deleted;
- window->buffer->input_buffer_length -= length_deleted;
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- gui_input_optimize_size (window->buffer);
- gui_input_draw (window->buffer, 0);
- window->buffer->completion.position = -1;
+ gui_current_window->buffer->input_buffer_size -= size_deleted;
+ gui_current_window->buffer->input_buffer_length -= length_deleted;
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
+ gui_current_window->buffer->completion->position = -1;
}
}
@@ -349,7 +359,7 @@ gui_action_delete_next_word (t_gui_window *window, char *args)
*/
void
-gui_action_delete_begin_of_line (t_gui_window *window, char *args)
+gui_action_delete_begin_of_line (char *args)
{
int length_deleted, size_deleted, pos_start;
char *start;
@@ -357,28 +367,28 @@ gui_action_delete_begin_of_line (t_gui_window *window, char *args)
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos > 0)
+ if (gui_current_window->buffer->input_buffer_pos > 0)
{
- start = utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos);
- pos_start = start - window->buffer->input_buffer;
- size_deleted = start - window->buffer->input_buffer;
- length_deleted = utf8_strnlen (window->buffer->input_buffer, size_deleted);
- gui_action_clipboard_copy (window->buffer->input_buffer,
- start - window->buffer->input_buffer);
+ start = utf8_add_offset (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos);
+ pos_start = start - gui_current_window->buffer->input_buffer;
+ size_deleted = start - gui_current_window->buffer->input_buffer;
+ length_deleted = utf8_strnlen (gui_current_window->buffer->input_buffer, size_deleted);
+ gui_action_clipboard_copy (gui_current_window->buffer->input_buffer,
+ start - gui_current_window->buffer->input_buffer);
- gui_input_move (window->buffer, window->buffer->input_buffer, start, strlen (start));
+ gui_input_move (gui_current_window->buffer, gui_current_window->buffer->input_buffer, start, strlen (start));
- window->buffer->input_buffer_size -= size_deleted;
- window->buffer->input_buffer_length -= length_deleted;
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_pos = 0;
- gui_input_optimize_size (window->buffer);
- gui_input_draw (window->buffer, 0);
- window->buffer->completion.position = -1;
+ gui_current_window->buffer->input_buffer_size -= size_deleted;
+ gui_current_window->buffer->input_buffer_length -= length_deleted;
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_pos = 0;
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
+ gui_current_window->buffer->completion->position = -1;
}
}
}
@@ -388,7 +398,7 @@ gui_action_delete_begin_of_line (t_gui_window *window, char *args)
*/
void
-gui_action_delete_end_of_line (t_gui_window *window, char *args)
+gui_action_delete_end_of_line (char *args)
{
char *start;
int size_deleted, length_deleted, pos_start;
@@ -396,21 +406,21 @@ gui_action_delete_end_of_line (t_gui_window *window, char *args)
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- start = utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos);
- pos_start = start - window->buffer->input_buffer;
+ start = utf8_add_offset (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos);
+ pos_start = start - gui_current_window->buffer->input_buffer;
size_deleted = strlen (start);
length_deleted = utf8_strlen (start);
gui_action_clipboard_copy (start, size_deleted);
start[0] = '\0';
- window->buffer->input_buffer_color_mask[pos_start] = '\0';
- window->buffer->input_buffer_size = strlen (window->buffer->input_buffer);
- window->buffer->input_buffer_length = utf8_strlen (window->buffer->input_buffer);
- gui_input_optimize_size (window->buffer);
- gui_input_draw (window->buffer, 0);
- window->buffer->completion.position = -1;
+ gui_current_window->buffer->input_buffer_color_mask[pos_start] = '\0';
+ gui_current_window->buffer->input_buffer_size = strlen (gui_current_window->buffer->input_buffer);
+ gui_current_window->buffer->input_buffer_length = utf8_strlen (gui_current_window->buffer->input_buffer);
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
+ gui_current_window->buffer->completion->position = -1;
}
}
@@ -419,22 +429,13 @@ gui_action_delete_end_of_line (t_gui_window *window, char *args)
*/
void
-gui_action_delete_line (t_gui_window *window, char *args)
+gui_action_delete_line (char *args)
{
/* make C compiler happy */
(void) args;
-
- if (window->buffer->has_input)
- {
- window->buffer->input_buffer[0] = '\0';
- window->buffer->input_buffer_color_mask[0] = '\0';
- window->buffer->input_buffer_size = 0;
- window->buffer->input_buffer_length = 0;
- window->buffer->input_buffer_pos = 0;
- gui_input_optimize_size (window->buffer);
- gui_input_draw (window->buffer, 0);
- window->buffer->completion.position = -1;
- }
+
+ gui_input_delete_line (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
}
/*
@@ -442,7 +443,7 @@ gui_action_delete_line (t_gui_window *window, char *args)
*/
void
-gui_action_transpose_chars (t_gui_window *window, char *args)
+gui_action_transpose_chars (char *args)
{
/* make C compiler happy */
(void) args;
@@ -451,20 +452,20 @@ gui_action_transpose_chars (t_gui_window *window, char *args)
int size_prev_char, size_start_char;
int pos_prev_char, pos_start;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if ((window->buffer->input_buffer_pos > 0)
- && (window->buffer->input_buffer_length > 1))
+ if ((gui_current_window->buffer->input_buffer_pos > 0)
+ && (gui_current_window->buffer->input_buffer_length > 1))
{
- if (window->buffer->input_buffer_pos == window->buffer->input_buffer_length)
- window->buffer->input_buffer_pos--;
+ if (gui_current_window->buffer->input_buffer_pos == gui_current_window->buffer->input_buffer_length)
+ gui_current_window->buffer->input_buffer_pos--;
- start = utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos);
- pos_start = start - window->buffer->input_buffer;
- prev_char = utf8_prev_char (window->buffer->input_buffer,
+ start = utf8_add_offset (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos);
+ pos_start = start - gui_current_window->buffer->input_buffer;
+ prev_char = utf8_prev_char (gui_current_window->buffer->input_buffer,
start);
- pos_prev_char = prev_char - window->buffer->input_buffer;
+ pos_prev_char = prev_char - gui_current_window->buffer->input_buffer;
size_prev_char = start - prev_char;
size_start_char = utf8_char_size (start);
@@ -472,16 +473,16 @@ gui_action_transpose_chars (t_gui_window *window, char *args)
memcpy (prev_char, start, size_start_char);
memcpy (prev_char + size_start_char, saved_char, size_prev_char);
- memcpy (saved_char, window->buffer->input_buffer_color_mask + pos_prev_char, size_prev_char);
- memcpy (window->buffer->input_buffer_color_mask + pos_prev_char,
- window->buffer->input_buffer_color_mask + pos_start, size_start_char);
- memcpy (window->buffer->input_buffer_color_mask + pos_prev_char + size_start_char,
+ memcpy (saved_char, gui_current_window->buffer->input_buffer_color_mask + pos_prev_char, size_prev_char);
+ memcpy (gui_current_window->buffer->input_buffer_color_mask + pos_prev_char,
+ gui_current_window->buffer->input_buffer_color_mask + pos_start, size_start_char);
+ memcpy (gui_current_window->buffer->input_buffer_color_mask + pos_prev_char + size_start_char,
saved_char, size_prev_char);
- window->buffer->input_buffer_pos++;
+ gui_current_window->buffer->input_buffer_pos++;
- gui_input_draw (window->buffer, 0);
- window->buffer->completion.position = -1;
+ gui_input_draw (gui_current_window->buffer, 0);
+ gui_current_window->buffer->completion->position = -1;
}
}
}
@@ -491,17 +492,17 @@ gui_action_transpose_chars (t_gui_window *window, char *args)
*/
void
-gui_action_home (t_gui_window *window, char *args)
+gui_action_home (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos > 0)
+ if (gui_current_window->buffer->input_buffer_pos > 0)
{
- window->buffer->input_buffer_pos = 0;
- gui_input_draw (window->buffer, 0);
+ gui_current_window->buffer->input_buffer_pos = 0;
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
}
@@ -511,19 +512,19 @@ gui_action_home (t_gui_window *window, char *args)
*/
void
-gui_action_end (t_gui_window *window, char *args)
+gui_action_end (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos <
- window->buffer->input_buffer_length)
+ if (gui_current_window->buffer->input_buffer_pos <
+ gui_current_window->buffer->input_buffer_length)
{
- window->buffer->input_buffer_pos =
- window->buffer->input_buffer_length;
- gui_input_draw (window->buffer, 0);
+ gui_current_window->buffer->input_buffer_pos =
+ gui_current_window->buffer->input_buffer_length;
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
}
@@ -533,17 +534,17 @@ gui_action_end (t_gui_window *window, char *args)
*/
void
-gui_action_left (t_gui_window *window, char *args)
+gui_action_left (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos > 0)
+ if (gui_current_window->buffer->input_buffer_pos > 0)
{
- window->buffer->input_buffer_pos--;
- gui_input_draw (window->buffer, 0);
+ gui_current_window->buffer->input_buffer_pos--;
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
}
@@ -553,40 +554,40 @@ gui_action_left (t_gui_window *window, char *args)
*/
void
-gui_action_previous_word (t_gui_window *window, char *args)
+gui_action_previous_word (char *args)
{
char *pos;
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos > 0)
+ if (gui_current_window->buffer->input_buffer_pos > 0)
{
- pos = utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos - 1);
+ pos = utf8_add_offset (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos - 1);
while (pos && (pos[0] == ' '))
{
- pos = utf8_prev_char (window->buffer->input_buffer, pos);
+ pos = utf8_prev_char (gui_current_window->buffer->input_buffer, pos);
}
if (pos)
{
while (pos && (pos[0] != ' '))
{
- pos = utf8_prev_char (window->buffer->input_buffer, pos);
+ pos = utf8_prev_char (gui_current_window->buffer->input_buffer, pos);
}
if (pos)
pos = utf8_next_char (pos);
else
- pos = window->buffer->input_buffer;
- window->buffer->input_buffer_pos = utf8_pos (window->buffer->input_buffer,
- pos - window->buffer->input_buffer);
+ pos = gui_current_window->buffer->input_buffer;
+ gui_current_window->buffer->input_buffer_pos = utf8_pos (gui_current_window->buffer->input_buffer,
+ pos - gui_current_window->buffer->input_buffer);
}
else
- window->buffer->input_buffer_pos = 0;
+ gui_current_window->buffer->input_buffer_pos = 0;
- gui_input_draw (window->buffer, 0);
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
}
@@ -596,18 +597,18 @@ gui_action_previous_word (t_gui_window *window, char *args)
*/
void
-gui_action_right (t_gui_window *window, char *args)
+gui_action_right (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos <
- window->buffer->input_buffer_length)
+ if (gui_current_window->buffer->input_buffer_pos <
+ gui_current_window->buffer->input_buffer_length)
{
- window->buffer->input_buffer_pos++;
- gui_input_draw (window->buffer, 0);
+ gui_current_window->buffer->input_buffer_pos++;
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
}
@@ -617,20 +618,20 @@ gui_action_right (t_gui_window *window, char *args)
*/
void
-gui_action_next_word (t_gui_window *window, char *args)
+gui_action_next_word (char *args)
{
char *pos;
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- if (window->buffer->input_buffer_pos <
- window->buffer->input_buffer_length)
+ if (gui_current_window->buffer->input_buffer_pos <
+ gui_current_window->buffer->input_buffer_length)
{
- pos = utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos);
+ pos = utf8_add_offset (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->input_buffer_pos);
while (pos[0] && (pos[0] == ' '))
{
pos = utf8_next_char (pos);
@@ -642,19 +643,19 @@ gui_action_next_word (t_gui_window *window, char *args)
pos = utf8_next_char (pos);
}
if (pos[0])
- window->buffer->input_buffer_pos =
- utf8_pos (window->buffer->input_buffer,
- pos - window->buffer->input_buffer);
+ gui_current_window->buffer->input_buffer_pos =
+ utf8_pos (gui_current_window->buffer->input_buffer,
+ pos - gui_current_window->buffer->input_buffer);
else
- window->buffer->input_buffer_pos =
- window->buffer->input_buffer_length;
+ gui_current_window->buffer->input_buffer_pos =
+ gui_current_window->buffer->input_buffer_length;
}
else
- window->buffer->input_buffer_pos =
- utf8_pos (window->buffer->input_buffer,
- utf8_prev_char (window->buffer->input_buffer, pos) - window->buffer->input_buffer);
+ gui_current_window->buffer->input_buffer_pos =
+ utf8_pos (gui_current_window->buffer->input_buffer,
+ utf8_prev_char (gui_current_window->buffer->input_buffer, pos) - gui_current_window->buffer->input_buffer);
- gui_input_draw (window->buffer, 0);
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
}
@@ -664,12 +665,12 @@ gui_action_next_word (t_gui_window *window, char *args)
*/
void
-gui_action_up (t_gui_window *window, char *args)
+gui_action_up (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->type == GUI_BUFFER_TYPE_DCC)
+ /*if (gui_current_window->buffer->type == GUI_BUFFER_TYPE_FREE)
{
if (irc_dcc_list)
{
@@ -682,69 +683,69 @@ gui_action_up (t_gui_window *window, char *args)
((t_irc_dcc *)(window->dcc_first))->prev_dcc;
window->dcc_selected =
((t_irc_dcc *)(window->dcc_selected))->prev_dcc;
- gui_chat_draw (window->buffer, 1);
- gui_input_draw (window->buffer, 1);
+ gui_chat_draw (gui_current_window->buffer, 1);
+ gui_input_draw (gui_current_window->buffer, 1);
}
}
}
- else if (window->buffer->has_input)
+ else*/ if (gui_current_window->buffer->input)
{
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
- if (window->buffer->ptr_history)
+ if (gui_current_window->buffer->ptr_history)
{
- window->buffer->ptr_history =
- window->buffer->ptr_history->next_history;
- if (!window->buffer->ptr_history)
- window->buffer->ptr_history =
- window->buffer->history;
+ gui_current_window->buffer->ptr_history =
+ gui_current_window->buffer->ptr_history->next_history;
+ if (!gui_current_window->buffer->ptr_history)
+ gui_current_window->buffer->ptr_history =
+ gui_current_window->buffer->history;
}
else
- window->buffer->ptr_history =
- window->buffer->history;
- if (window->buffer->ptr_history)
+ gui_current_window->buffer->ptr_history =
+ gui_current_window->buffer->history;
+ if (gui_current_window->buffer->ptr_history)
{
/* bash/readline like use of history */
- if (window->buffer->ptr_history->prev_history == NULL)
+ if (gui_current_window->buffer->ptr_history->prev_history == NULL)
{
- if (window->buffer->input_buffer_size > 0)
+ if (gui_current_window->buffer->input_buffer_size > 0)
{
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- history_buffer_add (window->buffer, window->buffer->input_buffer);
- history_global_add (window->buffer->input_buffer);
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_history_buffer_add (gui_current_window->buffer, gui_current_window->buffer->input_buffer);
+ gui_history_global_add (gui_current_window->buffer->input_buffer);
}
}
else
{
- if (window->buffer->input_buffer_size > 0)
+ if (gui_current_window->buffer->input_buffer_size > 0)
{
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- if (window->buffer->ptr_history->prev_history->text)
- free(window->buffer->ptr_history->prev_history->text);
- window->buffer->ptr_history->prev_history->text = strdup (window->buffer->input_buffer);
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0';
+ if (gui_current_window->buffer->ptr_history->prev_history->text)
+ free(gui_current_window->buffer->ptr_history->prev_history->text);
+ gui_current_window->buffer->ptr_history->prev_history->text = strdup (gui_current_window->buffer->input_buffer);
}
}
- window->buffer->input_buffer_size =
- strlen (window->buffer->ptr_history->text);
- window->buffer->input_buffer_length =
- utf8_strlen (window->buffer->ptr_history->text);
- gui_input_optimize_size (window->buffer);
- window->buffer->input_buffer_pos =
- window->buffer->input_buffer_length;
- window->buffer->input_buffer_1st_display = 0;
- strcpy (window->buffer->input_buffer,
- window->buffer->ptr_history->text);
- gui_input_init_color_mask (window->buffer);
- gui_input_draw (window->buffer, 0);
+ gui_current_window->buffer->input_buffer_size =
+ strlen (gui_current_window->buffer->ptr_history->text);
+ gui_current_window->buffer->input_buffer_length =
+ utf8_strlen (gui_current_window->buffer->ptr_history->text);
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_current_window->buffer->input_buffer_pos =
+ gui_current_window->buffer->input_buffer_length;
+ gui_current_window->buffer->input_buffer_1st_display = 0;
+ strcpy (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->ptr_history->text);
+ gui_input_init_color_mask (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
else
{
/* search backward in buffer history */
- window->buffer->text_search = GUI_TEXT_SEARCH_BACKWARD;
- (void) gui_buffer_search_text (window);
+ gui_current_window->buffer->text_search = GUI_TEXT_SEARCH_BACKWARD;
+ (void) gui_window_search_text (gui_current_window);
}
}
}
@@ -754,13 +755,13 @@ gui_action_up (t_gui_window *window, char *args)
*/
void
-gui_action_up_global (t_gui_window *window, char *args)
+gui_action_up_global (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input
- && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
+ if ((gui_current_window->buffer->input)
+ && (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
if (history_global_ptr)
{
@@ -772,18 +773,18 @@ gui_action_up_global (t_gui_window *window, char *args)
history_global_ptr = history_global;
if (history_global_ptr)
{
- window->buffer->input_buffer_size =
+ gui_current_window->buffer->input_buffer_size =
strlen (history_global_ptr->text);
- window->buffer->input_buffer_length =
+ gui_current_window->buffer->input_buffer_length =
utf8_strlen (history_global_ptr->text);
- gui_input_optimize_size (window->buffer);
- window->buffer->input_buffer_pos =
- window->buffer->input_buffer_length;
- window->buffer->input_buffer_1st_display = 0;
- strcpy (window->buffer->input_buffer,
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_current_window->buffer->input_buffer_pos =
+ gui_current_window->buffer->input_buffer_length;
+ gui_current_window->buffer->input_buffer_1st_display = 0;
+ strcpy (gui_current_window->buffer->input_buffer,
history_global_ptr->text);
- gui_input_init_color_mask (window->buffer);
- gui_input_draw (window->buffer, 0);
+ gui_input_init_color_mask (gui_current_window->buffer);
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
}
@@ -793,12 +794,12 @@ gui_action_up_global (t_gui_window *window, char *args)
*/
void
-gui_action_down (t_gui_window *window, char *args)
+gui_action_down (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->type == GUI_BUFFER_TYPE_DCC)
+ /*if (gui_current_window->buffer->type == GUI_BUFFER_TYPE_FREE)
{
if (irc_dcc_list)
{
@@ -822,66 +823,66 @@ gui_action_down (t_gui_window *window, char *args)
else
window->dcc_selected =
irc_dcc_list->next_dcc;
- gui_chat_draw (window->buffer, 1);
- gui_input_draw (window->buffer, 1);
+ gui_chat_draw (gui_current_window->buffer, 1);
+ gui_input_draw (gui_current_window->buffer, 1);
}
}
}
- else if (window->buffer->has_input)
+ else */if (gui_current_window->buffer->input)
{
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
- if (window->buffer->ptr_history)
+ if (gui_current_window->buffer->ptr_history)
{
- window->buffer->ptr_history =
- window->buffer->ptr_history->prev_history;
- if (window->buffer->ptr_history)
+ gui_current_window->buffer->ptr_history =
+ gui_current_window->buffer->ptr_history->prev_history;
+ if (gui_current_window->buffer->ptr_history)
{
- window->buffer->input_buffer_size =
- strlen (window->buffer->ptr_history->text);
- window->buffer->input_buffer_length =
- utf8_strlen (window->buffer->ptr_history->text);
+ gui_current_window->buffer->input_buffer_size =
+ strlen (gui_current_window->buffer->ptr_history->text);
+ gui_current_window->buffer->input_buffer_length =
+ utf8_strlen (gui_current_window->buffer->ptr_history->text);
}
else
{
- window->buffer->input_buffer_size = 0;
- window->buffer->input_buffer_length = 0;
+ gui_current_window->buffer->input_buffer_size = 0;
+ gui_current_window->buffer->input_buffer_length = 0;
}
- gui_input_optimize_size (window->buffer);
- window->buffer->input_buffer_pos =
- window->buffer->input_buffer_length;
- window->buffer->input_buffer_1st_display = 0;
- if (window->buffer->ptr_history)
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_current_window->buffer->input_buffer_pos =
+ gui_current_window->buffer->input_buffer_length;
+ gui_current_window->buffer->input_buffer_1st_display = 0;
+ if (gui_current_window->buffer->ptr_history)
{
- strcpy (window->buffer->input_buffer,
- window->buffer->ptr_history->text);
- gui_input_init_color_mask (window->buffer);
+ strcpy (gui_current_window->buffer->input_buffer,
+ gui_current_window->buffer->ptr_history->text);
+ gui_input_init_color_mask (gui_current_window->buffer);
}
- gui_input_draw (window->buffer, 0);
+ gui_input_draw (gui_current_window->buffer, 0);
}
else
{
/* add line to history then clear input */
- if (window->buffer->input_buffer_size > 0)
+ if (gui_current_window->buffer->input_buffer_size > 0)
{
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- history_buffer_add (window->buffer, window->buffer->input_buffer);
- history_global_add (window->buffer->input_buffer);
- window->buffer->input_buffer_size = 0;
- window->buffer->input_buffer_length = 0;
- gui_input_optimize_size (window->buffer);
- window->buffer->input_buffer_pos = 0;
- window->buffer->input_buffer_1st_display = 0;
- gui_input_draw (window->buffer, 0);
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_current_window->buffer->input_buffer_color_mask[gui_current_window->buffer->input_buffer_size] = '\0';
+ gui_history_buffer_add (gui_current_window->buffer, gui_current_window->buffer->input_buffer);
+ gui_history_global_add (gui_current_window->buffer->input_buffer);
+ gui_current_window->buffer->input_buffer_size = 0;
+ gui_current_window->buffer->input_buffer_length = 0;
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_current_window->buffer->input_buffer_pos = 0;
+ gui_current_window->buffer->input_buffer_1st_display = 0;
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
}
else
{
/* search forward in buffer history */
- window->buffer->text_search = GUI_TEXT_SEARCH_FORWARD;
- (void) gui_buffer_search_text (window);
+ gui_current_window->buffer->text_search = GUI_TEXT_SEARCH_FORWARD;
+ (void) gui_window_search_text (gui_current_window);
}
}
}
@@ -891,40 +892,40 @@ gui_action_down (t_gui_window *window, char *args)
*/
void
-gui_action_down_global (t_gui_window *window, char *args)
+gui_action_down_global (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input
- && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
+ if ((gui_current_window->buffer->input)
+ && (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
if (history_global_ptr)
{
history_global_ptr = history_global_ptr->prev_history;
if (history_global_ptr)
{
- window->buffer->input_buffer_size =
+ gui_current_window->buffer->input_buffer_size =
strlen (history_global_ptr->text);
- window->buffer->input_buffer_length =
+ gui_current_window->buffer->input_buffer_length =
utf8_strlen (history_global_ptr->text);
}
else
{
- window->buffer->input_buffer_size = 0;
- window->buffer->input_buffer_length = 0;
+ gui_current_window->buffer->input_buffer_size = 0;
+ gui_current_window->buffer->input_buffer_length = 0;
}
- gui_input_optimize_size (window->buffer);
- window->buffer->input_buffer_pos =
- window->buffer->input_buffer_length;
- window->buffer->input_buffer_1st_display = 0;
+ gui_input_optimize_size (gui_current_window->buffer);
+ gui_current_window->buffer->input_buffer_pos =
+ gui_current_window->buffer->input_buffer_length;
+ gui_current_window->buffer->input_buffer_1st_display = 0;
if (history_global_ptr)
{
- strcpy (window->buffer->input_buffer,
+ strcpy (gui_current_window->buffer->input_buffer,
history_global_ptr->text);
- gui_input_init_color_mask (window->buffer);
+ gui_input_init_color_mask (gui_current_window->buffer);
}
- gui_input_draw (window->buffer, 0);
+ gui_input_draw (gui_current_window->buffer, 0);
}
}
}
@@ -934,12 +935,12 @@ gui_action_down_global (t_gui_window *window, char *args)
*/
void
-gui_action_page_up (t_gui_window *window, char *args)
+gui_action_page_up (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_page_up (window);
+ gui_window_page_up (gui_current_window);
}
/*
@@ -947,12 +948,12 @@ gui_action_page_up (t_gui_window *window, char *args)
*/
void
-gui_action_page_down (t_gui_window *window, char *args)
+gui_action_page_down (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_page_down (window);
+ gui_window_page_down (gui_current_window);
}
/*
@@ -960,12 +961,12 @@ gui_action_page_down (t_gui_window *window, char *args)
*/
void
-gui_action_scroll_up (t_gui_window *window, char *args)
+gui_action_scroll_up (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_scroll_up (window);
+ gui_window_scroll_up (gui_current_window);
}
/*
@@ -973,12 +974,12 @@ gui_action_scroll_up (t_gui_window *window, char *args)
*/
void
-gui_action_scroll_down (t_gui_window *window, char *args)
+gui_action_scroll_down (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_scroll_down (window);
+ gui_window_scroll_down (gui_current_window);
}
/*
@@ -986,12 +987,12 @@ gui_action_scroll_down (t_gui_window *window, char *args)
*/
void
-gui_action_scroll_top (t_gui_window *window, char *args)
+gui_action_scroll_top (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_scroll_top (window);
+ gui_window_scroll_top (gui_current_window);
}
/*
@@ -999,12 +1000,12 @@ gui_action_scroll_top (t_gui_window *window, char *args)
*/
void
-gui_action_scroll_bottom (t_gui_window *window, char *args)
+gui_action_scroll_bottom (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_scroll_bottom (window);
+ gui_window_scroll_bottom (gui_current_window);
}
/*
@@ -1012,12 +1013,12 @@ gui_action_scroll_bottom (t_gui_window *window, char *args)
*/
void
-gui_action_scroll_topic_left (t_gui_window *window, char *args)
+gui_action_scroll_topic_left (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_scroll_topic_left (window);
+ gui_window_scroll_topic_left (gui_current_window);
}
/*
@@ -1025,12 +1026,12 @@ gui_action_scroll_topic_left (t_gui_window *window, char *args)
*/
void
-gui_action_scroll_topic_right (t_gui_window *window, char *args)
+gui_action_scroll_topic_right (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_scroll_topic_right (window);
+ gui_window_scroll_topic_right (gui_current_window);
}
/*
@@ -1038,12 +1039,12 @@ gui_action_scroll_topic_right (t_gui_window *window, char *args)
*/
void
-gui_action_nick_beginning (t_gui_window *window, char *args)
+gui_action_nick_beginning (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_nick_beginning (window);
+ gui_window_nick_beginning (gui_current_window);
}
/*
@@ -1051,12 +1052,12 @@ gui_action_nick_beginning (t_gui_window *window, char *args)
*/
void
-gui_action_nick_end (t_gui_window *window, char *args)
+gui_action_nick_end (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_nick_end (window);
+ gui_window_nick_end (gui_current_window);
}
/*
@@ -1064,12 +1065,12 @@ gui_action_nick_end (t_gui_window *window, char *args)
*/
void
-gui_action_nick_page_up (t_gui_window *window, char *args)
+gui_action_nick_page_up (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_nick_page_up (window);
+ gui_window_nick_page_up (gui_current_window);
}
/*
@@ -1077,12 +1078,12 @@ gui_action_nick_page_up (t_gui_window *window, char *args)
*/
void
-gui_action_nick_page_down (t_gui_window *window, char *args)
+gui_action_nick_page_down (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_nick_page_down (window);
+ gui_window_nick_page_down (gui_current_window);
}
/*
@@ -1090,27 +1091,29 @@ gui_action_nick_page_down (t_gui_window *window, char *args)
*/
void
-gui_action_jump_smart (t_gui_window *window, char *args)
+gui_action_jump_smart (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
- if (weechat_hotlist)
+ if (gui_hotlist)
{
- if (!hotlist_initial_buffer)
- hotlist_initial_buffer = window->buffer;
- gui_window_switch_to_buffer (window, weechat_hotlist->buffer);
- gui_window_redraw_buffer (window->buffer);
+ if (!gui_hotlist_initial_buffer)
+ gui_hotlist_initial_buffer = gui_current_window->buffer;
+ gui_window_switch_to_buffer (gui_current_window,
+ gui_hotlist->buffer);
+ gui_window_redraw_buffer (gui_current_window->buffer);
}
else
{
- if (hotlist_initial_buffer)
+ if (gui_hotlist_initial_buffer)
{
- gui_window_switch_to_buffer (window, hotlist_initial_buffer);
- gui_window_redraw_buffer (window->buffer);
- hotlist_initial_buffer = NULL;
+ gui_window_switch_to_buffer (gui_current_window,
+ gui_hotlist_initial_buffer);
+ gui_window_redraw_buffer (gui_current_window->buffer);
+ gui_hotlist_initial_buffer = NULL;
}
}
}
@@ -1121,28 +1124,28 @@ gui_action_jump_smart (t_gui_window *window, char *args)
*/
void
-gui_action_jump_dcc (t_gui_window *window, char *args)
+gui_action_jump_dcc (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ /*if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
- if (window->buffer->type == GUI_BUFFER_TYPE_DCC)
+ if (gui_current_window->buffer->type == GUI_BUFFER_TYPE_DCC)
{
if (gui_buffer_before_dcc)
{
gui_window_switch_to_buffer (window,
gui_buffer_before_dcc);
- gui_window_redraw_buffer (window->buffer);
+ gui_window_redraw_buffer (gui_current_window->buffer);
}
}
else
{
- gui_buffer_before_dcc = window->buffer;
+ gui_buffer_before_dcc = buffer;
gui_buffer_switch_dcc (window);
}
- }
+ }*/
}
/*
@@ -1150,28 +1153,28 @@ gui_action_jump_dcc (t_gui_window *window, char *args)
*/
void
-gui_action_jump_raw_data (t_gui_window *window, char *args)
+gui_action_jump_raw_data (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ /*if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
- if (window->buffer->type == GUI_BUFFER_TYPE_RAW_DATA)
+ if (gui_current_window->buffer->type == GUI_BUFFER_TYPE_RAW_DATA)
{
if (gui_buffer_before_raw_data)
{
gui_window_switch_to_buffer (window,
gui_buffer_before_raw_data);
- gui_window_redraw_buffer (window->buffer);
+ gui_window_redraw_buffer (gui_current_window->buffer);
}
}
else
{
- gui_buffer_before_raw_data = window->buffer;
+ gui_buffer_before_raw_data = buffer;
gui_buffer_switch_raw_data (window);
}
- }
+ }*/
}
/*
@@ -1179,15 +1182,16 @@ gui_action_jump_raw_data (t_gui_window *window, char *args)
*/
void
-gui_action_jump_last_buffer (t_gui_window *window, char *args)
+gui_action_jump_last_buffer (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
if (last_gui_buffer)
- gui_buffer_switch_by_number (window, last_gui_buffer->number);
+ gui_buffer_switch_by_number (gui_current_window,
+ last_gui_buffer->number);
}
}
@@ -1197,15 +1201,16 @@ gui_action_jump_last_buffer (t_gui_window *window, char *args)
*/
void
-gui_action_jump_previous_buffer (t_gui_window *window, char *args)
+gui_action_jump_previous_buffer (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
if (gui_previous_buffer)
- gui_buffer_switch_by_number (window, gui_previous_buffer->number);
+ gui_buffer_switch_by_number (gui_current_window,
+ gui_previous_buffer->number);
}
}
@@ -1214,24 +1219,24 @@ gui_action_jump_previous_buffer (t_gui_window *window, char *args)
*/
void
-gui_action_jump_server (t_gui_window *window, char *args)
+gui_action_jump_server (char *args)
{
/* make C compiler happy */
(void) args;
-
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+
+ /*if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
- if (GUI_SERVER(window->buffer))
+ if (GUI_SERVER(buffer))
{
- if (GUI_SERVER(window->buffer)->buffer !=
- window->buffer)
+ if (GUI_SERVER(buffer)->buffer !=
+ buffer)
{
gui_window_switch_to_buffer (window,
- GUI_SERVER(window->buffer)->buffer);
- gui_window_redraw_buffer (window->buffer);
+ GUI_SERVER(buffer)->buffer);
+ gui_window_redraw_buffer (gui_current_window->buffer);
}
}
- }
+ }*/
}
/*
@@ -1239,34 +1244,34 @@ gui_action_jump_server (t_gui_window *window, char *args)
*/
void
-gui_action_jump_next_server (t_gui_window *window, char *args)
+gui_action_jump_next_server (char *args)
{
- t_irc_server *ptr_server;
- t_gui_buffer *ptr_buffer;
+ //t_irc_server *ptr_server;
+ //t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) args;
-
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+
+ /*if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
- if (GUI_SERVER(window->buffer))
+ if (GUI_SERVER(buffer))
{
- ptr_server = GUI_SERVER(window->buffer)->next_server;
+ ptr_server = GUI_SERVER(buffer)->next_server;
if (!ptr_server)
ptr_server = irc_servers;
- while (ptr_server != GUI_SERVER(window->buffer))
+ while (ptr_server != GUI_SERVER(buffer))
{
if (ptr_server->buffer)
break;
ptr_server = (ptr_server->next_server) ?
ptr_server->next_server : irc_servers;
}
- if (ptr_server != GUI_SERVER(window->buffer))
+ if (ptr_server != GUI_SERVER(buffer))
{
- /* save current buffer */
- GUI_SERVER(window->buffer)->saved_buffer = window->buffer;
+ // save current buffer
+ GUI_SERVER(buffer)->saved_buffer = buffer;
- /* come back to memorized chan if found */
+ // come back to memorized chan if found
if (ptr_server->saved_buffer)
ptr_buffer = ptr_server->saved_buffer;
else
@@ -1276,10 +1281,10 @@ gui_action_jump_next_server (t_gui_window *window, char *args)
&& (ptr_buffer->all_servers))
ptr_buffer->server = ptr_server;
gui_window_switch_to_buffer (window, ptr_buffer);
- gui_window_redraw_buffer (window->buffer);
+ gui_window_redraw_buffer (gui_current_window->buffer);
}
}
- }
+ }*/
}
/*
@@ -1288,12 +1293,12 @@ gui_action_jump_next_server (t_gui_window *window, char *args)
*/
void
-gui_action_switch_server (t_gui_window *window, char *args)
+gui_action_switch_server (char *args)
{
/* make C compiler happy */
(void) args;
- gui_window_switch_server (window);
+ gui_window_switch_server (gui_current_window);
}
/*
@@ -1301,20 +1306,20 @@ gui_action_switch_server (t_gui_window *window, char *args)
*/
void
-gui_action_scroll_previous_highlight (t_gui_window *window, char *args)
+gui_action_scroll_previous_highlight (char *args)
{
- t_gui_line *ptr_line;
+ //t_gui_line *ptr_line;
/* make C compiler happy */
(void) args;
- if ((window->buffer->type == GUI_BUFFER_TYPE_STANDARD)
- && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
+ /*if ((gui_current_window->buffer->type == GUI_BUFFER_TYPE_FORMATED)
+ && (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
- if (window->buffer->lines)
+ if (gui_current_window->buffer->lines)
{
ptr_line = (window->start_line) ?
- window->start_line->prev_line : window->buffer->last_line;
+ window->start_line->prev_line : gui_current_window->buffer->last_line;
while (ptr_line)
{
if (ptr_line->line_with_highlight)
@@ -1322,15 +1327,15 @@ gui_action_scroll_previous_highlight (t_gui_window *window, char *args)
window->start_line = ptr_line;
window->start_line_pos = 0;
window->first_line_displayed =
- (window->start_line == window->buffer->lines);
- gui_chat_draw (window->buffer, 1);
- gui_status_draw (window->buffer, 0);
+ (window->start_line == gui_current_window->buffer->lines);
+ gui_chat_draw (gui_current_window->buffer, 1);
+ gui_status_draw (gui_current_window->buffer, 0);
return;
}
ptr_line = ptr_line->prev_line;
}
}
- }
+ }*/
}
/*
@@ -1338,20 +1343,20 @@ gui_action_scroll_previous_highlight (t_gui_window *window, char *args)
*/
void
-gui_action_scroll_next_highlight (t_gui_window *window, char *args)
+gui_action_scroll_next_highlight (char *args)
{
- t_gui_line *ptr_line;
+ //t_gui_line *ptr_line;
/* make C compiler happy */
(void) args;
- if ((window->buffer->type == GUI_BUFFER_TYPE_STANDARD)
- && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
+ /*if ((gui_current_window->buffer->type == GUI_BUFFER_TYPE_FORMATED)
+ && (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED))
{
- if (window->buffer->lines)
+ if (gui_current_window->buffer->lines)
{
ptr_line = (window->start_line) ?
- window->start_line->next_line : window->buffer->lines->next_line;
+ window->start_line->next_line : gui_current_window->buffer->lines->next_line;
while (ptr_line)
{
if (ptr_line->line_with_highlight)
@@ -1359,15 +1364,15 @@ gui_action_scroll_next_highlight (t_gui_window *window, char *args)
window->start_line = ptr_line;
window->start_line_pos = 0;
window->first_line_displayed =
- (window->start_line == window->buffer->lines);
- gui_chat_draw (window->buffer, 1);
- gui_status_draw (window->buffer, 0);
+ (window->start_line == gui_current_window->buffer->lines);
+ gui_chat_draw (gui_current_window->buffer, 1);
+ gui_status_draw (gui_current_window->buffer, 0);
return;
}
ptr_line = ptr_line->next_line;
}
}
- }
+ }*/
}
/*
@@ -1375,25 +1380,26 @@ gui_action_scroll_next_highlight (t_gui_window *window, char *args)
*/
void
-gui_action_scroll_unread (t_gui_window *window, char *args)
+gui_action_scroll_unread (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
if (cfg_look_read_marker &&
cfg_look_read_marker[0] &&
- (window->buffer->type == GUI_BUFFER_TYPE_STANDARD) &&
- window->buffer->last_read_line &&
- window->buffer->last_read_line != window->buffer->last_line)
+ (gui_current_window->buffer->type == GUI_BUFFER_TYPE_FORMATED) &&
+ gui_current_window->buffer->last_read_line &&
+ gui_current_window->buffer->last_read_line != gui_current_window->buffer->last_line)
{
- window->start_line = window->buffer->last_read_line->next_line;
- window->start_line_pos = 0;
- window->first_line_displayed =
- (window->start_line == window->buffer->lines);
- gui_chat_draw (window->buffer, 1);
- gui_status_draw (window->buffer, 0);
+ gui_current_window->start_line =
+ gui_current_window->buffer->last_read_line->next_line;
+ gui_current_window->start_line_pos = 0;
+ gui_current_window->first_line_displayed =
+ (gui_current_window->start_line == gui_current_window->buffer->lines);
+ gui_chat_draw (gui_current_window->buffer, 1);
+ gui_status_draw (gui_current_window->buffer, 0);
}
}
}
@@ -1403,19 +1409,18 @@ gui_action_scroll_unread (t_gui_window *window, char *args)
*/
void
-gui_action_set_unread (t_gui_window *window, char *args)
+gui_action_set_unread (char *args)
{
- t_gui_buffer *ptr_buffer;
+ struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
- (void) window;
(void) args;
/* set read marker for all standard buffers */
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- if (ptr_buffer->type == GUI_BUFFER_TYPE_STANDARD)
+ if (ptr_buffer->type == GUI_BUFFER_TYPE_FORMATED)
ptr_buffer->last_read_line = ptr_buffer->last_line;
}
@@ -1428,17 +1433,17 @@ gui_action_set_unread (t_gui_window *window, char *args)
*/
void
-gui_action_hotlist_clear (t_gui_window *window, char *args)
+gui_action_hotlist_clear (char *args)
{
/* make C compiler happy */
(void) args;
- if (weechat_hotlist)
+ if (gui_hotlist)
{
- hotlist_free_all (&weechat_hotlist, &last_weechat_hotlist);
- gui_window_redraw_buffer (window->buffer);
+ gui_hotlist_free_all (&gui_hotlist, &last_gui_hotlist);
+ gui_window_redraw_buffer (gui_current_window->buffer);
}
- hotlist_initial_buffer = window->buffer;
+ gui_hotlist_initial_buffer = gui_current_window->buffer;
}
/*
@@ -1446,13 +1451,13 @@ gui_action_hotlist_clear (t_gui_window *window, char *args)
*/
void
-gui_action_infobar_clear (t_gui_window *window, char *args)
+gui_action_infobar_clear (char *args)
{
/* make C compiler happy */
(void) args;
gui_infobar_remove ();
- gui_infobar_draw (window->buffer, 1);
+ gui_infobar_draw (gui_current_window->buffer, 1);
}
/*
@@ -1460,10 +1465,9 @@ gui_action_infobar_clear (t_gui_window *window, char *args)
*/
void
-gui_action_refresh_screen (t_gui_window *window, char *args)
+gui_action_refresh_screen (char *args)
{
/* make C compiler happy */
- (void) window;
(void) args;
gui_window_refresh_screen (1);
@@ -1474,12 +1478,12 @@ gui_action_refresh_screen (t_gui_window *window, char *args)
*/
void
-gui_action_grab_key (t_gui_window *window, char *args)
+gui_action_grab_key (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->has_input)
+ if (gui_current_window->buffer->input)
gui_keyboard_grab_init ();
}
@@ -1488,16 +1492,15 @@ gui_action_grab_key (t_gui_window *window, char *args)
*/
void
-gui_action_insert_string (t_gui_window *window, char *args)
+gui_action_insert_string (char *args)
{
char *args2;
if (args)
{
- args2 = weechat_convert_hex_chars (args);
- gui_insert_string_input (window,
- (args2) ? args2 : args, -1);
- gui_input_draw (window->buffer, 0);
+ args2 = string_convert_hex_chars (args);
+ gui_input_insert_string (gui_current_window->buffer, (args2) ? args2 : args, -1);
+ gui_input_draw (gui_current_window->buffer, 0);
if (args2)
free (args2);
}
@@ -1508,21 +1511,21 @@ gui_action_insert_string (t_gui_window *window, char *args)
*/
void
-gui_action_search_text (t_gui_window *window, char *args)
+gui_action_search_text (char *args)
{
/* make C compiler happy */
(void) args;
- if (window->buffer->type == GUI_BUFFER_TYPE_STANDARD)
+ if (gui_current_window->buffer->type == GUI_BUFFER_TYPE_FORMATED)
{
/* toggle search */
- if (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
- gui_buffer_search_start (window);
+ if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
+ gui_window_search_start (gui_current_window);
else
{
- window->buffer->text_search_exact ^= 1;
- gui_buffer_search_restart (window);
- gui_input_draw (window->buffer, 1);
+ gui_current_window->buffer->text_search_exact ^= 1;
+ gui_window_search_restart (gui_current_window);
+ gui_input_draw (gui_current_window->buffer, 1);
}
}
}
diff --git a/src/gui/gui-action.h b/src/gui/gui-action.h
new file mode 100644
index 000000000..8588beb91
--- /dev/null
+++ b/src/gui/gui-action.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_GUI_ACTION_H
+#define __WEECHAT_GUI_ACTION_H 1
+
+/* action functions */
+
+extern void gui_action_clipboard_copy (char *, int);
+extern void gui_action_clipboard_paste (char *);
+extern void gui_action_return (char *);
+extern void gui_action_tab (char *);
+extern void gui_action_tab_previous (char *);
+extern void gui_action_backspace (char *);
+extern void gui_action_delete (char *);
+extern void gui_action_delete_previous_word (char *);
+extern void gui_action_delete_next_word (char *);
+extern void gui_action_delete_begin_of_line (char *);
+extern void gui_action_delete_end_of_line (char *);
+extern void gui_action_delete_line (char *);
+extern void gui_action_transpose_chars (char *);
+extern void gui_action_home (char *);
+extern void gui_action_end (char *);
+extern void gui_action_left (char *);
+extern void gui_action_previous_word (char *);
+extern void gui_action_right (char *);
+extern void gui_action_next_word (char *);
+extern void gui_action_up (char *);
+extern void gui_action_up_global (char *);
+extern void gui_action_down (char *);
+extern void gui_action_down_global (char *);
+extern void gui_action_page_up (char *);
+extern void gui_action_page_down (char *);
+extern void gui_action_scroll_up (char *);
+extern void gui_action_scroll_down (char *);
+extern void gui_action_scroll_top (char *);
+extern void gui_action_scroll_bottom (char *);
+extern void gui_action_scroll_topic_left (char *);
+extern void gui_action_scroll_topic_right (char *);
+extern void gui_action_nick_beginning (char *);
+extern void gui_action_nick_end (char *);
+extern void gui_action_nick_page_up (char *);
+extern void gui_action_nick_page_down (char *);
+extern void gui_action_jump_smart (char *);
+extern void gui_action_jump_dcc (char *);
+extern void gui_action_jump_raw_data (char *);
+extern void gui_action_jump_last_buffer (char *);
+extern void gui_action_jump_previous_buffer (char *);
+extern void gui_action_jump_server (char *);
+extern void gui_action_jump_next_server (char *);
+extern void gui_action_switch_server (char *);
+extern void gui_action_scroll_previous_highlight (char *);
+extern void gui_action_scroll_next_highlight (char *);
+extern void gui_action_scroll_unread (char *);
+extern void gui_action_set_unread (char *);
+extern void gui_action_hotlist_clear (char *);
+extern void gui_action_infobar_clear (char *);
+extern void gui_action_refresh_screen (char *);
+extern void gui_action_grab_key (char *);
+extern void gui_action_insert_string (char *);
+extern void gui_action_search_text (char *);
+
+#endif /* gui-action.h */
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 50fb7fb96..16afc0133 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -32,174 +32,103 @@
#include <time.h>
#include <ctype.h>
-#include "../common/weechat.h"
-#include "gui.h"
-#include "../common/command.h"
-#include "../common/weeconfig.h"
-#include "../common/history.h"
-#include "../common/hotlist.h"
-#include "../common/log.h"
-#include "../common/utf8.h"
-#include "../common/util.h"
-#include "../protocols/irc/irc.h"
-
-#ifdef PLUGINS
-#include "../plugins/plugins.h"
-#endif
-
-
-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_previous_buffer = NULL; /* pointer to previous 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*/
+#include "../core/weechat.h"
+#include "gui-completion.h"
+#include "gui-history.h"
+#include "gui-hotlist.h"
+#include "gui-main.h"
+#include "gui-log.h"
+#include "gui-status.h"
+#include "gui-window.h"
+#include "../core/wee-command.h"
+#include "../core/wee-config.h"
+#include "../core/wee-log.h"
+#include "../core/wee-utf8.h"
+#include "../plugins/plugin.h"
+
+
+struct t_gui_buffer *gui_buffers = NULL; /* first buffer */
+struct t_gui_buffer *last_gui_buffer = NULL; /* last buffer */
+struct t_gui_buffer *gui_previous_buffer = NULL; /* previous buffer */
+struct t_gui_buffer *gui_buffer_before_dcc = NULL; /* buffer before dcc */
+struct t_gui_buffer *gui_buffer_raw_data = NULL; /* buffer with raw data */
+struct t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buf. before raw */
/*
- * gui_buffer_servers_search: search servers buffer
- * (when same buffer is used for all servers)
- */
-
-t_gui_buffer *
-gui_buffer_servers_search ()
-{
- t_gui_buffer *ptr_buffer;
-
- for (ptr_buffer = gui_buffers; ptr_buffer;
- ptr_buffer = ptr_buffer->next_buffer)
- {
- if (ptr_buffer->all_servers)
- return ptr_buffer;
- }
-
- /* buffer not found */
- return NULL;
-}
-
-/*
* gui_buffer_new: create a new buffer in current window
*/
-t_gui_buffer *
-gui_buffer_new (t_gui_window *window, void *server, void *channel, int type,
- int switch_to_buffer)
+struct t_gui_buffer *
+gui_buffer_new (void *plugin, char *category, char *name)
{
- t_gui_buffer *new_buffer, *ptr_buffer;
-#ifdef PLUGINS
+ struct t_gui_buffer *new_buffer;
+ struct t_gui_completion *new_completion;
char buffer_str[16], *argv[1] = { NULL };
-#endif
#ifdef DEBUG
weechat_log_printf ("Creating new buffer\n");
#endif
- /* use first buffer if no server is assigned to this buffer */
- if ((type == GUI_BUFFER_TYPE_STANDARD) && gui_buffers
- && (!GUI_SERVER(gui_buffers)) && (!channel))
- {
- if (server)
- ((t_irc_server *)(server))->buffer = gui_buffers;
- if (channel)
- ((t_irc_channel *)(channel))->buffer = gui_buffers;
- gui_buffers->server = server;
- gui_buffers->channel = channel;
- if (cfg_look_one_server_buffer && server && !channel)
- gui_buffers->all_servers = 1;
- if (cfg_log_auto_server)
- gui_log_start (gui_buffers);
- gui_buffers->completion.server = server;
- return gui_buffers;
- }
-
- /* use "all servers" buffer if found */
- if (cfg_look_one_server_buffer && (type == GUI_BUFFER_TYPE_STANDARD) &&
- gui_buffers && server && !channel)
- {
- ptr_buffer = gui_buffer_servers_search ();
- if (ptr_buffer)
- {
- ((t_irc_server *)(server))->buffer = ptr_buffer;
- ptr_buffer->server = server;
- if (switch_to_buffer)
- gui_window_switch_to_buffer (window, ptr_buffer);
- gui_window_redraw_buffer (ptr_buffer);
- return ptr_buffer;
- }
- }
+ if (!name)
+ return NULL;
- if ((new_buffer = (t_gui_buffer *)(malloc (sizeof (t_gui_buffer)))))
+ /* create new buffer */
+ if ((new_buffer = (struct t_gui_buffer *)(malloc (sizeof (struct t_gui_buffer)))))
{
- new_buffer->num_displayed = 0;
+ /* init buffer */
+ new_buffer->plugin = (struct t_weechat_plugin *)plugin;
new_buffer->number = (last_gui_buffer) ? last_gui_buffer->number + 1 : 1;
+ new_buffer->category = (category) ? strdup (category) : NULL;
+ new_buffer->name = strdup (name);
+ new_buffer->type = GUI_BUFFER_TYPE_FORMATED;
+ new_buffer->notify_level = GUI_BUFFER_NOTIFY_LEVEL_DEFAULT;
+ new_buffer->num_displayed = 0;
- /* assign server and channel to buffer */
- new_buffer->server = server;
- new_buffer->all_servers = 0;
- new_buffer->channel = channel;
- new_buffer->type = type;
- if (new_buffer->type == GUI_BUFFER_TYPE_RAW_DATA)
- gui_buffer_raw_data = new_buffer;
- /* assign buffer to server and channel */
- if (server && !channel)
- {
- GUI_SERVER(new_buffer)->buffer = new_buffer;
- new_buffer->all_servers = (cfg_look_one_server_buffer) ? 1 : 0;
- }
- if (!gui_buffers && cfg_look_one_server_buffer)
- new_buffer->all_servers = 1;
- if (channel)
- GUI_CHANNEL(new_buffer)->buffer = new_buffer;
+ /* create/append to log file */
+ new_buffer->log_filename = NULL;
+ new_buffer->log_file = NULL;
- if (!window->buffer)
- {
- window->buffer = new_buffer;
- window->first_line_displayed = 1;
- window->start_line = NULL;
- window->start_line_pos = 0;
- gui_window_calculate_pos_size (window, 1);
- }
+ /* title */
+ new_buffer->title = NULL;
- /* init lines */
+ /* chat lines */
new_buffer->lines = NULL;
new_buffer->last_line = NULL;
new_buffer->last_read_line = NULL;
- new_buffer->num_lines = 0;
- new_buffer->line_complete = 1;
+ new_buffer->lines_count = 0;
+ new_buffer->prefix_max_length = 0;
+ new_buffer->chat_refresh_needed = 1;
- /* notify level */
- new_buffer->notify_level = irc_channel_get_notify_level (server, channel);
+ /* nicklist */
+ new_buffer->nicklist = 0;
+ new_buffer->nick_case_sensitive = 0;
+ new_buffer->nicks = NULL;
+ new_buffer->last_nick = NULL;
+ new_buffer->nick_max_length = -1;
+ new_buffer->nicks_count = 0;
- /* create/append to log file */
- new_buffer->log_filename = NULL;
- new_buffer->log_file = NULL;
- if ((cfg_log_auto_server && GUI_BUFFER_IS_SERVER(new_buffer))
- || (cfg_log_auto_channel && GUI_BUFFER_IS_CHANNEL(new_buffer))
- || (cfg_log_auto_private && GUI_BUFFER_IS_PRIVATE(new_buffer)))
- gui_log_start (new_buffer);
-
- /* init input buffer */
- new_buffer->has_input = (new_buffer->type == GUI_BUFFER_TYPE_STANDARD) ? 1 : 0;
- if (new_buffer->has_input)
- {
- new_buffer->input_buffer_alloc = GUI_INPUT_BUFFER_BLOCK_SIZE;
- new_buffer->input_buffer = (char *) malloc (GUI_INPUT_BUFFER_BLOCK_SIZE);
- new_buffer->input_buffer_color_mask = (char *) malloc (GUI_INPUT_BUFFER_BLOCK_SIZE);
- new_buffer->input_buffer[0] = '\0';
- new_buffer->input_buffer_color_mask[0] = '\0';
- }
- else
- {
- new_buffer->input_buffer = NULL;
- new_buffer->input_buffer_color_mask = NULL;
- }
+ /* input */
+ new_buffer->input = 1;
+ new_buffer->input_data_cb = NULL;
+ new_buffer->input_nick = NULL;
+ new_buffer->input_buffer_alloc = GUI_BUFFER_INPUT_BLOCK_SIZE;
+ new_buffer->input_buffer = (char *) malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
+ new_buffer->input_buffer_color_mask = (char *) malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
+ new_buffer->input_buffer[0] = '\0';
+ new_buffer->input_buffer_color_mask[0] = '\0';
new_buffer->input_buffer_size = 0;
new_buffer->input_buffer_length = 0;
new_buffer->input_buffer_pos = 0;
new_buffer->input_buffer_1st_display = 0;
/* init completion */
- completion_init (&(new_buffer->completion), server, channel);
+ new_completion = (struct t_gui_completion *)malloc (sizeof (struct t_gui_completion));
+ if (new_completion)
+ {
+ new_buffer->completion = new_completion;
+ gui_completion_init (new_completion, new_buffer);
+ }
/* init history */
new_buffer->history = NULL;
@@ -213,7 +142,7 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int type,
new_buffer->text_search_found = 0;
new_buffer->text_search_input = NULL;
- /* add buffer to buffers queue */
+ /* add buffer to buffers list */
new_buffer->prev_buffer = last_gui_buffer;
if (gui_buffers)
last_gui_buffer->next_buffer = new_buffer;
@@ -222,30 +151,22 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int type,
last_gui_buffer = new_buffer;
new_buffer->next_buffer = NULL;
- /* move buffer next to server */
- if (server && cfg_look_open_near_server && (!cfg_look_one_server_buffer))
+ /* first buffer creation ? */
+ if (!gui_current_window->buffer)
{
- ptr_buffer = GUI_SERVER(new_buffer)->buffer;
- while (ptr_buffer && (ptr_buffer->server == server))
- {
- ptr_buffer = ptr_buffer->next_buffer;
- }
- if (ptr_buffer)
- gui_buffer_move_to_number (new_buffer, ptr_buffer->number);
+ gui_current_window->buffer = new_buffer;
+ gui_current_window->first_line_displayed = 1;
+ gui_current_window->start_line = NULL;
+ gui_current_window->start_line_pos = 0;
+ gui_window_calculate_pos_size (gui_current_window, 1);
+ gui_window_switch_to_buffer (gui_current_window, new_buffer);
+ gui_window_redraw_buffer (new_buffer);
}
- /* switch to new buffer */
- if (switch_to_buffer)
- gui_window_switch_to_buffer (window, new_buffer);
-
- /* redraw buffer */
- gui_window_redraw_buffer (new_buffer);
-
-#ifdef PLUGINS
snprintf (buffer_str, sizeof (buffer_str) - 1, "%d", new_buffer->number);
argv[0] = buffer_str;
- (void) plugin_event_handler_exec ("buffer_open", 1, argv);
-#endif
+ /* TODO: send buffer_open event */
+ /*(void) plugin_event_handler_exec ("buffer_open", 1, argv);*/
}
else
return NULL;
@@ -254,85 +175,137 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int type,
}
/*
- * gui_buffer_search: search a buffer by server and channel name
+ * buffer_valid: check if a buffer pointer exists
+ * return 1 if buffer exists
+ * 0 if buffer is not found
*/
-t_gui_buffer *
-gui_buffer_search (char *server, char *channel)
+int
+gui_buffer_valid (struct t_gui_buffer *buffer)
{
- t_irc_server *ptr_server, *ptr_srv;
- t_irc_channel *ptr_channel, *ptr_chan;
- t_gui_buffer *ptr_buffer;
+ struct t_gui_buffer *ptr_buffer;
- ptr_server = NULL;
- ptr_channel = NULL;
- ptr_buffer = NULL;
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if (ptr_buffer == buffer)
+ return 1;
+ }
- /* nothing given => print on current buffer */
- if ((!server || !server[0]) && (!channel || !channel[0]))
- ptr_buffer = gui_current_window->buffer;
- else
+ /* buffer not found */
+ return 0;
+}
+
+/*
+ * gui_buffer_set_category: set category for a buffer
+ */
+
+void
+gui_buffer_set_category (struct t_gui_buffer *buffer, char *category)
+{
+ if (buffer->category)
+ free (buffer->category);
+ buffer->category = (category) ? strdup (category) : NULL;
+}
+
+/*
+ * gui_buffer_set_name: set name for a buffer
+ */
+
+void
+gui_buffer_set_name (struct t_gui_buffer *buffer, char *name)
+{
+ if (buffer->name)
+ free (buffer->name);
+ buffer->name = (name) ? strdup (name) : NULL;
+}
+
+/*
+ * gui_buffer_set_log: set log file for a buffer
+ */
+
+void
+gui_buffer_set_log (struct t_gui_buffer *buffer, char *log_filename)
+{
+ if (buffer->log_file)
+ gui_log_end (buffer);
+
+ if (log_filename)
{
- if (server && server[0])
- {
- ptr_server = irc_server_search (server);
- if (!ptr_server)
- return NULL;
- }
-
- if (channel && channel[0])
- {
- if (ptr_server)
- {
- ptr_channel = irc_channel_search_any (ptr_server, channel);
- if (ptr_channel)
- ptr_buffer = ptr_channel->buffer;
- }
- else
- {
- for (ptr_srv = irc_servers; ptr_srv;
- ptr_srv = ptr_srv->next_server)
- {
- for (ptr_chan = ptr_srv->channels; ptr_chan;
- ptr_chan = ptr_chan->next_channel)
- {
- if (ascii_strcasecmp (ptr_chan->name, channel) == 0)
- {
- ptr_channel = ptr_chan;
- break;
- }
- }
- if (ptr_channel)
- break;
- }
- if (ptr_channel)
- ptr_buffer = ptr_channel->buffer;
- }
- }
- else
- {
- if (ptr_server)
- ptr_buffer = ptr_server->buffer;
- else
- ptr_buffer = gui_current_window->buffer;
- }
+ buffer->log_filename = strdup (log_filename);
+ gui_log_start (buffer);
}
+}
+
+/*
+ * gui_buffer_set_title: set title for a buffer
+ */
+
+void
+gui_buffer_set_title (struct t_gui_buffer *buffer, char *new_title)
+{
+ if (buffer->title)
+ free (buffer->title);
+ buffer->title = (new_title) ? strdup (new_title) : NULL;
+}
+
+/*
+ * gui_buffer_set_nick_case_sensitive: set nick_case_sensitive flag for a buffer
+ */
+
+void
+gui_buffer_set_nick_case_sensitive (struct t_gui_buffer *buffer,
+ int nick_case_sensitive)
+{
+ buffer->nick_case_sensitive = (nick_case_sensitive) ? 1 : 0;
+}
+
+/*
+ * gui_buffer_set_nick: set nick for a buffer
+ */
+
+void
+gui_buffer_set_nick (struct t_gui_buffer *buffer, char *new_nick)
+{
+ if (buffer->input_nick)
+ free (buffer->input_nick);
+ buffer->input_nick = (new_nick) ? strdup (new_nick) : NULL;
+}
+
+/*
+ * gui_buffer_search_by_category_name: search a buffer by category and/or name
+ */
+
+struct t_gui_buffer *
+gui_buffer_search_by_category_name (char *category, char *name)
+{
+ struct t_gui_buffer *ptr_buffer;
- if (!ptr_buffer)
- return NULL;
+ if (!category && !name)
+ return gui_current_window->buffer;
+
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ if ((category && ptr_buffer->category
+ && strcmp (ptr_buffer->category, category) == 0)
+ || (name && ptr_buffer->name
+ && strcmp (ptr_buffer->name, name) == 0))
+ return ptr_buffer;
+ }
- return (ptr_buffer->type != GUI_BUFFER_TYPE_STANDARD) ?
- gui_buffers : ptr_buffer;
+ /* buffer not found */
+ return NULL;
}
/*
* gui_buffer_search_by_number: search a buffer by number
*/
-t_gui_buffer *
+struct t_gui_buffer *
gui_buffer_search_by_number (int number)
{
- t_gui_buffer *ptr_buffer;
+ struct t_gui_buffer *ptr_buffer;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
@@ -349,10 +322,10 @@ gui_buffer_search_by_number (int number)
* gui_buffer_find_window: find a window displaying buffer
*/
-t_gui_window *
-gui_buffer_find_window (t_gui_buffer *buffer)
+struct t_gui_window *
+gui_buffer_find_window (struct t_gui_buffer *buffer)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
if (gui_current_window->buffer == buffer)
return gui_current_window;
@@ -369,63 +342,15 @@ gui_buffer_find_window (t_gui_buffer *buffer)
}
/*
- * gui_buffer_find_context: find window/buffer for a server/channel
- */
-
-void
-gui_buffer_find_context (void *server, void *channel,
- t_gui_window **window, t_gui_buffer **buffer)
-{
- t_gui_window *ptr_win;
-
- if (!buffer)
- return;
-
- /* first find buffer */
- *buffer = NULL;
- if ((t_irc_channel *)channel && ((t_irc_channel *)channel)->buffer)
- *buffer = ((t_irc_channel *)channel)->buffer;
- else
- {
- if ((t_irc_server *)server && ((t_irc_server *)server)->buffer)
- *buffer = ((t_irc_server *)server)->buffer;
- else
- *buffer = gui_current_window->buffer;
- }
-
- /* then find first window displaying this buffer */
- if (window)
- {
- *window = NULL;
- if (gui_current_window->buffer == *buffer)
- *window = gui_current_window;
- else
- {
- for (ptr_win = gui_windows; ptr_win;
- ptr_win = ptr_win->next_window)
- {
- if (ptr_win->buffer == *buffer)
- {
- *window = ptr_win;
- break;
- }
- }
- if (!*window)
- *window = gui_current_window;
- }
- }
-}
-
-/*
* gui_buffer_is_scrolled: return 1 if all windows displaying buffer are scrolled
* (user doesn't see end of buffer)
* return 0 if at least one window is NOT scrolled
*/
int
-gui_buffer_is_scrolled (t_gui_buffer *buffer)
+gui_buffer_is_scrolled (struct t_gui_buffer *buffer)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
int buffer_found;
if (!buffer)
@@ -455,13 +380,14 @@ gui_buffer_is_scrolled (t_gui_buffer *buffer)
* gui_buffer_get_dcc: get pointer to DCC buffer (DCC buffer created if not existing)
*/
-t_gui_buffer *
-gui_buffer_get_dcc (t_gui_window *window)
+struct t_gui_buffer *
+gui_buffer_get_dcc (struct t_gui_window *window)
{
- t_gui_buffer *ptr_buffer;
-
+ //struct t_gui_buffer *ptr_buffer;
+
+ (void) window;
/* check if dcc buffer exists */
- for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
+ /*for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->type == GUI_BUFFER_TYPE_DCC)
break;
@@ -469,7 +395,9 @@ gui_buffer_get_dcc (t_gui_window *window)
if (ptr_buffer)
return ptr_buffer;
else
- return gui_buffer_new (window, NULL, NULL, GUI_BUFFER_TYPE_DCC, 0);
+ return gui_buffer_new (window, weechat_protocols,
+ NULL, NULL, GUI_BUFFER_TYPE_DCC, 0);*/
+ return NULL;
}
/*
@@ -477,35 +405,37 @@ gui_buffer_get_dcc (t_gui_window *window)
*/
void
-gui_buffer_clear (t_gui_buffer *buffer)
+gui_buffer_clear (struct t_gui_buffer *buffer)
{
- t_gui_window *ptr_win;
- t_gui_line *ptr_line;
+ struct t_gui_window *ptr_win;
+ struct t_gui_line *ptr_line;
if (!buffer)
return;
- if (buffer->type == GUI_BUFFER_TYPE_DCC)
+ if (buffer->type == GUI_BUFFER_TYPE_FREE)
+ {
+ /* TODO: clear buffer with free content */
return;
+ }
/* remove buffer from hotlist */
- hotlist_remove_buffer (buffer);
+ gui_hotlist_remove_buffer (buffer);
/* remove lines from buffer */
while (buffer->lines)
{
ptr_line = buffer->lines->next_line;
- if (buffer->lines->data)
- free (buffer->lines->data);
+ if (buffer->lines->message)
+ free (buffer->lines->message);
free (buffer->lines);
buffer->lines = ptr_line;
}
buffer->lines = NULL;
buffer->last_line = NULL;
- buffer->num_lines = 0;
- buffer->line_complete = 1;
-
+ buffer->lines_count = 0;
+
/* remove any scroll for buffer */
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
@@ -528,76 +458,44 @@ gui_buffer_clear (t_gui_buffer *buffer)
void
gui_buffer_clear_all ()
{
- t_gui_buffer *ptr_buffer;
+ struct t_gui_buffer *ptr_buffer;
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
gui_buffer_clear (ptr_buffer);
}
/*
- * gui_buffer_line_free: delete a line from a buffer
- */
-
-void
-gui_buffer_line_free (t_gui_line *line)
-{
- t_gui_window *ptr_win;
-
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
- {
- if (ptr_win->start_line == line)
- {
- ptr_win->start_line = ptr_win->start_line->next_line;
- ptr_win->start_line_pos = 0;
- gui_chat_draw (ptr_win->buffer, 0);
- gui_status_draw (ptr_win->buffer, 0);
- }
- }
- if (line->nick)
- free (line->nick);
- if (line->data)
- free (line->data);
- free (line);
-}
-
-/*
* gui_buffer_free: delete a buffer
*/
void
-gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
+gui_buffer_free (struct t_gui_buffer *buffer, int switch_to_another)
{
- t_gui_window *ptr_win;
- t_gui_buffer *ptr_buffer;
- t_gui_line *ptr_line;
- t_irc_server *ptr_server;
- int create_new;
-#ifdef PLUGINS
+ struct t_gui_window *ptr_window;
+ struct t_gui_buffer *ptr_buffer;
+ struct t_gui_line *ptr_line;
char buffer_str[16], *argv[1] = { NULL };
-#endif
-#ifdef PLUGINS
snprintf (buffer_str, sizeof (buffer_str) - 1, "%d", buffer->number);
argv[0] = buffer_str;
- (void) plugin_event_handler_exec ("buffer_close", 1, argv);
-#endif
-
- create_new = (buffer->server || buffer->channel);
+ /* TODO: send buffer_close event */
+ /*(void) plugin_event_handler_exec ("buffer_close", 1, argv);*/
if (switch_to_another)
{
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ for (ptr_window = gui_windows; ptr_window;
+ ptr_window = ptr_window->next_window)
{
- if ((buffer == ptr_win->buffer) &&
+ if ((buffer == ptr_window->buffer) &&
((buffer->next_buffer) || (buffer->prev_buffer)))
- gui_buffer_switch_previous (ptr_win);
+ gui_buffer_switch_previous (ptr_window);
}
}
- hotlist_remove_buffer (buffer);
- if (hotlist_initial_buffer == buffer)
- hotlist_initial_buffer = NULL;
-
+ gui_hotlist_remove_buffer (buffer);
+ if (gui_hotlist_initial_buffer == buffer)
+ gui_hotlist_initial_buffer = NULL;
+
if (gui_previous_buffer == buffer)
gui_previous_buffer = NULL;
@@ -607,43 +505,41 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
if (gui_buffer_before_raw_data == buffer)
gui_buffer_before_raw_data = NULL;
- if (buffer->type == GUI_BUFFER_TYPE_RAW_DATA)
- gui_buffer_raw_data = NULL;
-
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
+ if (buffer->type == GUI_BUFFER_TYPE_FREE)
{
- if (ptr_server->saved_buffer == buffer)
- ptr_server->saved_buffer = NULL;
+ // TODO: review this
+ gui_buffer_raw_data = NULL;
}
- /* decrease buffer number for all next buffers */
- for (ptr_buffer = buffer->next_buffer; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
+ if (buffer->type == GUI_BUFFER_TYPE_FORMATED)
{
- ptr_buffer->number--;
- }
-
- /* free lines and messages */
- while (buffer->lines)
- {
- ptr_line = buffer->lines->next_line;
- gui_buffer_line_free (buffer->lines);
- buffer->lines = ptr_line;
+ /* decrease buffer number for all next buffers */
+ for (ptr_buffer = buffer->next_buffer; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ ptr_buffer->number--;
+ }
+
+ /* free lines and messages */
+ while (buffer->lines)
+ {
+ ptr_line = buffer->lines->next_line;
+ gui_chat_line_free (buffer->lines);
+ buffer->lines = ptr_line;
+ }
+
+ /* close log if opened */
+ if (buffer->log_file)
+ gui_log_end (buffer);
}
-
- /* close log if opened */
- if (buffer->log_file)
- gui_log_end (buffer);
-
+
if (buffer->input_buffer)
free (buffer->input_buffer);
if (buffer->input_buffer_color_mask)
free (buffer->input_buffer_color_mask);
-
- completion_free (&(buffer->completion));
-
- history_buffer_free (buffer);
-
+ if (buffer->completion)
+ gui_completion_free (buffer->completion);
+ gui_history_buffer_free (buffer);
if (buffer->text_search_input)
free (buffer->text_search_input);
@@ -657,208 +553,25 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
if (last_gui_buffer == buffer)
last_gui_buffer = buffer->prev_buffer;
- for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ for (ptr_window = gui_windows; ptr_window;
+ ptr_window = ptr_window->next_window)
{
- if (ptr_win->buffer == buffer)
- ptr_win->buffer = NULL;
+ if (ptr_window->buffer == buffer)
+ ptr_window->buffer = NULL;
}
free (buffer);
- /* always at least one buffer */
- if (!gui_buffers && create_new && switch_to_another)
- (void) gui_buffer_new (gui_windows, NULL, NULL,
- GUI_BUFFER_TYPE_STANDARD, 1);
-
if (gui_windows && gui_current_window && gui_current_window->buffer)
gui_status_draw (gui_current_window->buffer, 1);
}
/*
- * gui_buffer_line_new: create new line for a buffer
- */
-
-t_gui_line *
-gui_buffer_line_new (t_gui_buffer *buffer, time_t date)
-{
- t_gui_line *new_line, *ptr_line;
-
- if ((new_line = (t_gui_line *) malloc (sizeof (struct t_gui_line))))
- {
- new_line->length = 0;
- new_line->length_align = 0;
- new_line->log_write = 1;
- new_line->line_with_message = 0;
- new_line->line_with_highlight = 0;
- new_line->date = date;
- new_line->nick = NULL;
- new_line->data = NULL;
- new_line->ofs_after_date = -1;
- new_line->ofs_start_message = -1;
- if (!buffer->lines)
- buffer->lines = new_line;
- else
- buffer->last_line->next_line = new_line;
- new_line->prev_line = buffer->last_line;
- new_line->next_line = NULL;
- buffer->last_line = new_line;
- buffer->num_lines++;
- }
- else
- {
- weechat_log_printf (_("Not enough memory for new line\n"));
- return NULL;
- }
-
- /* remove one line if necessary */
- if ((cfg_history_max_lines > 0)
- && (buffer->num_lines > cfg_history_max_lines))
- {
- if (buffer->last_line == buffer->lines)
- buffer->last_line = NULL;
- ptr_line = buffer->lines->next_line;
- gui_buffer_line_free (buffer->lines);
- buffer->lines = ptr_line;
- ptr_line->prev_line = NULL;
- buffer->num_lines--;
- }
-
- return new_line;
-}
-
-/*
- * gui_buffer_line_search: search for text in a line
- */
-
-int
-gui_buffer_line_search (t_gui_line *line, char *text, int case_sensitive)
-{
- char *data;
- int rc;
-
- if (!line || !line->data || !text || !text[0])
- return 0;
-
- rc = 0;
- data = (char *)gui_color_decode ((unsigned char *)line->data, 0, 0);
- if (data)
- {
- if ((case_sensitive && (strstr (data, text)))
- || (!case_sensitive && (ascii_strcasestr (data, text))))
- rc = 1;
- free (data);
- }
- return rc;
-}
-
-/*
- * gui_buffer_merge_servers: merge server buffers in one buffer
- */
-
-void
-gui_buffer_merge_servers (t_gui_window *window)
-{
- t_gui_buffer *ptr_buffer_server, *ptr_buffer, *new_ptr_buffer;
- t_irc_server *ptr_server;
-
- /* new server buffer is the first server buffer found */
- for (ptr_buffer_server = gui_buffers; ptr_buffer_server;
- ptr_buffer_server = ptr_buffer_server->next_buffer)
- {
- if (GUI_BUFFER_IS_SERVER(ptr_buffer_server))
- break;
- }
-
- /* no server buffer found */
- if (!ptr_buffer_server)
- return;
-
- ptr_buffer = gui_buffers;
- while (ptr_buffer)
- {
- if ((ptr_buffer != ptr_buffer_server)
- && (GUI_BUFFER_IS_SERVER(ptr_buffer)))
- {
- ptr_server = GUI_SERVER(ptr_buffer);
-
- /* add (by pointer artefact) lines from buffer found to server buffer */
- if (ptr_buffer->lines)
- {
- if (ptr_buffer_server->lines)
- {
- ptr_buffer->lines->prev_line =
- ptr_buffer_server->last_line;
- ptr_buffer_server->last_line->next_line =
- ptr_buffer->lines;
- ptr_buffer_server->last_line =
- ptr_buffer->last_line;
- }
- else
- {
- ptr_buffer_server->lines = ptr_buffer->lines;
- ptr_buffer_server->last_line = ptr_buffer->last_line;
- }
- }
-
- /* free buffer but not lines, because they're now used by
- our unique server buffer */
- new_ptr_buffer = ptr_buffer->next_buffer;
- ptr_buffer->lines = NULL;
- gui_buffer_free (ptr_buffer, 1);
- ptr_buffer = new_ptr_buffer;
-
- /* asociate server with new server buffer */
- ptr_server->buffer = ptr_buffer_server;
- }
- else
- ptr_buffer = ptr_buffer->next_buffer;
- }
-
- ptr_buffer_server->all_servers = 1;
- gui_window_redraw_buffer (window->buffer);
-}
-
-/*
- * gui_buffer_split_server: split the server buffer into many buffers (one by server)
- */
-
-void
-gui_buffer_split_server (t_gui_window *window)
-{
- t_gui_buffer *ptr_buffer;
- t_irc_server *ptr_server;
-
- ptr_buffer = gui_buffer_servers_search ();
-
- if (ptr_buffer)
- {
- if (GUI_SERVER(ptr_buffer))
- {
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- if (ptr_server->buffer
- && (ptr_server != GUI_SERVER(ptr_buffer))
- && (ptr_server->buffer == ptr_buffer))
- {
- ptr_server->buffer = NULL;
- gui_buffer_new (window, ptr_server, NULL,
- GUI_BUFFER_TYPE_STANDARD, 0);
- }
- }
- }
- ptr_buffer->all_servers = 0;
- gui_status_draw (window->buffer, 1);
- gui_input_draw (window->buffer, 1);
- }
-}
-
-/*
* gui_buffer_switch_previous: switch to previous buffer
*/
void
-gui_buffer_switch_previous (t_gui_window *window)
+gui_buffer_switch_previous (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -880,7 +593,7 @@ gui_buffer_switch_previous (t_gui_window *window)
*/
void
-gui_buffer_switch_next (t_gui_window *window)
+gui_buffer_switch_next (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -902,12 +615,13 @@ gui_buffer_switch_next (t_gui_window *window)
*/
void
-gui_buffer_switch_dcc (t_gui_window *window)
+gui_buffer_switch_dcc (struct t_gui_window *window)
{
- t_gui_buffer *ptr_buffer;
-
+ //struct t_gui_buffer *ptr_buffer;
+
+ (void) window;
/* check if dcc buffer exists */
- for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
+ /*for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->type == GUI_BUFFER_TYPE_DCC)
break;
@@ -918,7 +632,8 @@ gui_buffer_switch_dcc (t_gui_window *window)
gui_window_redraw_buffer (ptr_buffer);
}
else
- gui_buffer_new (window, NULL, NULL, GUI_BUFFER_TYPE_DCC, 1);
+ gui_buffer_new (window, weechat_protocols,
+ NULL, NULL, GUI_BUFFER_TYPE_DCC, 1);*/
}
/*
@@ -926,12 +641,13 @@ gui_buffer_switch_dcc (t_gui_window *window)
*/
void
-gui_buffer_switch_raw_data (t_gui_window *window)
+gui_buffer_switch_raw_data (struct t_gui_window *window)
{
- t_gui_buffer *ptr_buffer;
-
+ //struct t_gui_buffer *ptr_buffer;
+
+ (void) window;
/* check if raw IRC data buffer exists */
- for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
+ /*for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->type == GUI_BUFFER_TYPE_RAW_DATA)
break;
@@ -942,17 +658,18 @@ gui_buffer_switch_raw_data (t_gui_window *window)
gui_window_redraw_buffer (ptr_buffer);
}
else
- gui_buffer_new (window, NULL, NULL, GUI_BUFFER_TYPE_RAW_DATA, 1);
+ gui_buffer_new (window, weechat_protocols,
+ NULL, NULL, GUI_BUFFER_TYPE_RAW_DATA, 1);*/
}
/*
* gui_buffer_switch_by_number: switch to another buffer with number
*/
-t_gui_buffer *
-gui_buffer_switch_by_number (t_gui_window *window, int number)
+struct t_gui_buffer *
+gui_buffer_switch_by_number (struct t_gui_window *window, int number)
{
- t_gui_buffer *ptr_buffer;
+ struct t_gui_buffer *ptr_buffer;
/* invalid buffer */
if (number < 0)
@@ -982,13 +699,11 @@ gui_buffer_switch_by_number (t_gui_window *window, int number)
*/
void
-gui_buffer_move_to_number (t_gui_buffer *buffer, int number)
+gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number)
{
- t_gui_buffer *ptr_buffer;
+ struct t_gui_buffer *ptr_buffer;
int i;
-#ifdef PLUGINS
char buf1_str[16], buf2_str[16], *argv[2] = { NULL, NULL };
-#endif
/* if only one buffer then return */
if (gui_buffers == last_gui_buffer)
@@ -1000,10 +715,8 @@ gui_buffer_move_to_number (t_gui_buffer *buffer, int number)
if (number < 1)
number = 1;
-
-#ifdef PLUGINS
+
snprintf (buf2_str, sizeof (buf2_str) - 1, "%d", buffer->number);
-#endif
/* remove buffer from list */
if (buffer == gui_buffers)
@@ -1072,341 +785,11 @@ gui_buffer_move_to_number (t_gui_buffer *buffer, int number)
gui_window_redraw_buffer (buffer);
-#ifdef PLUGINS
snprintf (buf1_str, sizeof (buf1_str) - 1, "%d", buffer->number);
argv[0] = buf1_str;
argv[1] = buf2_str;
- (void) plugin_event_handler_exec ("buffer_move", 2, argv);
-#endif
-}
-
-/*
- * gui_buffer_search_text: search text in a buffer
- */
-
-int
-gui_buffer_search_text (t_gui_window *window)
-{
- t_gui_line *ptr_line;
-
- if (window->buffer->text_search == GUI_TEXT_SEARCH_BACKWARD)
- {
- if (window->buffer->lines
- && window->buffer->input_buffer && window->buffer->input_buffer[0])
- {
- ptr_line = (window->start_line) ?
- window->start_line->prev_line : window->buffer->last_line;
- while (ptr_line)
- {
- if (gui_buffer_line_search (ptr_line, window->buffer->input_buffer,
- window->buffer->text_search_exact))
- {
- window->start_line = ptr_line;
- window->start_line_pos = 0;
- window->first_line_displayed =
- (window->start_line == window->buffer->lines);
- gui_chat_draw (window->buffer, 1);
- gui_status_draw (window->buffer, 1);
- return 1;
- }
- ptr_line = ptr_line->prev_line;
- }
- }
- }
- else if (window->buffer->text_search == GUI_TEXT_SEARCH_FORWARD)
- {
- if (window->buffer->lines
- && window->buffer->input_buffer && window->buffer->input_buffer[0])
- {
- ptr_line = (window->start_line) ?
- window->start_line->next_line : window->buffer->lines->next_line;
- while (ptr_line)
- {
- if (gui_buffer_line_search (ptr_line, window->buffer->input_buffer,
- window->buffer->text_search_exact))
- {
- window->start_line = ptr_line;
- window->start_line_pos = 0;
- window->first_line_displayed =
- (window->start_line == window->buffer->lines);
- gui_chat_draw (window->buffer, 1);
- gui_status_draw (window->buffer, 1);
- return 1;
- }
- ptr_line = ptr_line->next_line;
- }
- }
- }
- return 0;
-}
-
-/*
- * gui_buffer_search_start: start search in a buffer
- */
-
-void
-gui_buffer_search_start (t_gui_window *window)
-{
- window->buffer->text_search = GUI_TEXT_SEARCH_BACKWARD;
- window->buffer->text_search_exact = 0;
- window->buffer->text_search_found = 0;
- if (window->buffer->text_search_input)
- {
- free (window->buffer->text_search_input);
- window->buffer->text_search_input = NULL;
- }
- if (window->buffer->input_buffer && window->buffer->input_buffer[0])
- window->buffer->text_search_input =
- strdup (window->buffer->input_buffer);
- gui_action_delete_line (window, NULL);
- gui_status_draw (window->buffer, 1);
- gui_input_draw (window->buffer, 1);
-}
-
-/*
- * gui_buffer_search_restart: restart search (after input changes or exact
- * flag (un)set)
- */
-
-void
-gui_buffer_search_restart (t_gui_window *window)
-{
- window->start_line = NULL;
- window->start_line_pos = 0;
- window->buffer->text_search = GUI_TEXT_SEARCH_BACKWARD;
- window->buffer->text_search_found = 0;
- if (gui_buffer_search_text (window))
- window->buffer->text_search_found = 1;
- else
- {
- gui_chat_draw (window->buffer, 1);
- gui_status_draw (window->buffer, 1);
- }
-}
-
-/*
- * gui_buffer_search_stop: stop search in a buffer
- */
-
-void
-gui_buffer_search_stop (t_gui_window *window)
-{
- window->buffer->text_search = GUI_TEXT_SEARCH_DISABLED;
- window->buffer->text_search = 0;
- gui_action_delete_line (window, NULL);
- if (window->buffer->text_search_input)
- {
- gui_insert_string_input (window, window->buffer->text_search_input, -1);
- free (window->buffer->text_search_input);
- window->buffer->text_search_input = NULL;
- }
- window->start_line = NULL;
- window->start_line_pos = 0;
- hotlist_remove_buffer (window->buffer);
- gui_chat_draw (window->buffer, 0);
- gui_status_draw (window->buffer, 1);
- gui_input_draw (window->buffer, 1);
-}
-
-/*
- * gui_buffer_scroll: scroll buffer by # messages or time
- */
-
-void
-gui_buffer_scroll (t_gui_window *window, char *scroll)
-{
- int direction, stop, count_msg;
- char time_letter, saved_char;
- time_t old_date, diff_date;
- char *error;
- long number;
- t_gui_line *ptr_line;
- struct tm *date_tmp, line_date, old_line_date;
-
- if (window->buffer->lines)
- {
- direction = -1;
- number = 0;
- time_letter = ' ';
-
- // search direction
- if (scroll[0] == '-')
- {
- direction = -1;
- scroll++;
- }
- else if (scroll[0] == '+')
- {
- direction = +1;
- scroll++;
- }
-
- // search number and letter
- char *pos = scroll;
- while (pos && pos[0] && isdigit (pos[0]))
- {
- pos++;
- }
- if (pos)
- {
- if (pos == scroll)
- {
- if (pos[0])
- time_letter = scroll[0];
- }
- else
- {
- if (pos[0])
- time_letter = pos[0];
- saved_char = pos[0];
- pos[0] = '\0';
- error = NULL;
- number = strtol (scroll, &error, 10);
- if (!error || (error[0] != '\0'))
- number = 0;
- pos[0] = saved_char;
- }
- }
-
- /* at least number or letter has to he given */
- if ((number == 0) && (time_letter == ' '))
- return;
-
- // do the scroll!
- stop = 0;
- count_msg = 0;
- if (direction < 0)
- ptr_line = (window->start_line) ?
- window->start_line : window->buffer->last_line;
- else
- ptr_line = (window->start_line) ?
- window->start_line : window->buffer->lines;
-
- old_date = ptr_line->date;
- date_tmp = localtime (&old_date);
- memcpy (&old_line_date, date_tmp, sizeof (struct tm));
-
- while (ptr_line)
- {
- ptr_line = (direction < 0) ? ptr_line->prev_line : ptr_line->next_line;
-
- if (ptr_line)
- {
- if (time_letter == ' ')
- {
- count_msg++;
- if (count_msg >= number)
- stop = 1;
- }
- else
- {
- date_tmp = localtime (&(ptr_line->date));
- memcpy (&line_date, date_tmp, sizeof (struct tm));
- if (old_date > ptr_line->date)
- diff_date = old_date - ptr_line->date;
- else
- diff_date = ptr_line->date - old_date;
- switch (time_letter)
- {
- case 's': /* seconds */
- if (number == 0)
- {
- /* stop if line has different second */
- if ((line_date.tm_sec != old_line_date.tm_sec)
- || (line_date.tm_min != old_line_date.tm_min)
- || (line_date.tm_hour != old_line_date.tm_hour)
- || (line_date.tm_mday != old_line_date.tm_mday)
- || (line_date.tm_mon != old_line_date.tm_mon)
- || (line_date.tm_year != old_line_date.tm_year))
- if (line_date.tm_sec != old_line_date.tm_sec)
- stop = 1;
- }
- else if (diff_date >= number)
- stop = 1;
- break;
- case 'm': /* minutes */
- if (number == 0)
- {
- /* stop if line has different minute */
- if ((line_date.tm_min != old_line_date.tm_min)
- || (line_date.tm_hour != old_line_date.tm_hour)
- || (line_date.tm_mday != old_line_date.tm_mday)
- || (line_date.tm_mon != old_line_date.tm_mon)
- || (line_date.tm_year != old_line_date.tm_year))
- stop = 1;
- }
- else if (diff_date >= number * 60)
- stop = 1;
- break;
- case 'h': /* hours */
- if (number == 0)
- {
- /* stop if line has different hour */
- if ((line_date.tm_hour != old_line_date.tm_hour)
- || (line_date.tm_mday != old_line_date.tm_mday)
- || (line_date.tm_mon != old_line_date.tm_mon)
- || (line_date.tm_year != old_line_date.tm_year))
- stop = 1;
- }
- else if (diff_date >= number * 60 * 60)
- stop = 1;
- break;
- case 'd': /* days */
- if (number == 0)
- {
- /* stop if line has different day */
- if ((line_date.tm_mday != old_line_date.tm_mday)
- || (line_date.tm_mon != old_line_date.tm_mon)
- || (line_date.tm_year != old_line_date.tm_year))
- stop = 1;
- }
- else if (diff_date >= number * 60 * 60 * 24)
- stop = 1;
- break;
- case 'M': /* months */
- if (number == 0)
- {
- /* stop if line has different month */
- if ((line_date.tm_mon != old_line_date.tm_mon)
- || (line_date.tm_year != old_line_date.tm_year))
- stop = 1;
- }
- /* we consider month is 30 days, who will find I'm too
- lazy to code exact date diff ? ;) */
- else if (diff_date >= number * 60 * 60 * 24 * 30)
- stop = 1;
- break;
- case 'y': /* years */
- if (number == 0)
- {
- /* stop if line has different year */
- if (line_date.tm_year != old_line_date.tm_year)
- stop = 1;
- }
- /* we consider year is 365 days, who will find I'm too
- lazy to code exact date diff ? ;) */
- else if (diff_date >= number * 60 * 60 * 24 * 365)
- stop = 1;
- break;
- }
- }
- if (stop)
- {
- window->start_line = ptr_line;
- window->start_line_pos = 0;
- window->first_line_displayed =
- (window->start_line == window->buffer->lines);
- gui_chat_draw (window->buffer, 1);
- gui_status_draw (window->buffer, 0);
- return;
- }
- }
- }
- if (direction < 0)
- gui_window_scroll_top (window);
- else
- gui_window_scroll_bottom (window);
- }
+ /* TODO: send buffer_move event */
+ /*(void) plugin_event_handler_exec ("buffer_move", 2, argv);*/
}
/*
@@ -1414,11 +797,11 @@ gui_buffer_scroll (t_gui_window *window, char *scroll)
*/
void
-gui_buffer_dump_hexa (t_gui_buffer *buffer)
+gui_buffer_dump_hexa (struct t_gui_buffer *buffer)
{
- t_gui_line *ptr_line;
- int num_line, data_pos;
- char *data_without_colors;
+ struct t_gui_line *ptr_line;
+ int num_line, msg_pos;
+ char *message_without_colors;
char hexa[(16 * 3) + 1], ascii[(16 * 2) + 1];
int hexa_pos, ascii_pos;
@@ -1427,33 +810,34 @@ gui_buffer_dump_hexa (t_gui_buffer *buffer)
for (ptr_line = buffer->lines; ptr_line; ptr_line = ptr_line->next_line)
{
/* display line without colors */
- data_without_colors = (ptr_line->data) ?
- (char *)gui_color_decode ((unsigned char *)ptr_line->data, 0, 0) : NULL;
+ message_without_colors = (ptr_line->message) ?
+ (char *)gui_color_decode ((unsigned char *)ptr_line->message) : NULL;
weechat_log_printf ("\n");
weechat_log_printf (" line %d: %s\n",
num_line,
- (data_without_colors) ? data_without_colors : "(null)");
- if (data_without_colors)
- free (data_without_colors);
+ (message_without_colors) ?
+ message_without_colors : "(null)");
+ if (message_without_colors)
+ free (message_without_colors);
- /* display raw data for line */
- if (ptr_line->data)
+ /* display raw message for line */
+ if (ptr_line->message)
{
weechat_log_printf ("\n");
weechat_log_printf (" raw data for line %d (with color codes):\n",
num_line);
- data_pos = 0;
+ msg_pos = 0;
hexa_pos = 0;
ascii_pos = 0;
- while (ptr_line->data[data_pos])
+ while (ptr_line->message[msg_pos])
{
snprintf (hexa + hexa_pos, 4, "%02X ",
- (unsigned char)(ptr_line->data[data_pos]));
+ (unsigned char)(ptr_line->message[msg_pos]));
hexa_pos += 3;
snprintf (ascii + ascii_pos, 3, "%c ",
- ((((unsigned char)ptr_line->data[data_pos]) < 32)
- || (((unsigned char)ptr_line->data[data_pos]) > 127)) ?
- '.' : (unsigned char)(ptr_line->data[data_pos]));
+ ((((unsigned char)ptr_line->message[msg_pos]) < 32)
+ || (((unsigned char)ptr_line->message[msg_pos]) > 127)) ?
+ '.' : (unsigned char)(ptr_line->message[msg_pos]));
ascii_pos += 2;
if (ascii_pos == 32)
{
@@ -1461,7 +845,7 @@ gui_buffer_dump_hexa (t_gui_buffer *buffer)
hexa_pos = 0;
ascii_pos = 0;
}
- data_pos++;
+ msg_pos++;
}
if (ascii_pos > 0)
weechat_log_printf (" %-48s %s\n", hexa, ascii);
@@ -1476,69 +860,103 @@ gui_buffer_dump_hexa (t_gui_buffer *buffer)
*/
void
-gui_buffer_print_log (t_gui_buffer *buffer)
+gui_buffer_print_log ()
{
- t_gui_line *ptr_line;
+ struct t_gui_buffer *ptr_buffer;
+ struct t_gui_nick *ptr_nick;
+ struct t_gui_line *ptr_line;
int num;
- weechat_log_printf ("[buffer (addr:0x%X)]\n", buffer);
- weechat_log_printf (" num_displayed. . . . . : %d\n", buffer->num_displayed);
- weechat_log_printf (" number . . . . . . . . : %d\n", buffer->number);
- weechat_log_printf (" server . . . . . . . . : 0x%X\n", buffer->server);
- weechat_log_printf (" all_servers. . . . . . : %d\n", buffer->all_servers);
- weechat_log_printf (" channel. . . . . . . . : 0x%X\n", buffer->channel);
- weechat_log_printf (" type . . . . . . . . . : %d\n", buffer->type);
- weechat_log_printf (" lines. . . . . . . . . : 0x%X\n", buffer->lines);
- weechat_log_printf (" last_line. . . . . . . : 0x%X\n", buffer->last_line);
- weechat_log_printf (" last_read_line . . . . : 0x%X\n", buffer->last_read_line);
- weechat_log_printf (" num_lines. . . . . . . : %d\n", buffer->num_lines);
- weechat_log_printf (" line_complete. . . . . : %d\n", buffer->line_complete);
- weechat_log_printf (" notify_level . . . . . : %d\n", buffer->notify_level);
- weechat_log_printf (" log_filename . . . . . : '%s'\n", buffer->log_filename);
- weechat_log_printf (" log_file . . . . . . . : 0x%X\n", buffer->log_file);
- weechat_log_printf (" has_input. . . . . . . : %d\n", buffer->has_input);
- weechat_log_printf (" input_buffer . . . . . : '%s'\n", buffer->input_buffer);
- weechat_log_printf (" input_buffer_color_mask: '%s'\n", buffer->input_buffer_color_mask);
- weechat_log_printf (" input_buffer_alloc . . : %d\n", buffer->input_buffer_alloc);
- weechat_log_printf (" input_buffer_size. . . : %d\n", buffer->input_buffer_size);
- weechat_log_printf (" input_buffer_length. . : %d\n", buffer->input_buffer_length);
- weechat_log_printf (" input_buffer_pos . . . : %d\n", buffer->input_buffer_pos);
- weechat_log_printf (" input_buffer_1st_disp. : %d\n", buffer->input_buffer_1st_display);
- weechat_log_printf (" completion . . . . . . : 0x%X\n", &(buffer->completion));
- weechat_log_printf (" history. . . . . . . . : 0x%X\n", buffer->history);
- weechat_log_printf (" last_history . . . . . : 0x%X\n", buffer->last_history);
- weechat_log_printf (" ptr_history. . . . . . : 0x%X\n", buffer->ptr_history);
- weechat_log_printf (" num_history. . . . . . : %d\n", buffer->num_history);
- weechat_log_printf (" text_search. . . . . . : %d\n", buffer->text_search);
- weechat_log_printf (" text_search_exact. . . : %d\n", buffer->text_search_exact);
- weechat_log_printf (" text_search_input. . . : '%s'\n", buffer->text_search_input);
- weechat_log_printf (" prev_buffer. . . . . . : 0x%X\n", buffer->prev_buffer);
- weechat_log_printf (" next_buffer. . . . . . : 0x%X\n", buffer->next_buffer);
- weechat_log_printf ("\n");
- weechat_log_printf (" => last 100 lines:\n");
-
- num = 0;
- ptr_line = buffer->last_line;
- while (ptr_line && (num < 100))
- {
- num++;
- ptr_line = ptr_line->prev_line;
- }
- if (!ptr_line)
- ptr_line = buffer->lines;
- else
- ptr_line = ptr_line->next_line;
-
- while (ptr_line)
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
{
- num--;
- weechat_log_printf (" line N-%05d: %s\n",
- num,
- (ptr_line->data) ? ptr_line->data : "(empty)");
+ weechat_log_printf ("\n");
+ weechat_log_printf ("[buffer (addr:0x%X)]\n", ptr_buffer);
+ weechat_log_printf (" plugin . . . . . . . . : 0x%X\n", ptr_buffer->plugin);
+ weechat_log_printf (" number . . . . . . . . : %d\n", ptr_buffer->number);
+ weechat_log_printf (" category . . . . . . . : '%s'\n", ptr_buffer->category);
+ weechat_log_printf (" name . . . . . . . . . : '%s'\n", ptr_buffer->name);
+ weechat_log_printf (" type . . . . . . . . . : %d\n", ptr_buffer->type);
+ weechat_log_printf (" notify_level . . . . . : %d\n", ptr_buffer->notify_level);
+ weechat_log_printf (" num_displayed. . . . . : %d\n", ptr_buffer->num_displayed);
+ weechat_log_printf (" log_filename . . . . . : '%s'\n", ptr_buffer->log_filename);
+ weechat_log_printf (" log_file . . . . . . . : 0x%X\n", ptr_buffer->log_file);
+ weechat_log_printf (" title. . . . . . . . . : '%s'\n", ptr_buffer->title);
+ weechat_log_printf (" lines. . . . . . . . . : 0x%X\n", ptr_buffer->lines);
+ weechat_log_printf (" last_line. . . . . . . : 0x%X\n", ptr_buffer->last_line);
+ weechat_log_printf (" last_read_line . . . . : 0x%X\n", ptr_buffer->last_read_line);
+ weechat_log_printf (" lines_count. . . . . . : %d\n", ptr_buffer->lines_count);
+ weechat_log_printf (" prefix_max_length. . . : %d\n", ptr_buffer->prefix_max_length);
+ weechat_log_printf (" chat_refresh_needed. . : %d\n", ptr_buffer->chat_refresh_needed);
+ weechat_log_printf (" nicklist . . . . . . . : %d\n", ptr_buffer->nicklist);
+ weechat_log_printf (" nick_case_sensitive. . : %d\n", ptr_buffer->nick_case_sensitive);
+ weechat_log_printf (" nicks. . . . . . . . . : 0x%X\n", ptr_buffer->nicks);
+ weechat_log_printf (" last_nick. . . . . . . : 0x%X\n", ptr_buffer->last_nick);
+ weechat_log_printf (" nicks_count. . . . . . : %d\n", ptr_buffer->nicks_count);
+ weechat_log_printf (" input. . . . . . . . . : %d\n", ptr_buffer->input);
+ weechat_log_printf (" input_data_cb. . . . . : 0x%X\n", ptr_buffer->input_data_cb);
+ weechat_log_printf (" input_nick . . . . . . : '%s'\n", ptr_buffer->input_nick);
+ weechat_log_printf (" input_buffer . . . . . : '%s'\n", ptr_buffer->input_buffer);
+ weechat_log_printf (" input_buffer_color_mask: '%s'\n", ptr_buffer->input_buffer_color_mask);
+ weechat_log_printf (" input_buffer_alloc . . : %d\n", ptr_buffer->input_buffer_alloc);
+ weechat_log_printf (" input_buffer_size. . . : %d\n", ptr_buffer->input_buffer_size);
+ weechat_log_printf (" input_buffer_length. . : %d\n", ptr_buffer->input_buffer_length);
+ weechat_log_printf (" input_buffer_pos . . . : %d\n", ptr_buffer->input_buffer_pos);
+ weechat_log_printf (" input_buffer_1st_disp. : %d\n", ptr_buffer->input_buffer_1st_display);
+ weechat_log_printf (" completion . . . . . . : 0x%X\n", ptr_buffer->completion);
+ weechat_log_printf (" history. . . . . . . . : 0x%X\n", ptr_buffer->history);
+ weechat_log_printf (" last_history . . . . . : 0x%X\n", ptr_buffer->last_history);
+ weechat_log_printf (" ptr_history. . . . . . : 0x%X\n", ptr_buffer->ptr_history);
+ weechat_log_printf (" num_history. . . . . . : %d\n", ptr_buffer->num_history);
+ weechat_log_printf (" text_search. . . . . . : %d\n", ptr_buffer->text_search);
+ weechat_log_printf (" text_search_exact. . . : %d\n", ptr_buffer->text_search_exact);
+ weechat_log_printf (" text_search_found. . . : %d\n", ptr_buffer->text_search_found);
+ weechat_log_printf (" text_search_input. . . : '%s'\n", ptr_buffer->text_search_input);
+ weechat_log_printf (" prev_buffer. . . . . . : 0x%X\n", ptr_buffer->prev_buffer);
+ weechat_log_printf (" next_buffer. . . . . . : 0x%X\n", ptr_buffer->next_buffer);
+
+ for (ptr_nick = ptr_buffer->nicks; ptr_nick;
+ ptr_nick = ptr_nick->next_nick)
+ {
+ weechat_log_printf ("\n");
+ weechat_log_printf (" => nick %s (addr:0x%X):\n", ptr_nick->nick, ptr_nick);
+ weechat_log_printf (" sort_index. . . . . . : %d\n", ptr_nick->sort_index);
+ weechat_log_printf (" color_nick. . . . . . : %d\n", ptr_nick->color_nick);
+ weechat_log_printf (" prefix. . . . . . . . : '%c'\n", ptr_nick->prefix);
+ weechat_log_printf (" color_prefix. . . . . : %d\n", ptr_nick->color_prefix);
+ weechat_log_printf (" prev_nick . . . . . . : 0x%X\n", ptr_nick->prev_nick);
+ weechat_log_printf (" next_nick . . . . . . : 0x%X\n", ptr_nick->next_nick);
+ }
+
+ weechat_log_printf ("\n");
+ weechat_log_printf (" => last 100 lines:\n");
+ num = 0;
+ ptr_line = ptr_buffer->last_line;
+ while (ptr_line && (num < 100))
+ {
+ num++;
+ ptr_line = ptr_line->prev_line;
+ }
+ if (!ptr_line)
+ ptr_line = ptr_buffer->lines;
+ else
+ ptr_line = ptr_line->next_line;
- ptr_line = ptr_line->next_line;
+ while (ptr_line)
+ {
+ num--;
+ weechat_log_printf (" line N-%05d: str_time:'%s', prefix:'%s'\n",
+ num, ptr_line->str_time, ptr_line->prefix);
+ weechat_log_printf (" data: '%s'\n",
+ ptr_line->message);
+
+ ptr_line = ptr_line->next_line;
+ }
+
+ if (ptr_buffer->completion)
+ {
+ weechat_log_printf ("\n");
+ gui_completion_print_log (ptr_buffer->completion);
+ }
}
-
- weechat_log_printf ("\n");
- completion_print_log (&(buffer->completion));
}
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index de21b1fe8..e86a7b194 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -20,145 +20,156 @@
#ifndef __WEECHAT_GUI_BUFFER_H
#define __WEECHAT_GUI_BUFFER_H 1
-#include "../common/completion.h"
-#include "../common/history.h"
-
-#define GUI_BUFFER_TYPE_STANDARD 0
-#define GUI_BUFFER_TYPE_DCC 1
-#define GUI_BUFFER_TYPE_RAW_DATA 2
-
-#define GUI_SERVER(buffer) ((t_irc_server *)(buffer->server))
-#define GUI_CHANNEL(buffer) ((t_irc_channel *)(buffer->channel))
-
-#define GUI_BUFFER_IS_SERVER(buffer) ((GUI_SERVER(buffer) || (buffer->all_servers)) && !GUI_CHANNEL(buffer))
-#define GUI_BUFFER_IS_CHANNEL(buffer) (GUI_CHANNEL(buffer) && (GUI_CHANNEL(buffer)->type == IRC_CHANNEL_TYPE_CHANNEL))
-#define GUI_BUFFER_IS_PRIVATE(buffer) (GUI_CHANNEL(buffer) && \
- ((GUI_CHANNEL(buffer)->type == IRC_CHANNEL_TYPE_PRIVATE) \
- || (GUI_CHANNEL(buffer)->type == IRC_CHANNEL_TYPE_DCC_CHAT)))
-
-#define GUI_BUFFER_HAS_NICKLIST(buffer) (GUI_BUFFER_IS_CHANNEL(buffer))
-
-#define GUI_LINE_LENGTH_ALIGN(line) ((cfg_look_align_text_offset >= 0) ? \
- cfg_look_align_text_offset : line->length_align)
-
-#define GUI_MSG_TYPE_TIME 1
-#define GUI_MSG_TYPE_PREFIX 2
-#define GUI_MSG_TYPE_NICK 4
-#define GUI_MSG_TYPE_INFO 8
-#define GUI_MSG_TYPE_MSG 16
-#define GUI_MSG_TYPE_HIGHLIGHT 32
-#define GUI_MSG_TYPE_NOLOG 64
-
-#define GUI_PREFIX_SERVER "-@-"
-#define GUI_PREFIX_INFO "-=-"
-#define GUI_PREFIX_ACTION_ME "-*-"
-#define GUI_PREFIX_JOIN "-->"
-#define GUI_PREFIX_PART "<--"
-#define GUI_PREFIX_QUIT "<--"
-#define GUI_PREFIX_ERROR "=!="
-#define GUI_PREFIX_PLUGIN "-P-"
-#define GUI_PREFIX_RECV_MOD "==>"
-#define GUI_PREFIX_SEND_MOD "<=="
+enum t_gui_buffer_type
+{
+ GUI_BUFFER_TYPE_FORMATED = 0,
+ GUI_BUFFER_TYPE_FREE,
+};
-#define GUI_NOTIFY_LEVEL_MIN 0
-#define GUI_NOTIFY_LEVEL_MAX 3
-#define GUI_NOTIFY_LEVEL_DEFAULT GUI_NOTIFY_LEVEL_MAX
+#define GUI_BUFFER_NOTIFY_LEVEL_MIN 0
+#define GUI_BUFFER_NOTIFY_LEVEL_MAX 3
+#define GUI_BUFFER_NOTIFY_LEVEL_DEFAULT GUI_BUFFER_NOTIFY_LEVEL_MAX
#define GUI_TEXT_SEARCH_DISABLED 0
#define GUI_TEXT_SEARCH_BACKWARD 1
#define GUI_TEXT_SEARCH_FORWARD 2
-#define GUI_INPUT_BUFFER_BLOCK_SIZE 256
+#define GUI_BUFFER_INPUT_BLOCK_SIZE 256
/* 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 */
- time_t date; /* date/time of line */
- 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 */
+ time_t date; /* date/time of line */
+ char *str_time; /* time string (for display) */
+ char *prefix; /* prefix for line (may be NULL) */
+ int prefix_length; /* prefix length (on screen) */
+ char *message; /* line content (after prefix) */
+ struct t_gui_line *prev_line; /* link to previous line */
+ struct t_gui_line *next_line; /* link to next line */
};
-typedef struct t_gui_buffer t_gui_buffer;
+struct t_gui_nick
+{
+ char *nick; /* nickname */
+ int sort_index; /* index to force sort */
+ int color_nick; /* color for nick in nicklist */
+ char prefix; /* prefix for nick (for admins, ..) */
+ int color_prefix; /* color for prefix */
+ struct t_gui_nick *prev_nick; /* link to previous nick in nicklist */
+ struct t_gui_nick *next_nick; /* link to next nick in nicklist */
+};
struct t_gui_buffer
{
- int num_displayed; /* number of windows displaying buffer */
-
- int number; /* buffer number (for jump/switch) */
+ void *plugin; /* plugin which created this buffer */
+ /* (NULL for a WeeChat buffer) */
+ int number; /* buffer number (for jump/switch) */
+ char *category; /* category name */
+ char *name; /* buffer name */
+ enum t_gui_buffer_type type; /* buffer type (formated, free, ..) */
+ int notify_level; /* 0 = never */
+ /* 1 = highlight only */
+ /* 2 = highlight + msg */
+ /* 3 = highlight + msg + join/part */
+ int num_displayed; /* number of windows displaying buf. */
- /* 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 */
+ /* logging */
+ char *log_filename; /* filename for saving content */
+ FILE *log_file; /* file descriptor for log */
- /* 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) */
+ /* buffer title */
+ char *title; /* buffer title */
- /* 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 */
+ /* chat content */
+ struct t_gui_line *lines; /* lines of chat window */
+ struct t_gui_line *last_line; /* last line of chat window */
+ struct t_gui_line *last_read_line; /* last read line before jump */
+ int lines_count; /* number of lines in the buffer */
+ int prefix_max_length; /* length for prefix align */
+ int chat_refresh_needed; /* if refresh is needed (printf) */
- /* file to save buffer content */
- char *log_filename; /* filename for saving buffer content */
- FILE *log_file; /* for logging buffer to file */
+ /* nicklist */
+ int nicklist; /* = 1 if nicklist is enabled */
+ int nick_case_sensitive; /* nicks are case sensitive ? */
+ struct t_gui_nick *nicks; /* pointer to nicks for nicklist */
+ struct t_gui_nick *last_nick; /* last nick in nicklist */
+ int nick_max_length; /* max length for a nick */
+ int nicks_count; /* number of nicks on buffer */
- /* 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 */
+ /* inupt */
+ int input; /* = 1 if input is enabled */
+ void (*input_data_cb)(struct t_gui_buffer *, char *);
+ /* called when user send data */
+ /* to this buffer */
+ char *input_nick; /* self nick */
+ char *input_buffer; /* input buffer */
+ char *input_buffer_color_mask; /* color mask for input buffer */
+ int input_buffer_alloc; /* input buffer: allocated size */
+ 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 */
+ struct t_gui_completion *completion; /* 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 */
+ struct t_gui_history *history; /* commands history */
+ struct t_gui_history *last_history;/* last command in history */
+ struct t_gui_history *ptr_history; /* current command in history */
+ int num_history; /* number of commands in history */
/* text search */
- int text_search; /* text search type */
- int text_search_exact; /* exact search (case sensitive) ? */
- int text_search_found; /* 1 if text found, otherwise 0 */
- char *text_search_input; /* input saved before text search */
+ int text_search; /* text search type */
+ int text_search_exact; /* exact search (case sensitive) ? */
+ int text_search_found; /* 1 if text found, otherwise 0 */
+ char *text_search_input; /* input saved before text search */
/* link to previous/next buffer */
- t_gui_buffer *prev_buffer; /* link to previous buffer */
- t_gui_buffer *next_buffer; /* link to next buffer */
+ struct t_gui_buffer *prev_buffer; /* link to previous buffer */
+ struct 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_previous_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 struct t_gui_buffer *gui_buffers;
+extern struct t_gui_buffer *last_gui_buffer;
+extern struct t_gui_buffer *gui_previous_buffer;
+extern struct t_gui_buffer *gui_buffer_before_dcc;
+extern struct t_gui_buffer *gui_buffer_raw_data;
+extern struct t_gui_buffer *gui_buffer_before_raw_data;
+
+/* buffer functions */
+
+extern struct t_gui_buffer *gui_buffer_new (void *, char *, char *);
+extern int gui_buffer_valid (struct t_gui_buffer *);
+extern void gui_buffer_set_category (struct t_gui_buffer *, char *);
+extern void gui_buffer_set_name (struct t_gui_buffer *, char *);
+extern void gui_buffer_set_log (struct t_gui_buffer *, char *);
+extern void gui_buffer_set_title (struct t_gui_buffer *, char *);
+extern void gui_buffer_set_nick_case_sensitive (struct t_gui_buffer *, int);
+extern void gui_buffer_set_nick (struct t_gui_buffer *, char *);
+extern struct t_gui_buffer *gui_buffer_search_by_category_name (char *,
+ char *);
+extern struct t_gui_buffer *gui_buffer_search_by_number (int);
+extern struct t_gui_window *gui_buffer_find_window (struct t_gui_buffer *);
+extern void gui_buffer_find_context (void *, void *,
+ struct t_gui_window **,
+ struct t_gui_buffer **);
+extern int gui_buffer_is_scrolled (struct t_gui_buffer *);
+extern struct t_gui_buffer *gui_buffer_get_dcc (struct t_gui_window *);
+extern void gui_buffer_clear (struct t_gui_buffer *);
+extern void gui_buffer_clear_all ();
+extern void gui_buffer_free (struct t_gui_buffer *, int);
+extern void gui_buffer_switch_previous (struct t_gui_window *);
+extern void gui_buffer_switch_next (struct t_gui_window *);
+extern void gui_buffer_switch_dcc (struct t_gui_window *);
+extern void gui_buffer_switch_raw_data (struct t_gui_window *);
+extern struct t_gui_buffer *gui_buffer_switch_by_number (struct t_gui_window *,
+ int);
+extern void gui_buffer_move_to_number (struct t_gui_buffer *, int);
+extern void gui_buffer_dump_hexa (struct t_gui_buffer *);
+extern void gui_buffer_print_log ();
#endif /* gui-buffer.h */
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
new file mode 100644
index 000000000..616303acc
--- /dev/null
+++ b/src/gui/gui-chat.c
@@ -0,0 +1,566 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* gui-chat.c: chat functions, used by all GUI */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+#include "../core/weechat.h"
+#include "../core/wee-config.h"
+#include "../core/wee-log.h"
+#include "../core/wee-string.h"
+#include "../core/wee-utf8.h"
+#include "gui-chat.h"
+#include "gui-hotlist.h"
+#include "gui-main.h"
+#include "gui-status.h"
+#include "gui-window.h"
+
+
+char *gui_chat_prefix[GUI_CHAT_PREFIX_NUMBER]; /* prefixes */
+int gui_chat_time_length = 0; /* length of time for each line (in chars) */
+
+
+/*
+ * gui_chat_prefix_build: build prefix with colors
+ */
+
+void
+gui_chat_prefix_build ()
+{
+ char prefix[128];
+
+ snprintf (prefix, sizeof (prefix), "%s%s\t",
+ GUI_COLOR(GUI_COLOR_CHAT_PREFIX_INFO),
+ cfg_look_prefix[GUI_CHAT_PREFIX_INFO]);
+ gui_chat_prefix[GUI_CHAT_PREFIX_INFO] = strdup (prefix);
+
+ snprintf (prefix, sizeof (prefix), "%s%s\t",
+ GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ERROR),
+ cfg_look_prefix[GUI_CHAT_PREFIX_ERROR]);
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR] = strdup (prefix);
+
+ snprintf (prefix, sizeof (prefix), "%s%s\t",
+ GUI_COLOR(GUI_COLOR_CHAT_PREFIX_NETWORK),
+ cfg_look_prefix[GUI_CHAT_PREFIX_NETWORK]);
+ gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = strdup (prefix);
+
+ snprintf (prefix, sizeof (prefix), "%s%s\t",
+ GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ACTION),
+ cfg_look_prefix[GUI_CHAT_PREFIX_ACTION]);
+ gui_chat_prefix[GUI_CHAT_PREFIX_ACTION] = strdup (prefix);
+
+ snprintf (prefix, sizeof (prefix), "%s%s\t",
+ GUI_COLOR(GUI_COLOR_CHAT_PREFIX_JOIN),
+ cfg_look_prefix[GUI_CHAT_PREFIX_JOIN]);
+ gui_chat_prefix[GUI_CHAT_PREFIX_JOIN] = strdup (prefix);
+
+ snprintf (prefix, sizeof (prefix), "%s%s\t",
+ GUI_COLOR(GUI_COLOR_CHAT_PREFIX_QUIT),
+ cfg_look_prefix[GUI_CHAT_PREFIX_QUIT]);
+ gui_chat_prefix[GUI_CHAT_PREFIX_QUIT] = strdup (prefix);
+}
+
+/*
+ * gui_chat_strlen_screen: returns number of char needed on sreen to display a
+ * word special chars like color, bold, .. are ignored
+ */
+
+int
+gui_chat_strlen_screen (char *string)
+{
+ int length;
+
+ length = 0;
+ while (string && string[0])
+ {
+ string = gui_chat_string_next_char (NULL, (unsigned char *)string, 0);
+ if (string)
+ {
+ length += utf8_char_size_screen (string);
+ string = utf8_next_char (string);
+ }
+ }
+ return length;
+}
+
+/*
+ * gui_chat_string_real_pos: get real position in string
+ * (ignoring color/bold/.. chars)
+ */
+
+int
+gui_chat_string_real_pos (char *string, int pos)
+{
+ char *real_pos;
+
+ if (pos <= 0)
+ return 0;
+
+ real_pos = string;
+ while (string && string[0] && (pos > 0))
+ {
+ string = gui_chat_string_next_char (NULL, (unsigned char *)string, 0);
+ if (string)
+ {
+ pos -= utf8_char_size_screen (string);
+ string = utf8_next_char (string);
+ real_pos = string;
+ }
+ }
+ return 0 + (real_pos - string);
+}
+
+/*
+ * gui_chat_get_word_info: returns info about next word: beginning, end, length
+ */
+
+void
+gui_chat_get_word_info (struct t_gui_window *window,
+ char *data,
+ int *word_start_offset, int *word_end_offset,
+ int *word_length_with_spaces, int *word_length)
+{
+ char *start_data, *next_char, *next_char2;
+ int leading_spaces, char_size;
+
+ *word_start_offset = 0;
+ *word_end_offset = 0;
+ *word_length_with_spaces = 0;
+ *word_length = 0;
+
+ start_data = data;
+
+ leading_spaces = 1;
+ while (data && data[0])
+ {
+ next_char = gui_chat_string_next_char (window, (unsigned char *)data,
+ 0);
+ if (next_char)
+ {
+ next_char2 = utf8_next_char (next_char);
+ if (next_char2)
+ {
+ if (next_char[0] != ' ')
+ {
+ if (leading_spaces)
+ *word_start_offset = next_char - start_data;
+ leading_spaces = 0;
+ char_size = next_char2 - next_char;
+ *word_end_offset = next_char2 - start_data - 1;
+ (*word_length_with_spaces) += char_size;
+ (*word_length) += char_size;
+ }
+ else
+ {
+ if (leading_spaces)
+ (*word_length_with_spaces)++;
+ else
+ {
+ *word_end_offset = next_char - start_data - 1;
+ return;
+ }
+ }
+ data = next_char2;
+ }
+ }
+ else
+ {
+ *word_end_offset = data + strlen (data) - start_data - 1;
+ return;
+ }
+ }
+}
+
+/*
+ * gu_chat_get_time_string: get time string, for display (with colors)
+ */
+
+char *
+gui_chat_get_time_string (time_t date)
+{
+ char text_time[128], text_time2[(128*3)+16], text_time_char[2];
+ int i, time_first_digit, time_last_digit, last_color;
+ struct tm *local_time;
+
+ if (!cfg_look_buffer_time_format
+ || !cfg_look_buffer_time_format[0])
+ return NULL;
+
+ local_time = localtime (&date);
+ if (strftime (text_time, sizeof (text_time),
+ cfg_look_buffer_time_format, local_time) == 0)
+ return NULL;
+
+ time_first_digit = -1;
+ time_last_digit = -1;
+ i = 0;
+ while (text_time[i])
+ {
+ if (isdigit (text_time[i]))
+ {
+ if (time_first_digit == -1)
+ time_first_digit = i;
+ time_last_digit = i;
+ }
+ i++;
+ }
+
+ text_time2[0] = '\0';
+ text_time_char[1] = '\0';
+ last_color = -1;
+ i = 0;
+ while (text_time[i])
+ {
+ text_time_char[0] = text_time[i];
+ if (time_first_digit < 0)
+ {
+ if (last_color != GUI_COLOR_CHAT_TIME)
+ {
+ strcat (text_time2, GUI_COLOR(GUI_COLOR_CHAT_TIME));
+ last_color = GUI_COLOR_CHAT_TIME;
+ }
+ strcat (text_time2, text_time_char);
+ }
+ else
+ {
+ if ((i < time_first_digit) || (i > time_last_digit))
+ {
+ if (last_color != GUI_COLOR_CHAT_DELIMITERS)
+ {
+ strcat (text_time2, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
+ last_color = GUI_COLOR_CHAT_DELIMITERS;
+ }
+ strcat (text_time2, text_time_char);
+ }
+ else
+ {
+ if (isdigit (text_time[i]))
+ {
+ if (last_color != GUI_COLOR_CHAT_TIME)
+ {
+ strcat (text_time2, GUI_COLOR(GUI_COLOR_CHAT_TIME));
+ last_color = GUI_COLOR_CHAT_TIME;
+ }
+ strcat (text_time2, text_time_char);
+ }
+ else
+ {
+ if (last_color != GUI_COLOR_CHAT_TIME_DELIMITERS)
+ {
+ strcat (text_time2,
+ GUI_COLOR(GUI_COLOR_CHAT_TIME_DELIMITERS));
+ last_color = GUI_COLOR_CHAT_TIME_DELIMITERS;
+ }
+ strcat (text_time2, text_time_char);
+ }
+ }
+ }
+ i++;
+ }
+
+ return strdup (text_time2);
+}
+
+/*
+ * gui_chat_change_time_format: change time format for all lines of all buffers
+ */
+
+void
+gui_chat_change_time_format ()
+{
+ struct t_gui_buffer *ptr_buffer;
+ struct t_gui_line *ptr_line;
+
+ for (ptr_buffer = gui_buffers; ptr_buffer;
+ ptr_buffer = ptr_buffer->next_buffer)
+ {
+ for (ptr_line = ptr_buffer->lines; ptr_line;
+ ptr_line = ptr_line->next_line)
+ {
+ if (ptr_line->date != 0)
+ {
+ if (ptr_line->str_time)
+ free (ptr_line->str_time);
+ ptr_line->str_time = gui_chat_get_time_string (ptr_line->date);
+ }
+ }
+ }
+}
+
+/*
+ * gui_chat_get_line_align: get alignment for a line
+ */
+
+int
+gui_chat_get_line_align (struct t_gui_buffer *buffer, struct t_gui_line *line)
+{
+ if (cfg_look_prefix_align == CFG_LOOK_PREFIX_ALIGN_NONE)
+ return gui_chat_time_length + 1 + line->prefix_length + 2;
+
+ if (cfg_look_prefix_align_max > 0)
+ return gui_chat_time_length + 1 + cfg_look_prefix_align_max + 2 + 1;
+ else
+ return gui_chat_time_length + 1 + buffer->prefix_max_length + 2 + 1;
+}
+
+/*
+ * gui_chat_line_search: search for text in a line
+ */
+
+int
+gui_chat_line_search (struct t_gui_line *line, char *text, int case_sensitive)
+{
+ char *message;
+ int rc;
+
+ if (!line || !line->message || !text || !text[0])
+ return 0;
+
+ rc = 0;
+ message = (char *)gui_color_decode ((unsigned char *)line->message);
+ if (message)
+ {
+ if ((case_sensitive && (strstr (message, text)))
+ || (!case_sensitive && (string_strcasestr (message, text))))
+ rc = 1;
+ free (message);
+ }
+ return rc;
+}
+
+/*
+ * gui_chat_line_free: delete a line from a buffer
+ */
+
+void
+gui_chat_line_free (struct t_gui_line *line)
+{
+ struct t_gui_window *ptr_win;
+
+ for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
+ {
+ if (ptr_win->start_line == line)
+ {
+ ptr_win->start_line = ptr_win->start_line->next_line;
+ ptr_win->start_line_pos = 0;
+ gui_chat_draw (ptr_win->buffer, 0);
+ gui_status_draw (ptr_win->buffer, 0);
+ }
+ }
+ if (line->str_time)
+ free (line->str_time);
+ if (line->prefix)
+ free (line->prefix);
+ if (line->message)
+ free (line->message);
+ free (line);
+}
+
+/*
+ * gui_chat_line_add: add a new line for a buffer
+ */
+
+void
+gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, char *prefix,
+ char *message)
+{
+ struct t_gui_line *new_line, *ptr_line;
+
+ new_line = (struct t_gui_line *) malloc (sizeof (struct t_gui_line));
+ if (!new_line)
+ {
+ weechat_log_printf (_("Not enough memory for new line\n"));
+ return;
+ }
+
+ /* add new line */
+ new_line->date = date;
+ new_line->str_time = (date == 0) ?
+ NULL : gui_chat_get_time_string (date);
+ new_line->prefix = (prefix) ?
+ strdup (prefix) : ((date != 0) ? strdup ("") : NULL);
+ new_line->prefix_length = (prefix) ?
+ gui_chat_strlen_screen (prefix) : 0;
+ if (new_line->prefix_length > buffer->prefix_max_length)
+ buffer->prefix_max_length = new_line->prefix_length;
+ new_line->message = (message) ? strdup (message) : strdup ("");
+ if (!buffer->lines)
+ buffer->lines = new_line;
+ else
+ buffer->last_line->next_line = new_line;
+ new_line->prev_line = buffer->last_line;
+ new_line->next_line = NULL;
+ buffer->last_line = new_line;
+ buffer->lines_count++;
+
+ /* remove one line if necessary */
+ if ((cfg_history_max_lines > 0)
+ && (buffer->lines_count > cfg_history_max_lines))
+ {
+ if (buffer->last_line == buffer->lines)
+ buffer->last_line = NULL;
+ ptr_line = buffer->lines->next_line;
+ gui_chat_line_free (buffer->lines);
+ buffer->lines = ptr_line;
+ ptr_line->prev_line = NULL;
+ buffer->lines_count--;
+ }
+}
+
+/*
+ * gui_chat_printf: display a message in a buffer
+ */
+
+void
+gui_chat_printf (struct t_gui_buffer *buffer, char *message, ...)
+{
+ static char buf[8192];
+ time_t date;
+ int display_time;
+ char *pos, *pos_prefix, *pos_tab, *pos_end;
+ va_list argptr;
+
+ if (gui_init_ok)
+ {
+ if (buffer == NULL)
+ buffer = gui_buffers;
+
+ if (buffer->type == GUI_BUFFER_TYPE_FREE)
+ buffer = gui_buffers;
+
+ if (buffer->type == GUI_BUFFER_TYPE_FREE)
+ return;
+ }
+
+ va_start (argptr, message);
+ vsnprintf (buf, sizeof (buf) - 1, message, argptr);
+ va_end (argptr);
+
+ utf8_normalize (buf, '?');
+
+ date = time (NULL);
+
+ pos = buf;
+ while (pos)
+ {
+ pos_prefix = NULL;
+ display_time = 1;
+
+ /* if two first chars are tab, then do not display time */
+ if ((buf[0] == '\t') && (buf[1] == '\t'))
+ {
+ display_time = 0;
+ pos += 2;
+ }
+ else
+ {
+ /* if tab found, use prefix (before tab) */
+ pos_tab = strchr (buf, '\t');
+ if (pos_tab)
+ {
+ pos_tab[0] = '\0';
+ pos_prefix = buf;
+ pos = pos_tab + 1;
+ }
+ }
+
+ /* display until next end of line */
+ pos_end = strchr (pos, '\n');
+ if (pos_end)
+ pos_end[0] = '\0';
+
+ if (gui_init_ok)
+ gui_chat_line_add (buffer, (display_time) ? date : 0,
+ pos_prefix, pos);
+ else
+ {
+ if (pos_prefix)
+ string_iconv_fprintf (stdout, "%s ", pos_prefix);
+ string_iconv_fprintf (stdout, "%s\n", pos);
+ }
+
+ pos = (pos_end && pos_end[1]) ? pos_end + 1 : NULL;
+ }
+
+ if (gui_init_ok)
+ {
+ buffer->chat_refresh_needed = 1;
+ if (gui_add_hotlist
+ && ((buffer->num_displayed == 0)
+ || (gui_buffer_is_scrolled (buffer))))
+ {
+ gui_hotlist_add (buffer, 0, NULL, 1);
+ gui_status_draw (buffer, 0);
+ }
+ }
+}
+
+/*
+ * gui_chat_printf_raw_data: display raw IRC data (only if raw IRC data buffer
+ * exists)
+ * type: 0 = recv, 1 = send, -1 = recv, modified by
+ * a modifier (plugin)
+ */
+
+void
+gui_chat_printf_raw_data (void *server, int send, int modified, char *message)
+{
+ (void) server;
+ (void) send;
+ (void) modified;
+ (void) message;
+
+/* char *pos;
+
+ if (gui_buffer_raw_data)
+ {
+ while (message && message[0])
+ {
+ pos = strstr (message, "\r\n");
+ if (pos)
+ pos[0] = '\0';
+ gui_printf_nolog (gui_buffer_raw_data,
+ "%s[%s%s%s] %s%s%s %s\n",
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ GUI_COLOR(GUI_COLOR_WIN_CHAT_SERVER),
+ ((t_irc_server *)server)->name,
+ GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
+ GUI_COLOR((send) ? GUI_COLOR_WIN_CHAT_PART : GUI_COLOR_WIN_CHAT_JOIN),
+ (send) ? ((modified) ? GUI_PREFIX_SEND_MOD : GUI_PREFIX_PART) :
+ ((modified) ? GUI_PREFIX_RECV_MOD : GUI_PREFIX_JOIN),
+ GUI_COLOR(GUI_COLOR_CHAT),
+ message);
+ if (pos)
+ {
+ pos[0] = '\r';
+ message = pos + 2;
+ }
+ else
+ message = NULL;
+ }
+ }*/
+}
diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h
new file mode 100644
index 000000000..b95de01f6
--- /dev/null
+++ b/src/gui/gui-chat.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_GUI_CHAT_H
+#define __WEECHAT_GUI_CHAT_H 1
+
+#include "gui-buffer.h"
+
+enum t_gui_prefix
+{
+ GUI_CHAT_PREFIX_INFO = 0,
+ GUI_CHAT_PREFIX_ERROR,
+ GUI_CHAT_PREFIX_NETWORK,
+ GUI_CHAT_PREFIX_ACTION,
+ GUI_CHAT_PREFIX_JOIN,
+ GUI_CHAT_PREFIX_QUIT,
+
+ GUI_CHAT_PREFIX_NUMBER,
+};
+
+extern char *gui_chat_prefix[GUI_CHAT_PREFIX_NUMBER];
+extern int gui_chat_time_length;
+
+/* chat functions */
+
+extern void gui_chat_prefix_build ();
+extern int gui_chat_strlen_screen (char *);
+extern int gui_chat_string_real_pos (char *, int);
+extern void gui_chat_get_word_info (struct t_gui_window *,
+ char *, int *, int *, int *, int *);
+extern void gui_chat_change_time_format ();
+extern int gui_chat_get_line_align (struct t_gui_buffer *,
+ struct t_gui_line *);
+extern int gui_chat_line_search (struct t_gui_line *, char *, int);
+extern void gui_chat_line_free (struct t_gui_line *);
+extern void gui_chat_printf (struct t_gui_buffer *, char *, ...);
+extern void gui_chat_printf_raw_data (void *, int, int, char *);
+
+/* chat functions (GUI dependent) */
+
+extern void gui_chat_draw_title (struct t_gui_buffer *, int);
+extern char *gui_chat_string_next_char (struct t_gui_window *, unsigned char *,
+ int);
+extern void gui_chat_draw (struct t_gui_buffer *, int);
+extern void gui_chat_draw_line (struct t_gui_buffer *, struct t_gui_line *);
+
+#endif /* gui-chat.h */
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
new file mode 100644
index 000000000..ad391c0e3
--- /dev/null
+++ b/src/gui/gui-color.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* gui-color.c: color 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 "../core/weechat.h"
+#include "../core/wee-config.h"
+#include "../core/wee-string.h"
+#include "../core/wee-utf8.h"
+#include "gui-color.h"
+
+
+/*
+ * gui_color_search_config: search a color with configuration option name
+ * return color found (number >= 0), -1 if not found
+ */
+
+int
+gui_color_search_config (char *color_name)
+{
+ int i;
+
+ if (color_name)
+ {
+ i = 0;
+ while (weechat_options_colors[i].name)
+ {
+ if (string_strcasecmp (weechat_options_colors[i].name, color_name) == 0)
+ return weechat_options_colors[i].default_int;
+ i++;
+ }
+ }
+
+ /* color not found */
+ return -1;
+}
+
+/*
+ * gui_color_decode: parses a message and remove WeeChat color codes
+ * After use, string returned has to be free()
+ */
+
+unsigned char *
+gui_color_decode (unsigned char *string)
+{
+ unsigned char *out;
+ int out_length, out_pos, length;
+
+ out_length = (strlen ((char *)string) * 2) + 1;
+ out = (unsigned char *)malloc (out_length);
+ if (!out)
+ return NULL;
+
+ out_pos = 0;
+ while (string && string[0] && (out_pos < out_length - 1))
+ {
+ switch (string[0])
+ {
+ case GUI_COLOR_COLOR_CHAR:
+ string++;
+ if (isdigit (string[0]) && isdigit (string[1]))
+ string += 2;
+ break;
+ case GUI_COLOR_SET_CHAR:
+ case GUI_COLOR_REMOVE_CHAR:
+ string++;
+ if (string[0])
+ string++;
+ break;
+ case GUI_COLOR_RESET_CHAR:
+ string++;
+ break;
+ default:
+ length = utf8_char_size ((char *)string);
+ if (length == 0)
+ length = 1;
+ memcpy (out + out_pos, string, length);
+ out_pos += length;
+ string += length;
+ }
+ }
+ out[out_pos] = '\0';
+ return out;
+}
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 4135d00f6..090e64f37 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -20,118 +20,114 @@
#ifndef __WEECHAT_GUI_COLOR_H
#define __WEECHAT_GUI_COLOR_H 1
-#define GUI_COLOR_WIN_NICK_NUMBER 10
+#define GUI_COLOR_NICK_NUMBER 10
-typedef enum t_weechat_color t_weechat_color;
-
-enum t_weechat_color
+enum t_gui_color_enum
{
- GUI_COLOR_WIN_SEPARATOR = 0,
- GUI_COLOR_WIN_TITLE,
- GUI_COLOR_WIN_CHAT,
- GUI_COLOR_WIN_CHAT_TIME,
- GUI_COLOR_WIN_CHAT_TIME_SEP,
- GUI_COLOR_WIN_CHAT_PREFIX1,
- GUI_COLOR_WIN_CHAT_PREFIX2,
- GUI_COLOR_WIN_CHAT_SERVER,
- GUI_COLOR_WIN_CHAT_JOIN,
- GUI_COLOR_WIN_CHAT_PART,
- GUI_COLOR_WIN_CHAT_NICK,
- GUI_COLOR_WIN_CHAT_HOST,
- GUI_COLOR_WIN_CHAT_CHANNEL,
- GUI_COLOR_WIN_CHAT_DARK,
- GUI_COLOR_WIN_CHAT_HIGHLIGHT,
- GUI_COLOR_WIN_CHAT_READ_MARKER,
- GUI_COLOR_WIN_STATUS,
- GUI_COLOR_WIN_STATUS_DELIMITERS,
- GUI_COLOR_WIN_STATUS_CHANNEL,
- GUI_COLOR_WIN_STATUS_DATA_MSG,
- GUI_COLOR_WIN_STATUS_DATA_PRIVATE,
- GUI_COLOR_WIN_STATUS_DATA_HIGHLIGHT,
- GUI_COLOR_WIN_STATUS_DATA_OTHER,
- GUI_COLOR_WIN_STATUS_MORE,
- GUI_COLOR_WIN_INFOBAR,
- GUI_COLOR_WIN_INFOBAR_DELIMITERS,
- GUI_COLOR_WIN_INFOBAR_HIGHLIGHT,
- GUI_COLOR_WIN_INPUT,
- GUI_COLOR_WIN_INPUT_CHANNEL,
- GUI_COLOR_WIN_INPUT_NICK,
- GUI_COLOR_WIN_INPUT_DELIMITERS,
- GUI_COLOR_WIN_NICK,
- GUI_COLOR_WIN_NICK_AWAY,
- GUI_COLOR_WIN_NICK_CHANOWNER,
- GUI_COLOR_WIN_NICK_CHANADMIN,
- GUI_COLOR_WIN_NICK_OP,
- GUI_COLOR_WIN_NICK_HALFOP,
- GUI_COLOR_WIN_NICK_VOICE,
- GUI_COLOR_WIN_NICK_MORE,
- GUI_COLOR_WIN_NICK_SEP,
- GUI_COLOR_WIN_NICK_SELF,
- GUI_COLOR_WIN_NICK_PRIVATE,
- GUI_COLOR_WIN_NICK_1,
- GUI_COLOR_WIN_NICK_2,
- GUI_COLOR_WIN_NICK_3,
- GUI_COLOR_WIN_NICK_4,
- GUI_COLOR_WIN_NICK_5,
- GUI_COLOR_WIN_NICK_6,
- GUI_COLOR_WIN_NICK_7,
- GUI_COLOR_WIN_NICK_8,
- GUI_COLOR_WIN_NICK_9,
- GUI_COLOR_WIN_NICK_10,
- GUI_COLOR_DCC_SELECTED,
- GUI_COLOR_DCC_WAITING,
- GUI_COLOR_DCC_CONNECTING,
- GUI_COLOR_DCC_ACTIVE,
- GUI_COLOR_DCC_DONE,
- GUI_COLOR_DCC_FAILED,
- GUI_COLOR_DCC_ABORTED,
- GUI_COLOR_WIN_INPUT_SERVER,
- GUI_COLOR_WIN_TITLE_MORE,
- GUI_COLOR_WIN_INPUT_TEXT_NOT_FOUND,
- GUI_COLOR_WIN_NICK_CHANUSER,
- GUI_COLOR_WIN_INPUT_ACTIONS,
- GUI_NUM_COLORS
+ GUI_COLOR_SEPARATOR = 0,
+
+ GUI_COLOR_TITLE,
+ GUI_COLOR_TITLE_MORE,
+
+ GUI_COLOR_CHAT,
+ GUI_COLOR_CHAT_TIME,
+ GUI_COLOR_CHAT_TIME_DELIMITERS,
+ GUI_COLOR_CHAT_PREFIX_INFO,
+ GUI_COLOR_CHAT_PREFIX_ERROR,
+ GUI_COLOR_CHAT_PREFIX_NETWORK,
+ GUI_COLOR_CHAT_PREFIX_ACTION,
+ GUI_COLOR_CHAT_PREFIX_JOIN,
+ GUI_COLOR_CHAT_PREFIX_QUIT,
+ GUI_COLOR_CHAT_PREFIX_MORE,
+ GUI_COLOR_CHAT_PREFIX_SUFFIX,
+ GUI_COLOR_CHAT_BUFFER,
+ GUI_COLOR_CHAT_SERVER,
+ GUI_COLOR_CHAT_CHANNEL,
+ GUI_COLOR_CHAT_NICK,
+ GUI_COLOR_CHAT_NICK_SELF,
+ GUI_COLOR_CHAT_NICK_OTHER,
+ GUI_COLOR_CHAT_NICK1,
+ GUI_COLOR_CHAT_NICK2,
+ GUI_COLOR_CHAT_NICK3,
+ GUI_COLOR_CHAT_NICK4,
+ GUI_COLOR_CHAT_NICK5,
+ GUI_COLOR_CHAT_NICK6,
+ GUI_COLOR_CHAT_NICK7,
+ GUI_COLOR_CHAT_NICK8,
+ GUI_COLOR_CHAT_NICK9,
+ GUI_COLOR_CHAT_NICK10,
+ GUI_COLOR_CHAT_HOST,
+ GUI_COLOR_CHAT_DELIMITERS,
+ GUI_COLOR_CHAT_HIGHLIGHT,
+ GUI_COLOR_CHAT_READ_MARKER,
+
+ GUI_COLOR_STATUS,
+ GUI_COLOR_STATUS_DELIMITERS,
+ GUI_COLOR_STATUS_CHANNEL,
+ GUI_COLOR_STATUS_DATA_MSG,
+ GUI_COLOR_STATUS_DATA_PRIVATE,
+ GUI_COLOR_STATUS_DATA_HIGHLIGHT,
+ GUI_COLOR_STATUS_DATA_OTHER,
+ GUI_COLOR_STATUS_MORE,
+
+ GUI_COLOR_INFOBAR,
+ GUI_COLOR_INFOBAR_DELIMITERS,
+ GUI_COLOR_INFOBAR_HIGHLIGHT,
+
+ GUI_COLOR_INPUT,
+ GUI_COLOR_INPUT_SERVER,
+ GUI_COLOR_INPUT_CHANNEL,
+ GUI_COLOR_INPUT_NICK,
+ GUI_COLOR_INPUT_DELIMITERS,
+ GUI_COLOR_INPUT_TEXT_NOT_FOUND,
+ GUI_COLOR_INPUT_ACTIONS,
+
+ GUI_COLOR_NICKLIST,
+ GUI_COLOR_NICKLIST_AWAY,
+ GUI_COLOR_NICKLIST_PREFIX1,
+ GUI_COLOR_NICKLIST_PREFIX2,
+ GUI_COLOR_NICKLIST_PREFIX3,
+ GUI_COLOR_NICKLIST_PREFIX4,
+ GUI_COLOR_NICKLIST_PREFIX5,
+ GUI_COLOR_NICKLIST_MORE,
+ GUI_COLOR_NICKLIST_SEPARATOR,
+
+ GUI_COLOR_INFO,
+ GUI_COLOR_INFO_WAITING,
+ GUI_COLOR_INFO_CONNECTING,
+ GUI_COLOR_INFO_ACTIVE,
+ GUI_COLOR_INFO_DONE,
+ GUI_COLOR_INFO_FAILED,
+ GUI_COLOR_INFO_ABORTED,
+
+ 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_ATTR_WEECHAT_RESET_CHAR '\x1C'
-#define GUI_ATTR_WEECHAT_RESET_STR "\x1C"
+/* WeeChat internal color attributes (should never be in protocol messages) */
+
+#define GUI_COLOR_COLOR_CHAR '\x19'
+#define GUI_COLOR_COLOR_STR "\x19"
+#define GUI_COLOR_SET_CHAR '\x1A'
+#define GUI_COLOR_SET_STR "\x1A"
+#define GUI_COLOR_REMOVE_CHAR '\x1B'
+#define GUI_COLOR_REMOVE_STR "\x1B"
+#define GUI_COLOR_RESET_CHAR '\x1C'
+#define GUI_COLOR_RESET_STR "\x1C"
+
+#define GUI_COLOR_ATTR_BOLD_CHAR '\x01'
+#define GUI_COLOR_ATTR_BOLD_STR "\x01"
+#define GUI_COLOR_ATTR_REVERSE_CHAR '\x02'
+#define GUI_COLOR_ATTR_REVERSE_STR "\x02"
+#define GUI_COLOR_ATTR_ITALIC_CHAR '\x03'
+#define GUI_COLOR_ATTR_ITALIC_STR "\x03"
+#define GUI_COLOR_ATTR_UNDERLINE_CHAR '\x04'
+#define GUI_COLOR_ATTR_UNDERLINE_STR "\x04"
#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "")
-#define GUI_NO_COLOR GUI_ATTR_WEECHAT_RESET_STR
+#define GUI_NO_COLOR GUI_COLOR_RESET_STR
/* color structure */
-typedef struct t_gui_color t_gui_color;
-
struct t_gui_color
{
int foreground; /* foreground color */
@@ -142,6 +138,18 @@ struct t_gui_color
/* color variables */
-extern t_gui_color *gui_color[GUI_NUM_COLORS];
+extern struct t_gui_color *gui_color[GUI_NUM_COLORS];
+
+/* color functions */
+
+extern int gui_color_search_config (char *);
+extern unsigned char *gui_color_decode (unsigned char *);
+
+/* color functions (GUI dependent) */
+
+extern int gui_color_assign (int *, char *);
+extern char *gui_color_get_name (int);
+extern void gui_color_init_pairs ();
+extern void gui_color_rebuild_weechat ();
#endif /* gui-color.h */
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
deleted file mode 100644
index 90d62c27a..000000000
--- a/src/gui/gui-common.c
+++ /dev/null
@@ -1,875 +0,0 @@
-/*
- * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-/* gui-common.c: display 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"
-#include "../common/command.h"
-#include "../common/weeconfig.h"
-#include "../common/history.h"
-#include "../common/hotlist.h"
-#include "../common/log.h"
-#include "../common/utf8.h"
-#include "../common/util.h"
-#include "../protocols/irc/irc.h"
-
-#ifdef PLUGINS
-#include "../plugins/plugins.h"
-#endif
-
-
-int gui_init_ok = 0; /* = 1 if GUI is initialized */
-int gui_ok = 0; /* = 1 if GUI is ok */
- /* (0 when term size too small) */
-int gui_add_hotlist = 1; /* 0 is for temporarly disable */
- /* hotlist add for all buffers */
-
-t_gui_infobar *gui_infobar; /* pointer to infobar content */
-
-char *gui_input_clipboard = NULL; /* clipboard content */
-
-time_t gui_last_activity_time = 0; /* last activity time */
- /* (key pressed) */
-
-
-/*
- * gui_word_strlen: returns number of char needed on sreen to display a word
- * special chars like color, bold, .. are ignored
- */
-
-int
-gui_word_strlen (t_gui_window *window, char *string)
-{
- int length, width_screen;
-
- length = 0;
- while (string && string[0])
- {
- string = gui_chat_word_get_next_char (window, (unsigned char *)string, 0, &width_screen);
- if (string)
- length += width_screen;
- }
- return length;
-}
-
-/*
- * gui_word_real_pos: get real position in string (ignoring color/bold/.. chars)
- */
-
-int
-gui_word_real_pos (t_gui_window *window, char *string, int pos)
-{
- char *saved_pos;
- int real_pos, width_screen;
-
- if (pos <= 0)
- return 0;
-
- real_pos = 0;
- while (string && string[0] && (pos > 0))
- {
- saved_pos = string;
- string = gui_chat_word_get_next_char (window, (unsigned char *)string, 0, &width_screen);
- pos -= width_screen;
- if (string)
- real_pos += (string - saved_pos);
- }
- return real_pos;
-}
-
-/*
- * gui_add_to_line: add a message to last line of buffer
- */
-
-void
-gui_add_to_line (t_gui_buffer *buffer, int type, time_t date, char *nick, char *message)
-{
- char *pos;
- int length;
-
- /* create new line if previous was ending by '\n' (or if 1st line) */
- if (buffer->line_complete)
- {
- buffer->line_complete = 0;
- if (!gui_buffer_line_new (buffer, date))
- return;
- }
-
- pos = strchr (message, '\n');
- if (pos)
- {
- pos[0] = '\0';
- buffer->line_complete = 1;
- }
-
- if (nick && (!buffer->last_line->nick))
- buffer->last_line->nick = strdup (nick);
-
- if (buffer->last_line->data)
- {
- length = strlen (buffer->last_line->data);
- buffer->last_line->data = (char *) realloc (buffer->last_line->data,
- length + strlen (message) + 1);
- if (((type & GUI_MSG_TYPE_TIME) == 0)
- && (buffer->last_line->ofs_after_date < 0))
- buffer->last_line->ofs_after_date = length;
- if (((type & (GUI_MSG_TYPE_TIME | GUI_MSG_TYPE_NICK)) == 0)
- && (buffer->last_line->ofs_start_message < 0))
- buffer->last_line->ofs_start_message = length;
- strcat (buffer->last_line->data, message);
- }
- else
- {
- if (((type & GUI_MSG_TYPE_TIME) == 0)
- && (buffer->last_line->ofs_after_date < 0))
- buffer->last_line->ofs_after_date = 0;
- if (((type & (GUI_MSG_TYPE_TIME | GUI_MSG_TYPE_NICK)) == 0)
- && (buffer->last_line->ofs_start_message < 0))
- buffer->last_line->ofs_start_message = 0;
- buffer->last_line->data = strdup (message);
- }
-
- length = gui_word_strlen (NULL, message);
- buffer->last_line->length += length;
- if (type & GUI_MSG_TYPE_MSG)
- buffer->last_line->line_with_message = 1;
- if (type & GUI_MSG_TYPE_HIGHLIGHT)
- buffer->last_line->line_with_highlight = 1;
- if ((type & GUI_MSG_TYPE_TIME) || (type & GUI_MSG_TYPE_NICK) || (type & GUI_MSG_TYPE_PREFIX))
- buffer->last_line->length_align += length;
- if (type & GUI_MSG_TYPE_NOLOG)
- buffer->last_line->log_write = 0;
- if (pos)
- {
- pos[0] = '\n';
- if (buffer->num_displayed > 0)
- {
- gui_chat_draw_line (buffer, buffer->last_line);
- gui_chat_draw (buffer, 0);
- }
- if (gui_add_hotlist
- && ((buffer->num_displayed == 0) || (gui_buffer_is_scrolled (buffer))))
- {
- if (3 - buffer->last_line->line_with_message -
- buffer->last_line->line_with_highlight <=
- buffer->notify_level)
- {
- if (buffer->last_line->line_with_highlight)
- hotlist_add (HOTLIST_HIGHLIGHT, NULL, GUI_SERVER(buffer), buffer, 0);
- else if (GUI_BUFFER_IS_PRIVATE(buffer) && (buffer->last_line->line_with_message))
- hotlist_add (HOTLIST_PRIVATE, NULL, GUI_SERVER(buffer), buffer, 0);
- else if (buffer->last_line->line_with_message)
- hotlist_add (HOTLIST_MSG, NULL, GUI_SERVER(buffer), buffer, 0);
- else
- hotlist_add (HOTLIST_LOW, NULL, GUI_SERVER(buffer), buffer, 0);
- gui_status_draw (gui_current_window->buffer, 1);
- }
- }
- }
- if (buffer->line_complete && buffer->log_file && buffer->last_line->log_write)
- {
- gui_log_write_date (buffer);
- if (buffer->last_line->nick)
- {
- gui_log_write (buffer, "<");
- gui_log_write (buffer, buffer->last_line->nick);
- gui_log_write (buffer, "> ");
- }
- if (buffer->last_line->ofs_start_message >= 0)
- gui_log_write_line (buffer,
- buffer->last_line->data + buffer->last_line->ofs_start_message);
- else
- gui_log_write_line (buffer, buffer->last_line->data);
- }
-}
-
-/*
- * gui_printf_internal: display a message in a buffer
- * This function should NEVER be called directly.
- * You should use macros defined in gui.h
- */
-
-void
-gui_printf_internal (t_gui_buffer *buffer, int display_time, int type,
- int keep_irc_colors, char *nick, char *message, ...)
-{
- static char buf[8192];
- char *buf2;
- char text_time[1024], text_time_char[2];
- time_t date;
- struct tm *local_time;
- int time_first_digit, time_last_digit;
- char *pos;
- int i;
- va_list argptr;
-
- if (gui_init_ok)
- {
- if (buffer == NULL)
- {
- type |= GUI_MSG_TYPE_NOLOG;
- if (GUI_SERVER(gui_current_window->buffer))
- buffer = GUI_SERVER(gui_current_window->buffer)->buffer;
- else
- buffer = gui_current_window->buffer;
-
- if (!buffer || (buffer->type != GUI_BUFFER_TYPE_STANDARD))
- buffer = gui_buffers;
- }
-
- if (buffer == NULL)
- {
- weechat_log_printf ("%s gui_printf_internal without buffer! This is a bug, "
- "please send to developers - thanks\n",
- WEECHAT_WARNING);
- return;
- }
-
- if (buffer->type == GUI_BUFFER_TYPE_DCC)
- buffer = gui_buffers;
-
- if (buffer->type == GUI_BUFFER_TYPE_DCC)
- return;
- }
-
- va_start (argptr, message);
- vsnprintf (buf, sizeof (buf) - 1, message, argptr);
- va_end (argptr);
-
- if (!buf[0])
- return;
-
- buf2 = (char *)gui_color_decode ((unsigned char *)buf,
- (keep_irc_colors >= 0) ?
- keep_irc_colors : cfg_irc_colors_receive,
- 1);
-
- if (!buf2)
- return;
-
- utf8_normalize (buf2, '?');
-
- if (gui_init_ok)
- {
- pos = buf2;
- while (pos)
- {
- date = time (NULL);
- if ((!buffer->last_line) || (buffer->line_complete))
- {
- if (display_time && cfg_look_buffer_timestamp &&
- cfg_look_buffer_timestamp[0])
- {
- local_time = localtime (&date);
- strftime (text_time, sizeof (text_time), cfg_look_buffer_timestamp, local_time);
-
- time_first_digit = -1;
- time_last_digit = -1;
- i = 0;
- while (text_time[i])
- {
- if (isdigit (text_time[i]))
- {
- if (time_first_digit == -1)
- time_first_digit = i;
- time_last_digit = i;
- }
- i++;
- }
-
- text_time_char[1] = '\0';
- i = 0;
- while (text_time[i])
- {
- text_time_char[0] = text_time[i];
- if (time_first_digit < 0)
- {
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date,
- NULL, GUI_COLOR(GUI_COLOR_WIN_CHAT_TIME));
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date,
- NULL, text_time_char);
- }
- else
- {
- if ((i < time_first_digit) || (i > time_last_digit))
- {
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date,
- NULL, GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK));
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date,
- NULL, text_time_char);
- }
- else
- {
- if (isdigit (text_time[i]))
- {
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date,
- NULL, GUI_COLOR(GUI_COLOR_WIN_CHAT_TIME));
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date,
- NULL, text_time_char);
- }
- else
- {
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date,
- NULL, GUI_COLOR(GUI_COLOR_WIN_CHAT_TIME_SEP));
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date,
- NULL, text_time_char);
- }
- }
- }
- i++;
- }
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date,
- NULL, GUI_COLOR(GUI_COLOR_WIN_CHAT));
- }
- gui_add_to_line (buffer, GUI_MSG_TYPE_TIME, date, NULL, " ");
- }
- gui_add_to_line (buffer, type, date, nick, pos);
- pos = strchr (pos, '\n');
- if (pos)
- {
- if (!pos[1])
- pos = NULL;
- else
- pos++;
- }
- }
- }
- else
- weechat_iconv_fprintf (stdout, buf2);
-
- if (buf2)
- free (buf2);
-}
-
-/*
- * gui_printf_raw_data: display raw IRC data (only if raw IRC data buffer exists)
- * type: 0 = recv, 1 = send, -1 = recv, modified by a modifier (plugin)
- */
-
-void
-gui_printf_raw_data (void *server, int send, int modified, char *message)
-{
- char *pos;
-
- if (gui_buffer_raw_data)
- {
- while (message && message[0])
- {
- pos = strstr (message, "\r\n");
- if (pos)
- pos[0] = '\0';
- gui_printf_nolog (gui_buffer_raw_data,
- "%s[%s%s%s] %s%s%s %s\n",
- GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
- GUI_COLOR(GUI_COLOR_WIN_CHAT_SERVER),
- ((t_irc_server *)server)->name,
- GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
- GUI_COLOR((send) ? GUI_COLOR_WIN_CHAT_PART : GUI_COLOR_WIN_CHAT_JOIN),
- (send) ? ((modified) ? GUI_PREFIX_SEND_MOD : GUI_PREFIX_PART) :
- ((modified) ? GUI_PREFIX_RECV_MOD : GUI_PREFIX_JOIN),
- GUI_COLOR(GUI_COLOR_WIN_CHAT),
- message);
- if (pos)
- {
- pos[0] = '\r';
- message = pos + 2;
- }
- else
- message = NULL;
- }
- }
-}
-
-/*
- * gui_infobar_printf: display message in infobar
- */
-
-void
-gui_infobar_printf (int time_displayed, int color, char *message, ...)
-{
- static char buf[1024];
- va_list argptr;
- t_gui_infobar *ptr_infobar;
- char *buf2, *ptr_buf, *pos;
-
- va_start (argptr, message);
- vsnprintf (buf, sizeof (buf) - 1, message, argptr);
- va_end (argptr);
-
- ptr_infobar = (t_gui_infobar *)malloc (sizeof (t_gui_infobar));
- if (ptr_infobar)
- {
- buf2 = (char *)gui_color_decode ((unsigned char *)buf, 0, 0);
- ptr_buf = (buf2) ? buf2 : buf;
-
- ptr_infobar->color = color;
- ptr_infobar->text = strdup (ptr_buf);
- pos = strchr (ptr_infobar->text, '\n');
- if (pos)
- pos[0] = '\0';
- ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed;
- ptr_infobar->next_infobar = gui_infobar;
- gui_infobar = ptr_infobar;
- gui_infobar_draw (gui_current_window->buffer, 1);
- if (buf2)
- free (buf2);
- }
- else
- weechat_log_printf (_("%s not enough memory for infobar message\n"),
- WEECHAT_ERROR);
-}
-
-/*
- * gui_infobar_remove: remove last displayed message in infobar
- */
-
-void
-gui_infobar_remove ()
-{
- t_gui_infobar *new_infobar;
-
- if (gui_infobar)
- {
- new_infobar = gui_infobar->next_infobar;
- if (gui_infobar->text)
- free (gui_infobar->text);
- free (gui_infobar);
- gui_infobar = new_infobar;
- }
-}
-
-/*
- * gui_infobar_remove_all: remove last displayed message in infobar
- */
-
-void
-gui_infobar_remove_all ()
-{
- while (gui_infobar)
- {
- gui_infobar_remove ();
- }
-}
-
-/*
- * gui_input_optimize_size: optimize input buffer size by adding
- * or deleting data block (predefined size)
- */
-
-void
-gui_input_optimize_size (t_gui_buffer *buffer)
-{
- int optimal_size;
-
- if (buffer->has_input)
- {
- optimal_size = ((buffer->input_buffer_size / GUI_INPUT_BUFFER_BLOCK_SIZE) *
- GUI_INPUT_BUFFER_BLOCK_SIZE) + GUI_INPUT_BUFFER_BLOCK_SIZE;
- if (buffer->input_buffer_alloc != optimal_size)
- {
- buffer->input_buffer_alloc = optimal_size;
- buffer->input_buffer = realloc (buffer->input_buffer, optimal_size);
- buffer->input_buffer_color_mask = realloc (buffer->input_buffer_color_mask,
- optimal_size);
- }
- }
-}
-
-/*
- * gui_input_init_color_mask: initialize color mask for input buffer
- */
-
-void
-gui_input_init_color_mask (t_gui_buffer *buffer)
-{
- int i;
-
- if (buffer->has_input)
- {
- for (i = 0; i < buffer->input_buffer_size; i++)
- buffer->input_buffer_color_mask[i] = ' ';
- buffer->input_buffer_color_mask[buffer->input_buffer_size] = '\0';
- }
-}
-
-/*
- * gui_input_move: move data in input buffer
- */
-
-void
-gui_input_move (t_gui_buffer *buffer, char *target, char *source, int size)
-{
- int pos_source, pos_target;
-
- pos_target = target - buffer->input_buffer;
- pos_source = source - buffer->input_buffer;
-
- memmove (target, source, size);
- memmove (buffer->input_buffer_color_mask + pos_target,
- buffer->input_buffer_color_mask + pos_source, size);
-}
-
-/*
- * gui_input_complete: complete a word in input buffer
- */
-
-void
-gui_input_complete (t_gui_window *window)
-{
- int i;
-
- if (window->buffer->completion.word_found)
- {
- /* replace word with new completed word into input buffer */
- if (window->buffer->completion.diff_size > 0)
- {
- window->buffer->input_buffer_size +=
- window->buffer->completion.diff_size;
- window->buffer->input_buffer_length +=
- window->buffer->completion.diff_length;
- gui_input_optimize_size (window->buffer);
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- for (i = window->buffer->input_buffer_size - 1;
- i >= window->buffer->completion.position_replace +
- (int)strlen (window->buffer->completion.word_found); i--)
- {
- window->buffer->input_buffer[i] =
- window->buffer->input_buffer[i - window->buffer->completion.diff_size];
- window->buffer->input_buffer_color_mask[i] =
- window->buffer->input_buffer_color_mask[i - window->buffer->completion.diff_size];
- }
- }
- else
- {
- for (i = window->buffer->completion.position_replace +
- strlen (window->buffer->completion.word_found);
- i < window->buffer->input_buffer_size; i++)
- {
- window->buffer->input_buffer[i] =
- window->buffer->input_buffer[i - window->buffer->completion.diff_size];
- window->buffer->input_buffer_color_mask[i] =
- window->buffer->input_buffer_color_mask[i - window->buffer->completion.diff_size];
- }
- window->buffer->input_buffer_size +=
- window->buffer->completion.diff_size;
- window->buffer->input_buffer_length +=
- window->buffer->completion.diff_length;
- gui_input_optimize_size (window->buffer);
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
- }
-
- strncpy (window->buffer->input_buffer + window->buffer->completion.position_replace,
- window->buffer->completion.word_found,
- strlen (window->buffer->completion.word_found));
- for (i = 0; i < (int)strlen (window->buffer->completion.word_found); i++)
- {
- window->buffer->input_buffer_color_mask[window->buffer->completion.position_replace + i] = ' ';
- }
- window->buffer->input_buffer_pos =
- utf8_pos (window->buffer->input_buffer,
- window->buffer->completion.position_replace) +
- utf8_strlen (window->buffer->completion.word_found);
-
- /* position is < 0 this means only one word was found to complete,
- so reinit to stop completion */
- if (window->buffer->completion.position >= 0)
- window->buffer->completion.position =
- utf8_real_pos (window->buffer->input_buffer,
- window->buffer->input_buffer_pos);
-
- /* add nick completor if position 0 and completing nick */
- if ((window->buffer->completion.base_word_pos == 0)
- && (window->buffer->completion.context == COMPLETION_NICK))
- {
- if (strncmp (utf8_add_offset (window->buffer->input_buffer,
- window->buffer->input_buffer_pos),
- cfg_look_nick_completor, strlen (cfg_look_nick_completor)) != 0)
- gui_insert_string_input (window, cfg_look_nick_completor,
- window->buffer->input_buffer_pos);
- else
- window->buffer->input_buffer_pos += utf8_strlen (cfg_look_nick_completor);
- if (window->buffer->completion.position >= 0)
- window->buffer->completion.position += strlen (cfg_look_nick_completor);
- if (window->buffer->input_buffer[utf8_real_pos (window->buffer->input_buffer,
- window->buffer->input_buffer_pos)] != ' ')
- gui_insert_string_input (window, " ",
- window->buffer->input_buffer_pos);
- else
- window->buffer->input_buffer_pos++;
- if (window->buffer->completion.position >= 0)
- window->buffer->completion.position++;
- }
- else
- {
- /* add space or completor to the end of completion, if needed */
- if (window->buffer->completion.add_space)
- {
- if (window->buffer->input_buffer[utf8_real_pos (window->buffer->input_buffer,
- window->buffer->input_buffer_pos)] != ' ')
- gui_insert_string_input (window, " ",
- window->buffer->input_buffer_pos);
- else
- window->buffer->input_buffer_pos++;
- if (window->buffer->completion.position >= 0)
- window->buffer->completion.position++;
- }
- }
- gui_input_draw (window->buffer, 0);
- }
-}
-
-/*
- * gui_exec_action_dcc: execute an action on a DCC after a user input
- * return -1 if DCC buffer was closed due to action,
- * 0 otherwise
- */
-
-void
-gui_exec_action_dcc (t_gui_window *window, char *actions)
-{
- t_irc_dcc *dcc_selected, *ptr_dcc, *ptr_dcc_next;
- t_gui_window *ptr_win;
- t_gui_buffer *ptr_buffer;
-
- while (actions[0])
- {
- if (actions[0] >= 32)
- {
- dcc_selected = (window->dcc_selected) ?
- (t_irc_dcc *) window->dcc_selected : irc_dcc_list;
-
- switch (actions[0])
- {
- /* accept DCC */
- case 'a':
- case 'A':
- if (dcc_selected
- && (IRC_DCC_IS_RECV(dcc_selected->status))
- && (dcc_selected->status == IRC_DCC_WAITING))
- {
- irc_dcc_accept (dcc_selected);
- }
- break;
- /* cancel DCC */
- case 'c':
- case 'C':
- if (dcc_selected
- && (!IRC_DCC_ENDED(dcc_selected->status)))
- {
- irc_dcc_close (dcc_selected, IRC_DCC_ABORTED);
- gui_window_redraw_buffer (window->buffer);
- }
- break;
- /* purge old DCC */
- case 'p':
- case 'P':
- window->dcc_first = NULL;
- window->dcc_selected = NULL;
- window->dcc_last_displayed = NULL;
- ptr_dcc = irc_dcc_list;
- while (ptr_dcc)
- {
- ptr_dcc_next = ptr_dcc->next_dcc;
- if (IRC_DCC_ENDED(ptr_dcc->status))
- irc_dcc_free (ptr_dcc);
- ptr_dcc = ptr_dcc_next;
- }
- gui_window_redraw_buffer (window->buffer);
- break;
- /* close DCC window */
- case 'q':
- case 'Q':
- if (gui_buffer_before_dcc)
- {
- ptr_buffer = window->buffer;
- for (ptr_win = gui_windows; ptr_win;
- ptr_win = ptr_win->next_window)
- {
- if (ptr_win->buffer == ptr_buffer)
- gui_window_switch_to_buffer (ptr_win,
- gui_buffer_before_dcc);
- }
- gui_buffer_free (ptr_buffer, 0);
- }
- else
- gui_buffer_free (window->buffer, 1);
- gui_window_redraw_buffer (window->buffer);
- return;
- break;
- /* remove from DCC list */
- case 'r':
- case 'R':
- if (dcc_selected
- && (IRC_DCC_ENDED(dcc_selected->status)))
- {
- if (dcc_selected->next_dcc)
- window->dcc_selected = dcc_selected->next_dcc;
- else
- window->dcc_selected = NULL;
- irc_dcc_free (dcc_selected);
- gui_window_redraw_buffer (window->buffer);
- }
- break;
- }
- }
- actions = utf8_next_char (actions);
- }
-}
-
-/*
- * gui_exec_action_raw_data: execute an action on raw IRC data
- * return -1 if raw IRC data was closed due to action,
- * 0 otherwise
- */
-
-void
-gui_exec_action_raw_data (t_gui_window *window, char *actions)
-{
- t_gui_window *ptr_win;
- t_gui_buffer *ptr_buffer;
-
- while (actions[0])
- {
- if (actions[0] >= 32)
- {
- switch (actions[0])
- {
- /* close raw IRC data */
- case 'c':
- case 'C':
- gui_buffer_clear (window->buffer);
- gui_window_redraw_buffer (window->buffer);
- return;
- break;
- /* close raw IRC data */
- case 'q':
- case 'Q':
- if (gui_buffer_before_raw_data)
- {
- ptr_buffer = window->buffer;
- for (ptr_win = gui_windows; ptr_win;
- ptr_win = ptr_win->next_window)
- {
- if (ptr_win->buffer == ptr_buffer)
- gui_window_switch_to_buffer (ptr_win,
- gui_buffer_before_raw_data);
- }
- gui_buffer_free (ptr_buffer, 0);
- }
- else
- gui_buffer_free (window->buffer, 1);
- gui_window_redraw_buffer (window->buffer);
- return;
- break;
- }
- }
- actions = utf8_next_char (actions);
- }
-}
-
-/*
- * gui_insert_string_input: insert a string into the input buffer
- * if pos == -1, string is inserted at cursor position
- * return: number of chars inserted
- * (may be different of strlen if UTF-8 string)
- */
-
-int
-gui_insert_string_input (t_gui_window *window, char *string, int pos)
-{
- int i, pos_start, size, length;
- char *ptr_start;
-#ifdef PLUGINS
- char *buffer_before_insert, *string2;
-#endif
-
- if (window->buffer->has_input)
- {
-#ifdef PLUGINS
- buffer_before_insert =
- (window->buffer->input_buffer) ?
- strdup (window->buffer->input_buffer) : strdup ("");
-#endif
-
- if (pos == -1)
- pos = window->buffer->input_buffer_pos;
-
- size = strlen (string);
- length = utf8_strlen (string);
-
- /* increase buffer size */
- window->buffer->input_buffer_size += size;
- window->buffer->input_buffer_length += length;
- gui_input_optimize_size (window->buffer);
- window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
- window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
-
- /* move end of string to the right */
- ptr_start = utf8_add_offset (window->buffer->input_buffer, pos);
- pos_start = ptr_start - window->buffer->input_buffer;
- memmove (ptr_start + size, ptr_start, strlen (ptr_start));
- memmove (window->buffer->input_buffer_color_mask + pos_start + size,
- window->buffer->input_buffer_color_mask + pos_start,
- strlen (window->buffer->input_buffer_color_mask + pos_start));
-
- /* insert new string */
- ptr_start = utf8_add_offset (window->buffer->input_buffer, pos);
- pos_start = ptr_start - window->buffer->input_buffer;
- strncpy (ptr_start, string, size);
- for (i = 0; i < size; i++)
- {
- window->buffer->input_buffer_color_mask[pos_start + i] = ' ';
- }
-
- window->buffer->input_buffer_pos += length;
-
-#ifdef PLUGINS
- string2 = (char *) malloc (size + 2);
- if (string2)
- {
- snprintf (string2, size + 2, "*%s", string);
- (void) plugin_keyboard_handler_exec (string2,
- buffer_before_insert,
- window->buffer->input_buffer);
- free (string2);
- }
- if (buffer_before_insert)
- free (buffer_before_insert);
-#endif
-
- return length;
- }
- return 0;
-}
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c
index f04b35406..b74ce5010 100644
--- a/src/gui/gui-completion.c
+++ b/src/gui/gui-completion.c
@@ -30,32 +30,31 @@
#include <dirent.h>
#include <unistd.h>
-#include "weechat.h"
-#include "completion.h"
-#include "alias.h"
-#include "command.h"
-#include "log.h"
-#include "utf8.h"
-#include "util.h"
-#include "weelist.h"
-#include "weeconfig.h"
-#include "../protocols/irc/irc.h"
-
-#ifdef PLUGINS
-#include "../plugins/plugins.h"
-#endif
+#include "../core/weechat.h"
+#include "../core/wee-alias.h"
+#include "../core/wee-command.h"
+#include "../core/wee-config.h"
+#include "../core/wee-hook.h"
+#include "../core/wee-log.h"
+#include "../core/wee-string.h"
+#include "../core/wee-utf8.h"
+#include "../core/wee-list.h"
+#include "../plugins/plugin.h"
+#include "../plugins/plugin-config.h"
+#include "gui-completion.h"
+#include "gui-keyboard.h"
/*
- * completion_init: init completion
+ * gui_completion_init: init completion
*/
void
-completion_init (t_completion *completion, void *server, void *channel)
+gui_completion_init (struct t_gui_completion *completion,
+ struct t_gui_buffer *buffer)
{
- completion->server = server;
- completion->channel = channel;
- completion->context = COMPLETION_NULL;
+ completion->buffer = buffer;
+ completion->context = GUI_COMPLETION_NULL;
completion->base_command = NULL;
completion->base_command_arg = 0;
completion->arg_is_nick = 0;
@@ -68,7 +67,7 @@ completion_init (t_completion *completion, void *server, void *channel)
completion->completion_list = NULL;
completion->last_completion = NULL;
-
+
completion->word_found = NULL;
completion->position_replace = 0;
completion->diff_size = 0;
@@ -76,11 +75,11 @@ completion_init (t_completion *completion, void *server, void *channel)
}
/*
- * completion_free: free completion
+ * gui_completion_free_data: free data in completion
*/
void
-completion_free (t_completion *completion)
+gui_completion_free_data (struct t_gui_completion *completion)
{
if (completion->base_command)
free (completion->base_command);
@@ -105,31 +104,41 @@ completion_free (t_completion *completion)
}
/*
- * completion_stop: stop completion (for example after 1 arg of command with 1 arg)
+ * gui_completion_free: free completion
*/
void
-completion_stop (t_completion *completion)
+gui_completion_free (struct t_gui_completion *completion)
{
- completion->context = COMPLETION_NULL;
+ gui_completion_free_data (completion);
+ free (completion);
+}
+
+/*
+ * gui_completion_stop: stop completion (for example after 1 arg of command
+ * with 1 arg)
+ */
+
+void
+gui_completion_stop (struct t_gui_completion *completion)
+{
+ completion->context = GUI_COMPLETION_NULL;
completion->position = -1;
}
/*
- * completion_get_command_infos: return completion template and max arg for command
+ * gui_completion_get_command_infos: return completion template and max arg
+ * for command
*/
void
-completion_get_command_infos (t_completion *completion,
- char **template, int *max_arg)
+gui_completion_get_command_infos (struct t_gui_completion *completion,
+ char **template, int *max_arg)
{
- t_weechat_alias *ptr_alias;
+ struct alias *ptr_alias;
+ struct t_hook *ptr_hook;
char *ptr_command, *ptr_command2, *pos;
int i;
-#ifdef PLUGINS
- t_weechat_plugin *ptr_plugin;
- t_plugin_handler *ptr_handler;
-#endif
*template = NULL;
*max_arg = MAX_ARGS;
@@ -152,32 +161,26 @@ completion_get_command_infos (t_completion *completion,
if (pos)
pos[0] = '\0';
-#ifdef PLUGINS
- /* look for plugin command handler */
- for (ptr_plugin = weechat_plugins; ptr_plugin;
- ptr_plugin = ptr_plugin->next_plugin)
+ /* look for command hooked */
+ for (ptr_hook = weechat_hooks; ptr_hook;
+ ptr_hook = ptr_hook->next_hook)
{
- for (ptr_handler = ptr_plugin->handlers;
- ptr_handler; ptr_handler = ptr_handler->next_handler)
+ if ((ptr_hook->type == HOOK_TYPE_COMMAND)
+ && (string_strcasecmp (HOOK_COMMAND(ptr_hook, command),
+ ptr_command2) == 0))
{
- if ((ptr_handler->type == PLUGIN_HANDLER_COMMAND)
- && (ascii_strcasecmp (ptr_handler->command,
- ptr_command2) == 0))
- {
- *template = ptr_handler->completion_template;
- *max_arg = MAX_ARGS;
- free (ptr_command2);
- return;
- }
+ *template = HOOK_COMMAND(ptr_hook, completion);
+ *max_arg = MAX_ARGS;
+ free (ptr_command2);
+ return;
}
}
-#endif
/* look for WeeChat internal command */
- for (i = 0; weechat_commands[i].command_name; i++)
+ for (i = 0; weechat_commands[i].name; i++)
{
- if (ascii_strcasecmp (weechat_commands[i].command_name,
- ptr_command2) == 0)
+ if (string_strcasecmp (weechat_commands[i].name,
+ ptr_command2) == 0)
{
*template = weechat_commands[i].completion_template;
*max_arg = weechat_commands[i].max_arg;
@@ -186,31 +189,17 @@ completion_get_command_infos (t_completion *completion,
}
}
- /* look for IRC command */
- for (i = 0; irc_commands[i].command_name; i++)
- {
- if ((irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
- && (ascii_strcasecmp (irc_commands[i].command_name,
- ptr_command2) == 0))
- {
- *template = irc_commands[i].completion_template;
- *max_arg = irc_commands[i].max_arg;
- free (ptr_command2);
- return;
- }
- }
-
free (ptr_command2);
return;
}
/*
- * completion_is_only_alphanum: return 1 if there is only alpha/num chars
- * in a string
+ * gui_completion_is_only_alphanum: return 1 if there is only alpha/num chars
+ * in a string
*/
int
-completion_is_only_alphanum (char *string)
+gui_completion_is_only_alphanum (char *string)
{
while (string[0])
{
@@ -222,11 +211,11 @@ completion_is_only_alphanum (char *string)
}
/*
- * completion_strdup_alphanum: duplicate alpha/num chars in a string
+ * gui_completion_strdup_alphanum: duplicate alpha/num chars in a string
*/
char *
-completion_strdup_alphanum (char *string)
+gui_completion_strdup_alphanum (char *string)
{
char *result, *pos;
@@ -246,12 +235,12 @@ completion_strdup_alphanum (char *string)
}
/*
- * completion_nickncmp: locale and case independent string comparison
- * with max length for nicks (alpha or digits only)
+ * gui_completion_nickncmp: locale and case independent string comparison
+ * with max length for nicks (alpha or digits only)
*/
int
-completion_nickncmp (char *base_word, char *nick, int max)
+gui_completion_nickncmp (char *base_word, char *nick, int max)
{
char *base_word2, *nick2;
int return_cmp;
@@ -259,13 +248,13 @@ completion_nickncmp (char *base_word, char *nick, int max)
if (!cfg_look_nick_completion_ignore
|| !cfg_look_nick_completion_ignore[0]
|| !base_word || !nick || !base_word[0] || !nick[0]
- || (!completion_is_only_alphanum (base_word)))
- return ascii_strncasecmp (base_word, nick, max);
+ || (!gui_completion_is_only_alphanum (base_word)))
+ return string_strncasecmp (base_word, nick, max);
- base_word2 = completion_strdup_alphanum (base_word);
- nick2 = completion_strdup_alphanum (nick);
+ base_word2 = gui_completion_strdup_alphanum (base_word);
+ nick2 = gui_completion_strdup_alphanum (nick);
- return_cmp = ascii_strncasecmp (base_word2, nick2, strlen (base_word2));
+ return_cmp = string_strncasecmp (base_word2, nick2, strlen (base_word2));
free (base_word2);
free (nick2);
@@ -274,21 +263,21 @@ completion_nickncmp (char *base_word, char *nick, int max)
}
/*
- * completion_list_add: add a word to completion word list
+ * gui_completion_list_add: add a word to completion word list
*/
void
-completion_list_add (t_completion *completion, char *word,
- int nick_completion, int position)
+gui_completion_list_add (struct t_gui_completion *completion, char *word,
+ int nick_completion, int position)
{
if (!word || !word[0])
return;
if (!completion->base_word || !completion->base_word[0]
- || (nick_completion && (completion_nickncmp (completion->base_word, word,
- strlen (completion->base_word)) == 0))
- || (!nick_completion && (ascii_strncasecmp (completion->base_word, word,
- strlen (completion->base_word)) == 0)))
+ || (nick_completion && (gui_completion_nickncmp (completion->base_word, word,
+ strlen (completion->base_word)) == 0))
+ || (!nick_completion && (string_strncasecmp (completion->base_word, word,
+ strlen (completion->base_word)) == 0)))
{
weelist_add (&completion->completion_list,
&completion->last_completion,
@@ -298,57 +287,61 @@ completion_list_add (t_completion *completion, char *word,
}
/*
- * completion_list_add_alias: add alias to completion list
+ * gui_completion_list_add_alias: add alias to completion list
*/
void
-completion_list_add_alias (t_completion *completion)
+gui_completion_list_add_alias (struct t_gui_completion *completion)
{
- t_weechat_alias *ptr_alias;
+ struct alias *ptr_alias;
for (ptr_alias = weechat_alias; ptr_alias; ptr_alias = ptr_alias->next_alias)
{
- completion_list_add (completion, ptr_alias->alias_name,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_alias->name,
+ 0, WEELIST_POS_SORT);
}
}
/*
- * completion_list_add_alias_cmd: add alias and comands to completion list
+ * gui_completion_list_add_alias_cmd: add alias and comands to completion list
*/
void
-completion_list_add_alias_cmd (t_completion *completion)
+gui_completion_list_add_alias_cmd (struct t_gui_completion *completion)
{
- t_weelist *ptr_list;
+ struct t_weelist *ptr_list;
- for (ptr_list = index_commands; ptr_list; ptr_list = ptr_list->next_weelist)
+ for (ptr_list = weechat_index_commands; ptr_list;
+ ptr_list = ptr_list->next_weelist)
{
- completion_list_add (completion, ptr_list->data, 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_list->data, 0,
+ WEELIST_POS_SORT);
}
}
/*
- * completion_list_add_channel: add current channel to completion list
+ * gui_completion_list_add_channel: add current channel to completion list
*/
void
-completion_list_add_channel (t_completion *completion)
+gui_completion_list_add_channel (struct t_gui_completion *completion)
{
- if (completion->channel)
- completion_list_add (completion,
- ((t_irc_channel *)(completion->channel))->name,
- 0, WEELIST_POS_SORT);
+ (void) completion;
+ /*if (completion->channel)
+ gui_completion_list_add (completion,
+ ((t_irc_channel *)(completion->channel))->name,
+ 0, WEELIST_POS_SORT);*/
}
/*
- * completion_list_add_channels: add server channels to completion list
+ * gui_completion_list_add_channels: add server channels to completion list
*/
void
-completion_list_add_channels (t_completion *completion)
+gui_completion_list_add_channels (struct t_gui_completion *completion)
{
- t_irc_server *ptr_server;
+ (void) completion;
+ /*t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
if (completion->server)
@@ -359,19 +352,19 @@ completion_list_add_channels (t_completion *completion)
for (ptr_channel = ptr_server->channels;
ptr_channel; ptr_channel = ptr_channel->next_channel)
{
- completion_list_add (completion, ptr_channel->name,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_channel->name,
+ 0, WEELIST_POS_SORT);
}
}
- }
+ }*/
}
/*
- * completion_list_add_filename: add filename to completion list
+ * gui_completion_list_add_filename: add filename to completion list
*/
void
-completion_list_add_filename (t_completion *completion)
+gui_completion_list_add_filename (struct t_gui_completion *completion)
{
char *path_d, *path_b, *p, *d_name;
char *real_prefix, *prefix;
@@ -446,8 +439,8 @@ completion_list_add_filename (t_completion *completion)
entry->d_name,
S_ISDIR(statbuf.st_mode) ? DIR_SEPARATOR : "");
- completion_list_add (completion, buffer,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, buffer,
+ 0, WEELIST_POS_SORT);
}
}
}
@@ -461,14 +454,14 @@ completion_list_add_filename (t_completion *completion)
}
/*
- * completion_list_add_plugin_cmd: add plugin command handlers to completion list
+ * gui_completion_list_add_plugin_cmd: add plugin command handlers to completion list
*/
void
-completion_list_add_plugin_cmd (t_completion *completion)
+gui_completion_list_add_plugin_cmd (struct t_gui_completion *completion)
{
-#ifdef PLUGINS
- t_weechat_plugin *ptr_plugin;
+ (void) completion;
+ /*t_weechat_plugin *ptr_plugin;
t_plugin_handler *ptr_handler;
for (ptr_plugin = weechat_plugins; ptr_plugin;
@@ -478,87 +471,97 @@ completion_list_add_plugin_cmd (t_completion *completion)
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if (ptr_handler->type == PLUGIN_HANDLER_COMMAND)
- completion_list_add (completion, ptr_handler->command,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_handler->command,
+ 0, WEELIST_POS_SORT);
}
- }
-#else
- /* make C compiler happy */
- (void) completion;
-#endif
+ }*/
}
/*
- * completion_list_add_irc_cmd_sent: add IRC command (sent) to completion list
+ * gui_completion_list_add_protocol_commands: add protocol commands to completion list
*/
void
-completion_list_add_irc_cmd_sent (t_completion *completion)
+gui_completion_list_add_protocol_commands (struct t_gui_completion *completion)
{
- int i;
+ (void) completion;
- for (i = 0; irc_commands[i].command_name; i++)
+ /*int i;
+ t_weechat_protocol *ptr_protocol;
+
+ ptr_protocol = completion->buffer->protocol;
+
+ if (ptr_protocol && ptr_protocol->commands)
{
- if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
- completion_list_add (completion, irc_commands[i].command_name,
- 0, WEELIST_POS_SORT);
- }
+ i = 0;
+ while (ptr_protocol->commands[i].name)
+ {
+ gui_completion_list_add (completion,
+ ptr_protocol->commands[i].name,
+ 0, WEELIST_POS_SORT);
+ i++;
+ }
+ }*/
}
/*
- * completion_list_add_irc_cmd_recv: add IRC command (received) to completion list
+ * gui_completion_list_add_irc_cmd_recv: add IRC command (received) to
+ * completion list
*/
void
-completion_list_add_irc_cmd_recv (t_completion *completion)
+gui_completion_list_add_irc_cmd_recv (struct t_gui_completion *completion)
{
- int i;
+ (void) completion;
+ /*int i;
- for (i = 0; irc_commands[i].command_name; i++)
+ for (i = 0; irc_commands[i].name; i++)
{
if (irc_commands[i].recv_function)
- completion_list_add(completion, irc_commands[i].command_name,
- 0, WEELIST_POS_SORT);
- }
+ gui_completion_list_add(completion, irc_commands[i].name,
+ 0, WEELIST_POS_SORT);
+ }*/
}
/*
- * completion_list_add_key_cmd: add key commands/functions to completion list
+ * gui_completion_list_add_key_cmd: add key commands/functions to completion
+ * list
*/
void
-completion_list_add_key_cmd (t_completion *completion)
+gui_completion_list_add_key_cmd (struct t_gui_completion *completion)
{
int i;
for (i = 0; gui_key_functions[i].function_name; i++)
{
- completion_list_add (completion, gui_key_functions[i].function_name,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, gui_key_functions[i].function_name,
+ 0, WEELIST_POS_SORT);
}
}
/*
- * completion_list_add_self_nick: add self nick on server to completion list
+ * gui_completion_list_add_self_nick: add self nick on server to completion list
*/
void
-completion_list_add_self_nick (t_completion *completion)
+gui_completion_list_add_self_nick (struct t_gui_completion *completion)
{
- if (completion->server)
- completion_list_add (completion,
- ((t_irc_server *)(completion->server))->nick,
- 0, WEELIST_POS_SORT);
+ if (completion->buffer->input_nick)
+ gui_completion_list_add (completion,
+ completion->buffer->input_nick,
+ 0, WEELIST_POS_SORT);
}
/*
- * completion_list_add_server_nicks: add server nicks to completion list
+ * gui_completion_list_add_server_nicks: add server nicks to completion list
*/
void
-completion_list_add_server_nicks (t_completion *completion)
+gui_completion_list_add_server_nicks (struct t_gui_completion *completion)
{
- t_irc_server *ptr_server;
+ (void) completion;
+ /*t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
t_irc_nick *ptr_nick;
@@ -576,57 +579,58 @@ completion_list_add_server_nicks (t_completion *completion)
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
- completion_list_add (completion, ptr_nick->nick,
- 1, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_nick->nick,
+ 1, WEELIST_POS_SORT);
}
}
}
}
- /* add current channel nicks at beginning */
+ // add current channel nicks at beginning
if (completion->channel && (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_CHANNEL))
{
for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks;
ptr_nick; ptr_nick = ptr_nick->next_nick)
{
- completion_list_add (completion, ptr_nick->nick,
- 1, WEELIST_POS_BEGINNING);
+ gui_completion_list_add (completion, ptr_nick->nick,
+ 1, WEELIST_POS_BEGINNING);
}
}
- /* add self nick at the end */
+ // add self nick at the end
if (completion->server)
- completion_list_add (completion,
+ gui_completion_list_add (completion,
((t_irc_server *)(completion->server))->nick,
1, WEELIST_POS_END);
completion->arg_is_nick = 1;
- }
+ }*/
}
/*
- * completion_list_add_channel_nicks: add channel nicks to completion list
+ * gui_completion_list_add_channel_nicks: add channel nicks to completion list
*/
void
-completion_list_add_channel_nicks (t_completion *completion)
+gui_completion_list_add_channel_nicks (struct t_gui_completion *completion)
{
- t_irc_nick *ptr_nick;
- t_weelist *ptr_weelist;
+ (void) completion;
+ /*t_irc_nick *ptr_nick;
+ struct t_weelist *ptr_weelist;
if (completion->channel)
{
if (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_CHANNEL)
{
- /* add channel nicks */
+ // add channel nicks
for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks;
ptr_nick; ptr_nick = ptr_nick->next_nick)
{
- completion_list_add (completion, ptr_nick->nick,
- 1, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_nick->nick,
+ 1, WEELIST_POS_SORT);
}
- /* add nicks speaking recently on this channel */
+ // add nicks speaking recently on this channel
if (cfg_look_nick_completion_smart)
{
for (ptr_weelist = ((t_irc_channel *)(completion->channel))->nicks_speaking;
@@ -634,36 +638,37 @@ completion_list_add_channel_nicks (t_completion *completion)
{
if (irc_nick_search ((t_irc_channel *)(completion->channel),
ptr_weelist->data))
- completion_list_add (completion, ptr_weelist->data,
- 1, WEELIST_POS_BEGINNING);
+ gui_completion_list_add (completion, ptr_weelist->data,
+ 1, WEELIST_POS_BEGINNING);
}
}
- /* add self nick at the end */
+ // add self nick at the end
if (completion->server)
- completion_list_add (completion,
- ((t_irc_server *)(completion->server))->nick,
- 1, WEELIST_POS_END);
+ gui_completion_list_add (completion,
+ ((t_irc_server *)(completion->server))->nick,
+ 1, WEELIST_POS_END);
}
if ((((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_DCC_CHAT))
{
- completion_list_add (completion,
- ((t_irc_channel *)(completion->channel))->name,
- 1, WEELIST_POS_SORT);
+ gui_completion_list_add (completion,
+ ((t_irc_channel *)(completion->channel))->name,
+ 1, WEELIST_POS_SORT);
}
completion->arg_is_nick = 1;
- }
+ }*/
}
/*
- * completion_list_add_channel_nicks_hosts: add channel nicks and hosts to completion list
+ * gui_completion_list_add_channel_nicks_hosts: add channel nicks and hosts to completion list
*/
void
-completion_list_add_channel_nicks_hosts (t_completion *completion)
+gui_completion_list_add_channel_nicks_hosts (struct t_gui_completion *completion)
{
- t_irc_nick *ptr_nick;
+ (void) completion;
+ /*t_irc_nick *ptr_nick;
char *buf;
int length;
@@ -674,8 +679,8 @@ completion_list_add_channel_nicks_hosts (t_completion *completion)
for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks;
ptr_nick; ptr_nick = ptr_nick->next_nick)
{
- completion_list_add (completion, ptr_nick->nick,
- 1, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_nick->nick,
+ 1, WEELIST_POS_SORT);
if (ptr_nick->host)
{
length = strlen (ptr_nick->nick) + 1 +
@@ -685,8 +690,8 @@ completion_list_add_channel_nicks_hosts (t_completion *completion)
{
snprintf (buf, length, "%s!%s",
ptr_nick->nick, ptr_nick->host);
- completion_list_add (completion, buf,
- 1, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, buf,
+ 1, WEELIST_POS_SORT);
free (buf);
}
}
@@ -695,156 +700,138 @@ completion_list_add_channel_nicks_hosts (t_completion *completion)
if ((((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_PRIVATE))
{
- completion_list_add (completion,
- ((t_irc_channel *)(completion->channel))->name,
- 1, WEELIST_POS_SORT);
+ gui_completion_list_add (completion,
+ ((t_irc_channel *)(completion->channel))->name,
+ 1, WEELIST_POS_SORT);
}
completion->arg_is_nick = 1;
- }
+ }*/
}
/*
- * completion_list_add_option: add config option to completion list
+ * gui_completion_list_add_option: add config option to completion list
*/
void
-completion_list_add_option (t_completion *completion)
+gui_completion_list_add_option (struct t_gui_completion *completion)
{
int i, j;
- t_irc_server *ptr_server;
- char option_name[256];
- for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
+ /* WeeChat options */
+ for (i = 0; weechat_config_sections[i]; i++)
{
- if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS)
- && (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER))
+ if (weechat_config_options[i])
{
- for (j = 0; weechat_options[i][j].option_name; j++)
+ for (j = 0; weechat_config_options[i][j].name; j++)
{
- completion_list_add (completion,
- weechat_options[i][j].option_name,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion,
+ weechat_config_options[i][j].name,
+ 0, WEELIST_POS_SORT);
}
}
}
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- for (i = 0; weechat_options[CONFIG_SECTION_SERVER][i].option_name; i++)
- {
- snprintf (option_name, sizeof (option_name), "%s.%s",
- ptr_server->name,
- weechat_options[CONFIG_SECTION_SERVER][i].option_name);
- completion_list_add (completion, option_name, 0, WEELIST_POS_SORT);
- }
- }
}
/*
- * completion_list_add_plugin_option: add plugin option to completion list
+ * gui_completion_list_add_plugin_option: add plugin option to completion list
*/
void
-completion_list_add_plugin_option (t_completion *completion)
+gui_completion_list_add_plugin_option (struct t_gui_completion *completion)
{
-#ifdef PLUGINS
- t_plugin_option *ptr_option;
+ struct t_plugin_option *ptr_option;
for (ptr_option = plugin_options; ptr_option;
ptr_option = ptr_option->next_option)
{
- completion_list_add (completion, ptr_option->name, 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_option->name, 0, WEELIST_POS_SORT);
}
-#else
- /* make C compiler happy */
- (void) completion;
-#endif
}
/*
- * completion_list_add_part: add part message to completion list
+ * gui_completion_list_add_part: add part message to completion list
*/
void
-completion_list_add_part (t_completion *completion)
+gui_completion_list_add_part (struct t_gui_completion *completion)
{
- if (cfg_irc_default_msg_part && cfg_irc_default_msg_part[0])
- completion_list_add (completion, cfg_irc_default_msg_part,
- 0, WEELIST_POS_SORT);
+ (void) completion;
+ /*if (cfg_irc_default_msg_part && cfg_irc_default_msg_part[0])
+ gui_completion_list_add (completion, cfg_irc_default_msg_part,
+ 0, WEELIST_POS_SORT);*/
}
/*
- * completion_list_add_plugin: add plugin name to completion list
+ * gui_completion_list_add_plugin: add plugin name to completion list
*/
void
-completion_list_add_plugin (t_completion *completion)
+gui_completion_list_add_plugin (struct t_gui_completion *completion)
{
-#ifdef PLUGINS
- t_weechat_plugin *ptr_plugin;
+ struct t_weechat_plugin *ptr_plugin;
for (ptr_plugin = weechat_plugins; ptr_plugin;
ptr_plugin = ptr_plugin->next_plugin)
{
- completion_list_add (completion, ptr_plugin->name,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_plugin->name,
+ 0, WEELIST_POS_SORT);
}
-#else
- /* make C compiler happy */
- (void) completion;
-#endif
}
/*
- * completion_list_add_quit: add quit message to completion list
+ * gui_completion_list_add_quit: add quit message to completion list
*/
void
-completion_list_add_quit (t_completion *completion)
+gui_completion_list_add_quit (struct t_gui_completion *completion)
{
- if (cfg_irc_default_msg_quit && cfg_irc_default_msg_quit[0])
- completion_list_add (completion, cfg_irc_default_msg_quit,
- 0, WEELIST_POS_SORT);
+ (void) completion;
+ /*if (cfg_irc_default_msg_quit && cfg_irc_default_msg_quit[0])
+ gui_completion_list_add (completion, cfg_irc_default_msg_quit,
+ 0, WEELIST_POS_SORT);*/
}
/*
- * completion_list_add_server: add current server to completion list
+ * gui_completion_list_add_server: add current server to completion list
*/
void
-completion_list_add_server (t_completion *completion)
+gui_completion_list_add_server (struct t_gui_completion *completion)
{
- if (completion->server)
- completion_list_add (completion,
+ (void) completion;
+ /*if (completion->server)
+ gui_completion_list_add (completion,
((t_irc_server *)(completion->server))->name,
- 0, WEELIST_POS_SORT);
+ 0, WEELIST_POS_SORT);*/
}
/*
- * completion_list_add_servers: add all servers to completion list
+ * gui_completion_list_add_servers: add all servers to completion list
*/
void
-completion_list_add_servers (t_completion *completion)
+gui_completion_list_add_servers (struct t_gui_completion *completion)
{
- t_irc_server *ptr_server;
+ (void) completion;
+ /*t_irc_server *ptr_server;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
- completion_list_add (completion, ptr_server->name,
- 0, WEELIST_POS_SORT);
- }
+ gui_completion_list_add (completion, ptr_server->name,
+ 0, WEELIST_POS_SORT);
+ }*/
}
/*
- * completion_list_add_topic: add topic to completion list
+ * gui_completion_list_add_topic: add topic to completion list
*/
void
-completion_list_add_topic (t_completion *completion)
+gui_completion_list_add_topic (struct t_gui_completion *completion)
{
- char *string;
+ (void) completion;
+ /*char *string;
if (completion->server && completion->channel
&& ((t_irc_channel *)(completion->channel))->topic
@@ -854,24 +841,24 @@ completion_list_add_topic (t_completion *completion)
string = (char *)gui_color_decode_for_user_entry ((unsigned char *)((t_irc_channel *)(completion->channel))->topic);
else
string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)(completion->channel))->topic, 0, 0);
- completion_list_add (completion,
- (string) ?
- string : ((t_irc_channel *)(completion->channel))->topic,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion,
+ (string) ?
+ string : ((t_irc_channel *)(completion->channel))->topic,
+ 0, WEELIST_POS_SORT);
if (string)
free (string);
- }
+ }*/
}
/*
- * completion_list_add_option_value: add option value to completion list
+ * gui_completion_list_add_option_value: add option value to completion list
*/
void
-completion_list_add_option_value (t_completion *completion)
+gui_completion_list_add_option_value (struct t_gui_completion *completion)
{
char *pos;
- t_config_option *option;
+ struct t_config_option *option;
void *option_value;
char option_string[2048];
@@ -882,38 +869,43 @@ completion_list_add_option_value (t_completion *completion)
pos[0] = '\0';
option = NULL;
option_value = NULL;
- config_option_search_option_value (completion->args, &option, &option_value);
+ //config_option_search_option_value (completion->args, &option, &option_value);
+ config_option_section_option_search_get_value (weechat_config_sections,
+ weechat_config_options,
+ completion->args,
+ &option,
+ &option_value);
if (option && option_value)
{
- switch (option->option_type)
+ switch (option->type)
{
case OPTION_TYPE_BOOLEAN:
if (option_value && (*((int *)(option_value))))
- completion_list_add (completion, "on",
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, "on",
+ 0, WEELIST_POS_SORT);
else
- completion_list_add (completion, "off",
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, "off",
+ 0, WEELIST_POS_SORT);
break;
case OPTION_TYPE_INT:
snprintf (option_string, sizeof (option_string) - 1,
"%d", (option_value) ? *((int *)(option_value)) : option->default_int);
- completion_list_add (completion, option_string,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, option_string,
+ 0, WEELIST_POS_SORT);
break;
case OPTION_TYPE_INT_WITH_STRING:
- completion_list_add (completion,
- (option_value) ?
- option->array_values[*((int *)(option_value))] :
- option->array_values[option->default_int],
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion,
+ (option_value) ?
+ option->array_values[*((int *)(option_value))] :
+ option->array_values[option->default_int],
+ 0, WEELIST_POS_SORT);
break;
case OPTION_TYPE_COLOR:
- completion_list_add (completion,
- (option_value) ?
- gui_color_get_name (*((int *)(option_value))) :
- option->default_string,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion,
+ (option_value) ?
+ gui_color_get_name (*((int *)(option_value))) :
+ option->default_string,
+ 0, WEELIST_POS_SORT);
break;
case OPTION_TYPE_STRING:
snprintf (option_string, sizeof (option_string) - 1,
@@ -921,8 +913,8 @@ completion_list_add_option_value (t_completion *completion)
((option_value) && (*((char **)(option_value)))) ?
*((char **)(option_value)) :
option->default_string);
- completion_list_add (completion, option_string,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, option_string,
+ 0, WEELIST_POS_SORT);
break;
}
}
@@ -932,15 +924,14 @@ completion_list_add_option_value (t_completion *completion)
}
/*
- * completion_list_add_plugin_option_value: add plugin option value to completion list
+ * gui_completion_list_add_plugin_option_value: add plugin option value to completion list
*/
void
-completion_list_add_plugin_option_value (t_completion *completion)
+gui_completion_list_add_plugin_option_value (struct t_gui_completion *completion)
{
-#ifdef PLUGINS
char *pos;
- t_plugin_option *ptr_option;
+ struct t_plugin_option *ptr_option;
if (completion->args)
{
@@ -950,40 +941,36 @@ completion_list_add_plugin_option_value (t_completion *completion)
ptr_option = plugin_config_search_internal (completion->args);
if (ptr_option)
- completion_list_add (completion, ptr_option->value,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, ptr_option->value,
+ 0, WEELIST_POS_SORT);
if (pos)
pos[0] = ' ';
}
-#else
- /* make C compiler happy */
- (void) completion;
-#endif
}
/*
- * completion_list_add_weechat_cmd: add WeeChat commands to completion list
+ * gui_completion_list_add_weechat_cmd: add WeeChat commands to completion list
*/
void
-completion_list_add_weechat_cmd (t_completion *completion)
+gui_completion_list_add_weechat_cmd (struct t_gui_completion *completion)
{
int i;
- for (i = 0; weechat_commands[i].command_name; i++)
+ for (i = 0; weechat_commands[i].name; i++)
{
- completion_list_add (completion, weechat_commands[i].command_name,
- 0, WEELIST_POS_SORT);
+ gui_completion_list_add (completion, weechat_commands[i].name,
+ 0, WEELIST_POS_SORT);
}
}
/*
- * completion_build_list_template: build data list according to a template
+ * gui_completion_build_list_template: build data list according to a template
*/
void
-completion_build_list_template (t_completion *completion, char *template)
+gui_completion_build_list_template (struct t_gui_completion *completion, char *template)
{
char *word, *pos;
int word_offset;
@@ -1015,84 +1002,81 @@ completion_build_list_template (t_completion *completion, char *template)
switch (pos[0])
{
case '-': /* stop completion */
- completion_stop (completion);
+ gui_completion_stop (completion);
free (word);
return;
break;
case '*': /* repeat last completion (do nothing there) */
break;
case 'a': /* alias */
- completion_list_add_alias (completion);
+ gui_completion_list_add_alias (completion);
break;
case 'A': /* alias or any command */
- completion_list_add_alias_cmd (completion);
+ gui_completion_list_add_alias_cmd (completion);
break;
case 'c': /* current channel */
- completion_list_add_channel (completion);
+ gui_completion_list_add_channel (completion);
break;
case 'C': /* all channels */
- completion_list_add_channels (completion);
+ gui_completion_list_add_channels (completion);
break;
case 'f': /* filename */
- completion_list_add_filename (completion);
+ gui_completion_list_add_filename (completion);
break;
case 'h': /* plugin command handlers */
- completion_list_add_plugin_cmd (completion);
+ gui_completion_list_add_plugin_cmd (completion);
break;
- case 'i': /* IRC command (sent) */
- completion_list_add_irc_cmd_sent (completion);
- break;
- case 'I': /* IRC command (received) */
- completion_list_add_irc_cmd_recv (completion);
+ case 'i': /* protocol commands */
+ gui_completion_list_add_protocol_commands (completion);
break;
case 'k': /* key cmd/funtcions*/
- completion_list_add_key_cmd (completion);
+ gui_completion_list_add_key_cmd (completion);
break;
case 'm': /* self nickname */
- completion_list_add_self_nick (completion);
+ gui_completion_list_add_self_nick (completion);
break;
case 'M': /* nicks of current server (all open channels) */
- completion_list_add_server_nicks (completion);
+ gui_completion_list_add_server_nicks (completion);
break;
case 'n': /* channel nicks */
- completion_list_add_channel_nicks (completion);
- completion->context = COMPLETION_NICK;
+ gui_completion_list_add_channel_nicks (completion);
+ completion->context = GUI_COMPLETION_NICK;
break;
case 'N': /* channel nicks and hosts */
- completion_list_add_channel_nicks_hosts (completion);
+ gui_completion_list_add_channel_nicks_hosts (completion);
break;
case 'o': /* config option */
- completion_list_add_option (completion);
+ gui_completion_list_add_option (completion);
break;
case 'O': /* plugin option */
- completion_list_add_plugin_option (completion);
+ gui_completion_list_add_plugin_option (completion);
break;
case 'p': /* part message */
- completion_list_add_part (completion);
+ gui_completion_list_add_part (completion);
break;
case 'P': /* plugin name */
- completion_list_add_plugin (completion);
+ gui_completion_list_add_plugin (completion);
break;
case 'q': /* quit message */
- completion_list_add_quit (completion);
+ gui_completion_list_add_quit (completion);
break;
case 's': /* current server */
- completion_list_add_server (completion);
+ gui_completion_list_add_server (completion);
break;
case 'S': /* all servers */
- completion_list_add_servers (completion);
+ gui_completion_list_add_servers (completion);
break;
case 't': /* topic */
- completion_list_add_topic (completion);
+ gui_completion_list_add_topic (completion);
break;
case 'v': /* value of config option */
- completion_list_add_option_value (completion);
+ gui_completion_list_add_option_value (completion);
break;
case 'V': /* value of plugin option */
- completion_list_add_plugin_option_value (completion);
+ gui_completion_list_add_plugin_option_value (completion);
break;
case 'w': /* WeeChat commands */
- completion_list_add_weechat_cmd (completion);
+ gui_completion_list_add_weechat_cmd (completion);
break;
}
}
@@ -1110,22 +1094,22 @@ completion_build_list_template (t_completion *completion, char *template)
}
/*
- * completion_build_list: build data list according to command and argument #
+ * gui_completion_build_list: build data list according to command and argument #
*/
void
-completion_build_list (t_completion *completion)
+gui_completion_build_list (struct t_gui_completion *completion)
{
char *template, *pos_template, *pos_space;
int repeat_last, max_arg, i, length;
repeat_last = 0;
- completion_get_command_infos (completion, &template, &max_arg);
+ gui_completion_get_command_infos (completion, &template, &max_arg);
if (!template || (strcmp (template, "-") == 0) ||
(completion->base_command_arg > max_arg))
{
- completion_stop (completion);
+ gui_completion_stop (completion);
return;
}
@@ -1143,7 +1127,7 @@ completion_build_list (t_completion *completion)
pos_space = strchr (pos_template, ' ');
if (i == completion->base_command_arg)
{
- completion_build_list_template (completion, pos_template);
+ gui_completion_build_list_template (completion, pos_template);
return;
}
if (pos_space)
@@ -1159,35 +1143,36 @@ completion_build_list (t_completion *completion)
if (repeat_last)
{
pos_space = rindex (template, ' ');
- completion_build_list_template (completion,
- (pos_space) ? pos_space + 1 : template);
+ gui_completion_build_list_template (completion,
+ (pos_space) ? pos_space + 1 : template);
}
}
/*
- * completion_find_context: find context for completion
+ * gui_completion_find_context: find context for completion
*/
void
-completion_find_context (t_completion *completion, char *buffer, int size, int pos)
+gui_completion_find_context (struct t_gui_completion *completion, char *data,
+ int size, int pos)
{
int i, command, command_arg, pos_start, pos_end;
/* look for context */
- completion_free (completion);
- completion_init (completion, completion->server, completion->channel);
- command = ((buffer[0] == '/') && (buffer[1] != '/')) ? 1 : 0;
+ gui_completion_free_data (completion);
+ gui_completion_init (completion, completion->buffer);
+ command = ((data[0] == '/') && (data[1] != '/')) ? 1 : 0;
command_arg = 0;
i = 0;
while (i < pos)
{
- if (buffer[i] == ' ')
+ if (data[i] == ' ')
{
command_arg++;
i++;
- while ((i < pos) && (buffer[i] == ' ')) i++;
+ while ((i < pos) && (data[i] == ' ')) i++;
if (!completion->args)
- completion->args = strdup (buffer + i);
+ completion->args = strdup (data + i);
}
else
i++;
@@ -1196,17 +1181,17 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
{
if (command_arg > 0)
{
- completion->context = COMPLETION_COMMAND_ARG;
+ completion->context = GUI_COMPLETION_COMMAND_ARG;
completion->base_command_arg = command_arg;
}
else
{
- completion->context = COMPLETION_COMMAND;
+ completion->context = GUI_COMPLETION_COMMAND;
completion->base_command_arg = 0;
}
}
else
- completion->context = COMPLETION_AUTO;
+ completion->context = GUI_COMPLETION_AUTO;
/* look for word to complete (base word) */
completion->base_word_pos = 0;
@@ -1216,24 +1201,24 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
{
i = pos;
pos_start = i;
- if (buffer[i] == ' ')
+ if (data[i] == ' ')
{
- if ((i > 0) && (buffer[i-1] != ' '))
+ if ((i > 0) && (data[i-1] != ' '))
{
i--;
- while ((i >= 0) && (buffer[i] != ' '))
+ while ((i >= 0) && (data[i] != ' '))
i--;
pos_start = i + 1;
}
}
else
{
- while ((i >= 0) && (buffer[i] != ' '))
+ while ((i >= 0) && (data[i] != ' '))
i--;
pos_start = i + 1;
}
i = pos;
- while ((i < size) && (buffer[i] != ' '))
+ while ((i < size) && (data[i] != ' '))
i++;
pos_end = i - 1;
@@ -1241,14 +1226,14 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
if (pos_start <= pos_end)
{
- if (completion->context == COMPLETION_COMMAND)
+ if (completion->context == GUI_COMPLETION_COMMAND)
completion->position_replace = pos_start + 1;
else
completion->position_replace = pos_start;
completion->base_word = (char *) malloc (pos_end - pos_start + 2);
for (i = pos_start; i <= pos_end; i++)
- completion->base_word[i - pos_start] = buffer[i];
+ completion->base_word[i - pos_start] = data[i];
completion->base_word[pos_end - pos_start + 1] = '\0';
}
}
@@ -1257,58 +1242,58 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
completion->base_word = strdup ("");
/* find command (for command argument completion only) */
- if (completion->context == COMPLETION_COMMAND_ARG)
+ if (completion->context == GUI_COMPLETION_COMMAND_ARG)
{
pos_start = 0;
- while ((pos_start < size) && (buffer[pos_start] != '/'))
+ while ((pos_start < size) && (data[pos_start] != '/'))
pos_start++;
- if (buffer[pos_start] == '/')
+ if (data[pos_start] == '/')
{
pos_start++;
pos_end = pos_start;
- while ((pos_end < size) && (buffer[pos_end] != ' '))
+ while ((pos_end < size) && (data[pos_end] != ' '))
pos_end++;
- if (buffer[pos_end] == ' ')
+ if (data[pos_end] == ' ')
pos_end--;
completion->base_command = (char *) malloc (pos_end - pos_start + 2);
for (i = pos_start; i <= pos_end; i++)
- completion->base_command[i - pos_start] = buffer[i];
+ completion->base_command[i - pos_start] = data[i];
completion->base_command[pos_end - pos_start + 1] = '\0';
- completion_build_list (completion);
+ gui_completion_build_list (completion);
}
}
/* auto completion with nothing as base word is disabled,
in order to prevent completion when pasting messages with [tab] inside */
- if ((completion->context == COMPLETION_AUTO)
+ if ((completion->context == GUI_COMPLETION_AUTO)
&& ((!completion->base_word) || (!completion->base_word[0])))
{
- completion->context = COMPLETION_NULL;
+ completion->context = GUI_COMPLETION_NULL;
return;
}
}
/*
- * completion_command: complete a command
+ * gui_completion_command: complete a command
*/
void
-completion_command (t_completion *completion)
+gui_completion_command (struct t_gui_completion *completion)
{
int length, word_found_seen, other_completion;
- t_weelist *ptr_weelist, *ptr_weelist2;
+ struct t_weelist *ptr_weelist, *ptr_weelist2;
length = strlen (completion->base_word) - 1;
word_found_seen = 0;
other_completion = 0;
if (completion->direction < 0)
- ptr_weelist = last_index_command;
+ ptr_weelist = weechat_last_index_command;
else
- ptr_weelist = index_commands;
+ ptr_weelist = weechat_index_commands;
while (ptr_weelist)
{
- if (ascii_strncasecmp (ptr_weelist->data, completion->base_word + 1, length) == 0)
+ if (string_strncasecmp (ptr_weelist->data, completion->base_word + 1, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
@@ -1323,8 +1308,8 @@ completion_command (t_completion *completion)
while (ptr_weelist2)
{
- if (ascii_strncasecmp (ptr_weelist2->data,
- completion->base_word + 1, length) == 0)
+ if (string_strncasecmp (ptr_weelist2->data,
+ completion->base_word + 1, length) == 0)
other_completion++;
if (completion->direction < 0)
@@ -1343,7 +1328,7 @@ completion_command (t_completion *completion)
other_completion++;
}
if (completion->word_found &&
- (ascii_strcasecmp (ptr_weelist->data, completion->word_found) == 0))
+ (string_strcasecmp (ptr_weelist->data, completion->word_found) == 0))
word_found_seen = 1;
if (completion->direction < 0)
@@ -1355,19 +1340,19 @@ completion_command (t_completion *completion)
{
free (completion->word_found);
completion->word_found = NULL;
- completion_command (completion);
+ gui_completion_command (completion);
}
}
/*
- * completion_command_arg: complete a command argument
+ * gui_completion_command_arg: complete a command argument
*/
void
-completion_command_arg (t_completion *completion, int nick_completion)
+gui_completion_command_arg (struct t_gui_completion *completion, int nick_completion)
{
int length, word_found_seen, other_completion;
- t_weelist *ptr_weelist, *ptr_weelist2;
+ struct t_weelist *ptr_weelist, *ptr_weelist2;
length = strlen (completion->base_word);
word_found_seen = 0;
@@ -1379,8 +1364,8 @@ completion_command_arg (t_completion *completion, int nick_completion)
while (ptr_weelist)
{
- if ((nick_completion && (completion_nickncmp (completion->base_word, ptr_weelist->data, length) == 0))
- || ((!nick_completion) && (ascii_strncasecmp (completion->base_word, ptr_weelist->data, length) == 0)))
+ if ((nick_completion && (gui_completion_nickncmp (completion->base_word, ptr_weelist->data, length) == 0))
+ || ((!nick_completion) && (string_strncasecmp (completion->base_word, ptr_weelist->data, length) == 0)))
{
if ((!completion->word_found) || word_found_seen)
{
@@ -1396,9 +1381,9 @@ completion_command_arg (t_completion *completion, int nick_completion)
while (ptr_weelist2)
{
if ((nick_completion
- && (completion_nickncmp (completion->base_word, ptr_weelist2->data, length) == 0))
+ && (gui_completion_nickncmp (completion->base_word, ptr_weelist2->data, length) == 0))
|| ((!nick_completion)
- && (ascii_strncasecmp (completion->base_word, ptr_weelist2->data, length) == 0)))
+ && (string_strncasecmp (completion->base_word, ptr_weelist2->data, length) == 0)))
other_completion++;
if (completion->direction < 0)
@@ -1417,7 +1402,7 @@ completion_command_arg (t_completion *completion, int nick_completion)
other_completion++;
}
if (completion->word_found &&
- (ascii_strcasecmp (ptr_weelist->data, completion->word_found) == 0))
+ (string_strcasecmp (ptr_weelist->data, completion->word_found) == 0))
word_found_seen = 1;
if (completion->direction < 0)
@@ -1429,25 +1414,26 @@ completion_command_arg (t_completion *completion, int nick_completion)
{
free (completion->word_found);
completion->word_found = NULL;
- completion_command_arg (completion, nick_completion);
+ gui_completion_command_arg (completion, nick_completion);
}
}
/*
- * completion_nick: complete a nick
+ * gui_completion_nick: complete a nick
*/
void
-completion_nick (t_completion *completion)
+gui_completion_nick (struct t_gui_completion *completion)
{
- int length, word_found_seen, other_completion;
+ (void) completion;
+ /*int length, word_found_seen, other_completion;
t_irc_nick *ptr_nick;
- t_weelist *ptr_weelist, *ptr_weelist2;
+ struct t_weelist *ptr_weelist, *ptr_weelist2;
if (!completion->channel)
return;
- completion->context = COMPLETION_NICK;
+ completion->context = GUI_COMPLETION_NICK;
if ((((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_PRIVATE)
|| (((t_irc_channel *)(completion->channel))->type == IRC_CHANNEL_TYPE_DCC_CHAT))
@@ -1463,15 +1449,15 @@ completion_nick (t_completion *completion)
((t_irc_server *)(completion->server))->nick,
WEELIST_POS_SORT);
}
- completion_command_arg (completion, 1);
+ gui_completion_command_arg (completion, 1);
return;
}
- /* rebuild nick list for completion, with nicks speaking at beginning of list */
+ // rebuild nick list for completion, with nicks speaking at beginning of list
if ((((t_irc_channel *)(completion->channel))->nick_completion_reset)
|| (!(completion->completion_list)))
{
- /* empty completion list */
+ // empty completion list
if (completion->completion_list)
{
weelist_remove_all (&(completion->completion_list),
@@ -1480,7 +1466,7 @@ completion_nick (t_completion *completion)
completion->last_completion = NULL;
}
- /* add channel nicks */
+ // add channel nicks
for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks;
ptr_nick; ptr_nick = ptr_nick->next_nick)
{
@@ -1490,7 +1476,7 @@ completion_nick (t_completion *completion)
WEELIST_POS_SORT);
}
- /* add nicks speaking recently on this channel */
+ // add nicks speaking recently on this channel
if (cfg_look_nick_completion_smart)
{
for (ptr_weelist = ((t_irc_channel *)(completion->channel))->nicks_speaking;
@@ -1505,7 +1491,7 @@ completion_nick (t_completion *completion)
}
}
- /* add self nick at the end */
+ // add self nick at the end
if (completion->server)
weelist_add (&(completion->completion_list),
&(completion->last_completion),
@@ -1526,7 +1512,7 @@ completion_nick (t_completion *completion)
while (ptr_weelist)
{
- if (completion_nickncmp (completion->base_word, ptr_weelist->data, length) == 0)
+ if (gui_completion_nickncmp (completion->base_word, ptr_weelist->data, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
@@ -1546,9 +1532,9 @@ completion_nick (t_completion *completion)
while (ptr_weelist2)
{
- if (completion_nickncmp (completion->base_word,
- ptr_weelist2->data,
- length) == 0)
+ if (gui_completion_nickncmp (completion->base_word,
+ ptr_weelist2->data,
+ length) == 0)
other_completion++;
if (completion->direction < 0)
@@ -1569,7 +1555,7 @@ completion_nick (t_completion *completion)
other_completion++;
}
if (completion->word_found &&
- (ascii_strcasecmp (ptr_weelist->data, completion->word_found) == 0))
+ (string_strcasecmp (ptr_weelist->data, completion->word_found) == 0))
word_found_seen = 1;
if (completion->direction < 0)
@@ -1581,50 +1567,53 @@ completion_nick (t_completion *completion)
{
free (completion->word_found);
completion->word_found = NULL;
- completion_nick (completion);
- }
+ gui_completion_nick (completion);
+ }*/
}
/*
- * completion_auto: auto complete: nick, filename or channel
+ * gui_completion_auto: auto complete: nick, filename or channel
*/
void
-completion_auto (t_completion *completion)
+gui_completion_auto (struct t_gui_completion *completion)
{
- /* filename completion */
+ (void) completion;
+ /*
+ // filename completion
if ((completion->base_word[0] == '/')
|| (completion->base_word[0] == '~'))
{
if (!completion->completion_list)
- completion_list_add_filename (completion);
- completion_command_arg (completion, 0);
+ gui_completion_list_add_filename (completion);
+ gui_completion_command_arg (completion, 0);
return;
}
- /* channel completion */
+ // channel completion
if (irc_channel_is_channel (completion->base_word))
{
if (!completion->completion_list)
- completion_list_add_channels (completion);
- completion_command_arg (completion, 0);
+ gui_completion_list_add_channels (completion);
+ gui_completion_command_arg (completion, 0);
return;
}
- /* default: nick completion (if channel) */
+ // default: nick completion (if channel)
if (completion->channel)
- completion_nick (completion);
+ gui_completion_nick (completion);
else
- completion->context = COMPLETION_NULL;
+ completion->context = GUI_COMPLETION_NULL;
+ */
}
/*
- * completion_search: complete word according to context
+ * gui_completion_search: complete word according to context
*/
void
-completion_search (t_completion *completion, int direction,
- char *buffer, int size, int pos)
+gui_completion_search (struct t_gui_completion *completion, int direction,
+ char *data, int size, int pos)
{
char *old_word_found;
@@ -1636,7 +1625,7 @@ completion_search (t_completion *completion, int direction,
if (completion->word_found)
free (completion->word_found);
completion->word_found = NULL;
- completion_find_context (completion, buffer, size, pos);
+ gui_completion_find_context (completion, data, size, pos);
}
/* completion */
@@ -1644,26 +1633,26 @@ completion_search (t_completion *completion, int direction,
strdup (completion->word_found) : NULL;
switch (completion->context)
{
- case COMPLETION_NULL:
+ case GUI_COMPLETION_NULL:
/* should never be executed */
return;
- case COMPLETION_NICK:
- completion_nick (completion);
+ case GUI_COMPLETION_NICK:
+ gui_completion_nick (completion);
break;
- case COMPLETION_COMMAND:
- completion_command (completion);
+ case GUI_COMPLETION_COMMAND:
+ gui_completion_command (completion);
break;
- case COMPLETION_COMMAND_ARG:
+ case GUI_COMPLETION_COMMAND_ARG:
if (completion->completion_list)
- completion_command_arg (completion, completion->arg_is_nick);
+ gui_completion_command_arg (completion, completion->arg_is_nick);
else
{
- completion->context = COMPLETION_AUTO;
- completion_auto (completion);
+ completion->context = GUI_COMPLETION_AUTO;
+ gui_completion_auto (completion);
}
break;
- case COMPLETION_AUTO:
- completion_auto (completion);
+ case GUI_COMPLETION_AUTO:
+ gui_completion_auto (completion);
break;
}
if (completion->word_found)
@@ -1681,7 +1670,7 @@ completion_search (t_completion *completion, int direction,
strlen (completion->base_word);
completion->diff_length = utf8_strlen (completion->word_found) -
utf8_strlen (completion->base_word);
- if (completion->context == COMPLETION_COMMAND)
+ if (completion->context == GUI_COMPLETION_COMMAND)
{
completion->diff_size++;
completion->diff_length++;
@@ -1693,15 +1682,14 @@ completion_search (t_completion *completion, int direction,
}
/*
- * completion_print_log: print completion list in log (usually for crash dump)
+ * gui_completion_print_log: print completion list in log (usually for crash dump)
*/
void
-completion_print_log (t_completion *completion)
+gui_completion_print_log (struct t_gui_completion *completion)
{
weechat_log_printf ("[completion (addr:0x%X)]\n", completion);
- weechat_log_printf (" server . . . . . . . . : 0x%X\n", completion->server);
- weechat_log_printf (" channel. . . . . . . . : 0x%X\n", completion->channel);
+ weechat_log_printf (" buffer . . . . . . . . : 0x%X\n", completion->buffer);
weechat_log_printf (" context. . . . . . . . : %d\n", completion->context);
weechat_log_printf (" base_command . . . . . : '%s'\n", completion->base_command);
weechat_log_printf (" base_command_arg . . . : %d\n", completion->base_command_arg);
diff --git a/src/gui/gui-completion.h b/src/gui/gui-completion.h
index 5b9ff9bd7..d8adcb77b 100644
--- a/src/gui/gui-completion.h
+++ b/src/gui/gui-completion.h
@@ -17,49 +17,46 @@
*/
-#ifndef __WEECHAT_COMPLETION_H
-#define __WEECHAT_COMPLETION_H 1
+#ifndef __WEECHAT_GUI_COMPLETION_H
+#define __WEECHAT_GUI_COMPLETION_H 1
-#include "weelist.h"
+#define GUI_COMPLETION_NULL 0
+#define GUI_COMPLETION_NICK 1
+#define GUI_COMPLETION_COMMAND 2
+#define GUI_COMPLETION_COMMAND_ARG 3
+#define GUI_COMPLETION_AUTO 4
-#define COMPLETION_NULL 0
-#define COMPLETION_NICK 1
-#define COMPLETION_COMMAND 2
-#define COMPLETION_COMMAND_ARG 3
-#define COMPLETION_AUTO 4
-
-typedef struct t_completion t_completion;
-
-struct t_completion
+struct t_gui_completion
{
/* completion context */
- void *server; /* server pointer */
- void *channel; /* channel pointer */
- int context; /* context: null, nick, command, cmd arg */
- char *base_command; /* command with arg to complete (can be NULL) */
- int base_command_arg; /* # arg to complete (if context is cmd arg) */
- int arg_is_nick; /* argument is nick */
- char *base_word; /* word to complete (when Tab was pressed) */
- int base_word_pos; /* beggining of base word */
- int position; /* position where Tab was pressed */
- char *args; /* command line args (including base word) */
- int direction; /* +1 = search next word, -1 = previous word */
- int add_space; /* add space after completion? */
+ struct t_gui_buffer *buffer;/* buffer where completion was asked */
+ int context; /* context: null, nick, command, cmd arg */
+ char *base_command; /* command with arg to complete (can be NULL)*/
+ int base_command_arg; /* # arg to complete (if context is cmd arg) */
+ int arg_is_nick; /* argument is nick */
+ char *base_word; /* word to complete (when Tab was pressed) */
+ int base_word_pos; /* beggining of base word */
+ int position; /* position where Tab was pressed */
+ char *args; /* command line args (including base word) */
+ int direction; /* +1 = search next word, -1 = previous word */
+ int add_space; /* add space after completion? */
/* for command argument completion */
- t_weelist *completion_list; /* data list for completion */
- t_weelist *last_completion; /* last data element for completion */
+ struct t_weelist *completion_list; /* data list for completion */
+ struct t_weelist *last_completion; /* last data element for completion */
/* completion found */
- char *word_found; /* word found (to replace base word) */
- int position_replace; /* position where word has to be replaced */
- int diff_size; /* size difference (< 0 = char(s) deleted) */
- int diff_length; /* length difference (<= diff_size) */
+ char *word_found; /* word found (to replace base word) */
+ int position_replace; /* position where word has to be replaced */
+ int diff_size; /* size difference (< 0 = char(s) deleted) */
+ int diff_length; /* length difference (<= diff_size) */
};
-extern void completion_init (t_completion *, void *, void *);
-extern void completion_free (t_completion *);
-extern void completion_search (t_completion *, int, char *, int, int);
-extern void completion_print_log (t_completion *);
+/* completion functions */
+
+extern void gui_completion_init (struct t_gui_completion *, struct t_gui_buffer *);
+extern void gui_completion_free (struct t_gui_completion *);
+extern void gui_completion_search (struct t_gui_completion *, int, char *, int, int);
+extern void gui_completion_print_log (struct t_gui_completion *);
-#endif /* completion.h */
+#endif /* gui-completion.h */
diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c
index 0a682f9e9..3ce9f0022 100644
--- a/src/gui/gui-history.c
+++ b/src/gui/gui-history.c
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* history.c: memorize commands or text */
+/* gui-history.c: memorize commands or text for buffers */
#ifdef HAVE_CONFIG_H
@@ -26,65 +26,63 @@
#include <stdlib.h>
#include <string.h>
-#include "weechat.h"
-#include "history.h"
-#include "util.h"
-#include "weeconfig.h"
-#include "../protocols/irc/irc.h"
-#include "../gui/gui.h"
+#include "../core/weechat.h"
+#include "../core/wee-config.h"
+#include "../core/wee-string.h"
+#include "gui-history.h"
-t_history *history_global = NULL;
-t_history *history_global_last = NULL;
-t_history *history_global_ptr = NULL;
+struct t_gui_history *history_global = NULL;
+struct t_gui_history *history_global_last = NULL;
+struct t_gui_history *history_global_ptr = NULL;
int num_history_global = 0;
/*
- * history_buffer_add: add a text/command to buffer's history
+ * gui_history_buffer_add: add a text/command to buffer's history
*/
void
-history_buffer_add (void *buffer, char *string)
+gui_history_buffer_add (struct t_gui_buffer *buffer, char *string)
{
- t_history *new_history, *ptr_history;
+ struct t_gui_history *new_history, *ptr_history;
if (!string)
return;
- if ( !((t_gui_buffer *)(buffer))->history
- || ( ((t_gui_buffer *)(buffer))->history
- && ascii_strcasecmp (((t_gui_buffer *)(buffer))->history->text, string) != 0))
+ if (!buffer->history
+ || (buffer->history
+ && (string_strcasecmp (buffer->history->text, string) != 0)))
{
- new_history = (t_history *)malloc (sizeof (t_history));
+ new_history = (struct t_gui_history *)malloc (sizeof (struct t_gui_history));
if (new_history)
{
new_history->text = strdup (string);
- if (cfg_log_hide_nickserv_pwd)
- irc_display_hide_password (new_history->text, 1);
+ /*if (cfg_log_hide_nickserv_pwd)
+ irc_display_hide_password (new_history->text, 1);*/
- if (((t_gui_buffer *)(buffer))->history)
- ((t_gui_buffer *)(buffer))->history->prev_history = new_history;
+ if (buffer->history)
+ buffer->history->prev_history = new_history;
else
- ((t_gui_buffer *)(buffer))->last_history = new_history;
- new_history->next_history = ((t_gui_buffer *)(buffer))->history;
+ buffer->last_history = new_history;
+ new_history->next_history = buffer->history;
new_history->prev_history = NULL;
- ((t_gui_buffer *)buffer)->history = new_history;
- ((t_gui_buffer *)buffer)->num_history++;
+ buffer->history = new_history;
+ buffer->num_history++;
/* remove one command if necessary */
if ((cfg_history_max_commands > 0)
- && (((t_gui_buffer *)(buffer))->num_history > cfg_history_max_commands))
+ && (buffer->num_history > cfg_history_max_commands))
{
- ptr_history = ((t_gui_buffer *)buffer)->last_history->prev_history;
- if (((t_gui_buffer *)buffer)->ptr_history == ((t_gui_buffer *)buffer)->last_history)
- ((t_gui_buffer *)buffer)->ptr_history = ptr_history;
- ((t_gui_buffer *)buffer)->last_history->prev_history->next_history = NULL;
- if (((t_gui_buffer *)buffer)->last_history->text)
- free (((t_gui_buffer *)buffer)->last_history->text);
- free (((t_gui_buffer *)buffer)->last_history);
- ((t_gui_buffer *)buffer)->last_history = ptr_history;
- ((t_gui_buffer *)(buffer))->num_history++;
+ ptr_history = buffer->last_history->prev_history;
+ if (buffer->ptr_history == buffer->last_history)
+ buffer->ptr_history = ptr_history;
+ buffer->last_history->prev_history->next_history = NULL;
+ if (buffer->last_history->text)
+ free (buffer->last_history->text);
+ free (buffer->last_history);
+ buffer->last_history = ptr_history;
+ buffer->num_history++;
}
}
}
@@ -95,23 +93,23 @@ history_buffer_add (void *buffer, char *string)
*/
void
-history_global_add (char *string)
+gui_history_global_add (char *string)
{
- t_history *new_history, *ptr_history;
+ struct t_gui_history *new_history, *ptr_history;
if (!string)
return;
if (!history_global
|| (history_global
- && ascii_strcasecmp (history_global->text, string) != 0))
+ && (string_strcasecmp (history_global->text, string) != 0)))
{
- new_history = (t_history *)malloc (sizeof (t_history));
+ new_history = (struct t_gui_history *)malloc (sizeof (struct t_gui_history));
if (new_history)
{
new_history->text = strdup (string);
- if (cfg_log_hide_nickserv_pwd)
- irc_display_hide_password (new_history->text, 1);
+ /*if (cfg_log_hide_nickserv_pwd)
+ irc_display_hide_password (new_history->text, 1);*/
if (history_global)
history_global->prev_history = new_history;
@@ -141,13 +139,13 @@ history_global_add (char *string)
}
/*
- * history_global_free: free global history
+ * gui_history_global_free: free global history
*/
void
-history_global_free ()
+gui_history_global_free ()
{
- t_history *ptr_history;
+ struct t_gui_history *ptr_history;
while (history_global)
{
@@ -165,24 +163,24 @@ history_global_free ()
/*
- * history_buffer_free: free history for a buffer
+ * gui_history_buffer_free: free history for a buffer
*/
void
-history_buffer_free (void *buffer)
+gui_history_buffer_free (struct t_gui_buffer *buffer)
{
- t_history *ptr_history;
+ struct t_gui_history *ptr_history;
- while (((t_gui_buffer *)(buffer))->history)
+ while (buffer->history)
{
- ptr_history = ((t_gui_buffer *)(buffer))->history->next_history;
- if (((t_gui_buffer *)(buffer))->history->text)
- free (((t_gui_buffer *)(buffer))->history->text);
- free (((t_gui_buffer *)(buffer))->history);
- ((t_gui_buffer *)(buffer))->history = ptr_history;
+ ptr_history = buffer->history->next_history;
+ if (buffer->history->text)
+ free (buffer->history->text);
+ free (buffer->history);
+ buffer->history = ptr_history;
}
- ((t_gui_buffer *)(buffer))->history = NULL;
- ((t_gui_buffer *)(buffer))->last_history = NULL;
- ((t_gui_buffer *)(buffer))->ptr_history = NULL;
- ((t_gui_buffer *)(buffer))->num_history = 0;
+ buffer->history = NULL;
+ buffer->last_history = NULL;
+ buffer->ptr_history = NULL;
+ buffer->num_history = 0;
}
diff --git a/src/gui/gui-history.h b/src/gui/gui-history.h
index 166893b49..aa9296813 100644
--- a/src/gui/gui-history.h
+++ b/src/gui/gui-history.h
@@ -17,25 +17,24 @@
*/
-#ifndef __WEECHAT_HISTORY_H
-#define __WEECHAT_HISTORY_H 1
+#ifndef __WEECHAT_GUI_HISTORY_H
+#define __WEECHAT_GUI_HISTORY_H 1
-typedef struct t_history t_history;
-
-struct t_history
+struct t_gui_history
{
- char *text; /* text or command (as entered by user) */
- t_history *next_history; /* link to next text/command */
- t_history *prev_history; /* link to previous text/command */
+ char *text; /* text or command (entered by user) */
+ struct t_gui_history *next_history;/* link to next text/command */
+ struct t_gui_history *prev_history;/* link to previous text/command */
};
-extern t_history *history_global;
-extern t_history *history_global_last;
-extern t_history *history_global_ptr;
+extern struct t_gui_history *history_global;
+extern struct t_gui_history *history_global_last;
+extern struct t_gui_history *history_global_ptr;
-extern void history_buffer_add (void *, char *);
-extern void history_global_add (char *);
-extern void history_global_free ();
-extern void history_buffer_free (void *);
+/* history functions (gui-history.c) */
+extern void gui_history_buffer_add (struct t_gui_buffer *, char *);
+extern void gui_history_global_add (char *);
+extern void gui_history_global_free ();
+extern void gui_history_buffer_free (struct t_gui_buffer *);
-#endif /* history.h */
+#endif /* gui-history.h */
diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c
index 10e37ece1..bda1111b1 100644
--- a/src/gui/gui-hotlist.c
+++ b/src/gui/gui-hotlist.c
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* hotlist.c: WeeChat hotlist (buffers with activity) */
+/* gui-hotlist.c: hotlist management (buffers with activity) */
#ifdef HAVE_CONFIG_H
@@ -26,30 +26,33 @@
#include <stdlib.h>
#include <string.h>
-#include "weechat.h"
-#include "hotlist.h"
-#include "log.h"
-#include "util.h"
-#include "weeconfig.h"
-#include "../protocols/irc/irc.h"
-#include "../gui/gui.h"
+#include "../core/weechat.h"
+#include "../core/wee-config.h"
+#include "../core/wee-log.h"
+#include "../core/wee-util.h"
+#include "gui-hotlist.h"
+#include "gui-window.h"
-t_weechat_hotlist *weechat_hotlist = NULL;
-t_weechat_hotlist *last_weechat_hotlist = NULL;
-t_gui_buffer *hotlist_initial_buffer = NULL;
+struct t_gui_hotlist *gui_hotlist = NULL;
+struct t_gui_hotlist *last_gui_hotlist = NULL;
+struct t_gui_buffer *gui_hotlist_initial_buffer = NULL;
+
+int gui_add_hotlist = 1; /* 0 is for temporarly disable */
+ /* hotlist add for all buffers */
/*
- * hotlist_search: find hotlist with buffer pointer
+ * gui_hotlist_search: find hotlist with buffer pointer
*/
-t_weechat_hotlist *
-hotlist_search (t_weechat_hotlist *hotlist, t_gui_buffer *buffer)
+struct t_gui_hotlist *
+gui_hotlist_search (struct t_gui_hotlist *hotlist, struct t_gui_buffer *buffer)
{
- t_weechat_hotlist *ptr_hotlist;
+ struct t_gui_hotlist *ptr_hotlist;
- for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist)
+ for (ptr_hotlist = hotlist; ptr_hotlist;
+ ptr_hotlist = ptr_hotlist->next_hotlist)
{
if (ptr_hotlist->buffer == buffer)
return ptr_hotlist;
@@ -58,13 +61,14 @@ hotlist_search (t_weechat_hotlist *hotlist, t_gui_buffer *buffer)
}
/*
- * hotlist_find_pos: find position for a inserting in hotlist (for sorting hotlist)
+ * gui_hotlist_find_pos: find position for a inserting in hotlist
+ * (for sorting hotlist)
*/
-t_weechat_hotlist *
-hotlist_find_pos (t_weechat_hotlist *hotlist, t_weechat_hotlist *new_hotlist)
+struct t_gui_hotlist *
+gui_hotlist_find_pos (struct t_gui_hotlist *hotlist, struct t_gui_hotlist *new_hotlist)
{
- t_weechat_hotlist *ptr_hotlist;
+ struct t_gui_hotlist *ptr_hotlist;
switch (cfg_look_hotlist_sort)
{
@@ -74,8 +78,8 @@ hotlist_find_pos (t_weechat_hotlist *hotlist, t_weechat_hotlist *new_hotlist)
{
if ((new_hotlist->priority > ptr_hotlist->priority)
|| ((new_hotlist->priority == ptr_hotlist->priority)
- && (get_timeval_diff (&(new_hotlist->creation_time),
- &(ptr_hotlist->creation_time)) > 0)))
+ && (util_get_timeval_diff (&(new_hotlist->creation_time),
+ &(ptr_hotlist->creation_time)) > 0)))
return ptr_hotlist;
}
break;
@@ -85,8 +89,8 @@ hotlist_find_pos (t_weechat_hotlist *hotlist, t_weechat_hotlist *new_hotlist)
{
if ((new_hotlist->priority > ptr_hotlist->priority)
|| ((new_hotlist->priority == ptr_hotlist->priority)
- && (get_timeval_diff (&(new_hotlist->creation_time),
- &(ptr_hotlist->creation_time)) < 0)))
+ && (util_get_timeval_diff (&(new_hotlist->creation_time),
+ &(ptr_hotlist->creation_time)) < 0)))
return ptr_hotlist;
}
break;
@@ -131,18 +135,19 @@ hotlist_find_pos (t_weechat_hotlist *hotlist, t_weechat_hotlist *new_hotlist)
}
/*
- * hotlist_add_hotlist: add new hotlist in list
+ * gui_hotlist_add_hotlist: add new hotlist in list
*/
void
-hotlist_add_hotlist (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist,
- t_weechat_hotlist *new_hotlist)
+gui_hotlist_add_hotlist (struct t_gui_hotlist **hotlist,
+ struct t_gui_hotlist **last_hotlist,
+ struct t_gui_hotlist *new_hotlist)
{
- t_weechat_hotlist *pos_hotlist;
+ struct t_gui_hotlist *pos_hotlist;
if (*hotlist)
{
- pos_hotlist = hotlist_find_pos (*hotlist, new_hotlist);
+ pos_hotlist = gui_hotlist_find_pos (*hotlist, new_hotlist);
if (pos_hotlist)
{
@@ -174,16 +179,15 @@ hotlist_add_hotlist (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotli
}
/*
- * hotlist_add: add a buffer to hotlist, with priority
- * if creation_time is NULL, current time is used
+ * gui_hotlist_add: add a buffer to hotlist, with priority
+ * if creation_time is NULL, current time is used
*/
void
-hotlist_add (int priority, struct timeval *creation_time,
- t_irc_server *server, t_gui_buffer *buffer,
- int allow_current_buffer)
+gui_hotlist_add (struct t_gui_buffer *buffer, int priority,
+ struct timeval *creation_time, int allow_current_buffer)
{
- t_weechat_hotlist *new_hotlist, *ptr_hotlist;
+ struct t_gui_hotlist *new_hotlist, *ptr_hotlist;
if (!buffer)
return;
@@ -193,19 +197,21 @@ hotlist_add (int priority, struct timeval *creation_time,
&& (!allow_current_buffer) && (!gui_buffer_is_scrolled (buffer)))
return;
- if ((ptr_hotlist = hotlist_search (weechat_hotlist, buffer)))
+ if ((ptr_hotlist = gui_hotlist_search (gui_hotlist, buffer)))
{
/* return if priority is greater or equal than the one to add */
if (ptr_hotlist->priority >= priority)
return;
/* remove buffer if present with lower priority and go on */
- hotlist_free (&weechat_hotlist, &last_weechat_hotlist, ptr_hotlist);
+ gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, ptr_hotlist);
}
- if ((new_hotlist = (t_weechat_hotlist *) malloc (sizeof (t_weechat_hotlist))) == NULL)
+ if ((new_hotlist = (struct t_gui_hotlist *) malloc (sizeof (struct t_gui_hotlist))) == NULL)
{
- gui_printf (NULL,
- _("%s cannot add a buffer to hotlist\n"), WEECHAT_ERROR);
+ weechat_log_printf (NULL,
+ _("%s not enough memory to add a buffer to "
+ "hotlist\n"),
+ WEECHAT_ERROR);
return;
}
@@ -215,29 +221,27 @@ hotlist_add (int priority, struct timeval *creation_time,
creation_time, sizeof (creation_time));
else
gettimeofday (&(new_hotlist->creation_time), NULL);
- new_hotlist->server = server;
new_hotlist->buffer = buffer;
new_hotlist->next_hotlist = NULL;
new_hotlist->prev_hotlist = NULL;
- hotlist_add_hotlist (&weechat_hotlist, &last_weechat_hotlist, new_hotlist);
+ gui_hotlist_add_hotlist (&gui_hotlist, &last_gui_hotlist, new_hotlist);
}
/*
- * hotlist_dup: duplicate hotlist element
+ * gui_hotlist_dup: duplicate hotlist element
*/
-t_weechat_hotlist *
-hotlist_dup (t_weechat_hotlist *hotlist)
+struct t_gui_hotlist *
+gui_hotlist_dup (struct t_gui_hotlist *hotlist)
{
- t_weechat_hotlist *new_hotlist;
+ struct t_gui_hotlist *new_hotlist;
- if ((new_hotlist = (t_weechat_hotlist *) malloc (sizeof (t_weechat_hotlist))))
+ if ((new_hotlist = (struct t_gui_hotlist *) malloc (sizeof (struct t_gui_hotlist))))
{
new_hotlist->priority = hotlist->priority;
memcpy (&(new_hotlist->creation_time), &(hotlist->creation_time),
sizeof (new_hotlist->creation_time));
- new_hotlist->server = hotlist->server;
new_hotlist->buffer = hotlist->buffer;
new_hotlist->prev_hotlist = NULL;
new_hotlist->next_hotlist = NULL;
@@ -247,40 +251,41 @@ hotlist_dup (t_weechat_hotlist *hotlist)
}
/*
- * hotlist_resort: resort hotlist with new sort type
+ * gui_hotlist_resort: resort hotlist with new sort type
*/
void
-hotlist_resort ()
+gui_hotlist_resort ()
{
- t_weechat_hotlist *new_hotlist, *last_new_hotlist;
- t_weechat_hotlist *ptr_hotlist, *element;
+ struct t_gui_hotlist *new_hotlist, *last_new_hotlist;
+ struct t_gui_hotlist *ptr_hotlist, *element;
/* copy and resort hotlist in new linked list */
new_hotlist = NULL;
last_new_hotlist = NULL;
- for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
+ for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
- element = hotlist_dup (ptr_hotlist);
- hotlist_add_hotlist (&new_hotlist, &last_new_hotlist, element);
+ element = gui_hotlist_dup (ptr_hotlist);
+ gui_hotlist_add_hotlist (&new_hotlist, &last_new_hotlist, element);
}
- hotlist_free_all (&weechat_hotlist, &last_weechat_hotlist);
+ gui_hotlist_free_all (&gui_hotlist, &last_gui_hotlist);
- weechat_hotlist = new_hotlist;
- last_weechat_hotlist = last_new_hotlist;
+ gui_hotlist = new_hotlist;
+ last_gui_hotlist = last_new_hotlist;
}
/*
- * hotlist_free: free a hotlist and remove it from hotlist queue
+ * gui_hotlist_free: free a hotlist and remove it from hotlist queue
*/
void
-hotlist_free (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist,
- t_weechat_hotlist *ptr_hotlist)
+gui_hotlist_free (struct t_gui_hotlist **hotlist,
+ struct t_gui_hotlist **last_hotlist,
+ struct t_gui_hotlist *ptr_hotlist)
{
- t_weechat_hotlist *new_hotlist;
+ struct t_gui_hotlist *new_hotlist;
/* remove hotlist from queue */
if (*last_hotlist == ptr_hotlist)
@@ -301,41 +306,44 @@ hotlist_free (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist,
}
/*
- * hotlist_free_all: free all hotlists
+ * gui_hotlist_free_all: free all hotlists
*/
void
-hotlist_free_all (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist)
+gui_hotlist_free_all (struct t_gui_hotlist **hotlist,
+ struct t_gui_hotlist **last_hotlist)
{
/* remove all hotlists */
while (*hotlist)
- hotlist_free (hotlist, last_hotlist, *hotlist);
+ {
+ gui_hotlist_free (hotlist, last_hotlist, *hotlist);
+ }
}
/*
- * hotlist_remove_buffer: remove a buffer from hotlist
+ * gui_hotlist_remove_buffer: remove a buffer from hotlist
*/
void
-hotlist_remove_buffer (t_gui_buffer *buffer)
+gui_hotlist_remove_buffer (struct t_gui_buffer *buffer)
{
- t_weechat_hotlist *pos_hotlist;
+ struct t_gui_hotlist *pos_hotlist;
- pos_hotlist = hotlist_search (weechat_hotlist, buffer);
+ pos_hotlist = gui_hotlist_search (gui_hotlist, buffer);
if (pos_hotlist)
- hotlist_free (&weechat_hotlist, &last_weechat_hotlist, pos_hotlist);
+ gui_hotlist_free (&gui_hotlist, &last_gui_hotlist, pos_hotlist);
}
/*
- * hotlist_print_log: print hotlist in log (usually for crash dump)
+ * gui_hotlist_print_log: print hotlist in log (usually for crash dump)
*/
void
-hotlist_print_log ()
+gui_hotlist_print_log ()
{
- t_weechat_hotlist *ptr_hotlist;
+ struct t_gui_hotlist *ptr_hotlist;
- for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
+ for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
weechat_log_printf ("[hotlist (addr:0x%X)]\n", ptr_hotlist);
@@ -343,7 +351,6 @@ hotlist_print_log ()
weechat_log_printf (" creation_time. . . . . : tv_sec:%d, tv_usec:%d\n",
ptr_hotlist->creation_time.tv_sec,
ptr_hotlist->creation_time.tv_usec);
- weechat_log_printf (" server . . . . . . . . : 0x%X\n", ptr_hotlist->server);
weechat_log_printf (" buffer . . . . . . . . : 0x%X\n", ptr_hotlist->buffer);
weechat_log_printf (" prev_hotlist . . . . . : 0x%X\n", ptr_hotlist->prev_hotlist);
weechat_log_printf (" next_hotlist . . . . . : 0x%X\n", ptr_hotlist->next_hotlist);
diff --git a/src/gui/gui-hotlist.h b/src/gui/gui-hotlist.h
index 2d66e7c71..9cb664c5c 100644
--- a/src/gui/gui-hotlist.h
+++ b/src/gui/gui-hotlist.h
@@ -17,38 +17,40 @@
*/
-#ifndef __WEECHAT_HOTLIST_H
-#define __WEECHAT_HOTLIST_H 1
+#ifndef __WEECHAT_GUI_HOTLIST_H
+#define __WEECHAT_GUI_HOTLIST_H 1
-#include "../protocols/irc/irc.h"
+#define GUI_HOTLIST_LOW 0
+#define GUI_HOTLIST_MSG 1
+#define GUI_HOTLIST_PRIVATE 2
+#define GUI_HOTLIST_HIGHLIGHT 3
-#define HOTLIST_LOW 0
-#define HOTLIST_MSG 1
-#define HOTLIST_PRIVATE 2
-#define HOTLIST_HIGHLIGHT 3
-
-typedef struct t_weechat_hotlist t_weechat_hotlist;
-
-struct t_weechat_hotlist
+struct t_gui_hotlist
{
- int priority; /* 0=crappy msg (join/part), 1=msg, */
- /* 2=pv, 3=nick highlight */
- struct timeval creation_time; /* time when entry was added */
- t_irc_server *server; /* associated server */
- t_gui_buffer *buffer; /* associated buffer */
- t_weechat_hotlist *prev_hotlist; /* link to previous hotlist */
- t_weechat_hotlist *next_hotlist; /* link to next hotlist */
+ int priority; /* 0=crappy msg (join/part), 1=msg, */
+ /* 2=pv, 3=nick highlight */
+ struct timeval creation_time; /* time when entry was added */
+ struct t_gui_buffer *buffer; /* associated buffer */
+ struct t_gui_hotlist *prev_hotlist;/* link to previous hotlist */
+ struct t_gui_hotlist *next_hotlist;/* link to next hotlist */
};
-extern t_weechat_hotlist *weechat_hotlist;
-extern t_weechat_hotlist *last_weechat_hotlist;
-extern t_gui_buffer *hotlist_initial_buffer;
+/* history variables */
+
+extern struct t_gui_hotlist *gui_hotlist;
+extern struct t_gui_hotlist *last_gui_hotlist;
+extern struct t_gui_buffer *gui_hotlist_initial_buffer;
+extern int gui_add_hotlist;
+
+/* hotlist functions */
-extern void hotlist_add (int, struct timeval *, t_irc_server *, t_gui_buffer *, int);
-extern void hotlist_resort ();
-extern void hotlist_free (t_weechat_hotlist **, t_weechat_hotlist **, t_weechat_hotlist *);
-extern void hotlist_free_all (t_weechat_hotlist **, t_weechat_hotlist **);
-extern void hotlist_remove_buffer (t_gui_buffer *);
-extern void hotlist_print_log ();
+extern void gui_hotlist_add (struct t_gui_buffer *, int, struct timeval *, int);
+extern void gui_hotlist_resort ();
+extern void gui_hotlist_free (struct t_gui_hotlist **, struct t_gui_hotlist **,
+ struct t_gui_hotlist *);
+extern void gui_hotlist_free_all (struct t_gui_hotlist **,
+ struct t_gui_hotlist **);
+extern void gui_hotlist_remove_buffer (struct t_gui_buffer *);
+extern void gui_hotlist_print_log ();
-#endif /* hotlist.h */
+#endif /* gui-hotlist.h */
diff --git a/src/gui/gui-infobar.c b/src/gui/gui-infobar.c
new file mode 100644
index 000000000..b5a9666f7
--- /dev/null
+++ b/src/gui/gui-infobar.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* gui-infobar.c: infobar functions, used by all GUI */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "../core/weechat.h"
+#include "../core/wee-log.h"
+#include "gui-infobar.h"
+#include "gui-color.h"
+#include "gui-window.h"
+
+
+t_gui_infobar *gui_infobar; /* pointer to infobar content */
+
+
+/*
+ * gui_infobar_printf: display message in infobar
+ */
+
+void
+gui_infobar_printf (int time_displayed, int color, char *message, ...)
+{
+ static char buf[1024];
+ va_list argptr;
+ t_gui_infobar *ptr_infobar;
+ char *buf2, *ptr_buf, *pos;
+
+ va_start (argptr, message);
+ vsnprintf (buf, sizeof (buf) - 1, message, argptr);
+ va_end (argptr);
+
+ ptr_infobar = (t_gui_infobar *)malloc (sizeof (t_gui_infobar));
+ if (ptr_infobar)
+ {
+ buf2 = (char *)gui_color_decode ((unsigned char *)buf);
+ ptr_buf = (buf2) ? buf2 : buf;
+
+ ptr_infobar->color = color;
+ ptr_infobar->text = strdup (ptr_buf);
+ pos = strchr (ptr_infobar->text, '\n');
+ if (pos)
+ pos[0] = '\0';
+ ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed;
+ ptr_infobar->next_infobar = gui_infobar;
+ gui_infobar = ptr_infobar;
+ gui_infobar_draw (gui_current_window->buffer, 1);
+ if (buf2)
+ free (buf2);
+ }
+ else
+ weechat_log_printf (_("%s not enough memory for infobar message\n"),
+ WEECHAT_ERROR);
+}
+
+/*
+ * gui_infobar_remove: remove last displayed message in infobar
+ */
+
+void
+gui_infobar_remove ()
+{
+ t_gui_infobar *new_infobar;
+
+ if (gui_infobar)
+ {
+ new_infobar = gui_infobar->next_infobar;
+ if (gui_infobar->text)
+ free (gui_infobar->text);
+ free (gui_infobar);
+ gui_infobar = new_infobar;
+ }
+}
+
+/*
+ * gui_infobar_remove_all: remove last displayed message in infobar
+ */
+
+void
+gui_infobar_remove_all ()
+{
+ while (gui_infobar)
+ {
+ gui_infobar_remove ();
+ }
+}
diff --git a/src/gui/gui-infobar.h b/src/gui/gui-infobar.h
new file mode 100644
index 000000000..57baa8f45
--- /dev/null
+++ b/src/gui/gui-infobar.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_GUI_INFOBAR_H
+#define __WEECHAT_GUI_INFOBAR_H 1
+
+#include "gui-buffer.h"
+
+typedef struct t_gui_infobar t_gui_infobar;
+
+struct t_gui_infobar
+{
+ int color; /* text color */
+ char *text; /* infobar text */
+ int remaining_time; /* delay (sec) before erasing this text */
+ /* if < 0, text is never erased (except */
+ /* by user action to erase it) */
+ t_gui_infobar *next_infobar; /* next message for infobar */
+};
+
+/* infobar variables */
+
+extern t_gui_infobar *gui_infobar;
+
+/* infobar functions */
+
+extern void gui_infobar_printf (int, int, char *, ...);
+extern void gui_infobar_remove ();
+extern void gui_infobar_remove_all ();
+
+/* infobar functions (GUI dependent) */
+
+extern void gui_infobar_draw_time (struct t_gui_buffer *);
+extern void gui_infobar_draw (struct t_gui_buffer *, int);
+
+#endif /* gui-infobar.h */
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
new file mode 100644
index 000000000..cec1b2eb3
--- /dev/null
+++ b/src/gui/gui-input.c
@@ -0,0 +1,522 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* gui-input.c: input functions, used by all GUI */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "../core/weechat.h"
+#include "../core/wee-config.h"
+#include "../core/wee-utf8.h"
+#include "../plugins/plugin.h"
+#include "gui-input.h"
+#include "gui-completion.h"
+#include "gui-window.h"
+
+
+char *gui_input_clipboard = NULL; /* clipboard content */
+
+
+/*
+ * gui_input_optimize_size: optimize input buffer size by adding
+ * or deleting data block (predefined size)
+ */
+
+void
+gui_input_optimize_size (struct t_gui_buffer *buffer)
+{
+ int optimal_size;
+
+ if (buffer->input)
+ {
+ optimal_size = ((buffer->input_buffer_size / GUI_BUFFER_INPUT_BLOCK_SIZE) *
+ GUI_BUFFER_INPUT_BLOCK_SIZE) + GUI_BUFFER_INPUT_BLOCK_SIZE;
+ if (buffer->input_buffer_alloc != optimal_size)
+ {
+ buffer->input_buffer_alloc = optimal_size;
+ buffer->input_buffer = realloc (buffer->input_buffer, optimal_size);
+ buffer->input_buffer_color_mask = realloc (buffer->input_buffer_color_mask,
+ optimal_size);
+ }
+ }
+}
+
+/*
+ * gui_input_init_color_mask: initialize color mask for input buffer
+ */
+
+void
+gui_input_init_color_mask (struct t_gui_buffer *buffer)
+{
+ int i;
+
+ if (buffer->input)
+ {
+ for (i = 0; i < buffer->input_buffer_size; i++)
+ buffer->input_buffer_color_mask[i] = ' ';
+ buffer->input_buffer_color_mask[buffer->input_buffer_size] = '\0';
+ }
+}
+
+/*
+ * gui_input_move: move data in input buffer
+ */
+
+void
+gui_input_move (struct t_gui_buffer *buffer, char *target, char *source, int size)
+{
+ int pos_source, pos_target;
+
+ pos_target = target - buffer->input_buffer;
+ pos_source = source - buffer->input_buffer;
+
+ memmove (target, source, size);
+ memmove (buffer->input_buffer_color_mask + pos_target,
+ buffer->input_buffer_color_mask + pos_source, size);
+}
+
+/*
+ * gui_input_insert_string: insert a string into the input buffer
+ * if pos == -1, string is inserted at cursor position
+ * return: number of chars inserted
+ * (may be different of strlen if UTF-8 string)
+ */
+
+int
+gui_input_insert_string (struct t_gui_buffer *buffer, char *string, int pos)
+{
+ int i, pos_start, size, length;
+ char *ptr_start;
+ char *buffer_before_insert, *string2;
+
+ if (buffer->input)
+ {
+ buffer_before_insert =
+ (buffer->input_buffer) ?
+ strdup (buffer->input_buffer) : strdup ("");
+
+ if (pos == -1)
+ pos = buffer->input_buffer_pos;
+
+ size = strlen (string);
+ length = utf8_strlen (string);
+
+ /* increase buffer size */
+ buffer->input_buffer_size += size;
+ buffer->input_buffer_length += length;
+ gui_input_optimize_size (buffer);
+ buffer->input_buffer[buffer->input_buffer_size] = '\0';
+ buffer->input_buffer_color_mask[buffer->input_buffer_size] = '\0';
+
+ /* move end of string to the right */
+ ptr_start = utf8_add_offset (buffer->input_buffer, pos);
+ pos_start = ptr_start - buffer->input_buffer;
+ memmove (ptr_start + size, ptr_start, strlen (ptr_start));
+ memmove (buffer->input_buffer_color_mask + pos_start + size,
+ buffer->input_buffer_color_mask + pos_start,
+ strlen (buffer->input_buffer_color_mask + pos_start));
+
+ /* insert new string */
+ ptr_start = utf8_add_offset (buffer->input_buffer, pos);
+ pos_start = ptr_start - buffer->input_buffer;
+ strncpy (ptr_start, string, size);
+ for (i = 0; i < size; i++)
+ {
+ buffer->input_buffer_color_mask[pos_start + i] = ' ';
+ }
+
+ buffer->input_buffer_pos += length;
+
+ string2 = (char *) malloc (size + 2);
+ if (string2)
+ {
+ snprintf (string2, size + 2, "*%s", string);
+ /* TODO: execute keyboard hooks */
+ /*(void) plugin_keyboard_handler_exec (string2,
+ buffer_before_insert,
+ buffer->input_buffer);*/
+ free (string2);
+ }
+ if (buffer_before_insert)
+ free (buffer_before_insert);
+
+ return length;
+ }
+ return 0;
+}
+
+/*
+ * gui_input_complete: complete a word in input buffer
+ */
+
+void
+gui_input_complete (struct t_gui_buffer *buffer)
+{
+ int i;
+
+ if (!buffer->completion)
+ return;
+
+ if (buffer->completion->word_found)
+ {
+ /* replace word with new completed word into input buffer */
+ if (buffer->completion->diff_size > 0)
+ {
+ buffer->input_buffer_size +=
+ buffer->completion->diff_size;
+ buffer->input_buffer_length +=
+ buffer->completion->diff_length;
+ gui_input_optimize_size (buffer);
+ buffer->input_buffer[buffer->input_buffer_size] = '\0';
+ buffer->input_buffer_color_mask[buffer->input_buffer_size] = '\0';
+ for (i = buffer->input_buffer_size - 1;
+ i >= buffer->completion->position_replace +
+ (int)strlen (buffer->completion->word_found); i--)
+ {
+ buffer->input_buffer[i] =
+ buffer->input_buffer[i - buffer->completion->diff_size];
+ buffer->input_buffer_color_mask[i] =
+ buffer->input_buffer_color_mask[i - buffer->completion->diff_size];
+ }
+ }
+ else
+ {
+ for (i = buffer->completion->position_replace +
+ strlen (buffer->completion->word_found);
+ i < buffer->input_buffer_size; i++)
+ {
+ buffer->input_buffer[i] =
+ buffer->input_buffer[i - buffer->completion->diff_size];
+ buffer->input_buffer_color_mask[i] =
+ buffer->input_buffer_color_mask[i - buffer->completion->diff_size];
+ }
+ buffer->input_buffer_size += buffer->completion->diff_size;
+ buffer->input_buffer_length += buffer->completion->diff_length;
+ gui_input_optimize_size (buffer);
+ buffer->input_buffer[buffer->input_buffer_size] = '\0';
+ buffer->input_buffer_color_mask[buffer->input_buffer_size] = '\0';
+ }
+
+ strncpy (buffer->input_buffer + buffer->completion->position_replace,
+ buffer->completion->word_found,
+ strlen (buffer->completion->word_found));
+ for (i = 0; i < (int)strlen (buffer->completion->word_found); i++)
+ {
+ buffer->input_buffer_color_mask[buffer->completion->position_replace + i] = ' ';
+ }
+ buffer->input_buffer_pos =
+ utf8_pos (buffer->input_buffer,
+ buffer->completion->position_replace) +
+ utf8_strlen (buffer->completion->word_found);
+
+ /* position is < 0 this means only one word was found to complete,
+ so reinit to stop completion */
+ if (buffer->completion->position >= 0)
+ buffer->completion->position = utf8_real_pos (buffer->input_buffer,
+ buffer->input_buffer_pos);
+
+ /* add nick completor if position 0 and completing nick */
+ if ((buffer->completion->base_word_pos == 0)
+ && (buffer->completion->context == GUI_COMPLETION_NICK))
+ {
+ if (strncmp (utf8_add_offset (buffer->input_buffer,
+ buffer->input_buffer_pos),
+ cfg_look_nick_completor, strlen (cfg_look_nick_completor)) != 0)
+ gui_input_insert_string (buffer, cfg_look_nick_completor,
+ buffer->input_buffer_pos);
+ else
+ buffer->input_buffer_pos += utf8_strlen (cfg_look_nick_completor);
+ if (buffer->completion->position >= 0)
+ buffer->completion->position += strlen (cfg_look_nick_completor);
+ if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer,
+ buffer->input_buffer_pos)] != ' ')
+ gui_input_insert_string (buffer, " ",
+ buffer->input_buffer_pos);
+ else
+ buffer->input_buffer_pos++;
+ if (buffer->completion->position >= 0)
+ buffer->completion->position++;
+ }
+ else
+ {
+ /* add space or completor to the end of completion, if needed */
+ if (buffer->completion->add_space)
+ {
+ if (buffer->input_buffer[utf8_real_pos (buffer->input_buffer,
+ buffer->input_buffer_pos)] != ' ')
+ gui_input_insert_string (buffer, " ",
+ buffer->input_buffer_pos);
+ else
+ buffer->input_buffer_pos++;
+ if (buffer->completion->position >= 0)
+ buffer->completion->position++;
+ }
+ }
+ gui_input_draw (buffer, 0);
+ }
+}
+
+/*
+ * gui_input_delete_line: delete entire input line
+ */
+
+void
+gui_input_delete_line (struct t_gui_buffer *buffer)
+{
+ if (gui_current_window->buffer->input)
+ {
+ buffer->input_buffer[0] = '\0';
+ buffer->input_buffer_color_mask[0] = '\0';
+ buffer->input_buffer_size = 0;
+ buffer->input_buffer_length = 0;
+ buffer->input_buffer_pos = 0;
+ gui_input_optimize_size (buffer);
+ buffer->completion->position = -1;
+ }
+}
+
+/*
+ * gui_input_get_prompt_length: return input prompt length (displayed on screen)
+ */
+
+int
+gui_input_get_prompt_length (struct t_gui_buffer *buffer)
+{
+ char *pos, saved_char;
+ int char_size, length;
+
+ if (buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
+ {
+ if (buffer->text_search_exact)
+ return utf8_strlen_screen (_("Text search (exact): "));
+ else
+ return utf8_strlen_screen (_("Text search: "));
+ }
+
+ length = 0;
+ pos = cfg_look_input_format;
+ while (pos && pos[0])
+ {
+ switch (pos[0])
+ {
+ case '%':
+ pos++;
+ switch (pos[0])
+ {
+ case 'c': /* buffer name */
+ length += utf8_strlen_screen (buffer->name);
+ pos++;
+ break;
+ case 'm': // nick modes
+ /*if (GUI_SERVER(buffer) && GUI_SERVER(buffer)->is_connected)
+ {
+ if (GUI_SERVER(buffer)->nick_modes
+ && GUI_SERVER(buffer)->nick_modes[0])
+ length += strlen (GUI_SERVER(buffer)->nick_modes);
+ }*/
+ pos++;
+ break;
+ case 'n': /* nick */
+ if (buffer->input_nick)
+ length += utf8_strlen_screen (buffer->input_nick);
+ pos++;
+ break;
+ default:
+ length++;
+ if (pos[0])
+ {
+ if (pos[0] == '%')
+ pos++;
+ else
+ {
+ length++;
+ pos += utf8_char_size (pos);
+ }
+ }
+ break;
+ }
+ break;
+ default:
+ char_size = utf8_char_size (pos);
+ saved_char = pos[char_size];
+ pos[char_size] = '\0';
+ length += utf8_strlen_screen (pos);
+ pos[char_size] = saved_char;
+ pos += char_size;
+ break;
+ }
+ }
+ return length;
+}
+
+/*
+ * gui_exec_action_dcc: execute an action on a DCC after a user input
+ * return -1 if DCC buffer was closed due to action,
+ * 0 otherwise
+ */
+
+void
+gui_exec_action_dcc (struct t_gui_window *window, char *actions)
+{
+ (void) window;
+ (void) actions;
+ /*t_irc_dcc *dcc_selected, *ptr_dcc, *ptr_dcc_next;
+ struct t_gui_window *ptr_win;
+ struct t_gui_buffer *ptr_buffer;
+
+ while (actions[0])
+ {
+ if (actions[0] >= 32)
+ {
+ dcc_selected = (window->dcc_selected) ?
+ (t_irc_dcc *) window->dcc_selected : irc_dcc_list;
+
+ switch (actions[0])
+ {
+ // accept DCC
+ case 'a':
+ case 'A':
+ if (dcc_selected
+ && (IRC_DCC_IS_RECV(dcc_selected->status))
+ && (dcc_selected->status == IRC_DCC_WAITING))
+ {
+ irc_dcc_accept (dcc_selected);
+ }
+ break;
+ // cancel DCC
+ case 'c':
+ case 'C':
+ if (dcc_selected
+ && (!IRC_DCC_ENDED(dcc_selected->status)))
+ {
+ irc_dcc_close (dcc_selected, IRC_DCC_ABORTED);
+ gui_window_redraw_buffer (window->buffer);
+ }
+ break;
+ // purge old DCC
+ case 'p':
+ case 'P':
+ window->dcc_first = NULL;
+ window->dcc_selected = NULL;
+ window->dcc_last_displayed = NULL;
+ ptr_dcc = irc_dcc_list;
+ while (ptr_dcc)
+ {
+ ptr_dcc_next = ptr_dcc->next_dcc;
+ if (IRC_DCC_ENDED(ptr_dcc->status))
+ irc_dcc_free (ptr_dcc);
+ ptr_dcc = ptr_dcc_next;
+ }
+ gui_window_redraw_buffer (window->buffer);
+ break;
+ // close DCC window
+ case 'q':
+ case 'Q':
+ if (gui_buffer_before_dcc)
+ {
+ ptr_buffer = window->buffer;
+ for (ptr_win = gui_windows; ptr_win;
+ ptr_win = ptr_win->next_window)
+ {
+ if (ptr_win->buffer == ptr_buffer)
+ gui_window_switch_to_buffer (ptr_win,
+ gui_buffer_before_dcc);
+ }
+ gui_buffer_free (ptr_buffer, 0);
+ }
+ else
+ gui_buffer_free (window->buffer, 1);
+ gui_window_redraw_buffer (window->buffer);
+ return;
+ break;
+ // remove from DCC list
+ case 'r':
+ case 'R':
+ if (dcc_selected
+ && (IRC_DCC_ENDED(dcc_selected->status)))
+ {
+ if (dcc_selected->next_dcc)
+ window->dcc_selected = dcc_selected->next_dcc;
+ else
+ window->dcc_selected = NULL;
+ irc_dcc_free (dcc_selected);
+ gui_window_redraw_buffer (window->buffer);
+ }
+ break;
+ }
+ }
+ actions = utf8_next_char (actions);
+ }*/
+}
+
+/*
+ * gui_exec_action_raw_data: execute an action on raw IRC data
+ * return -1 if raw IRC data was closed due to action,
+ * 0 otherwise
+ */
+
+void
+gui_exec_action_raw_data (struct t_gui_window *window, char *actions)
+{
+ struct t_gui_window *ptr_win;
+ struct t_gui_buffer *ptr_buffer;
+
+ while (actions[0])
+ {
+ if (actions[0] >= 32)
+ {
+ switch (actions[0])
+ {
+ /* close raw IRC data */
+ case 'c':
+ case 'C':
+ gui_buffer_clear (window->buffer);
+ gui_window_redraw_buffer (window->buffer);
+ return;
+ break;
+ /* close raw IRC data */
+ case 'q':
+ case 'Q':
+ if (gui_buffer_before_raw_data)
+ {
+ ptr_buffer = window->buffer;
+ for (ptr_win = gui_windows; ptr_win;
+ ptr_win = ptr_win->next_window)
+ {
+ if (ptr_win->buffer == ptr_buffer)
+ gui_window_switch_to_buffer (ptr_win,
+ gui_buffer_before_raw_data);
+ }
+ gui_buffer_free (ptr_buffer, 0);
+ }
+ else
+ gui_buffer_free (window->buffer, 1);
+ gui_window_redraw_buffer (window->buffer);
+ return;
+ break;
+ }
+ }
+ actions = utf8_next_char (actions);
+ }
+}
diff --git a/src/gui/gtk/gui-gtk-panel.c b/src/gui/gui-input.h
index 90cbdc875..54aebd3da 100644
--- a/src/gui/gtk/gui-gtk-panel.c
+++ b/src/gui/gui-input.h
@@ -16,45 +16,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* gui-gtk-panel.c: panel functions for Gtk GUI */
+#ifndef __WEECHAT_GUI_INPUT_H
+#define __WEECHAT_GUI_INPUT_H 1
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "gui-buffer.h"
-#include <stdlib.h>
+/* input variables */
-#include "../../common/weechat.h"
-#include "../gui.h"
-#include "gui-gtk.h"
+extern char *gui_input_clipboard;
+/* input functions */
-/*
- * 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;
-}
+extern void gui_input_optimize_size (struct t_gui_buffer *);
+extern void gui_input_init_color_mask (struct t_gui_buffer *);
+extern void gui_input_move (struct t_gui_buffer *, char *, char *, int );
+extern int gui_input_insert_string (struct t_gui_buffer *, char *, int);
+extern void gui_input_complete (struct t_gui_buffer *);
+extern void gui_input_delete_line (struct t_gui_buffer *);
+extern int gui_input_get_prompt_length (struct t_gui_buffer *);
-/*
- * gui_panel_window_free: delete a panel window
- */
+/* input functions (GUI dependent) */
-void
-gui_panel_window_free (void *panel_win)
-{
- t_gui_panel_window *ptr_panel_win;
+extern void gui_input_draw (struct t_gui_buffer *, int);
- ptr_panel_win = (t_gui_panel_window *)panel_win;
-
- free (ptr_panel_win);
-}
+#endif /* gui-input.h */
diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c
index 25f0ab005..218b286f8 100644
--- a/src/gui/gui-keyboard.c
+++ b/src/gui/gui-keyboard.c
@@ -27,31 +27,35 @@
#include <string.h>
#include <ctype.h>
-#include "../common/weechat.h"
-#include "gui.h"
-#include "../common/command.h"
-#include "../common/log.h"
-#include "../common/util.h"
-
-#ifdef PLUGINS
-#include "../plugins/plugins.h"
-#endif
+#include "../core/weechat.h"
+#include "../core/wee-command.h"
+#include "../core/wee-input.h"
+#include "../core/wee-log.h"
+#include "../core/wee-string.h"
+#include "../plugins/plugin.h"
+#include "gui-keyboard.h"
+#include "gui-action.h"
+#include "gui-completion.h"
+#include "gui-input.h"
+#include "gui-window.h"
+
+t_gui_key *gui_keys = NULL; /* key bindings */
+t_gui_key *last_gui_key = NULL; /* last key binding */
-t_gui_key *gui_keys = NULL; /* key bindings */
-t_gui_key *last_gui_key = NULL; /* last key binding */
+char gui_key_combo_buffer[128]; /* buffer used for combos */
+int gui_key_grab = 0; /* 1 if grab mode enabled (alt-k) */
+int gui_key_grab_count = 0; /* number of keys pressed in grab mode */
-char gui_key_combo_buffer[128]; /* buffer used for combos */
-int gui_key_grab = 0; /* 1 if grab mode enabled (alt-k pressed) */
-int gui_key_grab_count = 0; /* number of keys pressed in grab mode */
+int *gui_keyboard_buffer = NULL; /* input buffer (for paste detection) */
+int gui_keyboard_buffer_alloc = 0; /* input buffer allocated size */
+int gui_keyboard_buffer_size = 0; /* input buffer size in bytes */
-int *gui_keyboard_buffer = NULL; /* input buffer (for paste detection) */
-int gui_keyboard_buffer_alloc = 0; /* input buffer allocated size */
-int gui_keyboard_buffer_size = 0; /* input buffer size in bytes */
+int gui_keyboard_paste_pending = 0; /* 1 is big paste was detected and */
+ /* WeeChat is asking user what to do */
+int gui_keyboard_paste_lines = 0; /* number of lines for pending paste */
-int gui_keyboard_paste_pending = 0; /* 1 is big paste was detected and */
- /* WeeChat is asking user what to do */
-int gui_keyboard_paste_lines = 0; /* number of lines for pending paste */
+time_t gui_keyboard_last_activity_time = 0; /* last activity time (key) */
t_gui_key_function gui_key_functions[] =
{ { "return", gui_action_return,
@@ -201,10 +205,11 @@ gui_keyboard_grab_end ()
if (expanded_key)
{
- if (gui_current_window->buffer->has_input)
+ if (gui_current_window->buffer->input)
{
- gui_insert_string_input (gui_current_window, expanded_key, -1);
- gui_current_window->buffer->completion.position = -1;
+ gui_input_insert_string (gui_current_window->buffer, expanded_key, -1);
+ if (gui_current_window->buffer->completion)
+ gui_current_window->buffer->completion->position = -1;
gui_input_draw (gui_current_window->buffer, 0);
}
free (expanded_key);
@@ -231,17 +236,17 @@ gui_keyboard_get_internal_code (char *key)
result[0] = '\0';
while (key[0])
{
- if (ascii_strncasecmp (key, "meta2-", 6) == 0)
+ if (string_strncasecmp (key, "meta2-", 6) == 0)
{
strcat (result, "^[[");
key += 6;
}
- if (ascii_strncasecmp (key, "meta-", 5) == 0)
+ if (string_strncasecmp (key, "meta-", 5) == 0)
{
strcat (result, "^[");
key += 5;
}
- else if (ascii_strncasecmp (key, "ctrl-", 5) == 0)
+ else if (string_strncasecmp (key, "ctrl-", 5) == 0)
{
strcat (result, "^");
key += 5;
@@ -274,12 +279,12 @@ gui_keyboard_get_expanded_name (char *key)
result[0] = '\0';
while (key[0])
{
- if (ascii_strncasecmp (key, "^[[", 3) == 0)
+ if (string_strncasecmp (key, "^[[", 3) == 0)
{
strcat (result, "meta2-");
key += 3;
}
- if (ascii_strncasecmp (key, "^[", 2) == 0)
+ if (string_strncasecmp (key, "^[", 2) == 0)
{
strcat (result, "meta-");
key += 2;
@@ -313,7 +318,7 @@ gui_keyboard_find_pos (t_gui_key *key)
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
{
- if (ascii_strcasecmp (key->key, ptr_key->key) < 0)
+ if (string_strcasecmp (key->key, ptr_key->key) < 0)
return ptr_key;
}
return NULL;
@@ -414,7 +419,7 @@ gui_keyboard_search (char *key)
for (ptr_key = gui_keys; ptr_key; ptr_key = ptr_key->next_key)
{
- if (ascii_strcasecmp (ptr_key->key, key) == 0)
+ if (string_strcasecmp (ptr_key->key, key) == 0)
return ptr_key;
}
@@ -471,7 +476,7 @@ gui_keyboard_function_search_by_name (char *name)
i = 0;
while (gui_key_functions[i].function_name)
{
- if (ascii_strcasecmp (gui_key_functions[i].function_name, name) == 0)
+ if (string_strcasecmp (gui_key_functions[i].function_name, name) == 0)
return gui_key_functions[i].function;
i++;
}
@@ -615,7 +620,7 @@ gui_keyboard_pressed (char *key_str)
ptr_key = gui_keyboard_search_part (gui_key_combo_buffer);
if (ptr_key)
{
- if (ascii_strcasecmp (ptr_key->key, gui_key_combo_buffer) == 0)
+ if (string_strcasecmp (ptr_key->key, gui_key_combo_buffer) == 0)
{
/* exact combo found => execute function or command */
buffer_before_key =
@@ -624,30 +629,30 @@ gui_keyboard_pressed (char *key_str)
gui_key_combo_buffer[0] = '\0';
if (ptr_key->command)
{
- commands = split_multi_command (ptr_key->command, ';');
+ commands = string_split_multi_command (ptr_key->command, ';');
if (commands)
{
for (ptr_cmd = commands; *ptr_cmd; ptr_cmd++)
{
- user_command (GUI_SERVER(gui_current_window->buffer),
- GUI_CHANNEL(gui_current_window->buffer),
- *ptr_cmd, 0);
+ input_data (gui_current_window->buffer,
+ *ptr_cmd, 0);
}
- free_multi_command (commands);
+ string_free_multi_command (commands);
}
}
else
- (void)(ptr_key->function)(gui_current_window, ptr_key->args);
-#ifdef PLUGINS
+ (void)(ptr_key->function)(ptr_key->args);
+
if (gui_current_window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)
{
- (void) plugin_keyboard_handler_exec (
+ /* TODO: execute keyboard hooks */
+ /*(void) plugin_keyboard_handler_exec (
(ptr_key->command) ?
ptr_key->command : gui_keyboard_function_search_by_ptr (ptr_key->function),
buffer_before_key,
- gui_current_window->buffer->input_buffer);
+ gui_current_window->buffer->input_buffer);*/
}
-#endif
+
if (buffer_before_key)
free (buffer_before_key);
}
diff --git a/src/gui/gui-keyboard.h b/src/gui/gui-keyboard.h
index 4ffaaa480..c7e048edd 100644
--- a/src/gui/gui-keyboard.h
+++ b/src/gui/gui-keyboard.h
@@ -22,9 +22,9 @@
#define GUI_KEYBOARD_BUFFER_BLOCK_SIZE 256
-/* key structures */
+/* keyboard structures */
-typedef void (t_gui_key_func)(t_gui_window *, char *);
+typedef void (t_gui_key_func)(char *);
typedef struct t_gui_key t_gui_key;
@@ -47,7 +47,7 @@ struct t_gui_key_function
char *description; /* description of function */
};
-/* key variables */
+/* keyboard variables */
extern t_gui_key *gui_keys;
extern t_gui_key *last_gui_key;
@@ -58,5 +58,31 @@ extern int gui_key_grab_count;
extern int *gui_keyboard_buffer;
extern int gui_keyboard_buffer_size;
extern int gui_keyboard_paste_pending;
+extern time_t gui_keyboard_last_activity_time;
+
+/* keyboard functions */
+
+extern void gui_keyboard_init ();
+extern void gui_keyboard_grab_init ();
+extern void gui_keyboard_grab_end ();
+extern char *gui_keyboard_get_internal_code (char *);
+extern char *gui_keyboard_get_expanded_name (char *);
+extern t_gui_key *gui_keyboard_search (char *);
+extern t_gui_key_func *gui_keyboard_function_search_by_name (char *);
+extern char *gui_keyboard_function_search_by_ptr (t_gui_key_func *);
+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 ();
+extern void gui_keyboard_buffer_reset ();
+extern void gui_keyboard_buffer_add (int);
+extern int gui_keyboard_get_paste_lines ();
+extern void gui_keyboard_paste_accept ();
+extern void gui_keyboard_paste_cancel ();
+
+/* keyboard functions (GUI dependent) */
+
+extern void gui_keyboard_default_bindings ();
#endif /* gui-keyboard.h */
diff --git a/src/gui/gui-log.c b/src/gui/gui-log.c
index d8a51c202..bc2b87a91 100644
--- a/src/gui/gui-log.c
+++ b/src/gui/gui-log.c
@@ -27,11 +27,11 @@
#include <unistd.h>
#include <string.h>
-#include "../common/weechat.h"
-#include "gui.h"
-#include "../common/log.h"
-#include "../common/util.h"
-#include "../common/weeconfig.h"
+#include "../core/weechat.h"
+#include "../core/wee-config.h"
+#include "../core/wee-log.h"
+#include "../core/wee-string.h"
+#include "gui-log.h"
/*
@@ -39,7 +39,7 @@
*/
void
-gui_log_write_date (t_gui_buffer *buffer)
+gui_log_write_date (struct t_gui_buffer *buffer)
{
static char buf_time[256];
static time_t seconds;
@@ -51,7 +51,8 @@ gui_log_write_date (t_gui_buffer *buffer)
date_tmp = localtime (&seconds);
if (date_tmp)
{
- strftime (buf_time, sizeof (buf_time) - 1, cfg_log_timestamp, date_tmp);
+ strftime (buf_time, sizeof (buf_time) - 1,
+ cfg_log_time_format, date_tmp);
fprintf (buffer->log_file, "%s ", buf_time);
fflush (buffer->log_file);
}
@@ -63,15 +64,15 @@ gui_log_write_date (t_gui_buffer *buffer)
*/
void
-gui_log_write_line (t_gui_buffer *buffer, char *message)
+gui_log_write_line (struct t_gui_buffer *buffer, char *message)
{
char *msg_no_color;
if (buffer->log_file)
{
- msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0, 0);
- weechat_iconv_fprintf (buffer->log_file,
- "%s\n", (msg_no_color) ? msg_no_color : message);
+ msg_no_color = (char *)gui_color_decode ((unsigned char *)message);
+ string_iconv_fprintf (buffer->log_file,
+ "%s\n", (msg_no_color) ? msg_no_color : message);
fflush (buffer->log_file);
if (msg_no_color)
free (msg_no_color);
@@ -83,15 +84,15 @@ gui_log_write_line (t_gui_buffer *buffer, char *message)
*/
void
-gui_log_write (t_gui_buffer *buffer, char *message)
+gui_log_write (struct t_gui_buffer *buffer, char *message)
{
char *msg_no_color;
if (buffer->log_file)
{
- msg_no_color = (char *)gui_color_decode ((unsigned char *)message, 0, 0);
- weechat_iconv_fprintf (buffer->log_file,
- "%s", (msg_no_color) ? msg_no_color : message);
+ msg_no_color = (char *)gui_color_decode ((unsigned char *)message);
+ string_iconv_fprintf (buffer->log_file,
+ "%s", (msg_no_color) ? msg_no_color : message);
fflush (buffer->log_file);
if (msg_no_color)
free (msg_no_color);
@@ -103,113 +104,28 @@ gui_log_write (t_gui_buffer *buffer, char *message)
*/
void
-gui_log_start (t_gui_buffer *buffer)
+gui_log_start (struct t_gui_buffer *buffer)
{
- int length;
- char *log_path, *log_path2;
- char *server_name, *channel_name;
-
- log_path = weechat_strreplace (cfg_log_path, "~", getenv ("HOME"));
- log_path2 = weechat_strreplace (log_path, "%h", weechat_home);
-
- if (GUI_SERVER(buffer))
- server_name = weechat_strreplace (GUI_SERVER(buffer)->name, DIR_SEPARATOR, "_");
- else
- server_name = NULL;
- if (GUI_CHANNEL(buffer))
- channel_name = weechat_strreplace (GUI_CHANNEL(buffer)->name, DIR_SEPARATOR, "_");
- else
- channel_name = NULL;
-
- if (!log_path || !log_path2 || (GUI_SERVER(buffer) && !server_name) ||
- (GUI_CHANNEL(buffer) && !channel_name))
- {
- weechat_log_printf (_("Not enough memory to write log file \"%s\"\n"),
- (log_path2) ? log_path2 : ((log_path) ? log_path : cfg_log_path));
- irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
- gui_printf_nolog (NULL, _("Not enough memory to write log file \"%s\"\n"),
- (log_path2) ? log_path2 : ((log_path) ? log_path : cfg_log_path));
- if (log_path)
- free (log_path);
- if (log_path2)
- free (log_path2);
- if (server_name)
- free (server_name);
- if (channel_name)
- free (channel_name);
- return;
- }
-
- length = strlen (log_path2) + 128;
- if (GUI_SERVER(buffer))
- length += strlen (server_name);
- if (GUI_CHANNEL(buffer))
- length += strlen (channel_name);
-
- buffer->log_filename = (char *) malloc (length);
- if (!buffer->log_filename)
- {
- weechat_log_printf (_("Not enough memory to write log file \"%s\"\n"),
- (log_path2) ? log_path2 : ((log_path) ? log_path : cfg_log_path));
- irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
- gui_printf_nolog (NULL, _("Not enough memory to write log file \"%s\"\n"),
- (log_path2) ? log_path2 : ((log_path) ? log_path : cfg_log_path));
- free (log_path);
- free (log_path2);
- if (server_name)
- free (server_name);
- if (channel_name)
- free (channel_name);
- return;
- }
-
- strcpy (buffer->log_filename, log_path2);
-
- free (log_path);
- free (log_path2);
-
- if (buffer->log_filename[strlen (buffer->log_filename) - 1] != DIR_SEPARATOR_CHAR)
- strcat (buffer->log_filename, DIR_SEPARATOR);
-
- if (GUI_SERVER(buffer))
- {
- strcat (buffer->log_filename, server_name);
- strcat (buffer->log_filename, ".");
- }
- if (GUI_CHANNEL(buffer)
- && (GUI_CHANNEL(buffer)->type == IRC_CHANNEL_TYPE_DCC_CHAT))
- {
- strcat (buffer->log_filename, "dcc.");
- }
- if (GUI_CHANNEL(buffer))
- {
- strcat (buffer->log_filename, channel_name);
- strcat (buffer->log_filename, ".");
- }
- strcat (buffer->log_filename, "weechatlog");
-
- if (server_name)
- free (server_name);
- if (channel_name)
- free (channel_name);
-
- buffer->log_file = fopen (buffer->log_filename, "a");
- if (!buffer->log_file)
+ if (buffer->log_filename)
{
- weechat_log_printf (_("Unable to write log file \"%s\"\n"),
- buffer->log_filename);
- irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
- gui_printf (NULL, _("Unable to write log file \"%s\"\n"),
- buffer->log_filename);
- free (buffer->log_filename);
- return;
+ buffer->log_file = fopen (buffer->log_filename, "a");
+ if (!buffer->log_file)
+ {
+ weechat_log_printf (_("Unable to write log file \"%s\"\n"),
+ buffer->log_filename);
+ gui_chat_printf (NULL,
+ _("%s%s Unable to write log file \"%s\"\n"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ WEECHAT_ERROR,
+ buffer->log_filename);
+ free (buffer->log_filename);
+ return;
+ }
+
+ gui_log_write (buffer, _("**** Beginning of log "));
+ gui_log_write_date (buffer);
+ gui_log_write (buffer, "****\n");
}
-
- gui_log_write (buffer, _("**** Beginning of log "));
- gui_log_write_date (buffer);
- gui_log_write (buffer, "****\n");
-
- return;
}
/*
@@ -217,7 +133,7 @@ gui_log_start (t_gui_buffer *buffer)
*/
void
-gui_log_end (t_gui_buffer *buffer)
+gui_log_end (struct t_gui_buffer *buffer)
{
if (buffer->log_file)
{
diff --git a/src/gui/gui-log.h b/src/gui/gui-log.h
new file mode 100644
index 000000000..52635ec70
--- /dev/null
+++ b/src/gui/gui-log.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_GUI_LOG_H
+#define __WEECHAT_GUI_LOG_H 1
+
+/* log functions */
+
+extern void gui_log_write_date (struct t_gui_buffer *);
+extern void gui_log_write_line (struct t_gui_buffer *, char *);
+extern void gui_log_write (struct t_gui_buffer *, char *);
+extern void gui_log_start (struct t_gui_buffer *);
+extern void gui_log_end (struct t_gui_buffer *);
+
+#endif /* gui-log.h */
diff --git a/src/gui/gui-main.h b/src/gui/gui-main.h
new file mode 100644
index 000000000..f657db0cf
--- /dev/null
+++ b/src/gui/gui-main.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_GUI_MAIN_H
+#define __WEECHAT_GUI_MAIN_H 1
+
+/* main variables */
+
+extern int gui_init_ok;
+extern int gui_ok;
+
+/* main functions (GUI dependent) */
+
+extern void gui_main_loop ();
+extern void gui_main_pre_init (int *, char **[]);
+extern void gui_main_init ();
+extern void gui_main_end ();
+
+#endif /* gui-main.h */
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c
new file mode 100644
index 000000000..03109d931
--- /dev/null
+++ b/src/gui/gui-nicklist.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* gui-nicklist.c: nicklist 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 "../core/weechat.h"
+#include "../core/wee-string.h"
+#include "../core/wee-utf8.h"
+#include "gui-nicklist.h"
+
+
+/*
+ * gui_nicklist_compare: compare two nicks
+ * return: -1 is nick1 < nick2
+ * 0 if nick1 = nick2
+ * +1 if nick1 > nick2
+ */
+
+int
+gui_nicklist_compare (struct t_gui_buffer *buffer,
+ struct t_gui_nick *nick1, struct t_gui_nick *nick2)
+{
+ if (nick1->sort_index > nick2->sort_index)
+ return 1;
+
+ if (nick1->sort_index < nick2->sort_index)
+ return -1;
+
+ /* sort index are the same, then use alphabetical sorting */
+ if (buffer->nick_case_sensitive)
+ return strcmp (nick1->nick, nick2->nick);
+ else
+ return string_strcasecmp (nick1->nick, nick2->nick);
+}
+
+/*
+ * gui_nicklist_find_pos: find position for a nick (for sorting nicklist)
+ */
+
+struct t_gui_nick *
+gui_nicklist_find_pos (struct t_gui_buffer *buffer, struct t_gui_nick *nick)
+{
+ struct t_gui_nick *ptr_nick;
+
+ for (ptr_nick = buffer->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
+ {
+ if (gui_nicklist_compare (buffer, nick, ptr_nick) < 0)
+ return ptr_nick;
+ }
+ return NULL;
+}
+
+/*
+ * gui_nicklist_insert_sorted: insert nick into sorted list
+ */
+
+void
+gui_nicklist_insert_sorted (struct t_gui_buffer *buffer, struct t_gui_nick *nick)
+{
+ struct t_gui_nick *pos_nick;
+
+ if (buffer->nicks)
+ {
+ pos_nick = gui_nicklist_find_pos (buffer, nick);
+
+ if (pos_nick)
+ {
+ /* insert nick into the list (before nick found) */
+ nick->prev_nick = pos_nick->prev_nick;
+ nick->next_nick = pos_nick;
+ if (pos_nick->prev_nick)
+ pos_nick->prev_nick->next_nick = nick;
+ else
+ buffer->nicks = nick;
+ pos_nick->prev_nick = nick;
+ }
+ else
+ {
+ /* add nick to the end */
+ nick->prev_nick = buffer->last_nick;
+ nick->next_nick = NULL;
+ buffer->last_nick->next_nick = nick;
+ buffer->last_nick = nick;
+ }
+ }
+ else
+ {
+ nick->prev_nick = NULL;
+ nick->next_nick = NULL;
+ buffer->nicks = nick;
+ buffer->last_nick = nick;
+ }
+}
+
+/*
+ * gui_nicklist_resort: resort a nick in nicklist
+ */
+
+void
+gui_nicklist_resort (struct t_gui_buffer *buffer, struct t_gui_nick *nick)
+{
+ /* temporarly remove nick from list */
+ if (nick == buffer->nicks)
+ buffer->nicks = nick->next_nick;
+ else
+ nick->prev_nick->next_nick = nick->next_nick;
+ if (nick->next_nick)
+ nick->next_nick->prev_nick = nick->prev_nick;
+ if (nick == buffer->last_nick)
+ buffer->last_nick = nick->prev_nick;
+
+ /* insert again nick into sorted list */
+ gui_nicklist_insert_sorted (buffer, nick);
+}
+
+/*
+ * gui_nicklist_search: search a nick in buffer nicklist
+ */
+
+struct t_gui_nick *
+gui_nicklist_search (struct t_gui_buffer *buffer, char *nick)
+{
+ struct t_gui_nick *ptr_nick;
+
+ for (ptr_nick = buffer->nicks; ptr_nick;
+ ptr_nick = ptr_nick->next_nick)
+ {
+ if ((buffer->nick_case_sensitive
+ && (strcmp (ptr_nick->nick, nick) == 0))
+ || (!buffer->nick_case_sensitive
+ && (string_strcasecmp (ptr_nick->nick, nick) == 0)))
+ return ptr_nick;
+ }
+
+ /* nick not found */
+ return NULL;
+}
+
+/*
+ * gui_nicklist_add: add a nick to nicklist for a buffer
+ */
+
+struct t_gui_nick *
+gui_nicklist_add (struct t_gui_buffer *buffer, char *nick, int sort_index,
+ int color_nick, char prefix, int color_prefix)
+{
+ struct t_gui_nick *new_nick;
+
+ if (!nick || gui_nicklist_search (buffer, nick))
+ return NULL;
+
+ new_nick = (struct t_gui_nick *)malloc (sizeof (struct t_gui_nick));
+ if (!new_nick)
+ return NULL;
+
+ new_nick->nick = strdup (nick);
+ new_nick->sort_index = sort_index;
+ new_nick->color_nick = color_nick;
+ new_nick->prefix = prefix;
+ new_nick->color_prefix = color_prefix;
+
+ gui_nicklist_insert_sorted (buffer, new_nick);
+
+ buffer->nicks_count++;
+
+ return new_nick;
+}
+
+/*
+ * gui_nicklist_update: update a nick in nicklist
+ */
+
+void
+gui_nicklist_update (struct t_gui_buffer *buffer, struct t_gui_nick *nick,
+ char *new_nick, int sort_index,
+ int color_nick, char prefix, int color_prefix)
+{
+ if (!nick)
+ return;
+
+ if (new_nick)
+ {
+ free (nick->nick);
+ nick->nick = strdup (new_nick);
+ }
+ nick->sort_index = sort_index;
+ nick->color_nick = color_nick;
+ nick->prefix = prefix;
+ nick->color_prefix = color_prefix;
+
+ gui_nicklist_resort (buffer, nick);
+}
+
+/*
+ * gui_nicklist_free: remove a nick to nicklist for a buffer
+ */
+
+void
+gui_nicklist_free (struct t_gui_buffer *buffer, struct t_gui_nick *nick)
+{
+ if (nick->nick)
+ free (nick->nick);
+
+ /* remove nick from nicks list */
+ if (nick->prev_nick)
+ nick->prev_nick->next_nick = nick->next_nick;
+ if (nick->next_nick)
+ nick->next_nick->prev_nick = nick->prev_nick;
+ if (buffer->nicks == nick)
+ buffer->nicks = nick->next_nick;
+ if (buffer->last_nick == nick)
+ buffer->last_nick = nick->prev_nick;
+
+ if (buffer->nicks_count > 0)
+ buffer->nicks_count--;
+}
+
+/*
+ * gui_nicklist_free_all: remove all nicks in nicklist
+ */
+
+void
+gui_nicklist_free_all (struct t_gui_buffer *buffer)
+{
+ while (buffer->nicks)
+ {
+ gui_nicklist_free (buffer, buffer->nicks);
+ }
+}
+
+/*
+ * gui_nicklist_remove: remove a nickname to nicklist for a buffer
+ * return 1 if a nick was removed, 0 otherwise
+ */
+
+int
+gui_nicklist_remove (struct t_gui_buffer *buffer, char *nick)
+{
+ struct t_gui_nick *ptr_nick;
+
+ ptr_nick = gui_nicklist_search (buffer, nick);
+ if (!ptr_nick)
+ return 0;
+
+ gui_nicklist_free (buffer, ptr_nick);
+ return 1;
+}
+
+/*
+ * gui_nicklist_get_max_length: return longer nickname on a buffer
+ */
+
+int
+gui_nicklist_get_max_length (struct t_gui_buffer *buffer)
+{
+ int length, max_length;
+ struct t_gui_nick *ptr_nick;
+
+ max_length = 0;
+ for (ptr_nick = buffer->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
+ {
+ length = utf8_strlen_screen (ptr_nick->nick);
+ if (length > max_length)
+ max_length = length;
+ }
+ return max_length;
+}
diff --git a/src/gui/gui-nicklist.h b/src/gui/gui-nicklist.h
new file mode 100644
index 000000000..b9cf4bd3b
--- /dev/null
+++ b/src/gui/gui-nicklist.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_GUI_NICKLIST_H
+#define __WEECHAT_GUI_NICKLIST_H 1
+
+#include "gui-buffer.h"
+
+/* nicklist functions */
+
+extern struct t_gui_nick *gui_nicklist_search (struct t_gui_buffer *, char *);
+extern struct t_gui_nick *gui_nicklist_add (struct t_gui_buffer *, char *,
+ int, int, char, int);
+extern void gui_nicklist_update (struct t_gui_buffer *, struct t_gui_nick *,
+ char *, int, int, char, int);
+extern void gui_nicklist_free (struct t_gui_buffer *, struct t_gui_nick *);
+extern void gui_nicklist_free_all (struct t_gui_buffer *);
+extern int gui_nicklist_remove (struct t_gui_buffer *, char *);
+extern int gui_nicklist_get_max_length (struct t_gui_buffer *);
+
+/* nicklist functions (GUI dependent) */
+
+extern void gui_nicklist_draw (struct t_gui_buffer *, int);
+
+#endif /* gui-nicklist.h */
diff --git a/src/gui/gui-panel.c b/src/gui/gui-panel.c
deleted file mode 100644
index c7d2c02dd..000000000
--- a/src/gui/gui-panel.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-/* 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"
-#include "../common/log.h"
-
-
-t_gui_panel *gui_panels = NULL; /* pointer to first panel */
-t_gui_panel *last_gui_panel = NULL; /* pointer to last panel */
-
-
-/*
- * gui_panel_global_get_size: get total panel size (global panels) for a position
- */
-
-int
-gui_panel_global_get_size (t_gui_panel *panel, int position)
-{
- t_gui_panel *ptr_panel;
- int total_size;
-
- total_size = 0;
- for (ptr_panel = gui_panels; ptr_panel; ptr_panel = ptr_panel->next_panel)
- {
- if ((panel) && (ptr_panel == panel))
- return total_size;
-
- if (ptr_panel->position == position)
- {
- switch (position)
- {
- case GUI_PANEL_TOP:
- case GUI_PANEL_BOTTOM:
- total_size += ptr_panel->size;
- break;
- case GUI_PANEL_LEFT:
- case GUI_PANEL_RIGHT:
- total_size += ptr_panel->size;
- break;
- }
- if (ptr_panel->separator)
- total_size++;
- }
- }
- return total_size;
-}
-
-/*
- * gui_panel_new: create a new panel
- */
-
-t_gui_panel *
-gui_panel_new (char *name, int type, int position, 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->number = (last_gui_panel) ? last_gui_panel->number + 1 : 1;
- new_panel->name = strdup (name);
- new_panel->position = position;
- 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);
-}
-
-/*
- * gui_panel_print_log: print panel infos in log (usually for crash dump)
- */
-
-void
-gui_panel_print_log ()
-{
- t_gui_panel *ptr_panel;
-
- for (ptr_panel = gui_panels; ptr_panel; ptr_panel = ptr_panel->next_panel)
- {
- weechat_log_printf ("\n");
- weechat_log_printf ("[panel (addr:0x%X)]\n", ptr_panel);
- weechat_log_printf (" position. . . . . . : %d\n", ptr_panel->position);
- weechat_log_printf (" name. . . . . . . . : '%s'\n", ptr_panel->name);
- weechat_log_printf (" panel_window. . . . : 0x%X\n", ptr_panel->panel_window);
- weechat_log_printf (" separator . . . . . : %d\n", ptr_panel->separator);
- weechat_log_printf (" size. . . . . . . . : %d\n", ptr_panel->size);
- weechat_log_printf (" prev_panel . .. . . : 0x%X\n", ptr_panel->prev_panel);
- weechat_log_printf (" next_panel . .. . . : 0x%X\n", ptr_panel->next_panel);
- }
-}
diff --git a/src/gui/gui-panel.h b/src/gui/gui-panel.h
deleted file mode 100644
index 740ba1178..000000000
--- a/src/gui/gui-panel.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-
-#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 4
-#define GUI_PANEL_RIGHT 8
-
-#define GUI_PANEL_GLOBAL 1
-#define GUI_PANEL_WINDOWS 2
-
-
-/* panel structure */
-
-typedef struct t_gui_panel t_gui_panel;
-
-struct t_gui_panel
-{
- int number; /* panel number */
- char *name; /* panel name */
- int position; /* position (top, bottom, left, right) */
- 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-status.h b/src/gui/gui-status.h
new file mode 100644
index 000000000..0c19d6b36
--- /dev/null
+++ b/src/gui/gui-status.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __WEECHAT_GUI_STATUS_H
+#define __WEECHAT_GUI_STATUS_H 1
+
+#include "gui-buffer.h"
+
+/* statusbar functions (GUI dependent) */
+
+extern void gui_status_draw (struct t_gui_buffer *, int);
+
+#endif /* gui-status.h */
diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c
index 62a515537..e911a6f5b 100644
--- a/src/gui/gui-window.c
+++ b/src/gui/gui-window.c
@@ -32,22 +32,26 @@
#include <time.h>
#include <ctype.h>
-#include "../common/weechat.h"
-#include "gui.h"
-#include "../common/command.h"
-#include "../common/weeconfig.h"
-#include "../common/history.h"
-#include "../common/hotlist.h"
-#include "../common/log.h"
-#include "../common/utf8.h"
-#include "../protocols/irc/irc.h"
+#include "../core/weechat.h"
+#include "../core/wee-command.h"
+#include "../core/wee-config.h"
+#include "../core/wee-log.h"
+#include "../core/wee-utf8.h"
+#include "gui-window.h"
+#include "gui-input.h"
+#include "gui-hotlist.h"
+#include "gui-status.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 */
+int gui_init_ok = 0; /* = 1 if GUI is initialized*/
+int gui_ok = 0; /* = 1 if GUI is ok */
+ /* (0 when size too small) */
-t_gui_window_tree *gui_windows_tree = NULL; /* pointer to windows tree */
+struct t_gui_window *gui_windows = NULL; /* first window */
+struct t_gui_window *last_gui_window = NULL; /* last window */
+struct t_gui_window *gui_current_window = NULL; /* current window */
+
+struct t_gui_window_tree *gui_windows_tree = NULL; /* windows tree */
/*
@@ -55,9 +59,9 @@ t_gui_window_tree *gui_windows_tree = NULL; /* pointer to windows tree */
*/
int
-gui_window_tree_init (t_gui_window *window)
+gui_window_tree_init (struct t_gui_window *window)
{
- gui_windows_tree = (t_gui_window_tree *)malloc (sizeof (t_gui_window_tree));
+ gui_windows_tree = (struct t_gui_window_tree *)malloc (sizeof (struct t_gui_window_tree));
if (!gui_windows_tree)
return 0;
gui_windows_tree->parent_node = NULL;
@@ -75,7 +79,8 @@ gui_window_tree_init (t_gui_window *window)
*/
void
-gui_window_tree_node_to_leaf (t_gui_window_tree *node, t_gui_window *window)
+gui_window_tree_node_to_leaf (struct t_gui_window_tree *node,
+ struct t_gui_window *window)
{
node->split_horiz = 0;
node->split_pct = 0;
@@ -98,7 +103,7 @@ gui_window_tree_node_to_leaf (t_gui_window_tree *node, t_gui_window *window)
*/
void
-gui_window_tree_free (t_gui_window_tree **tree)
+gui_window_tree_free (struct t_gui_window_tree **tree)
{
if (*tree)
{
@@ -115,13 +120,12 @@ gui_window_tree_free (t_gui_window_tree **tree)
* gui_window_new: create a new window
*/
-t_gui_window *
-gui_window_new (t_gui_window *parent, int x, int y, int width, int height,
+struct t_gui_window *
+gui_window_new (struct t_gui_window *parent, int x, int y, int width, int height,
int width_pct, int height_pct)
{
- t_gui_window *new_window;
- t_gui_window_tree *ptr_tree, *child1, *child2, *ptr_leaf;
- t_gui_panel *ptr_panel;
+ struct t_gui_window *new_window;
+ struct t_gui_window_tree *ptr_tree, *child1, *child2, *ptr_leaf;
#ifdef DEBUG
weechat_log_printf ("Creating new window (x:%d, y:%d, width:%d, height:%d)\n",
@@ -130,10 +134,10 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height,
if (parent)
{
- child1 = (t_gui_window_tree *)malloc (sizeof (t_gui_window_tree));
+ child1 = (struct t_gui_window_tree *)malloc (sizeof (struct t_gui_window_tree));
if (!child1)
return NULL;
- child2 = (t_gui_window_tree *)malloc (sizeof (t_gui_window_tree));
+ child2 = (struct t_gui_window_tree *)malloc (sizeof (struct t_gui_window_tree));
if (!child2)
{
free (child1);
@@ -179,7 +183,7 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height,
ptr_leaf = gui_windows_tree;
}
- if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window)))))
+ if ((new_window = (struct t_gui_window *)(malloc (sizeof (struct t_gui_window)))))
{
if (!gui_window_objects_init (new_window))
{
@@ -247,14 +251,6 @@ 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;
@@ -276,7 +272,7 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height,
*/
void
-gui_window_free (t_gui_window *window)
+gui_window_free (struct t_gui_window *window)
{
if (window->buffer && (window->buffer->num_displayed > 0))
window->buffer->num_displayed--;
@@ -301,14 +297,39 @@ gui_window_free (t_gui_window *window)
}
/*
+ * gui_window_search_by_buffer: search a window by buffer
+ * (return first window displaying this buffer)
+ */
+
+struct t_gui_window *
+gui_window_search_by_buffer (struct t_gui_buffer *buffer)
+{
+ struct t_gui_window *ptr_window;
+
+ if (!gui_ok)
+ return NULL;
+
+ for (ptr_window = gui_windows; ptr_window;
+ ptr_window = ptr_window->next_window)
+ {
+ if (ptr_window->buffer == buffer)
+ return ptr_window;
+ }
+
+ /* window not found */
+ return NULL;
+}
+
+/*
* gui_window_switch_server: switch server on servers buffer
* (if same buffer is used for all buffers)
*/
void
-gui_window_switch_server (t_gui_window *window)
+gui_window_switch_server (struct t_gui_window *window)
{
- t_gui_buffer *ptr_buffer;
+ (void) window;
+ /*struct t_gui_buffer *ptr_buffer;
t_irc_server *ptr_server;
ptr_buffer = gui_buffer_servers_search ();
@@ -340,7 +361,7 @@ gui_window_switch_server (t_gui_window *window)
gui_status_draw (window->buffer, 1);
gui_input_draw (window->buffer, 1);
}
- }
+ }*/
}
/*
@@ -348,7 +369,7 @@ gui_window_switch_server (t_gui_window *window)
*/
void
-gui_window_switch_previous (t_gui_window *window)
+gui_window_switch_previous (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -367,7 +388,7 @@ gui_window_switch_previous (t_gui_window *window)
*/
void
-gui_window_switch_next (t_gui_window *window)
+gui_window_switch_next (struct t_gui_window *window)
{
if (!gui_ok)
return;
@@ -386,9 +407,9 @@ gui_window_switch_next (t_gui_window *window)
*/
void
-gui_window_switch_by_buffer (t_gui_window *window, int buffer_number)
+gui_window_switch_by_buffer (struct t_gui_window *window, int buffer_number)
{
- t_gui_window *ptr_win;
+ struct t_gui_window *ptr_win;
if (!gui_ok)
return;
@@ -408,56 +429,397 @@ gui_window_switch_by_buffer (t_gui_window *window, int buffer_number)
}
/*
+ * gui_window_scroll: scroll window by # messages or time
+ */
+
+void
+gui_window_scroll (struct t_gui_window *window, char *scroll)
+{
+ int direction, stop, count_msg;
+ char time_letter, saved_char;
+ time_t old_date, diff_date;
+ char *error;
+ long number;
+ struct t_gui_line *ptr_line;
+ struct tm *date_tmp, line_date, old_line_date;
+
+ if (window->buffer->lines)
+ {
+ direction = -1;
+ number = 0;
+ time_letter = ' ';
+
+ // search direction
+ if (scroll[0] == '-')
+ {
+ direction = -1;
+ scroll++;
+ }
+ else if (scroll[0] == '+')
+ {
+ direction = +1;
+ scroll++;
+ }
+
+ // search number and letter
+ char *pos = scroll;
+ while (pos && pos[0] && isdigit (pos[0]))
+ {
+ pos++;
+ }
+ if (pos)
+ {
+ if (pos == scroll)
+ {
+ if (pos[0])
+ time_letter = scroll[0];
+ }
+ else
+ {
+ if (pos[0])
+ time_letter = pos[0];
+ saved_char = pos[0];
+ pos[0] = '\0';
+ error = NULL;
+ number = strtol (scroll, &error, 10);
+ if (!error || (error[0] != '\0'))
+ number = 0;
+ pos[0] = saved_char;
+ }
+ }
+
+ /* at least number or letter has to he given */
+ if ((number == 0) && (time_letter == ' '))
+ return;
+
+ // do the scroll!
+ stop = 0;
+ count_msg = 0;
+ if (direction < 0)
+ ptr_line = (window->start_line) ?
+ window->start_line : window->buffer->last_line;
+ else
+ ptr_line = (window->start_line) ?
+ window->start_line : window->buffer->lines;
+
+ old_date = ptr_line->date;
+ date_tmp = localtime (&old_date);
+ memcpy (&old_line_date, date_tmp, sizeof (struct tm));
+
+ while (ptr_line)
+ {
+ ptr_line = (direction < 0) ? ptr_line->prev_line : ptr_line->next_line;
+
+ if (ptr_line)
+ {
+ if (time_letter == ' ')
+ {
+ count_msg++;
+ if (count_msg >= number)
+ stop = 1;
+ }
+ else
+ {
+ date_tmp = localtime (&(ptr_line->date));
+ memcpy (&line_date, date_tmp, sizeof (struct tm));
+ if (old_date > ptr_line->date)
+ diff_date = old_date - ptr_line->date;
+ else
+ diff_date = ptr_line->date - old_date;
+ switch (time_letter)
+ {
+ case 's': /* seconds */
+ if (number == 0)
+ {
+ /* stop if line has different second */
+ if ((line_date.tm_sec != old_line_date.tm_sec)
+ || (line_date.tm_min != old_line_date.tm_min)
+ || (line_date.tm_hour != old_line_date.tm_hour)
+ || (line_date.tm_mday != old_line_date.tm_mday)
+ || (line_date.tm_mon != old_line_date.tm_mon)
+ || (line_date.tm_year != old_line_date.tm_year))
+ if (line_date.tm_sec != old_line_date.tm_sec)
+ stop = 1;
+ }
+ else if (diff_date >= number)
+ stop = 1;
+ break;
+ case 'm': /* minutes */
+ if (number == 0)
+ {
+ /* stop if line has different minute */
+ if ((line_date.tm_min != old_line_date.tm_min)
+ || (line_date.tm_hour != old_line_date.tm_hour)
+ || (line_date.tm_mday != old_line_date.tm_mday)
+ || (line_date.tm_mon != old_line_date.tm_mon)
+ || (line_date.tm_year != old_line_date.tm_year))
+ stop = 1;
+ }
+ else if (diff_date >= number * 60)
+ stop = 1;
+ break;
+ case 'h': /* hours */
+ if (number == 0)
+ {
+ /* stop if line has different hour */
+ if ((line_date.tm_hour != old_line_date.tm_hour)
+ || (line_date.tm_mday != old_line_date.tm_mday)
+ || (line_date.tm_mon != old_line_date.tm_mon)
+ || (line_date.tm_year != old_line_date.tm_year))
+ stop = 1;
+ }
+ else if (diff_date >= number * 60 * 60)
+ stop = 1;
+ break;
+ case 'd': /* days */
+ if (number == 0)
+ {
+ /* stop if line has different day */
+ if ((line_date.tm_mday != old_line_date.tm_mday)
+ || (line_date.tm_mon != old_line_date.tm_mon)
+ || (line_date.tm_year != old_line_date.tm_year))
+ stop = 1;
+ }
+ else if (diff_date >= number * 60 * 60 * 24)
+ stop = 1;
+ break;
+ case 'M': /* months */
+ if (number == 0)
+ {
+ /* stop if line has different month */
+ if ((line_date.tm_mon != old_line_date.tm_mon)
+ || (line_date.tm_year != old_line_date.tm_year))
+ stop = 1;
+ }
+ /* we consider month is 30 days, who will find I'm too
+ lazy to code exact date diff ? ;) */
+ else if (diff_date >= number * 60 * 60 * 24 * 30)
+ stop = 1;
+ break;
+ case 'y': /* years */
+ if (number == 0)
+ {
+ /* stop if line has different year */
+ if (line_date.tm_year != old_line_date.tm_year)
+ stop = 1;
+ }
+ /* we consider year is 365 days, who will find I'm too
+ lazy to code exact date diff ? ;) */
+ else if (diff_date >= number * 60 * 60 * 24 * 365)
+ stop = 1;
+ break;
+ }
+ }
+ if (stop)
+ {
+ window->start_line = ptr_line;
+ window->start_line_pos = 0;
+ window->first_line_displayed =
+ (window->start_line == window->buffer->lines);
+ gui_chat_draw (window->buffer, 1);
+ gui_status_draw (window->buffer, 0);
+ return;
+ }
+ }
+ }
+ if (direction < 0)
+ gui_window_scroll_top (window);
+ else
+ gui_window_scroll_bottom (window);
+ }
+}
+
+/*
+ * gui_window_search_text: search text in a buffer
+ */
+
+int
+gui_window_search_text (struct t_gui_window *window)
+{
+ struct t_gui_line *ptr_line;
+
+ if (window->buffer->text_search == GUI_TEXT_SEARCH_BACKWARD)
+ {
+ if (window->buffer->lines
+ && window->buffer->input_buffer && window->buffer->input_buffer[0])
+ {
+ ptr_line = (window->start_line) ?
+ window->start_line->prev_line : window->buffer->last_line;
+ while (ptr_line)
+ {
+ if (gui_chat_line_search (ptr_line,
+ window->buffer->input_buffer,
+ window->buffer->text_search_exact))
+ {
+ window->start_line = ptr_line;
+ window->start_line_pos = 0;
+ window->first_line_displayed =
+ (window->start_line == window->buffer->lines);
+ gui_chat_draw (window->buffer, 1);
+ gui_status_draw (window->buffer, 1);
+ return 1;
+ }
+ ptr_line = ptr_line->prev_line;
+ }
+ }
+ }
+ else if (window->buffer->text_search == GUI_TEXT_SEARCH_FORWARD)
+ {
+ if (window->buffer->lines
+ && window->buffer->input_buffer && window->buffer->input_buffer[0])
+ {
+ ptr_line = (window->start_line) ?
+ window->start_line->next_line : window->buffer->lines->next_line;
+ while (ptr_line)
+ {
+ if (gui_chat_line_search (ptr_line,
+ window->buffer->input_buffer,
+ window->buffer->text_search_exact))
+ {
+ window->start_line = ptr_line;
+ window->start_line_pos = 0;
+ window->first_line_displayed =
+ (window->start_line == window->buffer->lines);
+ gui_chat_draw (window->buffer, 1);
+ gui_status_draw (window->buffer, 1);
+ return 1;
+ }
+ ptr_line = ptr_line->next_line;
+ }
+ }
+ }
+ return 0;
+}
+
+/*
+ * gui_window_search_start: start search in a buffer
+ */
+
+void
+gui_window_search_start (struct t_gui_window *window)
+{
+ window->buffer->text_search = GUI_TEXT_SEARCH_BACKWARD;
+ window->buffer->text_search_exact = 0;
+ window->buffer->text_search_found = 0;
+ if (window->buffer->text_search_input)
+ {
+ free (window->buffer->text_search_input);
+ window->buffer->text_search_input = NULL;
+ }
+ if (window->buffer->input_buffer && window->buffer->input_buffer[0])
+ window->buffer->text_search_input =
+ strdup (window->buffer->input_buffer);
+ gui_input_delete_line (window->buffer);
+ gui_status_draw (window->buffer, 1);
+ gui_input_draw (window->buffer, 1);
+}
+
+/*
+ * gui_window_search_restart: restart search (after input changes or exact
+ * flag (un)set)
+ */
+
+void
+gui_window_search_restart (struct t_gui_window *window)
+{
+ window->start_line = NULL;
+ window->start_line_pos = 0;
+ window->buffer->text_search = GUI_TEXT_SEARCH_BACKWARD;
+ window->buffer->text_search_found = 0;
+ if (gui_window_search_text (window))
+ window->buffer->text_search_found = 1;
+ else
+ {
+ gui_chat_draw (window->buffer, 1);
+ gui_status_draw (window->buffer, 1);
+ }
+}
+
+/*
+ * gui_window_search_stop: stop search in a buffer
+ */
+
+void
+gui_window_search_stop (struct t_gui_window *window)
+{
+ window->buffer->text_search = GUI_TEXT_SEARCH_DISABLED;
+ window->buffer->text_search = 0;
+ gui_input_delete_line (window->buffer);
+ if (window->buffer->text_search_input)
+ {
+ gui_input_insert_string (window->buffer,
+ window->buffer->text_search_input, -1);
+ free (window->buffer->text_search_input);
+ window->buffer->text_search_input = NULL;
+ }
+ window->start_line = NULL;
+ window->start_line_pos = 0;
+ gui_hotlist_remove_buffer (window->buffer);
+ gui_chat_draw (window->buffer, 0);
+ gui_status_draw (window->buffer, 1);
+ gui_input_draw (window->buffer, 1);
+}
+
+/*
* gui_window_print_log: print window infos in log (usually for crash dump)
*/
void
-gui_window_print_log (t_gui_window *window)
+gui_window_print_log ()
{
- weechat_log_printf ("[window (addr:0x%X)]\n", window);
- weechat_log_printf (" win_x . . . . . . . : %d\n", window->win_x);
- weechat_log_printf (" win_y . . . . . . . : %d\n", window->win_y);
- weechat_log_printf (" win_width . . . . . : %d\n", window->win_width);
- weechat_log_printf (" win_height. . . . . : %d\n", window->win_height);
- weechat_log_printf (" win_width_pct . . . : %d\n", window->win_width_pct);
- weechat_log_printf (" win_height_pct. . . : %d\n", window->win_height_pct);
- weechat_log_printf (" win_chat_x. . . . . : %d\n", window->win_chat_x);
- weechat_log_printf (" win_chat_y. . . . . : %d\n", window->win_chat_y);
- weechat_log_printf (" win_chat_width. . . : %d\n", window->win_chat_width);
- weechat_log_printf (" win_chat_height . . : %d\n", window->win_chat_height);
- weechat_log_printf (" win_chat_cursor_x . : %d\n", window->win_chat_cursor_x);
- weechat_log_printf (" win_chat_cursor_y . : %d\n", window->win_chat_cursor_y);
- weechat_log_printf (" win_nick_x. . . . . : %d\n", window->win_nick_x);
- weechat_log_printf (" win_nick_y. . . . . : %d\n", window->win_nick_y);
- 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_x . . . . : %d\n", window->win_title_x);
- weechat_log_printf (" win_title_y . . . . : %d\n", window->win_title_y);
- weechat_log_printf (" win_title_width . . : %d\n", window->win_title_width);
- weechat_log_printf (" win_title_height. . : %d\n", window->win_title_height);
- weechat_log_printf (" win_title_start . . : %d\n", window->win_title_start);
- weechat_log_printf (" win_status_x. . . . : %d\n", window->win_status_x);
- weechat_log_printf (" win_status_y. . . . : %d\n", window->win_status_y);
- weechat_log_printf (" win_status_width. . : %d\n", window->win_status_width);
- weechat_log_printf (" win_status_height . : %d\n", window->win_status_height);
- weechat_log_printf (" win_infobar_x . . . : %d\n", window->win_infobar_x);
- weechat_log_printf (" win_infobar_y . . . : %d\n", window->win_infobar_y);
- weechat_log_printf (" win_infobar_width . : %d\n", window->win_infobar_width);
- weechat_log_printf (" win_infobar_height. : %d\n", window->win_infobar_height);
- weechat_log_printf (" win_input_x . . . . : %d\n", window->win_input_x);
- weechat_log_printf (" win_input_y . . . . : %d\n", window->win_input_y);
- weechat_log_printf (" win_input_width . . : %d\n", window->win_input_width);
- weechat_log_printf (" win_input_height. . : %d\n", window->win_input_height);
- weechat_log_printf (" win_input_cursor_x. : %d\n", window->win_input_cursor_x);
- 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);
- weechat_log_printf (" buffer. . . . . . . : 0x%X\n", window->buffer);
- weechat_log_printf (" first_line_displayed: %d\n", window->first_line_displayed);
- weechat_log_printf (" start_line. . . . . : 0x%X\n", window->start_line);
- weechat_log_printf (" start_line_pos. . . : %d\n", window->start_line_pos);
- weechat_log_printf (" prev_window . . . . : 0x%X\n", window->prev_window);
- weechat_log_printf (" next_window . . . . : 0x%X\n", window->next_window);
+ struct t_gui_window *ptr_window;
+
+ weechat_log_printf ("\n");
+ weechat_log_printf ("current window = 0x%X\n", gui_current_window);
+
+ for (ptr_window = gui_windows; ptr_window; ptr_window = ptr_window->next_window)
+ {
+ weechat_log_printf ("\n");
+ weechat_log_printf ("[window (addr:0x%X)]\n", ptr_window);
+ weechat_log_printf (" win_x . . . . . . . : %d\n", ptr_window->win_x);
+ weechat_log_printf (" win_y . . . . . . . : %d\n", ptr_window->win_y);
+ weechat_log_printf (" win_width . . . . . : %d\n", ptr_window->win_width);
+ weechat_log_printf (" win_height. . . . . : %d\n", ptr_window->win_height);
+ weechat_log_printf (" win_width_pct . . . : %d\n", ptr_window->win_width_pct);
+ weechat_log_printf (" win_height_pct. . . : %d\n", ptr_window->win_height_pct);
+ weechat_log_printf (" win_chat_x. . . . . : %d\n", ptr_window->win_chat_x);
+ weechat_log_printf (" win_chat_y. . . . . : %d\n", ptr_window->win_chat_y);
+ weechat_log_printf (" win_chat_width. . . : %d\n", ptr_window->win_chat_width);
+ weechat_log_printf (" win_chat_height . . : %d\n", ptr_window->win_chat_height);
+ weechat_log_printf (" win_chat_cursor_x . : %d\n", ptr_window->win_chat_cursor_x);
+ weechat_log_printf (" win_chat_cursor_y . : %d\n", ptr_window->win_chat_cursor_y);
+ weechat_log_printf (" win_nick_x. . . . . : %d\n", ptr_window->win_nick_x);
+ weechat_log_printf (" win_nick_y. . . . . : %d\n", ptr_window->win_nick_y);
+ weechat_log_printf (" win_nick_width. . . : %d\n", ptr_window->win_nick_width);
+ weechat_log_printf (" win_nick_height . . : %d\n", ptr_window->win_nick_height);
+ weechat_log_printf (" win_nick_start. . . : %d\n", ptr_window->win_nick_start);
+ weechat_log_printf (" win_title_x . . . . : %d\n", ptr_window->win_title_x);
+ weechat_log_printf (" win_title_y . . . . : %d\n", ptr_window->win_title_y);
+ weechat_log_printf (" win_title_width . . : %d\n", ptr_window->win_title_width);
+ weechat_log_printf (" win_title_height. . : %d\n", ptr_window->win_title_height);
+ weechat_log_printf (" win_title_start . . : %d\n", ptr_window->win_title_start);
+ weechat_log_printf (" win_status_x. . . . : %d\n", ptr_window->win_status_x);
+ weechat_log_printf (" win_status_y. . . . : %d\n", ptr_window->win_status_y);
+ weechat_log_printf (" win_status_width. . : %d\n", ptr_window->win_status_width);
+ weechat_log_printf (" win_status_height . : %d\n", ptr_window->win_status_height);
+ weechat_log_printf (" win_infobar_x . . . : %d\n", ptr_window->win_infobar_x);
+ weechat_log_printf (" win_infobar_y . . . : %d\n", ptr_window->win_infobar_y);
+ weechat_log_printf (" win_infobar_width . : %d\n", ptr_window->win_infobar_width);
+ weechat_log_printf (" win_infobar_height. : %d\n", ptr_window->win_infobar_height);
+ weechat_log_printf (" win_input_x . . . . : %d\n", ptr_window->win_input_x);
+ weechat_log_printf (" win_input_y . . . . : %d\n", ptr_window->win_input_y);
+ weechat_log_printf (" win_input_width . . : %d\n", ptr_window->win_input_width);
+ weechat_log_printf (" win_input_height. . : %d\n", ptr_window->win_input_height);
+ weechat_log_printf (" win_input_cursor_x. : %d\n", ptr_window->win_input_cursor_x);
+ gui_window_objects_print_log (ptr_window);
+ weechat_log_printf (" dcc_first . . . . . : 0x%X\n", ptr_window->dcc_first);
+ weechat_log_printf (" dcc_selected. . . . : 0x%X\n", ptr_window->dcc_selected);
+ weechat_log_printf (" dcc_last_displayed. : 0x%X\n", ptr_window->dcc_last_displayed);
+ weechat_log_printf (" buffer. . . . . . . : 0x%X\n", ptr_window->buffer);
+ weechat_log_printf (" first_line_displayed: %d\n", ptr_window->first_line_displayed);
+ weechat_log_printf (" start_line. . . . . : 0x%X\n", ptr_window->start_line);
+ weechat_log_printf (" start_line_pos. . . : %d\n", ptr_window->start_line_pos);
+ weechat_log_printf (" prev_window . . . . : 0x%X\n", ptr_window->prev_window);
+ weechat_log_printf (" next_window . . . . : 0x%X\n", ptr_window->next_window);
+ }
}
diff --git a/src/gui/gui-window.h b/src/gui/gui-window.h
index be282ca93..af29faba5 100644
--- a/src/gui/gui-window.h
+++ b/src/gui/gui-window.h
@@ -22,104 +22,159 @@
/* 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 win_x, win_y; /* position of window */
+ int win_width, win_height; /* window geometry */
+ int win_width_pct; /* % of width (compared to win size) */
+ int win_height_pct; /* % of height (compared to win size)*/
- int new_x, new_y; /* used for computing new position */
- int new_width, new_height; /* used for computing new 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 */
+ 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) */
+ 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)*/
/* title window settings */
- int win_title_x; /* title window position */
- int win_title_y; /* title window position */
- int win_title_width; /* width of title window */
- int win_title_height; /* height of title window */
- int win_title_start; /* first char of title for display */
+ int win_title_x; /* title window position */
+ int win_title_y; /* title window position */
+ int win_title_width; /* width of title window */
+ int win_title_height; /* height of title window */
+ int win_title_start; /* first char of title for display */
/* status bar settings */
- int win_status_x; /* status window position */
- int win_status_y; /* status window position */
- int win_status_width; /* width of status window */
- int win_status_height; /* height of status window */
+ int win_status_x; /* status window position */
+ int win_status_y; /* status window position */
+ int win_status_width; /* width of status window */
+ int win_status_height; /* height of status window */
/* infobar bar settings */
- int win_infobar_x; /* infobar window position */
- int win_infobar_y; /* infobar window position */
- int win_infobar_width; /* width of infobar window */
- int win_infobar_height; /* height of infobar window */
+ int win_infobar_x; /* infobar window position */
+ int win_infobar_y; /* infobar window position */
+ int win_infobar_width; /* width of infobar window */
+ int win_infobar_height; /* height of infobar window */
/* input window settings */
- int win_input_x; /* input window position */
- int win_input_y; /* input window position */
- int win_input_width; /* width of input window */
- int win_input_height; /* height of input window */
- int win_input_cursor_x; /* position of cursor in input window */
+ int win_input_x; /* input window position */
+ int win_input_y; /* input window position */
+ int win_input_width; /* width of input window */
+ int win_input_height; /* height of input window */
+ int win_input_cursor_x; /* position of cursor in input win */
/* GUI specific objects */
- void *gui_objects; /* pointer to a GUI specific struct */
+ 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 */
+ 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) used */
/* DCC */
- void *dcc_first; /* first dcc displayed */
- void *dcc_selected; /* selected dcc */
- void *dcc_last_displayed; /* last dcc displayed (for scroll) */
+ 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 */
+ struct t_gui_buffer *buffer; /* buffer currently displayed */
- 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 */
+ int first_line_displayed; /* = 1 if first line is displayed */
+ struct 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 */
+ struct 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 *prev_window; /* link to previous window */
+ struct t_gui_window *next_window; /* link to next window */
};
struct t_gui_window_tree
{
- t_gui_window_tree *parent_node; /* pointer to parent node */
+ struct 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 */
+ int split_horiz; /* 1 if horizontal, 0 if vertical */
+ int split_pct; /* % of split size (child1) */
+ struct t_gui_window_tree *child1; /* first child, NULL if a leaf */
+ struct t_gui_window_tree *child2; /* second child, NULL if a leaf */
/* leaf info */
- t_gui_window *window; /* pointer to window, NULL if a node */
+ struct 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;
+extern struct t_gui_window *gui_windows;
+extern struct t_gui_window *last_gui_window;
+extern struct t_gui_window *gui_current_window;
+extern struct t_gui_window_tree *gui_windows_tree;
+
+/* window functions */
+extern int gui_window_tree_init (struct t_gui_window *);
+extern void gui_window_tree_node_to_leaf (struct t_gui_window_tree *,
+ struct t_gui_window *);
+extern void gui_window_tree_free (struct t_gui_window_tree **);
+extern struct t_gui_window *gui_window_new (struct t_gui_window *, int, int,
+ int, int, int, int);
+extern void gui_window_free (struct t_gui_window *);
+extern struct t_gui_window *gui_window_search_by_buffer (struct t_gui_buffer *);
+extern void gui_window_switch_server (struct t_gui_window *);
+extern void gui_window_switch_previous (struct t_gui_window *);
+extern void gui_window_switch_next (struct t_gui_window *);
+extern void gui_window_switch_by_buffer (struct t_gui_window *, int);
+extern void gui_window_scroll (struct t_gui_window *, char *);
+extern void gui_window_search_start (struct t_gui_window *);
+extern void gui_window_search_restart (struct t_gui_window *);
+extern void gui_window_search_stop (struct t_gui_window *);
+extern int gui_window_search_text (struct t_gui_window *);
+extern void gui_window_print_log ();
+
+/* window functions (GUI dependent) */
+
+extern int gui_window_get_width ();
+extern int gui_window_get_height ();
+extern int gui_window_objects_init (struct t_gui_window *);
+extern void gui_window_objects_free (struct t_gui_window *, int);
+extern int gui_window_calculate_pos_size (struct t_gui_window *, int);
+extern void gui_window_redraw_buffer (struct t_gui_buffer *);
+extern void gui_window_redraw_all_buffers ();
+extern void gui_window_switch_to_buffer (struct t_gui_window *, struct t_gui_buffer *);
+extern void gui_window_page_up (struct t_gui_window *);
+extern void gui_window_page_down (struct t_gui_window *);
+extern void gui_window_scroll_up (struct t_gui_window *);
+extern void gui_window_scroll_down (struct t_gui_window *);
+extern void gui_window_scroll_top (struct t_gui_window *);
+extern void gui_window_scroll_bottom (struct t_gui_window *);
+extern void gui_window_scroll_topic_left (struct t_gui_window *);
+extern void gui_window_scroll_topic_right (struct t_gui_window *);
+extern void gui_window_nick_beginning (struct t_gui_window *);
+extern void gui_window_nick_end (struct t_gui_window *);
+extern void gui_window_nick_page_up (struct t_gui_window *);
+extern void gui_window_nick_page_down (struct t_gui_window *);
+extern void gui_window_init_subwindows (struct t_gui_window *);
+extern void gui_window_refresh_windows ();
+extern void gui_window_split_horiz (struct t_gui_window *, int);
+extern void gui_window_split_vertic (struct t_gui_window *, int);
+extern void gui_window_resize (struct t_gui_window *, int);
+extern int gui_window_merge (struct t_gui_window *);
+extern void gui_window_merge_all (struct t_gui_window *);
+extern void gui_window_switch_up (struct t_gui_window *);
+extern void gui_window_switch_down (struct t_gui_window *);
+extern void gui_window_switch_left (struct t_gui_window *);
+extern void gui_window_switch_right (struct t_gui_window *);
+extern void gui_window_refresh_screen ();
+extern void gui_window_title_set ();
+extern void gui_window_title_reset ();
+extern void gui_window_objects_print_log (struct t_gui_window *);
#endif /* gui-window.h */
diff --git a/src/gui/gui.h b/src/gui/gui.h
deleted file mode 100644
index 744f9d7a7..000000000
--- a/src/gui/gui.h
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (c) 2003-2007 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 3 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, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef __WEECHAT_GUI_H
-#define __WEECHAT_GUI_H 1
-
-#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, GUI_MSG_TYPE_INFO, -1, NULL, fmt, ##argz)
-
-#define gui_printf_keep_colors(buffer, fmt, argz...) \
- gui_printf_internal(buffer, 1, GUI_MSG_TYPE_INFO, 1, NULL, fmt, ##argz)
-
-#define gui_printf_type(buffer, type, fmt, argz...) \
- gui_printf_internal(buffer, 1, type, -1, NULL, fmt, ##argz)
-
-#define gui_printf_type_nick(buffer, type, nick, fmt, argz...) \
- gui_printf_internal(buffer, 1, type, -1, nick, fmt, ##argz)
-
-#define gui_printf_nolog(buffer, fmt, argz...) \
- gui_printf_internal(buffer, 1, GUI_MSG_TYPE_INFO | GUI_MSG_TYPE_NOLOG, -1, NULL, fmt, ##argz)
-
-#define gui_printf_nolog_notime(buffer, fmt, argz...) \
- gui_printf_internal(buffer, 0, GUI_MSG_TYPE_NOLOG, -1, NULL, fmt, ##argz)
-
-
-typedef struct t_gui_infobar t_gui_infobar;
-
-struct t_gui_infobar
-{
- int color; /* text color */
- char *text; /* infobar text */
- int remaining_time; /* delay (sec) before erasing this text */
- /* if < 0, text is never erased (except */
- /* by user action to erase it) */
- t_gui_infobar *next_infobar; /* next message for infobar */
-};
-
-/* GUI variables */
-
-extern int gui_init_ok;
-extern int gui_ok;
-extern int gui_add_hotlist;
-extern t_gui_infobar *gui_infobar;
-extern char *gui_input_clipboard;
-extern time_t gui_last_activity_time;
-
-/* 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 **);
-extern t_gui_window *gui_window_new (t_gui_window *, int, int, int, int, int, int);
-extern void gui_window_free (t_gui_window *);
-extern void gui_window_switch_server (t_gui_window *);
-extern void gui_window_switch_previous (t_gui_window *);
-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 *);
-
-/* 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 *);
-extern t_gui_buffer *gui_buffer_search_by_number (int);
-extern t_gui_window *gui_buffer_find_window (t_gui_buffer *);
-extern void gui_buffer_find_context (void *, void *,
- t_gui_window **, t_gui_buffer **);
-extern int gui_buffer_is_scrolled (t_gui_buffer *);
-extern t_gui_buffer *gui_buffer_get_dcc (t_gui_window *);
-extern void gui_buffer_clear (t_gui_buffer *);
-extern void gui_buffer_clear_all ();
-extern void gui_buffer_free (t_gui_buffer *, int);
-extern t_gui_line *gui_buffer_line_new (t_gui_buffer *, time_t);
-extern int gui_buffer_line_search (t_gui_line *, char *, int);
-extern void gui_buffer_merge_servers (t_gui_window *);
-extern void gui_buffer_split_server (t_gui_window *);
-extern void gui_buffer_switch_previous (t_gui_window *);
-extern void gui_buffer_switch_next (t_gui_window *);
-extern void gui_buffer_switch_dcc (t_gui_window *);
-extern void gui_buffer_switch_raw_data (t_gui_window *);
-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_search_start (t_gui_window *);
-extern void gui_buffer_search_restart (t_gui_window *);
-extern void gui_buffer_search_stop (t_gui_window *);
-extern int gui_buffer_search_text (t_gui_window *);
-extern void gui_buffer_scroll (t_gui_window *, char *);
-extern void gui_buffer_dump_hexa (t_gui_buffer *);
-extern void gui_buffer_print_log (t_gui_buffer *);
-
-/* panel */
-extern int gui_panel_global_get_size (t_gui_panel *, int);
-extern t_gui_panel *gui_panel_new (char *, int, int, int, int);
-extern void gui_panel_free (t_gui_panel *);
-extern void gui_panel_print_log ();
-
-/* action */
-extern void gui_action_clipboard_copy (char *, int);
-extern void gui_action_clipboard_paste (t_gui_window *, char *);
-extern void gui_action_return (t_gui_window *, char *);
-extern void gui_action_tab (t_gui_window *, char *);
-extern void gui_action_tab_previous (t_gui_window *, char *);
-extern void gui_action_backspace (t_gui_window *, char *);
-extern void gui_action_delete (t_gui_window *, char *);
-extern void gui_action_delete_previous_word (t_gui_window *, char *);
-extern void gui_action_delete_next_word (t_gui_window *, char *);
-extern void gui_action_delete_begin_of_line (t_gui_window *, char *);
-extern void gui_action_delete_end_of_line (t_gui_window *, char *);
-extern void gui_action_delete_line (t_gui_window *, char *);
-extern void gui_action_transpose_chars (t_gui_window *, char *);
-extern void gui_action_home (t_gui_window *, char *);
-extern void gui_action_end (t_gui_window *, char *);
-extern void gui_action_left (t_gui_window *, char *);
-extern void gui_action_previous_word (t_gui_window *, char *);
-extern void gui_action_right (t_gui_window *, char *);
-extern void gui_action_next_word (t_gui_window *, char *);
-extern void gui_action_up (t_gui_window *, char *);
-extern void gui_action_up_global (t_gui_window *, char *);
-extern void gui_action_down (t_gui_window *, char *);
-extern void gui_action_down_global (t_gui_window *, char *);
-extern void gui_action_page_up (t_gui_window *, char *);
-extern void gui_action_page_down (t_gui_window *, char *);
-extern void gui_action_scroll_up (t_gui_window *, char *);
-extern void gui_action_scroll_down (t_gui_window *, char *);
-extern void gui_action_scroll_top (t_gui_window *, char *);
-extern void gui_action_scroll_bottom (t_gui_window *, char *);
-extern void gui_action_scroll_topic_left (t_gui_window *, char *);
-extern void gui_action_scroll_topic_right (t_gui_window *, char *);
-extern void gui_action_nick_beginning (t_gui_window *, char *);
-extern void gui_action_nick_end (t_gui_window *, char *);
-extern void gui_action_nick_page_up (t_gui_window *, char *);
-extern void gui_action_nick_page_down (t_gui_window *, char *);
-extern void gui_action_jump_smart (t_gui_window *, char *);
-extern void gui_action_jump_dcc (t_gui_window *, char *);
-extern void gui_action_jump_raw_data (t_gui_window *, char *);
-extern void gui_action_jump_last_buffer (t_gui_window *, char *);
-extern void gui_action_jump_previous_buffer (t_gui_window *, char *);
-extern void gui_action_jump_server (t_gui_window *, char *);
-extern void gui_action_jump_next_server (t_gui_window *, char *);
-extern void gui_action_switch_server (t_gui_window *, char *);
-extern void gui_action_scroll_previous_highlight (t_gui_window *, char *);
-extern void gui_action_scroll_next_highlight (t_gui_window *, char *);
-extern void gui_action_scroll_unread (t_gui_window *, char *);
-extern void gui_action_set_unread (t_gui_window *, char *);
-extern void gui_action_hotlist_clear (t_gui_window *, char *);
-extern void gui_action_infobar_clear (t_gui_window *, char *);
-extern void gui_action_refresh_screen (t_gui_window *, char *);
-extern void gui_action_grab_key (t_gui_window *, char *);
-extern void gui_action_insert_string (t_gui_window *, char *);
-extern void gui_action_search_text (t_gui_window *, char *);
-
-/* key */
-extern void gui_keyboard_init ();
-extern void gui_keyboard_grab_init ();
-extern void gui_keyboard_grab_end ();
-extern char *gui_keyboard_get_internal_code (char *);
-extern char *gui_keyboard_get_expanded_name (char *);
-extern t_gui_key *gui_keyboard_search (char *);
-extern t_gui_key_func *gui_keyboard_function_search_by_name (char *);
-extern char *gui_keyboard_function_search_by_ptr (t_gui_key_func *);
-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 ();
-extern void gui_keyboard_buffer_reset ();
-extern void gui_keyboard_buffer_add (int);
-extern int gui_keyboard_get_paste_lines ();
-extern void gui_keyboard_paste_accept ();
-extern void gui_keyboard_paste_cancel ();
-
-/* log */
-extern void gui_log_write_date (t_gui_buffer *);
-extern void gui_log_write_line (t_gui_buffer *, char *);
-extern void gui_log_write (t_gui_buffer *, char *);
-extern void gui_log_start (t_gui_buffer *);
-extern void gui_log_end (t_gui_buffer *);
-
-/* other */
-extern int gui_word_strlen (t_gui_window *, char *);
-extern int gui_word_real_pos (t_gui_window *, char *, int);
-extern void gui_printf_internal (t_gui_buffer *, int, int, int, char *, char *, ...);
-extern void gui_printf_raw_data (void *, int, int, char *);
-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 ();
-extern void gui_infobar_remove_all ();
-extern void gui_input_optimize_size (t_gui_buffer *);
-extern void gui_input_init_color_mask (t_gui_buffer *);
-extern void gui_input_move (t_gui_buffer *, char *, char *, int );
-extern void gui_input_complete (t_gui_window *);
-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 dependent functions */
-
-/* color */
-extern int gui_color_assign (int *, char *);
-extern char *gui_color_get_name (int);
-extern unsigned char *gui_color_decode (unsigned char *, int, int);
-extern unsigned char *gui_color_decode_for_user_entry (unsigned char *);
-extern unsigned char *gui_color_encode (unsigned char *, int);
-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, 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, 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_redraw_all_buffers ();
-extern void gui_window_switch_to_buffer (t_gui_window *, t_gui_buffer *);
-extern void gui_window_page_up (t_gui_window *);
-extern void gui_window_page_down (t_gui_window *);
-extern void gui_window_scroll_up (t_gui_window *);
-extern void gui_window_scroll_down (t_gui_window *);
-extern void gui_window_scroll_top (t_gui_window *);
-extern void gui_window_scroll_bottom (t_gui_window *);
-extern void gui_window_scroll_topic_left (t_gui_window *);
-extern void gui_window_scroll_topic_right (t_gui_window *);
-extern void gui_window_nick_beginning (t_gui_window *);
-extern void gui_window_nick_end (t_gui_window *);
-extern void gui_window_nick_page_up (t_gui_window *);
-extern void gui_window_nick_page_down (t_gui_window *);
-extern void gui_window_init_subwindows (t_gui_window *);
-extern void gui_window_refresh_windows ();
-extern void gui_window_split_horiz (t_gui_window *, int);
-extern void gui_window_split_vertic (t_gui_window *, int);
-extern void gui_window_resize (t_gui_window *, int);
-extern int gui_window_merge (t_gui_window *);
-extern void gui_window_merge_all (t_gui_window *);
-extern void gui_window_switch_up (t_gui_window *);
-extern void gui_window_switch_down (t_gui_window *);
-extern void gui_window_switch_left (t_gui_window *);
-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 ();
-extern void gui_main_end ();
-
-#endif /* gui.h */