mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 15:26:37 +02:00
Renamed many sources and functions in src/gui, improved display of messages in buffer (faster and using less memory)
This commit is contained in:
@@ -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})
|
||||
|
||||
+25
-10
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
+349
-362
File diff suppressed because it is too large
Load Diff
+266
-421
@@ -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];
|
||||
|
||||
t_gui_color *gui_color[GUI_NUM_COLORS];
|
||||
|
||||
/*
|
||||
* gui_color_search: search a color by name
|
||||
* Return: number of color in WeeChat colors table
|
||||
*/
|
||||
|
||||
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;
|
||||
@@ -101,6 +145,110 @@ gui_color_assign (int *color, char *color_name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_assign: assign a WeeChat color (read from config)
|
||||
*/
|
||||
|
||||
/*void
|
||||
gui_color_assign (t_gui_color **color, char *fg_and_bg)
|
||||
{
|
||||
char *color_fg, *color_bg, *color_fg2, *color_bg2;
|
||||
int value_fg, value_bg;
|
||||
t_config_option *ptr_option;
|
||||
|
||||
if (!(*color))
|
||||
{
|
||||
*color = (t_gui_color *)malloc (sizeof (t_gui_color));
|
||||
if (!(*color))
|
||||
return;
|
||||
*color->foreground = 0;
|
||||
*color->background = 0;
|
||||
*color->attributes = 0;
|
||||
*color->string = NULL;
|
||||
}
|
||||
|
||||
gui_color_get_fg_bg (fg_and_bg, &color_fg, &color_bg);
|
||||
|
||||
if (color_fg && color_bg)
|
||||
{
|
||||
// look for curses colors in table
|
||||
value_fg = gui_color_search (color_fg);
|
||||
value_bg = gui_color_search (color_bg);
|
||||
|
||||
if (value_fg < 0)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
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_get_name: get color name
|
||||
*/
|
||||
@@ -111,329 +259,18 @@ 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()
|
||||
*/
|
||||
|
||||
unsigned char *
|
||||
gui_color_decode (unsigned char *string, int keep_irc_colors, int keep_weechat_attr)
|
||||
{
|
||||
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;
|
||||
|
||||
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:
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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, 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_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;
|
||||
}
|
||||
}
|
||||
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, 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;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_build: build a WeeChat color with foreground,
|
||||
* background and attributes (attributes are
|
||||
* 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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+105
-199
@@ -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,92 +59,13 @@ 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));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -153,7 +73,7 @@ gui_input_get_prompt_length (t_gui_window *window, char *nick)
|
||||
*/
|
||||
|
||||
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 ();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+200
-288
@@ -29,285 +29,22 @@
|
||||
#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
|
||||
|
||||
|
||||
int send_irc_quit = 0;
|
||||
|
||||
|
||||
/*
|
||||
* gui_main_quit: quit weechat (signal received)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_quit ()
|
||||
{
|
||||
quit_weechat = 1;
|
||||
send_irc_quit = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_loop: main loop for WeeChat with ncurses GUI
|
||||
*/
|
||||
|
||||
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;
|
||||
char text_time[1024], *text_time2;
|
||||
time_t new_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);
|
||||
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);
|
||||
signal (SIGHUP, gui_main_quit);
|
||||
|
||||
while (!quit_weechat)
|
||||
{
|
||||
/* refresh needed ? */
|
||||
if (gui_refresh_screen_needed)
|
||||
gui_window_refresh_screen (0);
|
||||
|
||||
new_time = time (NULL);
|
||||
local_time = localtime (&new_time);
|
||||
|
||||
/* minute has changed ? => redraw infobar */
|
||||
if (local_time->tm_min != old_min)
|
||||
{
|
||||
old_min = local_time->tm_min;
|
||||
gui_infobar_draw (gui_current_window->buffer, 1);
|
||||
|
||||
if (cfg_look_day_change
|
||||
&& (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);
|
||||
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 (text_time2)
|
||||
free (text_time2);
|
||||
gui_add_hotlist = 1;
|
||||
}
|
||||
old_day = local_time->tm_mday;
|
||||
}
|
||||
|
||||
/* second has changed ? */
|
||||
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)
|
||||
{
|
||||
gui_infobar_draw_time (gui_current_window->buffer);
|
||||
wmove (GUI_CURSES(gui_current_window)->win_input,
|
||||
0, gui_current_window->win_input_cursor_x);
|
||||
wrefresh (GUI_CURSES(gui_current_window)->win_input);
|
||||
}
|
||||
|
||||
/* infobar count down */
|
||||
if (gui_infobar && gui_infobar->remaining_time > 0)
|
||||
{
|
||||
gui_infobar->remaining_time--;
|
||||
if (gui_infobar->remaining_time == 0)
|
||||
{
|
||||
gui_infobar_remove ();
|
||||
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 */
|
||||
|
||||
/* 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);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 8000;
|
||||
|
||||
FD_SET (STDIN_FILENO, &read_fd);
|
||||
|
||||
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
|
||||
{
|
||||
if (FD_ISSET (STDIN_FILENO, &read_fd))
|
||||
{
|
||||
gui_keyboard_read ();
|
||||
}
|
||||
}
|
||||
else
|
||||
gui_keyboard_flush ();
|
||||
#endif
|
||||
|
||||
/* read sockets (servers, child process when connecting, FIFO pipe) */
|
||||
|
||||
FD_ZERO (&read_fd);
|
||||
|
||||
#ifdef __GNU__
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 10000;
|
||||
FD_SET (STDIN_FILENO, &read_fd);
|
||||
#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)
|
||||
{
|
||||
#ifdef __GNU__
|
||||
if (FD_ISSET (STDIN_FILENO, &read_fd))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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)
|
||||
@@ -328,6 +65,8 @@ gui_main_pre_init (int *argc, char **argv[])
|
||||
void
|
||||
gui_main_init ()
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
initscr ();
|
||||
|
||||
curs_set (1);
|
||||
@@ -336,6 +75,7 @@ gui_main_init ()
|
||||
raw ();
|
||||
|
||||
gui_color_init ();
|
||||
gui_chat_prefix_build ();
|
||||
|
||||
gui_infobar = NULL;
|
||||
|
||||
@@ -345,22 +85,198 @@ gui_main_init ()
|
||||
|
||||
/* 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;
|
||||
gui_buffer_new (gui_windows, NULL, NULL, GUI_BUFFER_TYPE_STANDARD, 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 ();
|
||||
|
||||
signal (SIGWINCH, gui_window_refresh_screen_sigwinch);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_quit: quit weechat (signal received)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_quit ()
|
||||
{
|
||||
quit_weechat = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_loop: main loop for WeeChat with ncurses GUI
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_loop ()
|
||||
{
|
||||
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;
|
||||
struct timeval tv_time;
|
||||
struct tm *local_time;
|
||||
|
||||
quit_weechat = 0;
|
||||
|
||||
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;
|
||||
|
||||
/* if SIGTERM or SIGHUP received => quit */
|
||||
signal (SIGTERM, gui_main_quit);
|
||||
signal (SIGHUP, gui_main_quit);
|
||||
|
||||
while (!quit_weechat)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
old_min = local_time->tm_min;
|
||||
gui_infobar_draw (gui_current_window->buffer, 1);
|
||||
|
||||
if (cfg_look_day_change
|
||||
&& (local_time->tm_mday != old_day))
|
||||
{
|
||||
strftime (text_time, sizeof (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_FORMATED)
|
||||
gui_chat_printf (ptr_buffer,
|
||||
_("\t\tDay changed to %s"),
|
||||
(text_time2) ?
|
||||
text_time2 : text_time);
|
||||
}
|
||||
if (text_time2)
|
||||
free (text_time2);
|
||||
gui_add_hotlist = 1;
|
||||
}
|
||||
old_day = local_time->tm_mday;
|
||||
}
|
||||
|
||||
/* second has changed ? */
|
||||
if (local_time->tm_sec != old_sec)
|
||||
{
|
||||
old_sec = local_time->tm_sec;
|
||||
|
||||
/* display time in infobar (if seconds displayed) */
|
||||
if (cfg_look_infobar_seconds)
|
||||
{
|
||||
gui_infobar_draw_time (gui_current_window->buffer);
|
||||
wmove (GUI_CURSES(gui_current_window)->win_input,
|
||||
0, gui_current_window->win_input_cursor_x);
|
||||
wrefresh (GUI_CURSES(gui_current_window)->win_input);
|
||||
}
|
||||
|
||||
/* infobar count down */
|
||||
if (gui_infobar && gui_infobar->remaining_time > 0)
|
||||
{
|
||||
gui_infobar->remaining_time--;
|
||||
if (gui_infobar->remaining_time == 0)
|
||||
{
|
||||
gui_infobar_remove ();
|
||||
gui_infobar_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* read keyboard */
|
||||
|
||||
/* on GNU/Hurd 2 select() are causing troubles with keyboard */
|
||||
/* waiting for a fix, we use only one select() */
|
||||
#ifndef __GNU__
|
||||
FD_ZERO (&read_fds);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 8000;
|
||||
|
||||
FD_SET (STDIN_FILENO, &read_fds);
|
||||
|
||||
if (select (FD_SETSIZE, &read_fds, NULL, NULL, &timeout) > 0)
|
||||
{
|
||||
if (FD_ISSET (STDIN_FILENO, &read_fds))
|
||||
{
|
||||
gui_keyboard_read ();
|
||||
}
|
||||
}
|
||||
else
|
||||
gui_keyboard_flush ();
|
||||
#endif
|
||||
|
||||
/* 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_fds);
|
||||
#else
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 2000;
|
||||
#endif
|
||||
|
||||
if (select (FD_SETSIZE,
|
||||
&read_fds, &write_fds, &except_fds,
|
||||
&timeout) > 0)
|
||||
{
|
||||
#ifdef __GNU__
|
||||
if (FD_ISSET (STDIN_FILENO, &read_fds))
|
||||
{
|
||||
gui_keyboard_read ();
|
||||
}
|
||||
#endif
|
||||
hook_fd_exec (&read_fds, &write_fds, &except_fds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_end: GUI end
|
||||
*/
|
||||
@@ -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 ();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
/* 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_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)
|
||||
{
|
||||
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);
|
||||
|
||||
+146
-160
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
+58
-200
@@ -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)
|
||||
@@ -406,68 +326,6 @@ gui_chat_display_word (t_gui_window *window,
|
||||
(void) simulate;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-352
@@ -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;
|
||||
@@ -110,332 +91,6 @@ 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()
|
||||
*/
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -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];*/
|
||||
|
||||
+11
-89
@@ -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;*/
|
||||
|
||||
@@ -50,88 +48,12 @@ gui_input_set_color (t_gui_window *window, int irc_color)
|
||||
(void) 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;
|
||||
|
||||
@@ -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
|
||||
|
||||
+36
-31
@@ -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;
|
||||
@@ -54,17 +54,6 @@ GtkWidget *gui_gtk_entry_input;
|
||||
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,15 +162,34 @@ 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
|
||||
*/
|
||||
@@ -188,15 +197,11 @@ gui_main_init ()
|
||||
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 ();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+5
-13
@@ -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 ();
|
||||
|
||||
+469
-466
File diff suppressed because it is too large
Load Diff
@@ -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 */
|
||||
+402
-984
File diff suppressed because it is too large
Load Diff
+118
-107
@@ -20,145 +20,156 @@
|
||||
#ifndef __WEECHAT_GUI_BUFFER_H
|
||||
#define __WEECHAT_GUI_BUFFER_H 1
|
||||
|
||||
#include "../common/completion.h"
|
||||
#include "../common/history.h"
|
||||
enum t_gui_buffer_type
|
||||
{
|
||||
GUI_BUFFER_TYPE_FORMATED = 0,
|
||||
GUI_BUFFER_TYPE_FREE,
|
||||
};
|
||||
|
||||
#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 "<=="
|
||||
|
||||
#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 */
|
||||
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. */
|
||||
|
||||
int number; /* buffer number (for jump/switch) */
|
||||
/* logging */
|
||||
char *log_filename; /* filename for saving content */
|
||||
FILE *log_file; /* file descriptor for log */
|
||||
|
||||
/* 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 */
|
||||
/* buffer title */
|
||||
char *title; /* buffer title */
|
||||
|
||||
/* 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) */
|
||||
/* 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) */
|
||||
|
||||
/* 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 */
|
||||
/* 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 */
|
||||
|
||||
/* file to save buffer content */
|
||||
char *log_filename; /* filename for saving buffer content */
|
||||
FILE *log_file; /* for logging buffer to file */
|
||||
|
||||
/* inupt buffer */
|
||||
int has_input; /* = 1 if buffer has input (DCC has not)*/
|
||||
char *input_buffer; /* input buffer */
|
||||
char *input_buffer_color_mask; /* color mask for input buffer */
|
||||
int input_buffer_alloc; /* input buffer: allocated size in mem */
|
||||
int input_buffer_size; /* buffer size in bytes */
|
||||
int input_buffer_length; /* number of chars in buffer */
|
||||
int input_buffer_pos; /* position into buffer */
|
||||
int input_buffer_1st_display; /* first char displayed on screen */
|
||||
/* 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 */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -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 */
|
||||
@@ -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;
|
||||
}
|
||||
+110
-102
@@ -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
|
||||
/* WeeChat internal color attributes (should never be in protocol messages) */
|
||||
|
||||
/* attributes in IRC messages for color & style (bold, ..) */
|
||||
#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_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"
|
||||
#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 */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
+436
-448
File diff suppressed because it is too large
Load Diff
+32
-35
@@ -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 */
|
||||
|
||||
#endif /* completion.h */
|
||||
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 /* gui-completion.h */
|
||||
|
||||
+55
-57
@@ -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;
|
||||
}
|
||||
|
||||
+15
-16
@@ -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 */
|
||||
|
||||
+82
-75
@@ -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);
|
||||
|
||||
+30
-28
@@ -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 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 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;
|
||||
|
||||
#endif /* hotlist.h */
|
||||
/* hotlist functions */
|
||||
|
||||
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 /* gui-hotlist.h */
|
||||
|
||||
@@ -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 ();
|
||||
}
|
||||
}
|
||||
@@ -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 */
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
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 *);
|
||||
|
||||
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;
|
||||
}
|
||||
/* input functions (GUI dependent) */
|
||||
|
||||
/*
|
||||
* gui_panel_window_free: delete a panel window
|
||||
*/
|
||||
extern void gui_input_draw (struct t_gui_buffer *, int);
|
||||
|
||||
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);
|
||||
}
|
||||
#endif /* gui-input.h */
|
||||
+47
-42
@@ -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 pressed) */
|
||||
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) */
|
||||
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);
|
||||
}
|
||||
|
||||
+29
-3
@@ -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 */
|
||||
|
||||
+36
-120
@@ -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))
|
||||
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));
|
||||
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;
|
||||
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");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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 */
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
+450
-88
@@ -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--;
|
||||
@@ -300,15 +296,40 @@ gui_window_free (t_gui_window *window)
|
||||
free (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;
|
||||
@@ -407,57 +428,398 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
+118
-63
@@ -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 */
|
||||
|
||||
-300
@@ -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 */
|
||||
Reference in New Issue
Block a user