From 63a1585c7afbb3f74944c7f9e90e2e550d218a13 Mon Sep 17 00:00:00 2001 From: ketmar <> Date: Sun, 10 Sep 2023 23:22:53 +0000 Subject: [PATCH] added "amber tint" mode for selection (default) FossilOrigin-Name: d15b4d56a6e47570c65026b133bbc3ad5fc09c9ac960c91bf2c88cea762309e9 --- .k8-yterm.Xresources | 2 ++ README.Xresources | 2 ++ src/cellwin.c | 11 +++++++++-- src/cellwin.h | 1 + src/term_lib.inc.c | 2 +- src/x11_xrm.inc.c | 2 ++ src/yterm_main.c | 2 ++ 7 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.k8-yterm.Xresources b/.k8-yterm.Xresources index eb75853..c802528 100644 --- a/.k8-yterm.Xresources +++ b/.k8-yterm.Xresources @@ -117,6 +117,8 @@ k8-yterm.selection.color.bg: #333 ! selection block k8-yterm.selection.block.color.fg: #fff k8-yterm.selection.block.color.bg: #05c +! tint selection color with real color intensity? +k8-yterm.selection.tint: tan ! OSD menus k8-yterm.osd-menu.color.active.bg: #d9d9ae diff --git a/README.Xresources b/README.Xresources index eb75853..c802528 100644 --- a/README.Xresources +++ b/README.Xresources @@ -117,6 +117,8 @@ k8-yterm.selection.color.bg: #333 ! selection block k8-yterm.selection.block.color.fg: #fff k8-yterm.selection.block.color.bg: #05c +! tint selection color with real color intensity? +k8-yterm.selection.tint: tan ! OSD menus k8-yterm.osd-menu.color.active.bg: #d9d9ae diff --git a/src/cellwin.c b/src/cellwin.c index 7e78742..b0150f0 100644 --- a/src/cellwin.c +++ b/src/cellwin.c @@ -305,7 +305,7 @@ YTERM_STATIC_INLINE uint32_t decode_color (uint32_t c, uint16_t flags, if (colorMode == CMODE_AMBER) { c = (isfg ? colorAmberFG : colorAmberBG); - } else if (colorMode == CMODE_BW || colorMode == CMODE_GREEN) { + } else if (colorMode == CMODE_BW || colorMode == CMODE_GREEN || colorMode == CMODE_AMBER_TINT) { //0.3*r + 0.59*g + 0.11*b int lumi = (19660 * ((c>>16)&0xff) + 38666 * ((c>>8)&0xff) + @@ -313,8 +313,15 @@ YTERM_STATIC_INLINE uint32_t decode_color (uint32_t c, uint16_t flags, if (lumi > 255) lumi = 255; if (colorMode == CMODE_BW) { c = ((uint32_t)lumi << 16) | ((uint32_t)lumi << 8) | (uint32_t)lumi; - } else { + } else if (colorMode == CMODE_GREEN) { c = ((uint32_t)lumi << 8); + } else { + // amber tint + lumi = 1 - ((lumi >> 7) & 0x01); + uint32_t xclr = (isfg ? colorAmberFG : colorAmberBG); + c = ((((xclr >> 16) & 0xff) >> lumi) << 16) | + ((((xclr >> 8) & 0xff) >> lumi) << 8) | + ((xclr & 0xff) >> lumi); } } diff --git a/src/cellwin.h b/src/cellwin.h index e3f3387..6fb20ad 100644 --- a/src/cellwin.h +++ b/src/cellwin.h @@ -42,6 +42,7 @@ #define CMODE_BW (1) #define CMODE_GREEN (2) #define CMODE_AMBER (3) +#define CMODE_AMBER_TINT (4) extern int colorMode; diff --git a/src/term_lib.inc.c b/src/term_lib.inc.c index 58888e4..701bd1c 100644 --- a/src/term_lib.inc.c +++ b/src/term_lib.inc.c @@ -45,7 +45,7 @@ if (term->colorMode >= 0) colorMode = term->colorMode; \ } else { \ cbufInverse = 0; \ - colorMode = CMODE_AMBER; \ + colorMode = (opt_amber_tint ? CMODE_AMBER_TINT : CMODE_AMBER); \ rcpos = &scpos; \ rcbuf = &hvbuf; \ scpos.x = term->history.cx; \ diff --git a/src/x11_xrm.inc.c b/src/x11_xrm.inc.c index 949be8e..bb64d55 100644 --- a/src/x11_xrm.inc.c +++ b/src/x11_xrm.inc.c @@ -665,6 +665,8 @@ static IniKey inikeys[] = { {.key="selection.block.color.fg", .type=XRM_COLOR, .varptr=&colorSelectionFG}, {.key="selection.block.color.bg", .type=XRM_COLOR, .varptr=&colorSelectionBG}, + {.key="selection.tint", .type=XRM_BOOL, .varptr=&opt_amber_tint}, + {.key="osd-menu.shadow.color", .type=XRM_COLOR_OR_NONE, .varptr=&opt_osd_menu_shadow_color}, {.key="osd-menu.shadow.x-ofs", .type=XRM_SHADOW_OFS, .varptr=&opt_osd_menu_shadow_xofs}, {.key="osd-menu.shadow.y-ofs", .type=XRM_SHADOW_OFS, .varptr=&opt_osd_menu_shadow_yofs}, diff --git a/src/yterm_main.c b/src/yterm_main.c index 2d4403b..2efe693 100644 --- a/src/yterm_main.c +++ b/src/yterm_main.c @@ -456,6 +456,8 @@ static uint32_t opt_osd_menu_shadow_color = 0x000000; static yterm_bool opt_osd_menu_shadow_xofs = 6; static yterm_bool opt_osd_menu_shadow_yofs = 6; +static yterm_bool opt_amber_tint = 1; + static yterm_bool opt_debug_perform_hotswap = 0; static int opt_debug_hotswap_fd = -1; #define IS_HOTSWAPPING() (opt_debug_hotswap_fd >= 0) -- 2.11.4.GIT