hsh :: command :: CommandToken :: Class CommandToken
[hide private]
[frames] | no frames]

Class CommandToken

object --+        
         |        
     Token --+    
             |    
AggregateToken --+
                 |
                CommandToken

Instance Methods [hide private]
 
__init__(self, do_aliases=True)
Create a new CommandToken token.
 
insert(self, loc, txt)
Insert the provided text at the given location, raising an exception in case of error.
 
delete(self, loc, count=1)
Delete count characters at the given location, raising an exception in case of error.
 
modify(self, txt='', begin=0, end=None)
Modify this token by replacing the text between begin and end with the given text.
 
create_token(self, txt, loc)
 
expand(self)
Command expansion is to concatenate the results of expansions of the Args into a list of parameters.
 
completions(self, cloc)
Return a list of completions for this token from the specified cursor location.
 
expand_directives(self)
Like parameter expansion, directives are concatenated into a list.

Inherited from AggregateToken: __len__, __str__, dump

Inherited from Token: commences, terminated, terminates

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]

Inherited from Token: commencer_ch, dquotable

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, do_aliases=True)
(Constructor)

 

Create a new CommandToken token. If aliases is False, do not expand aliases in this command, to prevent unbounded recursion.

Overrides: object.__init__

modify(self, txt='', begin=0, end=None)

 

Modify this token by replacing the text between begin and end with the given text. begin defaults to the beginning of the token, end to the end, and txt to the empty string.

Returns a 3-tuple:

  1. string: text which wasn't used by this token and spills over to the next token.
  2. boolean: True means that this token may absorb some characters from the next token. Spill over is not possible in this case.
  3. boolean: True means that this token needs to be deleted. May include spillover.

The default implementation checks the insertion range, raising an exception in case of error, but does not perform the actual modify.

Overrides: Token.modify
(inherited documentation)

create_token(self, txt, loc)

 
Overrides: AggregateToken.create_token

expand(self)

 

Command expansion is to concatenate the results of expansions of the Args into a list of parameters. ArgSeparators disappear since they expand to the empty list.

Overrides: Token.expand

completions(self, cloc)

 

Return a list of completions for this token from the specified cursor location. If no possible completions exist, [] is returned. If possible completions exist, a list of strings is returned. The first item is the root of the completions, the rest are possible extensions of the root. Most tokens will return None if the cursor is not at the end. The default implementation returns nothing.

Overrides: Token.completions
(inherited documentation)

expand_directives(self)

 

Like parameter expansion, directives are concatenated into a list. Directives which don't make sense together are filtered so that only the last one is preserved.

Overrides: Token.expand_directives