From 6fa901c4b13ff04afce092cda361327cf3e92926 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 4 Oct 2021 02:55:32 -0400 Subject: [PATCH] [kitty] fix default background workaround, erp --- src/info/main.c | 10 +++++++--- src/lib/in.c | 2 +- src/lib/render.c | 14 ++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/info/main.c b/src/info/main.c index 8a1d71c36..d0c4b080d 100644 --- a/src/info/main.c +++ b/src/info/main.c @@ -338,9 +338,13 @@ display_logo(struct ncplane* n, const char* path){ static void tinfo_debug_bitmaps(struct ncplane* n, const tinfo* ti, const char* indent){ if(!(ti->bg_collides_default & 0x80000000)){ - ncplane_printf(n, "%sdefault background 0x%06lx %sconsidered transparent", indent, - ti->bg_collides_default & 0xfffffful, - (ti->bg_collides_default & 0x01000000) ? "" : "not "); + if(!(ti->bg_collides_default & 0x01000000)){ + ncplane_printf(n, "%sdefault background 0x%06lx", indent, + ti->bg_collides_default & 0xfffffful); + }else{ + ncplane_printf(n, "%sdefault background 0x%06lx considered transparent", indent, + ti->bg_collides_default & 0xfffffful); + } }else{ ncplane_printf(n, "couldn't detect default background"); } diff --git a/src/lib/in.c b/src/lib/in.c index a0920a174..3d077533a 100644 --- a/src/lib/in.c +++ b/src/lib/in.c @@ -850,7 +850,7 @@ build_cflow_automaton(inputctx* ictx){ { "[?2;3;0S", NULL, }, // negative pixels XTSMGRAPHICS { "[?1;0;\\NS", xtsmgraphics_cregs_cb, }, { "[?2;0;\\N;\\NS", xtsmgraphics_sixel_cb, }, - { "[>\\N;\\N;\\Nc", da2_cb, }, // "VT100" + { "[>\\N;\\N;\\Nc", da2_cb, }, { "[=\\Sc", da3_cb, }, // CSI da3 form as issued by WezTerm // DCS (\eP...ST) { "P1+r\\S", tcap_cb, }, // positive XTGETTCAP diff --git a/src/lib/render.c b/src/lib/render.c index 4ae582854..fa73d1c8e 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -693,14 +693,12 @@ term_bg_rgb8(const tinfo* ti, fbuf* f, unsigned r, unsigned g, unsigned b){ // If it doesn't work, eh, it doesn't work. Fuck the world; save yourself. if(ti->caps.rgb){ if((ti->bg_collides_default & 0xff000000) == 0x01000000){ - if((r == (ti->bg_collides_default & 0xff0000lu)) && - (g == (ti->bg_collides_default & 0xff00lu)) && - (b == (ti->bg_collides_default & 0xfflu))){ - if(b < 255){ - ++b; - }else{ - --b; - } + if((r == ncchannel_r(ti->bg_collides_default)) && + (g == ncchannel_g(ti->bg_collides_default)) && + (b == ncchannel_b(ti->bg_collides_default))){ + // the human eye has fewer blue cones than red or green. toggle + // the last bit in the blue component to avoid a collision. + b ^= 0x00000001; } } return term_esc_rgb(f, false, r, g, b);