mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 07:16:37 +02:00
core: rename option weechat.look.set_title to weechat.look.window_title (evaluated string)
This commit is contained in:
+12
-11
@@ -164,10 +164,10 @@ struct t_config_option *config_look_scroll_page_percent;
|
||||
struct t_config_option *config_look_search_text_not_found_alert;
|
||||
struct t_config_option *config_look_separator_horizontal;
|
||||
struct t_config_option *config_look_separator_vertical;
|
||||
struct t_config_option *config_look_set_title;
|
||||
struct t_config_option *config_look_time_format;
|
||||
struct t_config_option *config_look_window_separator_horizontal;
|
||||
struct t_config_option *config_look_window_separator_vertical;
|
||||
struct t_config_option *config_look_window_title;
|
||||
|
||||
/* config, colors section */
|
||||
|
||||
@@ -316,18 +316,17 @@ config_change_save_config_on_exit (void *data, struct t_config_option *option)
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for changes on option "weechat.look.set_title".
|
||||
* Callback for changes on option "weechat.look.window_title".
|
||||
*/
|
||||
|
||||
void
|
||||
config_change_title (void *data, struct t_config_option *option)
|
||||
config_change_window_title (void *data, struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
gui_window_set_title (version_get_name_version ());
|
||||
gui_window_set_title (CONFIG_STRING(config_look_window_title));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2525,12 +2524,6 @@ config_weechat_init_options ()
|
||||
"(empty value will draw a real line with ncurses), wide chars are "
|
||||
"NOT allowed here"),
|
||||
NULL, 0, 0, "", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
|
||||
config_look_set_title = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"set_title", "boolean",
|
||||
N_("set title for window (terminal for Curses GUI) with "
|
||||
"name and version"),
|
||||
NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_title, NULL, NULL, NULL);
|
||||
config_look_time_format = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"time_format", "string",
|
||||
@@ -2547,6 +2540,14 @@ config_weechat_init_options ()
|
||||
"window_separator_vertical", "boolean",
|
||||
N_("display a vertical separator between windows"),
|
||||
NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
|
||||
config_look_window_title = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"window_title", "string",
|
||||
N_("title for window (terminal for Curses GUI), set on startup; "
|
||||
"an empty string will keep title unchanged "
|
||||
"(note: content is evaluated, see /help eval)"),
|
||||
NULL, 0, 0, "WeeChat ${info:version}", NULL, 0, NULL, NULL,
|
||||
&config_change_window_title, NULL, NULL, NULL);
|
||||
|
||||
/* palette */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "palette",
|
||||
|
||||
@@ -188,10 +188,10 @@ extern struct t_config_option *config_look_scroll_page_percent;
|
||||
extern struct t_config_option *config_look_search_text_not_found_alert;
|
||||
extern struct t_config_option *config_look_separator_horizontal;
|
||||
extern struct t_config_option *config_look_separator_vertical;
|
||||
extern struct t_config_option *config_look_set_title;
|
||||
extern struct t_config_option *config_look_time_format;
|
||||
extern struct t_config_option *config_look_window_separator_horizontal;
|
||||
extern struct t_config_option *config_look_window_separator_vertical;
|
||||
extern struct t_config_option *config_look_window_title;
|
||||
|
||||
extern struct t_config_option *config_color_bar_more;
|
||||
extern struct t_config_option *config_color_chat;
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
#include "../gui/gui-layout.h"
|
||||
#include "../gui/gui-main.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "../plugins/plugin-api.h"
|
||||
|
||||
|
||||
int weechat_debug_core = 0; /* debug level for core */
|
||||
@@ -452,6 +453,7 @@ main (int argc, char *argv[])
|
||||
weechat_parse_args (argc, argv); /* parse command line args */
|
||||
weechat_create_home_dir (); /* create WeeChat home directory */
|
||||
log_init (); /* init log file */
|
||||
plugin_api_init (); /* create some hooks (info,hdata,..)*/
|
||||
secure_read (); /* read secured data options */
|
||||
config_weechat_read (); /* read WeeChat options */
|
||||
network_init_gnutls (); /* init GnuTLS */
|
||||
|
||||
@@ -210,8 +210,11 @@ gui_main_init ()
|
||||
{
|
||||
gui_current_window = gui_windows;
|
||||
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
gui_window_set_title (version_get_name_version ());
|
||||
if (CONFIG_STRING(config_look_window_title)
|
||||
&& CONFIG_STRING(config_look_window_title)[0])
|
||||
{
|
||||
gui_window_set_title (CONFIG_STRING(config_look_window_title));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -538,8 +541,11 @@ gui_main_end (int clean_exit)
|
||||
gui_history_global_free ();
|
||||
|
||||
/* reset title */
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
if (CONFIG_STRING(config_look_window_title)
|
||||
&& CONFIG_STRING(config_look_window_title)[0])
|
||||
{
|
||||
gui_window_set_title (NULL);
|
||||
}
|
||||
|
||||
/* end color */
|
||||
gui_color_end ();
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "../../core/wee-config.h"
|
||||
#include "../../core/wee-eval.h"
|
||||
#include "../../core/wee-hook.h"
|
||||
#include "../../core/wee-log.h"
|
||||
#include "../../core/wee-string.h"
|
||||
@@ -2344,90 +2345,77 @@ gui_window_refresh_screen (int full_refresh)
|
||||
|
||||
/*
|
||||
* Sets terminal title.
|
||||
*
|
||||
* Note: the content of "title" (if not NULL) is evaluated, so variables like
|
||||
* "${info:version}" can be used inside.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_window_set_title (const char *title)
|
||||
{
|
||||
char *shell, *shellname;
|
||||
char *envterm = getenv ("TERM");
|
||||
char *envshell = getenv ("SHELL");
|
||||
char *new_title, *envterm, *envshell, *shell, *shellname;
|
||||
|
||||
if (envterm)
|
||||
envterm = getenv ("TERM");
|
||||
if (!envterm)
|
||||
return;
|
||||
|
||||
new_title = (title && title[0]) ?
|
||||
eval_expression (title, NULL, NULL, NULL) : strdup ("Terminal");
|
||||
if (!new_title)
|
||||
return;
|
||||
|
||||
if (strcmp (envterm, "sun-cmd") == 0)
|
||||
{
|
||||
printf ("\033]l%s\033\\", new_title);
|
||||
}
|
||||
else if (strcmp (envterm, "hpterm") == 0)
|
||||
{
|
||||
printf ("\033&f0k%dD%s", (int)(strlen (new_title) + 1), new_title);
|
||||
}
|
||||
/* the following terminals support the xterm escape codes */
|
||||
else if ((strncmp (envterm, "xterm", 5) == 0)
|
||||
|| (strncmp (envterm, "rxvt", 4) == 0)
|
||||
|| (strcmp (envterm, "Eterm") == 0)
|
||||
|| (strcmp (envterm, "aixterm") == 0)
|
||||
|| (strcmp (envterm, "iris-ansi") == 0)
|
||||
|| (strcmp (envterm, "dtterm") == 0))
|
||||
{
|
||||
printf ("\33]0;%s\7", new_title);
|
||||
}
|
||||
else if (strncmp (envterm, "screen", 6) == 0)
|
||||
{
|
||||
if (title && title[0])
|
||||
{
|
||||
if (strcmp (envterm, "sun-cmd") == 0)
|
||||
{
|
||||
printf ("\033]l%s\033\\", title);
|
||||
}
|
||||
else if (strcmp (envterm, "hpterm") == 0)
|
||||
{
|
||||
printf ("\033&f0k%dD%s", (int)(strlen(title) + 1), title);
|
||||
}
|
||||
/* the following terminals support the xterm escape codes */
|
||||
else if ((strncmp (envterm, "xterm", 5) == 0)
|
||||
|| (strncmp (envterm, "rxvt", 4) == 0)
|
||||
|| (strcmp (envterm, "Eterm") == 0)
|
||||
|| (strcmp (envterm, "aixterm") == 0)
|
||||
|| (strcmp (envterm, "iris-ansi") == 0)
|
||||
|| (strcmp (envterm, "dtterm") == 0))
|
||||
{
|
||||
printf ("\33]0;%s\7", title);
|
||||
}
|
||||
else if (strncmp (envterm, "screen", 6) == 0)
|
||||
{
|
||||
printf ("\033k%s\033\\", title);
|
||||
/* trying to set the title of a backgrounded xterm like terminal */
|
||||
printf ("\33]0;%s\7", title);
|
||||
}
|
||||
printf ("\033k%s\033\\", title);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp (envterm, "sun-cmd") == 0)
|
||||
envshell = getenv ("SHELL");
|
||||
if (envshell)
|
||||
{
|
||||
printf ("\033]l%s\033\\", "Terminal");
|
||||
}
|
||||
else if (strcmp (envterm, "hpterm") == 0)
|
||||
{
|
||||
printf ("\033&f0k%dD%s", (int)strlen("Terminal"), "Terminal");
|
||||
}
|
||||
/* the following terminals support the xterm escape codes */
|
||||
else if ((strncmp (envterm, "xterm", 5) == 0)
|
||||
|| (strncmp (envterm, "rxvt", 4) == 0)
|
||||
|| (strcmp (envterm, "Eterm") == 0)
|
||||
|| (strcmp( envterm, "aixterm") == 0)
|
||||
|| (strcmp( envterm, "iris-ansi") == 0)
|
||||
|| (strcmp( envterm, "dtterm") == 0))
|
||||
{
|
||||
printf ("\33]0;%s\7", "Terminal");
|
||||
}
|
||||
else if (strncmp (envterm, "screen", 6) == 0)
|
||||
{
|
||||
if (envshell)
|
||||
shell = strdup (envshell);
|
||||
if (shell)
|
||||
{
|
||||
shell = strdup (envshell);
|
||||
if (shell)
|
||||
{
|
||||
shellname = basename (shell);
|
||||
printf ("\033k%s\033\\", (shellname) ? shellname : shell);
|
||||
free (shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("\033k%s\033\\", envterm);
|
||||
}
|
||||
shellname = basename (shell);
|
||||
printf ("\033k%s\033\\", (shellname) ? shellname : shell);
|
||||
free (shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("\033k%s\033\\", envterm);
|
||||
}
|
||||
/* tryning to reset the title of a backgrounded xterm like terminal */
|
||||
printf ("\33]0;%s\7", "Terminal");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("\033k%s\033\\", envterm);
|
||||
}
|
||||
}
|
||||
fflush (stdout);
|
||||
/* trying to set the title of a backgrounded xterm like terminal */
|
||||
printf ("\33]0;%s\7", new_title);
|
||||
}
|
||||
fflush (stdout);
|
||||
|
||||
free (new_title);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1183,9 +1183,6 @@ plugin_display_short_list ()
|
||||
void
|
||||
plugin_init (int auto_load, int argc, char *argv[])
|
||||
{
|
||||
/* init plugin API (create some hooks) */
|
||||
plugin_api_init ();
|
||||
|
||||
/* read plugins options on disk */
|
||||
plugin_config_init ();
|
||||
plugin_config_read ();
|
||||
|
||||
Reference in New Issue
Block a user