Browse files

hack vty to display bright colors by abusing the bold attribute

  • Loading branch information...
1 parent 82dbed4 commit db72379037d3fe37d52654f7dfaa0bd8d8d5a956 @Mikolaj Mikolaj committed Mar 23, 2011
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/Display/Vty.hs
14 src/Display/Vty.hs
@@ -64,8 +64,16 @@ nextEvent session =
e <- V.next_event session
maybe (nextEvent session) return (keyTranslate e)
-setFG c a = with_fore_color a c
-setBG c a = with_back_color a c
-attr = def_attr
+-- A hack to get bright colors via the bold attribute. Depending on terminal
+-- settings this is needed or not and the characters really get bold or not.
+-- HCurses does this by default, but vty refuses to get crazy.
+isBright c = c `elem` [bright_black, bright_red, bright_green, bright_yellow,
+ bright_blue, bright_magenta, bright_cyan, bright_white]
+hack c a = if isBright c then with_style a bold else a
+setFG c a = hack c $ with_fore_color a c
+setBG c a = hack c $ with_back_color a c
+attr = def_attr { attr_fore_color = SetTo white,
+ attr_back_color = SetTo black }
type AttrColor = Color

0 comments on commit db72379

Please sign in to comment.