commit - dc7619245dfed3a4b315225e08e20016fa51919b
commit + 1853ee508a59ddba850679262f271c208738f207
blob - 8d35fc4661b3de028d157dd30c33f1d6c924a3cb
blob + 11c9d552b44915fbbf3dea7bd236a14ef65d4c89
--- telescope.c
+++ telescope.c
#include "ui.h"
static struct option longopts[] = {
+ {"colors", no_argument, NULL, 'c'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0},
};
-static const char *opts = "c:hnT:v";
+static const char *opts = "Cc:hnT:v";
static struct imsgev *iev_fs, *iev_net;
while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
switch (ch) {
+ case 'C':
+ exit(ui_print_colors());
case 'c':
fail = 1;
strlcpy(path, optarg, sizeof(path));
blob - a8967f141b318cb77d7a1810d4f9997d5b4faac8
blob + 7ed662f1b4a235e66747c32619e0312ac9c0b31e
--- ui.c
+++ ui.c
load_url_in_tab(tab, url);
return tab;
+}
+
+int
+ui_print_colors(void)
+{
+ int colors = 0, pairs = 0, can_change = 0;
+ int columns = 16, lines, color, i, j;
+
+ initscr();
+ if (has_colors()) {
+ start_color();
+ use_default_colors();
+
+ colors = COLORS;
+ pairs = COLOR_PAIRS;
+ can_change = can_change_color();
+ }
+ endwin();
+
+ printf("Term info:\n");
+ printf("TERM=%s COLORS=%d COLOR_PAIRS=%d can_change_colors=%d\n",
+ getenv("TERM"), colors, pairs, can_change);
+ printf("\n");
+
+ if (colors == 0) {
+ printf("No color support\n");
+ return 0;
+ }
+
+ printf("Available colors:\n\n");
+ lines = (colors - 1) / columns + 1;
+ color = 0;
+ for (i = 0; i < lines; ++i) {
+ for (j = 0; j < columns; ++j, ++color) {
+ printf("\033[0;38;5;%dm %03d", color, color);
+ }
+ printf("\n");
+ }
+
+ printf("\033[0m");
+ fflush(stdout);
+ return 0;
}
int
blob - bc8d51aa7eee03614320e152d9bd2637e11e7b3f
blob + 27a5a9566994a2bb2d1242a03d79a4df03d1dcd3
--- ui.h
+++ ui.h
struct buffer *current_buffer(void);
struct tab *new_tab(const char *);
unsigned int tab_new_id(void);
+int ui_print_colors(void);
int ui_init(void);
void ui_on_tab_loaded(struct tab *);
void ui_on_tab_refresh(struct tab *);