1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-02 07:46:38 +02:00

core: add option "-o" for command /color

This commit is contained in:
Sebastien Helleu
2013-07-27 23:23:15 +02:00
parent f3d537dd7a
commit 8cd4bf3750
16 changed files with 90 additions and 36 deletions
+15 -3
View File
@@ -1054,6 +1054,14 @@ COMMAND_CALLBACK(color)
return WEECHAT_RC_OK;
}
/* send terminal/colors info to buffer */
if (string_strcasecmp (argv[1], "-o") == 0)
{
gui_color_info_term_colors (str_color, sizeof (str_color));
input_data (buffer, str_color);
return WEECHAT_RC_OK;
}
/* add a color alias */
if (string_strcasecmp (argv[1], "alias") == 0)
{
@@ -6026,7 +6034,8 @@ command_init ()
N_("define color aliases and display palette of colors"),
N_("alias <color> <name>"
" || unalias <color>"
" || reset"),
" || reset"
" || -o"),
N_(" alias: add an alias for a color\n"
"unalias: delete an alias\n"
" color: color number (greater than or equal to 0, max "
@@ -6034,7 +6043,9 @@ command_init ()
" name: alias name for color (for example: \"orange\")\n"
" reset: reset all color pairs (required when no more "
"color pairs are available if automatic reset is disabled, "
"see option weechat.look.color_pairs_auto_reset)\n\n"
"see option weechat.look.color_pairs_auto_reset)\n"
" -o: send terminal/colors info to current buffer as "
"input\n\n"
"Without argument, this command displays colors in a new "
"buffer.\n\n"
"Examples:\n"
@@ -6044,7 +6055,8 @@ command_init ()
" /color unalias 214"),
"alias %(palette_colors)"
" || unalias %(palette_colors)"
" || reset",
" || reset"
" || -o",
&command_color, NULL);
/*
* give high priority (50000) so that an alias will not take precedence
+19 -7
View File
@@ -748,6 +748,23 @@ gui_color_buffer_display_timer ()
}
}
/*
* Put info about terminal and colors in buffer: $TERM, COLORS, COLOR_PAIRS,
* can_change_color.
*/
void
gui_color_info_term_colors (char *buffer, int size)
{
snprintf (buffer, size,
"$TERM=%s COLORS: %d, COLOR_PAIRS: %d, "
"can_change_color: %s",
getenv ("TERM"),
gui_color_term_colors,
gui_color_term_color_pairs,
(gui_color_term_can_change_color) ? "yes" : "no");
}
/*
* Displays content of color buffer.
*/
@@ -774,13 +791,8 @@ gui_color_buffer_display ()
/* display terminal/colors infos */
y = 0;
gui_chat_printf_y (gui_color_buffer, y++,
"$TERM=%s COLORS: %d, COLOR_PAIRS: %d, "
"can_change_color: %s",
getenv ("TERM"),
gui_color_term_colors,
gui_color_term_color_pairs,
(gui_color_term_can_change_color) ? "yes" : "no");
gui_color_info_term_colors (str_line, sizeof (str_line));
gui_chat_printf_y (gui_color_buffer, y++, "%s", str_line);
/* display palette of colors */
y++;
+1
View File
@@ -185,6 +185,7 @@ extern int gui_color_get_term_colors ();
extern const char *gui_color_get_name (int num_color);
extern void gui_color_init_weechat ();
extern void gui_color_display_terminal_colors ();
extern void gui_color_info_term_colors (char *buffer, int size);
extern void gui_color_buffer_display ();
extern void gui_color_switch_colors ();
extern void gui_color_reset_pairs ();