mirror of
https://github.com/weechat/weechat.git
synced 2026-07-07 02:03:13 +02:00
Version 0.0.7-pre2 - window management
This commit is contained in:
+60
-19
@@ -88,6 +88,14 @@ t_weechat_command weechat_commands[] =
|
||||
{ "unalias", N_("remove an alias"),
|
||||
N_("alias_name"), N_("alias_name: name of alias to remove"),
|
||||
1, 1, NULL, weechat_cmd_unalias },
|
||||
{ "window", N_("manage windows"),
|
||||
N_("[action]"),
|
||||
N_("action: action to do:\n"
|
||||
" close close current window\n"
|
||||
" list list opened windows (no parameter implies this list)\n"
|
||||
" splith split current window horizontally\n"
|
||||
" splitv split current window vertically"),
|
||||
0, MAX_ARGS, weechat_cmd_window, NULL },
|
||||
{ NULL, NULL, NULL, NULL, 0, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -707,46 +715,46 @@ user_command (t_irc_server *server, char *command)
|
||||
{
|
||||
if ((command[0] == '/') && (command[1] == '/'))
|
||||
command++;
|
||||
if (server && (!WIN_IS_SERVER(gui_current_window)))
|
||||
if (server && (!VIEW_IS_SERVER(gui_current_view)))
|
||||
{
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n",
|
||||
CHANNEL(gui_current_window)->name,
|
||||
CHANNEL(gui_current_view)->name,
|
||||
command);
|
||||
|
||||
if (WIN_IS_PRIVATE(gui_current_window))
|
||||
if (VIEW_IS_PRIVATE(gui_current_view))
|
||||
{
|
||||
gui_printf_color_type (CHANNEL(gui_current_window)->window,
|
||||
gui_printf_color_type (CHANNEL(gui_current_view)->view,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "<");
|
||||
gui_printf_color_type (CHANNEL(gui_current_window)->window,
|
||||
gui_printf_color_type (CHANNEL(gui_current_view)->view,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_NICK_SELF,
|
||||
"%s", server->nick);
|
||||
gui_printf_color_type (CHANNEL(gui_current_window)->window,
|
||||
gui_printf_color_type (CHANNEL(gui_current_view)->view,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "> ");
|
||||
gui_printf_color_type (CHANNEL(gui_current_window)->window,
|
||||
gui_printf_color_type (CHANNEL(gui_current_view)->view,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", command);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_nick = nick_search (CHANNEL(gui_current_window), server->nick);
|
||||
ptr_nick = nick_search (CHANNEL(gui_current_view), server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (CHANNEL(gui_current_window)->window, ptr_nick,
|
||||
irc_display_nick (CHANNEL(gui_current_view)->view, ptr_nick,
|
||||
MSG_TYPE_NICK, 1, 1, 0);
|
||||
gui_printf_color (CHANNEL(gui_current_window)->window,
|
||||
gui_printf_color (CHANNEL(gui_current_view)->view,
|
||||
COLOR_WIN_CHAT, "%s\n", command);
|
||||
}
|
||||
else
|
||||
gui_printf (server->window,
|
||||
gui_printf (server->view,
|
||||
_("%s cannot find nick for sending message\n"),
|
||||
WEECHAT_ERROR);
|
||||
}
|
||||
}
|
||||
else
|
||||
gui_printf ((server) ? server->window : NULL,
|
||||
gui_printf ((server) ? server->view : NULL,
|
||||
_("This window is not a channel!\n"));
|
||||
}
|
||||
}
|
||||
@@ -820,7 +828,7 @@ weechat_cmd_clear (int argc, char **argv)
|
||||
if (argc == 1)
|
||||
{
|
||||
if (strcmp (argv[0], "-all") == 0)
|
||||
gui_window_clear_all ();
|
||||
gui_view_clear_all ();
|
||||
else
|
||||
{
|
||||
gui_printf (NULL,
|
||||
@@ -830,7 +838,7 @@ weechat_cmd_clear (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
else
|
||||
gui_window_clear (gui_current_window);
|
||||
gui_view_clear (gui_current_view);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -857,9 +865,9 @@ weechat_cmd_connect (int argc, char **argv)
|
||||
WEECHAT_ERROR, argv[0]);
|
||||
return -1;
|
||||
}
|
||||
if (!ptr_server->window)
|
||||
if (!ptr_server->view)
|
||||
{
|
||||
if (!gui_window_new (ptr_server, NULL, 1))
|
||||
if (!gui_view_new (gui_current_view->window, ptr_server, NULL, 1))
|
||||
return -1;
|
||||
}
|
||||
if (server_connect (ptr_server))
|
||||
@@ -906,7 +914,7 @@ weechat_cmd_disconnect (int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
server_disconnect (ptr_server);
|
||||
gui_redraw_window_status (gui_current_window);
|
||||
gui_redraw_view_status (gui_current_view);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1300,7 +1308,7 @@ weechat_cmd_server (int argc, char **argv)
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT, _("has been deleted\n"));
|
||||
|
||||
server_free (server_found);
|
||||
gui_redraw_window (gui_current_window);
|
||||
gui_redraw_view (gui_current_view);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1441,7 +1449,7 @@ weechat_cmd_server (int argc, char **argv)
|
||||
|
||||
if (new_server->autoconnect)
|
||||
{
|
||||
(void) gui_window_new (new_server, NULL, 1);
|
||||
(void) gui_view_new (gui_current_view->window, new_server, NULL, 1);
|
||||
if (server_connect (new_server))
|
||||
irc_login (new_server);
|
||||
}
|
||||
@@ -1619,3 +1627,36 @@ weechat_cmd_unalias (char *arguments)
|
||||
arguments);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_window: manage windows
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_window (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
t_irc_server server, *ptr_server, *server_found, *new_server;
|
||||
|
||||
if ((argc == 0) || ((argc == 1) && (strcasecmp (argv[0], "list") == 0)))
|
||||
{
|
||||
/* list opened windows */
|
||||
gui_printf (NULL, "window list -- NOT DEVELOPED!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcasecmp (argv[0], "splith") == 0)
|
||||
{
|
||||
/* split window horizontally */
|
||||
gui_printf (NULL, "window splith -- NOT DEVELOPED!\n");
|
||||
}
|
||||
else if (strcasecmp (argv[0], "splitv") == 0)
|
||||
{
|
||||
/* split window vertically */
|
||||
gui_printf (NULL, "window splitv -- NOT DEVELOPED!\n");
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -76,5 +76,6 @@ extern int weechat_cmd_save (int, char **);
|
||||
extern int weechat_cmd_server (int, char **);
|
||||
extern int weechat_cmd_set (char *);
|
||||
extern int weechat_cmd_unalias (char *);
|
||||
extern int weechat_cmd_window (int, char **);
|
||||
|
||||
#endif /* command.h */
|
||||
|
||||
+15
-15
@@ -44,7 +44,7 @@ int num_history_general = 0;
|
||||
*/
|
||||
|
||||
void
|
||||
history_add (void *window, char *string)
|
||||
history_add (void *view, char *string)
|
||||
{
|
||||
t_history *new_history, *ptr_history;
|
||||
|
||||
@@ -83,26 +83,26 @@ history_add (void *window, char *string)
|
||||
{
|
||||
new_history->text = strdup (string);
|
||||
|
||||
if (((t_gui_window *)(window))->history)
|
||||
((t_gui_window *)(window))->history->prev_history = new_history;
|
||||
if (((t_gui_view *)(view))->history)
|
||||
((t_gui_view *)(view))->history->prev_history = new_history;
|
||||
else
|
||||
((t_gui_window *)(window))->last_history = new_history;
|
||||
new_history->next_history = ((t_gui_window *)(window))->history;
|
||||
((t_gui_view *)(view))->last_history = new_history;
|
||||
new_history->next_history = ((t_gui_view *)(view))->history;
|
||||
new_history->prev_history = NULL;
|
||||
((t_gui_window *)window)->history = new_history;
|
||||
((t_gui_window *)(window))->num_history++;
|
||||
((t_gui_view *)view)->history = new_history;
|
||||
((t_gui_view *)(view))->num_history++;
|
||||
|
||||
/* remove one command if necessary */
|
||||
if ((cfg_history_max_commands > 0)
|
||||
&& (((t_gui_window *)(window))->num_history > cfg_history_max_commands))
|
||||
&& (((t_gui_view *)(view))->num_history > cfg_history_max_commands))
|
||||
{
|
||||
ptr_history = ((t_gui_window *)window)->last_history->prev_history;
|
||||
((t_gui_window *)window)->last_history->prev_history->next_history = NULL;
|
||||
if (((t_gui_window *)window)->last_history->text)
|
||||
free (((t_gui_window *)window)->last_history->text);
|
||||
free (((t_gui_window *)window)->last_history);
|
||||
((t_gui_window *)window)->last_history = ptr_history;
|
||||
((t_gui_window *)(window))->num_history++;
|
||||
ptr_history = ((t_gui_view *)view)->last_history->prev_history;
|
||||
((t_gui_view *)view)->last_history->prev_history->next_history = NULL;
|
||||
if (((t_gui_view *)view)->last_history->text)
|
||||
free (((t_gui_view *)view)->last_history->text);
|
||||
free (((t_gui_view *)view)->last_history);
|
||||
((t_gui_view *)view)->last_history = ptr_history;
|
||||
((t_gui_view *)(view))->num_history++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -109,33 +109,33 @@ t_config_option weechat_options_look[] =
|
||||
{ "look_nicklist", N_("display nicklist window"),
|
||||
N_("display nicklist window (for channel windows)"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_look_nicklist, NULL, config_change_windows },
|
||||
NULL, NULL, &cfg_look_nicklist, NULL, config_change_views },
|
||||
{ "look_nicklist_position", N_("nicklist position"),
|
||||
N_("nicklist position (top, left, right (default), bottom)"),
|
||||
OPTION_TYPE_INT_WITH_STRING, 0, 0, 0,
|
||||
"right", cfg_look_nicklist_position_values, &cfg_look_nicklist_position, NULL, config_change_windows },
|
||||
"right", cfg_look_nicklist_position_values, &cfg_look_nicklist_position, NULL, config_change_views },
|
||||
{ "look_nicklist_min_size", N_("min size for nicklist"),
|
||||
N_("min size for nicklist (width or height, depending on look_nicklist_position "
|
||||
"(0 = no min size))"),
|
||||
OPTION_TYPE_INT, 0, 100, 0,
|
||||
NULL, NULL, &cfg_look_nicklist_min_size, NULL, config_change_windows },
|
||||
NULL, NULL, &cfg_look_nicklist_min_size, NULL, config_change_views },
|
||||
{ "look_nicklist_max_size", N_("max size for nicklist"),
|
||||
N_("max size for nicklist (width or height, depending on look_nicklist_position "
|
||||
"(0 = no max size; if min == max and > 0, then size is fixed))"),
|
||||
OPTION_TYPE_INT, 0, 100, 0,
|
||||
NULL, NULL, &cfg_look_nicklist_max_size, NULL, config_change_windows },
|
||||
NULL, NULL, &cfg_look_nicklist_max_size, NULL, config_change_views },
|
||||
{ "look_no_nickname", N_("text to display instead of nick when not connected"),
|
||||
N_("text to display instead of nick when not connected"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"-cmd-", NULL, NULL, &cfg_look_no_nickname, config_change_window_content },
|
||||
"-cmd-", NULL, NULL, &cfg_look_no_nickname, config_change_view_content },
|
||||
{ "look_nickmode", N_("display nick mode ((half)op/voice) before each nick"),
|
||||
N_("display nick mode ((half)op/voice) before each nick"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_look_nickmode, NULL, config_change_windows },
|
||||
NULL, NULL, &cfg_look_nickmode, NULL, config_change_views },
|
||||
{ "look_nickmode_empty", N_("display space if nick mode is not (half)op/voice"),
|
||||
N_("display space if nick mode is not (half)op/voice"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
|
||||
NULL, NULL, &cfg_look_nickmode_empty, NULL, config_change_windows },
|
||||
NULL, NULL, &cfg_look_nickmode_empty, NULL, config_change_views },
|
||||
{ "look_nick_completor", N_("the string inserted after nick completion"),
|
||||
N_("the string inserted after nick completion"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
@@ -143,11 +143,11 @@ t_config_option weechat_options_look[] =
|
||||
{ "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, config_change_windows },
|
||||
NULL, NULL, &cfg_look_infobar, NULL, config_change_views },
|
||||
{ "look_infobar_timestamp", N_("timestamp for time in infobar"),
|
||||
N_("timestamp for time in infobar"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"%B, %A %d %G - %H:%M", NULL, NULL, &cfg_look_infobar_timestamp, config_change_window_content },
|
||||
"%B, %A %d %G - %H:%M", NULL, NULL, &cfg_look_infobar_timestamp, config_change_view_content },
|
||||
{ "look_infobar_delay_highlight", N_("delay (in seconds) for highlight messages in infobar"),
|
||||
N_("delay (in seconds) for highlight messages in infobar "
|
||||
"(0 = disable highlight notifications in infobar)"),
|
||||
@@ -615,24 +615,24 @@ config_change_title ()
|
||||
}
|
||||
|
||||
/*
|
||||
* config_change_windows: called when windows change (for example nicklist)
|
||||
* config_change_views: called when views change (for example nicklist)
|
||||
*/
|
||||
|
||||
void
|
||||
config_change_windows ()
|
||||
config_change_views ()
|
||||
{
|
||||
gui_switch_to_window (gui_current_window);
|
||||
gui_redraw_window (gui_current_window);
|
||||
gui_switch_to_view (gui_current_view);
|
||||
gui_redraw_view (gui_current_view);
|
||||
}
|
||||
|
||||
/*
|
||||
* config_change_window_content: called when content of a window changes
|
||||
* config_change_view_content: called when content of a view changes
|
||||
*/
|
||||
|
||||
void
|
||||
config_change_window_content ()
|
||||
config_change_view_content ()
|
||||
{
|
||||
gui_redraw_window (gui_current_window);
|
||||
gui_redraw_view (gui_current_view);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -158,8 +158,8 @@ extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS];
|
||||
extern char *config_get_section ();
|
||||
extern void config_change_noop ();
|
||||
extern void config_change_title ();
|
||||
extern void config_change_windows ();
|
||||
extern void config_change_window_content ();
|
||||
extern void config_change_views ();
|
||||
extern void config_change_view_content ();
|
||||
extern void config_change_color ();
|
||||
extern int config_option_set_value (t_config_option *, char *);
|
||||
extern t_config_option *config_option_search (char *);
|
||||
|
||||
Reference in New Issue
Block a user