package string
String- and text-related classes.
- Alphabetic
 - By Inheritance
 
- string
 - AnyRef
 - Any
 
- Hide All
 - Show All
 
- Public
 - All
 
Type Members
- 
      
      
      
        
      
    
      
        final 
        case class
      
      
        WordWrapper(wrapWidth: Int = 79, indentation: Int = 0, prefix: String = "", ignore: Set[Char] = Set.empty[Char], indentChar: Char = ' ') extends Product with Serializable
      
      
      
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
WordWrapperabout 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 directoryAlternatively, 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 directoryNote 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
WordWrapperobject 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.