on master help sign in
Add support for italicized output when terminfo supports it
e237429Jonathan Daugherty
src/Graphics/Vty/Attributes.hs+8−3
@@ -38,6 +38,7 @@ module Graphics.Vty.Attributes
38 , Style
38 , Style
39 , withStyle
39 , withStyle
40 , standout
40 , standout
41+ , italic
41 , underline
42 , underline
42 , reverseVideo
43 , reverseVideo
43 , blink
44 , blink
@@ -103,14 +104,15 @@ data Attr = Attr
103-- __ - unused
104-- __ - unused
104--
105--
105-- Next is the style flags
106-- Next is the style flags
106−-- SURBDO__
107+-- SURBDOI_
107-- S - standout
108-- S - standout
108-- U - underline
109-- U - underline
109-- R - reverse video
110-- R - reverse video
110-- B - blink
111-- B - blink
111-- D - dim
112-- D - dim
112-- O - bold
113-- O - bold
114+-- I - italic
113−-- __ - unused
115+-- _ - unused
114--
116--
115-- Then the foreground color encoded into 8 bits.
117-- Then the foreground color encoded into 8 bits.
116-- Then the background color encoded into 8 bits.
118-- Then the background color encoded into 8 bits.
@@ -187,15 +189,18 @@ type Style = Word8
187--
189--
188-- * bold/bright
190-- * bold/bright
189--
191--
192+-- * italic
193+--
190-- (The invisible, protect, and altcharset display attributes some
194-- (The invisible, protect, and altcharset display attributes some
191-- terminals support are not supported via VTY.)
195-- terminals support are not supported via VTY.)
192−standout, underline, reverseVideo, blink, dim, bold :: Style
196+standout, underline, reverseVideo, blink, dim, bold, italic :: Style
193standout = 0x01
197standout = 0x01
194underline = 0x02
198underline = 0x02
195reverseVideo = 0x04
199reverseVideo = 0x04
196blink = 0x08
200blink = 0x08
197dim = 0x10
201dim = 0x10
198bold = 0x20
202bold = 0x20
203+italic = 0x40
199
204
200defaultStyleMask :: Style
205defaultStyleMask :: Style
201defaultStyleMask = 0x00
206defaultStyleMask = 0x00
src/Graphics/Vty/DisplayAttributes.hs+3
@@ -94,6 +94,8 @@ data DisplayColorDiff
94data StyleStateChange
94data StyleStateChange
95 = ApplyStandout
95 = ApplyStandout
96 | RemoveStandout
96 | RemoveStandout
97+ | ApplyItalic
98+ | RemoveItalic
97 | ApplyUnderline
99 | ApplyUnderline
98 | RemoveUnderline
100 | RemoveUnderline
99 | ApplyReverseVideo
101 | ApplyReverseVideo
@@ -141,6 +143,7 @@ diffStyles prev cur
141 = mconcat
143 = mconcat
142 [ styleDiff standout ApplyStandout RemoveStandout
144 [ styleDiff standout ApplyStandout RemoveStandout
143 , styleDiff underline ApplyUnderline RemoveUnderline
145 , styleDiff underline ApplyUnderline RemoveUnderline
146+ , styleDiff italic ApplyItalic RemoveItalic
144 , styleDiff reverseVideo ApplyReverseVideo RemoveReverseVideo
147 , styleDiff reverseVideo ApplyReverseVideo RemoveReverseVideo
145 , styleDiff blink ApplyBlink RemoveBlink
148 , styleDiff blink ApplyBlink RemoveBlink
146 , styleDiff dim ApplyDim RemoveDim
149 , styleDiff dim ApplyDim RemoveDim
src/Graphics/Vty/Output/TerminfoBased.hs+12
@@ -62,6 +62,8 @@ data DisplayAttrCaps = DisplayAttrCaps
62 { setAttrStates :: Maybe CapExpression
62 { setAttrStates :: Maybe CapExpression
63 , enterStandout :: Maybe CapExpression
63 , enterStandout :: Maybe CapExpression
64 , exitStandout :: Maybe CapExpression
64 , exitStandout :: Maybe CapExpression
65+ , enterItalic :: Maybe CapExpression
66+ , exitItalic :: Maybe CapExpression
65 , enterUnderline :: Maybe CapExpression
67 , enterUnderline :: Maybe CapExpression
66 , exitUnderline :: Maybe CapExpression
68 , exitUnderline :: Maybe CapExpression
67 , enterReverseVideo :: Maybe CapExpression
69 , enterReverseVideo :: Maybe CapExpression
@@ -227,6 +229,8 @@ currentDisplayAttrCaps ti
227 <*> probeCap ti "sgr"
229 <*> probeCap ti "sgr"
228 <*> probeCap ti "smso"
230 <*> probeCap ti "smso"
229 <*> probeCap ti "rmso"
231 <*> probeCap ti "rmso"
232+ <*> probeCap ti "sitm"
233+ <*> probeCap ti "ritm"
230 <*> probeCap ti "smul"
234 <*> probeCap ti "smul"
231 <*> probeCap ti "rmul"
235 <*> probeCap ti "rmul"
232 <*> probeCap ti "rev"
236 <*> probeCap ti "rev"
@@ -434,6 +438,7 @@ data DisplayAttrSeq
434data DisplayAttrState = DisplayAttrState
438data DisplayAttrState = DisplayAttrState
435 { applyStandout :: Bool
439 { applyStandout :: Bool
436 , applyUnderline :: Bool
440 , applyUnderline :: Bool
441+ , applyItalic :: Bool
437 , applyReverseVideo :: Bool
442 , applyReverseVideo :: Bool
438 , applyBlink :: Bool
443 , applyBlink :: Bool
439 , applyDim :: Bool
444 , applyDim :: Bool
@@ -444,6 +449,7 @@ sgrArgsForState :: DisplayAttrState -> [CapParam]
444sgrArgsForState attrState = map (\b -> if b then 1 else 0)
449sgrArgsForState attrState = map (\b -> if b then 1 else 0)
445 [ applyStandout attrState
450 [ applyStandout attrState
446 , applyUnderline attrState
451 , applyUnderline attrState
452+ , applyItalic attrState
447 , applyReverseVideo attrState
453 , applyReverseVideo attrState
448 , applyBlink attrState
454 , applyBlink attrState
449 , applyDim attrState
455 , applyDim attrState
@@ -470,6 +476,8 @@ reqDisplayCapSeqFor caps s diffs
470 -- set state cap then just use the set state cap.
476 -- set state cap then just use the set state cap.
471 ( True, True ) -> SetState $ stateForStyle s
477 ( True, True ) -> SetState $ stateForStyle s
472 where
478 where
479+ noEnterExitCap ApplyItalic = isNothing $ enterItalic caps
480+ noEnterExitCap RemoveItalic = isNothing $ exitItalic caps
473 noEnterExitCap ApplyStandout = isNothing $ enterStandout caps
481 noEnterExitCap ApplyStandout = isNothing $ enterStandout caps
474 noEnterExitCap RemoveStandout = isNothing $ exitStandout caps
482 noEnterExitCap RemoveStandout = isNothing $ exitStandout caps
475 noEnterExitCap ApplyUnderline = isNothing $ enterUnderline caps
483 noEnterExitCap ApplyUnderline = isNothing $ enterUnderline caps
@@ -482,6 +490,8 @@ reqDisplayCapSeqFor caps s diffs
482 noEnterExitCap RemoveDim = True
490 noEnterExitCap RemoveDim = True
483 noEnterExitCap ApplyBold = isNothing $ enterBoldMode caps
491 noEnterExitCap ApplyBold = isNothing $ enterBoldMode caps
484 noEnterExitCap RemoveBold = True
492 noEnterExitCap RemoveBold = True
493+ enterExitCap ApplyItalic = fromJust $ enterItalic caps
494+ enterExitCap RemoveItalic = fromJust $ exitItalic caps
485 enterExitCap ApplyStandout = fromJust $ enterStandout caps
495 enterExitCap ApplyStandout = fromJust $ enterStandout caps
486 enterExitCap RemoveStandout = fromJust $ exitStandout caps
496 enterExitCap RemoveStandout = fromJust $ exitStandout caps
487 enterExitCap ApplyUnderline = fromJust $ enterUnderline caps
497 enterExitCap ApplyUnderline = fromJust $ enterUnderline caps
@@ -495,6 +505,7 @@ stateForStyle :: Style -> DisplayAttrState
495stateForStyle s = DisplayAttrState
505stateForStyle s = DisplayAttrState
496 { applyStandout = isStyleSet standout
506 { applyStandout = isStyleSet standout
497 , applyUnderline = isStyleSet underline
507 , applyUnderline = isStyleSet underline
508+ , applyItalic = isStyleSet italic
498 , applyReverseVideo = isStyleSet reverseVideo
509 , applyReverseVideo = isStyleSet reverseVideo
499 , applyBlink = isStyleSet blink
510 , applyBlink = isStyleSet blink
500 , applyDim = isStyleSet dim
511 , applyDim = isStyleSet dim
@@ -506,6 +517,7 @@ styleToApplySeq :: Style -> [StyleStateChange]
506styleToApplySeq s = concat
517styleToApplySeq s = concat
507 [ applyIfRequired ApplyStandout standout
518 [ applyIfRequired ApplyStandout standout
508 , applyIfRequired ApplyUnderline underline
519 , applyIfRequired ApplyUnderline underline
520+ , applyIfRequired ApplyItalic italic
509 , applyIfRequired ApplyReverseVideo reverseVideo
521 , applyIfRequired ApplyReverseVideo reverseVideo
510 , applyIfRequired ApplyBlink blink
522 , applyIfRequired ApplyBlink blink
511 , applyIfRequired ApplyDim dim
523 , applyIfRequired ApplyDim dim