|
Class: TerminalView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ListView
|
+--TextView
|
+--EditTextView
|
+--TextCollector
|
+--TerminalView
|
+--VT100TerminalView
- Package:
- stx:libwidg2
- Category:
- Views-TerminalViews
- Version:
- rev:
1.339
date: 2023/12/13 09:04:04
- user: cg
- file: TerminalView.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
I provide terminal functionality, by interpreting data
arriving from some stream (typically connected to a command interpreter
via a pty, or another system via a modem) and sending my keyboard data to it.
I am abstract providing general functionality -
concrete terminal characteristics (i.e. escape sequences) are defined
by concrete subclasses (see VT52TerminalView, VT100TerminalView).
Concrete applications are:
consoles (VT100TerminalView),
telnet-views (see TelnetTool)
editor wrappers (if you like emacs/vi)
gdb terminal subviews (see GDBApplication)
Although my class protocol includes common startup protocol
(to open a terminalView with a shell or on the output of a command),
I can be used as a widget within an application (modem software).
Implementation notice:
some of my pty functionality and handling is being extracted to
the separate TerminalSession class (which allows communicating with a
program without having its output displayed).
So currently, some ugly code duplication is present.
Once stable, code will be refactored.
For now, as terminalView is being used in
some of our critical applications, this refactoring has not yet been done.
Line Editing mode:
Cursor keys allow for th user to navigate through previously entered input (as in cmd.exe and bash).
Special: <SHIFT>-cursor up goes back to the previously selected history line.
(not to the previous line).
For example, if the user types:
a <RETURN>
b <RETURN>
c <RETURN>
<CURSOR-UP> -> shows 'c'
<CURSOR-UP> -> shows 'b'
<CURSOR-UP> -> shows 'a'
123 <RETURN> -> resends 'a123'
<SHIFT-CURSOR-UP> -> shows 'a' again which is the previously selected history line(not a123)
<CURSOR-DOWN> -> shows 'b'
<RETURN> -> sends 'b'
[instance variables:]
inStream stream where keyboard input is
sent to (connected to shells or commands input)
outStream stream where the output of the
shell or command arrives
(read here and displayed in the view)
readerProcess process which reads commands
output and sends it to the view
lineEditMode if on, do readLine-alike input history and editing
signalControlKeys if on, CTRL-C sends an interrupt (for Windows)
[class variables]:
Debug := true trace incoming characters
Debug := false
DebugKeyboard := true trace outgoing characters
DebugKeyboard := false
copyrightCOPYRIGHT (c) 1998 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
defaults
-
defaultIcon
-
This resource specification was automatically generated
by the ImageEditor of ST/X.
Usage example(s):
self defaultIcon inspect
ImageEditor openOnClass:self andSelector:#defaultIcon
Icon flushCachedIcons
|
-
defaultNumberOfColumns
-
-
defaultNumberOfLines
-
initialization
-
initialize
-
self initialize
opening
-
open
-
VT100TerminalView open
VT52TerminalView open
TerminalView open
-
openDummy
-
for testing purposes only - opens a dummy tty-view, which simply
echoes whatever is typed in
Usage example(s):
-
openOnCommand: aCommandString
-
start a command on a pseudo-TTY, open a terminalView on it
(i.e. this is kind of an xterm)
Usage example(s):
VT100TerminalView openOnCommand:'ls -l'
|
-
openOnCommand: aCommand in: aDirectory
-
start a shell on a pseudo-TTY, open a terminalView on it
(i.e. this is kind of an xterm)
Usage example(s):
TerminalView openOnCommand:'ls'
TerminalView openOnCommand:'ls' in:'/etc'
|
-
openOnCommand: aCommandString in: aDirectory onExit: exitBlockOrNil
-
start a command on a pseudo-TTY, open a terminalView on its output
(i.e. this is kind of an xterm).
When the command finishes, evaluate aBlock.
Usage example(s):
VT100TerminalView openOnCommand:'ls -l' in:'/etc' onExit:[]
VT100TerminalView openOnCommand:'ls -l' in:'/etc' onExit:[:vt | vt topView destroy]
VT100TerminalView openOnCommand:'ls -l' in:'/etc' onExit:[:vt | Dialog information:'Shell terminated'. vt topView destroy ]
|
-
openOnCommand: aCommandString onExit: aBlock
-
start a command on a pseudo-TTY, open a terminalView on its output
(i.e. this is kind of an xterm).
When the command finishes, evaluate aBlock.
Usage example(s):
VT100TerminalView
openOnCommand:'ls -lR'
onExit:[:vt |
Dialog information:'Press OK to close'.
vt topView close.
].
|
-
openOnInput: inStream output: outStream
-
open a terminalView on the given streams (which are typically some
kind of socket or pty).
Keys pressed are sent to inStream, text appearing
from outStream is displayed in the terminal view.
This can be used to implement things like rlogin
or telnet views (if connected to a modem, a com-program can also be
implemented this way).
-
openOnInput: inStream output: outStream in: aView
-
open a terminalView on the given streams
(which are typically some kind of socket or pty).
Keys pressed are sent to inStream, text appearing
from outStream is displayed in the terminal view.
This can be used to implement things like rlogin
or telnet views (if connected to a modem, a com-program can also be
implemented this way).
-
openShell
-
start a shell on a pseudo-TTY, open a terminalView on it
(i.e. this is kind of an xterm)
Usage example(s):
VT100TerminalView openShell
|
-
openShellIn: aDirectory
-
start a shell on a pseudo-TTY, open a terminalView on it
(i.e. this is kind of an xterm)
Usage example(s):
TerminalView openShellIn:'/etc'
VT52TerminalView openShellIn:'/etc'
VT100TerminalView openShellIn:'/etc'
|
-
openShellIn: aDirectory onExit: exitAction
-
start a shell on a pseudo-TTY, open a terminalView on it
(i.e. this is kind of an xterm)
Usage example(s):
TerminalView openShellIn:'/etc' onExit:[ Dialog information:'Shell terminated' ]
|
-
openWithAction: setupAction
-
open a terminalView, let it start its command via setupAction,
which gets the instantiated terminalView as argument.
Usage example(s):
TerminalView openWithAction:[:vt | vt startShellIn:'/etc']
TerminalView openWithAction:[:vt | vt startCommand:'ls -l' in:'/etc'. vt shellTerminateAction:[].]
|
-
openWithAction: setupAction onExit: exitBlockOrNil
-
open a terminalView, let it start its command via setupAction,
which gets the instantiated terminalView as argument.
The default exitAction is to destroy the topView.
-
openWithAction: setupAction setupTerminalViewWith: terminalSetupActionOrNil onExit: exitBlockOrNil
-
open a terminalView, let it start its command via setupAction,
which gets the instantiated terminalView as argument.
The default exitAction is to destroy the topView.
Usage example(s):
TerminalView openWithAction:[:vt | vt startShellIn:'/etc']
TerminalView openWithAction:[:vt | vt startCommand:'ls -l' in:'/etc'. vt shellTerminateAction:[].]
|
queries
-
isVisualStartable
-
returns whether this application class can be started via #open
utilities
-
showOutputOfCommand: cmd in: aDirectory atEndShow: endMessageOrNil
-
open a terminalview, which presents the output of a command
Usage example(s):
VT100TerminalView
showOutputOfCommand:'ls -l'
in:'.'
atEndShow:'<< ls terminated >>'
VT100TerminalView
showOutputOfCommand:'ls'
in:'.'
atEndShow:'ls finished'
|
-
showOutputOfCommand: cmd in: aDirectory atStartShow: startMessageOrNil atEndShow: endMessageOrNil
-
open a terminalview, which presents the output of a command
Usage example(s):
VT100TerminalView
showOutputOfCommand:'ls -l'
in:'.'
atEndShow:'<< ls terminated >>'
VT100TerminalView
showOutputOfCommand:'ls'
in:'.'
atEndShow:'ls finished'
|
-
showOutputOfCommand: cmd in: aDirectory environment: envOrNil atEndShow: endMessageOrNil
-
open a terminalview, which presents the output of a command
Usage example(s):
VT100TerminalView
showOutputOfCommand:'ls -l'
in:'.'
atEndShow:'<< ls terminated >>'
VT100TerminalView
showOutputOfCommand:'ls'
in:'.'
atEndShow:'ls finished'
VT100TerminalView
showOutputOfCommand:'printenv'
in:'.'
environment:(Dictionary new at:'FOO' put:'helloFoo'; yourself)
atEndShow:'ls finished'
|
-
showOutputOfCommand: cmd in: aDirectory environment: envOrNil atStartShow: startMessageOrNil atEndShow: endMessageOrNil
-
open a terminalview, which presents the output of a command,
optionally showing message before and after the execution.
Usage example(s):
VT100TerminalView
showOutputOfCommand:'ls -l'
in:'.'
atStartShow:'<< ls running... >>'
atEndShow:'<< ls terminated >>'
|
Usage example(s):
VT100TerminalView
showOutputOfCommand:'sleep 4'
in:'.'
atStartShow:'<< sleeping... >>'
atEndShow:'<< shell terminated >>'
|
accessing
-
controlCAction: aBlockOrNil
-
if not nil, this is called when ctrl-C is pressed
(to send it to whatever underlying process is,
useful in case it was not started by the terminalView itself)
-
filterStream
-
get a filter stream if any; if not nil, it gets all incoming data via nextPutAll:.
Added to allow saving incoming data to a file, but can also be used to catch/filter/lookAt
incoming data by some other program
-
filterStream: aStream
-
set a filter stream; if not nil, it gets all incoming data via nextPutAll:.
Added to allow saving incoming data to a file, but can also be used to catch/filter/lookAt
incoming data by some other program
-
inStream
-
return the stream, which gets all input data
(i.e. keyboard input)
-
inStream: something
-
set the stream, which gets all input data
(i.e. keyboard input)
-
lineBufferHistory
-
-
lineBufferHistory: aCollection
-
-
lineBufferHistoryChanged
-
true if it changed since either set explicitly or since the terminal was opened
-
masterWindow: aTopView
-
if set, and a corresponding osCommand escape sequence is received,
that topView's title, icon or other attribute is changed.
Needed to support xterm's 'set window title' escape sequence
-
outStream
-
return the stream, which is used to present data in the view
(i.e. the shell's output)
-
outStream: something
-
set the stream, which is used to present data in the view
(i.e. the shell's output)
-
outputEncoding: aCharacterEncoder
-
defines how the program's output is to be decoded.
If nil, it will be iso8859;
a useful value is
outputEncoding:(CharacterEncoder encoderForUTF8)
The default is taken from the users preferences,
which itself defaults depending on the OS
-
outputRecorderStream
-
NOTICE: this records the program's output
if set, this one gets a chance to look at all incoming data
as received from the other side.
It will be sent messages of the form:
nextPutAll:count from:buffer startingAt:1
-
outputRecorderStream: aStream
-
NOTICE: this records the program's output
if set, this one gets a chance to look at all incoming data
as received from the other side.
It will be sent messages of the form:
nextPutAll:count from:buffer startingAt:1
-
readerProcess
-
-
recorderStream: aWriteStream
-
CAVEAT: bad naming: this records user input
set a recorder stream;
if not nil, it gets all user input (keyboard) data via nextPut:.
Allows saving of user input to a file, for later replay of a session
-
setShellPid: aProcessID
-
in case the program was started by someone else;
set the shellPid, for CTRLC sending via the menu
-
shellDirectory: aPathname
-
the directory, in which the shell/command should be executed.
By default, the 'current' directory is used
-
shellTerminateAction: aBlock
-
set the block which is evaluated when the shell terminates.
Can be used to close down the application or perform any other cleanup action.
The default shows a dialog, that the shell/command has terminated
-
streamErrorHandler: aBlock
-
if set, that one is informed on I/O errors
(i.e. if the connected PTY has been closed)
accessing-behavior
-
disableLineEditMode
-
-
enableLineEditMode
-
-
filterOnly: aBoolean
-
if true, any output from the program is ONLY
sent to the filterStream (if any) and outputRecorderStream (if any),
not to the window.
Can be used to divert output to a file, without showing
it (eg. for mass-data recording)
-
ignoreOutput: aBoolean
-
if true, any output from the program is ignored
(not processed at all).
Can be used to temporarily disable processing
(for example via a button) when huge mass-output is
coming which we want to ignore.
-
inputTranslateBackspaceToDelete
-
translating backspace to delete on user input
-
inputTranslateBackspaceToDelete: aBoolean
-
-
inputTranslateCRToCRNL: aBoolean
-
translate <RETURN> to <CRNL> on user input
-
inputTranslateCRToNL
-
translating <RETURN> to <NL> on user input
-
inputTranslateCRToNL: aBoolean
-
translate <RETURN> to <NL> on user input
-
lineEditMode: aBoolean
-
if true, I do some limited line editing for the user's input;
the user can use cursor keys to navigate in the input history and
reissue a previously entered input line.
Special: <SHIFT>-cursor up goes back to the previously selected history line.
(not to the previous line).
For example, if the user types:
a <RETURN>
b <RETURN>
c <RETURN>
<CURSOR-UP> -> shows 'c'
<CURSOR-UP> -> shows 'b'
<CURSOR-UP> -> shows 'a'
123 <RETURN> -> resends 'a123'
<SHIFT-CURSOR-UP> -> shows 'a' again which is the previously selected history line(not a123)
<CURSOR-DOWN> -> shows 'b'
<RETURN> -> sends 'b'
-
localEcho: aBoolean
-
enable/disable local echo
-
noColors
-
the noColors boolean disables color changes (from color rendition escape sequences)
-
noColors: aBoolean
-
the noColors boolean disables color changes (from color rendition escape sequences)
-
sendControlKeys
-
there is some conflict with control key handling, for keys such as CTRL-c:
it is both a shortcut (eg. Copy) and sometimes required in the terminal (interrupt key).
For this, we look if there is a current selection, and if so, always treat it as a
shortcut (and NOT sending it to the terminal's program).
Otherwise, if there is no selection, look at the 'sendControlKeys' boolean.
If it is set (which is the default), then send it to the terminal, otherwise perform the editor op.
Thus, an application containing me can offer a menu function (or toggle),
to control this behavior on the UI level.
-
sendControlKeys: aBoolean
-
there is some conflict with control key handling, for keys such as CTRL-c:
it is both a shortcut (eg. Copy) and sometimes required in the terminal (interrupt key).
For this, we look if there is a current selection, and if so, always treat it as a
shortcut (and NOT sending it to the terminal's program).
Otherwise, if there is no selection, look at the 'sendControlKeys' boolean.
If it is set (which is the default), then send it to the terminal, otherwise perform the editor op.
Thus, an application containing me can offer a menu function (or toggle),
to control this behavior on the UI level.
-
signalControlKeys
-
if true (default on Windows), CTRL-C sends an interrupt to
the program. Otherwise, it is sent as a character (0x03)
-
signalControlKeys: aBoolean
-
if true (default on Windows), CTRL-C sends an interrupt to
the program. Otherwise, it is sent as a character (0x03)
-
translateNLToCRNL
-
translate NL to CRNL on output
-
translateNLToCRNL: aBoolean
-
translate NL to CRNL on output
cursor handling
-
cursorDown: n
-
self textChanged.
-
cursorMovementAllowed
-
return true, if the user may move the cursor around
(via button-click, or cursor-key with selection).
Here false is returned - the cursor is only moved by
cursor positioning escape sequences arriving from the
stream.
-
numberOfTerminalCols
-
-
numberOfTerminalColumns
-
-
numberOfTerminalLines
-
be careful - this is NOT called numberOfLines,
-
restoreCursor
-
-
saveCursor
-
-
validateCursorCol: colNr inLine: lineNr
-
check of col is a valid cursor position; return a new col-nr if not.
Here, the linelength is enforced
defaults
-
anyKeyCodes
-
event handling
-
computeNumberOfLinesShown
-
(comment from inherited method)
recompute the number of visible lines
-
defineWindowSize
-
self halt.
-
keyPress: aKey x: x y: y
-
somewhat complicated, since some characters
-
keyPressInLineEditMode: aKey
-
readline alike line editing.
cursorUp/down select a previous line from the history (unix shell bahevior).
shift cursorUp selects a previous selected history line from the history (windows shell bahevior).
cursor left/right/^A/^E/backspace position/edit inside that line.
Return true, if the character was processed,
false if not. Then, the caller should proceed as usual.
-
shellTerminated
-
shell has terminated
-
shouldProcessInputInLineEditMode
-
should input be processed in the readline edit mode?
-
sizeChanged: how from: oldExtentOrNil
-
my view has changed the size (not the contents)
functions
-
autoMargin: aBoolean
-
set/clear autowrap at end of line (not yet fully implemented).
This may come from a CSI sequence, or set programmatically.
-
doBackspace
-
-
doClearDisplay
-
clear everything
-
doClearEntireLine
-
clear the cursor line.
cursor position remains unchanged
-
doClearEntireScreen
-
clear everything
-
doClearFromBeginningOfLine
-
clear from beginning of line to the cursorPosition
-
doClearFromBeginningOfScreen
-
clear from beginning of the screen to the cursorPosition
-
doClearToEndOfLine
-
clear from the cursorPosition to the end of the line
-
doClearToEndOfScreen
-
clear from the cursorPosition to the end of the screen
-
doCursorDown: n
-
move the cursor down by n lines
-
doCursorHome
-
move the cursor to the home position
-
doCursorLeft: n
-
move the cursor to the left by n columns
-
doCursorNewLine
-
move the cursor down to the next line (col remains unchanged)
-
doCursorReturn
-
move the cursor down and left to the beginning to the next line
-
doCursorRight: n
-
move the cursor to the right by n columns
-
doCursorUp: n
-
move the cursor up by n lines
initialization & release
-
closeDownShell
-
shut down my shell process.
-
closeDownShellAndStopReaderProcess
-
shut down my shell process and stop the background reader thread.
-
closeStreams
-
-
escapeSequences: codes
-
setup my escape sequences
-
flushInput
-
flush any leftover input-processing events
-
initStyle
-
self foregroundColor:Color green.
-
initialize
-
will vanish
-
initializeKeyboardMap
-
setup my own keyboardMap, where control-keys
(and some Cmd-keys) are not translated.
-
initializeKeyboardSequences
-
-
initializeShellTerminateAction
-
may be removed with shellTerminateAction:...
-
keyboardMap
-
return my own, private keyboard map.
This has control keys removed and
those will be passed unchanged to the shell
-
mapped
-
no dead keys here
-
reinitialize
-
reinit after a snapIn.
this is invoked (by the system thread) after a snapShot image restart
-
release
-
release myself - shut down the shell, stop the reader thread.
initialization-shell
-
basicStartCommand: aCommand environment: envOrNil in: aDirectory
-
start a command on a pseudo terminal. If the command arg is nil,
a shell is started. If aDirectory is not nil, the command is
executed in that directory.
Also fork a reader process, to read the shells output and
tell me, whenever something arrives
-
basicStartCommand: aCommand in: aDirectory
-
start a command on a pseudo terminal. If the command arg is nil,
a shell is started. If aDirectory is not nil, the command is
executed in that directory.
Also fork a reader process, to read the shells output and
tell me, whenever something arrives
-
startCommand: aCommand
-
start a command on a pseudo terminal. If the command arg is nil,
a shell is started. The command is started in the current directory.
Also fork a reader process, to read the shells output and
tell me, whenever something arrives
-
startCommand: aCommand environment: envOrNil in: aDirectory
-
start a command on a pseudo terminal. If the command arg is nil,
a shell is started. If aDirectory is not nil, the command is
executed in that directory.
Also fork a reader process, to read the shells output and
tell me, whenever something arrives
-
startCommand: aCommand in: aDirectory
-
start a command on a pseudo terminal. If the command arg is nil,
a shell is started. If aDirectory is not nil, the command is
executed in that directory.
Also fork a reader process, to read the shells output and
tell me, whenever something arrives
-
startShell
-
start a shell on a pseudo terminal in the current directory.
Also fork a reader process, to read the shells output and
tell me, whenever something arrives
-
startShellIn: aDirectory
-
start a shell on a pseudo terminal in some directory.
Also fork a reader process, to read the shells output and
tell me, whenever something arrives
menu
-
doClear
-
reset the scroll-range etc, clear the text buffer
-
doReset
-
reset the scroll-range;
may have to reset more in the future (current font-set; color; etc)
-
doSendInterrupt
-
send an INT-signal to the shell (UNIX only)
-
doSendKillSignal
-
send a KILL-signal to the shell (UNIX only)
-
doSendTerminateSignal
-
send a TERM-signal to the shell (UNIX only)
-
doSetLineLimit
-
ask for the lineLimit (the number of buffered lines)
-
editMenu
-
return the view's middleButtonMenu
-
openFileBrowserOnIt
-
open a fileBrowser on the selected fileName
-
pasteOrReplaceFromInputHistory
-
-
sendInterruptSignal
-
send an INTERRUPT-signal to the shell (UNIX only)
-
sendKillSignal
-
send a KILL-signal to the shell (UNIX only)
-
sendTerminateSignal
-
send a TERM-signal to the shell (UNIX only)
-
setGreenDisplayMode
-
-
setNormalDisplayMode
-
-
setRedDisplayMode
-
-
setReverseDisplayMode
-
-
startSaveAs
-
start saving all received data to some file
-
stopFilter
-
stop saving/printing of received data
misc
-
debugPrintCharacter: aCharacter as: what
-
-
removeTrailingBlankLines
-
processing-input
-
doNothing
-
private - end of an ignored escape-sequence
-
endOfSequence
-
private - reset state-machine at end of escape-sequence
-
nextPut: char
-
process a character (i.e. the shell's output).
Answer char
-
nextPutAll: aString
-
self processInput:aString n:aString size
-
processInput: buffer n: count
-
actually: output coming from the connected application (aka input to me);
the stuff coming from the application is a mix of plain text and CSI escape sequences.
If we process each character individually, things are trivial, but slow.
Therefore, we collect big chunks of non-escaped text and buffer them to make
use of the inherited buffered output optimizations (see TextCollector).
Thus, we collect until an escape sequence is encountered, and flush the buffered stuff then,
proceed in single-character mode (processState0:) until the sequence is finished, and continue
collecting.
This makes this terminalView's speed usable and actually competitive with some existing
console applications.
BTW: It is *much* faster than the MSWindows command.com window,
- so much for the 'slow' Smalltalk ;-)
-
sync
-
(comment from inherited method)
send all buffered drawing to the device and wait until the device responds
-
waitForOutputToDrain
-
give terminalView a chance to
queries
-
computePreferredExtent
-
return my preferred extent - this is computed from my numberOfLines,
numberOfCols and font size
-
isKeyboardConsumer
-
return true, if the receiver is a keyboard consumer;
Always return true here
-
terminalType
-
returns a string describing this terminal (usually, this is
passed down to the shell as TERM environment variable).
Here, 'dump' is returned.
reader process
-
readAnyAvailableData
-
read data from the stream,
and sends me #processInput:n: events if something arrived.
Returns the amount of data read.
-
readerProcessLoop
-
look for the command's output,
and send me #processInput:n: events whenever something arrives.
-
startReaderProcess
-
Start a reader process, which looks for the command's output,
and sends me #processInput:n: events whenever something arrives.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
startReaderProcessNow
-
Start a reader process, which looks for the commands output,
and sends me #processInput:n: events whenever something arrives.
-
startReaderProcessWhenVisible
-
Start a reader process, which looks for the commands output,
and sends me #processInput:n: events whenever something arrives.
-
startReaderProcessWhenVisible: whenVisible
-
Start a reader process, which looks for the commands output,
and sends me #processInput:n: events whenever something arrives.
-
stopReaderProcess
-
stop the background reader thread
searching
-
startPositionForSearchBackward
-
-
startPositionForSearchForward
-
selection handling
-
autoMoveCursorToEndOfSelection
-
Redefined to return false since the cursor should
not be affected by selecting
-
copySelection
-
the inherited code would leave the cursor behin the selection;
we always want it to stay at the end.
However: cursorToEndOfText ignores trailing spaces!
-
paste: someText
-
paste - redefined to send the chars to the shell instead
of pasting into the view
-
selection
-
if it is a line-wise collection, return multiple lines;
Usage example(s):
a full-line (3xclick selection)
|
sending
-
send: aString
-
send aString to the underlying program's stdinput
-
sendCR: aString
-
send aString followed by a return to the underlying program's stdinput
-
sendCharacter: aCharacter
-
send a single character to the underlying program's stdin
-
sendLine: aString
-
-
sendLineEnd
-
OperatingSystem isMSDOSlike ifTrue:[
start a shell in the current directory:
start a shell in a given directory:
TerminalView openShellIn:(OperatingSystem getHomeDirectory)
|
start another program current directory:
TerminalView openOnCommand:'ls -l'
|
start another program in some given directory:
TerminalView openOnCommand:'ls' in:'/etc'
|
specify how to react when the shell terminates:
TerminalView openOnCommand:'ls' in:'/etc' onExit:[:vt | vt topView destroy]
TerminalView openOnCommand:'ls' in:'/etc' onExit:[:vt | Dialog information:'finished'. vt topView destroy]
|
special low level usage: no shell command, interact with the user myself
(i.e. read the user's input, and intepret it myself):
|terminal in out inputLine|
in := InternalPipeStream new.
out := InternalPipeStream new.
terminal := TerminalView openOnInput:in output:out.
terminal localEcho:true.
terminal inputTranslateCRToNL:true.
terminal translateNLToCRNL:true.
out nextPutLine:'Hello world - please type at me:'.
[
inputLine := in nextLine asString.
inputLine ~= '#exit' ifTrue:[
out nextPutLine:(Compiler evaluate:inputLine) printString.
].
(inputLine = '#exit') or:[ terminal isOpen not ]
] whileFalse.
terminal topView destroy.
|
|