0 | module Protocol.IDE.Formatting
3 | import Protocol.IDE.Decoration
10 | data Formatting : Type where
13 | Underline : Formatting
16 | Show Formatting where
18 | show Italic = "italic"
19 | show Underline = "underline"
22 | SExpable Formatting where
23 | toSExp format = SExpList [ SymbolAtom "text-formatting"
24 | , SymbolAtom (show format)
30 | display : Formatting -> String
31 | display Bold = "bold"
32 | display Italic = "italic"
33 | display Underline = "underline"
37 | FromSExpable Formatting where
38 | fromSExp (SExpList [ SymbolAtom "text-formatting"
43 | "italic" => Just Italic
44 | "underline" => Just Underline
46 | fromSExp _ = Nothing
53 | record Properties where
54 | constructor MkProperties
55 | decor : Maybe Decoration
56 | format : Maybe Formatting
59 | mkDecor : Decoration -> Properties
60 | mkDecor dec = MkProperties (Just dec) Nothing
63 | mkFormat : Formatting -> Properties
64 | mkFormat = MkProperties Nothing . Just
67 | SExpable Properties where
68 | toSExp (MkProperties dec form) = SExpList $
catMaybes
74 | FromSExpable Properties where
75 | fromSExp (SExpList props) =
77 | [] => Just $
MkProperties {decor = Nothing, format = Nothing}
79 | let Nothing = fromSExp prop
80 | | Just decor => Just $
mkDecor decor
81 | format <- fromSExp prop
82 | pure $
mkFormat format
85 | do let format = Just !(fromSExp prop1)
86 | let decor = Just !(fromSExp prop2)
87 | pure $
MkProperties {format, decor}
89 | fromSExp _ = Nothing