Alaja.Components.Message (Alaja v2.0.0)

Copy Markdown View Source

Canonical renderer for Alaja.Structures.MessageInfo.

Returns an Alaja.Buffer.t/0 so the result can be composed with Alaja.Components.Box, Alaja.Components.Header, or any other Cell-engine component.

Why this exists

Before this component existed, Alaja.CLI.Commands.Show.Message flattened the MessageInfo to a colored string with ANSI escapes and handed it to Components.Box.render/2. The box then measured the width with String.length/1 which counted ANSI escapes as characters, producing a box that was much wider than the visible content.

With this component in place the flow is:

MessageInfo  Components.Message.render/1  Buffer
                                          
                                 Box.render(buffer, opts)
                                          
                                     final Buffer

Both pieces know each other's width because they speak Buffer.

Options

The component honors the :align, :padding, and :add_line options carried in the MessageInfo struct itself. No additional options are read here.

Summary

Functions

Renders a MessageInfo into an Alaja.Buffer.t/0.

Functions

render(msg)

Renders a MessageInfo into an Alaja.Buffer.t/0.

Returns an empty Buffer (0x1) when given an empty chunks list.