diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2004-12-31 15:59:58 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2004-12-31 15:59:58 +0000 |
commit | de5af8a3b107c276de0dd0ebd57bfadee694b003 (patch) | |
tree | b265362274aa5cbfe554b86e8e0223685c536b83 /src | |
parent | 37a2f80fae6c096e599532b194349dd1f2324026 (diff) | |
download | weechat-de5af8a3b107c276de0dd0ebd57bfadee694b003.zip |
Added /buffer close, new keys: Alt-S (switch to server buffer), Alt-X (switch to first channel of next server)
Diffstat (limited to 'src')
-rw-r--r-- | src/common/command.c | 32 | ||||
-rw-r--r-- | src/common/weeconfig.c | 1 | ||||
-rw-r--r-- | src/gui/curses/gui-input.c | 41 | ||||
-rw-r--r-- | src/irc/irc-commands.c | 3 | ||||
-rw-r--r-- | src/irc/irc-server.c | 1 |
5 files changed, 73 insertions, 5 deletions
diff --git a/src/common/command.c b/src/common/command.c index bcb7899fe..be9702132 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -47,6 +47,7 @@ t_weechat_command weechat_commands[] = N_("[action | number]"), N_("action: action to do:\n" " move move buffer in the list (may be relative, for example -1)\n" + " close close buffer (for channel: same as /part without part message)\n" " list list opened buffers (no parameter implies this list)\n" " notify set notify level for buffer (0=never, 1=highlight, 2=1+msg, 3=2+join/part)\n" "number: jump to buffer by number"), @@ -834,6 +835,7 @@ int weechat_cmd_buffer (int argc, char **argv) { t_gui_buffer *ptr_buffer; + t_irc_server *ptr_server; long number; char *error; @@ -916,6 +918,36 @@ weechat_cmd_buffer (int argc, char **argv) return -1; } } + else if (strcasecmp (argv[0], "close") == 0) + { + /* close buffer (server or channel/private) */ + + if ((!gui_current_window->buffer->next_buffer) + && (gui_current_window->buffer == gui_buffers)) + { + gui_printf (gui_current_window->buffer, + _("%s can not close the single buffer\n"), + WEECHAT_ERROR); + return -1; + } + if (BUFFER_IS_SERVER(gui_current_window->buffer)) + { + if (SERVER(gui_current_window->buffer)->channels) + { + gui_printf (gui_current_window->buffer, + _("%s can not close server buffer while channels " + "are opened\n"), + WEECHAT_ERROR); + return -1; + } + server_disconnect (SERVER(gui_current_window->buffer), 0); + ptr_server = SERVER(gui_current_window->buffer); + gui_buffer_free (gui_current_window->buffer, 1); + ptr_server->buffer = NULL; + } + else + irc_cmd_send_part (SERVER(gui_current_window->buffer), NULL); + } else if (strcasecmp (argv[0], "notify") == 0) { /* set notify level for buffer */ diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index e3c0ca190..746ad44df 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -1189,6 +1189,7 @@ config_create_default () fprintf (file, "SIGNOFF=quit\n"); fprintf (file, "C=clear\n"); fprintf (file, "CL=clear\n"); + fprintf (file, "CLOSE=buffer close\n"); fprintf (file, "# CHAT=dcc chat\n"); fprintf (file, "# GET=dcc get\n"); fprintf (file, "# IG=ignore\n"); diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c index 6c805742b..4cc4dff8f 100644 --- a/src/gui/curses/gui-input.c +++ b/src/gui/curses/gui-input.c @@ -51,6 +51,7 @@ gui_read_keyb () { int key, i; t_gui_buffer *ptr_buffer; + t_irc_server *ptr_server; char new_char[2]; t_dcc *dcc_selected; @@ -417,7 +418,7 @@ gui_read_keyb () } } break; - /* Alt-number */ + /* Alt-number: jump to window by number */ case 48: /* Alt-0 */ case 49: /* Alt-1 */ case 50: /* Alt-2 */ @@ -430,7 +431,7 @@ gui_read_keyb () case 57: /* Alt-9 */ gui_switch_to_buffer_by_number (gui_current_window, (key == 48) ? 10 : key - 48); break; - /* Alt-A */ + /* Alt-A: jump to buffer with activity */ case 'a': case 'A': if (hotlist) @@ -450,7 +451,7 @@ gui_read_keyb () } } break; - /* Alt-D */ + /* Alt-D: jump to DCC buffer */ case 'd': case 'D': if (gui_current_window->buffer->dcc) @@ -468,7 +469,7 @@ gui_read_keyb () gui_switch_to_dcc_buffer (); } break; - /* Alt-R */ + /* Alt-R: clear hotlist */ case 'r': case 'R': if (hotlist) @@ -478,6 +479,38 @@ gui_read_keyb () } hotlist_initial_buffer = gui_current_window->buffer; break; + /* Alt-S: jump to server buffer */ + case 's': + case 'S': + if (SERVER(gui_current_window->buffer)->buffer != + gui_current_window->buffer) + { + gui_switch_to_buffer (gui_current_window, + SERVER(gui_current_window->buffer)->buffer); + gui_redraw_buffer (gui_current_window->buffer); + } + break; + /* Alt-X: jump to first channel/private of next server */ + case 'x': + case 'X': + ptr_server = SERVER(gui_current_window->buffer)->next_server; + if (!ptr_server) + ptr_server = irc_servers; + while (ptr_server != SERVER(gui_current_window->buffer)) + { + if (ptr_server->buffer) + break; + ptr_server = (ptr_server->next_server) ? + ptr_server->next_server : irc_servers; + } + if (ptr_server != SERVER(gui_current_window->buffer)) + { + ptr_buffer = (ptr_server->channels) ? + ptr_server->channels->buffer : ptr_server->buffer; + gui_switch_to_buffer (gui_current_window, ptr_buffer); + gui_redraw_buffer (gui_current_window->buffer); + } + break; } } break; diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c index 0137257d7..59a6c9b40 100644 --- a/src/irc/irc-commands.c +++ b/src/irc/irc-commands.c @@ -151,7 +151,8 @@ t_irc_command irc_commands[] = N_("user/password: used to get privileges on current IRC server"), 2, 2, 1, NULL, irc_cmd_send_oper, NULL }, { "part", N_("leave a channel"), - N_("[channel[,channel]]"), N_("channel: channel name to leave"), + N_("[channel[,channel]] [part_message]"), N_("channel: channel name to leave\n" + "part_message: part message (displayed to other users)"), 0, MAX_ARGS, 1, NULL, irc_cmd_send_part, irc_cmd_recv_part }, { "ping", N_("ping server"), N_("server1 [server2]"), diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c index c5666403a..fb8f91e85 100644 --- a/src/irc/irc-server.c +++ b/src/irc/irc-server.c @@ -802,6 +802,7 @@ server_disconnect (t_irc_server *server, int reconnect) server->sock4 = -1; server->is_connected = 0; + server->is_away = 0; if ((reconnect) && (server->autoreconnect)) { |