1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-10 11:43:13 +02:00

Remove old title/nicklist/status/input, use of new bars

This commit is contained in:
Sebastien Helleu
2008-10-12 19:20:26 +02:00
parent f6073c8076
commit c83eef6e82
48 changed files with 274 additions and 2447 deletions
+1 -2
View File
@@ -19,8 +19,7 @@ if(COMMAND cmake_policy)
endif(COMMAND cmake_policy)
SET(WEECHAT_CURSES_SRC gui-curses-bar.c gui-curses-chat.c gui-curses-color.c
gui-curses-input.c gui-curses-keyboard.c gui-curses-main.c
gui-curses-nicklist.c gui-curses-status.c gui-curses-window.c gui-curses.h)
gui-curses-keyboard.c gui-curses-main.c gui-curses-window.c gui-curses.h)
SET(EXECUTABLE weechat-curses)
-3
View File
@@ -31,10 +31,7 @@ weechat_curses_LDADD = ./../../core/lib_weechat_core.a \
weechat_curses_SOURCES = gui-curses-bar.c \
gui-curses-chat.c \
gui-curses-color.c \
gui-curses-input.c \
gui-curses-keyboard.c \
gui-curses-main.c \
gui-curses-nicklist.c \
gui-curses-status.c \
gui-curses-window.c \
gui-curses.h
+18 -95
View File
@@ -42,91 +42,6 @@
#include "gui-curses.h"
/*
* gui_chat_draw_title: draw title window for a buffer
*/
void
gui_chat_draw_title (struct t_gui_buffer *buffer, int erase)
{
struct t_gui_window *ptr_win;
char format[32], *buf, *title_decoded, *ptr_title;
if (!gui_ok)
return;
title_decoded = (buffer->title) ?
(char *)gui_color_decode ((unsigned char *)buffer->title) : NULL;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
{
if (erase)
gui_window_clear_weechat (GUI_CURSES(ptr_win)->win_title,
GUI_COLOR_TITLE);
snprintf (format, sizeof (format), "%%-%ds", ptr_win->win_title_width);
wmove (GUI_CURSES(ptr_win)->win_title, 0, 0);
if (title_decoded)
{
ptr_title = utf8_add_offset (title_decoded,
ptr_win->win_title_start);
if (!ptr_title || !ptr_title[0])
{
ptr_win->win_title_start = 0;
ptr_title = title_decoded;
}
buf = string_iconv_from_internal (NULL,
ptr_title);
if (buf)
ptr_title = buf;
if (ptr_win->win_title_start > 0)
{
//gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
// GUI_COLOR_TITLE_MORE);
wprintw (GUI_CURSES(ptr_win)->win_title, "%s", "++");
}
if (utf8_strlen_screen (ptr_title) > ptr_win->win_width)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
GUI_COLOR_TITLE);
wprintw (GUI_CURSES(ptr_win)->win_title, "%s", ptr_title);
//gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
// GUI_COLOR_TITLE_MORE);
mvwprintw (GUI_CURSES(ptr_win)->win_title, 0,
ptr_win->win_width - 2,
"%s", "++");
}
else
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
GUI_COLOR_TITLE);
wprintw (GUI_CURSES(ptr_win)->win_title, "%s", ptr_title);
}
if (buf)
free (buf);
}
else
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_title,
GUI_COLOR_TITLE);
wprintw (GUI_CURSES(ptr_win)->win_title, format, " ");
}
wnoutrefresh (GUI_CURSES(ptr_win)->win_title);
refresh ();
}
}
if (title_decoded)
free (title_decoded);
buffer->title_refresh_needed = 0;
}
/*
* gui_chat_get_real_width: return real width: width - 1 if nicklist is at right,
* for good copy/paste (without nicklist separator)
@@ -417,13 +332,15 @@ gui_chat_string_next_char (struct t_gui_window *window,
/*
* gui_chat_display_word_raw: display word on chat buffer, letter by letter
* special chars like color, bold, .. are interpreted
* return number of chars displayed on screen
*/
void
int
gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
int max_chars_on_screen, int display)
{
char *next_char, *output, utf_char[16], chars_displayed, size_on_screen;
char *next_char, *output, utf_char[16];
int chars_displayed, size_on_screen;
if (display)
wmove (GUI_CURSES(window)->win_chat,
@@ -437,7 +354,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
string = gui_chat_string_next_char (window,
(unsigned char *)string, 1);
if (!string)
return;
return chars_displayed;
next_char = utf8_next_char (string);
if (display && next_char)
@@ -450,7 +367,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
if (max_chars_on_screen > 0)
{
if (chars_displayed + size_on_screen > max_chars_on_screen)
return;
return chars_displayed;
chars_displayed += size_on_screen;
}
if (size_on_screen > 0)
@@ -467,7 +384,7 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
if (max_chars_on_screen > 0)
{
if (chars_displayed + 1 > max_chars_on_screen)
return;
return chars_displayed;
chars_displayed++;
}
wprintw (GUI_CURSES(window)->win_chat, ".");
@@ -476,6 +393,8 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
string = next_char;
}
return chars_displayed;
}
/*
@@ -971,10 +890,11 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
window->win_chat_cursor_x);
wclrtoeol (GUI_CURSES(window)->win_chat);
gui_chat_display_word_raw (window, line->message,
window->win_chat_width, 1);
gui_window_clrtoeol_with_current_bg (GUI_CURSES(window)->win_chat);
if (gui_chat_display_word_raw (window, line->message,
window->win_chat_width, 1) < window->win_chat_width)
{
gui_window_clrtoeol_with_current_bg (GUI_CURSES(window)->win_chat);
}
}
/*
@@ -1196,7 +1116,7 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
WEECHAT_HOOK_SIGNAL_POINTER, ptr_win);
}
if (!ptr_win->scroll)
if (!ptr_win->scroll && ptr_win->scroll_reset_allowed)
{
ptr_win->start_line = NULL;
ptr_win->start_line_pos = 0;
@@ -1209,6 +1129,9 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
ptr_win->win_chat_cursor_x = 0;
ptr_win->win_chat_cursor_y = ptr_win->win_chat_height - 1;
}
ptr_win->scroll_reset_allowed = 0;
break;
case GUI_BUFFER_TYPE_FREE:
/* display at position of scrolling */
-31
View File
@@ -356,8 +356,6 @@ gui_color_init_weechat ()
gui_color_build (GUI_COLOR_SEPARATOR, CONFIG_COLOR(config_color_separator), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_TITLE, CONFIG_COLOR(config_color_title), CONFIG_COLOR(config_color_title_bg));
gui_color_build (GUI_COLOR_CHAT, CONFIG_COLOR(config_color_chat), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_CHAT_TIME, CONFIG_COLOR(config_color_chat_time), CONFIG_COLOR(config_color_chat_bg));
gui_color_build (GUI_COLOR_CHAT_TIME_DELIMITERS, CONFIG_COLOR(config_color_chat_time_delimiters), CONFIG_COLOR(config_color_chat_bg));
@@ -383,35 +381,6 @@ gui_color_init_weechat ()
gui_color_build (GUI_COLOR_CHAT_HIGHLIGHT, CONFIG_COLOR(config_color_chat_highlight), CONFIG_COLOR(config_color_chat_highlight_bg));
gui_color_build (GUI_COLOR_CHAT_READ_MARKER, CONFIG_COLOR(config_color_chat_read_marker), CONFIG_COLOR(config_color_chat_read_marker_bg));
gui_color_build (GUI_COLOR_CHAT_TEXT_FOUND, CONFIG_COLOR(config_color_chat_text_found), CONFIG_COLOR(config_color_chat_text_found_bg));
gui_color_build (GUI_COLOR_STATUS, CONFIG_COLOR(config_color_status), CONFIG_COLOR(config_color_status_bg));
gui_color_build (GUI_COLOR_STATUS_DELIMITERS, CONFIG_COLOR(config_color_status_delimiters), CONFIG_COLOR(config_color_status_bg));
gui_color_build (GUI_COLOR_STATUS_NUMBER, CONFIG_COLOR(config_color_status_number), CONFIG_COLOR(config_color_status_bg));
gui_color_build (GUI_COLOR_STATUS_NAME, CONFIG_COLOR(config_color_status_name), CONFIG_COLOR(config_color_status_bg));
gui_color_build (GUI_COLOR_STATUS_DATA_MSG, CONFIG_COLOR(config_color_status_data_msg), CONFIG_COLOR(config_color_status_bg));
gui_color_build (GUI_COLOR_STATUS_DATA_PRIVATE, CONFIG_COLOR(config_color_status_data_private), CONFIG_COLOR(config_color_status_bg));
gui_color_build (GUI_COLOR_STATUS_DATA_HIGHLIGHT, CONFIG_COLOR(config_color_status_data_highlight), CONFIG_COLOR(config_color_status_bg));
gui_color_build (GUI_COLOR_STATUS_DATA_OTHER, CONFIG_COLOR(config_color_status_data_other), CONFIG_COLOR(config_color_status_bg));
gui_color_build (GUI_COLOR_STATUS_MORE, CONFIG_COLOR(config_color_status_more), CONFIG_COLOR(config_color_status_bg));
gui_color_build (GUI_COLOR_INPUT, CONFIG_COLOR(config_color_input), CONFIG_COLOR(config_color_input_bg));
gui_color_build (GUI_COLOR_INPUT_SERVER, CONFIG_COLOR(config_color_input_server), CONFIG_COLOR(config_color_input_bg));
gui_color_build (GUI_COLOR_INPUT_CHANNEL, CONFIG_COLOR(config_color_input_channel), CONFIG_COLOR(config_color_input_bg));
gui_color_build (GUI_COLOR_INPUT_NICK, CONFIG_COLOR(config_color_input_nick), CONFIG_COLOR(config_color_input_bg));
gui_color_build (GUI_COLOR_INPUT_DELIMITERS, CONFIG_COLOR(config_color_input_delimiters), CONFIG_COLOR(config_color_input_bg));
gui_color_build (GUI_COLOR_INPUT_TEXT_NOT_FOUND, CONFIG_COLOR(config_color_input_text_not_found), CONFIG_COLOR(config_color_input_bg));
gui_color_build (GUI_COLOR_INPUT_ACTIONS, CONFIG_COLOR(config_color_input_actions), CONFIG_COLOR(config_color_input_bg));
gui_color_build (GUI_COLOR_NICKLIST, CONFIG_COLOR(config_color_nicklist), CONFIG_COLOR(config_color_nicklist_bg));
gui_color_build (GUI_COLOR_NICKLIST_GROUP, CONFIG_COLOR(config_color_nicklist_group), CONFIG_COLOR(config_color_nicklist_bg));
gui_color_build (GUI_COLOR_NICKLIST_AWAY, CONFIG_COLOR(config_color_nicklist_away), CONFIG_COLOR(config_color_nicklist_bg));
gui_color_build (GUI_COLOR_NICKLIST_PREFIX1, CONFIG_COLOR(config_color_nicklist_prefix1), CONFIG_COLOR(config_color_nicklist_bg));
gui_color_build (GUI_COLOR_NICKLIST_PREFIX2, CONFIG_COLOR(config_color_nicklist_prefix2), CONFIG_COLOR(config_color_nicklist_bg));
gui_color_build (GUI_COLOR_NICKLIST_PREFIX3, CONFIG_COLOR(config_color_nicklist_prefix3), CONFIG_COLOR(config_color_nicklist_bg));
gui_color_build (GUI_COLOR_NICKLIST_PREFIX4, CONFIG_COLOR(config_color_nicklist_prefix4), CONFIG_COLOR(config_color_nicklist_bg));
gui_color_build (GUI_COLOR_NICKLIST_PREFIX5, CONFIG_COLOR(config_color_nicklist_prefix5), CONFIG_COLOR(config_color_nicklist_bg));
gui_color_build (GUI_COLOR_NICKLIST_MORE, CONFIG_COLOR(config_color_nicklist_more), CONFIG_COLOR(config_color_nicklist_bg));
gui_color_build (GUI_COLOR_NICKLIST_SEPARATOR, CONFIG_COLOR(config_color_nicklist_separator), CONFIG_COLOR(config_color_nicklist_bg));
}
/*
-374
View File
@@ -1,374 +0,0 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* gui-curses-input: input display functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
#include "../../core/wee-string.h"
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-input.h"
#include "../gui-buffer.h"
#include "../gui-color.h"
#include "../gui-keyboard.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-curses.h"
/*
* gui_input_set_color: set color for an input window
*/
void
gui_input_set_color (struct t_gui_window *window, int color)
{
int fg, bg;
fg = gui_weechat_colors[color].foreground;
bg = gui_color[GUI_COLOR_INPUT]->background;
if (gui_weechat_colors[color].attributes & A_BOLD)
wattron (GUI_CURSES(window)->win_input, A_BOLD);
if (((fg == -1) || (fg == 99))
&& ((bg == -1) || (bg == 99)))
wattron (GUI_CURSES(window)->win_input, COLOR_PAIR(63));
else
{
if ((fg == -1) || (fg == 99))
fg = COLOR_WHITE;
if ((bg == -1) || (bg == 99))
bg = 0;
wattron (GUI_CURSES(window)->win_input, COLOR_PAIR((bg * 8) + fg));
}
}
/*
* gui_input_draw_prompt: display input prompt
* return: # chars displayed on screen (one UTF-8 char
* may be displayed on more than 1 char on screen)
*/
void
gui_input_draw_prompt (struct t_gui_window *window)
{
char *pos, saved_char, *buf;
int char_size;
wmove (GUI_CURSES(window)->win_input, 0, 0);
if (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
{
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
GUI_COLOR_INPUT);
wprintw (GUI_CURSES(window)->win_input, "%s",
(window->buffer->text_search_exact) ?
_("Text search (exact): ") : _("Text search: "));
return;
}
pos = CONFIG_STRING(config_look_input_format);
while (pos && pos[0])
{
switch (pos[0])
{
case '%':
pos++;
switch (pos[0])
{
case 'c': /* buffer name */
if (window->buffer->name)
{
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
GUI_COLOR_INPUT_CHANNEL);
buf = string_iconv_from_internal (NULL,
window->buffer->name);
wprintw (GUI_CURSES(window)->win_input, "%s",
(buf) ? buf : window->buffer->name);
if (buf)
free (buf);
}
pos++;
break;
case 'm': /* nick modes */
/*if (GUI_SERVER(window->buffer) && GUI_SERVER(window->buffer)->is_connected)
{
if (GUI_SERVER(window->buffer)->nick_modes
&& GUI_SERVER(window->buffer)->nick_modes[0])
{
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
GUI_COLOR_WIN_INPUT);
wprintw (GUI_CURSES(window)->win_input, "%s",
GUI_SERVER(window->buffer)->nick_modes);
}
}*/
pos++;
break;
case 'n': /* nick */
if (window->buffer->input_nick)
{
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
GUI_COLOR_INPUT_NICK);
buf = string_iconv_from_internal (NULL,
window->buffer->input_nick);
wprintw (GUI_CURSES(window)->win_input, "%s",
(buf) ? buf : window->buffer->input_nick);
if (buf)
free (buf);
}
pos++;
break;
default:
if (pos[0])
{
char_size = utf8_char_size (pos);
saved_char = pos[char_size];
pos[char_size] = '\0';
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
GUI_COLOR_INPUT_DELIMITERS);
wprintw (GUI_CURSES(window)->win_input, "%%%s", pos);
pos[char_size] = saved_char;
pos += char_size;
}
else
{
wprintw (GUI_CURSES(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 (GUI_CURSES(window)->win_input,
GUI_COLOR_INPUT_DELIMITERS);
wprintw (GUI_CURSES(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
* return: offset for cursor position on screen (one UTF-8
* char may be displayed on more than 1 char on screen)
*/
int
gui_input_draw_text (struct t_gui_window *window, int input_width)
{
char *ptr_start, *ptr_next, saved_char, *output, *ptr_string;
int pos_mask, size, last_color, color, count_cursor, offset_cursor;
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;
count_cursor = window->buffer->input_buffer_pos -
window->buffer->input_buffer_1st_display;
offset_cursor = 0;
if (window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
{
if (window->buffer->text_search_found)
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
GUI_COLOR_INPUT);
else
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
GUI_COLOR_INPUT_TEXT_NOT_FOUND);
}
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->text_search == GUI_TEXT_SEARCH_DISABLED)
{
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)
{
if (color == -1)
gui_window_set_weechat_color (GUI_CURSES(window)->win_input,
GUI_COLOR_INPUT);
else
gui_input_set_color (window, color);
}
last_color = color;
}
output = string_iconv_from_internal (NULL, ptr_start);
ptr_string = (output) ? output : ptr_start;
if ((((unsigned char)ptr_string[0]) < 32) && (!ptr_string[1]))
{
wattron (GUI_CURSES(window)->win_input, A_REVERSE);
wprintw (GUI_CURSES(window)->win_input, "%c",
'A' + ((unsigned char)ptr_string[0]) - 1);
wattroff (GUI_CURSES(window)->win_input, A_REVERSE);
if (count_cursor > 0)
{
offset_cursor++;
count_cursor--;
}
}
else
{
wprintw (GUI_CURSES(window)->win_input, "%s", ptr_string);
if (count_cursor > 0)
{
offset_cursor += utf8_strlen_screen (ptr_start);
count_cursor--;
}
}
if (output)
free (output);
ptr_next[0] = saved_char;
ptr_start = ptr_next;
pos_mask += size;
}
else
ptr_start = NULL;
input_width--;
}
return offset_cursor;
}
/*
* gui_input_draw: draw input window for a buffer
*/
void
gui_input_draw (struct t_gui_buffer *buffer, int erase)
{
struct t_gui_window *ptr_win;
char format[32];
int prompt_length, display_prompt, offset_cursor;
if (!gui_ok)
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (ptr_win->buffer == buffer)
{
if (erase)
gui_window_clear_weechat (GUI_CURSES(ptr_win)->win_input,
GUI_COLOR_INPUT);
if (gui_keyboard_paste_pending)
{
wmove (GUI_CURSES(ptr_win)->win_input, 0, 0);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input,
GUI_COLOR_INPUT_ACTIONS);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_input,
_(" Paste %d lines ? [ctrl-Y] Yes "
"[ctrl-N] No"),
gui_keyboard_get_paste_lines ());
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
ptr_win->win_input_cursor_x = 0;
if (ptr_win == gui_current_window)
move (ptr_win->win_input_y, ptr_win->win_input_x);
}
else
{
if (buffer->input)
{
if (buffer->input_buffer_length == 0)
buffer->input_buffer[0] = '\0';
prompt_length = gui_input_get_prompt_length (ptr_win->buffer);
if (ptr_win->win_input_width - prompt_length < 3)
{
prompt_length = 0;
display_prompt = 0;
}
else
display_prompt = 1;
if (buffer->input_buffer_pos - buffer->input_buffer_1st_display + 1 >
ptr_win->win_input_width - prompt_length)
buffer->input_buffer_1st_display = buffer->input_buffer_pos -
(ptr_win->win_input_width - prompt_length) + 1;
else
{
if (buffer->input_buffer_pos < buffer->input_buffer_1st_display)
buffer->input_buffer_1st_display = buffer->input_buffer_pos;
else
{
if ((buffer->input_buffer_1st_display > 0) &&
(buffer->input_buffer_pos -
buffer->input_buffer_1st_display + 1)
< ptr_win->win_input_width - prompt_length)
{
buffer->input_buffer_1st_display =
buffer->input_buffer_pos -
(ptr_win->win_input_width - prompt_length) + 1;
if (buffer->input_buffer_1st_display < 0)
buffer->input_buffer_1st_display = 0;
}
}
}
if (display_prompt)
gui_input_draw_prompt (ptr_win);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_input,
GUI_COLOR_INPUT);
snprintf (format, sizeof (format), "%%-%ds",
ptr_win->win_input_width - prompt_length);
offset_cursor = 0;
if (ptr_win == gui_current_window)
offset_cursor = gui_input_draw_text (ptr_win,
ptr_win->win_input_width - prompt_length);
else
wprintw (GUI_CURSES(ptr_win)->win_input, format, " ");
wclrtoeol (GUI_CURSES(ptr_win)->win_input);
ptr_win->win_input_cursor_x = prompt_length + offset_cursor;
if (ptr_win == gui_current_window)
move (ptr_win->win_input_y,
ptr_win->win_input_x + ptr_win->win_input_cursor_x);
}
}
wrefresh (GUI_CURSES(ptr_win)->win_input);
refresh ();
}
}
buffer->input_refresh_needed = 0;
}
+4 -18
View File
@@ -121,8 +121,8 @@ gui_keyboard_default_bindings ()
gui_keyboard_bind (NULL, /* m-end */ "meta-meta2-8~", "/window scroll_bottom");
gui_keyboard_bind (NULL, /* m-n */ "meta-n", "/window scroll_next_highlight");
gui_keyboard_bind (NULL, /* m-p */ "meta-p", "/window scroll_previous_highlight");
gui_keyboard_bind (NULL, /* F9 */ "meta2-20~", "/window scroll_topic_left");
gui_keyboard_bind (NULL, /* F10 */ "meta2-21~", "/window scroll_topic_right");
gui_keyboard_bind (NULL, /* F9 */ "meta2-20~", "/bar scroll title * x-50%");
gui_keyboard_bind (NULL, /* F10 */ "meta2-21~", "/bar scroll title * x+50%");
gui_keyboard_bind (NULL, /* F11 */ "meta2-23~", "/bar scroll nicklist * y-100%");
gui_keyboard_bind (NULL, /* F12 */ "meta2-24~", "/bar scroll nicklist * y+100%");
gui_keyboard_bind (NULL, /* m-F11 */ "meta-meta2-23~", "/bar scroll nicklist * yb");
@@ -162,7 +162,7 @@ gui_keyboard_default_bindings ()
void
gui_keyboard_flush ()
{
int i, key, insert_ok, input_draw;
int i, key, insert_ok;
char key_str[32], *key_utf, *input_old;
/* if there's no paste pending, then we use buffer and do actions
@@ -286,8 +286,6 @@ gui_keyboard_flush ()
else
input_old = NULL;
input_draw = 0;
if ((gui_keyboard_pressed (key_str) != 0) && (insert_ok))
{
if (strcmp (key_str, "^^") == 0)
@@ -298,7 +296,6 @@ gui_keyboard_flush ()
if (gui_current_window->buffer->completion)
gui_completion_stop (gui_current_window->buffer->completion, 0);
gui_input_text_changed_signal ();
input_draw = 1;
}
/* incremental text search in buffer */
@@ -307,12 +304,8 @@ gui_keyboard_flush ()
|| (strcmp (input_old, gui_current_window->buffer->input_buffer) != 0)))
{
gui_window_search_restart (gui_current_window);
input_draw = 1;
}
if (input_draw)
gui_input_draw (gui_current_window->buffer, 0);
if (input_old)
free (input_old);
}
@@ -389,18 +382,12 @@ gui_keyboard_read_cb (void *data)
{
/* user is ok for pasting text, let's paste! */
if (accept_paste)
{
gui_keyboard_paste_accept ();
gui_input_draw (gui_current_window->buffer, 1);
}
/* user doesn't want to paste text: clear whole buffer! */
else if (cancel_paste)
{
gui_keyboard_paste_cancel ();
gui_input_draw (gui_current_window->buffer, 1);
}
else if (text_added_to_buffer)
gui_input_draw (gui_current_window->buffer, 1);
gui_input_text_changed_signal ();
}
else
{
@@ -412,7 +399,6 @@ gui_keyboard_read_cb (void *data)
if (paste_lines > CONFIG_INTEGER(config_look_paste_max_lines))
{
gui_keyboard_paste_pending = 1;
gui_input_draw (gui_current_window->buffer, 1);
gui_input_paste_pending_signal ();
}
}
-17
View File
@@ -48,7 +48,6 @@
#include "../gui-input.h"
#include "../gui-history.h"
#include "../gui-nicklist.h"
#include "../gui-status.h"
#include "../gui-window.h"
#include "gui-curses.h"
@@ -273,30 +272,14 @@ gui_main_loop ()
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
/* refresh title if needed */
if (ptr_buffer->title_refresh_needed)
gui_chat_draw_title (ptr_buffer, 1);
/* refresh nicklist if needed */
if (ptr_buffer->nicklist_refresh_needed)
gui_nicklist_draw (ptr_buffer, 1);
/* refresh chat if needed */
if (ptr_buffer->chat_refresh_needed)
{
gui_chat_draw (ptr_buffer,
(ptr_buffer->chat_refresh_needed) > 1 ? 1 : 0);
}
/* refresh input if needed */
if (ptr_buffer->input_refresh_needed)
gui_input_draw (ptr_buffer, 1);
}
/* refresh status bar if needed */
if (gui_status_refresh_needed)
gui_status_draw (1);
/* refresh bars if needed */
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
{
-350
View File
@@ -1,350 +0,0 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* gui-curses-nicklist.c: nicklist display functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
#include "../../core/wee-string.h"
#include "../../core/wee-utf8.h"
#include "../gui-nicklist.h"
#include "../gui-buffer.h"
#include "../gui-chat.h"
#include "../gui-color.h"
#include "../gui-main.h"
#include "../gui-window.h"
#include "gui-curses.h"
/*
* gui_nicklist_draw: draw nick window for a buffer
* return 1 if chat window has been refreshed, 0 if only
* nicklist has been refreshed
*/
int
gui_nicklist_draw (struct t_gui_buffer *buffer, int erase)
{
struct t_gui_window *ptr_win;
struct t_gui_nick_group *ptr_group, *save_ptr_group;
struct t_gui_nick *ptr_nick, *save_ptr_nick;
struct t_config_option *ptr_option;
int rc, i, j, k, x, y, x2, max_y, column, max_length, max_chars;
int nicks_displayed, num_to_display, chars_left;
char format_empty[32], *buf, *ptr_buf, *ptr_next, saved_char;
rc = 0;
if (!gui_ok)
return 0;
if (!buffer->nicklist)
{
buffer->nicklist_refresh_needed = 0;
return 0;
}
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0))
{
max_length = gui_nicklist_get_max_length (buffer, NULL);
if ((max_length != buffer->nicklist_max_length)
|| (buffer->nicklist && !GUI_CURSES(ptr_win)->win_nick)
|| (!buffer->nicklist && GUI_CURSES(ptr_win)->win_nick))
{
buffer->nicklist_max_length = max_length;
if (gui_window_calculate_pos_size (ptr_win, 0))
{
delwin (GUI_CURSES(ptr_win)->win_chat);
delwin (GUI_CURSES(ptr_win)->win_nick);
GUI_CURSES(ptr_win)->win_chat = newwin (ptr_win->win_chat_height,
ptr_win->win_chat_width,
ptr_win->win_chat_y,
ptr_win->win_chat_x);
GUI_CURSES(ptr_win)->win_nick = newwin (ptr_win->win_nick_height,
ptr_win->win_nick_width,
ptr_win->win_nick_y,
ptr_win->win_nick_x);
gui_chat_draw (buffer, 1);
erase = 1;
rc = 1;
}
}
if (erase)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
GUI_COLOR_NICKLIST);
snprintf (format_empty, 32, "%%-%ds", ptr_win->win_nick_width);
for (i = 0; i < ptr_win->win_nick_height; i++)
{
mvwprintw (GUI_CURSES(ptr_win)->win_nick, i, 0,
format_empty, " ");
}
}
if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_TOP) ||
(CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM))
max_chars = max_length;
else
max_chars = ((CONFIG_INTEGER(config_look_nicklist_min_size) > 0)
&& (max_length < CONFIG_INTEGER(config_look_nicklist_min_size))) ?
CONFIG_INTEGER(config_look_nicklist_min_size) :
(((CONFIG_INTEGER(config_look_nicklist_max_size) > 0)
&& (max_length > CONFIG_INTEGER(config_look_nicklist_max_size))) ?
CONFIG_INTEGER(config_look_nicklist_max_size) : max_length);
if (CONFIG_BOOLEAN(config_look_nicklist_separator) && has_colors ())
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
GUI_COLOR_NICKLIST_SEPARATOR);
switch (CONFIG_INTEGER(config_look_nicklist_position))
{
case CONFIG_LOOK_NICKLIST_LEFT:
mvwvline (GUI_CURSES(ptr_win)->win_nick,
0, ptr_win->win_nick_width - 1, ACS_VLINE,
ptr_win->win_chat_height);
break;
case CONFIG_LOOK_NICKLIST_RIGHT:
mvwvline (GUI_CURSES(ptr_win)->win_nick,
0, 0, ACS_VLINE,
ptr_win->win_chat_height);
break;
case CONFIG_LOOK_NICKLIST_TOP:
mvwhline (GUI_CURSES(ptr_win)->win_nick,
ptr_win->win_nick_height - 1, 0, ACS_HLINE,
ptr_win->win_chat_width);
break;
case CONFIG_LOOK_NICKLIST_BOTTOM:
mvwhline (GUI_CURSES(ptr_win)->win_nick,
0, 0, ACS_HLINE,
ptr_win->win_chat_width);
break;
}
}
x = 0;
y = (CONFIG_BOOLEAN(config_look_nicklist_separator)
&& (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM)) ?
1 : 0;
max_y = 0;
switch (CONFIG_INTEGER(config_look_nicklist_position))
{
case CONFIG_LOOK_NICKLIST_LEFT:
case CONFIG_LOOK_NICKLIST_RIGHT:
max_y = 0;
break;
case CONFIG_LOOK_NICKLIST_TOP:
max_y = ptr_win->win_nick_height -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
break;
case CONFIG_LOOK_NICKLIST_BOTTOM:
max_y = ptr_win->win_nick_height;
break;
}
column = 0;
if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_TOP) ||
(CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM))
nicks_displayed = (ptr_win->win_width / (max_length + 2)) *
(ptr_win->win_nick_height -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0));
else
nicks_displayed = ptr_win->win_nick_height;
ptr_group = NULL;
ptr_nick = NULL;
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
i = 0;
while ((ptr_group || ptr_nick) && (i < ptr_win->win_nick_start))
{
if ((ptr_nick && ptr_nick->visible)
|| (ptr_group && buffer->nicklist_display_groups
&& ptr_group->visible))
i++;
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
}
save_ptr_group = ptr_group;
save_ptr_nick = ptr_nick;
while (ptr_group || ptr_nick)
{
if ((ptr_nick && ptr_nick->visible)
|| (ptr_group && buffer->nicklist_display_groups))
{
num_to_display++;
}
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
}
ptr_group = save_ptr_group;
ptr_nick = save_ptr_nick;
i = 0;
while ((ptr_group || ptr_nick) && (i < nicks_displayed))
{
if ((ptr_nick && ptr_nick->visible)
|| (ptr_group && buffer->nicklist_display_groups
&& ptr_group->visible))
{
switch (CONFIG_INTEGER(config_look_nicklist_position))
{
case CONFIG_LOOK_NICKLIST_LEFT:
x = 0;
break;
case CONFIG_LOOK_NICKLIST_RIGHT:
x = (CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0;
break;
case CONFIG_LOOK_NICKLIST_TOP:
case CONFIG_LOOK_NICKLIST_BOTTOM:
x = column;
break;
}
if (((i == 0) && (ptr_win->win_nick_start > 0))
|| ((i == nicks_displayed - 1) && (i < num_to_display - 1)))
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
GUI_COLOR_NICKLIST_MORE);
j = (max_length + 1) >= 4 ? 4 : max_length + 1;
for (x2 = 1; x2 <= j; x2++)
{
mvwprintw (GUI_CURSES(ptr_win)->win_nick,
y, x + x2, "+");
}
}
else
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
GUI_COLOR_NICKLIST);
chars_left = max_chars;
if (ptr_nick)
{
/* display spaces and prefix for nick */
if (buffer->nicklist_display_groups)
{
for (k = 0; k < ptr_nick->group->level; k++)
{
mvwprintw (GUI_CURSES(ptr_win)->win_nick,
y, x, " ");
x++;
}
chars_left -= ptr_nick->group->level;
}
//gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
// ptr_nick->prefix_color);
config_file_search_with_string (ptr_nick->prefix_color,
NULL, NULL, &ptr_option,
NULL);
if (ptr_option)
gui_window_set_custom_color_fg (GUI_CURSES(ptr_win)->win_nick,
CONFIG_COLOR(ptr_option));
mvwprintw (GUI_CURSES(ptr_win)->win_nick,
y, x, "%c", ptr_nick->prefix);
x++;
chars_left--;
//gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
// ptr_nick->color);
config_file_search_with_string (ptr_nick->color,
NULL, NULL, &ptr_option,
NULL);
if (ptr_option)
gui_window_set_custom_color_fg (GUI_CURSES(ptr_win)->win_nick,
CONFIG_COLOR(ptr_option));
ptr_buf = ptr_nick->name;
}
else
{
/* display group name */
for (k = 0; k < ptr_group->level - 1; k++)
{
mvwprintw (GUI_CURSES(ptr_win)->win_nick,
y, x, " ");
x++;
}
chars_left -= ptr_group->level;
//gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_nick,
// ptr_group->color);
//wattron (GUI_CURSES(ptr_win)->win_nick, A_UNDERLINE);
ptr_buf = gui_nicklist_get_group_start (ptr_group->name);
}
wmove (GUI_CURSES(ptr_win)->win_nick, y, x);
saved_char = '\0';
for (k = 0; k < chars_left; k++)
{
if (ptr_buf && ptr_buf[0])
{
ptr_next = utf8_next_char (ptr_buf);
if (ptr_next)
{
saved_char = ptr_next[0];
ptr_next[0] = '\0';
}
buf = string_iconv_from_internal (NULL,
ptr_buf);
wprintw (GUI_CURSES(ptr_win)->win_nick, "%s",
(buf) ? buf : "?");
if (buf)
free (buf);
if (ptr_next)
ptr_next[0] = saved_char;
ptr_buf = ptr_next;
//if (!ptr_buf || !ptr_buf[0])
// wattroff (GUI_CURSES(ptr_win)->win_nick,
// A_UNDERLINE);
}
else
wprintw (GUI_CURSES(ptr_win)->win_nick, " ");
}
}
y++;
i++;
if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_TOP) ||
(CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM))
{
if (y >= max_y)
{
column += max_length + 2;
y = (CONFIG_BOOLEAN(config_look_nicklist_separator)
&& (CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_BOTTOM)) ?
1 : 0;
}
}
}
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
}
wnoutrefresh (GUI_CURSES(ptr_win)->win_nick);
refresh ();
}
}
buffer->nicklist_refresh_needed = 0;
return rc;
}
-249
View File
@@ -1,249 +0,0 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* gui-curses-status.c: status display functions for Curses GUI */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-status.h"
#include "../gui-buffer.h"
#include "../gui-color.h"
#include "../gui-main.h"
#include "../gui-hotlist.h"
#include "../gui-window.h"
#include "gui-curses.h"
/*
* gui_status_draw: draw status window
*/
void
gui_status_draw (int erase)
{
struct t_gui_window *ptr_win;
struct t_gui_hotlist *ptr_hotlist;
char format[32], *more, *pos_point;
int x;
int display_name, names_count;
if (!gui_ok)
return;
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
if (erase)
gui_window_clear_weechat (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
/* display number of buffers */
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
mvwprintw (GUI_CURSES(ptr_win)->win_status, 0, 0, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
(last_gui_buffer) ? last_gui_buffer->number : 0);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
/* display buffer plugin */
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%s",
plugin_get_name (ptr_win->buffer->plugin));
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
/* display buffer number/name */
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_NUMBER);
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
ptr_win->buffer->number);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ":");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_NAME);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, "%s ",
ptr_win->buffer->name);
/* display list of other active windows (if any) with numbers */
if (gui_hotlist)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, _("Act: "));
names_count = 0;
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
ptr_hotlist = ptr_hotlist->next_hotlist)
{
switch (ptr_hotlist->priority)
{
case GUI_HOTLIST_LOW:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DATA_OTHER);
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 1) != 0);
break;
case GUI_HOTLIST_MESSAGE:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DATA_MSG);
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 2) != 0);
break;
case GUI_HOTLIST_PRIVATE:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DATA_PRIVATE);
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 4) != 0);
break;
case GUI_HOTLIST_HIGHLIGHT:
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DATA_HIGHLIGHT);
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 8) != 0);
break;
default:
display_name = 0;
break;
}
wprintw (GUI_CURSES(ptr_win)->win_status, "%d",
ptr_hotlist->buffer->number);
if (display_name
&& (CONFIG_INTEGER(config_look_hotlist_names_count) != 0)
&& (names_count < CONFIG_INTEGER(config_look_hotlist_names_count)))
{
names_count++;
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, ":");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0)
snprintf (format, sizeof (format) - 1, "%%s");
else
snprintf (format, sizeof (format) - 1,
"%%.%ds",
CONFIG_INTEGER(config_look_hotlist_names_length));
pos_point = NULL;
if (CONFIG_BOOLEAN(config_look_hotlist_short_names))
pos_point = strchr (ptr_hotlist->buffer->name, '.');
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
format,
(pos_point) ? pos_point + 1 : ptr_hotlist->buffer->name);
}
if (ptr_hotlist->next_hotlist)
wprintw (GUI_CURSES(ptr_win)->win_status, ",");
}
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
}
/* display lag */
/*if (GUI_SERVER(ptr_win->buffer))
{
if (GUI_SERVER(ptr_win->buffer)->lag / 1000 >= config_irc_lag_min_show)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status,
_("Lag: %.1f"),
((float)(GUI_SERVER(ptr_win->buffer)->lag)) / 1000);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "]");
}
}*/
/* display "-MORE-" (if last line is not displayed) & nicks count */
/*if (ptr_win->buffer->attribs & GUI_BUFFER_ATTRIB_NICKLIST)
{
snprintf (str_nicks, sizeof (str_nicks) - 1, "%d",
GUI_CHANNEL(ptr_win->buffer)->nicks_count);
x = ptr_win->win_status_width - utf8_strlen (str_nicks) - 4;
}
else*/
x = ptr_win->win_status_width - 1;
more = strdup (_("-MORE-"));
if (more)
{
x -= utf8_strlen (more) - 1;
if (x < 0)
x = 0;
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_MORE);
if (ptr_win->scroll)
{
wmove (GUI_CURSES(ptr_win)->win_status, 0, x);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, "%s", more);
}
else
{
/*snprintf (format, sizeof (format) - 1,
"%%-%ds", (int)(utf8_strlen (more)));
wmove (GUI_CURSES(ptr_win)->win_status, 0, x);
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, format, " ");
*/
}
/*if (ptr_win->buffer->attribs & GUI_BUFFER_ATTRIB_NICKLIST)
{
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, " [");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%s", str_nicks);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "]");
}*/
free (more);
}
wnoutrefresh (GUI_CURSES(ptr_win)->win_status);
refresh ();
}
gui_status_refresh_needed = 0;
}
+25 -356
View File
@@ -42,7 +42,6 @@
#include "../gui-input.h"
#include "../gui-main.h"
#include "../gui-nicklist.h"
#include "../gui-status.h"
#include "gui-curses.h"
@@ -85,11 +84,7 @@ gui_window_objects_init (struct t_gui_window *window)
if (new_objects)
{
window->gui_objects = new_objects;
GUI_CURSES(window)->win_title = NULL;
GUI_CURSES(window)->win_chat = NULL;
GUI_CURSES(window)->win_nick = NULL;
GUI_CURSES(window)->win_status = NULL;
GUI_CURSES(window)->win_input = NULL;
GUI_CURSES(window)->win_separator = NULL;
GUI_CURSES(window)->bar_windows = NULL;
GUI_CURSES(window)->last_bar_window = NULL;
@@ -106,31 +101,11 @@ void
gui_window_objects_free (struct t_gui_window *window, int free_separator,
int free_bar_windows)
{
if (GUI_CURSES(window)->win_title)
{
delwin (GUI_CURSES(window)->win_title);
GUI_CURSES(window)->win_title = NULL;
}
if (GUI_CURSES(window)->win_chat)
{
delwin (GUI_CURSES(window)->win_chat);
GUI_CURSES(window)->win_chat = NULL;
}
if (GUI_CURSES(window)->win_nick)
{
delwin (GUI_CURSES(window)->win_nick);
GUI_CURSES(window)->win_nick = NULL;
}
if (GUI_CURSES(window)->win_status)
{
delwin (GUI_CURSES(window)->win_status);
GUI_CURSES(window)->win_status = NULL;
}
if (GUI_CURSES(window)->win_input)
{
delwin (GUI_CURSES(window)->win_input);
GUI_CURSES(window)->win_input = NULL;
}
if (free_separator && GUI_CURSES(window)->win_separator)
{
delwin (GUI_CURSES(window)->win_separator);
@@ -380,19 +355,18 @@ gui_window_clrtoeol_with_current_bg (WINDOW *window)
}
/*
* gui_window_calculate_pos_size: calculate position and size for a buffer & subwindows
* return 1 if pos/size changed, 0 if no change
* gui_window_calculate_pos_size: calculate position and size for a buffer and
* subwindows
*/
int
gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
void
gui_window_calculate_pos_size (struct t_gui_window *window)
{
struct t_gui_bar_window *ptr_bar_win;
int max_length, max_height, lines, width_used;
int add_top, add_bottom, add_left, add_right;
if (!gui_ok)
return 0;
return;
for (ptr_bar_win = GUI_CURSES(window)->bar_windows; ptr_bar_win;
ptr_bar_win = ptr_bar_win->next_bar_window)
@@ -405,148 +379,12 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
add_left = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_LEFT);
add_right = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_RIGHT);
/* init chat & nicklist settings */
if (window->buffer->nicklist)
{
max_length = window->buffer->nicklist_max_length;
lines = 0;
if ((CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_LEFT) ||
(CONFIG_INTEGER(config_look_nicklist_position) == CONFIG_LOOK_NICKLIST_RIGHT))
{
if ((CONFIG_INTEGER(config_look_nicklist_min_size) > 0)
&& (max_length < CONFIG_INTEGER(config_look_nicklist_min_size)))
max_length = CONFIG_INTEGER(config_look_nicklist_min_size);
else if ((CONFIG_INTEGER(config_look_nicklist_max_size) > 0)
&& (max_length > CONFIG_INTEGER(config_look_nicklist_max_size)))
max_length = CONFIG_INTEGER(config_look_nicklist_max_size);
if (!force_calculate
&& (window->win_nick_width ==
max_length + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0)))
return 0;
}
else
{
width_used = (window->win_width - add_left - add_right)
- ((window->win_width - add_left - add_right) % (max_length + 2));
if (((max_length + 2) * window->buffer->nicklist_visible_count) % width_used == 0)
lines = ((max_length + 2) * window->buffer->nicklist_visible_count) / width_used;
else
lines = (((max_length + 2) * window->buffer->nicklist_visible_count) / width_used) + 1;
if ((CONFIG_INTEGER(config_look_nicklist_max_size) > 0)
&& (lines > CONFIG_INTEGER(config_look_nicklist_max_size)))
lines = CONFIG_INTEGER(config_look_nicklist_max_size);
if ((CONFIG_INTEGER(config_look_nicklist_min_size) > 0)
&& (lines < CONFIG_INTEGER(config_look_nicklist_min_size)))
lines = CONFIG_INTEGER(config_look_nicklist_min_size);
max_height = window->win_height - add_top - add_bottom - 2 - 4;
if (lines > max_height)
lines = max_height;
if (!force_calculate
&& (window->win_nick_height ==
lines + ((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0)))
return 0;
}
switch (CONFIG_INTEGER(config_look_nicklist_position))
{
case CONFIG_LOOK_NICKLIST_LEFT:
window->win_chat_x = window->win_x + add_left + max_length +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_chat_y = window->win_y + add_top + 1;
window->win_chat_width = window->win_width - max_length -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_x = window->win_x + add_left + 0;
window->win_nick_y = window->win_y + add_top + 1;
window->win_nick_width = max_length +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_chat_height = window->win_height - add_top - add_bottom - 3;
window->win_nick_height = window->win_height - add_top - add_bottom - 3;
window->win_nick_num_max = window->win_nick_height;
break;
case CONFIG_LOOK_NICKLIST_RIGHT:
window->win_chat_x = window->win_x + add_left;
window->win_chat_y = window->win_y + add_top + 1;
window->win_chat_width = window->win_width - add_left - add_right - max_length -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_x = window->win_x + window->win_width - add_right - max_length -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_y = window->win_y + add_top + 1;
window->win_nick_width = max_length +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_chat_height = window->win_height - add_top - add_bottom - 3;
window->win_nick_height = window->win_height - add_top - add_bottom - 3;
window->win_nick_num_max = window->win_nick_height;
break;
case CONFIG_LOOK_NICKLIST_TOP:
window->win_chat_x = window->win_x + add_left;
window->win_chat_y = window->win_y + add_top + 1 + lines +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_chat_width = window->win_width - add_left - add_right;
window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_x = window->win_x + add_left;
window->win_nick_y = window->win_y + add_top + 1;
window->win_nick_width = window->win_width - add_left - add_right;
window->win_nick_height = lines +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 1));
break;
case CONFIG_LOOK_NICKLIST_BOTTOM:
window->win_chat_x = window->win_x + add_left;
window->win_chat_y = window->win_y + add_top + 1;
window->win_chat_width = window->win_width - add_left - add_right;
window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_x = window->win_x;
window->win_nick_y = window->win_y + window->win_height - add_bottom -
2 - lines -
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_width = window->win_width;
window->win_nick_height = lines +
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 1));
break;
}
window->win_chat_cursor_x = window->win_x + add_left;
window->win_chat_cursor_y = window->win_y + add_top;
}
else
{
window->win_chat_x = window->win_x + add_left;
window->win_chat_y = window->win_y + add_top + 1;
window->win_chat_width = window->win_width - add_left - add_right;
window->win_chat_height = window->win_height - add_top - add_bottom - 3;
window->win_chat_cursor_x = window->win_x + add_left;
window->win_chat_cursor_y = window->win_y + add_top;
window->win_nick_x = -1;
window->win_nick_y = -1;
window->win_nick_width = -1;
window->win_nick_height = -1;
window->win_nick_num_max = -1;
}
/* title window */
window->win_title_x = window->win_x + add_left;
window->win_title_y = window->win_y + add_top;
window->win_title_width = window->win_width - add_left - add_right;
window->win_title_height = 1;
/* status window */
window->win_status_x = window->win_x + add_left;
window->win_status_y = window->win_y + window->win_height - add_bottom - 2;
window->win_status_width = window->win_width - add_left - add_right;
window->win_status_height = 1;
/* input window */
window->win_input_x = window->win_x + add_left;
window->win_input_y = window->win_y + window->win_height - add_bottom - 1;
window->win_input_width = window->win_width - add_left - add_right;
window->win_input_height = 1;
return 1;
window->win_chat_x = window->win_x + add_left;
window->win_chat_y = window->win_y + add_top;
window->win_chat_width = window->win_width - add_left - add_right;
window->win_chat_height = window->win_height - add_top - add_bottom;
window->win_chat_cursor_x = window->win_x + add_left;
window->win_chat_cursor_y = window->win_y + add_top;
}
/*
@@ -584,11 +422,7 @@ gui_window_redraw_buffer (struct t_gui_buffer *buffer)
if (!gui_ok)
return;
gui_chat_draw_title (buffer, 1);
if (!gui_nicklist_draw (buffer, 1))
gui_chat_draw (buffer, 1);
gui_status_draw (1);
gui_input_draw (buffer, 1);
gui_chat_draw (buffer, 1);
}
/*
@@ -641,8 +475,6 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
}
window->buffer = buffer;
window->win_title_start = 0;
window->win_nick_start = 0;
if (old_buffer == buffer)
{
@@ -650,7 +482,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
gui_bar_window_add_missing_bars (window);
}
gui_window_calculate_pos_size (window, 1);
gui_window_calculate_pos_size (window);
/* create bar windows */
for (ptr_bar_win = GUI_CURSES(window)->bar_windows; ptr_bar_win;
@@ -663,42 +495,12 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
gui_window_objects_free (window, 0, 0);
/* create Curses windows */
GUI_CURSES(window)->win_title = newwin (window->win_title_height,
window->win_title_width,
window->win_title_y,
window->win_title_x);
GUI_CURSES(window)->win_input = newwin (window->win_input_height,
window->win_input_width,
window->win_input_y,
window->win_input_x);
if (buffer->nicklist)
{
if (GUI_CURSES(window)->win_chat)
delwin (GUI_CURSES(window)->win_chat);
GUI_CURSES(window)->win_chat = newwin (window->win_chat_height,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
GUI_CURSES(window)->win_nick = newwin (window->win_nick_height,
window->win_nick_width,
window->win_nick_y,
window->win_nick_x);
}
else
{
if (GUI_CURSES(window)->win_chat)
delwin (GUI_CURSES(window)->win_chat);
GUI_CURSES(window)->win_chat = newwin (window->win_chat_height,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
}
/* create status window */
GUI_CURSES(window)->win_status = newwin (window->win_status_height,
window->win_status_width,
window->win_status_y,
window->win_status_x);
if (GUI_CURSES(window)->win_chat)
delwin (GUI_CURSES(window)->win_chat);
GUI_CURSES(window)->win_chat = newwin (window->win_chat_height,
window->win_chat_width,
window->win_chat_y,
window->win_chat_x);
buffer->num_displayed++;
@@ -785,8 +587,8 @@ gui_window_page_up (struct t_gui_window *window)
(window->start_line) ?
(-1) * (num_lines) :
(-1) * (num_lines + window->win_chat_height - 1));
window->scroll_reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
gui_status_refresh_needed = 1;
}
break;
case GUI_BUFFER_TYPE_FREE:
@@ -845,8 +647,8 @@ gui_window_page_down (struct t_gui_window *window)
window->start_line = NULL;
window->start_line_pos = 0;
}
window->scroll_reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
gui_status_refresh_needed = 1;
}
break;
case GUI_BUFFER_TYPE_FREE:
@@ -884,8 +686,8 @@ gui_window_scroll_up (struct t_gui_window *window)
(-1) * CONFIG_INTEGER(config_look_scroll_amount) :
(-1) * ( (window->win_chat_height - 1) +
CONFIG_INTEGER(config_look_scroll_amount)));
window->scroll_reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
gui_status_refresh_needed = 1;
}
break;
case GUI_BUFFER_TYPE_FREE:
@@ -938,9 +740,8 @@ gui_window_scroll_down (struct t_gui_window *window)
window->start_line = NULL;
window->start_line_pos = 0;
}
window->scroll_reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
gui_status_refresh_needed = 1;
}
break;
case GUI_BUFFER_TYPE_FREE:
@@ -972,8 +773,8 @@ gui_window_scroll_top (struct t_gui_window *window)
{
window->start_line = gui_chat_get_first_line_displayed (window->buffer);
window->start_line_pos = 0;
window->scroll_reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
gui_status_refresh_needed = 1;
}
break;
case GUI_BUFFER_TYPE_FREE:
@@ -1009,8 +810,8 @@ gui_window_scroll_bottom (struct t_gui_window *window)
{
window->start_line = NULL;
window->start_line_pos = 0;
window->scroll_reset_allowed = 1;
gui_buffer_ask_chat_refresh (window->buffer, 2);
gui_status_refresh_needed = 1;
}
break;
case GUI_BUFFER_TYPE_FREE:
@@ -1024,7 +825,6 @@ gui_window_scroll_bottom (struct t_gui_window *window)
else
{
gui_buffer_ask_chat_refresh (window->buffer, 2);
gui_status_refresh_needed = 1;
}
hook_signal_send ("window_scrolled",
WEECHAT_HOOK_SIGNAL_POINTER, window);
@@ -1034,133 +834,6 @@ gui_window_scroll_bottom (struct t_gui_window *window)
}
}
/*
* gui_window_scroll_topic_left: scroll left topic
*/
void
gui_window_scroll_topic_left (struct t_gui_window *window)
{
if (!gui_ok)
return;
if (window->win_title_start > 0)
window->win_title_start -= (window->win_width * 3) / 4;
if (window->win_title_start < 0)
window->win_title_start = 0;
gui_buffer_ask_title_refresh (window->buffer, 1);
}
/*
* gui_window_scroll_topic_right: scroll right topic
*/
void
gui_window_scroll_topic_right (struct t_gui_window *window)
{
if (!gui_ok)
return;
window->win_title_start += (window->win_width * 3) / 4;
gui_buffer_ask_title_refresh (window->buffer, 1);
}
/*
* gui_window_nicklist_page_up: scroll one page up in nicklist
*/
void
gui_window_nicklist_page_up (struct t_gui_window *window)
{
if (!gui_ok)
return;
if (window->buffer->nicklist)
{
if (window->win_nick_start > 0)
{
window->win_nick_start -= (window->win_nick_num_max - 1);
if (window->win_nick_start <= 1)
window->win_nick_start = 0;
gui_buffer_ask_nicklist_refresh (window->buffer, 1);
}
}
}
/*
* gui_window_nicklist_page_down: scroll one page down in nicklist
*/
void
gui_window_nicklist_page_down (struct t_gui_window *window)
{
if (!gui_ok)
return;
if (window->buffer->nicklist)
{
if ((window->buffer->nicklist_visible_count > window->win_nick_num_max)
&& (window->win_nick_start + window->win_nick_num_max - 1
< window->buffer->nicklist_visible_count))
{
if (window->win_nick_start == 0)
window->win_nick_start += (window->win_nick_num_max - 1);
else
window->win_nick_start += (window->win_nick_num_max - 2);
gui_buffer_ask_nicklist_refresh (window->buffer, 1);
}
}
}
/*
* gui_window_nicklist_beginning: go to beginning of nicklist
*/
void
gui_window_nicklist_beginning (struct t_gui_window *window)
{
if (!gui_ok)
return;
if (window->buffer->nicklist)
{
if (window->win_nick_start > 0)
{
window->win_nick_start = 0;
gui_buffer_ask_nicklist_refresh (window->buffer, 1);
}
}
}
/*
* gui_window_nicklist_end: go to the end of nicklist
*/
void
gui_window_nicklist_end (struct t_gui_window *window)
{
int new_start;
if (!gui_ok)
return;
if (window->buffer->nicklist)
{
new_start =
window->buffer->nicklist_visible_count - window->win_nick_num_max;
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_buffer_ask_nicklist_refresh (window->buffer, 1);
}
}
}
/*
* gui_window_auto_resize: auto-resize all windows, according to % of global size
* This function is called after a terminal resize.
@@ -1770,11 +1443,7 @@ gui_window_objects_print_log (struct t_gui_window *window)
log_printf ("");
log_printf (" window specific objects:");
log_printf (" win_title . . . . . : 0x%x", GUI_CURSES(window)->win_title);
log_printf (" win_chat. . . . . . : 0x%x", GUI_CURSES(window)->win_chat);
log_printf (" win_nick. . . . . . : 0x%x", GUI_CURSES(window)->win_nick);
log_printf (" win_status. . . . . : 0x%x", GUI_CURSES(window)->win_status);
log_printf (" win_input . . . . . : 0x%x", GUI_CURSES(window)->win_input);
log_printf (" win_separator . . . : 0x%x", GUI_CURSES(window)->win_separator);
log_printf (" bar_windows . . . . : 0x%x", GUI_CURSES(window)->bar_windows);
log_printf (" last_bar_windows. . : 0x%x", GUI_CURSES(window)->last_bar_window);
-4
View File
@@ -59,11 +59,7 @@ struct t_gui_bar_window
struct t_gui_curses_objects
{
WINDOW *win_title; /* title window */
WINDOW *win_chat; /* chat window (example: channel) */
WINDOW *win_nick; /* nick window */
WINDOW *win_status; /* status window */
WINDOW *win_input; /* input window */
WINDOW *win_separator; /* separation between 2 splited (V) win */
struct t_gui_bar_window *bar_windows; /* bar windows */
struct t_gui_bar_window *last_bar_window; /* last bar window */