Package edu.cornell.cs.apl.prettyprinting

Types

AnsiBaseColor
Link copied to clipboard
enum AnsiBaseColor : Enum<AnsiBaseColor>

One of the 8 basic colors supported by the ANSI standard.

AnsiColor
Link copied to clipboard
sealed class AnsiColor
BrightColor
Link copied to clipboard
data class BrightColor(baseColor: AnsiBaseColor) : AnsiColor

Bright variant of baseColor.

DefaultColor
Link copied to clipboard
object DefaultColor : AnsiColor

The default foreground or background color.

DefaultStyle
Link copied to clipboard
object DefaultStyle : Style

The default Style.

Document
Link copied to clipboard
sealed class Document : PrettyPrintable

Represents a pretty printed document.

NormalColor
Link copied to clipboard
data class NormalColor(baseColor: AnsiBaseColor) : AnsiColor

Normal variant of baseColor.

PrettyPrintable
Link copied to clipboard
interface PrettyPrintable

An object that has a pretty text representation.

Style
Link copied to clipboard
interface Style

A style describing how text should be printed on an ANSI terminal.

Functions

braced
Link copied to clipboard
fun List<PrettyPrintable>.braced(): Document

Like joined but using commas as separators and enclosed in curly braces.

bracketed
Link copied to clipboard
fun List<PrettyPrintable>.bracketed(): Document

Like joined but using commas as separators and enclosed in square brackets.

commented
Link copied to clipboard
fun PrettyPrintable.commented(): Document

Like joined but using commas as separators and enclosed in /* and */.

concatenated
Link copied to clipboard
fun List<PrettyPrintable>.concatenated(separator: PrettyPrintable = Document()): Document

Concatenates all the elements together with separators in between.

div
Link copied to clipboard
operator fun PrettyPrintable.div(other: PrettyPrintable): Document

Concatenates this and other with a line break in between.

operator fun PrettyPrintable.div(other: String): Document

Convenience method. See plus.

grouped
Link copied to clipboard
fun PrettyPrintable.grouped(): Document

Tries laying out this document into a single line by removing the contained Document.lineBreaks (and replacing them with spaces); if this does not fit the page, the document is laid out without any changes. This function is the key to layouts that adapt to available space nicely.

joined
Link copied to clipboard
fun List<PrettyPrintable>.joined(separator: PrettyPrintable = Document(","), prefix: PrettyPrintable = Document(), postfix: PrettyPrintable = Document()): Document

Concatenates all the elements separated by separator and enclosed in prefix and postfix.

nested
Link copied to clipboard
fun PrettyPrintable.nested(indentationChange: Int = 4): Document

Returns a new document that is this with the nesting level (indentation after newlines) increased by indentationChange. Negative values for indentationChange are allowed, and decrease the nesting level accordingly.

plus
Link copied to clipboard
operator fun PrettyPrintable.plus(other: PrettyPrintable): Document

Concatenates this and other.

operator fun PrettyPrintable.plus(other: String): Document

Convenience method that automatically converts other to a Document.

styled
Link copied to clipboard
fun PrettyPrintable.styled(style: Style): Document

Returns a new document that is this with style applied.

times
Link copied to clipboard
operator fun PrettyPrintable.times(other: PrettyPrintable): Document

Concatenates this and other with a space in between.

operator fun PrettyPrintable.times(other: String): Document

Convenience method. See plus.

tupled
Link copied to clipboard
fun List<PrettyPrintable>.tupled(): Document

Like joined but using commas as separators and enclosed in parentheses.

Properties

DEFAULT_LINE_WIDTH
Link copied to clipboard
const val DEFAULT_LINE_WIDTH: Int = 80

The maximum number of characters to put on one line.