Add colors utilities (#121)

* Add colors utilities

Local function get_base_color(), conversions hex <=> rgb, rgb color mixer, and global function get_color()

* Round numbers to avoid eventual float in string.format

* Simplify inbox/outbox mixing of color

Use a single if statement for each property and concatenate to displayed_color then execute mail.get_color(displayed_color) instead of making many combined if statements

* Convert 3-chars hex colors to 6-chars hex colors

Could break the code, the hex convert to rgb always run on 6-chars

* Rework color utility using tables

Instead of one-letter symbols, it now supports tables of identifiers or single strings
This commit is contained in:
Athozus 2023-12-06 10:11:12 +01:00 committed by GitHub
parent 802f9f727b
commit 3bad371353
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 86 additions and 61 deletions

View file

@ -21,7 +21,7 @@ function mail.show_drafts(name)
button_exit[6,9.5;2.5,0.5;quit;]] .. S("Close") .. [[]
tablecolumns[color;text;text]
table[0,0.7;5.75,9.35;drafts;]] .. mail.colors.header .. "," .. S("To") .. "," .. S("Subject")
table[0,0.7;5.75,9.35;drafts;]] .. mail.get_color("header") .. "," .. S("To") .. "," .. S("Subject")
local formspec = { drafts_formspec }
local entry = mail.get_storage_entry(name)