summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/command.c91
-rw-r--r--src/common/session.c17
-rw-r--r--src/common/session.h2
-rw-r--r--src/gui/curses/gui-display.c316
-rw-r--r--src/gui/curses/gui-input.c23
-rw-r--r--src/gui/gui-action.c41
-rw-r--r--src/gui/gui-common.c368
-rw-r--r--src/gui/gui-keyboard.c2
-rw-r--r--src/gui/gui.h17
-rw-r--r--src/irc/irc-channel.c3
-rw-r--r--src/irc/irc-recv.c12
-rw-r--r--src/irc/irc-send.c6
-rw-r--r--src/irc/irc-server.c11
13 files changed, 562 insertions, 347 deletions
diff --git a/src/common/command.c b/src/common/command.c
index 9104b1041..ea308b631 100644
--- a/src/common/command.c
+++ b/src/common/command.c
@@ -1125,41 +1125,55 @@ weechat_cmd_alias (t_irc_server *server, t_irc_channel *channel,
void
weechat_cmd_buffer_display_info (t_gui_buffer *buffer)
{
- if (buffer->dcc)
- gui_printf (NULL, "%sDCC\n",
- GUI_COLOR(COLOR_WIN_CHAT_CHANNEL));
- else if (BUFFER_IS_SERVER(buffer))
+ switch (buffer->type)
{
- if (SERVER(buffer))
- gui_printf (NULL, _("%sServer: %s%s\n"),
- GUI_COLOR(COLOR_WIN_CHAT),
- GUI_COLOR(COLOR_WIN_CHAT_SERVER),
- SERVER(buffer)->name);
- else
- gui_printf (NULL, _("%snot connected\n"),
+ case BUFFER_TYPE_STANDARD:
+ if (BUFFER_IS_SERVER(buffer))
+ {
+ if (SERVER(buffer))
+ gui_printf (NULL, _("%sServer: %s%s\n"),
+ GUI_COLOR(COLOR_WIN_CHAT),
+ GUI_COLOR(COLOR_WIN_CHAT_SERVER),
+ SERVER(buffer)->name);
+ else
+ gui_printf (NULL, _("%snot connected\n"),
+ GUI_COLOR(COLOR_WIN_CHAT));
+ }
+ else if (BUFFER_IS_CHANNEL (buffer))
+ gui_printf (NULL, _("%sChannel: %s%s %s(server: %s%s%s)\n"),
+ GUI_COLOR(COLOR_WIN_CHAT),
+ GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
+ CHANNEL(buffer)->name,
+ GUI_COLOR(COLOR_WIN_CHAT),
+ GUI_COLOR(COLOR_WIN_CHAT_SERVER),
+ SERVER(buffer)->name,
+ GUI_COLOR(COLOR_WIN_CHAT));
+ else if (BUFFER_IS_PRIVATE (buffer))
+ gui_printf (NULL, _("%sPrivate with: %s%s %s(server: %s%s%s)\n"),
+ GUI_COLOR(COLOR_WIN_CHAT),
+ GUI_COLOR(COLOR_WIN_CHAT_NICK),
+ CHANNEL(buffer)->name,
+ GUI_COLOR(COLOR_WIN_CHAT),
+ GUI_COLOR(COLOR_WIN_CHAT_SERVER),
+ SERVER(buffer)->name,
+ GUI_COLOR(COLOR_WIN_CHAT));
+ else
+ gui_printf (NULL, _("%sunknown\n"),
+ GUI_COLOR(COLOR_WIN_CHAT));
+ break;
+ case BUFFER_TYPE_DCC:
+ gui_printf (NULL, "%sDCC\n",
+ GUI_COLOR(COLOR_WIN_CHAT_CHANNEL));
+ break;
+ case BUFFER_TYPE_RAW_DATA:
+ gui_printf (NULL, _("%sraw IRC data\n"),
+ GUI_COLOR(COLOR_WIN_CHAT_CHANNEL));
+ break;
+ default:
+ gui_printf (NULL, _("%sunknown\n"),
GUI_COLOR(COLOR_WIN_CHAT));
+ break;
}
- else if (BUFFER_IS_CHANNEL (buffer))
- gui_printf (NULL, _("%sChannel: %s%s %s(server: %s%s%s)\n"),
- GUI_COLOR(COLOR_WIN_CHAT),
- GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
- CHANNEL(buffer)->name,
- GUI_COLOR(COLOR_WIN_CHAT),
- GUI_COLOR(COLOR_WIN_CHAT_SERVER),
- SERVER(buffer)->name,
- GUI_COLOR(COLOR_WIN_CHAT));
- else if (BUFFER_IS_PRIVATE (buffer))
- gui_printf (NULL, _("%sPrivate with: %s%s %s(server: %s%s%s)\n"),
- GUI_COLOR(COLOR_WIN_CHAT),
- GUI_COLOR(COLOR_WIN_CHAT_NICK),
- CHANNEL(buffer)->name,
- GUI_COLOR(COLOR_WIN_CHAT),
- GUI_COLOR(COLOR_WIN_CHAT_SERVER),
- SERVER(buffer)->name,
- GUI_COLOR(COLOR_WIN_CHAT));
- else
- gui_printf (NULL, _("%sunknown\n"),
- GUI_COLOR(COLOR_WIN_CHAT));
}
/*
@@ -1311,9 +1325,10 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
{
gui_printf (NULL, "%d.%s:",
ptr_buffer->number,
- (ptr_buffer->dcc) ? "DCC" :
- ((BUFFER_IS_SERVER(ptr_buffer)) ? SERVER(ptr_buffer)->name :
- CHANNEL(ptr_buffer)->name));
+ (ptr_buffer->type == BUFFER_TYPE_DCC) ? "DCC" :
+ ((ptr_buffer->type == BUFFER_TYPE_RAW_DATA) ? _("Raw IRC data") :
+ ((BUFFER_IS_SERVER(ptr_buffer)) ? SERVER(ptr_buffer)->name :
+ CHANNEL(ptr_buffer)->name)));
if ((!BUFFER_IS_CHANNEL(ptr_buffer))
&& (!BUFFER_IS_PRIVATE(ptr_buffer)))
gui_printf (NULL, "-");
@@ -1721,7 +1736,8 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel,
}
if (!ptr_server->buffer)
{
- if (!gui_buffer_new (window, ptr_server, NULL, 0, 1))
+ if (!gui_buffer_new (window, ptr_server, NULL,
+ BUFFER_TYPE_STANDARD, 1))
return -1;
}
if (server_connect (ptr_server))
@@ -2761,7 +2777,8 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel,
if (new_server->autoconnect)
{
- (void) gui_buffer_new (window, new_server, NULL, 0, 1);
+ (void) gui_buffer_new (window, new_server, NULL,
+ BUFFER_TYPE_STANDARD, 1);
server_connect (new_server);
}
diff --git a/src/common/session.c b/src/common/session.c
index 5406b3b65..ff4888d3f 100644
--- a/src/common/session.c
+++ b/src/common/session.c
@@ -386,7 +386,7 @@ session_save_buffers (FILE *file)
rc = rc && (session_write_id (file, SESSION_OBJ_BUFFER));
rc = rc && (session_write_str (file, SESSION_BUFF_SERVER, SERVER(ptr_buffer) ? SERVER(ptr_buffer)->name : NULL));
rc = rc && (session_write_str (file, SESSION_BUFF_CHANNEL, CHANNEL(ptr_buffer) ? CHANNEL(ptr_buffer)->name : NULL));
- rc = rc && (session_write_int (file, SESSION_BUFF_DCC, ptr_buffer->dcc));
+ rc = rc && (session_write_int (file, SESSION_BUFF_TYPE, ptr_buffer->type));
rc = rc && (session_write_int (file, SESSION_BUFF_ALL_SERVERS, ptr_buffer->all_servers));
rc = rc && (session_write_id (file, SESSION_BUFF_END));
@@ -1335,7 +1335,7 @@ session_load_buffer (FILE *file)
{
int object_id, rc;
char *server_name, *channel_name;
- int dcc;
+ int buffer_type;
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
@@ -1355,18 +1355,18 @@ session_load_buffer (FILE *file)
return 0;
}
- /* read dcc */
- if (!session_read_object (file, SESSION_BUFF_DCC, SESSION_TYPE_INT, &dcc, 0))
+ /* read buffer type */
+ if (!session_read_object (file, SESSION_BUFF_TYPE, SESSION_TYPE_INT, &buffer_type, 0))
{
- session_crash (file, _("dcc flag not found for buffer"));
+ session_crash (file, _("buffer type not found"));
return 0;
}
/* allocate buffer */
- weechat_log_printf (_("session: loading buffer (server: %s, channel: %s, dcc: %d)\n"),
+ weechat_log_printf (_("session: loading buffer (server: %s, channel: %s, type: %d)\n"),
(server_name) ? server_name : "-",
(channel_name) ? channel_name : "-",
- dcc);
+ buffer_type);
ptr_server = NULL;
ptr_channel = NULL;
if (server_name)
@@ -1389,7 +1389,8 @@ session_load_buffer (FILE *file)
}
}
- session_current_buffer = gui_buffer_new (gui_windows, ptr_server, ptr_channel, dcc, 1);
+ session_current_buffer = gui_buffer_new (gui_windows, ptr_server,
+ ptr_channel, buffer_type, 1);
if (!session_current_buffer)
{
session_crash (file, _("can't create new buffer"));
diff --git a/src/common/session.h b/src/common/session.h
index 6b2c4ecf8..c864dc5df 100644
--- a/src/common/session.h
+++ b/src/common/session.h
@@ -153,7 +153,7 @@ enum t_session_buffer
SESSION_BUFF_END = 0,
SESSION_BUFF_SERVER,
SESSION_BUFF_CHANNEL,
- SESSION_BUFF_DCC,
+ SESSION_BUFF_TYPE,
SESSION_BUFF_ALL_SERVERS
};
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index f95b1bafc..5d7df5c26 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -826,7 +826,7 @@ gui_draw_buffer_title (t_gui_buffer *buffer, int erase)
}
else
{
- if (!buffer->dcc)
+ if (buffer->type == BUFFER_TYPE_STANDARD)
{
mvwprintw (ptr_win->win_title, 0, 0,
format,
@@ -1509,7 +1509,7 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase)
gui_window_set_weechat_color (ptr_win->win_chat, COLOR_WIN_CHAT);
- if (buffer->dcc)
+ if (buffer->type == BUFFER_TYPE_DCC)
{
i = 0;
dcc_first = (ptr_win->dcc_first) ? (t_irc_dcc *) ptr_win->dcc_first : dcc_list;
@@ -2105,10 +2105,18 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
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 (ptr_win->buffer->dcc)
- wprintw (ptr_win->win_status, "<DCC> ");
- else
- wprintw (ptr_win->win_status, _("[not connected] "));
+ 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 */
@@ -2150,46 +2158,57 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
display_name = 0;
break;
}
- if (ptr_hotlist->buffer->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");
- }
- else
+ switch (ptr_hotlist->buffer->type)
{
- 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++;
+ 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);
- 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);
- }
+ 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)
@@ -2388,124 +2407,133 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
if (erase)
gui_curses_window_clear (ptr_win->win_input, COLOR_WIN_INPUT);
- if (buffer->dcc)
+ switch (buffer->type)
{
- 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 BUFFER_TYPE_STANDARD:
+ if (buffer->has_input)
{
- 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 (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;
+ input_width = gui_get_input_width (ptr_win, ptr_nickname);
+
+ if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
+ input_width)
+ buffer->input_buffer_1st_display = buffer->input_buffer_pos -
+ input_width + 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) < input_width)
+ {
+ buffer->input_buffer_1st_display =
+ buffer->input_buffer_pos - input_width + 1;
+ if (buffer->input_buffer_1st_display < 0)
+ buffer->input_buffer_1st_display = 0;
+ }
+ }
+ }
+ if (CHANNEL(buffer))
+ {
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
+ mvwprintw (ptr_win->win_input, 0, 0, "[");
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_CHANNEL);
+ wprintw (ptr_win->win_input, "%s ", CHANNEL(buffer)->name);
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK);
+ wprintw (ptr_win->win_input, "%s", ptr_nickname);
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
+ wprintw (ptr_win->win_input, "] ");
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
+ snprintf (format, 32, "%%-%ds", input_width);
+ if (ptr_win == gui_current_window)
+ wprintw (ptr_win->win_input, format,
+ utf8_add_offset (buffer->input_buffer,
+ buffer->input_buffer_1st_display));
+ else
+ wprintw (ptr_win->win_input, format, "");
+ wclrtoeol (ptr_win->win_input);
+ ptr_win->win_input_x = utf8_strlen (CHANNEL(buffer)->name) +
+ utf8_strlen (SERVER(buffer)->nick) + 4 +
+ (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);
+ }
+ else
+ {
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
+ mvwprintw (ptr_win->win_input, 0, 0, "[");
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK);
+ wprintw (ptr_win->win_input, "%s", ptr_nickname);
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
+ wprintw (ptr_win->win_input, "] ");
+ gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
+ snprintf (format, 32, "%%-%ds", input_width);
+ if (ptr_win == gui_current_window)
+ wprintw (ptr_win->win_input, format,
+ utf8_add_offset (buffer->input_buffer,
+ buffer->input_buffer_1st_display));
+ else
+ wprintw (ptr_win->win_input, format, "");
+ wclrtoeol (ptr_win->win_input);
+ ptr_win->win_input_x = utf8_strlen (ptr_nickname) + 3 +
+ (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);
+ }
}
- }
- 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);
- }
- else if (buffer->has_input)
- {
- 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;
- input_width = gui_get_input_width (ptr_win, ptr_nickname);
-
- if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
- input_width)
- buffer->input_buffer_1st_display = buffer->input_buffer_pos -
- input_width + 1;
- else
- {
- if (buffer->input_buffer_pos < buffer->input_buffer_1st_display)
- buffer->input_buffer_1st_display = buffer->input_buffer_pos;
- else
+ 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)
{
- if ((buffer->input_buffer_1st_display > 0) &&
- (buffer->input_buffer_pos -
- buffer->input_buffer_1st_display + 1) < input_width)
+ switch (dcc_selected->status)
{
- buffer->input_buffer_1st_display =
- buffer->input_buffer_pos - input_width + 1;
- if (buffer->input_buffer_1st_display < 0)
- buffer->input_buffer_1st_display = 0;
+ 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 (CHANNEL(buffer))
- {
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
- mvwprintw (ptr_win->win_input, 0, 0, "[");
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_CHANNEL);
- wprintw (ptr_win->win_input, "%s ", CHANNEL(buffer)->name);
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK);
- wprintw (ptr_win->win_input, "%s", ptr_nickname);
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
- wprintw (ptr_win->win_input, "] ");
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
- snprintf (format, 32, "%%-%ds", input_width);
- if (ptr_win == gui_current_window)
- wprintw (ptr_win->win_input, format,
- utf8_add_offset (buffer->input_buffer,
- buffer->input_buffer_1st_display));
- else
- wprintw (ptr_win->win_input, format,
- "");
+ 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 = utf8_strlen (CHANNEL(buffer)->name) +
- utf8_strlen (SERVER(buffer)->nick) + 4 +
- (buffer->input_buffer_pos - buffer->input_buffer_1st_display);
+ 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 + ptr_win->win_input_x);
- }
- else
- {
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
- mvwprintw (ptr_win->win_input, 0, 0, "[");
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK);
- wprintw (ptr_win->win_input, "%s", ptr_nickname);
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS);
- wprintw (ptr_win->win_input, "] ");
- gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT);
- snprintf (format, 32, "%%-%ds", input_width);
- if (ptr_win == gui_current_window)
- wprintw (ptr_win->win_input, format,
- utf8_add_offset (buffer->input_buffer,
- buffer->input_buffer_1st_display));
- else
- wprintw (ptr_win->win_input, format,
- "");
+ 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 = utf8_strlen (ptr_nickname) + 3 +
- (buffer->input_buffer_pos - buffer->input_buffer_1st_display);
+ 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 + ptr_win->win_input_x);
- }
+ ptr_win->win_x);
+ break;
}
-
doupdate ();
wrefresh (ptr_win->win_input);
refresh ();
@@ -3576,7 +3604,7 @@ gui_init ()
if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
{
gui_current_window = gui_windows;
- gui_buffer_new (gui_windows, NULL, NULL, 0, 1);
+ gui_buffer_new (gui_windows, NULL, NULL, BUFFER_TYPE_STANDARD, 1);
signal (SIGWINCH, gui_refresh_screen_sigwinch);
diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c
index 696ce9e1c..5641add76 100644
--- a/src/gui/curses/gui-input.c
+++ b/src/gui/curses/gui-input.c
@@ -106,6 +106,7 @@ gui_input_default_key_bindings ()
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");
@@ -275,14 +276,20 @@ gui_input_read ()
if (strcmp (key_str, "^^") == 0)
key_str[1] = '\0';
- if (gui_current_window->buffer->dcc)
- gui_exec_action_dcc (gui_current_window, key_str);
- else
+ switch (gui_current_window->buffer->type)
{
- 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;
+ case BUFFER_TYPE_STANDARD:
+ 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;
+ 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;
}
}
@@ -336,7 +343,7 @@ gui_main_loop ()
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
- if (!ptr_buffer->dcc)
+ if (ptr_buffer->type == BUFFER_TYPE_STANDARD)
gui_printf_nolog_notime (ptr_buffer,
_("Day changed to %s\n"),
text_time);
diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c
index 23dffab88..ca6ee2821 100644
--- a/src/gui/gui-action.c
+++ b/src/gui/gui-action.c
@@ -654,7 +654,7 @@ gui_action_next_word (t_gui_window *window)
void
gui_action_up (t_gui_window *window)
{
- if (window->buffer->dcc)
+ if (window->buffer->type == BUFFER_TYPE_DCC)
{
if (dcc_list)
{
@@ -763,7 +763,7 @@ gui_action_up_global (t_gui_window *window)
void
gui_action_down (t_gui_window *window)
{
- if (window->buffer->dcc)
+ if (window->buffer->type == BUFFER_TYPE_DCC)
{
if (dcc_list)
{
@@ -970,23 +970,46 @@ gui_action_jump_smart (t_gui_window *window)
void
gui_action_jump_dcc (t_gui_window *window)
{
- if (window->buffer->dcc)
+ if (window->buffer->type == BUFFER_TYPE_DCC)
{
- if (buffer_before_dcc)
+ if (gui_buffer_before_dcc)
{
gui_switch_to_buffer (window,
- buffer_before_dcc);
+ gui_buffer_before_dcc);
gui_redraw_buffer (window->buffer);
}
}
else
{
- buffer_before_dcc = window->buffer;
+ gui_buffer_before_dcc = window->buffer;
gui_buffer_switch_dcc (window);
}
}
/*
+ * gui_action_jump_raw_data: jump to raw IRC data buffer
+ */
+
+void
+gui_action_jump_raw_data (t_gui_window *window)
+{
+ if (window->buffer->type == BUFFER_TYPE_RAW_DATA)
+ {
+ if (gui_buffer_before_raw_data)
+ {
+ gui_switch_to_buffer (window,
+ gui_buffer_before_raw_data);
+ gui_redraw_buffer (window->buffer);
+ }
+ }
+ else
+ {
+ gui_buffer_before_raw_data = window->buffer;
+ gui_buffer_switch_raw_data (window);
+ }
+}
+
+/*
* gui_action_jump_last_buffer: jump to last buffer
*/
@@ -1078,7 +1101,7 @@ gui_action_scroll_previous_highlight (t_gui_window *window)
{
t_gui_line *ptr_line;
- if (!window->buffer->dcc)
+ if (window->buffer->type == BUFFER_TYPE_STANDARD)
{
if (window->buffer->lines)
{
@@ -1111,7 +1134,7 @@ gui_action_scroll_next_highlight (t_gui_window *window)
{
t_gui_line *ptr_line;
- if (!window->buffer->dcc)
+ if (window->buffer->type == BUFFER_TYPE_STANDARD)
{
if (window->buffer->lines)
{
@@ -1144,7 +1167,7 @@ gui_action_scroll_unread (t_gui_window *window)
{
if (cfg_look_read_marker &&
cfg_look_read_marker[0] &&
- !window->buffer->dcc &&
+ (window->buffer->type == BUFFER_TYPE_STANDARD) &&
window->buffer->last_read_line &&
window->buffer->last_read_line != window->buffer->last_line)
{
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 719ad340a..46a524000 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -58,7 +58,9 @@ t_gui_window_tree *gui_windows_tree = NULL; /* pointer to windows tree */
t_gui_buffer *gui_buffers = NULL; /* pointer to first buffer */
t_gui_buffer *last_gui_buffer = NULL; /* pointer to last buffer */
-t_gui_buffer *buffer_before_dcc = NULL; /* buffer before dcc switch */
+t_gui_buffer *gui_buffer_before_dcc = NULL; /* buffer before dcc switch */
+t_gui_buffer *gui_buffer_raw_data = NULL; /* buffer with raw IRC data */
+t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buffer before raw switch*/
t_gui_infobar *gui_infobar; /* pointer to infobar content */
char *gui_input_clipboard = NULL; /* clipboard content */
@@ -136,10 +138,10 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height,
t_gui_window *new_window;
t_gui_window_tree *ptr_tree, *child1, *child2, *ptr_leaf;
- #ifdef DEBUG
+#ifdef DEBUG
weechat_log_printf ("Creating new window (x:%d, y:%d, width:%d, height:%d)\n",
x, y, width, height);
- #endif
+#endif
if (parent)
{
@@ -265,86 +267,6 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height,
}
/*
- * 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 (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->dcc) ? 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_servers_search: search servers buffer
* (when same buffer is used for all servers)
*/
@@ -366,42 +288,21 @@ gui_buffer_servers_search ()
}
/*
- * gui_get_dcc_buffer: get pointer to DCC buffer (DCC buffer created if not existing)
- */
-
-t_gui_buffer *
-gui_get_dcc_buffer (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->dcc)
- break;
- }
- if (ptr_buffer)
- return ptr_buffer;
- else
- return gui_buffer_new (window, NULL, NULL, 1, 0);
-}
-
-/*
* 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 dcc,
+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
+#ifdef DEBUG
weechat_log_printf ("Creating new buffer\n");
- #endif
+#endif
/* use first buffer if no server was assigned to this buffer */
- if (!dcc && gui_buffers && (!SERVER(gui_buffers)))
+ if ((type == BUFFER_TYPE_STANDARD) && gui_buffers && (!SERVER(gui_buffers)))
{
if (server)
((t_irc_server *)(server))->buffer = gui_buffers;
@@ -416,7 +317,8 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int dcc,
return gui_buffers;
}
- if (cfg_look_one_server_buffer && !dcc && gui_buffers && server && !channel)
+ if (cfg_look_one_server_buffer && (type == BUFFER_TYPE_STANDARD) &&
+ gui_buffers && server && !channel)
{
ptr_buffer = gui_buffer_servers_search ();
if (ptr_buffer)
@@ -439,7 +341,9 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int dcc,
new_buffer->server = server;
new_buffer->all_servers = 0;
new_buffer->channel = channel;
- new_buffer->dcc = dcc;
+ 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)
{
@@ -480,7 +384,7 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int dcc,
log_start (new_buffer);
/* init input buffer */
- new_buffer->has_input = (new_buffer->dcc) ? 0 : 1;
+ 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;
@@ -538,6 +442,108 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int dcc,
}
/*
+ * 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 (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_get_dcc_buffer: get pointer to DCC buffer (DCC buffer created if not existing)
+ */
+
+t_gui_buffer *
+gui_get_dcc_buffer (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
*/
@@ -652,8 +658,14 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
if (hotlist_initial_buffer == buffer)
hotlist_initial_buffer = NULL;
- if (buffer_before_dcc == buffer)
- buffer_before_dcc = 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)
@@ -717,7 +729,8 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
/* always at least one buffer */
if (!gui_buffers && create_new && switch_to_another)
- (void) gui_buffer_new (gui_windows, NULL, NULL, 0, 1);
+ (void) gui_buffer_new (gui_windows, NULL, NULL,
+ BUFFER_TYPE_STANDARD, 1);
}
/*
@@ -932,7 +945,7 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *mes
else
buffer = gui_current_window->buffer;
- if (!buffer || buffer->dcc)
+ if (!buffer || (buffer->type != BUFFER_TYPE_STANDARD))
buffer = gui_buffers;
}
@@ -943,10 +956,10 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *mes
return;
}
- if (buffer->dcc)
+ if (buffer->type == BUFFER_TYPE_DCC)
buffer = gui_buffers;
- if (buffer->dcc)
+ if (buffer->type == BUFFER_TYPE_DCC)
return;
}
@@ -1051,6 +1064,43 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *mes
free (buf2);
}
+/*
+ * gui_printf_raw_data: display raw IRC data (only if raw IRC data buffer exists)
+ */
+
+void
+gui_printf_raw_data (void *server, int send, char *message)
+{
+ char *pos;
+
+ if (gui_buffer_raw_data)
+ {
+ while (message && message[0])
+ {
+ pos = strstr (message, "\r\n");
+ if (pos)
+ pos[0] = '\0';
+ gui_printf_nolog (gui_buffer_raw_data,
+ "%s[%s%s%s] %s%s%s %s\n",
+ GUI_COLOR(COLOR_WIN_CHAT_DARK),
+ GUI_COLOR(COLOR_WIN_CHAT_SERVER),
+ ((t_irc_server *)server)->name,
+ GUI_COLOR(COLOR_WIN_CHAT_DARK),
+ GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
+ (send) ? "<<--" : "-->>",
+ GUI_COLOR(COLOR_WIN_CHAT),
+ message);
+ if (pos)
+ {
+ pos[0] = '\r';
+ message = pos + 2;
+ }
+ else
+ message = NULL;
+ }
+ }
+}
+
/*
* gui_infobar_printf: display message in infobar
*/
@@ -1174,7 +1224,8 @@ gui_optimize_input_buffer_size (t_gui_buffer *buffer)
/*
* gui_exec_action_dcc: execute an action on a DCC after a user input
- * return -1 if DCC buffer was closed due to action, 0 otherwise
+ * return -1 if DCC buffer was closed due to action,
+ * 0 otherwise
*/
void
@@ -1212,7 +1263,7 @@ gui_exec_action_dcc (t_gui_window *window, char *actions)
gui_redraw_buffer (window->buffer);
}
break;
- /* purge old DCC */
+ /* purge old DCC */
case 'p':
case 'P':
window->dcc_selected = NULL;
@@ -1226,13 +1277,13 @@ gui_exec_action_dcc (t_gui_window *window, char *actions)
}
gui_redraw_buffer (window->buffer);
break;
- /* close DCC window */
+ /* close DCC window */
case 'q':
case 'Q':
- if (buffer_before_dcc)
+ if (gui_buffer_before_dcc)
{
ptr_buffer = window->buffer;
- gui_switch_to_buffer (window, buffer_before_dcc);
+ gui_switch_to_buffer (window, gui_buffer_before_dcc);
gui_buffer_free (ptr_buffer, 0);
}
else
@@ -1240,7 +1291,7 @@ gui_exec_action_dcc (t_gui_window *window, char *actions)
gui_redraw_buffer (window->buffer);
return;
break;
- /* remove from DCC list */
+ /* remove from DCC list */
case 'r':
case 'R':
if (dcc_selected
@@ -1261,6 +1312,44 @@ gui_exec_action_dcc (t_gui_window *window, char *actions)
}
/*
+ * gui_exec_action_raw_data: execute an action on raw IRC data
+ * return -1 if raw IRC data was closed due to action,
+ * 0 otherwise
+ */
+
+void
+gui_exec_action_raw_data (t_gui_window *window, char *actions)
+{
+ t_gui_buffer *ptr_buffer;
+
+ while (actions[0])
+ {
+ if (actions[0] >= 32)
+ {
+ switch (actions[0])
+ {
+ /* close raw IRC data */
+ case 'q':
+ case 'Q':
+ if (gui_buffer_before_raw_data)
+ {
+ ptr_buffer = window->buffer;
+ gui_switch_to_buffer (window,
+ gui_buffer_before_raw_data);
+ gui_buffer_free (ptr_buffer, 0);
+ }
+ else
+ gui_buffer_free (window->buffer, 1);
+ gui_redraw_buffer (window->buffer);
+ return;
+ break;
+ }
+ }
+ actions = utf8_next_char (actions);
+ }
+}
+
+/*
* gui_insert_string_input: insert a string into the input buffer
* if pos == -1, string is inserted at cursor position
* return: number of chars inserted
@@ -1385,7 +1474,8 @@ gui_split_server (t_gui_window *window)
&& (ptr_server->buffer == ptr_buffer))
{
ptr_server->buffer = NULL;
- gui_buffer_new (window, ptr_server, NULL, 0, 0);
+ gui_buffer_new (window, ptr_server, NULL,
+ BUFFER_TYPE_STANDARD, 0);
}
}
}
@@ -1557,7 +1647,31 @@ gui_buffer_switch_dcc (t_gui_window *window)
/* check if dcc buffer exists */
for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer)
{
- if (ptr_buffer->dcc)
+ if (ptr_buffer->type == BUFFER_TYPE_DCC)
+ break;
+ }
+ if (ptr_buffer)
+ {
+ gui_switch_to_buffer (window, ptr_buffer);
+ gui_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)
@@ -1566,7 +1680,7 @@ gui_buffer_switch_dcc (t_gui_window *window)
gui_redraw_buffer (ptr_buffer);
}
else
- gui_buffer_new (window, NULL, NULL, 1, 1);
+ gui_buffer_new (window, NULL, NULL, BUFFER_TYPE_RAW_DATA, 1);
}
/*
@@ -1755,7 +1869,7 @@ gui_buffer_print_log (t_gui_buffer *buffer)
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 (" dcc. . . . . . . . . : %d\n", buffer->dcc);
+ 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);
diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c
index 762c9eade..c2c824846 100644
--- a/src/gui/gui-keyboard.c
+++ b/src/gui/gui-keyboard.c
@@ -103,6 +103,8 @@ t_gui_key_function gui_key_functions[] =
N_("jump to buffer with activity") },
{ "jump_dcc", gui_action_jump_dcc,
N_("jump to DCC buffer") },
+ { "jump_raw_data", gui_action_jump_raw_data,
+ N_("jump to raw IRC data buffer") },
{ "jump_last_buffer", gui_action_jump_last_buffer,
N_("jump to last buffer") },
{ "jump_server", gui_action_jump_server,
diff --git a/src/gui/gui.h b/src/gui/gui.h
index e9fa66dc4..aba2e9c98 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -169,6 +169,10 @@ enum t_weechat_color
#define WINDOW_MIN_WIDTH 10
#define WINDOW_MIN_HEIGHT 5
+#define BUFFER_TYPE_STANDARD 0
+#define BUFFER_TYPE_DCC 1
+#define BUFFER_TYPE_RAW_DATA 2
+
#define NOTIFY_LEVEL_MIN 0
#define NOTIFY_LEVEL_MAX 3
#define NOTIFY_LEVEL_DEFAULT NOTIFY_LEVEL_MAX
@@ -225,7 +229,8 @@ struct t_gui_buffer
void *server; /* buffer's server */
int all_servers; /* =1 if all servers are displayed here */
void *channel; /* buffer's channel */
- int dcc; /* buffer is dcc status */
+ int type; /* type: standard (server/channel/pv), */
+ /* dcc or raw data */
/* chat content (lines, line is composed by many messages) */
t_gui_line *lines; /* lines of chat window */
@@ -384,7 +389,9 @@ extern t_gui_window *gui_current_window;
extern t_gui_window_tree *gui_windows_tree;
extern t_gui_buffer *gui_buffers;
extern t_gui_buffer *last_gui_buffer;
-extern t_gui_buffer *buffer_before_dcc;
+extern t_gui_buffer *gui_buffer_before_dcc;
+extern t_gui_buffer *gui_buffer_raw_data;
+extern t_gui_buffer *gui_buffer_before_raw_data;
extern t_gui_infobar *gui_infobar;
extern t_gui_key *gui_keys;
extern t_gui_key *last_gui_key;
@@ -402,10 +409,10 @@ 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 t_gui_buffer *gui_buffer_new (t_gui_window *, void *, void *, int, int);
extern void gui_buffer_clear (t_gui_buffer *);
extern void gui_buffer_clear_all ();
extern void gui_window_free (t_gui_window *);
@@ -418,8 +425,10 @@ 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 *, ...);
+extern void gui_printf_raw_data (void *, int, char *);
extern void gui_optimize_input_buffer_size (t_gui_buffer *);
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 *);
@@ -430,6 +439,7 @@ 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_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 *);
@@ -469,6 +479,7 @@ extern void gui_action_nick_page_up (t_gui_window *);
extern void gui_action_nick_page_down (t_gui_window *);
extern void gui_action_jump_smart (t_gui_window *);
extern void gui_action_jump_dcc (t_gui_window *);
+extern void gui_action_jump_raw_data (t_gui_window *);
extern void gui_action_jump_last_buffer (t_gui_window *);
extern void gui_action_jump_server (t_gui_window *);
extern void gui_action_jump_next_server (t_gui_window *);
diff --git a/src/irc/irc-channel.c b/src/irc/irc-channel.c
index fbff9d67d..84a7c2fb4 100644
--- a/src/irc/irc-channel.c
+++ b/src/irc/irc-channel.c
@@ -384,7 +384,8 @@ channel_create_dcc (t_irc_dcc *ptr_dcc)
ptr_dcc->nick);
if (!ptr_channel)
return 0;
- gui_buffer_new (gui_current_window, ptr_dcc->server, ptr_channel, 0, 0);
+ gui_buffer_new (gui_current_window, ptr_dcc->server, ptr_channel,
+ BUFFER_TYPE_STANDARD, 0);
if (ptr_channel->dcc_chat &&
(!DCC_ENDED(((t_irc_dcc *)(ptr_channel->dcc_chat))->status)))
diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c
index e74bdcdb3..a6b539d5f 100644
--- a/src/irc/irc-recv.c
+++ b/src/irc/irc-recv.c
@@ -402,7 +402,8 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *nick, char *arguments
WEECHAT_ERROR, arguments);
return -1;
}
- gui_buffer_new (gui_current_window, server, ptr_channel, 0, 1);
+ gui_buffer_new (gui_current_window, server, ptr_channel,
+ BUFFER_TYPE_STANDARD, 1);
}
if (!command_ignored)
@@ -1234,7 +1235,8 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen
WEECHAT_ERROR, nick);
return -1;
}
- gui_buffer_new (gui_current_window, server, ptr_channel, 0, 0);
+ gui_buffer_new (gui_current_window, server, ptr_channel,
+ BUFFER_TYPE_STANDARD, 0);
}
if (!ptr_channel->topic)
ptr_channel->topic = strdup ((host2) ? host2 : "");
@@ -2050,7 +2052,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
WEECHAT_ERROR, nick);
return -1;
}
- gui_buffer_new (gui_current_window, server, ptr_channel, 0, 0);
+ gui_buffer_new (gui_current_window, server, ptr_channel,
+ BUFFER_TYPE_STANDARD, 0);
}
if (!ptr_channel->topic)
ptr_channel->topic = strdup (host2);
@@ -2142,7 +2145,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume
WEECHAT_ERROR, nick);
return -1;
}
- gui_buffer_new (gui_current_window, server, ptr_channel, 0, 0);
+ gui_buffer_new (gui_current_window, server, ptr_channel,
+ BUFFER_TYPE_STANDARD, 0);
}
if (!ptr_channel->topic)
ptr_channel->topic = strdup (host2);
diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c
index 81890211e..591ab496f 100644
--- a/src/irc/irc-send.c
+++ b/src/irc/irc-send.c
@@ -1232,7 +1232,8 @@ irc_cmd_send_msg (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, arguments);
return -1;
}
- gui_buffer_new (window, server, ptr_channel, 0, 1);
+ gui_buffer_new (window, server, ptr_channel,
+ BUFFER_TYPE_STANDARD, 1);
gui_draw_buffer_title (ptr_channel->buffer, 1);
}
@@ -1603,7 +1604,8 @@ irc_cmd_send_query (t_irc_server *server, t_irc_channel *channel,
WEECHAT_ERROR, arguments);
return -1;
}
- gui_buffer_new (window, server, ptr_channel, 0, 1);
+ gui_buffer_new (window, server, ptr_channel,
+ BUFFER_TYPE_STANDARD, 1);
gui_draw_buffer_title (ptr_channel->buffer, 1);
}
else
diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c
index 1f5d4dda3..7c00e4687 100644
--- a/src/irc/irc-server.c
+++ b/src/irc/irc-server.c
@@ -552,11 +552,14 @@ server_sendf (t_irc_server *server, char *fmt, ...)
buffer[sizeof (buffer) - 1] = '\0';
if ((size_buf < 0) || (size_buf > (int) (sizeof (buffer) - 1)))
size_buf = strlen (buffer);
-#ifdef DEBUG
+
buffer[size_buf - 2] = '\0';
+ gui_printf_raw_data (server, 1, buffer);
+#ifdef DEBUG
gui_printf (server->buffer, "[DEBUG] Sending to server >>> %s\n", buffer);
- buffer[size_buf - 2] = '\r';
#endif
+ buffer[size_buf - 2] = '\r';
+
if (server_send (server, buffer, strlen (buffer)) <= 0)
{
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
@@ -726,6 +729,7 @@ server_msgq_flush ()
if (ptr_data && ptr_data[0])
{
+ gui_printf_raw_data (recv_msgq->server, 0, ptr_data);
#ifdef DEBUG
gui_printf (NULL, "[DEBUG] data received from server: %s\n", ptr_data);
#endif
@@ -1633,7 +1637,8 @@ server_auto_connect (int auto_connect, int command_line)
if ( ((command_line) && (ptr_server->command_line))
|| ((!command_line) && (auto_connect) && (ptr_server->autoconnect)) )
{
- (void) gui_buffer_new (gui_current_window, ptr_server, NULL, 0, 1);
+ (void) gui_buffer_new (gui_current_window, ptr_server, NULL,
+ BUFFER_TYPE_STANDARD, 1);
gui_redraw_buffer (gui_current_window->buffer);
if (!server_connect (ptr_server))
server_reconnect_schedule (ptr_server);