TIBET Developer Console (TDC)
NOTE: the TIBET Developer Console (TDC) Lama component is undergoing a redesign as part of our Lama restructuring effort.
Stay tuned for significant updates as we complete our Lama migration.
Wins
- Cross-browser development console with access to multiple "shells".
- Multi-line input cell with auto-sizing, making code/markup entry easy.
- Object-oriented input and output including type-specialized pretty-printers.
- Multiple output modes including
growl
mode,single cell
, andlog
. - Common command set including
:clear
,:history
,:help
, and more.
Contents
Concepts
Cookbook
The Input Cell
- Entering Text
- Evaluating Input
- Clearing Input
- Accessing History
- Focusing the Input Cell
- Activating Auto-Complete
- Cancelling an Input Request
The Output Cell(s)
Code
Concepts
The TIBET Developer Console (TDC) is a central tool in the TIBET Lama, TIBET's browser-based IDE, one used for interactive access to your application and TIBET.
Unlike a simple JavaScript evaluator, the TDC provides access to one or more "shells", the primary one being the TIBET Shell (TSH), our revolutionary object-oriented web shell.
This document covers the I/O interfaces provided by the TDC. To understand the full value of the TDC you should also review the documentation on the TIBET Shell (TSH).
The TDC input cell is found at the bottom of the TIBET Lama™ UI. Output cells position themselves above the input cell in either "growl", "single-cell", or "log" modes.
The screenshot below shows a simple multi-line JavaScript snippet. Output is written to a unique cell with access to history, the first line of text, and the datatype of the output.

Operation of the TDC is simple. You enter text in the input cell and
use Shift-Return
(or the run button) to send the text to the current shell for
evaluation.
When running TSH commands the behavior is the same, but notice that you can enter URIs directly, pipe their content through filters, redirect their output, and much more:

The TDC can be used in an open or closed format. When open you can resize the input cell to meet your needs. When closed the input cell automatically expands/contracts to fit your input.
Output Formatting
TIBET shells are object shells, meaning they work primarily with objects rather than strings like a typical shell. Response data for your input requests can be an object of any type.
To display command results effectively TIBET relies on a combination of polymorphic messaging and a general purpose "pretty printer" to produce output.
Functions, for example, will display their source text. TIBET's coding standard dictates placing JSDoc-style comments inside the function body so entering the name of a TIBET function will show both code and comments (in unminified code at any rate):

A TP.core.Hash
on the other hand will display itself as a set of key/value
pairs separated by =>
symbols:

You can alter how a particular type displays, and ensure your own custom types
display as you'd like, by implementing asTP_lama_pp
for your instances.
For example, enter this in a TDC input cell and hit [Shift-Return]:
myObj = TP.hc('a', 1);
// Note no '.Inst' here...this method is only for myObj
myObj.defineMethod('asTP_lama_pp', function() {
return 'top secret';
});
myObj;
You'll see your hash output top secret
rather than the typical display. You
can use this approach to customize how the Lama/TDC display your particular
types.
Help
Use ?
or :help
to get TSH and TDC options from within the command cell.
Prefixes
Shell input prefixes control how the underlying shell processes your input. For
the TSH the prefix list can be found at the bottom of the output from the
:help
command:

Shortcuts
Keyboard shortcuts allow you to quickly focus the input cell, toggle features like autocomplete, provide for easy clearing of the input and output areas, and more.
You can view the list of shortcuts using the :keys
command:

Cookbook
The Input Cell
Entering Text
The TDC’s input cell is dynamic and will grow to fit your input as you type. Just use the [Return] key as you would in a standard text editor and the TDC will adjust to fit.
For example:

Within the input cell you can use the [Tab] key to indent text to match your personal preference for text alignment. You can also use standard keys such as Home, End, and the various arrow keys to maneuver.
Evaluating Input
Entering [Shift-Return] sends the input cell text to the current shell for processing.

Once the command is submitted for processing the input cell returns to a single-line height and your result is displayed in an output cell (more on these shortly).
Clearing the Input Cell
The [Ctrl-U] sequence lets you clear the input cell with a simple command sequence, much like the Ctrl-U sequence in a UNIX command line environment.
Accessing History
[Shift-Up] and [Shift-Down] mirror the Up/Down arrow key sequences most command environments support for moving through your command history.
Since the input cell is multi-line and the arrow keys need to move you within the text itself we require the Shift key to trigger history traversal. Each entry is placed in the input cell so you can edit it as needed. Use [Shift-Return] to (re)run it.
Focusing the Input Cell
When the TDC is open but unfocused you can focus it via [Shift-Shift]. This is a useful shortcut when you're working on your UI so the focus has shifted away from the input cell and you want to enter a new command.
Activating Auto-Complete
** NOTE: Auto-complete is currently disabled while we tune the implementation.**
To activate auto-completion processing on your input you can use [Ctrl-A]. A small indicator will show next to the prompt indicating auto-complete is active:

Auto-Complete is currently implemented as a "single-use" toggle. It will clear (and the icon will disappear) when you use [Escape] to cancel it or [Shift-Return] to execute.
When auto-complete is active the TDC will display current matches next to your input. You can move within the list using the arrow keys, cancel it via [Escape], and accept the current item using [Tab].

Cancelling an Input Request
When a shell needs input from the user (you) it makes a UserInputRequest, literally signaling via TIBET’s event system that it needs data from the user to continue.
The TDC, as a UserIOService, observes these requests and displays the request’s prompt string. You can think of this sequence as TIBET’s signaling equivalent of the JavaScript prompt or confirm functions where the input cell is the prompt.
While processing a modal request of this form the console stops listening to your commands until you’ve responded via [Shift-Return]. Of course sometimes the response you want to give is Cancel. That’s where [Shift-Escape] comes in. [Shift-Escape] cancels the current input request, returning control to the shell so you can resume your tasks.
The Output Cell(s)
TDC output comes in three 'modes': growl, single-cell, and log.
In growl mode command output is displayed for a few seconds and then fades.
In single-cell mode a single output cell is reused but remains visible. Single-cell mode is a nice way to interact with a small output footprint.
In log mode each response gets a unique output cell and all output cells are
shown until you issue a :clear
command or [Ctrl-K]. Here's a sample:

As you may notice, output cells include an abbreviated portion of their input request as well as timing data and a note about the datatype of the result. Notice that in our example above the type is 'Function', not string. TIBET's shells are Object-Oriented shells. They accept and return objects, not strings (except to the degree strings are objects ;)).
Setting Display Mode
By default the TDC starts in 'growl mode', meaning that each output cell will display and then fade after a few seconds, leaving you with a clear view of your application.
You can change the display mode using the [Ctrl-Up] and [Ctrl-Down] keys which cycle through the three current modes: growl, single-cell, and log.
Pausing A Growl Mode Fadeout
If you are in growl mode and want to look at the output cell longer simply hit [Space]. The fade of the output cell will pause. The cell will hide once you execute the next command, returning you to normal growl mode.
Toggling Growl Cell Display
If you realize you want to look back at the last growl mode cell you can access it via [Shift-Space]. This sequence can be used to toggle viewing of the cell from that point forward.
shortcuts
The TDC uses a number of keyboard sequences to support common operations.
Default TDC key mappings tend to use the Shift key to avoid overlap with the Ctrl and/or Alt mappings commonly used by browsers except where the functionality overlaps (such as for Ctrl-U or Ctrl-K). This approach means the standard navigation keys such as Home, End, etc., will work within the input cell as you’d expect, as will the various arrow keys.
It's important to keep in mind that the console handles these key mappings, not the shells. The shells are unaware of the UI, responding only to requests to run scripts by creating responses and signaling their completion.
Shift-Return Sends the current input cell text to the current shell for
processing. This can be altered if a command makes a
UserInputRequest, thereby gaining control over subsequent
input. See Shift-Esc for more info.
Shift-Up Shifts the current shell’s history list index down by one
(decrements it) and returns the history list entry at
that index.
Shift-Down Shifts the current shell’s history list index up by one
(increments it) and returns the history list entry at
that index.
Shift-Right Shifts the shell index down by one (decrements it) and
makes the shell at that index the current shell. Only available
when running multiple shells.
Shift-Left Shifts the shell index up by one (increments it) and makes
the shell at that index the current shell. Only available when
running multiple shells.
Shift-Esc Cancels the current command or request controlling input
handling. When a command wants input it can make a
UserInputRequest to gain control over subsequent Shift-Return
input. Until the command completes or Shift-Esc is executed all
input is passed to the command rather than the current
shell.
Ctrl-A Activates autocompletion mode for the input cell and shell.
Ctrl-K Clears the current output cell(s). (Similar to Ctrl-K in UNIX
environments).
Ctrl-U Clears the current input cell text. (Similar to Ctrl-U in UNIX
environments).
Ctrl-Up Cycle output cell display mode.
Ctrl-Down Cycle output cell display mode.
Space Pause fade-out of growl mode output cell.
Escape Cancel auto-complete mode.
Code
Implementation of the TDC is handled primarily by the lama:console
type and
its related lama:consoleoutput
component. Files for these and related
templates etc. can be found in the ~lib/src/tibet/tools/lama
directory.