martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.19k stars 259 forks source link

bright colors support #1083

Open apprehensions opened 1 year ago

apprehensions commented 1 year ago

i've been trying to implement this into vis myself, but as i'm unfamiliar with C, i was not able to.

to put it simply, the current color indexes are 30 (fg) and 40 (bg); there should be a style mode (similar to bold) that simply adds 60 to these values, making them bright colored.

ncurses does this a bit differently unfortunately..

https://en.wikipedia.org/wiki/ANSI_escape_code

lobre commented 8 months ago

I have not properly dug the code but by trying numbers instead of string colors, I manage to have bright versions. Such as:

local bright = {
    black   = 8,
    red     = 9,
    green   = 10,
    yellow  = 11,
    blue    = 12,
    magenta = 13,
    cyan    = 14
}

...
lexers.STYLE_LINENUMBER = 'fore:'..bright.black
...
apprehensions commented 7 months ago

@lobre i'm glad you managed to find a way! but, it doesn't seem to do anything on my end..

(Nevermind, i'm just colorblind.)

this is why it works: netbsd-curses:

/*
 * Color definitions (ANSI color numbers)
 */

#define COLOR_BLACK 0x00
#define COLOR_RED   0x01
#define COLOR_GREEN 0x02
#define COLOR_YELLOW    0x03
#define COLOR_BLUE  0x04
#define COLOR_MAGENTA   0x05
#define COLOR_CYAN  0x06
#define COLOR_WHITE 0x07

vis:

#define CELL_COLOR_BLACK   COLOR_BLACK
#define CELL_COLOR_RED     COLOR_RED
#define CELL_COLOR_GREEN   COLOR_GREEN
#define CELL_COLOR_YELLOW  COLOR_YELLOW
#define CELL_COLOR_BLUE    COLOR_BLUE
#define CELL_COLOR_MAGENTA COLOR_MAGENTA
#define CELL_COLOR_CYAN    COLOR_CYAN
#define CELL_COLOR_WHITE   COLOR_WHITE
#define CELL_COLOR_DEFAULT (-1)
lobre commented 7 months ago

I am not sure I get your point. Can you please explain why you think it works? I don't see any bright definitions in the code you posted.

apprehensions commented 7 months ago

vis (or ncurses to be specific) only has the default normal colors 0-7 colors indexed with their representative strings red, green, etc. your way works because it adds the mixing other bright 8-15 colors.

although ncurses itself has no bright color support it seems..