Text.Trifecta.Rendering

trifecta-1.5.2: A modern parser combinator library with convenient diagnostics

Copyright | (C) 2011-2014 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | non-portable
Safe Haskell | None
Language | Haskell2010

Text.Trifecta.Rendering

Contents

- Carets
- Spans
- Fixits
- Drawing primitives

Description

The type for Lines will very likely change over time, to enable drawing lit up multi-character versions of control characters for `^Z`, `^[`, `0xff`, etc. This will make for much nicer diagnostics when working with protocols.

Synopsis

- data Rendering = Rendering !Delta !Int64 !Int64 (Lines -> Lines) (Delta -> Lines -> Lines)
- class HasRendering c where
  - rendering :: Lens' c Rendering
  - renderingDelta :: Lens' c Delta
  - renderingLine :: Lens' c (Lines -> Lines)
  - renderingLineBytes :: Lens' c Int64
  - renderingLineLen :: Lens' c Int64
  - renderingOverlays :: Lens' c (Delta -> Lines -> Lines)
- nullRendering :: Rendering -> Bool
- emptyRendering :: Rendering
- class Source t where
  - source :: t -> (Int64, Int64, Lines -> Lines)
- rendered :: Source s => Delta -> s -> Rendering
- class Renderable t where
  - render :: t -> Rendering
- data Rendered a = a :@ Rendering
- data Caret = Caret !Delta !ByteString
- class HasCaret t where
  - caret :: Lens' t Caret
- data Careted a = a :^ Caret
- drawCaret :: Delta -> Delta -> Lines -> Lines
- addCaret :: Delta -> Rendering -> Rendering
- caretEffects :: [SGR]
- renderingCaret :: Delta -> ByteString -> Rendering
- data Span = Span !Delta !Delta !ByteString
- class HasSpan t where
  - span :: Lens' t Span
- data Spanned a = a :~ Span
- spanEffects :: [SGR]
- drawSpan :: Delta -> Delta -> Delta -> Lines -> Lines
- addSpan :: Delta -> Delta -> Rendering -> Rendering
- data Fixit = Fixit {
  - _fixitSpan :: !Span
  - _fixitReplacement :: !ByteString
  }
- class HasFixit c where
  - fixit :: Lens' c Fixit
  - fixitReplacement :: Lens' c ByteString
  - fixitSpan :: Lens' c Span
- drawFixit :: Delta -> Delta -> String -> Delta -> Lines -> Lines
- addFixit :: Delta -> Delta -> String -> Rendering -> Rendering
- type Lines = Array (Int, Int64) ([SGR], Char)
- draw :: [SGR] -> Int -> Int64 -> String -> Lines -> Lines
- ifNear :: Delta -> (Lines -> Lines) -> Delta -> Lines -> Lines
- (.#) :: (Delta -> Lines -> Lines) -> Rendering -> Rendering

# Documentation

data Rendering

Constructors

Rendering !Delta !Int64 !Int64 (Lines -> Lines) (Delta -> Lines -> Lines) |

Instances

Show Rendering |
Pretty Rendering |
Monoid Rendering |
Semigroup Rendering |
HasDelta Rendering |
Renderable Rendering |
HasRendering Rendering |
Reducer Fixit Rendering |
Reducer Span Rendering |
Reducer Caret Rendering |
Reducer (Spanned a) Rendering |
Reducer (Careted a) Rendering |

class HasRendering c where

Minimal complete definition

rendering

Methods

rendering :: Lens' c Rendering

renderingDelta :: Lens' c Delta

renderingLine :: Lens' c (Lines -> Lines)

renderingLineBytes :: Lens' c Int64

renderingLineLen :: Lens' c Int64

renderingOverlays :: Lens' c (Delta -> Lines -> Lines)

Instances

HasRendering Rendering |

nullRendering :: Rendering -> Bool

emptyRendering :: Rendering

class Source t where

Methods

source :: t -> (Int64, Int64, Lines -> Lines)

Instances

Source String |
Source ByteString |

rendered :: Source s => Delta -> s -> Rendering

create a drawing surface

class Renderable t where

Methods

render :: t -> Rendering

Instances

Renderable Rendering |
Renderable Fixit |
Renderable Span |
Renderable Caret |
Renderable (Spanned a) |
Renderable (Careted a) |
Renderable (Rendered a) |

data Rendered a

Constructors

a :@ Rendering |

Instances

Functor Rendered |
Foldable Rendered |
Traversable Rendered |
Comonad Rendered |
ComonadApply Rendered |
Show a => Show (Rendered a) |
HasDelta (Rendered a) |
HasBytes (Rendered a) |
Renderable (Rendered a) |

# Carets

data Caret

    In file included from baz.c:9
    In file included from bar.c:4
    foo.c:8:36: note
    int main(int argc, char ** argv) { int; }
                                       ^

Constructors

Caret !Delta !ByteString |

Instances

Eq Caret |
Data Caret |
Ord Caret |
Show Caret |
Generic Caret |
Hashable Caret |
Semigroup Caret |
HasDelta Caret |
HasBytes Caret |
HasCaret Caret |
Renderable Caret |
Reducer Caret Rendering |
type Rep Caret |

class HasCaret t where

Methods

caret :: Lens' t Caret

Instances

HasCaret Caret |
HasCaret (Careted a) |

data Careted a

Constructors

a :^ Caret |

Instances

Functor Careted |
Foldable Careted |
Traversable Careted |
Comonad Careted |
ComonadApply Careted |
Eq a => Eq (Careted a) |
Data a => Data (Careted a) |
Ord a => Ord (Careted a) |
Show a => Show (Careted a) |
Generic (Careted a) |
Hashable a => Hashable (Careted a) |
HasDelta (Careted a) |
HasBytes (Careted a) |
HasCaret (Careted a) |
Renderable (Careted a) |
Reducer (Careted a) Rendering |
type Rep (Careted a) |

drawCaret :: Delta -> Delta -> Lines -> Lines

addCaret :: Delta -> Rendering -> Rendering

caretEffects :: [SGR]

renderingCaret :: Delta -> ByteString -> Rendering

# Spans

data Span

Constructors

Span !Delta !Delta !ByteString |

Instances

Eq Span |
Data Span |
Ord Span |
Show Span |
Generic Span |
Hashable Span |
Semigroup Span |
HasSpan Span |
Renderable Span |
Reducer Span Rendering |
type Rep Span |

class HasSpan t where

Methods

span :: Lens' t Span

Instances

HasSpan Fixit |
HasSpan Span |
HasSpan (Spanned a) |

data Spanned a

Constructors

a :~ Span |

Instances

Functor Spanned |
Foldable Spanned |
Traversable Spanned |
Comonad Spanned |
ComonadApply Spanned |
Eq a => Eq (Spanned a) |
Data a => Data (Spanned a) |
Ord a => Ord (Spanned a) |
Show a => Show (Spanned a) |
Generic (Spanned a) |
Hashable a => Hashable (Spanned a) |
HasSpan (Spanned a) |
Renderable (Spanned a) |
Reducer (Spanned a) Rendering |
type Rep (Spanned a) |

spanEffects :: [SGR]

drawSpan :: Delta -> Delta -> Delta -> Lines -> Lines

addSpan :: Delta -> Delta -> Rendering -> Rendering

    int main(int argc, char ** argv) { int; }
                                       ^~~

# Fixits

data Fixit

Constructors

Fixit |
Fields _fixitSpan :: !Span _fixitReplacement :: !ByteString

Instances

Eq Fixit |
Data Fixit |
Ord Fixit |
Show Fixit |
Generic Fixit |
Hashable Fixit |
HasSpan Fixit |
Renderable Fixit |
HasFixit Fixit |
Reducer Fixit Rendering |
type Rep Fixit |

class HasFixit c where

Minimal complete definition

fixit

Methods

fixit :: Lens' c Fixit

fixitReplacement :: Lens' c ByteString

fixitSpan :: Lens' c Span

Instances

HasFixit Fixit |

drawFixit :: Delta -> Delta -> String -> Delta -> Lines -> Lines

addFixit :: Delta -> Delta -> String -> Rendering -> Rendering

# Drawing primitives

type Lines = Array (Int, Int64) ([SGR], Char)

draw :: [SGR] -> Int -> Int64 -> String -> Lines -> Lines

ifNear :: Delta -> (Lines -> Lines) -> Delta -> Lines -> Lines

(.#) :: (Delta -> Lines -> Lines) -> Rendering -> Rendering