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

Added info bar

This commit is contained in:
Sebastien Helleu
2004-01-18 18:59:34 +00:00
parent 6d7afb96c1
commit 10f0236ea9
28 changed files with 1168 additions and 742 deletions
+3
View File
@@ -58,6 +58,7 @@
#include "../plugins/plugins.h"
char *var_LANG; /* LANG environment variable */
int quit_weechat; /* = 1 if quit request from user... why ? :'( */
char *weechat_home; /* WeeChat home dir. (example: /home/toto/.weechat) */
FILE *log_file; /* WeeChat log file (~/.weechat/weechat.log) */
@@ -391,6 +392,8 @@ wee_shutdown ()
int
main (int argc, char *argv[])
{
var_LANG = getenv ("LANG"); /* get LANG environment variable */
#ifdef ENABLE_NLS
setlocale (LC_ALL, ""); /* initialize gettext */
bindtextdomain (PACKAGE, LOCALEDIR);
+1
View File
@@ -94,6 +94,7 @@
/* global variables and functions */
extern char *var_LANG;
extern int quit_weechat;
extern char *weechat_home;
+17
View File
@@ -73,6 +73,7 @@ int cfg_look_nickmode;
int cfg_look_nickmode_empty;
char *cfg_look_no_nickname;
char *cfg_look_completor;
int cfg_look_infobar;
t_config_option weechat_options_look[] =
{ { "look_set_title", N_("set title for terminal window (curses GUI) with name & version"),
@@ -137,6 +138,10 @@ t_config_option weechat_options_look[] =
N_("the string inserted after nick completion"),
OPTION_TYPE_STRING, 0, 0, 0,
":", NULL, NULL, &cfg_look_completor, NULL },
{ "look_infobar", N_("enable info bar"),
N_("enable info bar"),
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
NULL, NULL, &cfg_look_infobar, NULL, NULL },
{ NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
};
@@ -161,6 +166,8 @@ int cfg_col_status_data_msg;
int cfg_col_status_data_other;
int cfg_col_status_more;
int cfg_col_status_bg;
int cfg_col_infobar;
int cfg_col_infobar_bg;
int cfg_col_input;
int cfg_col_input_channel;
int cfg_col_input_nick;
@@ -256,6 +263,16 @@ t_config_option weechat_options_colors[] =
N_("background for status window"),
OPTION_TYPE_COLOR, 0, 0, 0,
"blue", NULL, &cfg_col_status_bg, NULL, NULL },
/* infobar window */
{ "col_infobar", N_("color for info bar text"),
N_("color for info bar text"),
OPTION_TYPE_COLOR, 0, 0, 0,
"gray", NULL, &cfg_col_infobar, NULL, NULL },
{ "col_infobar_bg", N_("background for info bar window"),
N_("background for info bar window"),
OPTION_TYPE_COLOR, 0, 0, 0,
"blue", NULL, &cfg_col_infobar_bg, NULL, NULL },
/* input window */
{ "col_input", N_("color for input text"),
+3
View File
@@ -88,6 +88,7 @@ extern int cfg_look_nickmode;
extern int cfg_look_nickmode_empty;
extern char *cfg_look_no_nickname;
extern char *cfg_look_completor;
extern int cfg_look_infobar;
extern int cfg_col_title;
extern int cfg_col_title_bg;
@@ -108,6 +109,8 @@ extern int cfg_col_status_data_msg;
extern int cfg_col_status_data_other;
extern int cfg_col_status_more;
extern int cfg_col_status_bg;
extern int cfg_col_infobar;
extern int cfg_col_infobar_bg;
extern int cfg_col_input;
extern int cfg_col_input_channel;
extern int cfg_col_input_nick;
+109 -12
View File
@@ -192,21 +192,37 @@ gui_calculate_pos_size (t_gui_window *window)
window->win_chat_x = max_length + 2;
window->win_chat_y = 1;
window->win_chat_width = COLS - max_length - 2;
window->win_chat_height = LINES - 3;
window->win_nick_x = 0;
window->win_nick_y = 1;
window->win_nick_width = max_length + 2;
window->win_nick_height = LINES - 3;
if (cfg_look_infobar)
{
window->win_chat_height = LINES - 4;
window->win_nick_height = LINES - 4;
}
else
{
window->win_chat_height = LINES - 3;
window->win_nick_height = LINES - 3;
}
break;
case CFG_LOOK_NICKLIST_RIGHT:
window->win_chat_x = 0;
window->win_chat_y = 1;
window->win_chat_width = COLS - max_length - 2;
window->win_chat_height = LINES - 3;
window->win_nick_x = COLS - max_length - 2;
window->win_nick_y = 1;
window->win_nick_width = max_length + 2;
window->win_nick_height = LINES - 3;
if (cfg_look_infobar)
{
window->win_chat_height = LINES - 4;
window->win_nick_height = LINES - 4;
}
else
{
window->win_chat_height = LINES - 3;
window->win_nick_height = LINES - 3;
}
break;
case CFG_LOOK_NICKLIST_TOP:
nick_count (CHANNEL(window), &num_nicks, &num_op, &num_halfop,
@@ -218,7 +234,10 @@ gui_calculate_pos_size (t_gui_window *window)
window->win_chat_x = 0;
window->win_chat_y = 1 + (lines + 1);
window->win_chat_width = COLS;
window->win_chat_height = LINES - 3 - (lines + 1);
if (cfg_look_infobar)
window->win_chat_height = LINES - 3 - (lines + 1) - 1;
else
window->win_chat_height = LINES - 3 - (lines + 1);
window->win_nick_x = 0;
window->win_nick_y = 1;
window->win_nick_width = COLS;
@@ -234,9 +253,15 @@ gui_calculate_pos_size (t_gui_window *window)
window->win_chat_x = 0;
window->win_chat_y = 1;
window->win_chat_width = COLS;
window->win_chat_height = LINES - 3 - (lines + 1);
if (cfg_look_infobar)
window->win_chat_height = LINES - 3 - (lines + 1) - 1;
else
window->win_chat_height = LINES - 3 - (lines + 1);
window->win_nick_x = 0;
window->win_nick_y = LINES - 2 - (lines + 1);
if (cfg_look_infobar)
window->win_nick_y = LINES - 2 - (lines + 1) - 1;
else
window->win_nick_y = LINES - 2 - (lines + 1);
window->win_nick_width = COLS;
window->win_nick_height = lines + 1;
break;
@@ -250,7 +275,10 @@ gui_calculate_pos_size (t_gui_window *window)
window->win_chat_x = 0;
window->win_chat_y = 1;
window->win_chat_width = COLS;
window->win_chat_height = LINES - 3;
if (cfg_look_infobar)
window->win_chat_height = LINES - 4;
else
window->win_chat_height = LINES - 3;
window->win_chat_cursor_x = 0;
window->win_chat_cursor_y = 0;
window->win_nick_x = -1;
@@ -269,7 +297,6 @@ gui_curses_window_clear (WINDOW *window)
{
werase (window);
wmove (window, 0, 0);
//wrefresh (window);
}
/*
@@ -775,7 +802,6 @@ gui_draw_window_status (t_gui_window *window)
wborder (window->win_status, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
wrefresh (window->win_status);
}
//refresh ();
wmove (window->win_status, 0, 0);
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
{
@@ -891,6 +917,59 @@ gui_redraw_window_status (t_gui_window *window)
gui_draw_window_status (window);
}
/*
* gui_draw_window_infobar: draw infobar window
*/
void
gui_draw_window_infobar (t_gui_window *window)
{
t_gui_window *ptr_win;
char format_more[32];
time_t time_seconds;
struct tm *local_time;
char text[256];
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
if (has_colors ())
{
gui_window_set_color (window->win_infobar, COLOR_WIN_INFOBAR);
wborder (window->win_infobar, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
wrefresh (window->win_infobar);
}
wmove (window->win_infobar, 0, 0);
gui_window_set_color (window->win_infobar, COLOR_WIN_INFOBAR);
time_seconds = time (NULL);
local_time = localtime (&time_seconds);
if (strncmp (var_LANG, "fr", 2) == 0)
strftime (text, 255, "%A %d %B %G - %H:%M", local_time);
else
strftime (text, 255, "%B, %A %d %G - %H:%M", local_time);
wprintw (window->win_infobar, "%s", text);
wrefresh (window->win_infobar);
refresh ();
}
/*
* gui_redraw_window_infobar: redraw infobar window
*/
void
gui_redraw_window_infobar (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
gui_curses_window_clear (window->win_infobar);
gui_draw_window_infobar (window);
}
/*
* gui_get_input_width: return input width (max # chars displayed)
*/
@@ -931,7 +1010,6 @@ gui_draw_window_input (t_gui_window *window)
wborder (window->win_input, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
wrefresh (window->win_input);
}
//refresh ();
if (window->input_buffer_size == 0)
window->input_buffer[0] = '\0';
@@ -1038,6 +1116,8 @@ gui_redraw_window (t_gui_window *window)
if (window->win_nick)
gui_redraw_window_nick (window);
gui_redraw_window_status (window);
if (cfg_look_infobar)
gui_redraw_window_infobar (window);
gui_redraw_window_input (window);
}
@@ -1062,11 +1142,13 @@ gui_switch_to_window (t_gui_window *window)
window->win_chat = ptr_win->win_chat;
window->win_nick = ptr_win->win_nick;
window->win_status = ptr_win->win_status;
window->win_infobar = ptr_win->win_infobar;
window->win_input = ptr_win->win_input;
ptr_win->win_title = NULL;
ptr_win->win_chat = NULL;
ptr_win->win_nick = NULL;
ptr_win->win_status = NULL;
ptr_win->win_infobar = NULL;
ptr_win->win_input = NULL;
ptr_win->is_displayed = 0;
break;
@@ -1091,7 +1173,13 @@ gui_switch_to_window (t_gui_window *window)
window->win_nick_x);
else
window->win_nick = NULL;
window->win_status = newwin (1, COLS, LINES - 2, 0);
if (cfg_look_infobar)
{
window->win_infobar = newwin (1, COLS, LINES - 2, 0);
window->win_status = newwin (1, COLS, LINES - 3, 0);
}
else
window->win_status = newwin (1, COLS, LINES - 2, 0);
window->win_input = newwin (1, COLS, LINES - 1, 0);
}
else
@@ -1232,12 +1320,15 @@ gui_curses_resize_handler ()
delwin (ptr_win->win_nick);
if (ptr_win->win_status)
delwin (ptr_win->win_status);
if (ptr_win->win_infobar)
delwin (ptr_win->win_infobar);
if (ptr_win->win_input)
delwin (ptr_win->win_input);
ptr_win->win_title = NULL;
ptr_win->win_chat = NULL;
ptr_win->win_nick = NULL;
ptr_win->win_status = NULL;
ptr_win->win_infobar = NULL;
ptr_win->win_input = NULL;
gui_switch_to_window (ptr_win);
}
@@ -1255,6 +1346,7 @@ gui_window_init_subwindows (t_gui_window *window)
window->win_chat = NULL;
window->win_nick = NULL;
window->win_status = NULL;
window->win_infobar = NULL;
window->win_input = NULL;
}
@@ -1316,6 +1408,8 @@ gui_init_colors ()
cfg_col_status_data_other & A_CHARTEXT, cfg_col_status_bg);
init_pair (COLOR_WIN_STATUS_MORE,
cfg_col_status_more & A_CHARTEXT, cfg_col_status_bg);
init_pair (COLOR_WIN_INFOBAR,
cfg_col_infobar & A_CHARTEXT, cfg_col_infobar_bg);
init_pair (COLOR_WIN_INPUT,
cfg_col_input & A_CHARTEXT, cfg_col_input_bg);
init_pair (COLOR_WIN_INPUT_CHANNEL,
@@ -1362,6 +1456,7 @@ gui_init_colors ()
color_attr[COLOR_WIN_STATUS_DATA_MSG - 1] = cfg_col_status_data_msg & A_BOLD;
color_attr[COLOR_WIN_STATUS_DATA_OTHER - 1] = cfg_col_status_data_other & A_BOLD;
color_attr[COLOR_WIN_STATUS_MORE - 1] = cfg_col_status_more & A_BOLD;
color_attr[COLOR_WIN_INFOBAR - 1] = cfg_col_infobar & A_BOLD;
color_attr[COLOR_WIN_INPUT - 1] = cfg_col_input & A_BOLD;
color_attr[COLOR_WIN_INPUT_CHANNEL - 1] = cfg_col_input_channel & A_BOLD;
color_attr[COLOR_WIN_INPUT_NICK - 1] = cfg_col_input_nick & A_BOLD;
@@ -1426,6 +1521,8 @@ gui_end ()
delwin (ptr_win->win_nick);
if (ptr_win->win_status)
delwin (ptr_win->win_status);
if (ptr_win->win_infobar)
delwin (ptr_win->win_infobar);
if (ptr_win->win_input)
delwin (ptr_win->win_input);
/* TODO: free input buffer, lines, messages, completion */
+14 -1
View File
@@ -57,10 +57,11 @@ gui_read_keyb ()
{
switch (key)
{
/* resize event: do nothing */
/* resize event */
case KEY_RESIZE:
gui_redraw_window (gui_current_window);
break;
/* previous window */
case KEY_F(6):
gui_switch_to_previous_window ();
break;
@@ -352,10 +353,22 @@ gui_main_loop ()
fd_set read_fd;
static struct timeval timeout;
t_irc_server *ptr_server;
int old_min;
time_t new_time;
struct tm *local_time;
quit_weechat = 0;
old_min = 0;
while (!quit_weechat)
{
new_time = time (NULL);
local_time = localtime (&new_time);
if (local_time->tm_min != old_min)
{
old_min = local_time->tm_min;
gui_redraw_window_infobar (gui_current_window);
}
timeout.tv_sec = 0;
timeout.tv_usec = 10000;
FD_ZERO (&read_fd);
+29
View File
@@ -349,6 +349,35 @@ gui_redraw_window_status (t_gui_window *window)
gui_draw_window_status (window);
}
/*
* gui_draw_window_infobar: draw infobar window
*/
void
gui_draw_window_infobar (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: draw infobar window! */
}
/*
* gui_redraw_window_infobar: redraw infobar window
*/
void
gui_redraw_window_infobar (t_gui_window *window)
{
/* TODO: manage splitted windows! */
if (window != gui_current_window)
return;
/* TODO: first delete window content */
gui_draw_window_infobar (window);
}
/*
* gui_draw_window_input: draw input window
*/
+4
View File
@@ -96,6 +96,10 @@ gui_window_new (void *server, void *channel, int switch_to_window
new_window->line_complete = 1;
new_window->unread_data = 0;
/* init infobar */
new_window->infobar = NULL;
new_window->infobar_length = new_window->win_width + 1;
/* init input buffer */
new_window->input_buffer_alloc = INPUT_BUFFER_BLOCK_SIZE;
new_window->input_buffer = (char *) malloc (INPUT_BUFFER_BLOCK_SIZE);
+32 -13
View File
@@ -26,7 +26,7 @@
#define INPUT_BUFFER_BLOCK_SIZE 256
#define NUM_COLORS 36
#define NUM_COLORS 37
#define COLOR_WIN_TITLE 1
#define COLOR_WIN_CHAT 2
#define COLOR_WIN_CHAT_TIME 3
@@ -43,18 +43,19 @@
#define COLOR_WIN_STATUS_DATA_MSG 14
#define COLOR_WIN_STATUS_DATA_OTHER 15
#define COLOR_WIN_STATUS_MORE 16
#define COLOR_WIN_INPUT 17
#define COLOR_WIN_INPUT_CHANNEL 18
#define COLOR_WIN_INPUT_NICK 19
#define COLOR_WIN_NICK 20
#define COLOR_WIN_NICK_OP 21
#define COLOR_WIN_NICK_HALFOP 22
#define COLOR_WIN_NICK_VOICE 23
#define COLOR_WIN_NICK_SEP 24
#define COLOR_WIN_NICK_SELF 25
#define COLOR_WIN_NICK_PRIVATE 26
#define COLOR_WIN_NICK_FIRST 27
#define COLOR_WIN_NICK_LAST 36
#define COLOR_WIN_INFOBAR 17
#define COLOR_WIN_INPUT 18
#define COLOR_WIN_INPUT_CHANNEL 19
#define COLOR_WIN_INPUT_NICK 20
#define COLOR_WIN_NICK 21
#define COLOR_WIN_NICK_OP 22
#define COLOR_WIN_NICK_HALFOP 23
#define COLOR_WIN_NICK_VOICE 24
#define COLOR_WIN_NICK_SEP 25
#define COLOR_WIN_NICK_SELF 26
#define COLOR_WIN_NICK_PRIVATE 27
#define COLOR_WIN_NICK_FIRST 28
#define COLOR_WIN_NICK_LAST 37
#define COLOR_WIN_NICK_NUMBER (COLOR_WIN_NICK_LAST - COLOR_WIN_NICK_FIRST + 1)
#define SERVER(window) ((t_irc_server *)(window->server))
@@ -107,6 +108,17 @@ struct t_gui_color
int color;
};
typedef struct t_gui_infobar t_gui_infobar;
struct t_gui_infobar
{
char *text; /* infobar text */
int time_displayed; /* delay (ms) before erasing this text */
/* if 0, text is never erased (except */
/* by user action to erase it) */
t_gui_infobar *next_infobar; /* next message for infobar */
};
typedef struct t_gui_window t_gui_window;
struct t_gui_window
@@ -138,6 +150,7 @@ struct t_gui_window
void *win_chat; /* chat window (exemple: channel) */
void *win_nick; /* nick window */
void *win_status; /* status window */
void *win_infobar; /* info bar window */
void *win_input; /* input window */
/* windows for Curses GUI */
@@ -158,6 +171,10 @@ struct t_gui_window
int line_complete; /* current line complete ? (\n ending) */
int unread_data; /* highlight windows with unread data */
/* infobar content */
t_gui_infobar *infobar; /* infobar content (stack of messages) */
int infobar_length; /* length of infobar (width of win + 1) */
/* inupt buffer */
char *input_buffer; /* input buffer */
int input_buffer_alloc; /* input buffer: allocated size in mem */
@@ -211,6 +228,8 @@ extern void gui_draw_window_nick (t_gui_window *);
extern void gui_redraw_window_nick (t_gui_window *);
extern void gui_draw_window_status (t_gui_window *);
extern void gui_redraw_window_status (t_gui_window *);
extern void gui_draw_window_infobar (t_gui_window *);
extern void gui_redraw_window_infobar (t_gui_window *);
extern void gui_draw_window_input (t_gui_window *);
extern void gui_redraw_window_input (t_gui_window *);
extern void gui_redraw_window (t_gui_window *);