Documentation

TermColor.Layout.Basic

TermColor.Layout.Basic: pure styled-text layout #

These operations preserve segment styles and never emit ANSI escapes. Rendering remains the responsibility of TermColor.Text.render.

Default fallback for layout that has no terminal width yet.

Equations
Instances For
    • left : Alignment

      Align content against the left edge.

    • right : Alignment

      Align content against the right edge.

    • center : Alignment

      Center content within the available width.

    Instances For
      @[instance_reducible]
      Equations
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Split a Text into logical lines on '\n', preserving each segment's style.

        The counterpart to joinLines. Callers laying out their own multi-line cells need this to indent or pad continuation lines: columns aligns every column to its width, so a caller that wants no trailing padding on the last column has to split and rejoin itself.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Join logical lines with newline separators.

          Equations
          Instances For
            def TermColor.Layout.padRight (target : Nat) (text : Text) :

            Pad every logical line on the right to target columns.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              def TermColor.Layout.padLeft (target : Nat) (text : Text) :

              Pad every logical line on the left to target columns.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def TermColor.Layout.align (target : Nat) (alignment : Alignment) (text : Text) :

                Align every logical line to target columns.

                Equations
                Instances For
                  def TermColor.Layout.truncate (limit : Nat) (text : Text) :

                  Keep at most limit display columns on each logical line.

                  Equations
                  Instances For
                    def TermColor.Layout.wrapLines (limit : Nat) (text : Text) :

                    Wrap every logical line to at most limit display columns. A wide first character may occupy two columns when limit is one, since splitting a character is impossible.

                    Equations
                    Instances For
                      def TermColor.Layout.wrapWords (limit : Nat) (text : Text) :

                      Wrap every logical line to at most limit display columns, breaking at spaces where possible. A word wider than limit is split like wrapLines; spaces at a break are dropped.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        def TermColor.Layout.gutter (marker : Text) (indent width : Nat) (body : Text) :

                        Wrap body to width, prefixing its first line with marker and continuations with spaces.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def TermColor.Layout.columns (widths : List Nat) (gap : Nat) (cells : List Text) (alignments : List Alignment := []) (separator : Text := Text.empty) :

                          Lay out one row of styled cells as fixed-width columns. Cells wrap before alignment.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For

                            Characters used to draw a box.

                            • topLeft : Char

                              Top-left corner.

                            • topRight : Char

                              Top-right corner.

                            • bottomLeft : Char

                              Bottom-left corner.

                            • bottomRight : Char

                              Bottom-right corner.

                            • horizontal : Char

                              Horizontal border character.

                            • vertical : Char

                              Vertical border character.

                            Instances For
                              Equations
                              Instances For
                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    ASCII characters for terminals without Unicode box drawing.

                                    Equations
                                    Instances For

                                      Configuration for box. maxWidth is the outer width, including borders and padding.

                                      • chars : BoxChars

                                        Characters used for the border.

                                      • borderStyle : Style

                                        Style applied to border characters.

                                      • padding : Nat

                                        Number of spaces between the border and content.

                                      • title : Option Text

                                        Optional one-line title in the top border.

                                      • titleAlignment : Alignment

                                        Horizontal alignment of the title.

                                      • maxWidth : Option Nat

                                        Maximum outer width, including borders and padding.

                                      Instances For
                                        Equations
                                        Instances For
                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For

                                              The content width left inside a box with the given outer width.

                                              Equations
                                              Instances For
                                                def TermColor.Layout.box (content : Text) (config : BoxConfig := { }) :

                                                Draw a pure text box around styled content. maxWidth limits the outer width when supplied.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For