Copyright | (C) 2011-2015 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
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
- rendered :: Source s => Delta -> s -> Rendering
- class Renderable t where
- data Rendered a = a :@ Rendering
- data Caret = Caret !Delta !ByteString
- class HasCaret t where
- 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
- data Spanned a = a :~ Span
- spanEffects :: [SGR]
- drawSpan :: Delta -> Delta -> Delta -> Lines -> Lines
- addSpan :: Delta -> Delta -> Rendering -> Rendering
- data Fixit = Fixit {}
- 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
A Rendering
is a canvas of text that output can be written to.
Instances
class HasRendering c where Source #
Minimal complete definition
Methods
rendering :: Lens' c Rendering Source #
renderingDelta :: Lens' c Delta Source #
renderingLine :: Lens' c (Lines -> Lines) Source #
renderingLineBytes :: Lens' c Int64 Source #
renderingLineLen :: Lens' c Int64 Source #
renderingOverlays :: Lens' c (Delta -> Lines -> Lines) Source #
Instances
HasRendering Rendering Source # | |
Defined in Text.Trifecta.Rendering Methods rendering :: Lens' Rendering Rendering Source # renderingDelta :: Lens' Rendering Delta Source # renderingLine :: Lens' Rendering (Lines -> Lines) Source # renderingLineBytes :: Lens' Rendering Int64 Source # renderingLineLen :: Lens' Rendering Int64 Source # renderingOverlays :: Lens' Rendering (Delta -> Lines -> Lines) Source # |
nullRendering :: Rendering -> Bool Source #
Is the Rendering
empty?
>>>
nullRendering emptyRendering
True
>>>
nullRendering exampleRendering
False
emptyRendering :: Rendering Source #
The empty Rendering
, which contains nothing at all.
>>>
show (pretty emptyRendering)
""
class Renderable t where Source #
Instances
Instances
Carets
A Caret
marks a point in the input with a simple ^
character.
>>>
plain (pretty (addCaret (Columns 35 35) exampleRendering))
int main(int argc, char ** argv) { int; }<EOF> ^
Constructors
Caret !Delta !ByteString |
Instances
Instances
addCaret :: Delta -> Rendering -> Rendering Source #
Render a caret at a certain position in a Rendering
.
caretEffects :: [SGR] Source #
ANSI terminal style for rendering the caret.
renderingCaret :: Delta -> ByteString -> Rendering Source #
Spans
A Span
marks a range of input characters. If Caret
is a point, then
Span
is a line.
>>>
plain (pretty (addSpan (Columns 35 35) (Columns 38 38) exampleRendering))
int main(int argc, char ** argv) { int; }<EOF> ~~~
Constructors
Span !Delta !Delta !ByteString |
Instances
Annotate an arbitrary piece of data with a Span
, typically its
corresponding input location.
Instances
spanEffects :: [SGR] Source #
ANSI terminal style to render spans with.
Fixits
A Fixit
is a Span
with a suggestion.
>>>
plain (pretty (addFixit (Columns 35 35) (Columns 38 38) "Fix this!" exampleRendering))
int main(int argc, char ** argv) { int; }<EOF> ~~~ Fix this!
Constructors
Fixit | |
Fields
|
Instances
Eq Fixit Source # | |
Data Fixit Source # | |
Defined in Text.Trifecta.Rendering Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Fixit -> c Fixit Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Fixit Source # toConstr :: Fixit -> Constr Source # dataTypeOf :: Fixit -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Fixit) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Fixit) Source # gmapT :: (forall b. Data b => b -> b) -> Fixit -> Fixit Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Fixit -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Fixit -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Fixit -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Fixit -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Fixit -> m Fixit Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixit -> m Fixit Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixit -> m Fixit Source # | |
Ord Fixit Source # | |
Defined in Text.Trifecta.Rendering | |
Show Fixit Source # | |
Generic Fixit Source # | |
Hashable Fixit Source # | |
HasSpan Fixit Source # | |
Renderable Fixit Source # | |
HasFixit Fixit Source # | |
Reducer Fixit Rendering Source # | |
type Rep Fixit Source # | |
Defined in Text.Trifecta.Rendering type Rep Fixit = D1 (MetaData "Fixit" "Text.Trifecta.Rendering" "trifecta-2-8v9C3J3NjDs1PDjup8XfD" False) (C1 (MetaCons "Fixit" PrefixI True) (S1 (MetaSel (Just "_fixitSpan") SourceUnpack SourceStrict DecidedStrict) (Rec0 Span) :*: S1 (MetaSel (Just "_fixitReplacement") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ByteString))) |
class HasFixit c where Source #
Minimal complete definition
Drawing primitives
type Lines = Array (Int, Int64) ([SGR], Char) Source #
A raw canvas to paint ANSI-styled characters on.