Commit 77ee0e8 1 parent af65639 commit 77ee0e8 Copy full SHA for 77ee0e8
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
, (<+>)
@@ -754,6 +765,43 @@ italic = styled (RShape Italic)
754
765
underlined :: HasChars a => Doc a -> Doc a
755
766
underlined = styled (RUnderline ULSingle )
756
767
768
+ -- The Color type is here as an opaque alias to Color8 for the public interface
769
+ -- and there's trivial smart constructors for the individual colors to
770
+ -- hopefully allow for easier extension to supporting indexed and rgb colors in
771
+ -- the future, without dramatically changing the public API.
772
+
773
+ type Color = Color8
774
+
775
+ fg :: HasChars a => Color -> Doc a -> Doc a
776
+ fg = styled . RForeground . FG
777
+
778
+ bg :: HasChars a => Color -> Doc a -> Doc a
779
+ bg = styled . RBackground . BG
780
+
781
+ blue :: Color
782
+ blue = Blue
783
+
784
+ black :: Color
785
+ black = Black
786
+
787
+ red :: Color
788
+ red = Red
789
+
790
+ green :: Color
791
+ green = Green
792
+
793
+ yellow :: Color
794
+ yellow = Yellow
795
+
796
+ magenta :: Color
797
+ magenta = Magenta
798
+
799
+ cyan :: Color
800
+ cyan = Cyan
801
+
802
+ white :: Color
803
+ white = White
804
+
757
805
-- | Returns width of a character in a monospace font: 0 for a combining
758
806
-- character, 1 for a regular character, 2 for an East Asian wide character.
759
807
-- Ambiguous characters are treated as width 1.
You can’t perform that action at this time.
0 commit comments