commandbox.system.util.jline

Class ArgumentList

lucee.Component
    extended by commandbox.system.util.jline.ArgumentList

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com JLine parsed argument list

Class Attributes:
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano, Denny Valliant
  •  
    Constructor Summary
    init([string line], [numeric cursor], [array tokens], [any context])
    Method Summary
    any cursor()
         The cursor position within the line.
    any escape([string candidate], [boolean complete])
         Escapes a completion candidate before writing it to the buffer - this method can be used.
    any line()
         The unparsed line.
    private any namedParam([any token])
    any rawWordCursor()
         The cursor position within the current word in its raw (quoted and escaped) form.
    any rawWordLength()
         The length of the current word in its raw (quoted and escaped) form.
    private any token()
    private any unquote([any token])
    any word()
         This is the word the cursor is currently in - for our purposes it is always the last word.
    any wordCursor()
         The cursor position within the current word (unquoted, unescaped).
    any wordIndex()
         The index of the current word (the word the cursor is in) in the list of words.
    any words()
         The parsed list of words in the raw line.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init([string line], [numeric cursor], [array tokens], [any context])

    Parameters:
    line - the raw line from the buffer
    cursor - the position of the cursor on the line
    tokens - the array of parsed tokens from the CommandBox Parser
    context - ParseContext enum from org.jline.reader.Parser - can be UNSPECIFIED, ACCEPT_LINE, COMPLETE, SECONDARY_PROMPT

    Method Detail

    cursor

    public any cursor()

    The cursor position within the line This was passed into the parse function


    escape

    public any escape([string candidate], [boolean complete])

    Escapes a completion candidate before writing it to the buffer - this method can be used to quote completions that contain spaces. JLine will also use this method to backspace the current word from the buffer - not sure why it uses this in certain cases instead of the `rawWordXXXX()` methods above. But since it does, this method can be used to ensure the correct number of characters are removed. `complete` will generally match up with whether completion candidates are marked as complete, however, when choosing from a menu this is hard coded as true, and when backspacing the current word it is hard coded as false. So this needs to be worked around for now.

    Parameters:
    candidate - a string containing a completion candidate to be escaped - might also be the current word so Jline can backspace it
    complete - a boolean indicating whether this completion candidate is considered complete

    line

    public any line()

    The unparsed line This was passed into the parse function


    namedParam

    private any namedParam([any token])

    Parameters:
    token

    rawWordCursor

    public any rawWordCursor()

    The cursor position within the current word in its raw (quoted and escaped) form JLine uses this to correctly backspace the current word on the raw line when writing a completion to the buffer. This is not currently computed so just return the length of the current token


    rawWordLength

    public any rawWordLength()

    The length of the current word in its raw (quoted and escaped) form JLine uses this to correctly backspace the current word on the raw line when writing a completion to the buffer.


    token

    private any token()


    unquote

    private any unquote([any token])

    Parameters:
    token

    word

    public any word()

    This is the word the cursor is currently in - for our purposes it is always the last word. In order for quoted completions to work, this is expected to have any quotes wrapping the word stripped. (JLine also expects it to have escapes removed, but for our purposes unquoting seems sufficent.)


    wordCursor

    public any wordCursor()

    The cursor position within the current word (unquoted, unescaped) This is not currently computed so just return the length of the current word


    wordIndex

    public any wordIndex()

    The index of the current word (the word the cursor is in) in the list of words The last word is regarded as always being the current word for now


    words

    public any words()

    The parsed list of words in the raw line This is the array of tokens that were computed by our parser and passed in - with one difference. Completions in CommandBox are always done with respect to the last word on the line, so that word needs to be unquoted for JLine so it can match completions correctly.