1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Add foreground color to CodeMirror selections and fix #5272 (#5266)

* Add foreground color to CodeMirror selections

* Use default selection background if tiddler-editor-background matches selection-background
This commit is contained in:
Simon Huber 2020-12-13 12:40:57 +01:00 committed by GitHub
parent a17fa35c28
commit 8798ebadbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,16 +15,20 @@ name: tiddlywiki
\define set-fat-cursor-background() \define set-fat-cursor-background()
<$macrocall $name="set-fat-cursor-background-colours" palette={{$:/palette}}/> <$macrocall $name="set-fat-cursor-background-colours" palette={{$:/palette}}/>
\end \end
\define set-selection-background-css(colour,colourA,colourB) \define set-selection-background-css(colour,colourA,colourB,tiddlerEditorBackground)
<$wikify name="tiddlerEditorBackground" text={{{ [[$tiddlerEditorBackground$]lowercase[]] }}}>
<$set name="backgroundColour" value=<<contrastcolour target:"""$colour$""" fallbackTarget:"""""" colourA:"""$colourA$""" colourB:"""$colourB$""">>> <$set name="backgroundColour" value=<<contrastcolour target:"""$colour$""" fallbackTarget:"""""" colourA:"""$colourA$""" colourB:"""$colourB$""">>>
.cm-s-tiddlywiki div.CodeMirror-selected { background: <<backgroundColour>>; } <$set name="backgroundColour" value={{{ [<backgroundColour>lowercase[]match<tiddlerEditorBackground>then[]] ~[<backgroundColour>] }}}>
.cm-s-tiddlywiki.CodeMirror ::selection { background: <<backgroundColour>>; } .cm-s-tiddlywiki div.CodeMirror-selected { background: <<backgroundColour>>; color: <<colour foreground>>; }
.cm-s-tiddlywiki .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: <<backgroundColour>>; } .cm-s-tiddlywiki.CodeMirror ::selection { background: <<backgroundColour>>; color: <<colour foreground>>; }
.cm-s-tiddlywiki .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: <<backgroundColour>>; } .cm-s-tiddlywiki .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: <<backgroundColour>>; color: <<colour foreground>>; }
.cm-s-tiddlywiki .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: <<backgroundColour>>; color: <<colour foreground>>; }
</$set> </$set>
</$set>
</$wikify>
\end \end
\define set-selection-background-colours(palette) \define set-selection-background-colours(palette)
<$macrocall $name="set-selection-background-css" colour={{$palette$##foreground}} colourA={{{ [{$palette$##selection-background}!match[]!prefix[<<]!suffix[>>]] ~#073642 }}} colourB={{{ [{$palette$##selection-background}!match[]!prefix[<<]!suffix[>>]] ~#eee8d5 }}}/> <$macrocall $name="set-selection-background-css" colour={{$palette$##foreground}} colourA={{{ [{$palette$##selection-background}!match[]!prefix[<<]!suffix[>>]] ~#073642 }}} colourB={{{ [{$palette$##selection-background}!match[]!prefix[<<]!suffix[>>]] ~#eee8d5 }}} tiddlerEditorBackground={{$palette$##tiddler-editor-background}}/>
\end \end
\define set-selection-background() \define set-selection-background()
<$macrocall $name="set-selection-background-colours" palette={{$:/palette}}/> <$macrocall $name="set-selection-background-colours" palette={{$:/palette}}/>