commandbox.system.util

Class Print

lucee.Component
    extended by commandbox.system.util.Print
Direct Known Subclasses:
PrintBuffer

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I am a helper object for creating pretty ANSI-formmatted text in the shell. I use onMissingMethod to allow for nice, readable methods that contain combinations of text and background colors as well as text formatting. Ex. print.Line() print.text( 'Hello World' ); print.boldText( 'Hello World' ); print.line( 'Hello World' ); print.redLine( 'Hello World' ); print.redOnWhiteLine( 'Hello World' ); print.redOnWhiteBold( 'Hello World' ); print.boldBlinkingUnderscoredBlueTextOnRedBackground( 'Test' ); If you want to modify formatting at runtime, pass a second parameter of additional text that will be appended to the method name upon processing. print.text( 'Hello World', 'blue' ); print.text( 'Hello World', statusColor ); print.text( 'Hello World', ( status == 'running' ? 'green' : 'red' ) ); Indent each carridge return with two spaces like so: print.indentedLine( 'Hello World' );

Class Attributes:
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano, Denny Valliant
  •  
    Property Summary
    type property default serializable required
    any JSONService


    • access = public
    • returntype = any
    • inject = JSONService
    true false
    any colors256Data


    • access = public
    • returntype = any
    • inject = colors256Data@constants
    true false
    any cr


    • access = public
    • returntype = any
    • inject = cr@constants
    true false
    any formatterUtil


    • access = public
    • returntype = any
    • inject = formatter
    true false
    any shell


    • access = public
    • returntype = any
    • inject = shell
    true false
    Method Summary
    private string get256Color(any id, [any foreground='true'])
         Get an 256 color ANSI.
    private string getANSIAttribute(any attribute)
         Get an ANSI Attribute.
    private string indent([any text])
         Pad all lines with 2 spaces.
    any onMissingMethod([any missingMethodName], [any missingMethodArguments])
         This allows you concatenate pretty method names to describe the kind of text you want to generate.
    any unansi(any ansiString)
         Removes ANSI attributes from string.
     
    Methods inherited from class lucee.Component
    None

    Property Detail

    JSONService

    property any JSONService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - JSONService
    serializable - true

    colors256Data

    property any colors256Data

    Attributes:
    access - public
    required - false
    returntype - any
    inject - colors256Data@constants
    serializable - true

    cr

    property any cr

    Attributes:
    access - public
    required - false
    returntype - any
    inject - cr@constants
    serializable - true

    formatterUtil

    property any formatterUtil

    Attributes:
    access - public
    required - false
    returntype - any
    inject - formatter
    serializable - true

    shell

    property any shell

    Attributes:
    access - public
    required - false
    returntype - any
    inject - shell
    serializable - true

    Method Detail

    get256Color

    private string get256Color(any id, [any foreground='true'])

    Get an 256 color ANSI

    Parameters:
    id
    foreground

    getANSIAttribute

    private string getANSIAttribute(any attribute)

    Get an ANSI Attribute

    Parameters:
    attribute

    indent

    private string indent([any text])

    Pad all lines with 2 spaces

    Parameters:
    text

    onMissingMethod

    public any onMissingMethod([any missingMethodName], [any missingMethodArguments])

    This allows you concatenate pretty method names to describe the kind of text you want to generate If the method name contains "line", it will be appended with a carriage return Any other token in the name that exists in the list of ANSI attributes above will be picked up and applied to the text

    Parameters:
    missingMethodName
    missingMethodArguments

    unansi

    public any unansi(any ansiString)

    Removes ANSI attributes from string

    Parameters:
    ansiString