Objective-Everything Release 5.  Copyright ©1994-1998 by TipTop Software, Inc.  All Rights Reserved.

Interactors

Interactor objects evaluate commands in an interpreter.  Usually, they present you with a user interface which allows you to interactively type in commands.  Interactors are language-independent; an interactor object will work with any language interpreter.

To set up and run an interactor from your ObjC code, you just need to specify which interpreter to interact with, and then run it.  E.g., to run an interactor for the default ObjTcl interpreter, simply do:

id interactor=[[TTInteractor alloc] init];
[interactor setInterp:[TTObjTclInterp getDefaultInterp]];
[interactor runModal:YES]; 

For more info on the Interactor API see TTInteractorProtocol, TTInteractor, TTWInteractor, and TTEditWInteractor in the reference section.

Objective-Everything provides three Interactor classes: TTInteractor, TTWInteractor, and TTEditWInteractor.

TTInteractor:
TTY interactor

TTInteractor is intended for non-AppKit based (GUI-less) applications.  It reads the user commands from the standard input, and prints command results to the standard output.

On Unix platforms, by default, TTInteraction uses the getline library for command input, which facilitates command editing and history.  (Due to its restrictive license, we cannot use the GNU Readline library. However, you can link with readline, and use it.  See TTInteractor in the class reference section for more info.)

TTWInteractor:
Basic AppKit interactor

You use TTWinteractor in the AppKit-based application.  TTWInteractor presents you with a command window in which you type commands to be evaluated in an interpreter.  TTWInteractor features Text object based command editing with command history.

The TTWInteractor is available in the ObjPalette. To run it you can:

To run a TTWInteractor from your ObjC code, as a shortcut for creating an interactor, setting its interp, and running it, you can simply do:

[interp newWInteractor:nil]; 

to run an interactor for a specific interpreter instance, or:

[TTInterp newWInteractor:nil]; 

to run an interactor on a default interpreter in some language.

Key binding of interest are:

[Up Arrow]
[Down Arrow]
If outside input text area, move cursor one line up/down.  If inside text area, move cursor one line up/down, or move to the previous/next command in history.
[Alt-Up Arrow]
[Alt-Down Arrow]
Move to the previous/next command in history, and select it.
[Left Arrow]
[Right Arrow]
Move cursor left/right.
[Enter] If outside input text area, moves cursor into the input text area.  If inside text area, if the command is complete, saves it in the history buffer, and evaluates it in the interpreter; otherwise, adds a line.
[Shift-Enter] Add a line without evaluating command.
[NumericPad Enter] Evalute command in the interpreter, regardles whether it is complete or not.
[Ctrl-O] "Opens" a line.
[Ctrl-A]
[Ctrl-E]
Jumps to beginning/end of line.
[Ctrl-C] Kills the current command being typed.
[Ctrl-R] Runs History Lookup panel. See below.
[Command-a] Selects the current command, or the entire text in the text view. To kill the current command being typed, simply select it (Cmd-a) and delete it (Backspace).
Bang-expand To select the most recent history line which starts with a string, simply type !string and hit Return.

History Lookup Panel

The History Lookup panel provides a convenient access to the interactor's command history. You get the History Lookup panel by hitting Ctrl-R in an interactor window.

In the History Lookup panel, the following key bindings are in effect.

[Ctrl-C]
[ESC]
Cancel (close panel).
[Enter] Select history item. Selected text relaces command line contents.
[Up Arrow]
[Down Arrow]
Move to previous/next history item
text Search history items for text string.
[Ctrl-R]
[Ctrl-S]
Find previous/next occurence of the search text.
Save button Save history into file.
Load button Load history from file.
Flush button Forget history; i.e., remove all history items.
Find button Finds previous history item containing search text.

TTEditWInteractor:
AppKit interactor with a simple code editor

Edit-interactors provide a convenient way to interactively edit, test, debug, and execute code, all in one place.  An edit-interactor looks like this:

The top text view (edit view) is used as an editor.  You can load a file and edit it there.  The bottom view (shell view) is used to issue commands to the interpreter.

Load Load a file into the edit view.
Save Save the contents of the edit view into a file.
Run Execute contents of the edit view, line-by-line.
Stop Stop execution.
Continue Continue execution from the current line.
1 Step Execute the current line and advance to the next.
Eval selection Evaluates the current selection in the edit-view.
Clear Clears the shell view.
[Ctrl-J] Evaluate the current line (or block).

ObjTcl Example:

Type the following in the edit view:

expr 1+2
info tclversion
objtcl::info version
NSRunAlertPanel [nil] "Hello World!" [nil] [nil] [nil]
NSBeep
sdfsdfjsdf sdfsdf 

Hit the "Run" button.  Click into the third line and hit Ctrl-J.


[previous][contents][next]