summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/weechat.c9
-rw-r--r--src/gui/curses/gui-curses-color.c69
-rw-r--r--src/gui/gtk/gui-gtk-color.c12
-rw-r--r--src/gui/gui-color.h1
4 files changed, 90 insertions, 1 deletions
diff --git a/src/core/weechat.c b/src/core/weechat.c
index 75dac6b3c..8d60ba4a0 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -110,6 +110,7 @@ weechat_display_usage (char *exec_name)
string_iconv_fprintf (stdout, "\n\n");
string_iconv_fprintf (stdout,
_(" -a, --no-connect disable auto-connect to servers at startup\n"
+ " -c, --colors display default colors in terminal\n"
" -d, --dir <path> set WeeChat home directory (default: ~/.weechat)\n"
" -h, --help this help\n"
" -k, --keys display WeeChat default keys\n"
@@ -173,7 +174,13 @@ weechat_parse_args (int argc, char *argv[])
for (i = 1; i < argc; i++)
{
- if ((strcmp (argv[i], "-d") == 0)
+ if ((strcmp (argv[i], "-c") == 0)
+ || (strcmp (argv[i], "--colors") == 0))
+ {
+ gui_color_display_terminal_colors ();
+ weechat_shutdown (EXIT_SUCCESS, 0);
+ }
+ else if ((strcmp (argv[i], "-d") == 0)
|| (strcmp (argv[i], "--dir") == 0))
{
if (i + 1 < argc)
diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c
index 9d8a484a6..5508ac832 100644
--- a/src/gui/curses/gui-curses-color.c
+++ b/src/gui/curses/gui-curses-color.c
@@ -327,6 +327,75 @@ gui_color_init ()
}
/*
+ * gui_color_display_terminal_colors: display terminal colors
+ * This is called by command line option
+ * "-c" / "--colors"
+ */
+
+void
+gui_color_display_terminal_colors ()
+{
+ int lines, line, col, color;
+ int color_support, colors, color_pairs, change_color;
+ char str_line[1024], str_color[64];
+
+ color_support = 0;
+ colors = 0;
+ color_pairs = 0;
+ change_color = 0;
+
+ initscr ();
+ if (has_colors ())
+ {
+ color_support = 1;
+ start_color ();
+ use_default_colors ();
+ colors = COLORS;
+ color_pairs = COLOR_PAIRS;
+ change_color = can_change_color () ? 1 : 0;
+ refresh ();
+ endwin ();
+ }
+ printf ("\n");
+ printf ("%s $TERM=%s COLORS: %d, COLOR_PAIRS: %d, "
+ "can_change_color: %s\n",
+ _("Terminal infos:"),
+ getenv ("TERM"), colors, color_pairs,
+ (change_color) ? "yes" : "no");
+ if (colors == 0)
+ {
+ printf ("%s\n", _("No color support in terminal."));
+ }
+ else
+ {
+ printf ("\n");
+ printf ("%s\n", _("Default colors:"));
+ printf ("------------------------------------------------------------"
+ "--------------------\n");
+ lines = (colors < 16) ? colors : 16;
+ for (line = 0; line < lines; line++)
+ {
+ str_line[0] = '\0';
+ for (col = 0; col < 16; col++)
+ {
+ color = (col * 16) + line;
+ if (color < colors)
+ {
+ snprintf (str_color, sizeof (str_color),
+ "\33[0;38;5;%dm %03d ", color, color);
+ strcat (str_line, str_color);
+ }
+ }
+ printf ("%s\n", str_line);
+ }
+ printf ("\33[0m");
+ printf ("------------------------------------------------------------"
+ "--------------------\n");
+ }
+ printf ("\n");
+}
+
+/*
* gui_color_end: end GUI colors
*/
diff --git a/src/gui/gtk/gui-gtk-color.c b/src/gui/gtk/gui-gtk-color.c
index a4d7d0978..9cbd111d2 100644
--- a/src/gui/gtk/gui-gtk-color.c
+++ b/src/gui/gtk/gui-gtk-color.c
@@ -216,6 +216,18 @@ gui_color_init ()
}
/*
+ * gui_color_display_terminal_colors: display terminal colors
+ * This is called by command line option
+ * "-c" / "--colors"
+ */
+
+void
+gui_color_display_terminal_colors ()
+{
+ /* This function does nothing in Gtk GUI */
+}
+
+/*
* gui_color_end: end GUI colors
*/
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 0bbbda209..a78cefa87 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -144,5 +144,6 @@ extern int gui_color_get_number ();
extern const char *gui_color_get_name (int num_color);
extern void gui_color_init_pairs ();
extern void gui_color_init_weechat ();
+extern void gui_color_display_terminal_colors ();
#endif /* __WEECHAT_GUI_COLOR_H */