cc.strings

Various utilities for working with strings and text.

See also

wrap(text [, width])Wraps a block of text, so that each line fits within the given width.
ensure_width(line [, width])Makes the input string a fixed width.
wrap(text [, width])Source

Wraps a block of text, so that each line fits within the given width.

This may be useful if you want to wrap text before displaying it to a monitor or printer without using print.

Parameters

  1. text string The string to wrap.
  2. width? number The width to constrain to, defaults to the width of the terminal.

Returns

  1. { string... } The wrapped input string as a list of lines.

Usage

ensure_width(line [, width])Source

Makes the input string a fixed width. This either truncates it, or pads it with spaces.

Parameters

  1. line string The string to normalise.
  2. width? number The width to constrain to, defaults to the width of the terminal.

Returns

  1. string The string with a specific width.

Usage