mirror of
https://github.com/weechat/weechat.git
synced 2026-07-06 17:53:13 +02:00
Splited GUI sources
This commit is contained in:
@@ -1381,8 +1381,8 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
|
||||
ptr_channel = CHANNEL(buffer);
|
||||
gui_buffer_free (ptr_channel->buffer, 1);
|
||||
channel_free (SERVER(buffer), ptr_channel);
|
||||
gui_draw_buffer_status (buffer, 1);
|
||||
gui_draw_buffer_input (buffer, 1);
|
||||
gui_status_draw (buffer, 1);
|
||||
gui_input_draw (buffer, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1414,7 +1414,7 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
|
||||
gui_buffer_free (buffer, 1);
|
||||
}
|
||||
}
|
||||
gui_draw_buffer_status (buffer, 1);
|
||||
gui_status_draw (buffer, 1);
|
||||
}
|
||||
else if (ascii_strcasecmp (argv[0], "notify") == 0)
|
||||
{
|
||||
@@ -1563,8 +1563,8 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
|
||||
}
|
||||
if (ptr_buffer)
|
||||
{
|
||||
gui_switch_to_buffer (window, ptr_buffer);
|
||||
gui_redraw_buffer (ptr_buffer);
|
||||
gui_window_switch_to_buffer (window, ptr_buffer);
|
||||
gui_window_redraw_buffer (ptr_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2093,7 +2093,7 @@ weechat_cmd_disconnect (t_irc_server *server, t_irc_channel *channel,
|
||||
_("Auto-reconnection is cancelled\n"));
|
||||
}
|
||||
server_disconnect (ptr_server, 0);
|
||||
gui_draw_buffer_status (buffer, 1);
|
||||
gui_status_draw (buffer, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2879,7 +2879,7 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
|
||||
if (server_name)
|
||||
free (server_name);
|
||||
|
||||
gui_redraw_buffer (buffer);
|
||||
gui_window_redraw_buffer (buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -3088,7 +3088,7 @@ weechat_cmd_set_display_option (t_config_option *option, char *prefix, void *val
|
||||
option->array_values[*((int *)value)]);
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
color_name = gui_get_color_name (*((int *)value));
|
||||
color_name = gui_color_get_name (*((int *)value));
|
||||
gui_printf (NULL, "%s%s\n",
|
||||
GUI_COLOR(COLOR_WIN_CHAT_HOST),
|
||||
(color_name) ? color_name : _("(unknown)"));
|
||||
@@ -3798,7 +3798,7 @@ weechat_cmd_upgrade (t_irc_server *server, t_irc_channel *channel,
|
||||
plugin_end ();
|
||||
#endif
|
||||
(void) config_write (NULL);
|
||||
gui_end ();
|
||||
gui_main_end ();
|
||||
fifo_remove ();
|
||||
if (weechat_log_file)
|
||||
fclose (weechat_log_file);
|
||||
|
||||
@@ -644,7 +644,7 @@ completion_list_add_option_value (t_completion *completion)
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
(option_value) ?
|
||||
gui_get_color_name (*((int *)(option_value))) :
|
||||
gui_color_get_name (*((int *)(option_value))) :
|
||||
option->default_string);
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
|
||||
@@ -472,7 +472,7 @@ session_crash (FILE *file, char *message, ...)
|
||||
va_end (argptr);
|
||||
|
||||
fclose (file);
|
||||
gui_end ();
|
||||
gui_main_end ();
|
||||
fprintf (stderr, "%s %s\n",
|
||||
WEECHAT_ERROR, buffer);
|
||||
fprintf (stderr,
|
||||
@@ -1464,7 +1464,7 @@ session_load_line (FILE *file)
|
||||
}
|
||||
|
||||
/* allocate line */
|
||||
line = gui_line_new (session_current_buffer);
|
||||
line = gui_buffer_line_new (session_current_buffer);
|
||||
if (!line)
|
||||
{
|
||||
session_crash (file, _("can't create new line"));
|
||||
@@ -1685,8 +1685,8 @@ session_load (char *filename)
|
||||
ptr_server->buffer = gui_buffers;
|
||||
}
|
||||
|
||||
gui_switch_to_buffer (gui_windows, gui_buffers);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
gui_window_switch_to_buffer (gui_windows, gui_buffers);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
|
||||
fclose (file);
|
||||
|
||||
|
||||
@@ -1062,7 +1062,7 @@ weechat_sigsegv ()
|
||||
weechat_dump (1);
|
||||
dcc_end ();
|
||||
server_free_all ();
|
||||
gui_end ();
|
||||
gui_main_end ();
|
||||
fprintf (stderr, "\n");
|
||||
fprintf (stderr, "*** Very bad! WeeChat has crashed (SIGSEGV received)\n");
|
||||
fprintf (stderr, "*** Full crash dump was saved to %s/weechat.log file\n", weechat_home);
|
||||
@@ -1093,7 +1093,7 @@ main (int argc, char *argv[])
|
||||
signal (SIGQUIT, SIG_IGN); /* ignore SIGQUIT signal */
|
||||
signal (SIGPIPE, SIG_IGN); /* ignore SIGPIPE signal */
|
||||
signal (SIGSEGV, weechat_sigsegv); /* crash dump when SIGSEGV received */
|
||||
gui_pre_init (&argc, &argv); /* pre-initiliaze interface */
|
||||
gui_main_pre_init (&argc, &argv); /* pre-initiliaze interface */
|
||||
weechat_init_vars (); /* initialize some variables */
|
||||
gui_key_init (); /* init keyb. (default key bindings)*/
|
||||
weechat_parse_args (argc, argv); /* parse command line args */
|
||||
@@ -1103,7 +1103,7 @@ main (int argc, char *argv[])
|
||||
weechat_config_read (); /* read configuration */
|
||||
weechat_create_config_dirs (); /* create config directories */
|
||||
utf8_init (); /* init UTF-8 in WeeChat */
|
||||
gui_init (); /* init WeeChat interface */
|
||||
gui_main_init (); /* init WeeChat interface */
|
||||
fifo_create (); /* FIFO pipe for remote control */
|
||||
if (weechat_session)
|
||||
session_load (weechat_session); /* load previous session if asked */
|
||||
@@ -1125,7 +1125,7 @@ main (int argc, char *argv[])
|
||||
command_index_free (); /* free commands index */
|
||||
dcc_end (); /* remove all DCC */
|
||||
server_free_all (); /* free all servers */
|
||||
gui_end (); /* shut down WeeChat GUI */
|
||||
gui_main_end (); /* shut down WeeChat GUI */
|
||||
weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */
|
||||
|
||||
return EXIT_SUCCESS; /* make gcc happy (never executed) */
|
||||
|
||||
+16
-16
@@ -1110,9 +1110,9 @@ void
|
||||
config_change_title ()
|
||||
{
|
||||
if (cfg_look_set_title)
|
||||
gui_set_window_title ();
|
||||
gui_window_set_title ();
|
||||
else
|
||||
gui_reset_window_title ();
|
||||
gui_window_reset_title ();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1122,8 +1122,8 @@ config_change_title ()
|
||||
void
|
||||
config_change_buffers ()
|
||||
{
|
||||
gui_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1133,7 +1133,7 @@ config_change_buffers ()
|
||||
void
|
||||
config_change_buffer_content ()
|
||||
{
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1146,7 +1146,7 @@ config_change_read_marker ()
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
gui_redraw_buffer (ptr_win->buffer);
|
||||
gui_window_redraw_buffer (ptr_win->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1157,7 +1157,7 @@ void
|
||||
config_change_charset ()
|
||||
{
|
||||
utf8_init ();
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1169,9 +1169,9 @@ void
|
||||
config_change_one_server_buffer ()
|
||||
{
|
||||
if (cfg_look_one_server_buffer)
|
||||
gui_merge_servers (gui_current_window);
|
||||
gui_buffer_merge_servers (gui_current_window);
|
||||
else
|
||||
gui_split_server (gui_current_window);
|
||||
gui_buffer_split_server (gui_current_window);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1181,9 +1181,9 @@ config_change_one_server_buffer ()
|
||||
void
|
||||
config_change_color ()
|
||||
{
|
||||
gui_init_color_pairs ();
|
||||
gui_rebuild_weechat_colors ();
|
||||
gui_refresh_windows ();
|
||||
gui_color_init_pairs ();
|
||||
gui_color_rebuild_weechat ();
|
||||
gui_window_refresh_windows ();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1338,7 +1338,7 @@ config_option_set_value (t_config_option *option, char *value)
|
||||
*(option->ptr_int) = int_value;
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
if (!gui_assign_color (option->ptr_int, value))
|
||||
if (!gui_color_assign (option->ptr_int, value))
|
||||
return -1;
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
@@ -1574,7 +1574,7 @@ config_set_server_value (t_irc_server *server, char *option_name,
|
||||
*((int *)(ptr_data)) = int_value;
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
if (!gui_assign_color ((int *)ptr_data, value))
|
||||
if (!gui_color_assign ((int *)ptr_data, value))
|
||||
return -2;
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
@@ -1792,7 +1792,7 @@ config_default_values ()
|
||||
int_value;
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
if (!gui_assign_color (
|
||||
if (!gui_color_assign (
|
||||
weechat_options[i][j].ptr_int,
|
||||
weechat_options[i][j].default_string))
|
||||
gui_printf (NULL,
|
||||
@@ -2377,7 +2377,7 @@ config_write (char *config_name)
|
||||
fprintf (file, "%s = %s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
gui_get_color_name (*weechat_options[i][j].ptr_int) :
|
||||
gui_color_get_name (*weechat_options[i][j].ptr_int) :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
|
||||
+3
-1
@@ -19,9 +19,11 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
|
||||
|
||||
noinst_LIBRARIES = lib_weechat_gui_common.a
|
||||
|
||||
lib_weechat_gui_common_a_SOURCES = gui-common.c \
|
||||
lib_weechat_gui_common_a_SOURCES = gui-buffer.c \
|
||||
gui-common.c \
|
||||
gui-action.c \
|
||||
gui-keyboard.c \
|
||||
gui-window.c \
|
||||
gui.h
|
||||
|
||||
if GUI_NCURSES
|
||||
|
||||
@@ -20,7 +20,8 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
|
||||
bin_PROGRAMS = weechat-curses
|
||||
|
||||
if PLUGINS
|
||||
weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \
|
||||
weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \
|
||||
../gui-window.o ../gui-keyboard.o \
|
||||
../gui-action.o \
|
||||
../../common/lib_weechat_main.a \
|
||||
../../irc/lib_weechat_irc.a \
|
||||
@@ -29,7 +30,8 @@ weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \
|
||||
$(NCURSES_LIBS) \
|
||||
$(GNUTLS_LFLAGS)
|
||||
else
|
||||
weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \
|
||||
weechat_curses_LDADD = ../gui-common.o ../gui-buffer.o \
|
||||
../gui-window.o ../gui-keyboard.o \
|
||||
../gui-action.o \
|
||||
../../common/lib_weechat_main.a \
|
||||
../../irc/lib_weechat_irc.a \
|
||||
@@ -38,5 +40,13 @@ weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \
|
||||
$(GNUTLS_LFLAGS)
|
||||
endif
|
||||
|
||||
weechat_curses_SOURCES = gui-display.c \
|
||||
gui-input.c
|
||||
weechat_curses_SOURCES = gui-chat.c \
|
||||
gui-color.c \
|
||||
gui-infobar.c \
|
||||
gui-input.c \
|
||||
gui-keyboard.c \
|
||||
gui-main.c \
|
||||
gui-nicklist.c \
|
||||
gui-status.c \
|
||||
gui-window.c \
|
||||
gui-curses.h
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,607 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-color.c: color functions for Curses GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_CURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
#else
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#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 }
|
||||
};
|
||||
|
||||
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];
|
||||
|
||||
|
||||
/*
|
||||
* gui_color_assign: assign a WeeChat color (read from config)
|
||||
*/
|
||||
|
||||
int
|
||||
gui_color_assign (int *color, char *color_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* look for curses colors in table */
|
||||
i = 0;
|
||||
while (gui_weechat_colors[i].string)
|
||||
{
|
||||
if (ascii_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
|
||||
{
|
||||
*color = i;
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* color not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_get_name: get color name
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_color_get_name (int num_color)
|
||||
{
|
||||
return gui_weechat_colors[num_color].string;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_decode: parses a message (coming from IRC server),
|
||||
* and according:
|
||||
* - remove any color/style in message
|
||||
* or:
|
||||
* - change colors by codes to be compatible with
|
||||
* other IRC clients
|
||||
* After use, string returned has to be free()
|
||||
*/
|
||||
|
||||
unsigned char *
|
||||
gui_color_decode (unsigned char *string, int keep_colors)
|
||||
{
|
||||
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[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_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_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:
|
||||
string++;
|
||||
if (isdigit (string[0]) && isdigit (string[1]))
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
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:
|
||||
string++;
|
||||
if (string[0])
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
out[out_pos++] = *(string - 1);
|
||||
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[0] && (out_pos < out_length - 1))
|
||||
{
|
||||
switch (string[0])
|
||||
{
|
||||
case GUI_ATTR_BOLD_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = 'B';
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_FIXED_CHAR:
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_RESET_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = 'O';
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_REVERSE_CHAR:
|
||||
case GUI_ATTR_REVERSE2_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = 'R';
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_ITALIC_CHAR:
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_UNDERLINE_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = 'R';
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_COLOR_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = '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 (%B, %C, ..) in IRC colors
|
||||
* After use, string returned has to be free()
|
||||
*/
|
||||
|
||||
unsigned char *
|
||||
gui_color_encode (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[0] && (out_pos < out_length - 1))
|
||||
{
|
||||
switch (string[0])
|
||||
{
|
||||
case '%':
|
||||
string++;
|
||||
switch (string[0])
|
||||
{
|
||||
case '\0':
|
||||
out[out_pos++] = '%';
|
||||
break;
|
||||
case '%': /* double '%' replaced by single '%' */
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
break;
|
||||
case 'B': /* bold */
|
||||
out[out_pos++] = GUI_ATTR_BOLD_CHAR;
|
||||
string++;
|
||||
break;
|
||||
case 'C': /* color */
|
||||
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
}
|
||||
}
|
||||
if (string[0] == ',')
|
||||
{
|
||||
out[out_pos++] = ',';
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'O': /* reset */
|
||||
out[out_pos++] = GUI_ATTR_RESET_CHAR;
|
||||
string++;
|
||||
break;
|
||||
case 'R': /* reverse */
|
||||
out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
|
||||
string++;
|
||||
break;
|
||||
case 'U': /* underline */
|
||||
out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
|
||||
string++;
|
||||
break;
|
||||
default:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = string[0];
|
||||
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
|
||||
*/
|
||||
|
||||
int
|
||||
gui_color_get_pair (int num_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
if ((num_color < 0) || (num_color > GUI_NUM_COLORS - 1))
|
||||
return WEECHAT_COLOR_WHITE;
|
||||
|
||||
fg = gui_color[num_color]->foreground;
|
||||
bg = gui_color[num_color]->background;
|
||||
|
||||
if (((fg == -1) || (fg == 99))
|
||||
&& ((bg == -1) || (bg == 99)))
|
||||
return 63;
|
||||
if ((fg == -1) || (fg == 99))
|
||||
fg = WEECHAT_COLOR_WHITE;
|
||||
if ((bg == -1) || (bg == 99))
|
||||
bg = 0;
|
||||
|
||||
return (bg * 8) + fg;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init_pairs: init color pairs
|
||||
*/
|
||||
|
||||
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 < COLOR_PAIRS; i++)
|
||||
init_pair (i, shift_colors[i % 8], (i < 8) ? -1 : shift_colors[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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init_weechat: init WeeChat colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_init_weechat ()
|
||||
{
|
||||
int i;
|
||||
|
||||
gui_color[COLOR_WIN_SEPARATOR] = gui_color_build (COLOR_WIN_SEPARATOR, cfg_col_separator, cfg_col_separator);
|
||||
gui_color[COLOR_WIN_TITLE] = gui_color_build (COLOR_WIN_TITLE, cfg_col_title, cfg_col_title_bg);
|
||||
gui_color[COLOR_WIN_CHAT] = gui_color_build (COLOR_WIN_CHAT, cfg_col_chat, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_TIME] = gui_color_build (COLOR_WIN_CHAT_TIME, cfg_col_chat_time, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_TIME_SEP] = gui_color_build (COLOR_WIN_CHAT_TIME_SEP, cfg_col_chat_time_sep, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_PREFIX1] = gui_color_build (COLOR_WIN_CHAT_PREFIX1, cfg_col_chat_prefix1, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_PREFIX2] = gui_color_build (COLOR_WIN_CHAT_PREFIX2, cfg_col_chat_prefix2, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_SERVER] = gui_color_build (COLOR_WIN_CHAT_SERVER, cfg_col_chat_server, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_JOIN] = gui_color_build (COLOR_WIN_CHAT_JOIN, cfg_col_chat_join, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_PART] = gui_color_build (COLOR_WIN_CHAT_PART, cfg_col_chat_part, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_NICK] = gui_color_build (COLOR_WIN_CHAT_NICK, cfg_col_chat_nick, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_HOST] = gui_color_build (COLOR_WIN_CHAT_HOST, cfg_col_chat_host, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_CHANNEL] = gui_color_build (COLOR_WIN_CHAT_CHANNEL, cfg_col_chat_channel, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_DARK] = gui_color_build (COLOR_WIN_CHAT_DARK, cfg_col_chat_dark, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_HIGHLIGHT] = gui_color_build (COLOR_WIN_CHAT_HIGHLIGHT, cfg_col_chat_highlight, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_READ_MARKER] = gui_color_build (COLOR_WIN_CHAT_READ_MARKER, cfg_col_chat_read_marker, cfg_col_chat_read_marker_bg);
|
||||
gui_color[COLOR_WIN_STATUS] = gui_color_build (COLOR_WIN_STATUS, cfg_col_status, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DELIMITERS] = gui_color_build (COLOR_WIN_STATUS_DELIMITERS, cfg_col_status_delimiters, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_CHANNEL] = gui_color_build (COLOR_WIN_STATUS_CHANNEL, cfg_col_status_channel, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DATA_MSG] = gui_color_build (COLOR_WIN_STATUS_DATA_MSG, cfg_col_status_data_msg, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DATA_PRIVATE] = gui_color_build (COLOR_WIN_STATUS_DATA_PRIVATE, cfg_col_status_data_private, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DATA_HIGHLIGHT] = gui_color_build (COLOR_WIN_STATUS_DATA_HIGHLIGHT, cfg_col_status_data_highlight, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DATA_OTHER] = gui_color_build (COLOR_WIN_STATUS_DATA_OTHER, cfg_col_status_data_other, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_MORE] = gui_color_build (COLOR_WIN_STATUS_MORE, cfg_col_status_more, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_INFOBAR] = gui_color_build (COLOR_WIN_INFOBAR, cfg_col_infobar, cfg_col_infobar_bg);
|
||||
gui_color[COLOR_WIN_INFOBAR_DELIMITERS] = gui_color_build (COLOR_WIN_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg);
|
||||
gui_color[COLOR_WIN_INFOBAR_HIGHLIGHT] = gui_color_build (COLOR_WIN_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg);
|
||||
gui_color[COLOR_WIN_INPUT] = gui_color_build (COLOR_WIN_INPUT, cfg_col_input, cfg_col_input_bg);
|
||||
gui_color[COLOR_WIN_INPUT_SERVER] = gui_color_build (COLOR_WIN_INPUT_SERVER, cfg_col_input_server, cfg_col_input_bg);
|
||||
gui_color[COLOR_WIN_INPUT_CHANNEL] = gui_color_build (COLOR_WIN_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg);
|
||||
gui_color[COLOR_WIN_INPUT_NICK] = gui_color_build (COLOR_WIN_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg);
|
||||
gui_color[COLOR_WIN_INPUT_DELIMITERS] = gui_color_build (COLOR_WIN_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg);
|
||||
gui_color[COLOR_WIN_NICK] = gui_color_build (COLOR_WIN_NICK, cfg_col_nick, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_AWAY] = gui_color_build (COLOR_WIN_NICK_AWAY, cfg_col_nick_away, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_CHANOWNER] = gui_color_build (COLOR_WIN_NICK_CHANOWNER, cfg_col_nick_chanowner, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_CHANADMIN] = gui_color_build (COLOR_WIN_NICK_CHANADMIN, cfg_col_nick_chanadmin, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_OP] = gui_color_build (COLOR_WIN_NICK_OP, cfg_col_nick_op, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_HALFOP] = gui_color_build (COLOR_WIN_NICK_HALFOP, cfg_col_nick_halfop, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_VOICE] = gui_color_build (COLOR_WIN_NICK_VOICE, cfg_col_nick_voice, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_MORE] = gui_color_build (COLOR_WIN_NICK_MORE, cfg_col_nick_more, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_SEP] = gui_color_build (COLOR_WIN_NICK_SEP, cfg_col_nick_sep, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_SELF] = gui_color_build (COLOR_WIN_NICK_SELF, cfg_col_nick_self, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_PRIVATE] = gui_color_build (COLOR_WIN_NICK_PRIVATE, cfg_col_nick_private, cfg_col_nick_bg);
|
||||
|
||||
for (i = 0; i < COLOR_WIN_NICK_NUMBER; i++)
|
||||
{
|
||||
gui_color[COLOR_WIN_NICK_1 + i] = gui_color_build (COLOR_WIN_NICK_1 + i, cfg_col_nick_colors[i], cfg_col_chat_bg);
|
||||
}
|
||||
|
||||
gui_color[COLOR_DCC_SELECTED] = gui_color_build (COLOR_DCC_SELECTED, cfg_col_dcc_selected, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_WAITING] = gui_color_build (COLOR_DCC_WAITING, cfg_col_dcc_waiting, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_CONNECTING] = gui_color_build (COLOR_DCC_CONNECTING, cfg_col_dcc_connecting, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_ACTIVE] = gui_color_build (COLOR_DCC_ACTIVE, cfg_col_dcc_active, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_DONE] = gui_color_build (COLOR_DCC_DONE, cfg_col_dcc_done, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_FAILED] = gui_color_build (COLOR_DCC_FAILED, cfg_col_dcc_failed, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_ABORTED] = gui_color_build (COLOR_DCC_ABORTED, cfg_col_dcc_aborted, cfg_col_chat_bg);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_rebuild_weechat: rebuild WeeChat colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_rebuild_weechat ()
|
||||
{
|
||||
int i;
|
||||
|
||||
if (has_colors ())
|
||||
{
|
||||
for (i = 0; i < GUI_NUM_COLORS; i++)
|
||||
{
|
||||
if (gui_color[i])
|
||||
{
|
||||
if (gui_color[i]->string)
|
||||
free (gui_color[i]->string);
|
||||
free (gui_color[i]);
|
||||
gui_color[i] = NULL;
|
||||
}
|
||||
}
|
||||
gui_color_init_weechat ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init: init GUI colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_init ()
|
||||
{
|
||||
if (has_colors ())
|
||||
{
|
||||
start_color ();
|
||||
use_default_colors ();
|
||||
}
|
||||
gui_color_init_pairs ();
|
||||
gui_color_init_weechat ();
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_GUI_CURSES_H
|
||||
#define __WEECHAT_GUI_CURSES_H 1
|
||||
|
||||
/* 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
|
||||
|
||||
extern t_gui_color gui_weechat_colors[];
|
||||
extern int gui_irc_colors[GUI_NUM_IRC_COLORS][2];
|
||||
|
||||
/* color functions */
|
||||
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);
|
||||
|
||||
/* keyboard functions */
|
||||
extern void gui_keyboard_default_bindings ();
|
||||
extern void gui_keyboard_read ();
|
||||
|
||||
/* window functions */
|
||||
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 ();
|
||||
|
||||
#endif /* gui-curses.h */
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-infobar.c: infobar display functions for Curses GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_CURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
#else
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/hotlist.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-curses.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_infobar_draw_time: draw time in infobar window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_infobar_draw_time (t_gui_buffer *buffer)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
time_t time_seconds;
|
||||
struct tm *local_time;
|
||||
|
||||
/* make gcc happy */
|
||||
(void) buffer;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
time_seconds = time (NULL);
|
||||
local_time = localtime (&time_seconds);
|
||||
if (local_time)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
|
||||
mvwprintw (ptr_win->win_infobar,
|
||||
0, 1,
|
||||
"%02d:%02d",
|
||||
local_time->tm_hour, local_time->tm_min);
|
||||
if (cfg_look_infobar_seconds)
|
||||
wprintw (ptr_win->win_infobar,
|
||||
":%02d",
|
||||
local_time->tm_sec);
|
||||
}
|
||||
wnoutrefresh (ptr_win->win_infobar);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_infobar_draw: draw infobar window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_infobar_draw (t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
time_t time_seconds;
|
||||
struct tm *local_time;
|
||||
char text_time[1024 + 1];
|
||||
|
||||
/* make gcc happy */
|
||||
(void) buffer;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (erase)
|
||||
gui_window_curses_clear (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
|
||||
|
||||
gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
|
||||
|
||||
time_seconds = time (NULL);
|
||||
local_time = localtime (&time_seconds);
|
||||
if (local_time)
|
||||
{
|
||||
strftime (text_time, 1024, cfg_look_infobar_timestamp, local_time);
|
||||
gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS);
|
||||
wprintw (ptr_win->win_infobar, "[");
|
||||
gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
|
||||
wprintw (ptr_win->win_infobar,
|
||||
"%02d:%02d",
|
||||
local_time->tm_hour, local_time->tm_min);
|
||||
if (cfg_look_infobar_seconds)
|
||||
wprintw (ptr_win->win_infobar,
|
||||
":%02d",
|
||||
local_time->tm_sec);
|
||||
gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS);
|
||||
wprintw (ptr_win->win_infobar, "]");
|
||||
gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR);
|
||||
wprintw (ptr_win->win_infobar,
|
||||
" %s", text_time);
|
||||
}
|
||||
if (gui_infobar)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS);
|
||||
wprintw (ptr_win->win_infobar, " | ");
|
||||
gui_window_set_weechat_color (ptr_win->win_infobar, gui_infobar->color);
|
||||
wprintw (ptr_win->win_infobar, "%s", gui_infobar->text);
|
||||
}
|
||||
|
||||
wnoutrefresh (ptr_win->win_infobar);
|
||||
refresh ();
|
||||
}
|
||||
}
|
||||
+346
-447
@@ -17,7 +17,7 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-input: user input functions for Curses GUI */
|
||||
/* gui-input: input display functions for Curses GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -25,12 +25,6 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_CURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
@@ -40,12 +34,9 @@
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../common/command.h"
|
||||
#include "../../common/hotlist.h"
|
||||
#include "../../common/fifo.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../irc/irc.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-curses.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../../plugins/plugins.h"
|
||||
@@ -53,483 +44,391 @@
|
||||
|
||||
|
||||
/*
|
||||
* gui_input_default_key_bindings: create default key bindings
|
||||
* gui_input_set_color: set color for an input window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_default_key_bindings ()
|
||||
gui_input_set_color (t_gui_window *window, int irc_color)
|
||||
{
|
||||
int i;
|
||||
char key_str[32], command[32];
|
||||
int fg, bg;
|
||||
|
||||
/* keys binded with internal functions */
|
||||
gui_key_bind ( /* RC */ "ctrl-M", "return");
|
||||
gui_key_bind ( /* RC */ "ctrl-J", "return");
|
||||
gui_key_bind ( /* tab */ "ctrl-I", "tab");
|
||||
gui_key_bind ( /* basckp */ "ctrl-H", "backspace");
|
||||
gui_key_bind ( /* basckp */ "ctrl-?", "backspace");
|
||||
gui_key_bind ( /* del */ "meta2-3~", "delete");
|
||||
gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line");
|
||||
gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line");
|
||||
gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word");
|
||||
gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste");
|
||||
gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars");
|
||||
gui_key_bind ( /* home */ "meta2-1~", "home");
|
||||
gui_key_bind ( /* home */ "meta2-H", "home");
|
||||
gui_key_bind ( /* home */ "meta2-7~", "home");
|
||||
gui_key_bind ( /* ^A */ "ctrl-A", "home");
|
||||
gui_key_bind ( /* end */ "meta2-4~", "end");
|
||||
gui_key_bind ( /* end */ "meta2-F", "end");
|
||||
gui_key_bind ( /* end */ "meta2-8~", "end");
|
||||
gui_key_bind ( /* ^E */ "ctrl-E", "end");
|
||||
gui_key_bind ( /* left */ "meta2-D", "left");
|
||||
gui_key_bind ( /* right */ "meta2-C", "right");
|
||||
gui_key_bind ( /* up */ "meta2-A", "up");
|
||||
gui_key_bind ( /* ^up */ "meta-Oa", "up_global");
|
||||
gui_key_bind ( /* down */ "meta2-B", "down");
|
||||
gui_key_bind ( /* ^down */ "meta-Ob", "down_global");
|
||||
gui_key_bind ( /* pgup */ "meta2-5~", "page_up");
|
||||
gui_key_bind ( /* pgdn */ "meta2-6~", "page_down");
|
||||
gui_key_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up");
|
||||
gui_key_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down");
|
||||
gui_key_bind ( /* m-home */ "meta-meta2-1~", "scroll_top");
|
||||
gui_key_bind ( /* m-end */ "meta-meta2-4~", "scroll_bottom");
|
||||
gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear");
|
||||
gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up");
|
||||
gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down");
|
||||
gui_key_bind ( /* m-F11 */ "meta-meta2-23~", "nick_beginning");
|
||||
gui_key_bind ( /* m-F12 */ "meta-meta2-24~", "nick_end");
|
||||
gui_key_bind ( /* ^L */ "ctrl-L", "refresh");
|
||||
gui_key_bind ( /* m-a */ "meta-a", "jump_smart");
|
||||
gui_key_bind ( /* m-b */ "meta-b", "previous_word");
|
||||
gui_key_bind ( /* ^left */ "meta-Od", "previous_word");
|
||||
gui_key_bind ( /* m-d */ "meta-d", "delete_next_word");
|
||||
gui_key_bind ( /* m-f */ "meta-f", "next_word");
|
||||
gui_key_bind ( /* ^right */ "meta-Oc", "next_word");
|
||||
gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear");
|
||||
gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc");
|
||||
gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer");
|
||||
gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server");
|
||||
gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server");
|
||||
gui_key_bind ( /* m-j,m-r */ "meta-jmeta-r", "jump_raw_data");
|
||||
gui_key_bind ( /* m-k */ "meta-k", "grab_key");
|
||||
gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight");
|
||||
gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight");
|
||||
gui_key_bind ( /* m-r */ "meta-r", "delete_line");
|
||||
gui_key_bind ( /* m-s */ "meta-s", "switch_server");
|
||||
gui_key_bind ( /* m-u */ "meta-u", "scroll_unread");
|
||||
fg = gui_irc_colors[irc_color][0];
|
||||
bg = gui_color[COLOR_WIN_INPUT]->background;
|
||||
|
||||
/* keys binded with commands */
|
||||
gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1");
|
||||
gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1");
|
||||
gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1");
|
||||
gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1");
|
||||
gui_key_bind ( /* F7 */ "meta2-18~", "/window -1");
|
||||
gui_key_bind ( /* F8 */ "meta2-19~", "/window +1");
|
||||
gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up");
|
||||
gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down");
|
||||
gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left");
|
||||
gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right");
|
||||
gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10");
|
||||
gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1");
|
||||
gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2");
|
||||
gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3");
|
||||
gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4");
|
||||
gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5");
|
||||
gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6");
|
||||
gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7");
|
||||
gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8");
|
||||
gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9");
|
||||
irc_color %= GUI_NUM_IRC_COLORS;
|
||||
if (gui_irc_colors[irc_color][1] & A_BOLD)
|
||||
wattron (window->win_input, A_BOLD);
|
||||
|
||||
/* bind meta-j + {01..99} to switch to buffers # > 10 */
|
||||
for (i = 1; i < 100; i++)
|
||||
if (((fg == -1) || (fg == 99))
|
||||
&& ((bg == -1) || (bg == 99)))
|
||||
wattron (window->win_input, COLOR_PAIR(63));
|
||||
else
|
||||
{
|
||||
sprintf (key_str, "meta-j%02d", i);
|
||||
sprintf (command, "/buffer %d", i);
|
||||
gui_key_bind (key_str, command);
|
||||
if ((fg == -1) || (fg == 99))
|
||||
fg = WEECHAT_COLOR_WHITE;
|
||||
if ((bg == -1) || (bg == 99))
|
||||
bg = 0;
|
||||
wattron (window->win_input, COLOR_PAIR((bg * 8) + fg));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_grab_end: insert grabbed key in input buffer
|
||||
* 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 (CHANNEL(window->buffer))
|
||||
length += utf8_strlen (CHANNEL(window->buffer)->name);
|
||||
else
|
||||
{
|
||||
if (SERVER(window->buffer))
|
||||
length += utf8_strlen (SERVER(window->buffer)->name);
|
||||
}
|
||||
pos++;
|
||||
break;
|
||||
case 'm':
|
||||
if (SERVER(window->buffer))
|
||||
{
|
||||
mode_found = 0;
|
||||
for (modes = 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_grab_end ()
|
||||
gui_input_draw_prompt (t_gui_window *window, char *nick)
|
||||
{
|
||||
char *expanded_key, *expanded_key2;
|
||||
int length;
|
||||
char *buffer_before_key;
|
||||
|
||||
/* get expanded name (for example: ^U => ctrl-u) */
|
||||
expanded_key = gui_key_get_expanded_name (gui_key_buffer);
|
||||
char *pos, saved_char, *modes;
|
||||
int char_size, mode_found;
|
||||
|
||||
if (expanded_key)
|
||||
wmove (window->win_input, 0, 0);
|
||||
pos = cfg_look_input_format;
|
||||
while (pos && pos[0])
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
switch (pos[0])
|
||||
{
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_insert_string_input (gui_current_window, expanded_key, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 1);
|
||||
gui_current_window->buffer->completion.position = -1;
|
||||
#ifdef PLUGINS
|
||||
length = strlen (expanded_key) + 1 + 1;
|
||||
expanded_key2 = (char *) malloc (length);
|
||||
if (expanded_key2)
|
||||
case '%':
|
||||
pos++;
|
||||
switch (pos[0])
|
||||
{
|
||||
case 'c':
|
||||
if (CHANNEL(window->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (window->win_input,
|
||||
COLOR_WIN_INPUT_CHANNEL);
|
||||
wprintw (window->win_input, "%s",
|
||||
CHANNEL(window->buffer)->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SERVER(window->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (window->win_input,
|
||||
COLOR_WIN_INPUT_SERVER);
|
||||
wprintw (window->win_input, "%s",
|
||||
SERVER(window->buffer)->name);
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
break;
|
||||
case 'm':
|
||||
if (SERVER(window->buffer))
|
||||
{
|
||||
mode_found = 0;
|
||||
for (modes = SERVER(window->buffer)->nick_modes;
|
||||
modes && modes[0]; modes++)
|
||||
{
|
||||
if (modes[0] != ' ')
|
||||
mode_found = 1;
|
||||
}
|
||||
if (mode_found)
|
||||
{
|
||||
gui_window_set_weechat_color (window->win_input,
|
||||
COLOR_WIN_INPUT);
|
||||
wprintw (window->win_input, "+");
|
||||
for (modes = SERVER(window->buffer)->nick_modes;
|
||||
modes && modes[0]; modes++)
|
||||
{
|
||||
if (modes[0] != ' ')
|
||||
wprintw (window->win_input, "%c",
|
||||
modes[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
break;
|
||||
case 'n':
|
||||
gui_window_set_weechat_color (window->win_input,
|
||||
COLOR_WIN_INPUT_NICK);
|
||||
wprintw (window->win_input, "%s", nick);
|
||||
pos++;
|
||||
break;
|
||||
default:
|
||||
if (pos[0])
|
||||
{
|
||||
char_size = utf8_char_size (pos);
|
||||
saved_char = pos[char_size];
|
||||
pos[char_size] = '\0';
|
||||
gui_window_set_weechat_color (window->win_input,
|
||||
COLOR_WIN_INPUT_DELIMITERS);
|
||||
wprintw (window->win_input, "%%%s", pos);
|
||||
pos[char_size] = saved_char;
|
||||
pos += char_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
wprintw (window->win_input, "%%");
|
||||
pos++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
char_size = utf8_char_size (pos);
|
||||
saved_char = pos[char_size];
|
||||
pos[char_size] = '\0';
|
||||
gui_window_set_weechat_color (window->win_input,
|
||||
COLOR_WIN_INPUT_DELIMITERS);
|
||||
wprintw (window->win_input, "%s", pos);
|
||||
pos[char_size] = saved_char;
|
||||
pos += char_size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_draw_text: display text in input buffer, according to color mask
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_draw_text (t_gui_window *window, int input_width)
|
||||
{
|
||||
char *ptr_start, *ptr_next, saved_char;
|
||||
int pos_mask, size, last_color, color;
|
||||
|
||||
ptr_start = utf8_add_offset (window->buffer->input_buffer,
|
||||
window->buffer->input_buffer_1st_display);
|
||||
pos_mask = ptr_start - window->buffer->input_buffer;
|
||||
last_color = -1;
|
||||
while ((input_width > 0) && ptr_start && ptr_start[0])
|
||||
{
|
||||
ptr_next = utf8_next_char (ptr_start);
|
||||
if (ptr_next)
|
||||
{
|
||||
saved_char = ptr_next[0];
|
||||
ptr_next[0] = '\0';
|
||||
size = ptr_next - ptr_start;
|
||||
if (window->buffer->input_buffer_color_mask[pos_mask] != ' ')
|
||||
color = window->buffer->input_buffer_color_mask[pos_mask] - '0';
|
||||
else
|
||||
color = -1;
|
||||
if (color != last_color)
|
||||
{
|
||||
snprintf (expanded_key2, length, "*%s", expanded_key);
|
||||
(void) plugin_keyboard_handler_exec (expanded_key2,
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
free (expanded_key2);
|
||||
if (color == -1)
|
||||
gui_window_set_weechat_color (window->win_input, COLOR_WIN_INPUT);
|
||||
else
|
||||
gui_input_set_color (window, color);
|
||||
}
|
||||
#endif
|
||||
if (buffer_before_key)
|
||||
free (buffer_before_key);
|
||||
}
|
||||
free (expanded_key);
|
||||
}
|
||||
|
||||
/* end grab mode */
|
||||
gui_key_grab = 0;
|
||||
gui_key_grab_count = 0;
|
||||
gui_key_buffer[0] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_read: read keyboard chars
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_read ()
|
||||
{
|
||||
int key, i, insert_ok;
|
||||
char key_str[32], key_str2[33];
|
||||
char *buffer_before_key;
|
||||
|
||||
i = 0;
|
||||
/* do not loop too much here (for example when big paste was made),
|
||||
to read also socket & co */
|
||||
while (i < 8)
|
||||
{
|
||||
if (gui_key_grab && (gui_key_grab_count > 10))
|
||||
gui_input_grab_end ();
|
||||
|
||||
key = getch ();
|
||||
insert_ok = 1;
|
||||
|
||||
if (key == ERR)
|
||||
{
|
||||
if (gui_key_grab && (gui_key_grab_count > 0))
|
||||
gui_input_grab_end ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (key == KEY_RESIZE)
|
||||
{
|
||||
gui_refresh_screen ();
|
||||
continue;
|
||||
}
|
||||
|
||||
gui_last_activity_time = time (NULL);
|
||||
|
||||
if (key < 32)
|
||||
{
|
||||
insert_ok = 0;
|
||||
key_str[0] = '^';
|
||||
key_str[1] = (char) key + '@';
|
||||
key_str[2] = '\0';
|
||||
}
|
||||
else if (key == 127)
|
||||
{
|
||||
key_str[0] = '^';
|
||||
key_str[1] = '?';
|
||||
key_str[2] = '\0';
|
||||
last_color = color;
|
||||
wprintw (window->win_input, "%s", ptr_start);
|
||||
ptr_next[0] = saved_char;
|
||||
ptr_start = ptr_next;
|
||||
pos_mask += size;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (local_utf8)
|
||||
{
|
||||
/* 1 char: 0vvvvvvv */
|
||||
if (key < 0x80)
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = '\0';
|
||||
}
|
||||
/* 2 chars: 110vvvvv 10vvvvvv */
|
||||
else if ((key & 0xE0) == 0xC0)
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = (char) (getch ());
|
||||
key_str[2] = '\0';
|
||||
}
|
||||
/* 3 chars: 1110vvvv 10vvvvvv 10vvvvvv */
|
||||
else if ((key & 0xF0) == 0xE0)
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = (char) (getch ());
|
||||
key_str[2] = (char) (getch ());
|
||||
key_str[3] = '\0';
|
||||
}
|
||||
/* 4 chars: 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv */
|
||||
else if ((key & 0xF8) == 0xF0)
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = (char) (getch ());
|
||||
key_str[2] = (char) (getch ());
|
||||
key_str[3] = (char) (getch ());
|
||||
key_str[4] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp (key_str, "^") == 0)
|
||||
{
|
||||
key_str[1] = '^';
|
||||
key_str[2] = '\0';
|
||||
}
|
||||
|
||||
/*gui_printf (gui_current_window->buffer, "gui_input_read: key = %s (%d)\n", key_str, key);*/
|
||||
|
||||
if ((gui_key_pressed (key_str) != 0) && (insert_ok))
|
||||
{
|
||||
if (strcmp (key_str, "^^") == 0)
|
||||
key_str[1] = '\0';
|
||||
|
||||
switch (gui_current_window->buffer->type)
|
||||
{
|
||||
case BUFFER_TYPE_STANDARD:
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_insert_string_input (gui_current_window, key_str, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (key_str);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 0);
|
||||
gui_current_window->buffer->completion.position = -1;
|
||||
#ifdef PLUGINS
|
||||
snprintf (key_str2, sizeof (key_str2), "*%s", key_str);
|
||||
(void) plugin_keyboard_handler_exec (key_str2,
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
#endif
|
||||
break;
|
||||
case BUFFER_TYPE_DCC:
|
||||
gui_exec_action_dcc (gui_current_window, key_str);
|
||||
break;
|
||||
case BUFFER_TYPE_RAW_DATA:
|
||||
gui_exec_action_raw_data (gui_current_window, key_str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
ptr_start = NULL;
|
||||
input_width--;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_loop: main loop for WeeChat with ncurses GUI
|
||||
* gui_input_draw: draw input window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_loop ()
|
||||
gui_input_draw (t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
fd_set read_fd;
|
||||
static struct timeval timeout, tv;
|
||||
static struct timezone tz;
|
||||
t_irc_server *ptr_server;
|
||||
t_gui_buffer *ptr_buffer;
|
||||
int old_day, old_min, old_sec, diff;
|
||||
char text_time[1024];
|
||||
time_t new_time;
|
||||
struct tm *local_time;
|
||||
t_gui_window *ptr_win;
|
||||
char format[32];
|
||||
char *ptr_nickname;
|
||||
int prompt_length, display_prompt;
|
||||
t_irc_dcc *dcc_selected;
|
||||
|
||||
quit_weechat = 0;
|
||||
|
||||
new_time = time (NULL);
|
||||
gui_last_activity_time = new_time;
|
||||
local_time = localtime (&new_time);
|
||||
old_day = local_time->tm_mday;
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
old_min = -1;
|
||||
old_sec = -1;
|
||||
check_away = 0;
|
||||
while (!quit_weechat)
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
new_time = time (NULL);
|
||||
local_time = localtime (&new_time);
|
||||
|
||||
/* minute has changed ? => redraw infobar */
|
||||
if (local_time->tm_min != old_min)
|
||||
if (ptr_win->buffer == buffer)
|
||||
{
|
||||
old_min = local_time->tm_min;
|
||||
gui_draw_buffer_infobar (gui_current_window->buffer, 1);
|
||||
if (erase)
|
||||
gui_window_curses_clear (ptr_win->win_input, COLOR_WIN_INPUT);
|
||||
|
||||
if (cfg_look_day_change
|
||||
&& (local_time->tm_mday != old_day))
|
||||
switch (buffer->type)
|
||||
{
|
||||
strftime (text_time, sizeof (text_time),
|
||||
cfg_look_day_change_timestamp, local_time);
|
||||
gui_add_hotlist = 0;
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->type == BUFFER_TYPE_STANDARD)
|
||||
gui_printf_nolog_notime (ptr_buffer,
|
||||
_("Day changed to %s\n"),
|
||||
text_time);
|
||||
}
|
||||
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;
|
||||
|
||||
if (cfg_look_infobar_seconds)
|
||||
{
|
||||
gui_draw_buffer_infobar_time (gui_current_window->buffer);
|
||||
wmove (gui_current_window->win_input,
|
||||
0, gui_current_window->win_input_x);
|
||||
wrefresh (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_draw_buffer_infobar (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* away check */
|
||||
if (cfg_irc_away_check != 0)
|
||||
{
|
||||
check_away++;
|
||||
if (check_away >= (cfg_irc_away_check * 60))
|
||||
{
|
||||
check_away = 0;
|
||||
server_check_away ();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PLUGINS
|
||||
/* call timer handlers */
|
||||
plugin_timer_handler_exec ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* read keyboard */
|
||||
|
||||
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_input_read ();
|
||||
}
|
||||
}
|
||||
|
||||
/* read sockets (servers, child process when connecting, FIFO pipe) */
|
||||
|
||||
FD_ZERO (&read_fd);
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 2000;
|
||||
|
||||
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)))
|
||||
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))
|
||||
case BUFFER_TYPE_STANDARD:
|
||||
if (buffer->has_input)
|
||||
{
|
||||
server_sendf (ptr_server, "PING %s\r\n", ptr_server->address);
|
||||
gettimeofday (&(ptr_server->lag_check_time), &tz);
|
||||
}
|
||||
|
||||
/* lag timeout => disconnect */
|
||||
if ((ptr_server->lag_check_time.tv_sec != 0)
|
||||
&& (cfg_irc_lag_disconnect > 0))
|
||||
{
|
||||
gettimeofday (&tv, &tz);
|
||||
diff = (int) get_timeval_diff (&(ptr_server->lag_check_time), &tv);
|
||||
if (diff / 1000 > cfg_irc_lag_disconnect * 60)
|
||||
if (buffer->input_buffer_length == 0)
|
||||
buffer->input_buffer[0] = '\0';
|
||||
|
||||
if (SERVER(buffer))
|
||||
ptr_nickname = (SERVER(buffer)->nick) ?
|
||||
SERVER(buffer)->nick : SERVER(buffer)->nick1;
|
||||
else
|
||||
ptr_nickname = cfg_look_no_nickname;
|
||||
|
||||
prompt_length = gui_input_get_prompt_length (ptr_win, ptr_nickname);
|
||||
|
||||
if (ptr_win->win_width - prompt_length < 3)
|
||||
{
|
||||
irc_display_prefix (ptr_server, ptr_server->buffer, PREFIX_ERROR);
|
||||
gui_printf (ptr_server->buffer,
|
||||
_("%s lag is high, disconnecting from server...\n"),
|
||||
WEECHAT_WARNING);
|
||||
server_disconnect (ptr_server, 1);
|
||||
continue;
|
||||
prompt_length = 0;
|
||||
display_prompt = 0;
|
||||
}
|
||||
else
|
||||
display_prompt = 1;
|
||||
|
||||
if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
|
||||
ptr_win->win_width - prompt_length)
|
||||
buffer->input_buffer_1st_display = buffer->input_buffer_pos -
|
||||
(ptr_win->win_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_width - prompt_length)
|
||||
{
|
||||
buffer->input_buffer_1st_display =
|
||||
buffer->input_buffer_pos -
|
||||
(ptr_win->win_width - prompt_length) + 1;
|
||||
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 (ptr_win->win_input, COLOR_WIN_INPUT);
|
||||
snprintf (format, 32, "%%-%ds", ptr_win->win_width - prompt_length);
|
||||
if (ptr_win == gui_current_window)
|
||||
gui_input_draw_text (ptr_win, ptr_win->win_width - prompt_length);
|
||||
else
|
||||
wprintw (ptr_win->win_input, format, "");
|
||||
wclrtoeol (ptr_win->win_input);
|
||||
ptr_win->win_input_x = prompt_length +
|
||||
(buffer->input_buffer_pos - buffer->input_buffer_1st_display);
|
||||
if (ptr_win == gui_current_window)
|
||||
move (ptr_win->win_y + ptr_win->win_height - 1,
|
||||
ptr_win->win_x + ptr_win->win_input_x);
|
||||
}
|
||||
break;
|
||||
case BUFFER_TYPE_DCC:
|
||||
dcc_selected = (ptr_win->dcc_selected) ? (t_irc_dcc *) ptr_win->dcc_selected : dcc_list;
|
||||
wmove (ptr_win->win_input, 0, 0);
|
||||
if (dcc_selected)
|
||||
{
|
||||
switch (dcc_selected->status)
|
||||
{
|
||||
case DCC_WAITING:
|
||||
if (DCC_IS_RECV(dcc_selected->type))
|
||||
wprintw (ptr_win->win_input, _(" [A] Accept"));
|
||||
wprintw (ptr_win->win_input, _(" [C] Cancel"));
|
||||
break;
|
||||
case DCC_CONNECTING:
|
||||
case DCC_ACTIVE:
|
||||
wprintw (ptr_win->win_input, _(" [C] Cancel"));
|
||||
break;
|
||||
case DCC_DONE:
|
||||
case DCC_FAILED:
|
||||
case DCC_ABORTED:
|
||||
wprintw (ptr_win->win_input, _(" [R] Remove"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
wprintw (ptr_win->win_input, _(" [P] Purge old DCC"));
|
||||
wprintw (ptr_win->win_input, _(" [Q] Close DCC view"));
|
||||
wclrtoeol (ptr_win->win_input);
|
||||
ptr_win->win_input_x = 0;
|
||||
if (ptr_win == gui_current_window)
|
||||
move (ptr_win->win_y + ptr_win->win_height - 1,
|
||||
ptr_win->win_x);
|
||||
break;
|
||||
case BUFFER_TYPE_RAW_DATA:
|
||||
mvwprintw (ptr_win->win_input, 0, 0, _(" [Q] Close raw data view"));
|
||||
wclrtoeol (ptr_win->win_input);
|
||||
ptr_win->win_input_x = 0;
|
||||
if (ptr_win == gui_current_window)
|
||||
move (ptr_win->win_y + ptr_win->win_height - 1,
|
||||
ptr_win->win_x);
|
||||
break;
|
||||
}
|
||||
doupdate ();
|
||||
wrefresh (ptr_win->win_input);
|
||||
refresh ();
|
||||
}
|
||||
|
||||
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
|
||||
{
|
||||
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))
|
||||
server_child_read (ptr_server);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((ptr_server->sock >= 0) &&
|
||||
(FD_ISSET (ptr_server->sock, &read_fd)))
|
||||
server_recv (ptr_server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* manages active DCC */
|
||||
dcc_handle ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-keyboard.c: keyboard functions for Curses GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_CURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
#else
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/utf8.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* gui_keyboard__default_bindings: create default key bindings
|
||||
*/
|
||||
|
||||
void
|
||||
gui_keyboard_default_bindings ()
|
||||
{
|
||||
int i;
|
||||
char key_str[32], command[32];
|
||||
|
||||
/* keys binded with internal functions */
|
||||
gui_key_bind ( /* RC */ "ctrl-M", "return");
|
||||
gui_key_bind ( /* RC */ "ctrl-J", "return");
|
||||
gui_key_bind ( /* tab */ "ctrl-I", "tab");
|
||||
gui_key_bind ( /* basckp */ "ctrl-H", "backspace");
|
||||
gui_key_bind ( /* basckp */ "ctrl-?", "backspace");
|
||||
gui_key_bind ( /* del */ "meta2-3~", "delete");
|
||||
gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line");
|
||||
gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line");
|
||||
gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word");
|
||||
gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste");
|
||||
gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars");
|
||||
gui_key_bind ( /* home */ "meta2-1~", "home");
|
||||
gui_key_bind ( /* home */ "meta2-H", "home");
|
||||
gui_key_bind ( /* home */ "meta2-7~", "home");
|
||||
gui_key_bind ( /* ^A */ "ctrl-A", "home");
|
||||
gui_key_bind ( /* end */ "meta2-4~", "end");
|
||||
gui_key_bind ( /* end */ "meta2-F", "end");
|
||||
gui_key_bind ( /* end */ "meta2-8~", "end");
|
||||
gui_key_bind ( /* ^E */ "ctrl-E", "end");
|
||||
gui_key_bind ( /* left */ "meta2-D", "left");
|
||||
gui_key_bind ( /* right */ "meta2-C", "right");
|
||||
gui_key_bind ( /* up */ "meta2-A", "up");
|
||||
gui_key_bind ( /* ^up */ "meta-Oa", "up_global");
|
||||
gui_key_bind ( /* down */ "meta2-B", "down");
|
||||
gui_key_bind ( /* ^down */ "meta-Ob", "down_global");
|
||||
gui_key_bind ( /* pgup */ "meta2-5~", "page_up");
|
||||
gui_key_bind ( /* pgdn */ "meta2-6~", "page_down");
|
||||
gui_key_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up");
|
||||
gui_key_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down");
|
||||
gui_key_bind ( /* m-home */ "meta-meta2-1~", "scroll_top");
|
||||
gui_key_bind ( /* m-end */ "meta-meta2-4~", "scroll_bottom");
|
||||
gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear");
|
||||
gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up");
|
||||
gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down");
|
||||
gui_key_bind ( /* m-F11 */ "meta-meta2-23~", "nick_beginning");
|
||||
gui_key_bind ( /* m-F12 */ "meta-meta2-24~", "nick_end");
|
||||
gui_key_bind ( /* ^L */ "ctrl-L", "refresh");
|
||||
gui_key_bind ( /* m-a */ "meta-a", "jump_smart");
|
||||
gui_key_bind ( /* m-b */ "meta-b", "previous_word");
|
||||
gui_key_bind ( /* ^left */ "meta-Od", "previous_word");
|
||||
gui_key_bind ( /* m-d */ "meta-d", "delete_next_word");
|
||||
gui_key_bind ( /* m-f */ "meta-f", "next_word");
|
||||
gui_key_bind ( /* ^right */ "meta-Oc", "next_word");
|
||||
gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear");
|
||||
gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc");
|
||||
gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer");
|
||||
gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server");
|
||||
gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server");
|
||||
gui_key_bind ( /* m-j,m-r */ "meta-jmeta-r", "jump_raw_data");
|
||||
gui_key_bind ( /* m-k */ "meta-k", "grab_key");
|
||||
gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight");
|
||||
gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight");
|
||||
gui_key_bind ( /* m-r */ "meta-r", "delete_line");
|
||||
gui_key_bind ( /* m-s */ "meta-s", "switch_server");
|
||||
gui_key_bind ( /* m-u */ "meta-u", "scroll_unread");
|
||||
|
||||
/* keys binded with commands */
|
||||
gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1");
|
||||
gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1");
|
||||
gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1");
|
||||
gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1");
|
||||
gui_key_bind ( /* F7 */ "meta2-18~", "/window -1");
|
||||
gui_key_bind ( /* F8 */ "meta2-19~", "/window +1");
|
||||
gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up");
|
||||
gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down");
|
||||
gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left");
|
||||
gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right");
|
||||
gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10");
|
||||
gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1");
|
||||
gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2");
|
||||
gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3");
|
||||
gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4");
|
||||
gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5");
|
||||
gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6");
|
||||
gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7");
|
||||
gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8");
|
||||
gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9");
|
||||
|
||||
/* bind meta-j + {01..99} to switch to buffers # > 10 */
|
||||
for (i = 1; i < 100; i++)
|
||||
{
|
||||
sprintf (key_str, "meta-j%02d", i);
|
||||
sprintf (command, "/buffer %d", i);
|
||||
gui_key_bind (key_str, command);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_keyboard_grab_end: insert grabbed key in input buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_keyboard_grab_end ()
|
||||
{
|
||||
char *expanded_key, *expanded_key2;
|
||||
int length;
|
||||
char *buffer_before_key;
|
||||
|
||||
/* get expanded name (for example: ^U => ctrl-u) */
|
||||
expanded_key = gui_key_get_expanded_name (gui_key_buffer);
|
||||
|
||||
if (expanded_key)
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
{
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_insert_string_input (gui_current_window, expanded_key, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
gui_current_window->buffer->completion.position = -1;
|
||||
#ifdef PLUGINS
|
||||
length = strlen (expanded_key) + 1 + 1;
|
||||
expanded_key2 = (char *) malloc (length);
|
||||
if (expanded_key2)
|
||||
{
|
||||
snprintf (expanded_key2, length, "*%s", expanded_key);
|
||||
(void) plugin_keyboard_handler_exec (expanded_key2,
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
free (expanded_key2);
|
||||
}
|
||||
#endif
|
||||
if (buffer_before_key)
|
||||
free (buffer_before_key);
|
||||
}
|
||||
free (expanded_key);
|
||||
}
|
||||
|
||||
/* end grab mode */
|
||||
gui_key_grab = 0;
|
||||
gui_key_grab_count = 0;
|
||||
gui_key_buffer[0] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_keyboard_read: read keyboard chars
|
||||
*/
|
||||
|
||||
void
|
||||
gui_keyboard_read ()
|
||||
{
|
||||
int key, i, insert_ok;
|
||||
char key_str[32], key_str2[33];
|
||||
char *buffer_before_key;
|
||||
|
||||
i = 0;
|
||||
/* do not loop too much here (for example when big paste was made),
|
||||
to read also socket & co */
|
||||
while (i < 8)
|
||||
{
|
||||
if (gui_key_grab && (gui_key_grab_count > 10))
|
||||
gui_keyboard_grab_end ();
|
||||
|
||||
key = getch ();
|
||||
insert_ok = 1;
|
||||
|
||||
if (key == ERR)
|
||||
{
|
||||
if (gui_key_grab && (gui_key_grab_count > 0))
|
||||
gui_keyboard_grab_end ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (key == KEY_RESIZE)
|
||||
{
|
||||
gui_window_refresh_screen ();
|
||||
continue;
|
||||
}
|
||||
|
||||
gui_last_activity_time = time (NULL);
|
||||
|
||||
if (key < 32)
|
||||
{
|
||||
insert_ok = 0;
|
||||
key_str[0] = '^';
|
||||
key_str[1] = (char) key + '@';
|
||||
key_str[2] = '\0';
|
||||
}
|
||||
else if (key == 127)
|
||||
{
|
||||
key_str[0] = '^';
|
||||
key_str[1] = '?';
|
||||
key_str[2] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (local_utf8)
|
||||
{
|
||||
/* 1 char: 0vvvvvvv */
|
||||
if (key < 0x80)
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = '\0';
|
||||
}
|
||||
/* 2 chars: 110vvvvv 10vvvvvv */
|
||||
else if ((key & 0xE0) == 0xC0)
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = (char) (getch ());
|
||||
key_str[2] = '\0';
|
||||
}
|
||||
/* 3 chars: 1110vvvv 10vvvvvv 10vvvvvv */
|
||||
else if ((key & 0xF0) == 0xE0)
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = (char) (getch ());
|
||||
key_str[2] = (char) (getch ());
|
||||
key_str[3] = '\0';
|
||||
}
|
||||
/* 4 chars: 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv */
|
||||
else if ((key & 0xF8) == 0xF0)
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = (char) (getch ());
|
||||
key_str[2] = (char) (getch ());
|
||||
key_str[3] = (char) (getch ());
|
||||
key_str[4] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
key_str[0] = (char) key;
|
||||
key_str[1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp (key_str, "^") == 0)
|
||||
{
|
||||
key_str[1] = '^';
|
||||
key_str[2] = '\0';
|
||||
}
|
||||
|
||||
/*gui_printf (gui_current_window->buffer, "gui_input_read: key = %s (%d)\n", key_str, key);*/
|
||||
|
||||
if ((gui_key_pressed (key_str) != 0) && (insert_ok))
|
||||
{
|
||||
if (strcmp (key_str, "^^") == 0)
|
||||
key_str[1] = '\0';
|
||||
|
||||
switch (gui_current_window->buffer->type)
|
||||
{
|
||||
case BUFFER_TYPE_STANDARD:
|
||||
buffer_before_key =
|
||||
(gui_current_window->buffer->input_buffer) ?
|
||||
strdup (gui_current_window->buffer->input_buffer) : strdup ("");
|
||||
gui_insert_string_input (gui_current_window, key_str, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (key_str);
|
||||
gui_input_draw (gui_current_window->buffer, 0);
|
||||
gui_current_window->buffer->completion.position = -1;
|
||||
#ifdef PLUGINS
|
||||
snprintf (key_str2, sizeof (key_str2), "*%s", key_str);
|
||||
(void) plugin_keyboard_handler_exec (key_str2,
|
||||
buffer_before_key,
|
||||
gui_current_window->buffer->input_buffer);
|
||||
#endif
|
||||
break;
|
||||
case BUFFER_TYPE_DCC:
|
||||
gui_exec_action_dcc (gui_current_window, key_str);
|
||||
break;
|
||||
case BUFFER_TYPE_RAW_DATA:
|
||||
gui_exec_action_raw_data (gui_current_window, key_str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-main.c: main loop and keyboard management for Curses GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_CURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
#else
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/fifo.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-curses.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* gui_main_loop: main loop for WeeChat with ncurses GUI
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_loop ()
|
||||
{
|
||||
fd_set read_fd;
|
||||
static struct timeval timeout, tv;
|
||||
static struct timezone tz;
|
||||
t_irc_server *ptr_server;
|
||||
t_gui_buffer *ptr_buffer;
|
||||
int old_day, old_min, old_sec, diff;
|
||||
char text_time[1024];
|
||||
time_t new_time;
|
||||
struct tm *local_time;
|
||||
|
||||
quit_weechat = 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;
|
||||
check_away = 0;
|
||||
while (!quit_weechat)
|
||||
{
|
||||
new_time = time (NULL);
|
||||
local_time = localtime (&new_time);
|
||||
|
||||
/* minute has changed ? => redraw infobar */
|
||||
if (local_time->tm_min != old_min)
|
||||
{
|
||||
old_min = local_time->tm_min;
|
||||
gui_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);
|
||||
gui_add_hotlist = 0;
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->type == BUFFER_TYPE_STANDARD)
|
||||
gui_printf_nolog_notime (ptr_buffer,
|
||||
_("Day changed to %s\n"),
|
||||
text_time);
|
||||
}
|
||||
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;
|
||||
|
||||
if (cfg_look_infobar_seconds)
|
||||
{
|
||||
gui_infobar_draw_time (gui_current_window->buffer);
|
||||
wmove (gui_current_window->win_input,
|
||||
0, gui_current_window->win_input_x);
|
||||
wrefresh (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)
|
||||
{
|
||||
check_away++;
|
||||
if (check_away >= (cfg_irc_away_check * 60))
|
||||
{
|
||||
check_away = 0;
|
||||
server_check_away ();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PLUGINS
|
||||
/* call timer handlers */
|
||||
plugin_timer_handler_exec ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* read keyboard */
|
||||
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
|
||||
/* read sockets (servers, child process when connecting, FIFO pipe) */
|
||||
|
||||
FD_ZERO (&read_fd);
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 2000;
|
||||
|
||||
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)))
|
||||
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))
|
||||
{
|
||||
server_sendf (ptr_server, "PING %s\r\n", ptr_server->address);
|
||||
gettimeofday (&(ptr_server->lag_check_time), &tz);
|
||||
}
|
||||
|
||||
/* lag timeout => disconnect */
|
||||
if ((ptr_server->lag_check_time.tv_sec != 0)
|
||||
&& (cfg_irc_lag_disconnect > 0))
|
||||
{
|
||||
gettimeofday (&tv, &tz);
|
||||
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, PREFIX_ERROR);
|
||||
gui_printf (ptr_server->buffer,
|
||||
_("%s lag is high, disconnecting from server...\n"),
|
||||
WEECHAT_WARNING);
|
||||
server_disconnect (ptr_server, 1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ptr_server->is_connected && (ptr_server->child_pid > 0))
|
||||
FD_SET (ptr_server->child_read, &read_fd);
|
||||
else
|
||||
{
|
||||
if (ptr_server->sock >= 0)
|
||||
FD_SET (ptr_server->sock, &read_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
|
||||
{
|
||||
if ((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))
|
||||
server_child_read (ptr_server);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((ptr_server->sock >= 0) &&
|
||||
(FD_ISSET (ptr_server->sock, &read_fd)))
|
||||
server_recv (ptr_server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* manages active DCC */
|
||||
dcc_handle ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_pre_init: pre-initialize GUI (called before gui_init)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_pre_init (int *argc, char **argv[])
|
||||
{
|
||||
/* nothing for Curses interface */
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_init: init GUI
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_init ()
|
||||
{
|
||||
initscr ();
|
||||
|
||||
curs_set (1);
|
||||
noecho ();
|
||||
nodelay (stdscr, TRUE);
|
||||
|
||||
gui_color_init ();
|
||||
|
||||
gui_infobar = NULL;
|
||||
|
||||
gui_ok = ((COLS > 5) && (LINES > 5));
|
||||
|
||||
refresh ();
|
||||
|
||||
/* init clipboard buffer */
|
||||
gui_input_clipboard = NULL;
|
||||
|
||||
/* create new window/buffer */
|
||||
if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
|
||||
{
|
||||
gui_current_window = gui_windows;
|
||||
gui_buffer_new (gui_windows, NULL, NULL, BUFFER_TYPE_STANDARD, 1);
|
||||
|
||||
signal (SIGWINCH, gui_window_refresh_screen_sigwinch);
|
||||
|
||||
if (cfg_look_set_title)
|
||||
gui_window_set_title ();
|
||||
|
||||
gui_init_ok = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_end: GUI end
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_end ()
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
/* free clipboard buffer */
|
||||
if (gui_input_clipboard)
|
||||
free(gui_input_clipboard);
|
||||
|
||||
/* delete all windows */
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->win_title)
|
||||
delwin (ptr_win->win_title);
|
||||
if (ptr_win->win_chat)
|
||||
delwin (ptr_win->win_chat);
|
||||
if (ptr_win->win_nick)
|
||||
delwin (ptr_win->win_nick);
|
||||
if (ptr_win->win_status)
|
||||
delwin (ptr_win->win_status);
|
||||
if (ptr_win->win_infobar)
|
||||
delwin (ptr_win->win_infobar);
|
||||
if (ptr_win->win_input)
|
||||
delwin (ptr_win->win_input);
|
||||
}
|
||||
|
||||
/* delete all buffers */
|
||||
while (gui_buffers)
|
||||
gui_buffer_free (gui_buffers, 0);
|
||||
|
||||
/* delete all windows */
|
||||
while (gui_windows)
|
||||
gui_window_free (gui_windows);
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
|
||||
/* delete global history */
|
||||
history_global_free ();
|
||||
|
||||
/* delete infobar messages */
|
||||
while (gui_infobar)
|
||||
gui_infobar_remove ();
|
||||
|
||||
/* reset title */
|
||||
if (cfg_look_set_title)
|
||||
gui_window_reset_title ();
|
||||
|
||||
/* end of curses output */
|
||||
refresh ();
|
||||
endwin ();
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-nicklist.c: nicklist display functions for Curses GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NCURSESW_CURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
#else
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../irc/irc.h"
|
||||
#include "gui-curses.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_nicklist_draw: draw nick window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_nicklist_draw (t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
int i, j, x, y, x2, column, max_length, nicks_displayed;
|
||||
char format[32], format_empty[32];
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
if (!gui_ok || !BUFFER_HAS_NICKLIST(buffer))
|
||||
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 = nick_get_max_length (CHANNEL(buffer));
|
||||
|
||||
if (gui_window_calculate_pos_size (ptr_win, 0))
|
||||
{
|
||||
delwin (ptr_win->win_chat);
|
||||
delwin (ptr_win->win_nick);
|
||||
ptr_win->win_chat = newwin (ptr_win->win_chat_height,
|
||||
ptr_win->win_chat_width,
|
||||
ptr_win->win_chat_y,
|
||||
ptr_win->win_chat_x);
|
||||
ptr_win->win_nick = newwin (ptr_win->win_nick_height,
|
||||
ptr_win->win_nick_width,
|
||||
ptr_win->win_nick_y,
|
||||
ptr_win->win_nick_x);
|
||||
gui_chat_draw (buffer, 1);
|
||||
erase = 1;
|
||||
}
|
||||
|
||||
if (erase)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK);
|
||||
|
||||
snprintf (format_empty, 32, "%%-%ds", ptr_win->win_nick_width);
|
||||
for (i = 0; i < ptr_win->win_nick_height; i++)
|
||||
{
|
||||
mvwprintw (ptr_win->win_nick, i, 0, format_empty, " ");
|
||||
}
|
||||
}
|
||||
|
||||
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
|
||||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
|
||||
snprintf (format, 32, "%%.%ds", max_length);
|
||||
else
|
||||
snprintf (format, 32, "%%.%ds",
|
||||
((cfg_look_nicklist_min_size > 0)
|
||||
&& (max_length < cfg_look_nicklist_min_size)) ?
|
||||
cfg_look_nicklist_min_size :
|
||||
(((cfg_look_nicklist_max_size > 0)
|
||||
&& (max_length > cfg_look_nicklist_max_size)) ?
|
||||
cfg_look_nicklist_max_size : max_length));
|
||||
|
||||
if (has_colors ())
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_SEP);
|
||||
switch (cfg_look_nicklist_position)
|
||||
{
|
||||
case CFG_LOOK_NICKLIST_LEFT:
|
||||
mvwvline (ptr_win->win_nick,
|
||||
0, ptr_win->win_nick_width - 1, ACS_VLINE,
|
||||
ptr_win->win_chat_height);
|
||||
break;
|
||||
case CFG_LOOK_NICKLIST_RIGHT:
|
||||
mvwvline (ptr_win->win_nick,
|
||||
0, 0, ACS_VLINE,
|
||||
ptr_win->win_chat_height);
|
||||
break;
|
||||
case CFG_LOOK_NICKLIST_TOP:
|
||||
mvwhline (ptr_win->win_nick,
|
||||
ptr_win->win_nick_height - 1, 0, ACS_HLINE,
|
||||
ptr_win->win_chat_width);
|
||||
break;
|
||||
case CFG_LOOK_NICKLIST_BOTTOM:
|
||||
mvwhline (ptr_win->win_nick,
|
||||
0, 0, ACS_HLINE,
|
||||
ptr_win->win_chat_width);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK);
|
||||
x = 0;
|
||||
y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0;
|
||||
column = 0;
|
||||
|
||||
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 - 1);
|
||||
else
|
||||
nicks_displayed = ptr_win->win_nick_height;
|
||||
|
||||
ptr_nick = CHANNEL(buffer)->nicks;
|
||||
for (i = 0; i < ptr_win->win_nick_start; i++)
|
||||
{
|
||||
if (!ptr_nick)
|
||||
break;
|
||||
ptr_nick = ptr_nick->next_nick;
|
||||
}
|
||||
if (ptr_nick)
|
||||
{
|
||||
for (i = 0; i < nicks_displayed; i++)
|
||||
{
|
||||
switch (cfg_look_nicklist_position)
|
||||
{
|
||||
case CFG_LOOK_NICKLIST_LEFT:
|
||||
x = 0;
|
||||
break;
|
||||
case CFG_LOOK_NICKLIST_RIGHT:
|
||||
x = 1;
|
||||
break;
|
||||
case CFG_LOOK_NICKLIST_TOP:
|
||||
case CFG_LOOK_NICKLIST_BOTTOM:
|
||||
x = column;
|
||||
break;
|
||||
}
|
||||
if ( ((i == 0) && (ptr_win->win_nick_start > 0))
|
||||
|| ((i == nicks_displayed - 1) && (ptr_nick->next_nick)) )
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_MORE);
|
||||
j = (max_length + 1) >= 4 ? 4 : max_length + 1;
|
||||
for (x2 = 1; x2 <= j; x2++)
|
||||
mvwprintw (ptr_win->win_nick, y, x + x2, "+");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ptr_nick->flags & NICK_CHANOWNER)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANOWNER);
|
||||
mvwprintw (ptr_win->win_nick, y, x, "~");
|
||||
x++;
|
||||
}
|
||||
else if (ptr_nick->flags & NICK_CHANADMIN)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANADMIN);
|
||||
mvwprintw (ptr_win->win_nick, y, x, "&");
|
||||
x++;
|
||||
}
|
||||
else if (ptr_nick->flags & NICK_OP)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_OP);
|
||||
mvwprintw (ptr_win->win_nick, y, x, "@");
|
||||
x++;
|
||||
}
|
||||
else if (ptr_nick->flags & NICK_HALFOP)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_HALFOP);
|
||||
mvwprintw (ptr_win->win_nick, y, x, "%%");
|
||||
x++;
|
||||
}
|
||||
else if (ptr_nick->flags & NICK_VOICE)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_VOICE);
|
||||
mvwprintw (ptr_win->win_nick, y, x, "+");
|
||||
x++;
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK);
|
||||
mvwprintw (ptr_win->win_nick, y, x, " ");
|
||||
x++;
|
||||
}
|
||||
gui_window_set_weechat_color (ptr_win->win_nick,
|
||||
((cfg_irc_away_check > 0) && (ptr_nick->flags & NICK_AWAY)) ?
|
||||
COLOR_WIN_NICK_AWAY : COLOR_WIN_NICK);
|
||||
mvwprintw (ptr_win->win_nick, y, x, format, ptr_nick->nick);
|
||||
|
||||
ptr_nick = ptr_nick->next_nick;
|
||||
|
||||
if (!ptr_nick)
|
||||
break;
|
||||
}
|
||||
y++;
|
||||
if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ||
|
||||
(cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM))
|
||||
{
|
||||
if (y - ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0) >= ptr_win->win_nick_height - 1)
|
||||
{
|
||||
column += max_length + 2;
|
||||
y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ?
|
||||
0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
wnoutrefresh (ptr_win->win_nick);
|
||||
refresh ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-status.c: status display functions for Curses GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_CURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
#else
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/hotlist.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-curses.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_status_draw: draw status window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_status_draw (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 gcc happy */
|
||||
(void) buffer;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (erase)
|
||||
gui_window_curses_clear (ptr_win->win_status, COLOR_WIN_STATUS);
|
||||
|
||||
gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS);
|
||||
|
||||
/* display number of buffers */
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
mvwprintw (ptr_win->win_status, 0, 0, "[");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%d",
|
||||
(last_gui_buffer) ? last_gui_buffer->number : 0);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "] ");
|
||||
|
||||
/* display "<servers>" or current server */
|
||||
if (ptr_win->buffer->all_servers)
|
||||
{
|
||||
wprintw (ptr_win->win_status, "[");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, _("<servers>"));
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "] ");
|
||||
}
|
||||
else if (SERVER(ptr_win->buffer) && SERVER(ptr_win->buffer)->name)
|
||||
{
|
||||
wprintw (ptr_win->win_status, "[");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%s", SERVER(ptr_win->buffer)->name);
|
||||
if (SERVER(ptr_win->buffer)->is_away)
|
||||
wprintw (ptr_win->win_status, _("(away)"));
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "] ");
|
||||
}
|
||||
|
||||
/* infos about current server buffer */
|
||||
if (SERVER(ptr_win->buffer) && !CHANNEL(ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%d",
|
||||
ptr_win->buffer->number);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, ":");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_CHANNEL);
|
||||
if (SERVER(ptr_win->buffer)->is_connected)
|
||||
wprintw (ptr_win->win_status, "[%s] ",
|
||||
SERVER(ptr_win->buffer)->name);
|
||||
else
|
||||
wprintw (ptr_win->win_status, "(%s) ",
|
||||
SERVER(ptr_win->buffer)->name);
|
||||
if (ptr_win->buffer->all_servers)
|
||||
{
|
||||
server_get_number_buffer (SERVER(ptr_win->buffer),
|
||||
&server_pos,
|
||||
&server_total);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "(");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%d", server_pos);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "/");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%d", server_total);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, ") ");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* infos about current channel/pv buffer */
|
||||
if (SERVER(ptr_win->buffer) && CHANNEL(ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%d",
|
||||
ptr_win->buffer->number);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, ":");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_CHANNEL);
|
||||
if (((CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_PRIVATE)
|
||||
&& (CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (!CHANNEL(ptr_win->buffer)->nicks))
|
||||
|| ((CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (CHANNEL(ptr_win->buffer)->dcc_chat)
|
||||
&& (((t_irc_dcc *)(CHANNEL(ptr_win->buffer)->dcc_chat))->sock < 0)))
|
||||
wprintw (ptr_win->win_status, "(%s)",
|
||||
CHANNEL(ptr_win->buffer)->name);
|
||||
else
|
||||
wprintw (ptr_win->win_status, "%s",
|
||||
CHANNEL(ptr_win->buffer)->name);
|
||||
if (ptr_win->buffer == CHANNEL(ptr_win->buffer)->buffer)
|
||||
{
|
||||
/* display channel modes */
|
||||
if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "(");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
i = 0;
|
||||
first_mode = 1;
|
||||
while (CHANNEL(ptr_win->buffer)->modes[i])
|
||||
{
|
||||
if (CHANNEL(ptr_win->buffer)->modes[i] != ' ')
|
||||
{
|
||||
if (first_mode)
|
||||
{
|
||||
wprintw (ptr_win->win_status, "+");
|
||||
first_mode = 0;
|
||||
}
|
||||
wprintw (ptr_win->win_status, "%c",
|
||||
CHANNEL(ptr_win->buffer)->modes[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_KEY] != ' ')
|
||||
wprintw (ptr_win->win_status, ",%s",
|
||||
CHANNEL(ptr_win->buffer)->key);
|
||||
if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_LIMIT] != ' ')
|
||||
wprintw (ptr_win->win_status, ",%d",
|
||||
CHANNEL(ptr_win->buffer)->limit);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, ")");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
}
|
||||
|
||||
/* display DCC if private is DCC CHAT */
|
||||
if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "(");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_CHANNEL);
|
||||
wprintw (ptr_win->win_status, "DCC");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, ")");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
}
|
||||
}
|
||||
wprintw (ptr_win->win_status, " ");
|
||||
}
|
||||
if (!SERVER(ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%d",
|
||||
ptr_win->buffer->number);
|
||||
gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, ":");
|
||||
gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_CHANNEL);
|
||||
switch (ptr_win->buffer->type)
|
||||
{
|
||||
case BUFFER_TYPE_STANDARD:
|
||||
wprintw (ptr_win->win_status, _("[not connected] "));
|
||||
break;
|
||||
case BUFFER_TYPE_DCC:
|
||||
wprintw (ptr_win->win_status, "<DCC> ");
|
||||
break;
|
||||
case BUFFER_TYPE_RAW_DATA:
|
||||
wprintw (ptr_win->win_status, _("<RAW_IRC> "));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* display list of other active windows (if any) with numbers */
|
||||
if (hotlist)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "[");
|
||||
gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, _("Act: "));
|
||||
|
||||
names_count = 0;
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
switch (ptr_hotlist->priority)
|
||||
{
|
||||
case HOTLIST_LOW:
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DATA_OTHER);
|
||||
display_name = ((cfg_look_hotlist_names_level & 1) != 0);
|
||||
break;
|
||||
case HOTLIST_MSG:
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DATA_MSG);
|
||||
display_name = ((cfg_look_hotlist_names_level & 2) != 0);
|
||||
break;
|
||||
case HOTLIST_PRIVATE:
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DATA_PRIVATE);
|
||||
display_name = ((cfg_look_hotlist_names_level & 4) != 0);
|
||||
break;
|
||||
case HOTLIST_HIGHLIGHT:
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DATA_HIGHLIGHT);
|
||||
display_name = ((cfg_look_hotlist_names_level & 8) != 0);
|
||||
break;
|
||||
default:
|
||||
display_name = 0;
|
||||
break;
|
||||
}
|
||||
switch (ptr_hotlist->buffer->type)
|
||||
{
|
||||
case BUFFER_TYPE_STANDARD:
|
||||
wprintw (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 (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, ":");
|
||||
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
if (cfg_look_hotlist_names_length == 0)
|
||||
snprintf (format, sizeof (format) - 1, "%%s");
|
||||
else
|
||||
snprintf (format, sizeof (format) - 1, "%%.%ds", cfg_look_hotlist_names_length);
|
||||
if (BUFFER_IS_SERVER(ptr_hotlist->buffer))
|
||||
wprintw (ptr_win->win_status, format,
|
||||
(ptr_hotlist->server) ?
|
||||
ptr_hotlist->server->name :
|
||||
SERVER(ptr_hotlist->buffer)->name);
|
||||
else if (BUFFER_IS_CHANNEL(ptr_hotlist->buffer)
|
||||
|| BUFFER_IS_PRIVATE(ptr_hotlist->buffer))
|
||||
wprintw (ptr_win->win_status, format, CHANNEL(ptr_hotlist->buffer)->name);
|
||||
}
|
||||
break;
|
||||
case BUFFER_TYPE_DCC:
|
||||
wprintw (ptr_win->win_status, "%d",
|
||||
ptr_hotlist->buffer->number);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, ":");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "DCC");
|
||||
break;
|
||||
case BUFFER_TYPE_RAW_DATA:
|
||||
wprintw (ptr_win->win_status, "%d",
|
||||
ptr_hotlist->buffer->number);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, ":");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, _("RAW_IRC"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (ptr_hotlist->next_hotlist)
|
||||
wprintw (ptr_win->win_status, ",");
|
||||
}
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "] ");
|
||||
}
|
||||
|
||||
/* display lag */
|
||||
if (SERVER(ptr_win->buffer))
|
||||
{
|
||||
if (SERVER(ptr_win->buffer)->lag / 1000 >= cfg_irc_lag_min_show)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "[");
|
||||
gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, _("Lag: %.1f"),
|
||||
((float)(SERVER(ptr_win->buffer)->lag)) / 1000);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "]");
|
||||
}
|
||||
}
|
||||
|
||||
/* display "-MORE-" (if last line is not displayed) & nicks count */
|
||||
if (BUFFER_HAS_NICKLIST(ptr_win->buffer))
|
||||
{
|
||||
snprintf (str_nicks, sizeof (str_nicks) - 1, "%d", CHANNEL(ptr_win->buffer)->nicks_count);
|
||||
x = ptr_win->win_width - strlen (str_nicks) - 4;
|
||||
}
|
||||
else
|
||||
x = ptr_win->win_width - 2;
|
||||
more = strdup (_("-MORE-"));
|
||||
x -= strlen (more) - 1;
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE);
|
||||
if (ptr_win->scroll)
|
||||
mvwprintw (ptr_win->win_status, 0, x, "%s", more);
|
||||
else
|
||||
{
|
||||
snprintf (format, sizeof (format) - 1, "%%-%ds", (int)(strlen (more)));
|
||||
mvwprintw (ptr_win->win_status, 0, x, format, " ");
|
||||
}
|
||||
if (BUFFER_HAS_NICKLIST(ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, " [");
|
||||
gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS);
|
||||
wprintw (ptr_win->win_status, "%s", str_nicks);
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
wprintw (ptr_win->win_status, "]");
|
||||
}
|
||||
free (more);
|
||||
|
||||
wnoutrefresh (ptr_win->win_status);
|
||||
refresh ();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+14
-4
@@ -20,7 +20,8 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(GTK_CFLAGS)
|
||||
bin_PROGRAMS = weechat-gtk
|
||||
|
||||
if PLUGINS
|
||||
weechat_gtk_LDADD = ../gui-common.o ../gui-keyboard.o \
|
||||
weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \
|
||||
../gui-window.o ../gui-keyboard.o \
|
||||
../gui-action.o \
|
||||
../../common/lib_weechat_main.a \
|
||||
../../irc/lib_weechat_irc.a \
|
||||
@@ -29,7 +30,8 @@ weechat_gtk_LDADD = ../gui-common.o ../gui-keyboard.o \
|
||||
$(GTK_LIBS) \
|
||||
$(GNUTLS_LFLAGS)
|
||||
else
|
||||
weechat_gtk_LDADD = ../gui-common.o ../gui-keyboard.o \
|
||||
weechat_gtk_LDADD = ../gui-common.o ../gui-buffer.o \
|
||||
../gui-window.o ../gui-keyboard.o \
|
||||
../gui-action.o \
|
||||
../../common/lib_weechat_main.a \
|
||||
../../irc/lib_weechat_irc.a \
|
||||
@@ -38,5 +40,13 @@ weechat_gtk_LDADD = ../gui-common.o ../gui-keyboard.o \
|
||||
$(GNUTLS_LFLAGS)
|
||||
endif
|
||||
|
||||
weechat_gtk_SOURCES = gui-display.c \
|
||||
gui-input.c
|
||||
weechat_gtk_SOURCES = gui-chat.c \
|
||||
gui-color.c \
|
||||
gui-infobar.c \
|
||||
gui-input.c \
|
||||
gui-keyboard.c \
|
||||
gui-main.c \
|
||||
gui-nicklist.c \
|
||||
gui-status.c \
|
||||
gui-window.c \
|
||||
gui-gtk.h
|
||||
|
||||
@@ -0,0 +1,633 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-chat.c: chat display functions for Gtk GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../irc/irc.h"
|
||||
#include "gui-gtk.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_chat_set_style: set style (bold, underline, ..)
|
||||
* for a chat window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_set_style (t_gui_window *window, int style)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
/*wattron (window->win_chat, style);*/
|
||||
(void) window;
|
||||
(void) style;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_remove_style: remove style (bold, underline, ..)
|
||||
* for a chat window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_remove_style (t_gui_window *window, int style)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
/*wattroff (window->win_chat, style);*/
|
||||
(void) window;
|
||||
(void) style;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_toggle_style: toggle a style (bold, underline, ..)
|
||||
* for a chat window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_toggle_style (t_gui_window *window, int style)
|
||||
{
|
||||
window->current_style_attr ^= style;
|
||||
if (window->current_style_attr & style)
|
||||
gui_chat_set_style (window, style);
|
||||
else
|
||||
gui_chat_remove_style (window, style);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_reset_style: reset style (color and attr)
|
||||
* for a chat window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_reset_style (t_gui_window *window)
|
||||
{
|
||||
window->current_style_fg = -1;
|
||||
window->current_style_bg = -1;
|
||||
window->current_style_attr = 0;
|
||||
window->current_color_attr = 0;
|
||||
|
||||
/* TODO: change following function call */
|
||||
/*gui_window_set_weechat_color (window->win_chat, COLOR_WIN_CHAT);*/
|
||||
gui_chat_remove_style (window,
|
||||
A_BOLD | A_UNDERLINE | A_REVERSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_set_color_style: set style for color
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_set_color_style (t_gui_window *window, int style)
|
||||
{
|
||||
window->current_color_attr |= style;
|
||||
/* TODO: change following function call */
|
||||
/*wattron (window->win_chat, style);*/
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_remove_color_style: remove style for color
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_remove_color_style (t_gui_window *window, int style)
|
||||
{
|
||||
window->current_color_attr &= !style;
|
||||
/* TODO: change following function call */
|
||||
/*wattroff (window->win_chat, style);*/
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_reset_color_style: reset style for color
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_reset_color_style (t_gui_window *window)
|
||||
{
|
||||
/* TODO: change following function call */
|
||||
/*wattroff (window->win_chat, window->current_color_attr);*/
|
||||
window->current_color_attr = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_set_color: set color for a chat window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_set_color (t_gui_window *window, int fg, int bg)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
/*if (((fg == -1) || (fg == 99))
|
||||
&& ((bg == -1) || (bg == 99)))
|
||||
wattron (window->win_chat, COLOR_PAIR(63));
|
||||
else
|
||||
{
|
||||
if ((fg == -1) || (fg == 99))
|
||||
fg = WEECHAT_COLOR_WHITE;
|
||||
if ((bg == -1) || (bg == 99))
|
||||
bg = 0;
|
||||
wattron (window->win_chat, COLOR_PAIR((bg * 8) + fg));
|
||||
}*/
|
||||
(void) window;
|
||||
(void) fg;
|
||||
(void) bg;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_set_weechat_color: set a WeeChat color for a chat window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_set_weechat_color (t_gui_window *window, int weechat_color)
|
||||
{
|
||||
gui_chat_reset_style (window);
|
||||
gui_chat_set_style (window,
|
||||
gui_color[weechat_color]->attributes);
|
||||
gui_chat_set_color (window,
|
||||
gui_color[weechat_color]->foreground,
|
||||
gui_color[weechat_color]->background);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_draw_title: draw title window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_draw_title (t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) buffer;
|
||||
(void) erase;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_word_get_next_char: returns next char of a word
|
||||
* special chars like colors, bold, .. are skipped
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string, int apply_style)
|
||||
{
|
||||
char str_fg[3], str_bg[3];
|
||||
int fg, bg, 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:
|
||||
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:
|
||||
string++;
|
||||
if (isdigit (string[0]) && isdigit (string[1]))
|
||||
{
|
||||
str_fg[0] = string[0];
|
||||
str_fg[1] = string[1];
|
||||
str_fg[2] = '\0';
|
||||
string += 2;
|
||||
if (apply_style)
|
||||
{
|
||||
sscanf (str_fg, "%d", &weechat_color);
|
||||
gui_chat_set_weechat_color (window, weechat_color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GUI_ATTR_WEECHAT_SET_CHAR:
|
||||
string++;
|
||||
switch (string[0])
|
||||
{
|
||||
case GUI_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:
|
||||
string++;
|
||||
if (apply_style)
|
||||
gui_chat_set_color_style (window, A_REVERSE);
|
||||
break;
|
||||
case GUI_ATTR_UNDERLINE_CHAR:
|
||||
string++;
|
||||
if (apply_style)
|
||||
gui_chat_set_color_style (window, A_UNDERLINE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GUI_ATTR_WEECHAT_REMOVE_CHAR:
|
||||
string++;
|
||||
switch (string[0])
|
||||
{
|
||||
case GUI_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:
|
||||
string++;
|
||||
if (apply_style)
|
||||
gui_chat_remove_color_style (window, A_REVERSE);
|
||||
break;
|
||||
case GUI_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
|
||||
return utf8_next_char ((char *)string);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* nothing found except color/attrib codes, so return NULL */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_display_word_raw: display word on chat buffer, letter by letter
|
||||
* special chars like color, bold, .. are interpreted
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_display_word_raw (t_gui_window *window, char *string)
|
||||
{
|
||||
/*char *prev_char, *next_char, saved_char;*/
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) string;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_display_word: display a word on chat buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_display_word (t_gui_window *window,
|
||||
t_gui_line *line,
|
||||
char *data,
|
||||
char *end_offset,
|
||||
int num_lines, int count, int *lines_displayed, int simulate)
|
||||
{
|
||||
/*char *end_line, saved_char_end, saved_char;
|
||||
int pos_saved_char, chars_to_display, num_displayed;*/
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) line;
|
||||
(void) data;
|
||||
(void) end_offset;
|
||||
(void) num_lines;
|
||||
(void) count;
|
||||
(void) lines_displayed;
|
||||
(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);
|
||||
if (next_char)
|
||||
{
|
||||
prev_char = utf8_prev_char (data, next_char);
|
||||
if (prev_char)
|
||||
{
|
||||
if (prev_char[0] != ' ')
|
||||
{
|
||||
if (leading_spaces)
|
||||
*word_start_offset = prev_char - start_data;
|
||||
leading_spaces = 0;
|
||||
char_size = next_char - prev_char;
|
||||
*word_end_offset = next_char - start_data - 1;
|
||||
(*word_length_with_spaces) += char_size;
|
||||
(*word_length) += char_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (leading_spaces)
|
||||
(*word_length_with_spaces)++;
|
||||
else
|
||||
{
|
||||
*word_end_offset = prev_char - start_data - 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
data = next_char;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*word_end_offset = data + strlen (data) - start_data - 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_display_line: display a line in the chat window
|
||||
* if count == 0, display whole line
|
||||
* if count > 0, display 'count' lines (beginning from the end)
|
||||
* if simulate == 1, nothing is displayed (for counting how
|
||||
* many lines would have been lines displayed)
|
||||
* returns: number of lines displayed (or simulated)
|
||||
*/
|
||||
|
||||
int
|
||||
gui_chat_display_line (t_gui_window *window, t_gui_line *line, int count,
|
||||
int simulate)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) line;
|
||||
(void) count;
|
||||
(void) simulate;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_calculate_line_diff: returns pointer to line & offset for a difference
|
||||
* with given line
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_calculate_line_diff (t_gui_window *window, t_gui_line **line,
|
||||
int *line_pos, int difference)
|
||||
{
|
||||
int backward, current_size;
|
||||
|
||||
if (!line || !line_pos)
|
||||
return;
|
||||
|
||||
backward = (difference < 0);
|
||||
|
||||
if (!(*line))
|
||||
{
|
||||
/* if looking backward, start at last line of buffer */
|
||||
if (backward)
|
||||
{
|
||||
*line = window->buffer->last_line;
|
||||
if (!(*line))
|
||||
return;
|
||||
current_size = gui_chat_display_line (window, *line, 0, 1);
|
||||
if (current_size == 0)
|
||||
current_size = 1;
|
||||
*line_pos = current_size - 1;
|
||||
}
|
||||
/* if looking forward, start at first line of buffer */
|
||||
else
|
||||
{
|
||||
*line = window->buffer->lines;
|
||||
if (!(*line))
|
||||
return;
|
||||
*line_pos = 0;
|
||||
current_size = gui_chat_display_line (window, *line, 0, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
current_size = gui_chat_display_line (window, *line, 0, 1);
|
||||
|
||||
while ((*line) && (difference != 0))
|
||||
{
|
||||
/* looking backward */
|
||||
if (backward)
|
||||
{
|
||||
if (*line_pos > 0)
|
||||
(*line_pos)--;
|
||||
else
|
||||
{
|
||||
*line = (*line)->prev_line;
|
||||
if (*line)
|
||||
{
|
||||
current_size = gui_chat_display_line (window, *line, 0, 1);
|
||||
if (current_size == 0)
|
||||
current_size = 1;
|
||||
*line_pos = current_size - 1;
|
||||
}
|
||||
}
|
||||
difference++;
|
||||
}
|
||||
/* looking forward */
|
||||
else
|
||||
{
|
||||
if (*line_pos < current_size - 1)
|
||||
(*line_pos)++;
|
||||
else
|
||||
{
|
||||
*line = (*line)->next_line;
|
||||
if (*line)
|
||||
{
|
||||
current_size = gui_chat_display_line (window, *line, 0, 1);
|
||||
if (current_size == 0)
|
||||
current_size = 1;
|
||||
*line_pos = 0;
|
||||
}
|
||||
}
|
||||
difference--;
|
||||
}
|
||||
}
|
||||
|
||||
/* first or last line reached */
|
||||
if (!(*line))
|
||||
{
|
||||
if (backward)
|
||||
{
|
||||
/* first line reached */
|
||||
*line = window->buffer->lines;
|
||||
*line_pos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* last line reached => consider we'll display all until the end */
|
||||
*line_pos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_draw: draw chat window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_draw (t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
/*t_gui_window *ptr_win;
|
||||
t_gui_line *ptr_line;
|
||||
t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc;
|
||||
char format_empty[32];
|
||||
int i, j, line_pos, count, num_bars;
|
||||
char *unit_name[] = { N_("bytes"), N_("Kb"), N_("Mb"), N_("Gb") };
|
||||
char *unit_format[] = { "%.0Lf", "%.1Lf", "%.02Lf", "%.02Lf" };
|
||||
long unit_divide[] = { 1, 1024, 1024*1024, 1024*1024,1024 };
|
||||
int num_unit;
|
||||
char format[32], date[128], *buf;
|
||||
struct tm *date_tmp;*/
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) buffer;
|
||||
(void) erase;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_draw_line: add a line to chat window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_draw_line (t_gui_buffer *buffer, t_gui_line *line)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
unsigned char *text_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);
|
||||
if (text_without_color)
|
||||
{
|
||||
gtk_text_buffer_insert_at_cursor (ptr_win->textbuffer_chat,
|
||||
(char *)text_without_color, -1);
|
||||
gtk_text_buffer_insert_at_cursor (ptr_win->textbuffer_chat,
|
||||
"\n", -1);
|
||||
gtk_text_buffer_get_bounds (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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,580 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-color.c: color functions for Gtk GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-gtk.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 }
|
||||
};
|
||||
|
||||
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];
|
||||
|
||||
|
||||
/*
|
||||
* gui_color_assign: assign a WeeChat color (read from config)
|
||||
*/
|
||||
|
||||
int
|
||||
gui_color_assign (int *color, char *color_name)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* look for curses colors in table */
|
||||
i = 0;
|
||||
while (gui_weechat_colors[i].string)
|
||||
{
|
||||
if (ascii_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
|
||||
{
|
||||
*color = i;
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* color not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_get_name: get color name
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_color_get_name (int num_color)
|
||||
{
|
||||
return gui_weechat_colors[num_color].string;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_decode: parses a message (coming from IRC server),
|
||||
* and according:
|
||||
* - remove any color/style in message
|
||||
* or:
|
||||
* - change colors by codes to be compatible with
|
||||
* other IRC clients
|
||||
* After use, string returned has to be free()
|
||||
*/
|
||||
|
||||
unsigned char *
|
||||
gui_color_decode (unsigned char *string, int keep_colors)
|
||||
{
|
||||
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[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_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_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 %= 16;
|
||||
attr |= gui_irc_colors[fg][1];
|
||||
}
|
||||
if (str_bg[0])
|
||||
{
|
||||
sscanf (str_bg, "%d", &bg);
|
||||
bg %= 16;
|
||||
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:
|
||||
string++;
|
||||
if (isdigit (string[0]) && isdigit (string[1]))
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
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:
|
||||
string++;
|
||||
if (string[0])
|
||||
{
|
||||
if (keep_colors)
|
||||
{
|
||||
out[out_pos++] = *(string - 1);
|
||||
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[0] && (out_pos < out_length - 1))
|
||||
{
|
||||
switch (string[0])
|
||||
{
|
||||
case GUI_ATTR_BOLD_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = 'B';
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_FIXED_CHAR:
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_RESET_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = 'O';
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_REVERSE_CHAR:
|
||||
case GUI_ATTR_REVERSE2_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = 'R';
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_ITALIC_CHAR:
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_UNDERLINE_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = 'R';
|
||||
string++;
|
||||
break;
|
||||
case GUI_ATTR_COLOR_CHAR:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = '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 (%B, %C, ..) in IRC colors
|
||||
* After use, string returned has to be free()
|
||||
*/
|
||||
|
||||
unsigned char *
|
||||
gui_color_encode (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[0] && (out_pos < out_length - 1))
|
||||
{
|
||||
switch (string[0])
|
||||
{
|
||||
case '%':
|
||||
string++;
|
||||
switch (string[0])
|
||||
{
|
||||
case '\0':
|
||||
out[out_pos++] = '%';
|
||||
break;
|
||||
case '%': /* double '%' replaced by single '%' */
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
break;
|
||||
case 'B': /* bold */
|
||||
out[out_pos++] = GUI_ATTR_BOLD_CHAR;
|
||||
string++;
|
||||
break;
|
||||
case 'C': /* color */
|
||||
out[out_pos++] = GUI_ATTR_COLOR_CHAR;
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
}
|
||||
}
|
||||
if (string[0] == ',')
|
||||
{
|
||||
out[out_pos++] = ',';
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'O': /* reset */
|
||||
out[out_pos++] = GUI_ATTR_RESET_CHAR;
|
||||
string++;
|
||||
break;
|
||||
case 'R': /* reverse */
|
||||
out[out_pos++] = GUI_ATTR_REVERSE_CHAR;
|
||||
string++;
|
||||
break;
|
||||
case 'U': /* underline */
|
||||
out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR;
|
||||
string++;
|
||||
break;
|
||||
default:
|
||||
out[out_pos++] = '%';
|
||||
out[out_pos++] = string[0];
|
||||
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
|
||||
*/
|
||||
|
||||
int
|
||||
gui_color_get_pair (int num_color)
|
||||
{
|
||||
int fg, bg;
|
||||
|
||||
if ((num_color < 0) || (num_color > GUI_NUM_COLORS - 1))
|
||||
return WEECHAT_COLOR_WHITE;
|
||||
|
||||
fg = gui_color[num_color]->foreground;
|
||||
bg = gui_color[num_color]->background;
|
||||
|
||||
if (((fg == -1) || (fg == 99))
|
||||
&& ((bg == -1) || (bg == 99)))
|
||||
return 63;
|
||||
if ((fg == -1) || (fg == 99))
|
||||
fg = WEECHAT_COLOR_WHITE;
|
||||
if ((bg == -1) || (bg == 99))
|
||||
bg = 0;
|
||||
|
||||
return (bg * 8) + fg;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init_pairs: init color pairs
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_init_pairs ()
|
||||
{
|
||||
/* This function does nothing in Gtk GUI */
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init_weechat: init WeeChat colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_init_weechat ()
|
||||
{
|
||||
int i;
|
||||
|
||||
gui_color[COLOR_WIN_SEPARATOR] = gui_color_build (COLOR_WIN_SEPARATOR, cfg_col_separator, cfg_col_separator);
|
||||
gui_color[COLOR_WIN_TITLE] = gui_color_build (COLOR_WIN_TITLE, cfg_col_title, cfg_col_title_bg);
|
||||
gui_color[COLOR_WIN_CHAT] = gui_color_build (COLOR_WIN_CHAT, cfg_col_chat, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_TIME] = gui_color_build (COLOR_WIN_CHAT_TIME, cfg_col_chat_time, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_TIME_SEP] = gui_color_build (COLOR_WIN_CHAT_TIME_SEP, cfg_col_chat_time_sep, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_PREFIX1] = gui_color_build (COLOR_WIN_CHAT_PREFIX1, cfg_col_chat_prefix1, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_PREFIX2] = gui_color_build (COLOR_WIN_CHAT_PREFIX2, cfg_col_chat_prefix2, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_SERVER] = gui_color_build (COLOR_WIN_CHAT_SERVER, cfg_col_chat_server, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_JOIN] = gui_color_build (COLOR_WIN_CHAT_JOIN, cfg_col_chat_join, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_PART] = gui_color_build (COLOR_WIN_CHAT_PART, cfg_col_chat_part, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_NICK] = gui_color_build (COLOR_WIN_CHAT_NICK, cfg_col_chat_nick, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_HOST] = gui_color_build (COLOR_WIN_CHAT_HOST, cfg_col_chat_host, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_CHANNEL] = gui_color_build (COLOR_WIN_CHAT_CHANNEL, cfg_col_chat_channel, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_DARK] = gui_color_build (COLOR_WIN_CHAT_DARK, cfg_col_chat_dark, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_HIGHLIGHT] = gui_color_build (COLOR_WIN_CHAT_HIGHLIGHT, cfg_col_chat_highlight, cfg_col_chat_bg);
|
||||
gui_color[COLOR_WIN_CHAT_READ_MARKER] = gui_color_build (COLOR_WIN_CHAT_READ_MARKER, cfg_col_chat_read_marker, cfg_col_chat_read_marker_bg);
|
||||
gui_color[COLOR_WIN_STATUS] = gui_color_build (COLOR_WIN_STATUS, cfg_col_status, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DELIMITERS] = gui_color_build (COLOR_WIN_STATUS_DELIMITERS, cfg_col_status_delimiters, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_CHANNEL] = gui_color_build (COLOR_WIN_STATUS_CHANNEL, cfg_col_status_channel, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DATA_MSG] = gui_color_build (COLOR_WIN_STATUS_DATA_MSG, cfg_col_status_data_msg, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DATA_PRIVATE] = gui_color_build (COLOR_WIN_STATUS_DATA_PRIVATE, cfg_col_status_data_private, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DATA_HIGHLIGHT] = gui_color_build (COLOR_WIN_STATUS_DATA_HIGHLIGHT, cfg_col_status_data_highlight, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_DATA_OTHER] = gui_color_build (COLOR_WIN_STATUS_DATA_OTHER, cfg_col_status_data_other, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_STATUS_MORE] = gui_color_build (COLOR_WIN_STATUS_MORE, cfg_col_status_more, cfg_col_status_bg);
|
||||
gui_color[COLOR_WIN_INFOBAR] = gui_color_build (COLOR_WIN_INFOBAR, cfg_col_infobar, cfg_col_infobar_bg);
|
||||
gui_color[COLOR_WIN_INFOBAR_DELIMITERS] = gui_color_build (COLOR_WIN_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg);
|
||||
gui_color[COLOR_WIN_INFOBAR_HIGHLIGHT] = gui_color_build (COLOR_WIN_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg);
|
||||
gui_color[COLOR_WIN_INPUT] = gui_color_build (COLOR_WIN_INPUT, cfg_col_input, cfg_col_input_bg);
|
||||
gui_color[COLOR_WIN_INPUT_CHANNEL] = gui_color_build (COLOR_WIN_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg);
|
||||
gui_color[COLOR_WIN_INPUT_NICK] = gui_color_build (COLOR_WIN_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg);
|
||||
gui_color[COLOR_WIN_INPUT_DELIMITERS] = gui_color_build (COLOR_WIN_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg);
|
||||
gui_color[COLOR_WIN_NICK] = gui_color_build (COLOR_WIN_NICK, cfg_col_nick, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_AWAY] = gui_color_build (COLOR_WIN_NICK_AWAY, cfg_col_nick_away, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_CHANOWNER] = gui_color_build (COLOR_WIN_NICK_CHANOWNER, cfg_col_nick_chanowner, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_CHANADMIN] = gui_color_build (COLOR_WIN_NICK_CHANADMIN, cfg_col_nick_chanadmin, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_OP] = gui_color_build (COLOR_WIN_NICK_OP, cfg_col_nick_op, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_HALFOP] = gui_color_build (COLOR_WIN_NICK_HALFOP, cfg_col_nick_halfop, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_VOICE] = gui_color_build (COLOR_WIN_NICK_VOICE, cfg_col_nick_voice, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_MORE] = gui_color_build (COLOR_WIN_NICK_MORE, cfg_col_nick_more, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_SEP] = gui_color_build (COLOR_WIN_NICK_SEP, cfg_col_nick_sep, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_SELF] = gui_color_build (COLOR_WIN_NICK_SELF, cfg_col_nick_self, cfg_col_nick_bg);
|
||||
gui_color[COLOR_WIN_NICK_PRIVATE] = gui_color_build (COLOR_WIN_NICK_PRIVATE, cfg_col_nick_private, cfg_col_nick_bg);
|
||||
|
||||
for (i = 0; i < COLOR_WIN_NICK_NUMBER; i++)
|
||||
{
|
||||
gui_color[COLOR_WIN_NICK_1 + i] = gui_color_build (COLOR_WIN_NICK_1 + i, cfg_col_nick_colors[i], cfg_col_chat_bg);
|
||||
}
|
||||
|
||||
gui_color[COLOR_DCC_SELECTED] = gui_color_build (COLOR_DCC_SELECTED, cfg_col_dcc_selected, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_WAITING] = gui_color_build (COLOR_DCC_WAITING, cfg_col_dcc_waiting, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_CONNECTING] = gui_color_build (COLOR_DCC_CONNECTING, cfg_col_dcc_connecting, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_ACTIVE] = gui_color_build (COLOR_DCC_ACTIVE, cfg_col_dcc_active, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_DONE] = gui_color_build (COLOR_DCC_DONE, cfg_col_dcc_done, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_FAILED] = gui_color_build (COLOR_DCC_FAILED, cfg_col_dcc_failed, cfg_col_chat_bg);
|
||||
gui_color[COLOR_DCC_ABORTED] = gui_color_build (COLOR_DCC_ABORTED, cfg_col_dcc_aborted, cfg_col_chat_bg);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_rebuild_weechat: rebuild WeeChat colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_rebuild_weechat ()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GUI_NUM_COLORS; i++)
|
||||
{
|
||||
if (gui_color[i])
|
||||
{
|
||||
if (gui_color[i]->string)
|
||||
free (gui_color[i]->string);
|
||||
free (gui_color[i]);
|
||||
gui_color[i] = NULL;
|
||||
}
|
||||
}
|
||||
gui_color_init_weechat ();
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_color_init: init GUI colors
|
||||
*/
|
||||
|
||||
void
|
||||
gui_color_init ()
|
||||
{
|
||||
gui_color_init_pairs ();
|
||||
gui_color_init_weechat ();
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_GUI_GTK_H
|
||||
#define __WEECHAT_GUI_GTK_H 1
|
||||
|
||||
/* TODO: remove these temporary defines */
|
||||
|
||||
#define A_BOLD 1
|
||||
#define A_UNDERLINE 2
|
||||
#define A_REVERSE 4
|
||||
|
||||
#define COLOR_BLACK 0
|
||||
#define COLOR_BLUE 1
|
||||
#define COLOR_GREEN 2
|
||||
#define COLOR_CYAN 3
|
||||
#define COLOR_RED 4
|
||||
#define COLOR_MAGENTA 5
|
||||
#define COLOR_YELLOW 6
|
||||
#define COLOR_WHITE 7
|
||||
|
||||
/* 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
|
||||
|
||||
extern t_gui_color gui_weechat_colors[];
|
||||
extern int gui_irc_colors[GUI_NUM_IRC_COLORS][2];
|
||||
|
||||
extern GtkWidget *gtk_main_window;
|
||||
extern GtkWidget *vbox1;
|
||||
extern GtkWidget *entry_topic;
|
||||
extern GtkWidget *notebook1;
|
||||
extern GtkWidget *vbox2;
|
||||
extern GtkWidget *hbox1;
|
||||
extern GtkWidget *hpaned1;
|
||||
extern GtkWidget *scrolledwindow_chat;
|
||||
extern GtkWidget *scrolledwindow_nick;
|
||||
extern GtkWidget *entry_input;
|
||||
extern GtkWidget *label1;
|
||||
|
||||
/* color functions */
|
||||
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);
|
||||
|
||||
/* keyboard functions */
|
||||
extern void gui_keyboard_default_bindings ();
|
||||
extern void gui_keyboard_read ();
|
||||
|
||||
/* window functions */
|
||||
extern void gui_window_set_title ();
|
||||
extern void gui_window_reset_title ();
|
||||
|
||||
#endif /* gui-gtk.h */
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-infobar.c: infobar display functions for Gtk GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/hotlist.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-gtk.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_infobar_draw_time: draw time in infobar window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_infobar_draw_time (t_gui_buffer *buffer)
|
||||
{
|
||||
/*t_gui_window *ptr_win;
|
||||
time_t time_seconds;
|
||||
struct tm *local_time;*/
|
||||
|
||||
/* make gcc happy */
|
||||
(void) buffer;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_infobar_draw: draw infobar window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_infobar_draw (t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
/*t_gui_window *ptr_win;
|
||||
time_t time_seconds;
|
||||
struct tm *local_time;
|
||||
char text_time[1024 + 1];*/
|
||||
|
||||
/* make gcc happy */
|
||||
(void) buffer;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) buffer;
|
||||
(void) erase;
|
||||
}
|
||||
+128
-137
@@ -25,166 +25,157 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../common/command.h"
|
||||
#include "../../common/hotlist.h"
|
||||
#include "../../common/fifo.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../irc/irc.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-gtk.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* gui_input_default_key_bindings: create default key bindings
|
||||
* gui_input_set_color: set color for an input window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_default_key_bindings ()
|
||||
gui_input_set_color (t_gui_window *window, int irc_color)
|
||||
{
|
||||
int i;
|
||||
char key_str[32], command[32];
|
||||
|
||||
/* keys binded with internal functions */
|
||||
gui_key_bind ( /* RC */ "ctrl-M", "return");
|
||||
gui_key_bind ( /* RC */ "ctrl-J", "return");
|
||||
gui_key_bind ( /* tab */ "ctrl-I", "tab");
|
||||
gui_key_bind ( /* basckp */ "ctrl-H", "backspace");
|
||||
gui_key_bind ( /* basckp */ "ctrl-?", "backspace");
|
||||
gui_key_bind ( /* del */ "meta2-3~", "delete");
|
||||
gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line");
|
||||
gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line");
|
||||
gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word");
|
||||
gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste");
|
||||
gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars");
|
||||
gui_key_bind ( /* home */ "meta2-1~", "home");
|
||||
gui_key_bind ( /* home */ "meta2-H", "home");
|
||||
gui_key_bind ( /* home */ "meta2-7~", "home");
|
||||
gui_key_bind ( /* ^A */ "ctrl-A", "home");
|
||||
gui_key_bind ( /* end */ "meta2-4~", "end");
|
||||
gui_key_bind ( /* end */ "meta2-F", "end");
|
||||
gui_key_bind ( /* end */ "meta2-8~", "end");
|
||||
gui_key_bind ( /* ^E */ "ctrl-E", "end");
|
||||
gui_key_bind ( /* left */ "meta2-D", "left");
|
||||
gui_key_bind ( /* right */ "meta2-C", "right");
|
||||
gui_key_bind ( /* up */ "meta2-A", "up");
|
||||
gui_key_bind ( /* ^up */ "meta-Oa", "up_global");
|
||||
gui_key_bind ( /* down */ "meta2-B", "down");
|
||||
gui_key_bind ( /* ^down */ "meta-Ob", "down_global");
|
||||
gui_key_bind ( /* pgup */ "meta2-5~", "page_up");
|
||||
gui_key_bind ( /* pgdn */ "meta2-6~", "page_down");
|
||||
gui_key_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up");
|
||||
gui_key_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down");
|
||||
gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear");
|
||||
gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up");
|
||||
gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down");
|
||||
gui_key_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning");
|
||||
gui_key_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end");
|
||||
gui_key_bind ( /* ^L */ "ctrl-L", "refresh");
|
||||
gui_key_bind ( /* m-a */ "meta-a", "jump_smart");
|
||||
gui_key_bind ( /* m-b */ "meta-b", "previous_word");
|
||||
gui_key_bind ( /* ^left */ "meta-Od", "previous_word");
|
||||
gui_key_bind ( /* m-d */ "meta-d", "delete_next_word");
|
||||
gui_key_bind ( /* m-f */ "meta-f", "next_word");
|
||||
gui_key_bind ( /* ^right */ "meta-Oc", "next_word");
|
||||
gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear");
|
||||
gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc");
|
||||
gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer");
|
||||
gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server");
|
||||
gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server");
|
||||
gui_key_bind ( /* m-k */ "meta-k", "grab_key");
|
||||
gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight");
|
||||
gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight");
|
||||
gui_key_bind ( /* m-r */ "meta-r", "delete_line");
|
||||
gui_key_bind ( /* m-s */ "meta-s", "switch_server");
|
||||
gui_key_bind ( /* m-u */ "meta-u", "scroll_unread");
|
||||
|
||||
/* keys binded with commands */
|
||||
gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1");
|
||||
gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1");
|
||||
gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1");
|
||||
gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1");
|
||||
gui_key_bind ( /* F7 */ "meta2-18~", "/window -1");
|
||||
gui_key_bind ( /* F8 */ "meta2-19~", "/window +1");
|
||||
gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up");
|
||||
gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down");
|
||||
gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left");
|
||||
gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right");
|
||||
gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10");
|
||||
gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1");
|
||||
gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2");
|
||||
gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3");
|
||||
gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4");
|
||||
gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5");
|
||||
gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6");
|
||||
gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7");
|
||||
gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8");
|
||||
gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9");
|
||||
|
||||
/* bind meta-j + {01..99} to switch to buffers # > 10 */
|
||||
for (i = 1; i < 100; i++)
|
||||
{
|
||||
sprintf (key_str, "meta-j%02d", i);
|
||||
sprintf (command, "/buffer %d", i);
|
||||
gui_key_bind (key_str, command);
|
||||
}
|
||||
/*int fg, bg;*/
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) irc_color;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_grab_end: insert grabbed key in input buffer
|
||||
* gui_input_get_prompt_length: return input prompt length
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_grab_end ()
|
||||
int
|
||||
gui_input_get_prompt_length (t_gui_window *window, char *nick)
|
||||
{
|
||||
char *expanded_key;
|
||||
|
||||
/* get expanded name (for example: ^U => ctrl-u) */
|
||||
expanded_key = gui_key_get_expanded_name (gui_key_buffer);
|
||||
char *pos, *modes;
|
||||
int length, mode_found;
|
||||
|
||||
if (expanded_key)
|
||||
length = 0;
|
||||
pos = cfg_look_input_format;
|
||||
while (pos && pos[0])
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
switch (pos[0])
|
||||
{
|
||||
gui_insert_string_input (gui_current_window, expanded_key, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 1);
|
||||
case '%':
|
||||
pos++;
|
||||
switch (pos[0])
|
||||
{
|
||||
case 'c':
|
||||
if (CHANNEL(window->buffer))
|
||||
length += utf8_strlen (CHANNEL(window->buffer)->name);
|
||||
else
|
||||
{
|
||||
if (SERVER(window->buffer))
|
||||
length += utf8_strlen (SERVER(window->buffer)->name);
|
||||
}
|
||||
pos++;
|
||||
break;
|
||||
case 'm':
|
||||
if (SERVER(window->buffer))
|
||||
{
|
||||
mode_found = 0;
|
||||
for (modes = 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;
|
||||
}
|
||||
free (expanded_key);
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_draw_prompt: display input prompt
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_draw_prompt (t_gui_window *window, char *nick)
|
||||
{
|
||||
/*char *pos, saved_char, *modes;
|
||||
int char_size, mode_found;*/
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) nick;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_draw_text: display text in input buffer, according to color mask
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_draw_text (t_gui_window *window, int input_width)
|
||||
{
|
||||
/*char *ptr_start, *ptr_next, saved_char;
|
||||
int pos_mask, size, last_color, color;*/
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) input_width;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_draw: draw input window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_draw (t_gui_buffer *buffer, int erase)
|
||||
{
|
||||
/*t_gui_window *ptr_win;
|
||||
char format[32];
|
||||
char *ptr_nickname;
|
||||
int input_width;
|
||||
t_irc_dcc *dcc_selected;*/
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
/* end grab mode */
|
||||
gui_key_grab = 0;
|
||||
gui_key_grab_count = 0;
|
||||
gui_key_buffer[0] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_read: read keyboard chars
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_read ()
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) buffer;
|
||||
(void) erase;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_loop: main loop for WeeChat with ncurses GUI
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_loop ()
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
gtk_main ();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-keyboard.c: keyboard functions for Gtk GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/utf8.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* gui_keyboard_default_bindings: create default key bindings
|
||||
*/
|
||||
|
||||
void
|
||||
gui_keyboard_default_bindings ()
|
||||
{
|
||||
int i;
|
||||
char key_str[32], command[32];
|
||||
|
||||
/* keys binded with internal functions */
|
||||
gui_key_bind ( /* RC */ "ctrl-M", "return");
|
||||
gui_key_bind ( /* RC */ "ctrl-J", "return");
|
||||
gui_key_bind ( /* tab */ "ctrl-I", "tab");
|
||||
gui_key_bind ( /* basckp */ "ctrl-H", "backspace");
|
||||
gui_key_bind ( /* basckp */ "ctrl-?", "backspace");
|
||||
gui_key_bind ( /* del */ "meta2-3~", "delete");
|
||||
gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line");
|
||||
gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line");
|
||||
gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word");
|
||||
gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste");
|
||||
gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars");
|
||||
gui_key_bind ( /* home */ "meta2-1~", "home");
|
||||
gui_key_bind ( /* home */ "meta2-H", "home");
|
||||
gui_key_bind ( /* home */ "meta2-7~", "home");
|
||||
gui_key_bind ( /* ^A */ "ctrl-A", "home");
|
||||
gui_key_bind ( /* end */ "meta2-4~", "end");
|
||||
gui_key_bind ( /* end */ "meta2-F", "end");
|
||||
gui_key_bind ( /* end */ "meta2-8~", "end");
|
||||
gui_key_bind ( /* ^E */ "ctrl-E", "end");
|
||||
gui_key_bind ( /* left */ "meta2-D", "left");
|
||||
gui_key_bind ( /* right */ "meta2-C", "right");
|
||||
gui_key_bind ( /* up */ "meta2-A", "up");
|
||||
gui_key_bind ( /* ^up */ "meta-Oa", "up_global");
|
||||
gui_key_bind ( /* down */ "meta2-B", "down");
|
||||
gui_key_bind ( /* ^down */ "meta-Ob", "down_global");
|
||||
gui_key_bind ( /* pgup */ "meta2-5~", "page_up");
|
||||
gui_key_bind ( /* pgdn */ "meta2-6~", "page_down");
|
||||
gui_key_bind ( /* m-pgup */ "meta-meta2-5~", "scroll_up");
|
||||
gui_key_bind ( /* m-pgdn */ "meta-meta2-6~", "scroll_down");
|
||||
gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear");
|
||||
gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up");
|
||||
gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down");
|
||||
gui_key_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning");
|
||||
gui_key_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end");
|
||||
gui_key_bind ( /* ^L */ "ctrl-L", "refresh");
|
||||
gui_key_bind ( /* m-a */ "meta-a", "jump_smart");
|
||||
gui_key_bind ( /* m-b */ "meta-b", "previous_word");
|
||||
gui_key_bind ( /* ^left */ "meta-Od", "previous_word");
|
||||
gui_key_bind ( /* m-d */ "meta-d", "delete_next_word");
|
||||
gui_key_bind ( /* m-f */ "meta-f", "next_word");
|
||||
gui_key_bind ( /* ^right */ "meta-Oc", "next_word");
|
||||
gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear");
|
||||
gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc");
|
||||
gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer");
|
||||
gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server");
|
||||
gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server");
|
||||
gui_key_bind ( /* m-k */ "meta-k", "grab_key");
|
||||
gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight");
|
||||
gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight");
|
||||
gui_key_bind ( /* m-r */ "meta-r", "delete_line");
|
||||
gui_key_bind ( /* m-s */ "meta-s", "switch_server");
|
||||
gui_key_bind ( /* m-u */ "meta-u", "scroll_unread");
|
||||
|
||||
/* keys binded with commands */
|
||||
gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1");
|
||||
gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1");
|
||||
gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1");
|
||||
gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1");
|
||||
gui_key_bind ( /* F7 */ "meta2-18~", "/window -1");
|
||||
gui_key_bind ( /* F8 */ "meta2-19~", "/window +1");
|
||||
gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up");
|
||||
gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down");
|
||||
gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left");
|
||||
gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right");
|
||||
gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10");
|
||||
gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1");
|
||||
gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2");
|
||||
gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3");
|
||||
gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4");
|
||||
gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5");
|
||||
gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6");
|
||||
gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7");
|
||||
gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8");
|
||||
gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9");
|
||||
|
||||
/* bind meta-j + {01..99} to switch to buffers # > 10 */
|
||||
for (i = 1; i < 100; i++)
|
||||
{
|
||||
sprintf (key_str, "meta-j%02d", i);
|
||||
sprintf (command, "/buffer %d", i);
|
||||
gui_key_bind (key_str, command);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_keyboard_grab_end: insert grabbed key in input buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_keyboard_grab_end ()
|
||||
{
|
||||
char *expanded_key;
|
||||
|
||||
/* get expanded name (for example: ^U => ctrl-u) */
|
||||
expanded_key = gui_key_get_expanded_name (gui_key_buffer);
|
||||
|
||||
if (expanded_key)
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
{
|
||||
gui_insert_string_input (gui_current_window, expanded_key, -1);
|
||||
gui_current_window->buffer->input_buffer_pos += utf8_strlen (expanded_key);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
free (expanded_key);
|
||||
}
|
||||
|
||||
/* end grab mode */
|
||||
gui_key_grab = 0;
|
||||
gui_key_grab_count = 0;
|
||||
gui_key_buffer[0] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_keyboard_read: read keyboard chars
|
||||
*/
|
||||
|
||||
void
|
||||
gui_keyboard_read ()
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-main.c: main loop and keyboard management for Gtk GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/fifo.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-gtk.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
GtkWidget *gtk_main_window;
|
||||
GtkWidget *vbox1;
|
||||
GtkWidget *entry_topic;
|
||||
GtkWidget *notebook1;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *hbox1;
|
||||
GtkWidget *hpaned1;
|
||||
GtkWidget *scrolledwindow_chat;
|
||||
GtkWidget *scrolledwindow_nick;
|
||||
GtkWidget *entry_input;
|
||||
GtkWidget *label1;
|
||||
|
||||
|
||||
/*
|
||||
* gui_main_loop: main loop for WeeChat with ncurses GUI
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_loop ()
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
gtk_main ();
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_pre_init: pre-initialize GUI (called before gui_init)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_pre_init (int *argc, char **argv[])
|
||||
{
|
||||
/* Initialise Gtk */
|
||||
gtk_init (argc, argv);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_init: init GUI
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_init ()
|
||||
{
|
||||
GdkColor color_fg, color_bg;
|
||||
|
||||
gui_color_init ();
|
||||
|
||||
gui_infobar = NULL;
|
||||
|
||||
gui_ok = 1;
|
||||
|
||||
/* init clipboard buffer */
|
||||
gui_input_clipboard = NULL;
|
||||
|
||||
/* create Gtk widgets */
|
||||
|
||||
gdk_color_parse ("white", &color_fg);
|
||||
gdk_color_parse ("black", &color_bg);
|
||||
|
||||
gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (gtk_main_window), PACKAGE_STRING);
|
||||
|
||||
g_signal_connect (G_OBJECT (gtk_main_window), "destroy", gtk_main_quit, NULL);
|
||||
|
||||
vbox1 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_widget_show (vbox1);
|
||||
gtk_container_add (GTK_CONTAINER (gtk_main_window), vbox1);
|
||||
|
||||
entry_topic = gtk_entry_new ();
|
||||
gtk_widget_show (entry_topic);
|
||||
gtk_box_pack_start (GTK_BOX (vbox1), entry_topic, FALSE, FALSE, 0);
|
||||
gtk_widget_modify_text (entry_topic, GTK_STATE_NORMAL, &color_fg);
|
||||
gtk_widget_modify_base (entry_topic, GTK_STATE_NORMAL, &color_bg);
|
||||
|
||||
notebook1 = gtk_notebook_new ();
|
||||
gtk_widget_show (notebook1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox1), notebook1, TRUE, TRUE, 0);
|
||||
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook1), GTK_POS_BOTTOM);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_widget_show (vbox2);
|
||||
gtk_container_add (GTK_CONTAINER (notebook1), vbox2);
|
||||
|
||||
hbox1 = gtk_hbox_new (FALSE, 0);
|
||||
gtk_widget_show (hbox1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), hbox1, TRUE, TRUE, 0);
|
||||
|
||||
hpaned1 = gtk_hpaned_new ();
|
||||
gtk_widget_show (hpaned1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox1), hpaned1, TRUE, TRUE, 0);
|
||||
gtk_paned_set_position (GTK_PANED (hpaned1), 0);
|
||||
|
||||
scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolledwindow_chat);
|
||||
gtk_paned_pack1 (GTK_PANED (hpaned1), scrolledwindow_chat, FALSE, TRUE);
|
||||
//gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_chat, TRUE, TRUE, 0);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_chat), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
|
||||
gtk_widget_modify_text (scrolledwindow_chat, GTK_STATE_NORMAL, &color_fg);
|
||||
gtk_widget_modify_base (scrolledwindow_chat, GTK_STATE_NORMAL, &color_bg);
|
||||
|
||||
scrolledwindow_nick = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolledwindow_nick);
|
||||
gtk_paned_pack2 (GTK_PANED (hpaned1), scrolledwindow_nick, FALSE, TRUE);
|
||||
//gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_nick, TRUE, TRUE, 0);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_nick), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
|
||||
gtk_widget_modify_text (scrolledwindow_nick, GTK_STATE_NORMAL, &color_fg);
|
||||
gtk_widget_modify_base (scrolledwindow_nick, GTK_STATE_NORMAL, &color_bg);
|
||||
|
||||
entry_input = gtk_entry_new ();
|
||||
gtk_widget_show (entry_input);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), entry_input, FALSE, FALSE, 0);
|
||||
gtk_widget_modify_text (entry_input, GTK_STATE_NORMAL, &color_fg);
|
||||
gtk_widget_modify_base (entry_input, GTK_STATE_NORMAL, &color_bg);
|
||||
|
||||
label1 = gtk_label_new (_("server"));
|
||||
gtk_widget_show (label1);
|
||||
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), label1);
|
||||
gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);
|
||||
|
||||
gtk_widget_show_all (gtk_main_window);
|
||||
|
||||
/* create new window/buffer */
|
||||
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);
|
||||
|
||||
if (cfg_look_set_title)
|
||||
gui_window_set_title ();
|
||||
|
||||
gui_init_ok = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_main_end: GUI end
|
||||
*/
|
||||
|
||||
void
|
||||
gui_main_end ()
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
/* free clipboard buffer */
|
||||
if (gui_input_clipboard)
|
||||
free(gui_input_clipboard);
|
||||
|
||||
/* delete all windows */
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
/* TODO: destroy Gtk widgets */
|
||||
}
|
||||
|
||||
/* delete all buffers */
|
||||
while (gui_buffers)
|
||||
gui_buffer_free (gui_buffers, 0);
|
||||
|
||||
/* delete all windows */
|
||||
while (gui_windows)
|
||||
gui_window_free (gui_windows);
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
|
||||
/* delete global history */
|
||||
history_global_free ();
|
||||
|
||||
/* delete infobar messages */
|
||||
while (gui_infobar)
|
||||
gui_infobar_remove ();
|
||||
|
||||
/* reset title */
|
||||
if (cfg_look_set_title)
|
||||
gui_window_reset_title ();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-nicklist.c: nicklist display functions for Gtk GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../irc/irc.h"
|
||||
#include "gui-gtk.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_nicklist_draw: draw nick window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_nicklist_draw (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 || !BUFFER_HAS_NICKLIST(buffer))
|
||||
return;
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) buffer;
|
||||
(void) erase;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-status.c: status display functions for Gtk GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/hotlist.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-gtk.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_status_draw: draw status window for a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_status_draw (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 gcc happy */
|
||||
(void) buffer;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) buffer;
|
||||
(void) erase;
|
||||
}
|
||||
@@ -0,0 +1,847 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-window.c: window display functions for Gtk GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../gui.h"
|
||||
#include "../../common/hotlist.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "gui-gtk.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_window_set_weechat_color: set WeeChat color for window
|
||||
*/
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
/*void
|
||||
gui_window_set_weechat_color (WINDOW *window, int num_color)
|
||||
{
|
||||
if ((num_color >= 0) && (num_color <= GUI_NUM_COLORS - 1))
|
||||
{
|
||||
wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE);
|
||||
wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) |
|
||||
gui_color[num_color]->attributes);
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
* gui_window_calculate_pos_size: calculate position and size for a window & sub-win
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_calculate_pos_size (t_gui_window *window, int force_calculate)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) force_calculate;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_draw_separator: draw window separation
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_draw_separator (t_gui_window *window)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
/*if (window->win_separator)
|
||||
delwin (window->win_separator);
|
||||
|
||||
if (window->win_x > 0)
|
||||
{
|
||||
window->win_separator = newwin (window->win_height,
|
||||
1,
|
||||
window->win_y,
|
||||
window->win_x - 1);
|
||||
gui_window_set_weechat_color (window->win_separator, COLOR_WIN_SEPARATOR);
|
||||
wborder (window->win_separator, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
|
||||
wnoutrefresh (window->win_separator);
|
||||
refresh ();
|
||||
}*/
|
||||
(void) window;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_redraw_buffer: redraw a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_redraw_buffer (t_gui_buffer *buffer)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->buffer == buffer)
|
||||
{
|
||||
gui_chat_draw_title (buffer, 1);
|
||||
gui_chat_draw (buffer, 1);
|
||||
if (ptr_win->win_nick)
|
||||
gui_nicklist_draw (buffer, 1);
|
||||
gui_status_draw (buffer, 1);
|
||||
if (cfg_look_infobar)
|
||||
gui_infobar_draw (buffer, 1);
|
||||
gui_input_draw (buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_switch_to_buffer: switch to another buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer)
|
||||
{
|
||||
GtkTextIter start, end;
|
||||
|
||||
if (window->buffer->num_displayed > 0)
|
||||
window->buffer->num_displayed--;
|
||||
|
||||
if (window->buffer != buffer)
|
||||
{
|
||||
window->buffer->last_read_line = window->buffer->last_line;
|
||||
if (buffer->last_read_line == buffer->last_line)
|
||||
buffer->last_read_line = NULL;
|
||||
}
|
||||
|
||||
window->buffer = buffer;
|
||||
window->win_nick_start = 0;
|
||||
gui_window_calculate_pos_size (window, 1);
|
||||
|
||||
if (!window->textview_chat)
|
||||
{
|
||||
window->textview_chat = gtk_text_view_new ();
|
||||
gtk_widget_show (window->textview_chat);
|
||||
gtk_container_add (GTK_CONTAINER (scrolledwindow_chat), window->textview_chat);
|
||||
gtk_widget_set_size_request (window->textview_chat, 300, -1);
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (window->textview_chat), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (window->textview_chat), FALSE);
|
||||
|
||||
window->textbuffer_chat = gtk_text_buffer_new (NULL);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (window->textview_chat), window->textbuffer_chat);
|
||||
|
||||
/*window->texttag_chat = gtk_text_buffer_create_tag(window->textbuffer_chat, "courier", "font_family", "lucida");*/
|
||||
gtk_text_buffer_get_bounds (window->textbuffer_chat, &start, &end);
|
||||
gtk_text_buffer_apply_tag (window->textbuffer_chat, window->texttag_chat, &start, &end);
|
||||
}
|
||||
if (BUFFER_IS_CHANNEL(buffer) && !window->textbuffer_nicklist)
|
||||
{
|
||||
window->textview_nicklist = gtk_text_view_new ();
|
||||
gtk_widget_show (window->textview_nicklist);
|
||||
gtk_container_add (GTK_CONTAINER (scrolledwindow_nick), window->textview_nicklist);
|
||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (window->textview_nicklist), FALSE);
|
||||
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (window->textview_nicklist), FALSE);
|
||||
|
||||
window->textbuffer_nicklist = gtk_text_buffer_new (NULL);
|
||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (window->textview_nicklist), window->textbuffer_nicklist);
|
||||
}
|
||||
|
||||
window->start_line = NULL;
|
||||
window->start_line_pos = 0;
|
||||
|
||||
buffer->num_displayed++;
|
||||
|
||||
hotlist_remove_buffer (buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_page_up: display previous page on buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_page_up (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (!window->first_line_displayed)
|
||||
{
|
||||
gui_chat_calculate_line_diff (window, &window->start_line,
|
||||
&window->start_line_pos,
|
||||
(window->start_line) ?
|
||||
(-1) * (window->win_chat_height - 1) :
|
||||
(-1) * ((window->win_chat_height - 1) * 2));
|
||||
gui_chat_draw (window->buffer, 0);
|
||||
gui_status_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_page_down: display next page on buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_page_down (t_gui_window *window)
|
||||
{
|
||||
t_gui_line *ptr_line;
|
||||
int line_pos;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (window->start_line)
|
||||
{
|
||||
gui_chat_calculate_line_diff (window, &window->start_line,
|
||||
&window->start_line_pos,
|
||||
window->win_chat_height - 1);
|
||||
|
||||
/* check if we can display all */
|
||||
ptr_line = window->start_line;
|
||||
line_pos = window->start_line_pos;
|
||||
gui_chat_calculate_line_diff (window, &ptr_line,
|
||||
&line_pos,
|
||||
window->win_chat_height - 1);
|
||||
if (!ptr_line)
|
||||
{
|
||||
window->start_line = NULL;
|
||||
window->start_line_pos = 0;
|
||||
}
|
||||
|
||||
gui_chat_draw (window->buffer, 0);
|
||||
gui_status_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_scroll_up: display previous few lines in buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_scroll_up (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (!window->first_line_displayed)
|
||||
{
|
||||
gui_chat_calculate_line_diff (window, &window->start_line,
|
||||
&window->start_line_pos,
|
||||
(window->start_line) ?
|
||||
(-1) * cfg_look_scroll_amount :
|
||||
(-1) * ( (window->win_chat_height - 1) + cfg_look_scroll_amount));
|
||||
gui_chat_draw (window->buffer, 0);
|
||||
gui_status_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_scroll_down: display next few lines in buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_scroll_down (t_gui_window *window)
|
||||
{
|
||||
t_gui_line *ptr_line;
|
||||
int line_pos;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (window->start_line)
|
||||
{
|
||||
gui_chat_calculate_line_diff (window, &window->start_line,
|
||||
&window->start_line_pos,
|
||||
cfg_look_scroll_amount);
|
||||
|
||||
/* check if we can display all */
|
||||
ptr_line = window->start_line;
|
||||
line_pos = window->start_line_pos;
|
||||
gui_chat_calculate_line_diff (window, &ptr_line,
|
||||
&line_pos,
|
||||
window->win_chat_height - 1);
|
||||
|
||||
if (!ptr_line)
|
||||
{
|
||||
window->start_line = NULL;
|
||||
window->start_line_pos = 0;
|
||||
}
|
||||
|
||||
gui_chat_draw (window->buffer, 0);
|
||||
gui_status_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_scroll_top: scroll to top of buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_scroll_top (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (!window->first_line_displayed)
|
||||
{
|
||||
window->start_line = window->buffer->lines;
|
||||
window->start_line_pos = 0;
|
||||
gui_chat_draw (window->buffer, 0);
|
||||
gui_status_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_scroll_bottom: scroll to bottom of buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_scroll_bottom (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (window->start_line)
|
||||
{
|
||||
window->start_line = NULL;
|
||||
window->start_line_pos = 0;
|
||||
gui_chat_draw (window->buffer, 0);
|
||||
gui_status_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_nick_beginning: go to beginning of nicklist
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_nick_beginning (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (BUFFER_HAS_NICKLIST(window->buffer))
|
||||
{
|
||||
if (window->win_nick_start > 0)
|
||||
{
|
||||
window->win_nick_start = 0;
|
||||
gui_nicklist_draw (window->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_nick_end: go to the end of nicklist
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_nick_end (t_gui_window *window)
|
||||
{
|
||||
int new_start;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (BUFFER_HAS_NICKLIST(window->buffer))
|
||||
{
|
||||
new_start =
|
||||
CHANNEL(window->buffer)->nicks_count - window->win_nick_height;
|
||||
if (new_start < 0)
|
||||
new_start = 0;
|
||||
else if (new_start >= 1)
|
||||
new_start++;
|
||||
|
||||
if (new_start != window->win_nick_start)
|
||||
{
|
||||
window->win_nick_start = new_start;
|
||||
gui_nicklist_draw (window->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_nick_page_up: scroll one page up in nicklist
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_nick_page_up (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (BUFFER_HAS_NICKLIST(window->buffer))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_nick_page_down: scroll one page down in nicklist
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_nick_page_down (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
if (BUFFER_HAS_NICKLIST(window->buffer))
|
||||
{
|
||||
if ((CHANNEL(window->buffer)->nicks_count > window->win_nick_height)
|
||||
&& (window->win_nick_start + window->win_nick_height - 1
|
||||
< CHANNEL(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_init_subwindows: init subwindows for a WeeChat window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_init_subwindows (t_gui_window *window)
|
||||
{
|
||||
window->textview_chat = NULL;
|
||||
window->textbuffer_chat = NULL;
|
||||
window->texttag_chat = NULL;
|
||||
window->textview_nicklist = NULL;
|
||||
window->textbuffer_nicklist = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_auto_resize: auto-resize all windows, according to % of global size
|
||||
* This function is called after a terminal resize.
|
||||
* Returns 0 if ok, -1 if all window should be merged
|
||||
* (not enough space according to windows %)
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_auto_resize (t_gui_window_tree *tree,
|
||||
int x, int y, int width, int height,
|
||||
int simulate)
|
||||
{
|
||||
int size1, size2;
|
||||
|
||||
if (tree)
|
||||
{
|
||||
if (tree->window)
|
||||
{
|
||||
if ((width < WINDOW_MIN_WIDTH) || (height < WINDOW_MIN_HEIGHT))
|
||||
return -1;
|
||||
if (!simulate)
|
||||
{
|
||||
tree->window->win_x = x;
|
||||
tree->window->win_y = y;
|
||||
tree->window->win_width = width;
|
||||
tree->window->win_height = height;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tree->split_horiz)
|
||||
{
|
||||
size1 = (height * tree->split_pct) / 100;
|
||||
size2 = height - size1;
|
||||
if (gui_window_auto_resize (tree->child1, x, y + size1,
|
||||
width, size2, simulate) < 0)
|
||||
return -1;
|
||||
if (gui_window_auto_resize (tree->child2, x, y,
|
||||
width, size1, simulate) < 0)
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
size1 = (width * tree->split_pct) / 100;
|
||||
size2 = width - size1 - 1;
|
||||
if (gui_window_auto_resize (tree->child1, x, y,
|
||||
size1, height, simulate) < 0)
|
||||
return -1;
|
||||
if (gui_window_auto_resize (tree->child2, x + size1 + 1, y,
|
||||
size2, height, simulate) < 0)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_refresh_windows: auto resize and refresh all windows
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_refresh_windows ()
|
||||
{
|
||||
/*t_gui_window *ptr_win, *old_current_window;*/
|
||||
|
||||
if (gui_ok)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_split_horiz: split a window horizontally
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_split_horiz (t_gui_window *window, int pourcentage)
|
||||
{
|
||||
t_gui_window *new_window;
|
||||
int height1, height2;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
height1 = (window->win_height * pourcentage) / 100;
|
||||
height2 = window->win_height - height1;
|
||||
|
||||
if ((height1 >= WINDOW_MIN_HEIGHT) && (height2 >= WINDOW_MIN_HEIGHT)
|
||||
&& (pourcentage > 0) && (pourcentage <= 100))
|
||||
{
|
||||
if ((new_window = gui_window_new (window,
|
||||
window->win_x, window->win_y,
|
||||
window->win_width, height1,
|
||||
100, pourcentage)))
|
||||
{
|
||||
/* reduce old window height (bottom window) */
|
||||
window->win_y = new_window->win_y + new_window->win_height;
|
||||
window->win_height = height2;
|
||||
window->win_height_pct = 100 - pourcentage;
|
||||
|
||||
/* assign same buffer for new window (top window) */
|
||||
new_window->buffer = window->buffer;
|
||||
new_window->buffer->num_displayed++;
|
||||
|
||||
gui_window_switch_to_buffer (window, window->buffer);
|
||||
|
||||
gui_current_window = new_window;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_split_vertic: split a window vertically
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_split_vertic (t_gui_window *window, int pourcentage)
|
||||
{
|
||||
t_gui_window *new_window;
|
||||
int width1, width2;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
width1 = (window->win_width * pourcentage) / 100;
|
||||
width2 = window->win_width - width1 - 1;
|
||||
|
||||
if ((width1 >= WINDOW_MIN_WIDTH) && (width2 >= WINDOW_MIN_WIDTH)
|
||||
&& (pourcentage > 0) && (pourcentage <= 100))
|
||||
{
|
||||
if ((new_window = gui_window_new (window,
|
||||
window->win_x + width1 + 1, window->win_y,
|
||||
width2, window->win_height,
|
||||
pourcentage, 100)))
|
||||
{
|
||||
/* reduce old window height (left window) */
|
||||
window->win_width = width1;
|
||||
window->win_width_pct = 100 - pourcentage;
|
||||
|
||||
/* assign same buffer for new window (right window) */
|
||||
new_window->buffer = window->buffer;
|
||||
new_window->buffer->num_displayed++;
|
||||
|
||||
gui_window_switch_to_buffer (window, window->buffer);
|
||||
|
||||
gui_current_window = new_window;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
|
||||
/* create & draw separator */
|
||||
gui_window_draw_separator (gui_current_window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_resize: resize window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_resize (t_gui_window *window, int pourcentage)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
(void) pourcentage;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_merge: merge window with its sister
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_merge (t_gui_window *window)
|
||||
{
|
||||
t_gui_window_tree *parent, *sister;
|
||||
|
||||
parent = window->ptr_tree->parent_node;
|
||||
if (parent)
|
||||
{
|
||||
sister = (parent->child1->window == window) ?
|
||||
parent->child2 : parent->child1;
|
||||
|
||||
if (!(sister->window))
|
||||
return 0;
|
||||
|
||||
if (window->win_y == sister->window->win_y)
|
||||
{
|
||||
/* horizontal merge */
|
||||
window->win_width += sister->window->win_width + 1;
|
||||
window->win_width_pct += sister->window->win_width_pct;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* vertical merge */
|
||||
window->win_height += sister->window->win_height;
|
||||
window->win_height_pct += sister->window->win_height_pct;
|
||||
}
|
||||
if (sister->window->win_x < window->win_x)
|
||||
window->win_x = sister->window->win_x;
|
||||
if (sister->window->win_y < window->win_y)
|
||||
window->win_y = sister->window->win_y;
|
||||
|
||||
gui_window_free (sister->window);
|
||||
gui_window_tree_node_to_leaf (parent, window);
|
||||
|
||||
gui_window_switch_to_buffer (window, window->buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_merge_all: merge all windows into only one
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_merge_all (t_gui_window *window)
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
(void) window;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_side_by_side: return a code about position of 2 windows:
|
||||
* 0 = they're not side by side
|
||||
* 1 = side by side (win2 is over the win1)
|
||||
* 2 = side by side (win2 on the right)
|
||||
* 3 = side by side (win2 below win1)
|
||||
* 4 = side by side (win2 on the left)
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_side_by_side (t_gui_window *win1, t_gui_window *win2)
|
||||
{
|
||||
/* win2 over win1 ? */
|
||||
if (win2->win_y + win2->win_height == win1->win_y)
|
||||
{
|
||||
if (win2->win_x >= win1->win_x + win1->win_width)
|
||||
return 0;
|
||||
if (win2->win_x + win2->win_width <= win1->win_x)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* win2 on the right ? */
|
||||
if (win2->win_x == win1->win_x + win1->win_width + 1)
|
||||
{
|
||||
if (win2->win_y >= win1->win_y + win1->win_height)
|
||||
return 0;
|
||||
if (win2->win_y + win2->win_height <= win1->win_y)
|
||||
return 0;
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* win2 below win1 ? */
|
||||
if (win2->win_y == win1->win_y + win1->win_height)
|
||||
{
|
||||
if (win2->win_x >= win1->win_x + win1->win_width)
|
||||
return 0;
|
||||
if (win2->win_x + win2->win_width <= win1->win_x)
|
||||
return 0;
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* win2 on the left ? */
|
||||
if (win2->win_x + win2->win_width + 1 == win1->win_x)
|
||||
{
|
||||
if (win2->win_y >= win1->win_y + win1->win_height)
|
||||
return 0;
|
||||
if (win2->win_y + win2->win_height <= win1->win_y)
|
||||
return 0;
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_switch_up: search and switch to a window over current window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_switch_up (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if ((ptr_win != window) &&
|
||||
(gui_window_side_by_side (window, ptr_win) == 1))
|
||||
{
|
||||
gui_current_window = ptr_win;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_switch_down: search and switch to a window below current window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_switch_down (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if ((ptr_win != window) &&
|
||||
(gui_window_side_by_side (window, ptr_win) == 3))
|
||||
{
|
||||
gui_current_window = ptr_win;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_switch_left: search and switch to a window on the left of current window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_switch_left (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if ((ptr_win != window) &&
|
||||
(gui_window_side_by_side (window, ptr_win) == 4))
|
||||
{
|
||||
gui_current_window = ptr_win;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_switch_right: search and switch to a window on the right of current window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_switch_right (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if ((ptr_win != window) &&
|
||||
(gui_window_side_by_side (window, ptr_win) == 2))
|
||||
{
|
||||
gui_current_window = ptr_win;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_refresh_screen: called when term size is modified
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_refresh_screen ()
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_set_title: set terminal title
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_set_title ()
|
||||
{
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_reset_title: reset terminal title
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_reset_title ()
|
||||
{
|
||||
/* This function does nothing in Gtk GUI */
|
||||
}
|
||||
+49
-49
@@ -76,7 +76,7 @@ gui_action_clipboard_paste (t_gui_window *window)
|
||||
{
|
||||
gui_insert_string_input (window, gui_input_clipboard, -1);
|
||||
window->buffer->input_buffer_pos += utf8_strlen (gui_input_clipboard);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ gui_action_return (t_gui_window *window)
|
||||
window->buffer->completion.position = -1;
|
||||
window->buffer->ptr_history = NULL;
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
user_command (SERVER(window->buffer), CHANNEL(window->buffer),
|
||||
command, 0);
|
||||
free (command);
|
||||
@@ -231,7 +231,7 @@ gui_action_tab (t_gui_window *window)
|
||||
window->buffer->input_buffer_pos++;
|
||||
}
|
||||
}
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,7 +262,7 @@ gui_action_backspace (t_gui_window *window)
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ gui_action_delete (t_gui_window *window)
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ gui_action_delete_previous_word (t_gui_window *window)
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_pos -= length_deleted;
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
}
|
||||
@@ -394,7 +394,7 @@ gui_action_delete_next_word (t_gui_window *window)
|
||||
window->buffer->input_buffer[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
}
|
||||
@@ -429,7 +429,7 @@ gui_action_delete_begin_of_line (t_gui_window *window)
|
||||
window->buffer->input_buffer_color_mask[window->buffer->input_buffer_size] = '\0';
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
}
|
||||
@@ -458,7 +458,7 @@ gui_action_delete_end_of_line (t_gui_window *window)
|
||||
window->buffer->input_buffer_size = strlen (window->buffer->input_buffer);
|
||||
window->buffer->input_buffer_length = utf8_strlen (window->buffer->input_buffer);
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
}
|
||||
@@ -478,7 +478,7 @@ gui_action_delete_line (t_gui_window *window)
|
||||
window->buffer->input_buffer_length = 0;
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
gui_input_optimize_size (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
}
|
||||
@@ -522,7 +522,7 @@ gui_action_transpose_chars (t_gui_window *window)
|
||||
|
||||
window->buffer->input_buffer_pos++;
|
||||
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
window->buffer->completion.position = -1;
|
||||
}
|
||||
}
|
||||
@@ -540,7 +540,7 @@ gui_action_home (t_gui_window *window)
|
||||
if (window->buffer->input_buffer_pos > 0)
|
||||
{
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -559,7 +559,7 @@ gui_action_end (t_gui_window *window)
|
||||
{
|
||||
window->buffer->input_buffer_pos =
|
||||
window->buffer->input_buffer_length;
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -576,7 +576,7 @@ gui_action_left (t_gui_window *window)
|
||||
if (window->buffer->input_buffer_pos > 0)
|
||||
{
|
||||
window->buffer->input_buffer_pos--;
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -616,7 +616,7 @@ gui_action_previous_word (t_gui_window *window)
|
||||
else
|
||||
window->buffer->input_buffer_pos = 0;
|
||||
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -634,7 +634,7 @@ gui_action_right (t_gui_window *window)
|
||||
window->buffer->input_buffer_length)
|
||||
{
|
||||
window->buffer->input_buffer_pos++;
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -678,7 +678,7 @@ gui_action_next_word (t_gui_window *window)
|
||||
utf8_pos (window->buffer->input_buffer,
|
||||
utf8_prev_char (window->buffer->input_buffer, pos) - window->buffer->input_buffer);
|
||||
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -703,8 +703,8 @@ gui_action_up (t_gui_window *window)
|
||||
((t_irc_dcc *)(window->dcc_first))->prev_dcc;
|
||||
window->dcc_selected =
|
||||
((t_irc_dcc *)(window->dcc_selected))->prev_dcc;
|
||||
gui_draw_buffer_chat (window->buffer, 1);
|
||||
gui_draw_buffer_input (window->buffer, 1);
|
||||
gui_chat_draw (window->buffer, 1);
|
||||
gui_input_draw (window->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -756,7 +756,7 @@ gui_action_up (t_gui_window *window)
|
||||
strcpy (window->buffer->input_buffer,
|
||||
window->buffer->ptr_history->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -791,7 +791,7 @@ gui_action_up_global (t_gui_window *window)
|
||||
strcpy (window->buffer->input_buffer,
|
||||
history_global_ptr->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,8 +827,8 @@ gui_action_down (t_gui_window *window)
|
||||
else
|
||||
window->dcc_selected =
|
||||
dcc_list->next_dcc;
|
||||
gui_draw_buffer_chat (window->buffer, 1);
|
||||
gui_draw_buffer_input (window->buffer, 1);
|
||||
gui_chat_draw (window->buffer, 1);
|
||||
gui_input_draw (window->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -860,7 +860,7 @@ gui_action_down (t_gui_window *window)
|
||||
window->buffer->ptr_history->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
}
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -899,7 +899,7 @@ gui_action_down_global (t_gui_window *window)
|
||||
history_global_ptr->text);
|
||||
gui_input_init_color_mask (window->buffer);
|
||||
}
|
||||
gui_draw_buffer_input (window->buffer, 0);
|
||||
gui_input_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1015,15 +1015,15 @@ gui_action_jump_smart (t_gui_window *window)
|
||||
{
|
||||
if (!hotlist_initial_buffer)
|
||||
hotlist_initial_buffer = window->buffer;
|
||||
gui_switch_to_buffer (window, hotlist->buffer);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
gui_window_switch_to_buffer (window, hotlist->buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hotlist_initial_buffer)
|
||||
{
|
||||
gui_switch_to_buffer (window, hotlist_initial_buffer);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
gui_window_switch_to_buffer (window, hotlist_initial_buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
hotlist_initial_buffer = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1040,9 +1040,9 @@ gui_action_jump_dcc (t_gui_window *window)
|
||||
{
|
||||
if (gui_buffer_before_dcc)
|
||||
{
|
||||
gui_switch_to_buffer (window,
|
||||
gui_buffer_before_dcc);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
gui_window_switch_to_buffer (window,
|
||||
gui_buffer_before_dcc);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1063,9 +1063,9 @@ gui_action_jump_raw_data (t_gui_window *window)
|
||||
{
|
||||
if (gui_buffer_before_raw_data)
|
||||
{
|
||||
gui_switch_to_buffer (window,
|
||||
gui_buffer_before_raw_data);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
gui_window_switch_to_buffer (window,
|
||||
gui_buffer_before_raw_data);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1098,9 +1098,9 @@ gui_action_jump_server (t_gui_window *window)
|
||||
if (SERVER(window->buffer)->buffer !=
|
||||
window->buffer)
|
||||
{
|
||||
gui_switch_to_buffer (window,
|
||||
SERVER(window->buffer)->buffer);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
gui_window_switch_to_buffer (window,
|
||||
SERVER(window->buffer)->buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1141,8 +1141,8 @@ gui_action_jump_next_server (t_gui_window *window)
|
||||
if ((ptr_server->buffer == ptr_buffer)
|
||||
&& (ptr_buffer->all_servers))
|
||||
ptr_buffer->server = ptr_server;
|
||||
gui_switch_to_buffer (window, ptr_buffer);
|
||||
gui_redraw_buffer (window->buffer);
|
||||
gui_window_switch_to_buffer (window, ptr_buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1181,8 +1181,8 @@ gui_action_scroll_previous_highlight (t_gui_window *window)
|
||||
window->start_line_pos = 0;
|
||||
window->first_line_displayed =
|
||||
(window->start_line == window->buffer->lines);
|
||||
gui_draw_buffer_chat (window->buffer, 1);
|
||||
gui_draw_buffer_status (window->buffer, 0);
|
||||
gui_chat_draw (window->buffer, 1);
|
||||
gui_status_draw (window->buffer, 0);
|
||||
return;
|
||||
}
|
||||
ptr_line = ptr_line->prev_line;
|
||||
@@ -1214,8 +1214,8 @@ gui_action_scroll_next_highlight (t_gui_window *window)
|
||||
window->start_line_pos = 0;
|
||||
window->first_line_displayed =
|
||||
(window->start_line == window->buffer->lines);
|
||||
gui_draw_buffer_chat (window->buffer, 1);
|
||||
gui_draw_buffer_status (window->buffer, 0);
|
||||
gui_chat_draw (window->buffer, 1);
|
||||
gui_status_draw (window->buffer, 0);
|
||||
return;
|
||||
}
|
||||
ptr_line = ptr_line->next_line;
|
||||
@@ -1241,8 +1241,8 @@ gui_action_scroll_unread (t_gui_window *window)
|
||||
window->start_line_pos = 0;
|
||||
window->first_line_displayed =
|
||||
(window->start_line == window->buffer->lines);
|
||||
gui_draw_buffer_chat (window->buffer, 1);
|
||||
gui_draw_buffer_status (window->buffer, 0);
|
||||
gui_chat_draw (window->buffer, 1);
|
||||
gui_status_draw (window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1256,7 +1256,7 @@ gui_action_hotlist_clear (t_gui_window *window)
|
||||
if (hotlist)
|
||||
{
|
||||
hotlist_free_all ();
|
||||
gui_redraw_buffer (window->buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
hotlist_initial_buffer = window->buffer;
|
||||
}
|
||||
@@ -1269,7 +1269,7 @@ void
|
||||
gui_action_infobar_clear (t_gui_window *window)
|
||||
{
|
||||
gui_infobar_remove ();
|
||||
gui_draw_buffer_infobar (window->buffer, 1);
|
||||
gui_infobar_draw (window->buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1282,7 +1282,7 @@ gui_action_refresh_screen (t_gui_window *window)
|
||||
/* make gcc happy */
|
||||
(void) window;
|
||||
|
||||
gui_refresh_screen ();
|
||||
gui_window_refresh_screen ();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,932 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-window.c: window 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 "../irc/irc.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_buffer_servers_search: search servers buffer
|
||||
* (when same buffer is used for all servers)
|
||||
*/
|
||||
|
||||
t_gui_buffer *
|
||||
gui_buffer_servers_search ()
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->all_servers)
|
||||
return ptr_buffer;
|
||||
}
|
||||
|
||||
/* buffer not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_new: create a new buffer in current window
|
||||
*/
|
||||
|
||||
t_gui_buffer *
|
||||
gui_buffer_new (t_gui_window *window, void *server, void *channel, int type,
|
||||
int switch_to_buffer)
|
||||
{
|
||||
t_gui_buffer *new_buffer, *ptr_buffer;
|
||||
|
||||
#ifdef DEBUG
|
||||
weechat_log_printf ("Creating new buffer\n");
|
||||
#endif
|
||||
|
||||
/* use first buffer if no server was assigned to this buffer */
|
||||
if ((type == BUFFER_TYPE_STANDARD) && gui_buffers && (!SERVER(gui_buffers)))
|
||||
{
|
||||
if (server)
|
||||
((t_irc_server *)(server))->buffer = gui_buffers;
|
||||
if (channel)
|
||||
((t_irc_channel *)(channel))->buffer = gui_buffers;
|
||||
gui_buffers->server = server;
|
||||
gui_buffers->channel = channel;
|
||||
if (cfg_look_one_server_buffer && server && !channel)
|
||||
gui_buffers->all_servers = 1;
|
||||
if (cfg_log_auto_server)
|
||||
log_start (gui_buffers);
|
||||
return gui_buffers;
|
||||
}
|
||||
|
||||
if (cfg_look_one_server_buffer && (type == BUFFER_TYPE_STANDARD) &&
|
||||
gui_buffers && server && !channel)
|
||||
{
|
||||
ptr_buffer = gui_buffer_servers_search ();
|
||||
if (ptr_buffer)
|
||||
{
|
||||
((t_irc_server *)(server))->buffer = gui_buffers;
|
||||
gui_buffers->server = server;
|
||||
if (switch_to_buffer)
|
||||
gui_window_switch_to_buffer (window, gui_buffers);
|
||||
gui_window_redraw_buffer (gui_buffers);
|
||||
return gui_buffers;
|
||||
}
|
||||
}
|
||||
|
||||
if ((new_buffer = (t_gui_buffer *)(malloc (sizeof (t_gui_buffer)))))
|
||||
{
|
||||
new_buffer->num_displayed = 0;
|
||||
new_buffer->number = (last_gui_buffer) ? last_gui_buffer->number + 1 : 1;
|
||||
|
||||
/* assign server and channel to buffer */
|
||||
new_buffer->server = server;
|
||||
new_buffer->all_servers = 0;
|
||||
new_buffer->channel = channel;
|
||||
new_buffer->type = type;
|
||||
if (new_buffer->type == BUFFER_TYPE_RAW_DATA)
|
||||
gui_buffer_raw_data = new_buffer;
|
||||
/* assign buffer to server and channel */
|
||||
if (server && !channel)
|
||||
{
|
||||
SERVER(new_buffer)->buffer = new_buffer;
|
||||
new_buffer->all_servers = (cfg_look_one_server_buffer) ? 1 : 0;
|
||||
}
|
||||
if (!gui_buffers && cfg_look_one_server_buffer)
|
||||
new_buffer->all_servers = 1;
|
||||
if (channel)
|
||||
CHANNEL(new_buffer)->buffer = new_buffer;
|
||||
|
||||
if (!window->buffer)
|
||||
{
|
||||
window->buffer = new_buffer;
|
||||
window->first_line_displayed = 1;
|
||||
window->start_line = NULL;
|
||||
window->start_line_pos = 0;
|
||||
gui_window_calculate_pos_size (window, 1);
|
||||
gui_window_init_subwindows (window);
|
||||
}
|
||||
|
||||
/* init lines */
|
||||
new_buffer->lines = NULL;
|
||||
new_buffer->last_line = NULL;
|
||||
new_buffer->last_read_line = NULL;
|
||||
new_buffer->num_lines = 0;
|
||||
new_buffer->line_complete = 1;
|
||||
|
||||
/* notify level */
|
||||
new_buffer->notify_level = channel_get_notify_level (server, channel);
|
||||
|
||||
/* create/append to log file */
|
||||
new_buffer->log_filename = NULL;
|
||||
new_buffer->log_file = NULL;
|
||||
if ((cfg_log_auto_server && BUFFER_IS_SERVER(new_buffer))
|
||||
|| (cfg_log_auto_channel && BUFFER_IS_CHANNEL(new_buffer))
|
||||
|| (cfg_log_auto_private && BUFFER_IS_PRIVATE(new_buffer)))
|
||||
log_start (new_buffer);
|
||||
|
||||
/* init input buffer */
|
||||
new_buffer->has_input = (new_buffer->type == BUFFER_TYPE_STANDARD) ? 1 : 0;
|
||||
if (new_buffer->has_input)
|
||||
{
|
||||
new_buffer->input_buffer_alloc = INPUT_BUFFER_BLOCK_SIZE;
|
||||
new_buffer->input_buffer = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
|
||||
new_buffer->input_buffer_color_mask = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
|
||||
new_buffer->input_buffer[0] = '\0';
|
||||
new_buffer->input_buffer_color_mask[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
new_buffer->input_buffer = NULL;
|
||||
new_buffer->input_buffer_color_mask = NULL;
|
||||
}
|
||||
new_buffer->input_buffer_size = 0;
|
||||
new_buffer->input_buffer_length = 0;
|
||||
new_buffer->input_buffer_pos = 0;
|
||||
new_buffer->input_buffer_1st_display = 0;
|
||||
|
||||
/* init completion */
|
||||
completion_init (&(new_buffer->completion), server, channel);
|
||||
|
||||
/* init history */
|
||||
new_buffer->history = NULL;
|
||||
new_buffer->last_history = NULL;
|
||||
new_buffer->ptr_history = NULL;
|
||||
new_buffer->num_history = 0;
|
||||
|
||||
/* add buffer to buffers queue */
|
||||
new_buffer->prev_buffer = last_gui_buffer;
|
||||
if (gui_buffers)
|
||||
last_gui_buffer->next_buffer = new_buffer;
|
||||
else
|
||||
gui_buffers = new_buffer;
|
||||
last_gui_buffer = new_buffer;
|
||||
new_buffer->next_buffer = NULL;
|
||||
|
||||
/* move buffer next to server */
|
||||
if (server && cfg_look_open_near_server && (!cfg_look_one_server_buffer))
|
||||
{
|
||||
ptr_buffer = SERVER(new_buffer)->buffer;
|
||||
while (ptr_buffer && (ptr_buffer->server == server))
|
||||
{
|
||||
ptr_buffer = ptr_buffer->next_buffer;
|
||||
}
|
||||
if (ptr_buffer)
|
||||
gui_buffer_move_to_number (new_buffer, ptr_buffer->number);
|
||||
}
|
||||
|
||||
/* switch to new buffer */
|
||||
if (switch_to_buffer)
|
||||
gui_window_switch_to_buffer (window, new_buffer);
|
||||
|
||||
/* redraw buffer */
|
||||
gui_window_redraw_buffer (new_buffer);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return new_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_search: search a buffer by server and channel name
|
||||
*/
|
||||
|
||||
t_gui_buffer *
|
||||
gui_buffer_search (char *server, char *channel)
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
t_irc_channel *ptr_channel;
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
ptr_server = NULL;
|
||||
ptr_channel = NULL;
|
||||
ptr_buffer = NULL;
|
||||
|
||||
/* nothing given => print on current buffer */
|
||||
if ((!server || !server[0]) && (!channel || !channel[0]))
|
||||
ptr_buffer = gui_current_window->buffer;
|
||||
else
|
||||
{
|
||||
if (server && server[0])
|
||||
{
|
||||
ptr_server = server_search (server);
|
||||
if (!ptr_server)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_server = SERVER(gui_current_window->buffer);
|
||||
if (!ptr_server)
|
||||
ptr_server = SERVER(gui_buffers);
|
||||
}
|
||||
|
||||
if (channel && channel[0])
|
||||
{
|
||||
if (ptr_server)
|
||||
{
|
||||
ptr_channel = channel_search_any (ptr_server, channel);
|
||||
if (ptr_channel)
|
||||
ptr_buffer = ptr_channel->buffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ptr_server)
|
||||
ptr_buffer = ptr_server->buffer;
|
||||
else
|
||||
ptr_buffer = gui_current_window->buffer;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ptr_buffer)
|
||||
return NULL;
|
||||
|
||||
return (ptr_buffer->type != BUFFER_TYPE_STANDARD) ?
|
||||
gui_buffers : ptr_buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_find_window: find a window displaying buffer
|
||||
*/
|
||||
|
||||
t_gui_window *
|
||||
gui_buffer_find_window (t_gui_buffer *buffer)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
if (gui_current_window->buffer == buffer)
|
||||
return gui_current_window;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->buffer == buffer)
|
||||
return ptr_win;
|
||||
}
|
||||
|
||||
/* no window found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_get_dcc: get pointer to DCC buffer (DCC buffer created if not existing)
|
||||
*/
|
||||
|
||||
t_gui_buffer *
|
||||
gui_buffer_get_dcc (t_gui_window *window)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* check if dcc buffer exists */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->type == BUFFER_TYPE_DCC)
|
||||
break;
|
||||
}
|
||||
if (ptr_buffer)
|
||||
return ptr_buffer;
|
||||
else
|
||||
return gui_buffer_new (window, NULL, NULL, BUFFER_TYPE_DCC, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_clear: clear buffer content
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_clear (t_gui_buffer *buffer)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
t_gui_line *ptr_line;
|
||||
|
||||
/* remove buffer from hotlist */
|
||||
hotlist_remove_buffer (buffer);
|
||||
|
||||
/* remove lines from buffer */
|
||||
while (buffer->lines)
|
||||
{
|
||||
ptr_line = buffer->lines->next_line;
|
||||
if (buffer->lines->data)
|
||||
free (buffer->lines->data);
|
||||
free (buffer->lines);
|
||||
buffer->lines = ptr_line;
|
||||
}
|
||||
|
||||
buffer->lines = NULL;
|
||||
buffer->last_line = NULL;
|
||||
buffer->num_lines = 0;
|
||||
buffer->line_complete = 1;
|
||||
|
||||
/* remove any scroll for buffer */
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->buffer == buffer)
|
||||
{
|
||||
ptr_win->first_line_displayed = 1;
|
||||
ptr_win->start_line = NULL;
|
||||
ptr_win->start_line_pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
gui_chat_draw (buffer, 1);
|
||||
gui_status_draw (buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_clear_all: clear all buffers content
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_clear_all ()
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
gui_buffer_clear (ptr_buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_line_free: delete a line from a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_line_free (t_gui_line *line)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->start_line == line)
|
||||
{
|
||||
ptr_win->start_line = ptr_win->start_line->next_line;
|
||||
ptr_win->start_line_pos = 0;
|
||||
gui_chat_draw (ptr_win->buffer, 0);
|
||||
gui_status_draw (ptr_win->buffer, 0);
|
||||
}
|
||||
}
|
||||
if (line->nick)
|
||||
free (line->nick);
|
||||
if (line->data)
|
||||
free (line->data);
|
||||
free (line);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_free: delete a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
t_gui_buffer *ptr_buffer;
|
||||
t_gui_line *ptr_line;
|
||||
t_irc_server *ptr_server;
|
||||
int create_new;
|
||||
|
||||
create_new = (buffer->server || buffer->channel);
|
||||
|
||||
hotlist_remove_buffer (buffer);
|
||||
if (hotlist_initial_buffer == buffer)
|
||||
hotlist_initial_buffer = NULL;
|
||||
|
||||
if (gui_buffer_before_dcc == buffer)
|
||||
gui_buffer_before_dcc = NULL;
|
||||
|
||||
if (gui_buffer_before_raw_data == buffer)
|
||||
gui_buffer_before_raw_data = NULL;
|
||||
|
||||
if (buffer->type == BUFFER_TYPE_RAW_DATA)
|
||||
gui_buffer_raw_data = NULL;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (ptr_server->saved_buffer == buffer)
|
||||
ptr_server->saved_buffer = NULL;
|
||||
}
|
||||
|
||||
if (switch_to_another)
|
||||
{
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if ((buffer == ptr_win->buffer) &&
|
||||
((buffer->next_buffer) || (buffer->prev_buffer)))
|
||||
gui_buffer_switch_previous (ptr_win);
|
||||
}
|
||||
}
|
||||
|
||||
/* decrease buffer number for all next buffers */
|
||||
for (ptr_buffer = buffer->next_buffer; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
ptr_buffer->number--;
|
||||
}
|
||||
|
||||
/* free lines and messages */
|
||||
while (buffer->lines)
|
||||
{
|
||||
ptr_line = buffer->lines->next_line;
|
||||
gui_buffer_line_free (buffer->lines);
|
||||
buffer->lines = ptr_line;
|
||||
}
|
||||
|
||||
/* close log if opened */
|
||||
if (buffer->log_file)
|
||||
log_end (buffer);
|
||||
|
||||
if (buffer->input_buffer)
|
||||
free (buffer->input_buffer);
|
||||
if (buffer->input_buffer_color_mask)
|
||||
free (buffer->input_buffer_color_mask);
|
||||
|
||||
completion_free (&(buffer->completion));
|
||||
|
||||
history_buffer_free (buffer);
|
||||
|
||||
/* remove buffer from buffers list */
|
||||
if (buffer->prev_buffer)
|
||||
buffer->prev_buffer->next_buffer = buffer->next_buffer;
|
||||
if (buffer->next_buffer)
|
||||
buffer->next_buffer->prev_buffer = buffer->prev_buffer;
|
||||
if (gui_buffers == buffer)
|
||||
gui_buffers = buffer->next_buffer;
|
||||
if (last_gui_buffer == buffer)
|
||||
last_gui_buffer = buffer->prev_buffer;
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->buffer == buffer)
|
||||
ptr_win->buffer = NULL;
|
||||
}
|
||||
|
||||
free (buffer);
|
||||
|
||||
/* always at least one buffer */
|
||||
if (!gui_buffers && create_new && switch_to_another)
|
||||
(void) gui_buffer_new (gui_windows, NULL, NULL,
|
||||
BUFFER_TYPE_STANDARD, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_line_new: create new line for a buffer
|
||||
*/
|
||||
|
||||
t_gui_line *
|
||||
gui_buffer_line_new (t_gui_buffer *buffer)
|
||||
{
|
||||
t_gui_line *new_line, *ptr_line;
|
||||
|
||||
if ((new_line = (t_gui_line *) malloc (sizeof (struct t_gui_line))))
|
||||
{
|
||||
new_line->length = 0;
|
||||
new_line->length_align = 0;
|
||||
new_line->log_write = 1;
|
||||
new_line->line_with_message = 0;
|
||||
new_line->line_with_highlight = 0;
|
||||
new_line->nick = NULL;
|
||||
new_line->data = NULL;
|
||||
new_line->ofs_after_date = -1;
|
||||
new_line->ofs_start_message = -1;
|
||||
if (!buffer->lines)
|
||||
buffer->lines = new_line;
|
||||
else
|
||||
buffer->last_line->next_line = new_line;
|
||||
new_line->prev_line = buffer->last_line;
|
||||
new_line->next_line = NULL;
|
||||
buffer->last_line = new_line;
|
||||
buffer->num_lines++;
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_log_printf (_("Not enough memory for new line\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* remove one line if necessary */
|
||||
if ((cfg_history_max_lines > 0)
|
||||
&& (buffer->num_lines > cfg_history_max_lines))
|
||||
{
|
||||
if (buffer->last_line == buffer->lines)
|
||||
buffer->last_line = NULL;
|
||||
ptr_line = buffer->lines->next_line;
|
||||
gui_buffer_line_free (buffer->lines);
|
||||
buffer->lines = ptr_line;
|
||||
ptr_line->prev_line = NULL;
|
||||
buffer->num_lines--;
|
||||
gui_chat_draw (buffer, 1);
|
||||
}
|
||||
|
||||
return new_line;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_merge_servers: merge server buffers in one buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_merge_servers (t_gui_window *window)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer_server, *ptr_buffer;
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
/* new server buffer is the first server buffer found */
|
||||
for (ptr_buffer_server = gui_buffers; ptr_buffer_server;
|
||||
ptr_buffer_server = ptr_buffer_server->next_buffer)
|
||||
{
|
||||
if (BUFFER_IS_SERVER(ptr_buffer_server))
|
||||
break;
|
||||
}
|
||||
|
||||
/* no server buffer found */
|
||||
if (!ptr_buffer_server)
|
||||
return;
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if ((ptr_buffer != ptr_buffer_server)
|
||||
&& (BUFFER_IS_SERVER(ptr_buffer)))
|
||||
{
|
||||
ptr_server = SERVER(ptr_buffer);
|
||||
|
||||
/* add (by pointer artefact) lines from buffer found to server buffer */
|
||||
if (ptr_buffer->lines)
|
||||
{
|
||||
if (ptr_buffer_server->lines)
|
||||
{
|
||||
ptr_buffer->lines->prev_line =
|
||||
ptr_buffer_server->last_line;
|
||||
ptr_buffer_server->last_line->next_line =
|
||||
ptr_buffer->lines;
|
||||
ptr_buffer_server->last_line =
|
||||
ptr_buffer->last_line;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_buffer_server->lines = ptr_buffer->lines;
|
||||
ptr_buffer_server->last_line = ptr_buffer->last_line;
|
||||
}
|
||||
}
|
||||
|
||||
/* free buffer but not lines, because they're now used by
|
||||
our unique server buffer */
|
||||
ptr_buffer->lines = NULL;
|
||||
gui_buffer_free (ptr_buffer, 1);
|
||||
|
||||
/* asociate server with new server buffer */
|
||||
ptr_server->buffer = ptr_buffer_server;
|
||||
}
|
||||
}
|
||||
|
||||
ptr_buffer_server->all_servers = 1;
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_split_server: split the server buffer into many buffers (one by server)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_split_server (t_gui_window *window)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
ptr_buffer = gui_buffer_servers_search ();
|
||||
|
||||
if (ptr_buffer)
|
||||
{
|
||||
if (SERVER(ptr_buffer))
|
||||
{
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (ptr_server->buffer
|
||||
&& (ptr_server != SERVER(ptr_buffer))
|
||||
&& (ptr_server->buffer == ptr_buffer))
|
||||
{
|
||||
ptr_server->buffer = NULL;
|
||||
gui_buffer_new (window, ptr_server, NULL,
|
||||
BUFFER_TYPE_STANDARD, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
ptr_buffer->all_servers = 0;
|
||||
gui_status_draw (window->buffer, 1);
|
||||
gui_input_draw (window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_switch_previous: switch to previous buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_switch_previous (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
/* if only one buffer then return */
|
||||
if (gui_buffers == last_gui_buffer)
|
||||
return;
|
||||
|
||||
if (window->buffer->prev_buffer)
|
||||
gui_window_switch_to_buffer (window, window->buffer->prev_buffer);
|
||||
else
|
||||
gui_window_switch_to_buffer (window, last_gui_buffer);
|
||||
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_switch_next: switch to next buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_switch_next (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
/* if only one buffer then return */
|
||||
if (gui_buffers == last_gui_buffer)
|
||||
return;
|
||||
|
||||
if (window->buffer->next_buffer)
|
||||
gui_window_switch_to_buffer (window, window->buffer->next_buffer);
|
||||
else
|
||||
gui_window_switch_to_buffer (window, gui_buffers);
|
||||
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_switch_dcc: switch to dcc buffer (create it if it does not exist)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_switch_dcc (t_gui_window *window)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* check if dcc buffer exists */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->type == BUFFER_TYPE_DCC)
|
||||
break;
|
||||
}
|
||||
if (ptr_buffer)
|
||||
{
|
||||
gui_window_switch_to_buffer (window, ptr_buffer);
|
||||
gui_window_redraw_buffer (ptr_buffer);
|
||||
}
|
||||
else
|
||||
gui_buffer_new (window, NULL, NULL, BUFFER_TYPE_DCC, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_switch_raw_data: switch to rax IRC data buffer (create it if it does not exist)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_switch_raw_data (t_gui_window *window)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* check if raw IRC data buffer exists */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->type == BUFFER_TYPE_RAW_DATA)
|
||||
break;
|
||||
}
|
||||
if (ptr_buffer)
|
||||
{
|
||||
gui_window_switch_to_buffer (window, ptr_buffer);
|
||||
gui_window_redraw_buffer (ptr_buffer);
|
||||
}
|
||||
else
|
||||
gui_buffer_new (window, NULL, NULL, BUFFER_TYPE_RAW_DATA, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_switch_by_number: switch to another buffer with number
|
||||
*/
|
||||
|
||||
t_gui_buffer *
|
||||
gui_buffer_switch_by_number (t_gui_window *window, int number)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* invalid buffer */
|
||||
if (number < 0)
|
||||
return NULL;
|
||||
|
||||
/* buffer is currently displayed ? */
|
||||
if (number == window->buffer->number)
|
||||
return window->buffer;
|
||||
|
||||
/* search for buffer in the list */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if ((ptr_buffer != window->buffer) && (number == ptr_buffer->number))
|
||||
{
|
||||
gui_window_switch_to_buffer (window, ptr_buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
return ptr_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
/* buffer not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_move_to_number: move a buffer to another number
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_move_to_number (t_gui_buffer *buffer, int number)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
int i;
|
||||
|
||||
/* if only one buffer then return */
|
||||
if (gui_buffers == last_gui_buffer)
|
||||
return;
|
||||
|
||||
/* buffer number is already ok ? */
|
||||
if (number == buffer->number)
|
||||
return;
|
||||
|
||||
if (number < 1)
|
||||
number = 1;
|
||||
|
||||
/* remove buffer from list */
|
||||
if (buffer == gui_buffers)
|
||||
{
|
||||
gui_buffers = buffer->next_buffer;
|
||||
gui_buffers->prev_buffer = NULL;
|
||||
}
|
||||
if (buffer == last_gui_buffer)
|
||||
{
|
||||
last_gui_buffer = buffer->prev_buffer;
|
||||
last_gui_buffer->next_buffer = NULL;
|
||||
}
|
||||
if (buffer->prev_buffer)
|
||||
(buffer->prev_buffer)->next_buffer = buffer->next_buffer;
|
||||
if (buffer->next_buffer)
|
||||
(buffer->next_buffer)->prev_buffer = buffer->prev_buffer;
|
||||
|
||||
if (number == 1)
|
||||
{
|
||||
gui_buffers->prev_buffer = buffer;
|
||||
buffer->prev_buffer = NULL;
|
||||
buffer->next_buffer = gui_buffers;
|
||||
gui_buffers = buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* assign new number to all buffers */
|
||||
i = 1;
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
ptr_buffer->number = i++;
|
||||
}
|
||||
|
||||
/* search for new position in the list */
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->number == number)
|
||||
break;
|
||||
}
|
||||
if (ptr_buffer)
|
||||
{
|
||||
/* insert before buffer found */
|
||||
buffer->prev_buffer = ptr_buffer->prev_buffer;
|
||||
buffer->next_buffer = ptr_buffer;
|
||||
if (ptr_buffer->prev_buffer)
|
||||
(ptr_buffer->prev_buffer)->next_buffer = buffer;
|
||||
ptr_buffer->prev_buffer = buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* number not found (too big)? => add to end */
|
||||
buffer->prev_buffer = last_gui_buffer;
|
||||
buffer->next_buffer = NULL;
|
||||
last_gui_buffer->next_buffer = buffer;
|
||||
last_gui_buffer = buffer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* assign new number to all buffers */
|
||||
i = 1;
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
ptr_buffer->number = i++;
|
||||
}
|
||||
|
||||
gui_window_redraw_buffer (buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_buffer_print_log: print buffer infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_print_log (t_gui_buffer *buffer)
|
||||
{
|
||||
t_gui_line *ptr_line;
|
||||
int num;
|
||||
|
||||
weechat_log_printf ("[buffer (addr:0x%X)]\n", buffer);
|
||||
weechat_log_printf (" num_displayed. . . . . : %d\n", buffer->num_displayed);
|
||||
weechat_log_printf (" number . . . . . . . . : %d\n", buffer->number);
|
||||
weechat_log_printf (" server . . . . . . . . : 0x%X\n", buffer->server);
|
||||
weechat_log_printf (" all_servers. . . . . . : %d\n", buffer->all_servers);
|
||||
weechat_log_printf (" channel. . . . . . . . : 0x%X\n", buffer->channel);
|
||||
weechat_log_printf (" type . . . . . . . . . : %d\n", buffer->type);
|
||||
weechat_log_printf (" lines. . . . . . . . . : 0x%X\n", buffer->lines);
|
||||
weechat_log_printf (" last_line. . . . . . . : 0x%X\n", buffer->last_line);
|
||||
weechat_log_printf (" last_read_line . . . . : 0x%X\n", buffer->last_read_line);
|
||||
weechat_log_printf (" num_lines. . . . . . . : %d\n", buffer->num_lines);
|
||||
weechat_log_printf (" line_complete. . . . . : %d\n", buffer->line_complete);
|
||||
weechat_log_printf (" notify_level . . . . . : %d\n", buffer->notify_level);
|
||||
weechat_log_printf (" log_filename . . . . . : '%s'\n", buffer->log_filename);
|
||||
weechat_log_printf (" log_file . . . . . . . : 0x%X\n", buffer->log_file);
|
||||
weechat_log_printf (" has_input. . . . . . . : %d\n", buffer->has_input);
|
||||
weechat_log_printf (" input_buffer . . . . . : '%s'\n", buffer->input_buffer);
|
||||
weechat_log_printf (" input_buffer_color_mask: '%s'\n", buffer->input_buffer_color_mask);
|
||||
weechat_log_printf (" input_buffer_alloc . . : %d\n", buffer->input_buffer_alloc);
|
||||
weechat_log_printf (" input_buffer_size. . . : %d\n", buffer->input_buffer_size);
|
||||
weechat_log_printf (" input_buffer_length. . : %d\n", buffer->input_buffer_length);
|
||||
weechat_log_printf (" input_buffer_pos . . . : %d\n", buffer->input_buffer_pos);
|
||||
weechat_log_printf (" input_buffer_1st_disp. : %d\n", buffer->input_buffer_1st_display);
|
||||
weechat_log_printf (" history. . . . . . . . : 0x%X\n", buffer->history);
|
||||
weechat_log_printf (" last_history . . . . . : 0x%X\n", buffer->last_history);
|
||||
weechat_log_printf (" ptr_history. . . . . . : 0x%X\n", buffer->ptr_history);
|
||||
weechat_log_printf (" prev_buffer. . . . . . : 0x%X\n", buffer->prev_buffer);
|
||||
weechat_log_printf (" next_buffer. . . . . . : 0x%X\n", buffer->next_buffer);
|
||||
weechat_log_printf ("\n");
|
||||
weechat_log_printf (" => last 100 lines:\n");
|
||||
|
||||
num = 0;
|
||||
ptr_line = buffer->last_line;
|
||||
while (ptr_line && (num < 100))
|
||||
{
|
||||
num++;
|
||||
ptr_line = ptr_line->prev_line;
|
||||
}
|
||||
if (!ptr_line)
|
||||
ptr_line = buffer->lines;
|
||||
else
|
||||
ptr_line = ptr_line->next_line;
|
||||
|
||||
while (ptr_line)
|
||||
{
|
||||
num--;
|
||||
weechat_log_printf (" line N-%05d: %s\n",
|
||||
num,
|
||||
(ptr_line->data) ? ptr_line->data : "(empty)");
|
||||
|
||||
ptr_line = ptr_line->next_line;
|
||||
}
|
||||
}
|
||||
+15
-1281
File diff suppressed because it is too large
Load Diff
@@ -150,7 +150,7 @@ gui_key_init ()
|
||||
gui_key_grab = 0;
|
||||
gui_key_grab_count = 0;
|
||||
|
||||
gui_input_default_key_bindings ();
|
||||
gui_keyboard_default_bindings ();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2006 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/* gui-window.c: window 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 "../irc/irc.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_window_tree_init: create first entry in windows tree
|
||||
*/
|
||||
|
||||
int
|
||||
gui_window_tree_init (t_gui_window *window)
|
||||
{
|
||||
gui_windows_tree = (t_gui_window_tree *)malloc (sizeof (t_gui_window_tree));
|
||||
if (!gui_windows_tree)
|
||||
return 0;
|
||||
gui_windows_tree->parent_node = NULL;
|
||||
gui_windows_tree->split_horiz = 0;
|
||||
gui_windows_tree->split_pct = 0;
|
||||
gui_windows_tree->child1 = NULL;
|
||||
gui_windows_tree->child2 = NULL;
|
||||
gui_windows_tree->window = window;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_tree_node_to_leaf: convert a node to a leaf (free any leafs)
|
||||
* Called when 2 windows are merging into one
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_tree_node_to_leaf (t_gui_window_tree *node, t_gui_window *window)
|
||||
{
|
||||
node->split_horiz = 0;
|
||||
node->split_pct = 0;
|
||||
if (node->child1)
|
||||
{
|
||||
free (node->child1);
|
||||
node->child1 = NULL;
|
||||
}
|
||||
if (node->child2)
|
||||
{
|
||||
free (node->child2);
|
||||
node->child2 = NULL;
|
||||
}
|
||||
node->window = window;
|
||||
window->ptr_tree = node;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_tree_free: delete entire windows tree
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_tree_free (t_gui_window_tree **tree)
|
||||
{
|
||||
if (*tree)
|
||||
{
|
||||
if ((*tree)->child1)
|
||||
gui_window_tree_free (&((*tree)->child1));
|
||||
if ((*tree)->child2)
|
||||
gui_window_tree_free (&((*tree)->child2));
|
||||
free (*tree);
|
||||
*tree = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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,
|
||||
int width_pct, int height_pct)
|
||||
{
|
||||
t_gui_window *new_window;
|
||||
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",
|
||||
x, y, width, height);
|
||||
#endif
|
||||
|
||||
if (parent)
|
||||
{
|
||||
child1 = (t_gui_window_tree *)malloc (sizeof (t_gui_window_tree));
|
||||
if (!child1)
|
||||
return NULL;
|
||||
child2 = (t_gui_window_tree *)malloc (sizeof (t_gui_window_tree));
|
||||
if (!child2)
|
||||
{
|
||||
free (child1);
|
||||
return NULL;
|
||||
}
|
||||
ptr_tree = parent->ptr_tree;
|
||||
|
||||
if (width_pct == 100)
|
||||
{
|
||||
ptr_tree->split_horiz = 1;
|
||||
ptr_tree->split_pct = height_pct;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_tree->split_horiz = 0;
|
||||
ptr_tree->split_pct = width_pct;
|
||||
}
|
||||
|
||||
/* parent window leaf becomes node and we add 2 leafs below
|
||||
(#1 is parent win, #2 is new win) */
|
||||
|
||||
parent->ptr_tree = child1;
|
||||
child1->parent_node = ptr_tree;
|
||||
child1->child1 = NULL;
|
||||
child1->child2 = NULL;
|
||||
child1->window = ptr_tree->window;
|
||||
|
||||
child2->parent_node = ptr_tree;
|
||||
child2->child1 = NULL;
|
||||
child2->child2 = NULL;
|
||||
child2->window = NULL; /* will be assigned by new window below */
|
||||
|
||||
ptr_tree->child1 = child1;
|
||||
ptr_tree->child2 = child2;
|
||||
ptr_tree->window = NULL; /* leaf becomes node */
|
||||
|
||||
ptr_leaf = child2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gui_window_tree_init (NULL))
|
||||
return NULL;
|
||||
ptr_leaf = gui_windows_tree;
|
||||
}
|
||||
|
||||
if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window)))))
|
||||
{
|
||||
new_window->win_x = x;
|
||||
new_window->win_y = y;
|
||||
new_window->win_width = width;
|
||||
new_window->win_height = height;
|
||||
new_window->win_width_pct = width_pct;
|
||||
new_window->win_height_pct = height_pct;
|
||||
|
||||
new_window->new_x = -1;
|
||||
new_window->new_y = -1;
|
||||
new_window->new_width = -1;
|
||||
new_window->new_height = -1;
|
||||
|
||||
new_window->win_chat_x = 0;
|
||||
new_window->win_chat_y = 0;
|
||||
new_window->win_chat_width = 0;
|
||||
new_window->win_chat_height = 0;
|
||||
new_window->win_chat_cursor_x = 0;
|
||||
new_window->win_chat_cursor_y = 0;
|
||||
|
||||
new_window->win_nick_x = 0;
|
||||
new_window->win_nick_y = 0;
|
||||
new_window->win_nick_width = 0;
|
||||
new_window->win_nick_height = 0;
|
||||
new_window->win_nick_num_max = 0;
|
||||
new_window->win_nick_start = 0;
|
||||
|
||||
new_window->win_input_x = 0;
|
||||
|
||||
new_window->win_title = NULL;
|
||||
new_window->win_chat = NULL;
|
||||
new_window->win_nick = NULL;
|
||||
new_window->win_status = NULL;
|
||||
new_window->win_infobar = NULL;
|
||||
new_window->win_input = NULL;
|
||||
new_window->win_separator = NULL;
|
||||
|
||||
new_window->textview_chat = NULL;
|
||||
new_window->textbuffer_chat = NULL;
|
||||
new_window->texttag_chat = NULL;
|
||||
new_window->textview_nicklist = NULL;
|
||||
new_window->textbuffer_nicklist = NULL;
|
||||
|
||||
new_window->dcc_first = NULL;
|
||||
new_window->dcc_selected = NULL;
|
||||
new_window->dcc_last_displayed = NULL;
|
||||
|
||||
new_window->buffer = NULL;
|
||||
|
||||
new_window->first_line_displayed = 0;
|
||||
new_window->start_line = NULL;
|
||||
new_window->start_line_pos = 0;
|
||||
new_window->scroll = 0;
|
||||
|
||||
new_window->ptr_tree = ptr_leaf;
|
||||
ptr_leaf->window = new_window;
|
||||
|
||||
/* add window to windows queue */
|
||||
new_window->prev_window = last_gui_window;
|
||||
if (gui_windows)
|
||||
last_gui_window->next_window = new_window;
|
||||
else
|
||||
gui_windows = new_window;
|
||||
last_gui_window = new_window;
|
||||
new_window->next_window = NULL;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return new_window;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_free: delete a window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_free (t_gui_window *window)
|
||||
{
|
||||
if (window->buffer && (window->buffer->num_displayed > 0))
|
||||
window->buffer->num_displayed--;
|
||||
|
||||
/* remove window from windows list */
|
||||
if (window->prev_window)
|
||||
window->prev_window->next_window = window->next_window;
|
||||
if (window->next_window)
|
||||
window->next_window->prev_window = window->prev_window;
|
||||
if (gui_windows == window)
|
||||
gui_windows = window->next_window;
|
||||
if (last_gui_window == window)
|
||||
last_gui_window = window->prev_window;
|
||||
|
||||
free (window);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
ptr_buffer = gui_buffer_servers_search ();
|
||||
|
||||
if (ptr_buffer)
|
||||
{
|
||||
ptr_server = (SERVER(ptr_buffer) && SERVER(ptr_buffer)->next_server) ?
|
||||
SERVER(ptr_buffer)->next_server : irc_servers;
|
||||
while (ptr_server != SERVER(window->buffer))
|
||||
{
|
||||
if (ptr_server->buffer)
|
||||
break;
|
||||
if (ptr_server->next_server)
|
||||
ptr_server = ptr_server->next_server;
|
||||
else
|
||||
{
|
||||
if (SERVER(ptr_buffer) == NULL)
|
||||
{
|
||||
ptr_server = NULL;
|
||||
break;
|
||||
}
|
||||
ptr_server = irc_servers;
|
||||
}
|
||||
}
|
||||
if (ptr_server && (ptr_server != SERVER(ptr_buffer)))
|
||||
{
|
||||
ptr_buffer->server = ptr_server;
|
||||
gui_status_draw (window->buffer, 1);
|
||||
gui_input_draw (window->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_switch_previous: switch to previous window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_switch_previous (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
/* if only one window then return */
|
||||
if (gui_windows == last_gui_window)
|
||||
return;
|
||||
|
||||
gui_current_window = (window->prev_window) ? window->prev_window : last_gui_window;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_switch_next: switch to next window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_switch_next (t_gui_window *window)
|
||||
{
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
/* if only one window then return */
|
||||
if (gui_windows == last_gui_window)
|
||||
return;
|
||||
|
||||
gui_current_window = (window->next_window) ? window->next_window : gui_windows;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_switch_by_buffer: switch to next window displaying a buffer
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_switch_by_buffer (t_gui_window *window, int buffer_number)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
ptr_win = (window->next_window) ? window->next_window : gui_windows;
|
||||
while (ptr_win != window)
|
||||
{
|
||||
if (ptr_win->buffer->number == buffer_number)
|
||||
{
|
||||
gui_current_window = ptr_win;
|
||||
gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
return;
|
||||
}
|
||||
ptr_win = (ptr_win->next_window) ? ptr_win->next_window : gui_windows;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_print_log: print window infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_print_log (t_gui_window *window)
|
||||
{
|
||||
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 . . . . . : 0x%X\n", window->win_title);
|
||||
weechat_log_printf (" win_chat. . . . . . : 0x%X\n", window->win_chat);
|
||||
weechat_log_printf (" win_nick. . . . . . : 0x%X\n", window->win_nick);
|
||||
weechat_log_printf (" win_status. . . . . : 0x%X\n", window->win_status);
|
||||
weechat_log_printf (" win_infobar . . . . : 0x%X\n", window->win_infobar);
|
||||
weechat_log_printf (" win_input . . . . . : 0x%X\n", window->win_input);
|
||||
weechat_log_printf (" win_separator . . . : 0x%X\n", window->win_separator);
|
||||
weechat_log_printf (" textview_chat . . . : 0x%X\n", window->textview_chat);
|
||||
weechat_log_printf (" textbuffer_chat . . : 0x%X\n", window->textbuffer_chat);
|
||||
weechat_log_printf (" texttag_chat. . . . : 0x%X\n", window->texttag_chat);
|
||||
weechat_log_printf (" textview_nicklist . : 0x%X\n", window->textview_nicklist);
|
||||
weechat_log_printf (" textbuffer_nicklist : 0x%X\n", window->textbuffer_nicklist);
|
||||
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);
|
||||
|
||||
}
|
||||
+62
-53
@@ -404,48 +404,38 @@ extern time_t gui_last_activity_time;
|
||||
|
||||
extern t_gui_color *gui_color[GUI_NUM_COLORS];
|
||||
|
||||
/* GUI independent functions: windows & buffers */
|
||||
/* GUI independent functions: windows */
|
||||
|
||||
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 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_window *gui_buffer_find_window (t_gui_buffer *);
|
||||
extern t_gui_buffer *gui_get_dcc_buffer (t_gui_window *);
|
||||
extern void gui_buffer_clear (t_gui_buffer *);
|
||||
extern void gui_buffer_clear_all ();
|
||||
extern void gui_window_free (t_gui_window *);
|
||||
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_buffer_free (t_gui_buffer *, int);
|
||||
extern t_gui_line *gui_line_new (t_gui_buffer *);
|
||||
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, char *, char *, ...);
|
||||
extern void gui_printf_raw_data (void *, int, char *);
|
||||
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_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);
|
||||
extern void gui_merge_servers (t_gui_window *);
|
||||
extern void gui_split_server (t_gui_window *);
|
||||
extern void gui_window_switch_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_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 *);
|
||||
|
||||
/* GUI independent functions: buffers */
|
||||
|
||||
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_window *gui_buffer_find_window (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 *);
|
||||
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_window_print_log (t_gui_window *);
|
||||
extern void gui_buffer_print_log (t_gui_buffer *);
|
||||
|
||||
/* GUI independent functions: actions */
|
||||
@@ -511,26 +501,48 @@ extern int gui_key_pressed (char *);
|
||||
extern void gui_key_free (t_gui_key *);
|
||||
extern void gui_key_free_all ();
|
||||
|
||||
/* other GUI independent functions */
|
||||
|
||||
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 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, char *, char *, ...);
|
||||
extern void gui_printf_raw_data (void *, int, char *);
|
||||
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_exec_action_dcc (t_gui_window *, char *);
|
||||
extern void gui_exec_action_raw_data (t_gui_window *, char *);
|
||||
extern int gui_insert_string_input (t_gui_window *, char *, int);
|
||||
|
||||
/* GUI dependant functions: keyboard */
|
||||
|
||||
extern void gui_keyboard_default_bindings ();
|
||||
|
||||
/* GUI dependant functions: display */
|
||||
|
||||
extern int gui_assign_color (int *, char *);
|
||||
extern char *gui_get_color_name (int);
|
||||
extern void gui_chat_draw_title (t_gui_buffer *, int);
|
||||
extern char *gui_chat_word_get_next_char (t_gui_window *, unsigned char *, int);
|
||||
extern void gui_chat_draw (t_gui_buffer *, int);
|
||||
extern void gui_chat_draw_line (t_gui_buffer *, t_gui_line *);
|
||||
extern int gui_color_assign (int *, char *);
|
||||
extern char *gui_color_get_name (int);
|
||||
extern unsigned char *gui_color_decode (unsigned char *, int);
|
||||
extern unsigned char *gui_color_decode_for_user_entry (unsigned char *);
|
||||
extern unsigned char *gui_color_encode (unsigned char *);
|
||||
extern int gui_buffer_has_nicklist (t_gui_buffer *);
|
||||
extern int gui_calculate_pos_size (t_gui_window *, int);
|
||||
extern void gui_draw_buffer_title (t_gui_buffer *, int);
|
||||
extern char *gui_word_get_next_char (t_gui_window *, unsigned char *, int);
|
||||
extern void gui_draw_buffer_chat (t_gui_buffer *, int);
|
||||
extern void gui_draw_buffer_chat_line (t_gui_buffer *, t_gui_line *);
|
||||
extern void gui_draw_buffer_nick (t_gui_buffer *, int);
|
||||
extern void gui_draw_buffer_status (t_gui_buffer *, int);
|
||||
extern void gui_draw_buffer_infobar_time (t_gui_buffer *);
|
||||
extern void gui_draw_buffer_infobar (t_gui_buffer *, int);
|
||||
extern void gui_draw_buffer_input (t_gui_buffer *, int);
|
||||
extern void gui_redraw_buffer (t_gui_buffer *);
|
||||
extern void gui_switch_to_buffer (t_gui_window *, t_gui_buffer *);
|
||||
extern void gui_color_init_pairs ();
|
||||
extern void gui_color_rebuild_weechat();
|
||||
extern void gui_infobar_draw_time (t_gui_buffer *);
|
||||
extern void gui_infobar_draw (t_gui_buffer *, int);
|
||||
extern void gui_input_draw (t_gui_buffer *, int);
|
||||
extern void gui_nicklist_draw (t_gui_buffer *, int);
|
||||
extern void gui_status_draw (t_gui_buffer *, int);
|
||||
extern int gui_window_calculate_pos_size (t_gui_window *, int);
|
||||
extern void gui_window_redraw_buffer (t_gui_buffer *);
|
||||
extern void gui_window_switch_to_buffer (t_gui_window *, t_gui_buffer *);
|
||||
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 *);
|
||||
@@ -542,7 +554,7 @@ 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_refresh_windows ();
|
||||
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);
|
||||
@@ -552,15 +564,12 @@ 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_refresh_screen ();
|
||||
extern void gui_pre_init (int *, char **[]);
|
||||
extern void gui_init_color_pairs ();
|
||||
extern void gui_rebuild_weechat_colors ();
|
||||
extern void gui_set_window_title ();
|
||||
extern void gui_reset_window_title ();
|
||||
extern void gui_init ();
|
||||
extern void gui_end ();
|
||||
extern void gui_input_default_key_bindings ();
|
||||
extern void gui_window_refresh_screen ();
|
||||
extern void gui_window_set_title ();
|
||||
extern void gui_window_reset_title ();
|
||||
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 */
|
||||
|
||||
@@ -376,7 +376,7 @@ channel_remove_away (t_irc_channel *channel)
|
||||
{
|
||||
NICK_SET_FLAG(ptr_nick, 0, NICK_AWAY);
|
||||
}
|
||||
gui_draw_buffer_nick (channel->buffer, 0);
|
||||
gui_nicklist_draw (channel->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ channel_create_dcc (t_irc_dcc *ptr_dcc)
|
||||
|
||||
ptr_channel->dcc_chat = ptr_dcc;
|
||||
ptr_dcc->channel = ptr_channel;
|
||||
gui_redraw_buffer (ptr_channel->buffer);
|
||||
gui_window_redraw_buffer (ptr_channel->buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -57,11 +57,11 @@ char *dcc_status_string[] = /* strings for DCC status */
|
||||
void
|
||||
dcc_redraw (int highlight)
|
||||
{
|
||||
gui_redraw_buffer (gui_get_dcc_buffer (gui_current_window));
|
||||
gui_window_redraw_buffer (gui_buffer_get_dcc (gui_current_window));
|
||||
if (highlight)
|
||||
{
|
||||
hotlist_add (highlight, NULL, gui_get_dcc_buffer (gui_current_window));
|
||||
gui_draw_buffer_status (gui_current_window->buffer, 0);
|
||||
hotlist_add (highlight, NULL, gui_buffer_get_dcc (gui_current_window));
|
||||
gui_status_draw (gui_current_window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -849,7 +849,7 @@ dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char *nic
|
||||
dcc_accept (new_dcc);
|
||||
else
|
||||
dcc_redraw (HOTLIST_PRIVATE);
|
||||
gui_draw_buffer_status (gui_current_window->buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 0);
|
||||
|
||||
return new_dcc;
|
||||
}
|
||||
|
||||
+1
-1
@@ -400,7 +400,7 @@ nick_set_away (t_irc_channel *channel, t_irc_nick *nick, int is_away)
|
||||
((!is_away) && (nick->flags & NICK_AWAY)))
|
||||
{
|
||||
NICK_SET_FLAG(nick, is_away, NICK_AWAY);
|
||||
gui_draw_buffer_nick (channel->buffer, 0);
|
||||
gui_nicklist_draw (channel->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+36
-36
@@ -379,7 +379,7 @@ irc_cmd_recv_invite (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
GUI_COLOR(COLOR_WIN_CHAT_NICK),
|
||||
nick);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, server, server->buffer);
|
||||
gui_draw_buffer_status (gui_current_window->buffer, 1);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -442,8 +442,8 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
ptr_nick = nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0);
|
||||
if (ptr_nick)
|
||||
ptr_nick->host = strdup ((pos) ? pos + 1 : host);
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
gui_nicklist_draw (ptr_channel->buffer, 1);
|
||||
gui_status_draw (ptr_channel->buffer, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -523,8 +523,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
{
|
||||
/* my nick was kicked => free all nicks, channel is not active any more */
|
||||
nick_free_all (ptr_channel);
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
gui_nicklist_draw (ptr_channel->buffer, 1);
|
||||
gui_status_draw (ptr_channel->buffer, 1);
|
||||
if (server->autorejoin)
|
||||
irc_cmd_send_join (server, NULL, ptr_channel->name);
|
||||
}
|
||||
@@ -534,8 +534,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
if (ptr_nick)
|
||||
{
|
||||
nick_free (ptr_channel, ptr_nick);
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
gui_nicklist_draw (ptr_channel->buffer, 1);
|
||||
gui_status_draw (ptr_channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -761,7 +761,7 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *channel,
|
||||
{
|
||||
NICK_SET_FLAG(ptr_nick, (set_flag == '+'), NICK_HALFOP);
|
||||
nick_resort (channel, ptr_nick);
|
||||
gui_draw_buffer_nick (channel->buffer, 1);
|
||||
gui_nicklist_draw (channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -923,7 +923,7 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *channel,
|
||||
{
|
||||
NICK_SET_FLAG(ptr_nick, (set_flag == '+'), NICK_OP);
|
||||
nick_resort (channel, ptr_nick);
|
||||
gui_draw_buffer_nick (channel->buffer, 1);
|
||||
gui_nicklist_draw (channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1022,7 +1022,7 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *channel,
|
||||
{
|
||||
NICK_SET_FLAG(ptr_nick, (set_flag == '+'), NICK_VOICE);
|
||||
nick_resort (channel, ptr_nick);
|
||||
gui_draw_buffer_nick (channel->buffer, 1);
|
||||
gui_nicklist_draw (channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1235,8 +1235,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
{
|
||||
irc_get_channel_modes (server, ptr_channel, arguments, nick,
|
||||
pos, pos_parm, command_ignored);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_input (ptr_channel->buffer, 1);
|
||||
gui_status_draw (ptr_channel->buffer, 1);
|
||||
gui_input_draw (ptr_channel->buffer, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1250,8 +1250,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
else
|
||||
{
|
||||
irc_get_nick_modes (server, nick, pos, command_ignored);
|
||||
gui_draw_buffer_status (gui_current_window->buffer, 1);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 1);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1320,7 +1320,7 @@ irc_cmd_recv_nick (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
GUI_COLOR(COLOR_WIN_CHAT_NICK),
|
||||
arguments);
|
||||
}
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_nicklist_draw (ptr_channel->buffer, 1);
|
||||
gui_add_hotlist = 1;
|
||||
}
|
||||
}
|
||||
@@ -1329,17 +1329,17 @@ irc_cmd_recv_nick (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
{
|
||||
free (server->nick);
|
||||
server->nick = strdup (arguments);
|
||||
gui_draw_buffer_status (gui_current_window->buffer, 1);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if (ptr_win->buffer->server == server)
|
||||
gui_draw_buffer_input (ptr_win->buffer, 1);
|
||||
gui_input_draw (ptr_win->buffer, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_draw_buffer_status (gui_current_window->buffer, 1);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 1);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1527,7 +1527,7 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
(ascii_strcasecmp (nick, "memoserv") != 0))
|
||||
{
|
||||
hotlist_add (HOTLIST_PRIVATE, server, server->buffer);
|
||||
gui_draw_buffer_status (gui_current_window->buffer, 1);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1641,10 +1641,10 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
gui_nicklist_draw (ptr_channel->buffer, 1);
|
||||
gui_status_draw (ptr_channel->buffer, 1);
|
||||
}
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 1);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1701,7 +1701,7 @@ irc_cmd_recv_pong (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
gettimeofday (&tv, &tz);
|
||||
server->lag = (int) get_timeval_diff (&(server->lag_check_time), &tv);
|
||||
if (old_lag != server->lag)
|
||||
gui_draw_buffer_status (gui_current_window->buffer, 1);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
|
||||
/* schedule next lag check */
|
||||
server->lag_check_time.tv_sec = 0;
|
||||
@@ -2584,8 +2584,8 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
arguments,
|
||||
GUI_COLOR(COLOR_WIN_CHAT_DARK));
|
||||
}
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
gui_nicklist_draw (ptr_channel->buffer, 1);
|
||||
gui_status_draw (ptr_channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2756,7 +2756,7 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *nick, char *argument
|
||||
ptr_channel->topic = strdup (pos);
|
||||
else
|
||||
ptr_channel->topic = strdup ("");
|
||||
gui_draw_buffer_title (ptr_channel->buffer, 1);
|
||||
gui_chat_draw_title (ptr_channel->buffer, 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -2787,8 +2787,8 @@ irc_cmd_recv_004 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
/* connection to IRC server is ok! */
|
||||
server->is_connected = 1;
|
||||
server->lag_next_check = time (NULL) + cfg_irc_lag_check;
|
||||
gui_draw_buffer_status (server->buffer, 1);
|
||||
gui_draw_buffer_input (server->buffer, 1);
|
||||
gui_status_draw (server->buffer, 1);
|
||||
gui_input_draw (server->buffer, 1);
|
||||
|
||||
/* execute command once connected */
|
||||
if (server->command && server->command[0])
|
||||
@@ -3079,7 +3079,7 @@ irc_cmd_recv_305 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
ptr_window = ptr_window->next_window)
|
||||
{
|
||||
if (SERVER(ptr_window->buffer) == server)
|
||||
gui_draw_buffer_status (ptr_window->buffer, 1);
|
||||
gui_status_draw (ptr_window->buffer, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -3116,7 +3116,7 @@ irc_cmd_recv_306 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
ptr_window = ptr_window->next_window)
|
||||
{
|
||||
if (SERVER(ptr_window->buffer) == server)
|
||||
gui_draw_buffer_status (ptr_window->buffer, 1);
|
||||
gui_status_draw (ptr_window->buffer, 1);
|
||||
if (SERVER(ptr_window->buffer) == server)
|
||||
ptr_window->buffer->last_read_line =
|
||||
ptr_window->buffer->last_line;
|
||||
@@ -3869,7 +3869,7 @@ irc_cmd_recv_324 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
{
|
||||
irc_get_channel_modes (server, ptr_channel, NULL, NULL,
|
||||
pos, pos_parm, command_ignored);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 0);
|
||||
gui_status_draw (ptr_channel->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4002,7 +4002,7 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
}
|
||||
|
||||
if (ptr_channel)
|
||||
gui_draw_buffer_title (ptr_buffer, 1);
|
||||
gui_chat_draw_title (ptr_buffer, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -4140,7 +4140,7 @@ irc_cmd_recv_341 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
GUI_COLOR(COLOR_WIN_CHAT),
|
||||
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
|
||||
pos_channel);
|
||||
gui_draw_buffer_status (gui_current_window->buffer, 1);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4758,8 +4758,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *nick, char *arguments)
|
||||
}
|
||||
if (ptr_channel)
|
||||
{
|
||||
gui_draw_buffer_nick (ptr_channel->buffer, 1);
|
||||
gui_draw_buffer_status (ptr_channel->buffer, 1);
|
||||
gui_nicklist_draw (ptr_channel->buffer, 1);
|
||||
gui_status_draw (ptr_channel->buffer, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+9
-9
@@ -75,7 +75,7 @@ irc_login (t_irc_server *server)
|
||||
"USER %s %s %s :%s\r\n",
|
||||
server->nick, server->username, ptr_hostname, "servername",
|
||||
server->realname);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 1);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -343,7 +343,7 @@ irc_cmd_send_away (t_irc_server *server, t_irc_channel *channel,
|
||||
else
|
||||
irc_send_away (server, arguments);
|
||||
|
||||
gui_draw_buffer_status (buffer, 1);
|
||||
gui_status_draw (buffer, 1);
|
||||
gui_add_hotlist = 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -1368,11 +1368,11 @@ irc_cmd_send_nick_server (t_irc_server *server, char *nickname)
|
||||
if (server->nick)
|
||||
free (server->nick);
|
||||
server->nick = strdup (nickname);
|
||||
gui_draw_buffer_input (server->buffer, 1);
|
||||
gui_input_draw (server->buffer, 1);
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
gui_draw_buffer_input (ptr_channel->buffer, 1);
|
||||
gui_input_draw (ptr_channel->buffer, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1554,8 +1554,8 @@ irc_cmd_send_part (t_irc_server *server, t_irc_channel *channel,
|
||||
ptr_channel = CHANNEL(buffer);
|
||||
gui_buffer_free (ptr_channel->buffer, 1);
|
||||
channel_free (server, ptr_channel);
|
||||
gui_draw_buffer_status (buffer, 1);
|
||||
gui_draw_buffer_input (buffer, 1);
|
||||
gui_status_draw (buffer, 1);
|
||||
gui_input_draw (buffer, 1);
|
||||
return 0;
|
||||
}
|
||||
channel_name = CHANNEL(buffer)->name;
|
||||
@@ -1652,7 +1652,7 @@ irc_cmd_send_query (t_irc_server *server, t_irc_channel *channel,
|
||||
}
|
||||
gui_buffer_new (window, server, ptr_channel,
|
||||
BUFFER_TYPE_STANDARD, 1);
|
||||
gui_draw_buffer_title (ptr_channel->buffer, 1);
|
||||
gui_chat_draw_title (ptr_channel->buffer, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1660,8 +1660,8 @@ irc_cmd_send_query (t_irc_server *server, t_irc_channel *channel,
|
||||
{
|
||||
if (ptr_buffer->channel == ptr_channel)
|
||||
{
|
||||
gui_switch_to_buffer (window, ptr_buffer);
|
||||
gui_redraw_buffer (ptr_buffer);
|
||||
gui_window_switch_to_buffer (window, ptr_buffer);
|
||||
gui_window_redraw_buffer (ptr_buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1655,7 +1655,7 @@ server_auto_connect (int auto_connect, int command_line)
|
||||
{
|
||||
(void) gui_buffer_new (gui_current_window, ptr_server, NULL,
|
||||
BUFFER_TYPE_STANDARD, 1);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
if (!server_connect (ptr_server))
|
||||
server_reconnect_schedule (ptr_server);
|
||||
}
|
||||
@@ -1708,7 +1708,7 @@ server_disconnect (t_irc_server *server, int reconnect)
|
||||
else
|
||||
server->reconnect_start = 0;
|
||||
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -234,7 +234,7 @@ weechat_plugin_infobar_remove (t_weechat_plugin *plugin, int how_many)
|
||||
how_many--;
|
||||
}
|
||||
}
|
||||
gui_draw_buffer_infobar (gui_current_window->buffer, 1);
|
||||
gui_infobar_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -621,7 +621,7 @@ weechat_plugin_get_config_str_value (t_config_option *option, void *value)
|
||||
return option->array_values[*((int *)value)];
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
color_name = gui_get_color_name (*((int *)value));
|
||||
color_name = gui_color_get_name (*((int *)value));
|
||||
return (color_name) ? strdup (color_name) : strdup ("");
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
@@ -1073,7 +1073,7 @@ weechat_plugin_input_color (t_weechat_plugin *plugin, int color, int start, int
|
||||
return;
|
||||
|
||||
if (color < 0)
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 0);
|
||||
gui_input_draw (gui_current_window->buffer, 0);
|
||||
else
|
||||
{
|
||||
if ((start < 0) || (length <= 0))
|
||||
|
||||
Reference in New Issue
Block a user