hslua-module-doclayout-0.1.0: Lua module wrapping Text.DocLayout.

Copyright© 2020 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <albert+hslua@zeitkraut.de>
Stabilityalpha
PortabilityRequires GHC 8 or later.
Safe HaskellNone
LanguageHaskell2010

Foreign.Lua.Module.DocLayout

Contents

Description

Provides a Lua module which wraps DocLayout. The Doc' type is specialized to Text@.

This module defines orphan instances for Doc Text.

Synopsis

Module

pushModule :: Lua NumResults Source #

Pushes the doclayout module to the Lua stack.

preloadModule :: String -> Lua () Source #

Add the doclayout module under the given name to the table of preloaded packages.

Doc constructors and combinators

after_break :: Text -> Lua (Doc Text) Source #

Creates a Doc which is conditionally included only if it comes at the beginning of a line.

before_non_blank :: Doc Text -> Lua (Doc Text) Source #

Conditionally includes the given Doc unless it is followed by a blank space.

blankline :: Doc Text Source #

Inserts a blank line unless one exists already.

blanklines :: Int -> Lua (Doc Text) Source #

Insert blank lines unless they exist already.

braces :: Doc Text -> Lua (Doc Text) Source #

Puts a Doc in curly braces.

brackets :: Doc Text -> Lua (Doc Text) Source #

Puts a Doc in square brackets.

cblock :: Int -> Doc Text -> Lua (Doc Text) Source #

Like lblock but aligned centered.

chomp :: Doc Text -> Lua (Doc Text) Source #

Chomps trailing blank space off of a Doc.

concat :: [Doc Text] -> Optional (Doc Text) -> Lua (Doc Text) Source #

Concatenates a list of Docs.

cr :: Doc Text Source #

A carriage return. Does nothing if we're at the beginning of a line; otherwise inserts a newline.

double_quotes :: Doc Text -> Lua (Doc Text) Source #

Wraps a Doc in double quotes

empty :: Doc Text Source #

The empty document.

flush :: Doc Text -> Lua (Doc Text) Source #

Makes a Doc flush against the left margin.

hang :: Int -> Doc Text -> Doc Text -> Lua (Doc Text) Source #

Creates a hanging indent.

inside :: Doc Text -> Doc Text -> Doc Text -> Lua (Doc Text) Source #

Encloses a Doc inside a start and end Doc.

lblock :: Int -> Doc Text -> Lua (Doc Text) Source #

Creates a block with the given width and content, aligned to the left.

literal :: Text -> Lua (Doc Text) Source #

Creates a Doc from a string.

nest :: Int -> Doc Text -> Lua (Doc Text) Source #

Indents a Doc by the specified number of spaces.

nestle :: Doc Text -> Lua (Doc Text) Source #

Removes leading blank lines from a Doc.

nowrap :: Doc Text -> Lua (Doc Text) Source #

Makes a Doc non-reflowable.

parens :: Doc Text -> Lua (Doc Text) Source #

Puts a Doc in parentheses.

prefixed :: Text -> Doc Text -> Lua (Doc Text) Source #

Uses the specified string as a prefix for every line of the inside document (except the first, if not at the beginning of the line).

quotes :: Doc Text -> Lua (Doc Text) Source #

Wraps a Doc in single quotes.

rblock :: Int -> Doc Text -> Lua (Doc Text) Source #

Like lblock but aligned to the right.

space :: Doc Text Source #

A breaking (reflowable) space.

Rendering

render :: Doc Text -> Optional Int -> Lua Text Source #

Render a Doc. The text is reflowed on breakable spaces to match the given line length. Text is not reflowed if the line length parameter is omitted or nil.

Document Querying

is_empty :: Doc Text -> Lua Bool Source #

True iff the document is empty.

height :: Doc Text -> Lua Int Source #

Returns the height of a block or other Doc.

min_offset :: Doc Text -> Lua Int Source #

Returns the minimal width of a Doc when reflowed at breakable spaces.

offset :: Doc Text -> Lua Int Source #

Returns the width of a Doc.

real_length :: Text -> Lua Int Source #

Returns the real length of a string in a monospace font: 0 for a combining character, 1, for a regular character, 2 for an East Asian wide character.

update_column :: Doc Text -> Int -> Lua Int Source #

Returns the column that would be occupied by the last laid out character.

Marshaling

peekDoc :: StackIndex -> Lua (Doc Text) Source #

Retrieve a Doc Text value from the Lua stack. Strings are converted to plain Doc values.

pushDoc :: Doc Text -> Lua () Source #

Push a Doc Text value to the Lua stack.

Orphan instances

Peekable (Doc Text) Source # 
Instance details

Methods

peek :: StackIndex -> Lua (Doc Text) #

Pushable (Doc Text) Source # 
Instance details

Methods

push :: Doc Text -> Lua () #