Merge branch 'master' of ssh://forgejo.nishi.boats:2222/pyrite-dev/milsko
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
IoIxD 2026-09-26 19:18:37 -07:00
commit 59e1faaef2
10 changed files with 70 additions and 62 deletions

View file

@ -42,6 +42,11 @@ MWDECL const char* MwDefaultTitleBackground;
*/ */
MWDECL const char* MwDefaultTitleForeground; MWDECL const char* MwDefaultTitleForeground;
/*!
* @brief Default link foreground color
*/
MWDECL const char* MwDefaultLinkForeground;
/*! /*!
* @brief Default dark theme background color * @brief Default dark theme background color
*/ */
@ -72,6 +77,11 @@ MWDECL const char* MwDefaultDarkTitleBackground;
*/ */
MWDECL const char* MwDefaultDarkTitleForeground; MWDECL const char* MwDefaultDarkTitleForeground;
/*!
* @brief Default dark theme link foreground color
*/
MWDECL const char* MwDefaultDarkLinkForeground;
/*! /*!
* @brief Default shadow difference * @brief Default shadow difference
*/ */

View file

@ -42,10 +42,8 @@ struct _MwLLCommon {
MwLLHandler handler; MwLLHandler handler;
#if defined(USE_WAYLAND) || defined(USE_X11)
/* 0 = default, 1 = light, 2 = dark */ /* 0 = default, 1 = light, 2 = dark */
int theme_override; int theme_override;
#endif
}; };
struct _MwLLCommonColor { struct _MwLLCommonColor {

View file

@ -69,6 +69,7 @@
#define MwNforeground "Sforeground" #define MwNforeground "Sforeground"
#define MwNsubForeground "SsubForeground" #define MwNsubForeground "SsubForeground"
#define MwNtitleForeground "StitleForeground" #define MwNtitleForeground "StitleForeground"
#define MwNlinkForeground "SlinkForeground"
#define MwNvulkanExtension "SEvulkanExtension" #define MwNvulkanExtension "SEvulkanExtension"
#define MwNvulkanLayer "SEvulkanLayer" #define MwNvulkanLayer "SEvulkanLayer"

View file

@ -124,6 +124,7 @@
<string name="foreground" common="yes" /> <string name="foreground" common="yes" />
<string name="subForeground" common="yes" /> <string name="subForeground" common="yes" />
<string name="titleForeground" common="yes" /> <string name="titleForeground" common="yes" />
<string name="linkForeground" common="yes" />
<!-- Early string properties --> <!-- Early string properties -->
<string name="vulkanExtension" early="yes" /> <string name="vulkanExtension" early="yes" />

View file

@ -38,9 +38,13 @@ static void detect_darktheme_classictheme(MwLL handle) {
/* Dark theme detection for modern Windows: use the registry to check if dark mode is enabled. */ /* Dark theme detection for modern Windows: use the registry to check if dark mode is enabled. */
static void detect_darktheme(MwLL handle) { static void detect_darktheme(MwLL handle) {
int t;
if(handle->common.theme_override > 0) {
t = handle->common.theme_override - 1;
} else {
DWORD dw; DWORD dw;
DWORD sz = sizeof(dw); DWORD sz = sizeof(dw);
int err, t; int err;
HKEY hkey; HKEY hkey;
DWORD type; DWORD type;
@ -58,6 +62,7 @@ static void detect_darktheme(MwLL handle) {
} }
t = dw ? 0 : 1; t = dw ? 0 : 1;
}
/* no don't do this here (nishi) */ /* no don't do this here (nishi) */
#if 0 #if 0

View file

@ -819,7 +819,7 @@ int MwGetInteger(MwWidget handle, const char* key) {
} }
const char* MwGetString(MwWidget handle, const char* key) { const char* MwGetString(MwWidget handle, const char* key) {
if((shgeti(handle->string, key) == -1 || strcmp(shget(handle->string, key), "DEFAULT") == 0) && (strcmp(key, MwNbackground) == 0 || strcmp(key, MwNforeground) == 0 || strcmp(key, MwNsubBackground) == 0 || strcmp(key, MwNsubForeground) == 0 || strcmp(key, MwNtitleBackground) == 0 || strcmp(key, MwNtitleForeground) == 0)) { if((shgeti(handle->string, key) == -1 || strcmp(shget(handle->string, key), "DEFAULT") == 0) && (strcmp(key, MwNbackground) == 0 || strcmp(key, MwNforeground) == 0 || strcmp(key, MwNsubBackground) == 0 || strcmp(key, MwNsubForeground) == 0 || strcmp(key, MwNtitleBackground) == 0 || strcmp(key, MwNtitleForeground) == 0 || strcmp(key, MwNlinkForeground) == 0)) {
const char* v = NULL; const char* v = NULL;
if(shgeti(handle->string, key) != -1 && strcmp(shget(handle->string, key), "DEFAULT") != 0) { if(shgeti(handle->string, key) != -1 && strcmp(shget(handle->string, key), "DEFAULT") != 0) {
MwWidget h = handle->parent; MwWidget h = handle->parent;
@ -836,6 +836,7 @@ const char* MwGetString(MwWidget handle, const char* key) {
if(strcmp(key, MwNsubForeground) == 0) return MwDefaultDarkSubForeground; if(strcmp(key, MwNsubForeground) == 0) return MwDefaultDarkSubForeground;
if(strcmp(key, MwNtitleBackground) == 0) return MwDefaultDarkTitleBackground; if(strcmp(key, MwNtitleBackground) == 0) return MwDefaultDarkTitleBackground;
if(strcmp(key, MwNtitleForeground) == 0) return MwDefaultDarkTitleForeground; if(strcmp(key, MwNtitleForeground) == 0) return MwDefaultDarkTitleForeground;
if(strcmp(key, MwNlinkForeground) == 0) return MwDefaultDarkLinkForeground;
} else { } else {
if(strcmp(key, MwNbackground) == 0) return MwDefaultBackground; if(strcmp(key, MwNbackground) == 0) return MwDefaultBackground;
if(strcmp(key, MwNforeground) == 0) return MwDefaultForeground; if(strcmp(key, MwNforeground) == 0) return MwDefaultForeground;
@ -843,6 +844,7 @@ const char* MwGetString(MwWidget handle, const char* key) {
if(strcmp(key, MwNsubForeground) == 0) return MwDefaultSubForeground; if(strcmp(key, MwNsubForeground) == 0) return MwDefaultSubForeground;
if(strcmp(key, MwNtitleBackground) == 0) return MwDefaultTitleBackground; if(strcmp(key, MwNtitleBackground) == 0) return MwDefaultTitleBackground;
if(strcmp(key, MwNtitleForeground) == 0) return MwDefaultTitleForeground; if(strcmp(key, MwNtitleForeground) == 0) return MwDefaultTitleForeground;
if(strcmp(key, MwNlinkForeground) == 0) return MwDefaultLinkForeground;
} }
} }
return v; return v;

View file

@ -9,6 +9,7 @@ const char* MwDefaultSubBackground = "#9ca0b0";
const char* MwDefaultSubForeground = "#6c6f85"; const char* MwDefaultSubForeground = "#6c6f85";
const char* MwDefaultTitleBackground = "#bcc0cc"; const char* MwDefaultTitleBackground = "#bcc0cc";
const char* MwDefaultTitleForeground = "#5c5f77"; const char* MwDefaultTitleForeground = "#5c5f77";
const char* MwDefaultLinkForeground = "#8839ef";
#else #else
const char* MwDefaultBackground = "#d2d2d2"; const char* MwDefaultBackground = "#d2d2d2";
const char* MwDefaultForeground = "#000"; const char* MwDefaultForeground = "#000";
@ -16,6 +17,7 @@ const char* MwDefaultSubBackground = "#fff";
const char* MwDefaultSubForeground = "#000"; const char* MwDefaultSubForeground = "#000";
const char* MwDefaultTitleBackground = "#008"; const char* MwDefaultTitleBackground = "#008";
const char* MwDefaultTitleForeground = "#fff"; const char* MwDefaultTitleForeground = "#fff";
const char* MwDefaultLinkForeground = "#008";
#endif #endif
#ifdef USE_CATPPUCCIN_DARK #ifdef USE_CATPPUCCIN_DARK
@ -25,6 +27,7 @@ const char* MwDefaultDarkSubBackground = "#313244";
const char* MwDefaultDarkSubForeground = "#a6adc8"; const char* MwDefaultDarkSubForeground = "#a6adc8";
const char* MwDefaultDarkTitleBackground = "#45475a"; const char* MwDefaultDarkTitleBackground = "#45475a";
const char* MwDefaultDarkTitleForeground = "#bac2de"; const char* MwDefaultDarkTitleForeground = "#bac2de";
const char* MwDefaultDarkLinkForeground = "#cba6f7";
#else #else
const char* MwDefaultDarkBackground = "#333"; const char* MwDefaultDarkBackground = "#333";
const char* MwDefaultDarkForeground = "#ddd"; const char* MwDefaultDarkForeground = "#ddd";
@ -32,6 +35,7 @@ const char* MwDefaultDarkSubBackground = "#333";
const char* MwDefaultDarkSubForeground = "#ddd"; const char* MwDefaultDarkSubForeground = "#ddd";
const char* MwDefaultDarkTitleBackground = "#008"; const char* MwDefaultDarkTitleBackground = "#008";
const char* MwDefaultDarkTitleForeground = "#fff"; const char* MwDefaultDarkTitleForeground = "#fff";
const char* MwDefaultDarkLinkForeground = "#008";
#endif #endif
const int MwDefaultShadow = -32; const int MwDefaultShadow = -32;

View file

@ -66,22 +66,19 @@ void (*MwLLRaise)(MwLL handle) = NULL;
void (*MwLLClip)(MwLL handle, MwRect* rect) = NULL; void (*MwLLClip)(MwLL handle, MwRect* rect) = NULL;
void MwLLCreateCommon(MwLL handle) { void MwLLCreateCommon(MwLL handle) {
#if defined(USE_WAYLAND) || defined(USE_X11)
char* light_theme = getenv("MW_LIGHT_THEME"); char* light_theme = getenv("MW_LIGHT_THEME");
char* dark_theme = getenv("MW_DARK_THEME"); char* dark_theme = getenv("MW_DARK_THEME");
#endif
handle->common.handler = malloc(sizeof(*handle->common.handler)); handle->common.handler = malloc(sizeof(*handle->common.handler));
memset(handle->common.handler, 0, sizeof(*handle->common.handler)); memset(handle->common.handler, 0, sizeof(*handle->common.handler));
handle->common.supports_transparency = 0; handle->common.supports_transparency = 0;
#if defined(USE_WAYLAND) || defined(USE_X11)
if(light_theme || dark_theme) { if(light_theme || dark_theme) {
handle->common.theme_override = (light_theme != NULL) ? 1 : ((dark_theme != NULL) ? 2 : 0); handle->common.theme_override = (light_theme != NULL) ? 1 : ((dark_theme != NULL) ? 2 : 0);
} else {
handle->common.theme_override = 0;
} }
#endif
} }
void MwLLDestroyCommon(MwLL handle) { void MwLLDestroyCommon(MwLL handle) {

View file

@ -54,6 +54,7 @@ static void draw(MwWidget handle) {
MwDocument d = handle->internal; MwDocument d = handle->internal;
MwColor base = MwParseColor(handle, MwGetString(handle, MwNbackground)); MwColor base = MwParseColor(handle, MwGetString(handle, MwNbackground));
MwColor text = MwParseColor(handle, MwGetString(handle, MwNforeground)); MwColor text = MwParseColor(handle, MwGetString(handle, MwNforeground));
MwColor link = MwParseColor(handle, MwGetString(handle, MwNlinkForeground));
MwRect r; MwRect r;
int i; int i;
MwFLFont font = NULL; MwFLFont font = NULL;
@ -124,28 +125,16 @@ static void draw(MwWidget handle) {
if(j == 1) s_p.x = line[1].x; if(j == 1) s_p.x = line[1].x;
if(j == 2) c_p.x = line[1].x; if(j == 2) c_p.x = line[1].x;
if(j == 2) { if(j == 0 || j == 1 || j == 2) {
MwRect c_r; int am = MwTextHeight(handle, font, l->text) / 2 * (2 - (j == 2 ? 0 : j));
line[0].y += am;
c_r.x = line[0].x; line[1].y += am;
c_r.y = line[0].y; MwLine(handle, line, (c ? link : text));
c_r.width = line[1].x - line[0].x;
c_r.height = MwTextHeight(handle, font, l->text);
MwDrawRect(handle, &c_r, text);
}
if(j == 0 || j == 1) {
line[0].y += MwTextHeight(handle, font, l->text) / 2 * (2 - j);
line[1].y += MwTextHeight(handle, font, l->text) / 2 * (2 - j);
MwLine(handle, line, (c ? base : text));
} }
} }
} }
handle->bgcolor = c ? text : NULL; MwDrawText(handle, font, &p, l->text, MwALIGNMENT_BEGINNING, c ? link : text);
MwDrawText(handle, font, &p, l->text, MwALIGNMENT_BEGINNING, c ? base : text);
handle->bgcolor = NULL;
break; break;
} }
case MwDOCUMENT_UNDERLINE: case MwDOCUMENT_UNDERLINE:
@ -191,6 +180,7 @@ static void draw(MwWidget handle) {
if(IsFontChange(l->type)) font = l->font; if(IsFontChange(l->type)) font = l->font;
} }
MwFreeColor(link);
MwFreeColor(text); MwFreeColor(text);
MwFreeColor(base); MwFreeColor(base);
} }
@ -665,8 +655,8 @@ MwClassRec MwDocumentClassRec = {
NULL, /* parent_resize */ NULL, /* parent_resize */
prop_change, /* prop_change */ prop_change, /* prop_change */
mouse_move, /* mouse_move */ mouse_move, /* mouse_move */
NULL, /* mouse_up */ MwForceRender2, /* mouse_up */
NULL, /* mouse_down */ MwForceRender2, /* mouse_down */
NULL, /* key */ NULL, /* key */
NULL, /* execute */ NULL, /* execute */
NULL, /* tick */ NULL, /* tick */