proper selection colors

This commit is contained in:
Henry Jameson 2024-03-04 19:53:45 +02:00
parent 075f2cb903
commit 7e01d2083d
3 changed files with 23 additions and 2 deletions

View File

@ -887,3 +887,8 @@ option {
padding: 0; padding: 0;
position: absolute; position: absolute;
} }
*::selection {
color: var(--selectionText);
background-color: var(--selectionBackground);
}

View File

@ -21,6 +21,7 @@ export default {
'--fg': 'color | #182230', '--fg': 'color | #182230',
'--text': 'color | #b9b9ba', '--text': 'color | #b9b9ba',
'--link': 'color | #d8a070', '--link': 'color | #d8a070',
'--accent': 'color | #d8a070',
'--cRed': 'color | #FF0000', '--cRed': 'color | #FF0000',
'--cBlue': 'color | #0095ff', '--cBlue': 'color | #0095ff',
'--cGreen': 'color | #0fa00f', '--cGreen': 'color | #0fa00f',
@ -32,7 +33,11 @@ export default {
// Fallback no-background-image color // Fallback no-background-image color
// (also useful in some other places like scrollbars) // (also useful in some other places like scrollbars)
'--wallpaper': 'color | --bg, -2' '--wallpaper': 'color | --bg, -2',
// Selection colors
'--selectionBackground': 'color | --accent',
'--selectionText': 'color | $textColor(--accent, --text)'
} }
} }
] ]

View File

@ -1,5 +1,5 @@
import { convert, brightness } from 'chromatism' import { convert, brightness } from 'chromatism'
import { alphaBlend, relativeLuminance } from '../color_convert/color_convert.js' import { alphaBlend, getTextColor, relativeLuminance } from '../color_convert/color_convert.js'
export const process = (text, functions, { findColor, findShadow }, { dynamicVars, staticVars }) => { export const process = (text, functions, { findColor, findShadow }, { dynamicVars, staticVars }) => {
const { funcName, argsString } = /\$(?<funcName>\w+)\((?<argsString>[#a-zA-Z0-9-,.'"\s]*)\)/.exec(text).groups const { funcName, argsString } = /\$(?<funcName>\w+)\((?<argsString>[#a-zA-Z0-9-,.'"\s]*)\)/.exec(text).groups
@ -23,6 +23,17 @@ export const colorFunctions = {
return { ...colorArg, a: amount } return { ...colorArg, a: amount }
} }
}, },
textColor: {
argsNeeded: 2,
exec: (args, { findColor }, { dynamicVars, staticVars }) => {
const [backgroundArg, foregroundArg, preserve = 'preserve'] = args
const background = convert(findColor(backgroundArg, { dynamicVars, staticVars })).rgb
const foreground = convert(findColor(foregroundArg, { dynamicVars, staticVars })).rgb
return getTextColor(background, foreground, preserve === 'preserve')
}
},
blend: { blend: {
argsNeeded: 3, argsNeeded: 3,
exec: (args, { findColor }, { dynamicVars, staticVars }) => { exec: (args, { findColor }, { dynamicVars, staticVars }) => {