termlib.js home | multiple terminals | parser | faq | documentation | samples
Text Import Sample
 
> open terminal  

> test insertText() 

> test importEachLine() 

> test importMultiLine() 

 
 
(c) mass:werk,
N. Landsteiner 2005-2007
http://www.masswerk.at

How to import text to a termlib.js Terminal object.
 

This page demos 3 different methods of TermGlobals for text import:

  • TermGlobals.insertText( text:String )
    Auto-types a given text at the current cursor position.
    this is a true input (just as it came form the keyboard).
    Works only with single line input.
     
  • TermGlobals.importEachLine( text:String )
    Types multiline input to the current command line.
    The given text exchanges any text on the current command line.
    Each line is executed separately - just as if it would have
    been typed with a trailing <ENTER> each.
     
  • TermGlobals.importMultiLine( text:String )
    Imports multiple lines of text as one input, fakes terminal input.
    The whole text will be imported as one string using "\n" as line
    separator. (As all non-printable characters the newline will be
    displayed as a caret [CARET/CIRCUMFLEX ACCENT] using type().)
    As with TermGlobals.importEachLine() any text in the current
    command line will be lost.
     

Note on forms for input:
Be sure to set TermGlobals.keylock to true before waiting for any form input!

All three methods act on the currently active Terminal-object and return their
success. A negative return value indicates an inactive terminal, or a global or
individual lock => ((TermGlobals.keylock) || (TermGlobals.activeTerm.lock)).