Module ftext

fText processing

Info:

  • Copyright: 2020 Damian Monogue
  • License: MIT, see LICENSE.lua
  • Author: Damian Monogue

Functions

wordWrap(str, limit) Performs wordwrapping on a string, given a length limit.
xwrap(text, limit, type) Performs wordwrapping on a string, while ignoring color tags of a given type.
fText(str, opts) The main course, this function returns a formatted string, based on a table of options


Functions

wordWrap(str, limit)
Performs wordwrapping on a string, given a length limit. Does not understand colour tags and will count them as characters in the string

Parameters:

  • str string the string to wordwrap
  • limit number the line length to wrap at
xwrap(text, limit, type)
Performs wordwrapping on a string, while ignoring color tags of a given type.

Parameters:

  • text string the string you are wordwrapping
  • limit number the line length to wrap at
  • type string What type of color codes to ignore. 'c' for cecho, 'd' for decho, 'h' for hecho, and anything else or nil to pass the string on to wordWrap
fText(str, opts)
The main course, this function returns a formatted string, based on a table of options

Parameters:

  • str string the string to format
  • opts table the table of options which control the formatting

    Table of options
    option name description default
    wrap Should it wordwrap to multiple lines? true
    formatType Determines how it formats for color. 'c' for cecho, 'd' for decho, 'h' for hecho, and anything else for no colors ""
    width How wide should we format the text? 80
    cap what characters to use for the endcap. ""
    capColor what color to make the endcap? the correct 'white' for your formatType
    spacer What character to use for empty space. Must be a single character " "
    spacerColor what color should the spacer be? the correct 'white' for your formatType
    textColor what color should the text itself be? the correct 'white' for your formatType
    alignment How should the text be aligned within the width. "center", "left", or "right" "center"
    nogap Should we put a literal space between the spacer character and the text? false
    inside Put the spacers inside the caps? false
    mirror Should the endcap be reversed on the right? IE [[ becomes ]] true
generated by LDoc 1.4.6 Last updated 2020-08-25 15:14:20