fzy

terminal fuzzy finder picker

git clone https://9o.is/git/fzy.git

commit 581099bc6126c3ac14cd51435e70d1806be39d22
parent 2e91e53da849e489503ea1e4c58e581b02ad3bcd
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Mon,  4 Aug 2014 01:01:43 -0700

Define ANSI color values

Diffstat:
Mfzy.c | 6++++--
Mtty.h | 9+++++++++
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/fzy.c b/fzy.c @@ -98,6 +98,8 @@ void clear(tty_t *tty){ fprintf(tty->fout, "%c%c0G", 0x1b, '['); } +#define TTY_COLOR_HIGHLIGHT TTY_COLOR_YELLOW + void draw_match(tty_t *tty, const char *choice, int selected){ int n = strlen(search); size_t positions[n + 1]; @@ -111,10 +113,10 @@ void draw_match(tty_t *tty, const char *choice, int selected){ for(size_t i = 0, p = 0; choice[i] != '\0'; i++){ if(positions[p] == i){ - tty_setfg(tty, 3); + tty_setfg(tty, TTY_COLOR_HIGHLIGHT); p++; }else{ - tty_setfg(tty, 9); + tty_setfg(tty, TTY_COLOR_NORMAL); } fprintf(tty->fout, "%c", choice[i]); } diff --git a/tty.h b/tty.h @@ -18,5 +18,14 @@ void tty_setfg(tty_t *tty, int fg); void tty_setinvert(tty_t *tty); void tty_setnormal(tty_t *tty); +#define TTY_COLOR_BLACK 0 +#define TTY_COLOR_RED 1 +#define TTY_COLOR_GREEN 2 +#define TTY_COLOR_YELLOW 3 +#define TTY_COLOR_BLUE 4 +#define TTY_COLOR_MAGENTA 5 +#define TTY_COLOR_CYAN 6 +#define TTY_COLOR_WHITE 7 +#define TTY_COLOR_NORMAL 9 #endif