svenstaro / rofi-calc

🖩 Do live calculations in rofi!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error Message Color

kvnduff opened this issue · comments

Just wondering if there is a way to customize the color of the error message. In your gif it displays as light pink as it does in my rofi theme. I have tried changing relevant colors in the rofi theme but can't find the relevant variable. Thanks for your work on this project. :)

Hey, sorry to have this ignored for so long. Are you still experiencing this problem? Are you sure this is a rofi-calc question or maybe a general rofi question?

I'm also having trouble accomplishing that. Changing the text-color for textbox to inherit and specifying a text-color for message allows me to change the color of the Result: field. However, when the calculator throws an error, it shows up (in the same place) in pink.

I found this line in the source code that defines the color for the error message as PaleVioletRed, which is the color I see when an error comes up:

return g_markup_printf_escaped("<span foreground='PaleVioletRed'>%s</span>", pd->last_result);

Reading through the man pages, from what I understand, both the message and error-message boxes use the textbox child. In theory, setting a text-color for error-message should resolve the issue, as it also uses the textbox as its child, but that isn't the case.
Reading this section in rofi-theme(5) though, the error-message seems to only be used in a standalone context. The above <span> element is therefore probably, for lack of a better word, "injected" into message's child textbox (the place where the calculator's results are printed).

tl;dr error-message is probably irrelevant; It seems like the foreground= property for the calculator errors in src/calc.c#615 is overwriting the text-color I have set for the textbox { } in my config.rasi file.

Oh right. Happy for a PR that fixes this if you'd like to take a look!

Maybe one approach could be to replace PaleVioletRed with a variable. I have absolutely no idea how to make it configurable through config.rasi, but I could try to implement it as a command option - at least temporarily until someone comes up with a better solution. I am thinking:

rofi -show calc -modi calc -calc-error-color '#ff0000' -no-show-match -no-sort

(I should probably add: I am absolutely not familiar with rofi plugin development and the rofi codebase in general, so right now I fear this is as far as I can go)

A few hours of tinkering later... it works! #121

As I said, it's just a quick implementation, but it'll do for now. If someone wants to / is capable of writing a proper implementation (with .rasi support) that would be nice.

I only tested it with lbonn/rofi on Void Linux (Wayfire), but I don't see why it wouldn't work on X11.