TerminalView subclass:#VT52TerminalView
instanceVariableNames:'state'
classVariableNames:''
poolDictionaries:''
category:'Views-TerminalViews'
!
!VT52TerminalView class methodsFor:'documentation'!
documentation
"
VT52 terminal
[start with:]
VT52TerminalView openShell
"
! !
!VT52TerminalView methodsFor:'defaults'!
vt52KeyCodes
^ IdentityDictionary withKeysAndValues:
#(
#CursorUp '\eA'
#CursorDown '\eB'
#CursorRight '\eC'
#CursorLeft '\eD'
#Home '\eH'
#Escape '\e'
#BackSpace '\b'
#Return '\r'
#Delete '\0377'
)
"Modified: / 10.6.1998 / 14:19:27 / cg"
! !
!VT52TerminalView methodsFor:'initialization'!
initialize
super initialize.
self endOfSequence.
"Modified: / 12.6.1998 / 20:39:19 / cg"
!
initializeKeyboardSequences
kbdSequences := (self vt52KeyCodes)
! !
!VT52TerminalView methodsFor:'processing - input'!
doNothing
self endOfSequence
"Created: / 12.6.1998 / 20:40:43 / cg"
!
endOfSequence
state := 0.
"Created: / 12.6.1998 / 20:39:52 / cg"
!
nextPut:char
"process a character (i.e. the shells output)"
"/ Transcript show:state; show:' '; showCR:char storeString.
state == #gotReturn ifTrue:[
state := 0.
char == Character nl ifTrue:[
"/ cr-nl
"/ stay in buffering mode.
super nextPut:Character cr.
^ self.
].
self endEntry.
self cursorToBeginOfLine.
"/ continue in initial state
].
state == 0 ifTrue:[
"/ Currently, we are in initial state.
"/ Decide what to do on the basis of the parameter char.
(char == Character esc) ifTrue:[
self endEntry.
state := #gotESC.
^ self
].
(char == Character nl) ifTrue:[
self endEntry.
^ self cursorDown:1
].
(char == Character return) ifTrue:[
state := #gotReturn.
^ self.
].
(char == Character backspace) ifTrue:[
self endEntry.
^ self cursorLeft. "/ doBackspace
].
(char == Character bell) ifTrue:[
self beep.
^ self
].
char asciiValue < 32 ifTrue:[
Transcript show:'unhandled control key: '; showCR:char storeString.
].
^ super nextPut:char
].
state == #gotESC ifTrue:[
"/ Currently, we are in ESC state.
"/ Decide what to do on the basis of the parameter char.
char == $A ifTrue:[
"/ ESC-A
self cursorUp.
^ self endOfSequence
].
char == $B ifTrue:[
"/ ESC-B
self cursorDown.
^ self endOfSequence
].
char == $C ifTrue:[
"/ ESC-C
self cursorRight.
^ self endOfSequence
].
char == $D ifTrue:[
"/ ESC-D
self cursorLeft.
^ self endOfSequence
].
char == $H ifTrue: [
"/ ESC-H
self doCursorHome.
^ self endOfSequence
].
char == $J ifTrue: [
"/ ESC-J
self doClearToEnd.
^ self endOfSequence
].
Transcript show:'unhandled esc-key: '; showCR:char storeString.
].
self doNothing
"Modified: / 12.6.1998 / 21:00:54 / cg"
! !
!VT52TerminalView methodsFor:'queries'!
terminalType
^ #vt52
"Created: / 10.6.1998 / 16:22:46 / cg"
! !
!VT52TerminalView class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libwidg2/VT52TerminalView.st,v 1.6 1998-06-12 20:03:46 cg Exp $'
! !