Commit 949d42f 1 parent 625482f commit 949d42f Copy full SHA for 949d42f
File tree 1 file changed +48
-0
lines changed
1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,17 @@ module Text.DocLayout (
59
59
, bold
60
60
, italic
61
61
, underlined
62
+ , fg
63
+ , bg
64
+ , Color
65
+ , black
66
+ , red
67
+ , green
68
+ , yellow
69
+ , blue
70
+ , magenta
71
+ , cyan
72
+ , white
62
73
, empty
63
74
-- * Functions for concatenating documents
64
75
, (<+>)
@@ -757,6 +768,43 @@ italic = styled (RShape Italic)
757
768
underlined :: HasChars a => Doc a -> Doc a
758
769
underlined = styled (RUnderline ULSingle )
759
770
771
+ -- The Color type is here as an opaque alias to Color8 for the public interface
772
+ -- and there's trivial smart constructors for the individual colors to
773
+ -- hopefully allow for easier extension to supporting indexed and rgb colors in
774
+ -- the future, without dramatically changing the public API.
775
+
776
+ type Color = Color8
777
+
778
+ fg :: HasChars a => Color -> Doc a -> Doc a
779
+ fg = styled . RForeground . FG
780
+
781
+ bg :: HasChars a => Color -> Doc a -> Doc a
782
+ bg = styled . RBackground . BG
783
+
784
+ blue :: Color
785
+ blue = Blue
786
+
787
+ black :: Color
788
+ black = Black
789
+
790
+ red :: Color
791
+ red = Red
792
+
793
+ green :: Color
794
+ green = Green
795
+
796
+ yellow :: Color
797
+ yellow = Yellow
798
+
799
+ magenta :: Color
800
+ magenta = Magenta
801
+
802
+ cyan :: Color
803
+ cyan = Cyan
804
+
805
+ white :: Color
806
+ white = White
807
+
760
808
-- | Returns width of a character in a monospace font: 0 for a combining
761
809
-- character, 1 for a regular character, 2 for an East Asian wide character.
762
810
-- Ambiguous characters are treated as width 1.
You can’t perform that action at this time.
0 commit comments