View Source Kino.Text (Kino v0.13.1)
A kino for rendering text content.
For rich text, use Kino.Markdown
.
Examples
Kino.Text.new("Hello!")
[:green, "Hello!"]
|> IO.ANSI.format()
|> IO.iodata_to_binary()
|> Kino.Text.new(terminal: true)
Summary
Functions
Creates a new kino displaying the given text content.
Types
@opaque t()
Functions
Creates a new kino displaying the given text content.
Options
:terminal
- whether to render the text as if it were printed to standard output, supporting ANSI escape codes. Defaults tofalse
:chunk
- whether this is a part of a larger text. Adjacent chunks are merged into a single text. This is useful for streaming content. Defaults tofalse
Examples
Using the :chunk
option
Using a Kino.Frame
.
frame = Kino.Frame.new() |> Kino.render()
for word <- ["who", " let", " the", " dogs", " out"] do
text = Kino.Text.new(word, chunk: true)
Kino.Frame.append(frame, text)
Process.sleep(250)
end
Without using a Kino.Frame
.
for word <- ["who", " let", " the", " dogs", " out"] do
Kino.Text.new(word, chunk: true) |> Kino.render()
Process.sleep(250)
end
Kino.nothing()