mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 05:16:38 +02:00
script: add status "a" (autoloaded) for scripts
This commit is contained in:
@@ -69,7 +69,7 @@ script_action_list ()
|
||||
ptr_name = weechat_hdata_string (hdata, ptr_script, "name");
|
||||
weechat_printf (NULL, " %s %s%s%s.%s %s%s %s(%s%s%s)",
|
||||
script_repo_get_status_for_display (script_repo_search_by_name (ptr_name),
|
||||
"*?HN", 0),
|
||||
"*?iaHN", 0),
|
||||
weechat_color (weechat_config_string (script_config_color_text_name)),
|
||||
ptr_name,
|
||||
weechat_color (weechat_config_string (script_config_color_text_extension)),
|
||||
|
||||
@@ -202,7 +202,7 @@ script_buffer_display_line_script (int line, struct t_repo_script *script)
|
||||
snprintf (str_item, sizeof (str_item),
|
||||
"%s",
|
||||
script_repo_get_status_for_display (script,
|
||||
"*iHrN", 0));
|
||||
"*iaHrN", 0));
|
||||
break;
|
||||
case 't': /* tags */
|
||||
if (script->tags)
|
||||
@@ -416,19 +416,26 @@ script_buffer_display_detail_script (struct t_repo_script *script)
|
||||
else
|
||||
{
|
||||
weechat_printf_y (script_buffer, line + 1,
|
||||
"%s: %s%s (%s%s%s%s%s%s%s%s%s%s )",
|
||||
"%s: %s%s (%s%s%s%s%s%s%s%s%s%s%s%s )",
|
||||
script_buffer_detail_label (_(labels[line]), max_length),
|
||||
script_repo_get_status_for_display (script, "*iHrN", 1),
|
||||
script_repo_get_status_for_display (script, "*iaHrN", 1),
|
||||
weechat_color ("chat"),
|
||||
(script->popularity > 0) ? " " : "",
|
||||
(script->popularity > 0) ? _("popular") : "",
|
||||
(script->status & SCRIPT_STATUS_INSTALLED) ? " " : "",
|
||||
/* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
|
||||
(script->status & SCRIPT_STATUS_INSTALLED) ? _("installed") : "",
|
||||
(script->status & SCRIPT_STATUS_AUTOLOADED) ? " " : "",
|
||||
/* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
|
||||
(script->status & SCRIPT_STATUS_AUTOLOADED) ? _("autoloaded") : "",
|
||||
(script->status & SCRIPT_STATUS_HELD) ? " " : "",
|
||||
/* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
|
||||
(script->status & SCRIPT_STATUS_HELD) ? _("held") : "",
|
||||
(script->status & SCRIPT_STATUS_RUNNING) ? " " : "",
|
||||
/* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
|
||||
(script->status & SCRIPT_STATUS_RUNNING) ? _("running") : "",
|
||||
(script->status & SCRIPT_STATUS_NEW_VERSION) ? " " : "",
|
||||
/* TRANSLATORS: translation must be one short word without spaces (replace spaces by underscores if needed) */
|
||||
(script->status & SCRIPT_STATUS_NEW_VERSION) ? _("obsolete") : "");
|
||||
}
|
||||
line++;
|
||||
|
||||
@@ -233,11 +233,12 @@ script_command_init ()
|
||||
"with list of scripts.\n\n"
|
||||
"On script buffer, the possible status for each "
|
||||
"script are:\n"
|
||||
" * i H r N\n"
|
||||
" | | | | |\n"
|
||||
" | | | | obsolete (new version available)\n"
|
||||
" | | | running (loaded)\n"
|
||||
" | | held\n"
|
||||
" * i a H r N\n"
|
||||
" | | | | | |\n"
|
||||
" | | | | | obsolete (new version available)\n"
|
||||
" | | | | running (loaded)\n"
|
||||
" | | | held\n"
|
||||
" | | autoloaded\n"
|
||||
" | installed\n"
|
||||
" popular script\n\n"
|
||||
"Keys on script buffer:\n"
|
||||
|
||||
@@ -46,6 +46,7 @@ struct t_config_option *script_config_look_sort;
|
||||
|
||||
struct t_config_option *script_config_color_status_popular;
|
||||
struct t_config_option *script_config_color_status_installed;
|
||||
struct t_config_option *script_config_color_status_autoloaded;
|
||||
struct t_config_option *script_config_color_status_held;
|
||||
struct t_config_option *script_config_color_status_running;
|
||||
struct t_config_option *script_config_color_status_obsolete;
|
||||
@@ -343,10 +344,11 @@ script_config_init ()
|
||||
script_config_file, ptr_section,
|
||||
"sort", "string",
|
||||
N_("default sort keys for scripts: comma-separated list of identifiers: "
|
||||
"a=author, d=date added, e=extension, i=installed, l=language, "
|
||||
"n=name, o=obsolete, p=popularity, r=running, u=date updated; char "
|
||||
"\"-\" can be used before identifier to reverse order; example: "
|
||||
"\"i,u\": installed scripts first, sorted by update date"),
|
||||
"a=author, A=autoloaded, d=date added, e=extension, i=installed, "
|
||||
"l=language, n=name, o=obsolete, p=popularity, r=running, "
|
||||
"u=date updated; char \"-\" can be used before identifier to reverse "
|
||||
"order; example: \"i,u\": installed scripts first, sorted by update "
|
||||
"date"),
|
||||
NULL, 0, 0, "p,n", NULL, 0,
|
||||
NULL, NULL, &script_config_change_sort_cb, NULL, NULL, NULL);
|
||||
|
||||
@@ -374,6 +376,12 @@ script_config_init ()
|
||||
N_("color for status \"installed\" (\"i\")"),
|
||||
NULL, 0, 0, "lightcyan", NULL, 0,
|
||||
NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
|
||||
script_config_color_status_autoloaded = weechat_config_new_option (
|
||||
script_config_file, ptr_section,
|
||||
"status_autoloaded", "color",
|
||||
N_("color for status \"autoloaded\" (\"a\")"),
|
||||
NULL, 0, 0, "cyan", NULL, 0,
|
||||
NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
|
||||
script_config_color_status_held = weechat_config_new_option (
|
||||
script_config_file, ptr_section,
|
||||
"status_held", "color",
|
||||
|
||||
@@ -29,6 +29,7 @@ extern struct t_config_option *script_config_look_sort;
|
||||
|
||||
extern struct t_config_option *script_config_color_status_popular;
|
||||
extern struct t_config_option *script_config_color_status_installed;
|
||||
extern struct t_config_option *script_config_color_status_autoloaded;
|
||||
extern struct t_config_option *script_config_color_status_held;
|
||||
extern struct t_config_option *script_config_color_status_running;
|
||||
extern struct t_config_option *script_config_color_status_obsolete;
|
||||
|
||||
@@ -149,7 +149,7 @@ script_repo_search_by_name_ext (const char *name_with_extension)
|
||||
/*
|
||||
* script_repo_get_status_for_display: get status for display
|
||||
* list is the codes of status to display
|
||||
* (exemple: "*iHrN" for all status)
|
||||
* (exemple: "*iaHrN" for all status)
|
||||
*/
|
||||
|
||||
const char *
|
||||
@@ -178,6 +178,10 @@ script_repo_get_status_for_display (struct t_repo_script *script,
|
||||
strcat (str_status, weechat_color (weechat_config_string (script_config_color_status_installed)));
|
||||
strcat (str_status, (script && (script->status & SCRIPT_STATUS_INSTALLED)) ? "i" : str_space);
|
||||
break;
|
||||
case 'a':
|
||||
strcat (str_status, weechat_color (weechat_config_string (script_config_color_status_autoloaded)));
|
||||
strcat (str_status, (script && (script->status & SCRIPT_STATUS_AUTOLOADED)) ? "a" : str_space);
|
||||
break;
|
||||
case '?':
|
||||
strcat (str_status, weechat_color (weechat_config_string (script_config_color_status_unknown)));
|
||||
strcat (str_status, (script) ? str_space : "?");
|
||||
@@ -265,6 +269,14 @@ script_repo_compare_scripts (struct t_repo_script *script1,
|
||||
case 'a': /* author */
|
||||
cmp = strcmp (script1->author, script2->author);
|
||||
break;
|
||||
case 'A': /* status autoloaded */
|
||||
if ((script1->status & SCRIPT_STATUS_AUTOLOADED)
|
||||
&& !(script2->status & SCRIPT_STATUS_AUTOLOADED))
|
||||
cmp = -1;
|
||||
else if (!(script1->status & SCRIPT_STATUS_AUTOLOADED)
|
||||
&& (script2->status & SCRIPT_STATUS_AUTOLOADED))
|
||||
cmp = 1;
|
||||
break;
|
||||
case 'd': /* date added */
|
||||
if (script1->date_added > script2->date_added)
|
||||
cmp = -1;
|
||||
@@ -638,6 +650,7 @@ script_repo_update_status (struct t_repo_script *script)
|
||||
if (stat (filename, &st) == 0)
|
||||
{
|
||||
script->status |= SCRIPT_STATUS_INSTALLED;
|
||||
script->status |= SCRIPT_STATUS_AUTOLOADED;
|
||||
md5sum = script_repo_md5sum_file (filename);
|
||||
}
|
||||
else
|
||||
@@ -1352,9 +1365,10 @@ script_repo_print_log ()
|
||||
weechat_log_printf (" popularity. . . . . . : %d", ptr_script->popularity);
|
||||
weechat_log_printf (" date_added. . . . . . : %ld", ptr_script->date_added);
|
||||
weechat_log_printf (" date_updated. . . . . : %ld", ptr_script->date_updated);
|
||||
weechat_log_printf (" status. . . . . . . . : %d (%s%s%s%s )",
|
||||
weechat_log_printf (" status. . . . . . . . : %d (%s%s%s%s%s )",
|
||||
ptr_script->status,
|
||||
(ptr_script->status & SCRIPT_STATUS_INSTALLED) ? " installed": "",
|
||||
(ptr_script->status & SCRIPT_STATUS_AUTOLOADED) ? " autoloaded": "",
|
||||
(ptr_script->status & SCRIPT_STATUS_HELD) ? " held": "",
|
||||
(ptr_script->status & SCRIPT_STATUS_RUNNING) ? " running": "",
|
||||
(ptr_script->status & SCRIPT_STATUS_NEW_VERSION) ? " new_version": "");
|
||||
|
||||
@@ -22,9 +22,10 @@
|
||||
|
||||
/* status for script */
|
||||
#define SCRIPT_STATUS_INSTALLED 1
|
||||
#define SCRIPT_STATUS_HELD 2
|
||||
#define SCRIPT_STATUS_RUNNING 4
|
||||
#define SCRIPT_STATUS_NEW_VERSION 8
|
||||
#define SCRIPT_STATUS_AUTOLOADED 2
|
||||
#define SCRIPT_STATUS_HELD 4
|
||||
#define SCRIPT_STATUS_RUNNING 8
|
||||
#define SCRIPT_STATUS_NEW_VERSION 16
|
||||
|
||||
struct t_repo_script
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user