@@ -16,75 +16,71 @@ import qualified Skylighting.Styles as Sky
1616mkAttrName :: String -> AttrName
1717mkAttrName = attrName
1818
19- mainAttrMap :: AttrMap
20- mainAttrMap = attrMap V. defAttr ([
21- -- (listAttr, V.white `on` V.blue)
22- -- (listSelectedAttr, V.blue `on` V.white)
23- -- (listSelectedAttr, bg (V.Color240 $ V.rgbColorToColor240 0 1 0))
24- -- (selectedAttr, bg (V.Color240 $ V.rgbColorToColor240 0 1 0))
25-
19+ buildAdaptiveAttrMap :: V. ColorMode -> AttrMap
20+ buildAdaptiveAttrMap colorMode = attrMap V. defAttr ([
2621 -- Statuses
2722 (iconAttr, fg V. white)
2823 , (normalAttr, fg V. white)
29- , (notFetchedAttr, fg midGray)
24+ , (notFetchedAttr, fg (select midGray) )
3025 , (fetchingAttr, fg V. blue)
3126 , (erroredAttr, fg V. red)
3227
3328 -- Pagination
34-
35- , (searchAttr, fg midGray)
36- , (selectedPageAttr, fg solarizedGreen & flip V. withStyle V. bold)
37- , (notSelectedPageAttr, fg midGray & flip V. withStyle V. dim)
38- , (pageEllipsesAttr, fg midGray)
29+ , (searchAttr, fg (select midGray))
30+ , (selectedPageAttr, fg (select solarizedGreen) & flip V. withStyle V. bold)
31+ , (notSelectedPageAttr, fg (select midGray) & flip V. withStyle V. dim)
32+ , (pageEllipsesAttr, fg (select midGray))
3933
4034 -- Stats box
4135 , (starsAttr, fg V. yellow)
4236
4337 -- Workflow icons
44- , (cancelledAttr, fg midGray)
38+ , (cancelledAttr, fg (select midGray) )
4539 , (greenCheckAttr, fg V. green)
4640 , (redXAttr, fg V. red)
47- , (ellipsesAttr, fg midGray)
48- , (neutralAttr, fg midGray)
41+ , (ellipsesAttr, fg (select midGray) )
42+ , (neutralAttr, fg (select midGray) )
4943 , (unknownAttr, fg V. white)
50- , (queuedAttr, fg githubOrange)
44+ , (queuedAttr, fg (select githubOrange) )
5145
5246 -- Progress bar
53- , (progressCompleteAttr, bg (V. Color240 235 ))
54- , (progressIncompleteAttr, bg (V. Color240 225 ))
47+ , (progressCompleteAttr, bg (select ( V. Color240 235 , V. Color240 235 , V. brightBlack, V. black, V. black) ))
48+ , (progressIncompleteAttr, bg (select ( V. Color240 225 , V. Color240 225 , V. black, V. black, V. black) ))
5549
5650 -- Main list
57- , (toggleMarkerAttr, fg midGray)
58- , (openMarkerAttr, fg midGray)
51+ , (toggleMarkerAttr, fg (select midGray) )
52+ , (openMarkerAttr, fg (select midGray) )
5953
6054 -- Hotkey stuff
6155 , (hotkeyAttr, fg V. blue)
62- , (disabledHotkeyAttr, fg midGray)
63- , (hotkeyMessageAttr, fg brightWhite)
64- , (disabledHotkeyMessageAttr, fg brightGray)
56+ , (disabledHotkeyAttr, fg (select midGray) )
57+ , (hotkeyMessageAttr, fg (select brightWhite) )
58+ , (disabledHotkeyMessageAttr, fg (select brightGray) )
6559
6660 -- Spinner
67- , (circleSpinnerAttr, fg brightGray)
61+ , (circleSpinnerAttr, fg (select brightGray) )
6862
6963 -- General UI
70- , (branchAttr, fg solarizedBlue)
71- , (hashAttr, fg midGray)
72- , (hashNumberAttr, fg solarizedViolet)
73- , (usernameAttr, fg solarizedBlue)
64+ , (branchAttr, fg (select solarizedBlue) )
65+ , (hashAttr, fg (select midGray) )
66+ , (hashNumberAttr, fg (select solarizedViolet) )
67+ , (usernameAttr, fg (select solarizedBlue) )
7468
7569 -- Markdown
7670 , (italicText, style V. italic)
7771 , (underlineText, style V. underline)
7872 , (boldText, style V. bold)
7973 , (boldUnderlineText, V. defAttr `V.withStyle` V. bold `V.withStyle` V. underline)
8074 , (strikeoutText, style V. strikethrough)
81- , (codeText, brightWhite `on` dimGray)
82- , (codeBlockText, fg midGray)
83- , (horizontalRuleAttr, fg midGray)
75+ , (codeText, select brightWhite `on` select dimGray)
76+ , (codeBlockText, fg (select midGray) )
77+ , (horizontalRuleAttr, fg (select midGray) )
8478
8579 -- Forms
8680 , (E. editFocusedAttr, V. black `on` V. yellow)
8781 ] <> attrMappingsForStyle Sky. breezeDark)
82+ where
83+ select = selectColor colorMode
8884
8985iconAttr = mkAttrName " icon"
9086normalAttr = mkAttrName " normal"
@@ -141,32 +137,87 @@ codeText = mkAttrName "code-text"
141137codeBlockText = mkAttrName " code-block-text"
142138horizontalRuleAttr = mkAttrName " horizontal-rule"
143139
144- -- * Colors
145-
146- solarizedBase03 = V. rgbColor 0x00 0x2b 0x36
147- solarizedBase02 = V. rgbColor 0x07 0x36 0x42
148- solarizedBase01 = V. rgbColor 0x58 0x6e 0x75
149- solarizedbase00 = V. rgbColor 0x65 0x7b 0x83
150- solarizedBase0 = V. rgbColor 0x83 0x94 0x96
151- solarizedBase1 = V. rgbColor 0x93 0xa1 0xa1
152- solarizedBase2 = V. rgbColor 0xee 0xe8 0xd5
153- solarizedBase3 = V. rgbColor 0xfd 0xf6 0xe3
154- solarizedYellow = V. rgbColor 0xb5 0x89 0x00
155- solarizedOrange = V. rgbColor 0xcb 0x4b 0x16
156- solarizedRed = V. rgbColor 0xdc 0x32 0x2f
157- solarizedMagenta = V. rgbColor 0xd3 0x36 0x82
158- solarizedViolet = V. rgbColor 0x6c 0x71 0xc4
159- solarizedBlue = V. rgbColor 0x26 0x8b 0xd2
160- solarizedCyan = V. rgbColor 0x2a 0xa1 0x98
161- solarizedGreen = V. rgbColor 0x85 0x99 0x00
162-
163- githubOrange = V. rgbColor 0xd2 0x99 0x22
164-
165- dimGray = grayAt 25
166- midGray = grayAt 50
167- brightGray = grayAt 80
168- midWhite = grayAt 140
169- brightWhite = grayAt 200
170-
171- grayAt level = V. rgbColor level level level
172- -- grayAt level = V.Color240 $ V.rgbColorToColor240 level level level
140+ -- * Color Fallback System
141+
142+ -- Type alias for color fallbacks: (FullColor, ColorMode240, ColorMode16, ColorMode8, NoColor)
143+ type ColorFallback = (V. Color , V. Color , V. Color , V. Color , V. Color )
144+
145+ -- Color selection function based on detected terminal capabilities
146+ selectColor :: V. ColorMode -> ColorFallback -> V. Color
147+ selectColor colorMode (fullColor, color240, color16, color8, noColor) = case colorMode of
148+ V. FullColor -> fullColor
149+ V. ColorMode240 _ -> color240
150+ V. ColorMode16 -> color16
151+ V. ColorMode8 -> color8
152+ V. NoColor -> noColor
153+
154+ -- * Color Definitions with Fallbacks
155+
156+ solarizedBase03 :: ColorFallback
157+ solarizedBase03 = (V. rgbColor 0x00 0x2b 0x36 , V. Color240 234 , V. black, V. black, V. black)
158+
159+ solarizedBase02 :: ColorFallback
160+ solarizedBase02 = (V. rgbColor 0x07 0x36 0x42 , V. Color240 235 , V. black, V. black, V. black)
161+
162+ solarizedBase01 :: ColorFallback
163+ solarizedBase01 = (V. rgbColor 0x58 0x6e 0x75 , V. Color240 240 , V. brightBlack, V. black, V. black)
164+
165+ solarizedbase00 :: ColorFallback
166+ solarizedbase00 = (V. rgbColor 0x65 0x7b 0x83 , V. Color240 241 , V. brightBlack, V. black, V. black)
167+
168+ solarizedBase0 :: ColorFallback
169+ solarizedBase0 = (V. rgbColor 0x83 0x94 0x96 , V. Color240 244 , V. brightBlack, V. white, V. white)
170+
171+ solarizedBase1 :: ColorFallback
172+ solarizedBase1 = (V. rgbColor 0x93 0xa1 0xa1 , V. Color240 245 , V. brightWhite, V. white, V. white)
173+
174+ solarizedBase2 :: ColorFallback
175+ solarizedBase2 = (V. rgbColor 0xee 0xe8 0xd5 , V. Color240 254 , V. brightWhite, V. white, V. white)
176+
177+ solarizedBase3 :: ColorFallback
178+ solarizedBase3 = (V. rgbColor 0xfd 0xf6 0xe3 , V. Color240 230 , V. brightWhite, V. white, V. white)
179+
180+ solarizedYellow :: ColorFallback
181+ solarizedYellow = (V. rgbColor 0xb5 0x89 0x00 , V. Color240 136 , V. brightYellow, V. yellow, V. white)
182+
183+ solarizedOrange :: ColorFallback
184+ solarizedOrange = (V. rgbColor 0xcb 0x4b 0x16 , V. Color240 166 , V. brightRed, V. red, V. white)
185+
186+ solarizedRed :: ColorFallback
187+ solarizedRed = (V. rgbColor 0xdc 0x32 0x2f , V. Color240 160 , V. brightRed, V. red, V. white)
188+
189+ solarizedMagenta :: ColorFallback
190+ solarizedMagenta = (V. rgbColor 0xd3 0x36 0x82 , V. Color240 125 , V. brightMagenta, V. magenta, V. white)
191+
192+ solarizedViolet :: ColorFallback
193+ solarizedViolet = (V. rgbColor 0x6c 0x71 0xc4 , V. Color240 61 , V. brightBlue, V. blue, V. white)
194+
195+ solarizedBlue :: ColorFallback
196+ solarizedBlue = (V. rgbColor 0x26 0x8b 0xd2 , V. Color240 33 , V. brightBlue, V. blue, V. white)
197+
198+ solarizedCyan :: ColorFallback
199+ solarizedCyan = (V. rgbColor 0x2a 0xa1 0x98 , V. Color240 37 , V. brightCyan, V. cyan, V. white)
200+
201+ solarizedGreen :: ColorFallback
202+ solarizedGreen = (V. rgbColor 0x85 0x99 0x00 , V. Color240 106 , V. brightGreen, V. green, V. white)
203+
204+ githubOrange :: ColorFallback
205+ githubOrange = (V. rgbColor 0xd2 0x99 0x22 , V. Color240 178 , V. brightYellow, V. yellow, V. white)
206+
207+ dimGray :: ColorFallback
208+ dimGray = (grayAtRGB 25 , V. Color240 236 , V. black, V. black, V. black)
209+
210+ midGray :: ColorFallback
211+ midGray = (grayAtRGB 50 , V. Color240 238 , V. brightBlack, V. black, V. black)
212+
213+ brightGray :: ColorFallback
214+ brightGray = (grayAtRGB 80 , V. Color240 244 , V. brightBlack, V. white, V. white)
215+
216+ midWhite :: ColorFallback
217+ midWhite = (grayAtRGB 140 , V. Color240 249 , V. brightWhite, V. white, V. white)
218+
219+ brightWhite :: ColorFallback
220+ brightWhite = (grayAtRGB 200 , V. Color240 253 , V. brightWhite, V. white, V. white)
221+
222+ grayAtRGB :: Word8 -> V. Color
223+ grayAtRGB level = V. rgbColor level level level
0 commit comments