termonad.hs 4.32 KB
Newer Older
Craige McWhirter's avatar
Craige McWhirter committed
1
{-# LANGUAGE OverloadedStrings #-}
Craige McWhirter's avatar
Craige McWhirter committed
2
-- This is my Termonad configuration.
Craige McWhirter's avatar
Craige McWhirter committed
3 4 5

module Main where

6 7 8 9 10 11
import Termonad
  ( CursorBlinkMode(CursorBlinkModeOff), Option(Set)
  , ShowScrollbar(ShowScrollbarNever), TMConfig, confirmExit, cursorBlinkMode
  , defaultConfigOptions, defaultTMConfig, options, showMenu, showScrollbar
  , start, FontConfig, FontSize(FontSizePoints), defaultFontConfig, fontConfig
  , fontFamily, fontSize
Craige McWhirter's avatar
Craige McWhirter committed
12 13
  )
import Termonad.Config.Colour
14 15 16 17 18 19
  ( Colour, ColourConfig, Palette(ExtendedPalette), addColourExtension
  , createColourExtension, cursorBgColour, defaultColourConfig, foregroundColour
  , palette, sRGB24
  )
import Termonad.Config.Vec (Vec((:*), EmptyVec), N8, unsafeFromListVec_)
import Data.Colour.SRGB (Colour, sRGB24)
Craige McWhirter's avatar
Craige McWhirter committed
20

21 22
-- This is our main 'TMConfig'.  It holds all of the non-colour settings
-- for Termonad.
Craige McWhirter's avatar
Craige McWhirter committed
23
--
24 25 26 27 28 29 30 31 32 33 34 35 36
-- This shows how a few settings can be changed.
myTMConfig :: TMConfig
myTMConfig =
  defaultTMConfig
    { options =
        defaultConfigOptions
          { showScrollbar = ShowScrollbarNever
          , confirmExit = False
          , showMenu = False
          , cursorBlinkMode = CursorBlinkModeOff
          , fontConfig = fontConf
          }
    }
Craige McWhirter's avatar
Craige McWhirter committed
37

Craige McWhirter's avatar
Craige McWhirter committed
38
-- This is our Solarized dark 'ColourConfig'.  It holds all of our dark-related settings.
39 40
solarizedDark :: ColourConfig (Colour Double)
solarizedDark =
Craige McWhirter's avatar
Craige McWhirter committed
41
  defaultColourConfig
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
    -- Set the default foreground colour of text of the terminal.
    { foregroundColour = sRGB24 131 148 150 -- base0
    -- Set the extended palette that has 2 Vecs of 8 Solarized pallette colours
    , palette = ExtendedPalette solarizedDark1 solarizedDark2
    }
  where
    solarizedDark1 :: Vec N8 (Colour Double)
    solarizedDark1 =
         sRGB24   0  43  54 -- base03, background
      :* sRGB24 220  50  47 -- red
      :* sRGB24 133 153   0 -- green
      :* sRGB24 181 137   0 -- yellow
      :* sRGB24  38 139 210 -- blue
      :* sRGB24 211  54 130 -- magenta
      :* sRGB24  42 161 152 -- cyan
      :* sRGB24 238 232 213 -- base2
      :* EmptyVec

    solarizedDark2 :: Vec N8 (Colour Double)
    solarizedDark2 =
         sRGB24   7  54  66 -- base02, background highlights
      :* sRGB24 203  75  22 -- orange
      :* sRGB24  88 110 117 -- base01, comments / secondary text
      :* sRGB24 131 148 150 -- base0, body text / default code / primary content
      :* sRGB24 147 161 161 -- base1, optional emphasised content
      :* sRGB24 108 113 196 -- violet
      :* sRGB24 101 123 131 -- base00
      :* sRGB24 253 246 227 -- base3
      :* EmptyVec

Craige McWhirter's avatar
Craige McWhirter committed
72
-- This is our Solarized light 'ColourConfig'.  It holds all of our light-related settings.
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
solarizedLight :: ColourConfig (Colour Double)
solarizedLight =
  defaultColourConfig
    -- Set the default foreground colour of text of the terminal.
    { foregroundColour = sRGB24 101 123 131 -- base00
    -- Set the extended palette that has 2 Vecs of 8 Solarized pallette colours
    , palette = ExtendedPalette solarizedLight1 solarizedLight2
    }
  where
    solarizedLight1 :: Vec N8 (Colour Double)
    solarizedLight1 =
         sRGB24 238 232 213 -- base2, background highlights
      :* sRGB24 220  50  47 -- red
      :* sRGB24 133 153   0 -- green
      :* sRGB24 181 137   0 -- yellow
      :* sRGB24  38 139 210 -- blue
      :* sRGB24 211  54 130 -- magenta
      :* sRGB24  42 161 152 -- cyan
      :* sRGB24   7  54  66 -- base02
      :* EmptyVec

    solarizedLight2 :: Vec N8 (Colour Double)
    solarizedLight2 =
         sRGB24 253 246 227 -- base3, background
      :* sRGB24 203  75  22 -- orange
      :* sRGB24 147 161 161 -- base1, comments / secondary text
      :* sRGB24 101 123 131 -- base00, body text / default code / primary content
      :* sRGB24  88 110 117 -- base01, optional emphasised content
      :* sRGB24 108 113 196 -- violet
      :* sRGB24 131 148 150 -- base0
      :* sRGB24   0  43  54 -- base03
      :* EmptyVec
Craige McWhirter's avatar
Craige McWhirter committed
105

Craige McWhirter's avatar
Craige McWhirter committed
106
-- This defines the font for the terminal.
Craige McWhirter's avatar
Craige McWhirter committed
107 108 109 110 111 112 113 114 115
fontConf :: FontConfig
fontConf =
  defaultFontConfig
    { fontFamily = "DejaVu Sans Mono"
    , fontSize = FontSizePoints 8
    }

main :: IO ()
main = do
116 117 118 119 120 121 122 123
  -- First, create the colour extension based on either Solarixed modules.
  myColourExt <- createColourExtension solarizedDark

  -- Update 'myTMConfig' with our colour extension.
  let newTMConfig = addColourExtension myTMConfig myColourExt

  -- Start Termonad with our updated 'TMConfig'.
  start newTMConfig