on master help sign in
Add support for italicized output when terminfo supports it
commite23742907a5a2f991a853ddafe229842f7699651 authorJonathan Daugherty <cygnus@foobox.com> dateFri 27 Jul 2018, 13:30 (8 years ago) parentbb68f7a
3 files changed+23−3
src/Graphics/Vty/Attributes.hs+8−3 src/Graphics/Vty/DisplayAttributes.hs+3 src/Graphics/Vty/Output/TerminfoBased.hs+12
src/Graphics/Vty/Attributes.hs+8−3
@@ -38,6 +38,7 @@ module Graphics.Vty.Attributes
3838 , Style
3939 , withStyle
4040 , standout
41+ , italic
4142 , underline
4243 , reverseVideo
4344 , blink
@@ -103,14 +104,15 @@ data Attr = Attr
103104-- __ - unused
104105--
105106-- Next is the style flags
106−-- SURBDO__
107+-- SURBDOI_
107108-- S - standout
108109-- U - underline
109110-- R - reverse video
110111-- B - blink
111112-- D - dim
112113-- O - bold
113−-- __ - unused
114+-- I - italic
115+-- _ - unused
114116--
115117-- Then the foreground color encoded into 8 bits.
116118-- Then the background color encoded into 8 bits.
@@ -187,15 +189,18 @@ type Style = Word8
187189--
188190-- * bold/bright
189191--
192+-- * italic
193+--
190194-- (The invisible, protect, and altcharset display attributes some
191195-- terminals support are not supported via VTY.)
192−standout, underline, reverseVideo, blink, dim, bold :: Style
196+standout, underline, reverseVideo, blink, dim, bold, italic :: Style
193197standout = 0x01
194198underline = 0x02
195199reverseVideo = 0x04
196200blink = 0x08
197201dim = 0x10
198202bold = 0x20
203+italic = 0x40
199204
200205defaultStyleMask :: Style
201206defaultStyleMask = 0x00
src/Graphics/Vty/DisplayAttributes.hs+3
@@ -94,6 +94,8 @@ data DisplayColorDiff
9494data StyleStateChange
9595 = ApplyStandout
9696 | RemoveStandout
97+ | ApplyItalic
98+ | RemoveItalic
9799 | ApplyUnderline
98100 | RemoveUnderline
99101 | ApplyReverseVideo
@@ -141,6 +143,7 @@ diffStyles prev cur
141143 = mconcat
142144 [ styleDiff standout ApplyStandout RemoveStandout
143145 , styleDiff underline ApplyUnderline RemoveUnderline
146+ , styleDiff italic ApplyItalic RemoveItalic
144147 , styleDiff reverseVideo ApplyReverseVideo RemoveReverseVideo
145148 , styleDiff blink ApplyBlink RemoveBlink
146149 , styleDiff dim ApplyDim RemoveDim
src/Graphics/Vty/Output/TerminfoBased.hs+12
@@ -62,6 +62,8 @@ data DisplayAttrCaps = DisplayAttrCaps
6262 { setAttrStates :: Maybe CapExpression
6363 , enterStandout :: Maybe CapExpression
6464 , exitStandout :: Maybe CapExpression
65+ , enterItalic :: Maybe CapExpression
66+ , exitItalic :: Maybe CapExpression
6567 , enterUnderline :: Maybe CapExpression
6668 , exitUnderline :: Maybe CapExpression
6769 , enterReverseVideo :: Maybe CapExpression
@@ -227,6 +229,8 @@ currentDisplayAttrCaps ti
227229 <*> probeCap ti "sgr"
228230 <*> probeCap ti "smso"
229231 <*> probeCap ti "rmso"
232+ <*> probeCap ti "sitm"
233+ <*> probeCap ti "ritm"
230234 <*> probeCap ti "smul"
231235 <*> probeCap ti "rmul"
232236 <*> probeCap ti "rev"
@@ -434,6 +438,7 @@ data DisplayAttrSeq
434438data DisplayAttrState = DisplayAttrState
435439 { applyStandout :: Bool
436440 , applyUnderline :: Bool
441+ , applyItalic :: Bool
437442 , applyReverseVideo :: Bool
438443 , applyBlink :: Bool
439444 , applyDim :: Bool
@@ -444,6 +449,7 @@ sgrArgsForState :: DisplayAttrState -> [CapParam]
444449sgrArgsForState attrState = map (\b -> if b then 1 else 0)
445450 [ applyStandout attrState
446451 , applyUnderline attrState
452+ , applyItalic attrState
447453 , applyReverseVideo attrState
448454 , applyBlink attrState
449455 , applyDim attrState
@@ -470,6 +476,8 @@ reqDisplayCapSeqFor caps s diffs
470476 -- set state cap then just use the set state cap.
471477 ( True, True ) -> SetState $ stateForStyle s
472478 where
479+ noEnterExitCap ApplyItalic = isNothing $ enterItalic caps
480+ noEnterExitCap RemoveItalic = isNothing $ exitItalic caps
473481 noEnterExitCap ApplyStandout = isNothing $ enterStandout caps
474482 noEnterExitCap RemoveStandout = isNothing $ exitStandout caps
475483 noEnterExitCap ApplyUnderline = isNothing $ enterUnderline caps
@@ -482,6 +490,8 @@ reqDisplayCapSeqFor caps s diffs
482490 noEnterExitCap RemoveDim = True
483491 noEnterExitCap ApplyBold = isNothing $ enterBoldMode caps
484492 noEnterExitCap RemoveBold = True
493+ enterExitCap ApplyItalic = fromJust $ enterItalic caps
494+ enterExitCap RemoveItalic = fromJust $ exitItalic caps
485495 enterExitCap ApplyStandout = fromJust $ enterStandout caps
486496 enterExitCap RemoveStandout = fromJust $ exitStandout caps
487497 enterExitCap ApplyUnderline = fromJust $ enterUnderline caps
@@ -495,6 +505,7 @@ stateForStyle :: Style -> DisplayAttrState
495505stateForStyle s = DisplayAttrState
496506 { applyStandout = isStyleSet standout
497507 , applyUnderline = isStyleSet underline
508+ , applyItalic = isStyleSet italic
498509 , applyReverseVideo = isStyleSet reverseVideo
499510 , applyBlink = isStyleSet blink
500511 , applyDim = isStyleSet dim
@@ -506,6 +517,7 @@ styleToApplySeq :: Style -> [StyleStateChange]
506517styleToApplySeq s = concat
507518 [ applyIfRequired ApplyStandout standout
508519 , applyIfRequired ApplyUnderline underline
520+ , applyIfRequired ApplyItalic italic
509521 , applyIfRequired ApplyReverseVideo reverseVideo
510522 , applyIfRequired ApplyBlink blink
511523 , applyIfRequired ApplyDim dim