Skip to content

Commit

Permalink
Merge pull request #195 from craigem/example-Dracula-config
Browse files Browse the repository at this point in the history
example-config: added Dracula
  • Loading branch information
cdepillabout committed Jul 24, 2021
2 parents 2713500 + 68dce8f commit 50b20dc
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 0 deletions.
112 changes: 112 additions & 0 deletions example-config/ExampleDraculaColourExtension.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{-# LANGUAGE OverloadedStrings #-}
-- | This is an example Termonad configuration that shows how to use the
-- Dracula colour scheme https://draculatheme.com/

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 Dracula 'ColourConfig'.
dracula :: ColourConfig (AlphaColour Double)
dracula =
defaultColourConfig
-- Set the default background & foreground colour of text of the terminal.
{ backgroundColour = Set (createColour 40 42 54) -- black.0
, foregroundColour = Set (createColour 248 248 242) -- white.7
-- Set the extended palette that has 2 Vecs of 8 Dracula palette colours
, palette = ExtendedPalette draculaNormal draculaBright
}
where
draculaNormal :: List8 (AlphaColour Double)
draculaNormal = fromMaybe defaultStandardColours $ mkList8
[ createColour 40 42 54 -- black.0
, createColour 255 85 85 -- red.1
, createColour 80 250 123 -- green.2
, createColour 241 250 140 -- yellow.3
, createColour 189 147 249 -- blue.4
, createColour 255 121 198 -- magenta.5
, createColour 139 233 253 -- cyan.6
, createColour 191 191 191 -- white.7
]

draculaBright :: List8 (AlphaColour Double)
draculaBright = fromMaybe defaultStandardColours $ mkList8
[ createColour 77 77 77 -- black.8
, createColour 255 110 103 -- red.9
, createColour 90 247 142 -- green.10
, createColour 244 249 157 -- yellow.11
, createColour 202 169 250 -- blue.12
, createColour 255 146 208 -- magenta.13
, createColour 154 237 254 -- cyan.14
, createColour 230 230 230 -- white.15
]

fontConf =
defaultFontConfig
{ fontFamily = "Monospace"
, fontSize = FontSizePoints 12
}

main :: IO ()
main = do
-- First, create the colour extension based on either PaperColor modules.
myColourExt <- createColourExtension dracula

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

-- Start Termonad with our updated 'TMConfig'.
start newTMConfig
Binary file added img/termonad-Dracula.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions termonad.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ executable termonad-example-colour-extension
else
buildable: False

executable termonad-example-colour-extension-dracula
main-is: example-config/ExampleDraculaColourExtension.hs
build-depends: base
, termonad
, colour
default-language: Haskell2010
ghc-options: -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -threaded -rtsopts -with-rtsopts=-N

if flag(buildexamples)
buildable: True
else
buildable: False

executable termonad-example-colour-extension-gruvbox
main-is: example-config/ExampleGruvboxColourExtension.hs
build-depends: base
Expand Down

0 comments on commit 50b20dc

Please sign in to comment.