Open vikasnkumar opened 5 hours ago
$window->map_color( $window->backColor) should do it. A non-object syntax is also available (if window is not there yet for example), with Prima::Widget->map_color( ci::Window | cl::Back )
For comparison you can also use something like this: $dark_mode = cl::to_gray_byte($color) > cl::to_gray_byte($backColor)
my $is_dark_mode = (cl::to_gray_byte($mw->color) > cl::to_gray_byte($mw->backColor)) ? 1 : 0;
I tried this but it does not show 1 when in dark mode. Keeps showing 0. here $mw
is my main editor Prima::Window
which then has the Prima::Edit
element.
I also tried $is_dark_mode = 1 if ($mw->map_color($mw->backColor) ne cl::White);
but it always gets set to 1 even in light mode.
Can you point me to what I am doing wrong here ? should I not be comparing to cl::White
?
I have a
Prima::Edit
widget that allows a user to enter some text, which I am using a regex to syntax highlight using thehighlightREs
feature. however, i am testing on 2 different systems - one of them runs XFCE in dark mode and the other runs regular XFCE.how can I detect dark mode ? I am trying to use
$window->backColor
but it returns0x100F0002
which looks likecl::Normal
but it is not. and I get the same value in both the non-dark and dark mode window managers.My main goal is to detect dark mode and if the editor is in dark mode, change the color scheme so that some colors like black which are great on a white/lite background are swapped for cyan/white for a dark background.