diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-10-30 09:56:24 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-10-30 09:56:24 +0000 |
commit | 079e4a40281c6e8802885d1331f4c0217addaa19 (patch) | |
tree | 5137fffc0ca6ad208fc076cbd0b9c866dce57bf2 /src/gui/curses | |
parent | 24ceb3bb95f41b938a4ac1d10fb36cdd33381bf3 (diff) | |
download | weechat-079e4a40281c6e8802885d1331f4c0217addaa19.zip |
- added new setting (look_one_server_buffer): use same buffer for all servers
- fixed DCC bug when looking for ports in range
Diffstat (limited to 'src/gui/curses')
-rw-r--r-- | src/gui/curses/Makefile.am | 1 | ||||
-rw-r--r-- | src/gui/curses/gui-display.c | 138 | ||||
-rw-r--r-- | src/gui/curses/gui-input.c | 11 |
3 files changed, 79 insertions, 71 deletions
diff --git a/src/gui/curses/Makefile.am b/src/gui/curses/Makefile.am index 76b5b5f92..3466970b8 100644 --- a/src/gui/curses/Makefile.am +++ b/src/gui/curses/Makefile.am @@ -20,6 +20,7 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" bin_PROGRAMS = weechat-curses weechat_curses_LDADD = ../gui-common.o ../gui-keyboard.o \ + ../gui-action.o \ ../../common/lib_weechat_main.a \ ../../irc/lib_weechat_irc.a \ $(PLUGINS_LIBS) \ diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index 895f3c2bd..8c2897a90 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -1222,8 +1222,8 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) { t_gui_window *ptr_win; t_weechat_hotlist *ptr_hotlist; - char format[32], str_nicks[32], *string; - int i, first_mode, x; + char format[32], str_nicks[32], *more; + int i, first_mode, x, server_pos, server_total; int display_name, names_count; /* make gcc happy */ @@ -1256,27 +1256,31 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "] "); - /* display current server */ - if (SERVER(ptr_win->buffer) && SERVER(ptr_win->buffer)->name) + /* display "<servers>" or current server */ + if (ptr_win->buffer->all_servers) + { + wprintw (ptr_win->win_status, "["); + gui_window_set_color (ptr_win->win_status, + COLOR_WIN_STATUS); + wprintw (ptr_win->win_status, _("<servers>")); + gui_window_set_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_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) - { - string = weechat_convert_encoding ((local_utf8) ? - cfg_look_charset_decode_iso : cfg_look_charset_decode_utf, - (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset, - _("(away)")); - wprintw (ptr_win->win_status, string); - free (string); - } + wprintw (ptr_win->win_status, _("(away)")); gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "] "); } + + /* infos about current buffer */ if (SERVER(ptr_win->buffer) && !CHANNEL(ptr_win->buffer)) { gui_window_set_color (ptr_win->win_status, @@ -1294,6 +1298,28 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) 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_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); + wprintw (ptr_win->win_status, "("); + gui_window_set_color (ptr_win->win_status, + COLOR_WIN_STATUS); + wprintw (ptr_win->win_status, "%d", server_pos); + gui_window_set_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); + wprintw (ptr_win->win_status, "/"); + gui_window_set_color (ptr_win->win_status, + COLOR_WIN_STATUS); + wprintw (ptr_win->win_status, "%d", server_total); + gui_window_set_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); + wprintw (ptr_win->win_status, ") "); + + } } if (SERVER(ptr_win->buffer) && CHANNEL(ptr_win->buffer)) { @@ -1382,15 +1408,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) if (ptr_win->buffer->dcc) wprintw (ptr_win->win_status, "<DCC> "); else - { - string = weechat_convert_encoding ((local_utf8) ? - cfg_look_charset_decode_iso : cfg_look_charset_decode_utf, - (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset, - _("[not connected]")); - wprintw (ptr_win->win_status, "%s " , string); - free (string); - } + wprintw (ptr_win->win_status, _("[not connected] ")); } /* display list of other active windows (if any) with numbers */ @@ -1400,13 +1418,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "["); gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS); - string = weechat_convert_encoding ((local_utf8) ? - cfg_look_charset_decode_iso : cfg_look_charset_decode_utf, - (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset, - _("Act: ")); - wprintw (ptr_win->win_status, string); - free (string); + wprintw (ptr_win->win_status, _("Act: ")); names_count = 0; for (ptr_hotlist = hotlist; ptr_hotlist; @@ -1494,14 +1506,8 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "["); gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS); - string = weechat_convert_encoding ((local_utf8) ? - cfg_look_charset_decode_iso : cfg_look_charset_decode_utf, - (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset, - _("Lag: %.1f")); - wprintw (ptr_win->win_status, string, + wprintw (ptr_win->win_status, _("Lag: %.1f"), ((float)(SERVER(ptr_win->buffer)->lag)) / 1000); - free (string); gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "]"); @@ -1516,20 +1522,16 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) } else x = ptr_win->win_width - 2; - string = weechat_convert_encoding ((local_utf8) ? - cfg_look_charset_decode_iso : cfg_look_charset_decode_utf, - (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset, - _("-MORE-")); - x -= strlen (string) - 1; + more = strdup (_("-MORE-")); + x -= strlen (more) - 1; if (x < 0) x = 0; gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE); if (ptr_win->start_line) - mvwprintw (ptr_win->win_status, 0, x, "%s", string); + mvwprintw (ptr_win->win_status, 0, x, "%s", more); else { - snprintf (format, sizeof (format) - 1, "%%-%ds", (int)(strlen (string))); + snprintf (format, sizeof (format) - 1, "%%-%ds", (int)(strlen (more))); mvwprintw (ptr_win->win_status, 0, x, format, " "); } if (gui_buffer_has_nicklist (ptr_win->buffer)) @@ -1543,7 +1545,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "]"); } - free (string); + free (more); wnoutrefresh (ptr_win->win_status); refresh (); @@ -1778,8 +1780,8 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase) wprintw (ptr_win->win_input, format, ""); wclrtoeol (ptr_win->win_input); - ptr_win->win_input_x = strlen (CHANNEL(buffer)->name) + - strlen (SERVER(buffer)->nick) + 3 + + ptr_win->win_input_x = utf8_strlen (CHANNEL(buffer)->name) + + utf8_strlen (SERVER(buffer)->nick) + 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, @@ -1805,7 +1807,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase) wprintw (ptr_win->win_input, format, ""); wclrtoeol (ptr_win->win_input); - ptr_win->win_input_x = strlen (ptr_nickname) + 2 + + ptr_win->win_input_x = utf8_strlen (ptr_nickname) + 2 + (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, @@ -1966,11 +1968,11 @@ gui_get_dcc_buffer (t_gui_window *window) } /* - * gui_input_page_up: display previous page on buffer + * gui_window_page_up: display previous page on buffer */ void -gui_input_page_up (t_gui_window *window) +gui_window_page_up (t_gui_window *window) { if (!gui_ok) return; @@ -1988,11 +1990,11 @@ gui_input_page_up (t_gui_window *window) } /* - * gui_input_page_down: display next page on buffer + * gui_window_page_down: display next page on buffer */ void -gui_input_page_down (t_gui_window *window) +gui_window_page_down (t_gui_window *window) { t_gui_line *ptr_line; int line_pos; @@ -2024,11 +2026,11 @@ gui_input_page_down (t_gui_window *window) } /* - * gui_input_nick_beginning: go to beginning of nicklist + * gui_window_nick_beginning: go to beginning of nicklist */ void -gui_input_nick_beginning (t_gui_window *window) +gui_window_nick_beginning (t_gui_window *window) { if (!gui_ok) return; @@ -2044,11 +2046,11 @@ gui_input_nick_beginning (t_gui_window *window) } /* - * gui_input_nick_end: go to the end of nicklist + * gui_window_nick_end: go to the end of nicklist */ void -gui_input_nick_end (t_gui_window *window) +gui_window_nick_end (t_gui_window *window) { int new_start; @@ -2073,11 +2075,11 @@ gui_input_nick_end (t_gui_window *window) } /* - * gui_input_nick_page_up: scroll one page up in nicklist + * gui_window_nick_page_up: scroll one page up in nicklist */ void -gui_input_nick_page_up (t_gui_window *window) +gui_window_nick_page_up (t_gui_window *window) { if (!gui_ok) return; @@ -2095,11 +2097,11 @@ gui_input_nick_page_up (t_gui_window *window) } /* - * gui_input_nick_page_down: scroll one page down in nicklist + * gui_window_nick_page_down: scroll one page down in nicklist */ void -gui_input_nick_page_down (t_gui_window *window) +gui_window_nick_page_down (t_gui_window *window) { if (!gui_ok) return; @@ -2120,7 +2122,7 @@ gui_input_nick_page_down (t_gui_window *window) } /* - * gui_window_init_subviews: init subviews for a WeeChat window + * gui_window_init_subwindows: init subviews for a WeeChat window */ void @@ -2363,11 +2365,11 @@ gui_window_merge_all (t_gui_window *window) } /* - * gui_curses_resize_handler: called when term size is modified + * gui_refresh_screen: called when term size is modified */ void -gui_curses_resize_handler () +gui_refresh_screen () { t_gui_window *ptr_win, *old_current_window; int old_width, old_height; @@ -2460,6 +2462,8 @@ gui_init_colors () cfg_col_chat_prefix1, cfg_col_chat_bg); init_pair (COLOR_WIN_CHAT_PREFIX2, cfg_col_chat_prefix2, cfg_col_chat_bg); + init_pair (COLOR_WIN_CHAT_SERVER, + cfg_col_chat_server, cfg_col_chat_bg); init_pair (COLOR_WIN_CHAT_JOIN, cfg_col_chat_join, cfg_col_chat_bg); init_pair (COLOR_WIN_CHAT_PART, @@ -2555,6 +2559,7 @@ gui_init_colors () color_attr[COLOR_WIN_CHAT_DARK - 1] = (cfg_col_chat_dark >= 0) ? cfg_col_chat_dark & A_BOLD : 0; color_attr[COLOR_WIN_CHAT_PREFIX1 - 1] = (cfg_col_chat_prefix1 >= 0) ? cfg_col_chat_prefix1 & A_BOLD : 0; color_attr[COLOR_WIN_CHAT_PREFIX2 - 1] = (cfg_col_chat_prefix2 >= 0) ? cfg_col_chat_prefix2 & A_BOLD : 0; + color_attr[COLOR_WIN_CHAT_SERVER - 1] = (cfg_col_chat_server >= 0) ? cfg_col_chat_server & A_BOLD : 0; color_attr[COLOR_WIN_CHAT_JOIN - 1] = (cfg_col_chat_join >= 0) ? cfg_col_chat_join & A_BOLD : 0; color_attr[COLOR_WIN_CHAT_PART - 1] = (cfg_col_chat_part >= 0) ? cfg_col_chat_part & A_BOLD : 0; color_attr[COLOR_WIN_CHAT_NICK - 1] = (cfg_col_chat_nick >= 0) ? cfg_col_chat_nick & A_BOLD : 0; @@ -2642,7 +2647,7 @@ gui_init () gui_current_window = gui_windows; gui_buffer_new (gui_windows, NULL, NULL, 0, 1); - signal (SIGWINCH, gui_curses_resize_handler); + signal (SIGWINCH, gui_refresh_screen); if (cfg_look_set_title) gui_set_window_title (); @@ -2809,13 +2814,14 @@ gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, int color else buffer = gui_current_window->buffer; - if (buffer->dcc) + if (!buffer || buffer->dcc) buffer = gui_buffers; } if (buffer == NULL) { - wee_log_printf ("gui_printf without buffer! this is a bug, please send to developers - thanks\n"); + wee_log_printf ("WARNING: gui_printf_internal without buffer! This is a bug, " + "please send to developers - thanks\n"); return; } diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c index 3993f7ad7..66c675d61 100644 --- a/src/gui/curses/gui-input.c +++ b/src/gui/curses/gui-input.c @@ -105,6 +105,7 @@ gui_input_default_key_bindings () 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-r */ "meta-r", "delete_line"); + gui_key_bind ( /* m-s */ "meta-s", "switch_server"); /* keys binded with commands */ gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); @@ -149,7 +150,7 @@ gui_input_grab_end () { if (gui_current_window->buffer->has_input) { - gui_input_insert_string (gui_current_window, expanded_key, -1); + gui_insert_string_input (gui_current_window, expanded_key, -1); gui_current_window->buffer->input_buffer_pos += strlen (expanded_key); gui_draw_buffer_input (gui_current_window->buffer, 1); } @@ -192,7 +193,7 @@ gui_input_read () if (key == KEY_RESIZE) { - gui_curses_resize_handler (); + gui_refresh_screen (); continue; } @@ -265,10 +266,10 @@ gui_input_read () key_str[1] = '\0'; if (gui_current_window->buffer->dcc) - gui_input_action_dcc (gui_current_window, key_str); + gui_exec_action_dcc (gui_current_window, key_str); else { - gui_input_insert_string (gui_current_window, key_str, -1); + 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; @@ -408,7 +409,7 @@ gui_main_loop () diff = (int) get_timeval_diff (&(ptr_server->lag_check_time), &tv); if (diff / 1000 > cfg_irc_lag_disconnect * 60) { - irc_display_prefix (ptr_server->buffer, PREFIX_ERROR); + 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); |