1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
{-# LANGUAGE OverloadedStrings #-}
-- | This is an example Termonad configuration that shows how to use the
-- Solarized colour scheme https://ethanschoonover.com/solarized/
module Main where
import Data.Maybe (fromMaybe)
import Termonad
( CursorBlinkMode(CursorBlinkModeOn)
, Option(Set)
, ShowScrollbar(ShowScrollbarNever)
, TMConfig
, confirmExit
, cursorBlinkMode
, defaultConfigOptions
, defaultTMConfig
, options
, showMenu
, showScrollbar
, start
, FontConfig
, FontSize(FontSizePoints)
, defaultFontConfig
, fontConfig
, fontFamily
, fontSize
)
import Termonad.Config.Colour
( AlphaColour
, ColourConfig
, Palette(ExtendedPalette)
, addColourExtension
, createColour
, createColourExtension
, defaultColourConfig
, defaultStandardColours
, defaultLightColours
, backgroundColour
, foregroundColour
, palette
, List8
, mkList8
)
-- This is our main 'TMConfig'. It holds all of the non-colour settings
-- for Termonad.
--
-- This shows how a few settings can be changed.
myTMConfig :: TMConfig
myTMConfig =
defaultTMConfig
{ options =
defaultConfigOptions
{ showScrollbar = ShowScrollbarNever
, confirmExit = False
, showMenu = False
, cursorBlinkMode = CursorBlinkModeOn
, fontConfig = fontConf
}
}
-- This is our Solarized dark 'ColourConfig'. It holds all of our dark-related settings.
solarizedDark :: ColourConfig (AlphaColour Double)
solarizedDark =
defaultColourConfig
-- Set the default foreground colour of text of the terminal.
{ foregroundColour = Set (createColour 131 148 150) -- base0
, backgroundColour = Set (createColour 0 43 54) -- base03
-- Set the extended palette that has 2 Vecs of 8 Solarized palette colours
, palette = ExtendedPalette solarizedDark1 solarizedDark2
}
where
solarizedDark1 :: List8 (AlphaColour Double)
solarizedDark1 = fromMaybe defaultStandardColours $ mkList8
[ createColour 7 54 66 -- base02
, createColour 220 50 47 -- red
, createColour 133 153 0 -- green
, createColour 181 137 0 -- yellow
, createColour 38 139 210 -- blue
, createColour 211 54 130 -- magenta
, createColour 42 161 152 -- cyan
, createColour 238 232 213 -- base2
]
solarizedDark2 :: List8 (AlphaColour Double)
solarizedDark2 = fromMaybe defaultStandardColours $ mkList8
[ createColour 0 43 54 -- base03
, createColour 203 75 22 -- orange
, createColour 88 110 117 -- base01
, createColour 101 123 131 -- base00
, createColour 131 148 150 -- base0
, createColour 108 113 196 -- violet
, createColour 147 161 161 -- base1
, createColour 253 246 227 -- base3
]
-- This is our Solarized light 'ColourConfig'. It holds all of our light-related settings.
solarizedLight :: ColourConfig (AlphaColour Double)
solarizedLight =
defaultColourConfig
-- Set the default foreground colour of text of the terminal.
{ foregroundColour = Set (createColour 101 123 131) -- base00
, backgroundColour = Set (createColour 253 246 227) -- base3
-- Set the extended palette that has 2 Vecs of 8 Solarized palette colours
, palette = ExtendedPalette solarizedLight1 solarizedLight2
}
where
solarizedLight1 :: List8 (AlphaColour Double)
solarizedLight1 = fromMaybe defaultLightColours $ mkList8
[ createColour 7 54 66 -- base02
, createColour 220 50 47 -- red
, createColour 133 153 0 -- green
, createColour 181 137 0 -- yellow
, createColour 38 139 210 -- blue
, createColour 211 54 130 -- magenta
, createColour 42 161 152 -- cyan
, createColour 238 232 213 -- base2
]
solarizedLight2 :: List8 (AlphaColour Double)
solarizedLight2 = fromMaybe defaultLightColours $ mkList8
[ createColour 0 43 54 -- base03
, createColour 203 75 22 -- orange
, createColour 88 110 117 -- base01
, createColour 101 123 131 -- base00
, createColour 131 148 150 -- base0
, createColour 108 113 196 -- violet
, createColour 147 161 161 -- base1
, createColour 253 246 227 -- base3
]
-- This defines the font for the terminal.
fontConf :: FontConfig
fontConf =
defaultFontConfig
{ fontFamily = "Monospace"
, fontSize = FontSizePoints 12
}
main :: IO ()
main = do
-- First, create the colour extension based on either Solarized modules.
myColourExt <- createColourExtension solarizedDark
-- Update 'myTMConfig' with our colour extension.
let newTMConfig = addColourExtension myTMConfig myColourExt
-- Start Termonad with our updated 'TMConfig'.
start newTMConfig
|