mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-11-29 08:49:40 +03:00
Add support for italicized output when terminfo supports it
This commit is contained in:
parent
bb68f7ae05
commit
e23742907a
@ -38,6 +38,7 @@ module Graphics.Vty.Attributes
|
||||
, Style
|
||||
, withStyle
|
||||
, standout
|
||||
, italic
|
||||
, underline
|
||||
, reverseVideo
|
||||
, blink
|
||||
@ -103,14 +104,15 @@ data Attr = Attr
|
||||
-- __ - unused
|
||||
--
|
||||
-- Next is the style flags
|
||||
-- SURBDO__
|
||||
-- SURBDOI_
|
||||
-- S - standout
|
||||
-- U - underline
|
||||
-- R - reverse video
|
||||
-- B - blink
|
||||
-- D - dim
|
||||
-- O - bold
|
||||
-- __ - unused
|
||||
-- I - italic
|
||||
-- _ - unused
|
||||
--
|
||||
-- Then the foreground color encoded into 8 bits.
|
||||
-- Then the background color encoded into 8 bits.
|
||||
@ -187,15 +189,18 @@ type Style = Word8
|
||||
--
|
||||
-- * bold/bright
|
||||
--
|
||||
-- * italic
|
||||
--
|
||||
-- (The invisible, protect, and altcharset display attributes some
|
||||
-- terminals support are not supported via VTY.)
|
||||
standout, underline, reverseVideo, blink, dim, bold :: Style
|
||||
standout, underline, reverseVideo, blink, dim, bold, italic :: Style
|
||||
standout = 0x01
|
||||
underline = 0x02
|
||||
reverseVideo = 0x04
|
||||
blink = 0x08
|
||||
dim = 0x10
|
||||
bold = 0x20
|
||||
italic = 0x40
|
||||
|
||||
defaultStyleMask :: Style
|
||||
defaultStyleMask = 0x00
|
||||
|
@ -94,6 +94,8 @@ data DisplayColorDiff
|
||||
data StyleStateChange
|
||||
= ApplyStandout
|
||||
| RemoveStandout
|
||||
| ApplyItalic
|
||||
| RemoveItalic
|
||||
| ApplyUnderline
|
||||
| RemoveUnderline
|
||||
| ApplyReverseVideo
|
||||
@ -141,6 +143,7 @@ diffStyles prev cur
|
||||
= mconcat
|
||||
[ styleDiff standout ApplyStandout RemoveStandout
|
||||
, styleDiff underline ApplyUnderline RemoveUnderline
|
||||
, styleDiff italic ApplyItalic RemoveItalic
|
||||
, styleDiff reverseVideo ApplyReverseVideo RemoveReverseVideo
|
||||
, styleDiff blink ApplyBlink RemoveBlink
|
||||
, styleDiff dim ApplyDim RemoveDim
|
||||
|
@ -62,6 +62,8 @@ data DisplayAttrCaps = DisplayAttrCaps
|
||||
{ setAttrStates :: Maybe CapExpression
|
||||
, enterStandout :: Maybe CapExpression
|
||||
, exitStandout :: Maybe CapExpression
|
||||
, enterItalic :: Maybe CapExpression
|
||||
, exitItalic :: Maybe CapExpression
|
||||
, enterUnderline :: Maybe CapExpression
|
||||
, exitUnderline :: Maybe CapExpression
|
||||
, enterReverseVideo :: Maybe CapExpression
|
||||
@ -227,6 +229,8 @@ currentDisplayAttrCaps ti
|
||||
<*> probeCap ti "sgr"
|
||||
<*> probeCap ti "smso"
|
||||
<*> probeCap ti "rmso"
|
||||
<*> probeCap ti "sitm"
|
||||
<*> probeCap ti "ritm"
|
||||
<*> probeCap ti "smul"
|
||||
<*> probeCap ti "rmul"
|
||||
<*> probeCap ti "rev"
|
||||
@ -434,6 +438,7 @@ data DisplayAttrSeq
|
||||
data DisplayAttrState = DisplayAttrState
|
||||
{ applyStandout :: Bool
|
||||
, applyUnderline :: Bool
|
||||
, applyItalic :: Bool
|
||||
, applyReverseVideo :: Bool
|
||||
, applyBlink :: Bool
|
||||
, applyDim :: Bool
|
||||
@ -444,6 +449,7 @@ sgrArgsForState :: DisplayAttrState -> [CapParam]
|
||||
sgrArgsForState attrState = map (\b -> if b then 1 else 0)
|
||||
[ applyStandout attrState
|
||||
, applyUnderline attrState
|
||||
, applyItalic attrState
|
||||
, applyReverseVideo attrState
|
||||
, applyBlink attrState
|
||||
, applyDim attrState
|
||||
@ -470,6 +476,8 @@ reqDisplayCapSeqFor caps s diffs
|
||||
-- set state cap then just use the set state cap.
|
||||
( True, True ) -> SetState $ stateForStyle s
|
||||
where
|
||||
noEnterExitCap ApplyItalic = isNothing $ enterItalic caps
|
||||
noEnterExitCap RemoveItalic = isNothing $ exitItalic caps
|
||||
noEnterExitCap ApplyStandout = isNothing $ enterStandout caps
|
||||
noEnterExitCap RemoveStandout = isNothing $ exitStandout caps
|
||||
noEnterExitCap ApplyUnderline = isNothing $ enterUnderline caps
|
||||
@ -482,6 +490,8 @@ reqDisplayCapSeqFor caps s diffs
|
||||
noEnterExitCap RemoveDim = True
|
||||
noEnterExitCap ApplyBold = isNothing $ enterBoldMode caps
|
||||
noEnterExitCap RemoveBold = True
|
||||
enterExitCap ApplyItalic = fromJust $ enterItalic caps
|
||||
enterExitCap RemoveItalic = fromJust $ exitItalic caps
|
||||
enterExitCap ApplyStandout = fromJust $ enterStandout caps
|
||||
enterExitCap RemoveStandout = fromJust $ exitStandout caps
|
||||
enterExitCap ApplyUnderline = fromJust $ enterUnderline caps
|
||||
@ -495,6 +505,7 @@ stateForStyle :: Style -> DisplayAttrState
|
||||
stateForStyle s = DisplayAttrState
|
||||
{ applyStandout = isStyleSet standout
|
||||
, applyUnderline = isStyleSet underline
|
||||
, applyItalic = isStyleSet italic
|
||||
, applyReverseVideo = isStyleSet reverseVideo
|
||||
, applyBlink = isStyleSet blink
|
||||
, applyDim = isStyleSet dim
|
||||
@ -506,6 +517,7 @@ styleToApplySeq :: Style -> [StyleStateChange]
|
||||
styleToApplySeq s = concat
|
||||
[ applyIfRequired ApplyStandout standout
|
||||
, applyIfRequired ApplyUnderline underline
|
||||
, applyIfRequired ApplyItalic italic
|
||||
, applyIfRequired ApplyReverseVideo reverseVideo
|
||||
, applyIfRequired ApplyBlink blink
|
||||
, applyIfRequired ApplyDim dim
|
||||
|
Loading…
Reference in New Issue
Block a user