Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
204 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module Attr where | ||
|
||
import qualified Data.Binary | ||
|
||
data Color = | ||
Black | ||
| Red | ||
| Green | ||
| Yellow | ||
| Blue | ||
| Magenta | ||
| Cyan | ||
| White | ||
| BrBlack | ||
| BrRed | ||
| BrGreen | ||
| BrYellow | ||
| BrBlue | ||
| BrMagenta | ||
| BrCyan | ||
| BrWhite | ||
deriving (Show, Eq, Ord, Enum, Bounded) | ||
|
||
instance Data.Binary.Binary Color where | ||
put c = Data.Binary.putWord8 $ toEnum $ fromEnum c | ||
get = do | ||
c <- Data.Binary.getWord8 | ||
return $ toEnum $ fromEnum c | ||
|
||
defBG, defFG :: Color | ||
defBG = Black | ||
defFG = White | ||
|
||
isBright :: Color -> Bool | ||
isBright c = fromEnum c > 7 | ||
|
||
-- Mimics the Linux console; good old retro feel and more useful than xterm. | ||
colorToRGB :: Color -> String | ||
colorToRGB Black = "#000000" | ||
colorToRGB Red = "#AA0000" | ||
colorToRGB Green = "#00AA00" | ||
colorToRGB Yellow = "#AA5500" | ||
colorToRGB Blue = "#0000AA" | ||
colorToRGB Magenta = "#AA00AA" | ||
colorToRGB Cyan = "#00AAAA" | ||
colorToRGB White = "#AAAAAA" | ||
colorToRGB BrBlack = "#555555" | ||
colorToRGB BrRed = "#FF5555" | ||
colorToRGB BrGreen = "#55FF55" | ||
colorToRGB BrYellow = "#FFFF55" | ||
colorToRGB BrBlue = "#5555FF" | ||
colorToRGB BrMagenta = "#FF55FF" | ||
colorToRGB BrCyan = "#55FFFF" | ||
colorToRGB BrWhite = "#FFFFFF" | ||
|
||
-- Human-readable names, for item descriptions. L | ||
-- Lots of licentia poetica, since the colors are artificial and rarely seen. | ||
colorToName :: Color -> String | ||
colorToName Black = "black" | ||
colorToName Red = "apple red" | ||
colorToName Green = "forest green" | ||
colorToName Yellow = "brown" | ||
colorToName Blue = "ultramarine" | ||
colorToName Magenta = "purple" | ||
colorToName Cyan = "cyan" | ||
colorToName White = "silver gray" | ||
colorToName BrBlack = "charcoal" | ||
colorToName BrRed = "coral red" | ||
colorToName BrGreen = "emerald green" | ||
colorToName BrYellow = "yellow" | ||
colorToName BrBlue = "royal blue" | ||
colorToName BrMagenta = "magenta" | ||
colorToName BrCyan = "aquamarine" | ||
colorToName BrWhite = "white" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.