Package

grizzled

string

Permalink

package string

String- and text-related classes.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. string
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final case class WordWrapper(wrapWidth: Int = 79, indentation: Int = 0, prefix: String = "", ignore: Set[Char] = Set.empty[Char], indentChar: Char = ' ') extends Product with Serializable

    Permalink

    Wraps strings on word boundaries to fit within a proscribed output width.

    Wraps strings on word boundaries to fit within a proscribed output width. The wrapped string may have a prefix or not; prefixes are useful for error messages, for instance. You tell a WordWrapper about a prefix by passing a non-empty prefix to the constructor.

    Examples:

    Unable to open file /usr/local/etc/wombat: No such file or directory

    might appear like this without a prefix:

    Unable to open file /usr/local/etc/wombat: No such file or
    directory

    and like this if the prefix is "myprog:"

    myprog: Unable to open file /usr/local/etc/wombat: No such
            file or directory

    Alternatively, if the output width is shortened, the same message can be made to wrap something like this:

    myprog: Unable to open file
            /usr/local/etc/wombat:
            No such file or
            directory

    Note how the wrapping logic will "tab" past the prefix on wrapped lines.

    This method also supports the notion of an indentation level, which is independent of the prefix. A non-zero indentation level causes each line, including the first line, to be indented that many characters. Thus, initializing a WordWrapper object with an indentation value of 4 will cause each output line to be preceded by 4 blanks. (It's also possible to change the indentation character from a blank to any other character.

    Notes

    - The class does not do any special processing of tab characters. Embedded tab characters can have surprising (and unwanted) effects on the rendered output. - Wrapping an already wrapped string is an invitation to trouble.

    wrapWidth

    the number of characters after which to wrap each line

    indentation

    how many characters to indent

    prefix

    the prefix to use, or "" for none. Cannot be null.

    ignore

    set of characters to ignore when calculating wrapping. This feature can be useful when certain characters represent escape characters, and you intend to post-process the wrapped string.

    indentChar

    the indentation character to use.

Value Members

  1. object Implicits

    Permalink

    String and character implicits.

  2. package template

    Permalink

    Scala classes that provide for variable substitution within strings, akin to the Python StringTemplate library.

    Scala classes that provide for variable substitution within strings, akin to the Python StringTemplate library. Several syntaxes are supported.

  3. object util

    Permalink

    Useful string-related utility functions.

Inherited from AnyRef

Inherited from Any

Ungrouped