@@ -8,6 +8,7 @@ module Text.DocLayout.ANSIFont
8
8
, Shape (.. )
9
9
, Color8 (.. )
10
10
, Underline (.. )
11
+ , Strikeout (.. )
11
12
, Foreground (.. )
12
13
, Background (.. )
13
14
, (~>)
@@ -23,24 +24,31 @@ data Font = Font
23
24
{ ftWeight :: Weight ,
24
25
ftShape :: Shape ,
25
26
ftUnderline :: Underline ,
27
+ ftStrikeout :: Strikeout ,
26
28
ftForeground :: Foreground ,
27
29
ftBackground :: Background ,
28
30
ftLink :: Maybe Text
29
31
}
30
32
deriving (Show , Eq , Read , Data , Ord )
31
33
32
34
baseFont :: Font
33
- baseFont = Font Normal Roman ULNone FGDefault BGDefault Nothing
35
+ baseFont = Font Normal Roman ULNone Unstruck FGDefault BGDefault Nothing
34
36
35
37
data Weight = Normal | Bold deriving (Show , Eq , Read , Data , Ord )
36
38
data Shape = Roman | Italic deriving (Show , Eq , Read , Data , Ord )
37
39
data Color8 = Black | Red | Green | Yellow | Blue | Magenta | Cyan | White deriving (Show , Eq , Enum , Read , Data , Ord )
38
40
data Underline = ULNone | ULSingle | ULDouble | ULCurly deriving (Show , Eq , Read , Data , Ord )
41
+ data Strikeout = Unstruck | Struck deriving (Show , Eq , Read , Data , Ord )
39
42
data Foreground = FGDefault | FG Color8 deriving (Show , Eq , Read , Data , Ord )
40
43
data Background = BGDefault | BG Color8 deriving (Show , Eq , Read , Data , Ord )
41
44
42
- data StyleReq =
43
- RWeight Weight | RShape Shape | RForeground Foreground | RBackground Background | RUnderline Underline
45
+ data StyleReq
46
+ = RWeight Weight
47
+ | RShape Shape
48
+ | RForeground Foreground
49
+ | RBackground Background
50
+ | RUnderline Underline
51
+ | RStrikeout Strikeout
44
52
deriving (Show , Eq , Read , Data , Ord )
45
53
46
54
(~>) :: Font -> StyleReq -> Font
@@ -49,6 +57,7 @@ data StyleReq =
49
57
(~>) f (RForeground c) = f{ftForeground = c}
50
58
(~>) f (RBackground c) = f{ftBackground = c}
51
59
(~>) f (RUnderline u) = f{ftUnderline = u}
60
+ (~>) f (RStrikeout u) = f{ftStrikeout = u}
52
61
53
62
rawSGR :: (Semigroup a , IsString a ) => a -> a
54
63
rawSGR n = " \ESC [" <> n <> " m"
@@ -78,6 +87,10 @@ instance SGR Underline where
78
87
renderSGR ULDouble = rawSGR " 21"
79
88
renderSGR ULCurly = rawSGR " 4:3"
80
89
90
+ instance SGR Strikeout where
91
+ renderSGR Unstruck = rawSGR " 29"
92
+ renderSGR Struck = rawSGR " 9"
93
+
81
94
renderFont :: (Semigroup a , IsString a ) => Font -> a
82
95
renderFont f
83
96
| f == baseFont = rawSGR " 0"
@@ -87,6 +100,7 @@ renderFont f
87
100
<> renderSGR (ftForeground f)
88
101
<> renderSGR (ftBackground f)
89
102
<> renderSGR (ftUnderline f)
103
+ <> renderSGR (ftStrikeout f)
90
104
91
105
renderOSC8 :: (Semigroup a , IsString a ) => Maybe a -> a
92
106
renderOSC8 Nothing = " \ESC ]8;;\ESC\\ "
0 commit comments