--- a/TerminalView.st Thu Feb 07 12:16:15 2019 +0000
+++ b/TerminalView.st Mon May 20 13:55:48 2019 +0100
@@ -620,6 +620,14 @@
!TerminalView methodsFor:'accessing - behavior'!
+disableLineEditMode
+ self lineEditMode:false.
+!
+
+enableLineEditMode
+ self lineEditMode:true.
+!
+
filterOnly:aBoolean
"if true, any output from the program is ONLY
sent to the filterStream (if any), not to the window.
@@ -956,7 +964,7 @@
"Created: / 13-06-2017 / 14:35:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-keyPress:logicalKey x:x y:y
+keyPress:aKey x:x y:y
<resource: #keyboard (#Control #Control_L #Control_R
#Shift #Shift_L #Shift_R
#Alt #Alt_L #Alt_R
@@ -966,8 +974,8 @@
|rest event rawKey seq shortCut|
- ( #(ZoomIn ZoomOut ZoomInAll ZoomOutAll) includes:logicalKey) ifTrue:[
- super keyPress:logicalKey x:x y:y.
+ ( #(ZoomIn ZoomOut ZoomInAll ZoomOutAll) includes:aKey) ifTrue:[
+ super keyPress:aKey x:x y:y.
].
"/ somewhat complicated, since some characters
@@ -977,21 +985,21 @@
inStream isNil ifTrue:[^ self].
DebugKeyboard ifTrue:[
- Transcript showCR:'----'; show:'keyPress:' ; showCR:logicalKey printString.
+ Transcript showCR:'----'; show:'keyPress:' ; showCR:aKey printString.
].
self shouldProcessInputInLineEditMode ifTrue:[
- (self keyPressInLineEditMode:logicalKey) ifTrue:[^ self].
+ (self keyPressInLineEditMode:aKey) ifTrue:[^ self].
].
- logicalKey isCharacter ifTrue:[
+ aKey isCharacter ifTrue:[
self deselect.
localEcho ifTrue:[
- self nextPut:logicalKey.
+ self nextPut:aKey.
self flush.
].
"/ send it down to inStream ...
- self sendCharacter:logicalKey.
+ self sendCharacter:aKey.
^ self
].
@@ -999,22 +1007,22 @@
Shift Shift_L Shift_R
Alt Alt_L Alt_R
Cmd Cmd_L Cmd_R
- Meta Meta_L Meta_R) includes:logicalKey) ifTrue:[
+ Meta Meta_L Meta_R) includes:aKey) ifTrue:[
^ self
].
"/
"/ common translations (Tab, Backspace, F-keys etc.)
"/
- (logicalKey == #Return
+ (aKey == #Return
and:[inputTranslateCRToNL]) ifTrue:[
seq := '\n'.
] ifFalse:[
- (logicalKey == #BackSpace
+ (aKey == #BackSpace
and:[inputTranslateBackspaceToDelete]) ifTrue:[
- seq := kbdSequences at:#Delete ifAbsent:[ kbdSequences at:logicalKey ifAbsent:nil ].
+ seq := kbdSequences at:#Delete ifAbsent:[ kbdSequences at:aKey ifAbsent:nil ].
] ifFalse:[
- seq := kbdSequences at:logicalKey ifAbsent:nil.
+ seq := kbdSequences at:aKey ifAbsent:nil.
].
].
@@ -1033,11 +1041,11 @@
].
self sensor ctrlDown ifTrue:[
- (logicalKey startsWith:'Ctrl') ifTrue:[
- rawKey := logicalKey
+ (aKey startsWith:'Ctrl') ifTrue:[
+ rawKey := aKey
] ifFalse:[
"/ already translated - undo it.
-
+
event := WindowGroup lastEventQuerySignal query.
rawKey := event rawKey.
rawKey isCharacter ifTrue:[
@@ -1045,18 +1053,18 @@
]
]
] ifFalse:[
- rawKey := self keyboardMap bindingForLogical:logicalKey.
+ rawKey := self keyboardMap bindingForLogical:aKey.
rawKey isNil ifTrue:[
"/ Try aliases...
| rawKeys |
- rawKeys := self keyboardMap aliasesForLogical: logicalKey.
+ rawKeys := self keyboardMap aliasesForLogical: aKey.
rawKeys notEmpty ifTrue:[
rawKey := rawKeys anyOne.
].
].
rawKey isNil ifTrue:[
- rawKey := logicalKey
+ rawKey := aKey
].
].
@@ -1076,7 +1084,7 @@
"/ Thus, an application containing me can offer a menu function (or toggle), to control this behavior
"/ on the UI level.
- shortCut := device keyboardMap mappingFor:logicalKey.
+ shortCut := device keyboardMap mappingFor: aKey.
(shortCut notNil and:[shortCut isSymbol]) ifTrue:[
(sendControlKeys not or:[ self hasSelection or:[ shortCut == #Paste] ]) ifTrue:[
DebugKeyboard ifTrue:[
@@ -1127,7 +1135,7 @@
DebugKeyboard ifTrue:[
Transcript showCR:'CMD handled internal'.
].
- ^ super keyPress:logicalKey x:x y:y
+ ^ super keyPress:aKey x:x y:y
].
DebugKeyboard ifTrue:[
@@ -1140,6 +1148,7 @@
"Modified: / 25-01-2012 / 10:43:06 / cg"
"Modified: / 12-07-2017 / 09:39:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-08-2018 / 10:32:07 / Claus Gittinger"
!
keyPressInLineEditMode:aKey
@@ -1188,14 +1197,14 @@
lineBufferHistory isNil ifTrue:[
lineBufferHistory := OrderedCollection new.
].
- (lineBufferHistory size > 0 and:[lineBufferHistory last isEmpty]) ifTrue:[
+ (lineBufferHistory notEmpty and:[lineBufferHistory last isEmpty]) ifTrue:[
lineBufferHistory removeLast.
lineBufferHistoryChanged := true.
].
"/ do not remember blank lines
(lineBuffer notEmptyOrNil and:[lineBuffer isBlank not]) ifTrue:[
"/ do not remember repetitions
- (lineBufferHistory size > 0 and:[lineBufferHistory last = lineBuffer]) ifFalse:[
+ (lineBufferHistory notEmpty and:[lineBufferHistory last = lineBuffer]) ifFalse:[
lineBufferHistory addLast:lineBuffer.
lineBufferHistoryChanged := true.
].
@@ -1238,6 +1247,23 @@
self cursorToEndOfLine.
^ true.
].
+
+ aKey == #Ctrlr ifTrue:[
+ lineBufferHistory size >= lineBufferHistoryPosition ifTrue:[
+ lineBufferHistory at:lineBufferHistoryPosition put:lineBuffer.
+ ] ifFalse:[
+ lineBufferHistory add:lineBuffer.
+ ].
+
+ clearLine value.
+
+ lineBuffer := lineBufferHistory at:lineBufferHistoryPosition ifAbsent:[lineBufferHistory last].
+ self insertStringAtCursor:lineBuffer.
+ lineBufferCursorPosition := lineBuffer size + 1.
+ self makeCursorVisible.
+ ^ true.
+ ].
+
aKey == #CursorLeft ifTrue:[
lineBufferCursorPosition > 1 ifFalse:[
self beep.
@@ -1257,6 +1283,8 @@
^ true.
].
aKey == #CursorUp ifTrue:[
+ |p|
+
(lineBufferHistoryPosition notNil and:[lineBufferHistoryPosition > 1]) ifFalse:[
self beep.
^ true
@@ -1280,7 +1308,13 @@
lineBufferHistoryPosition := lineBufferHistoryPosition - 1.
].
"/ lastSelectedLineBufferHistoryPosition := lineBufferHistoryPosition.
- lineBuffer := lineBufferHistory at:lineBufferHistoryPosition ifAbsent:[lineBufferHistory last].
+ p := lineBufferHistoryPosition.
+ [
+ lineBuffer := lineBufferHistory at:p ifAbsent:[nil].
+ p := p - 1.
+ ] doUntil:[
+ p == 0 or:[ lineBuffer notEmptyOrNil ]
+ ].
self insertStringAtCursor:lineBuffer.
lineBufferCursorPosition := lineBuffer size + 1.
self makeCursorVisible.
@@ -1308,6 +1342,8 @@
].
^ false.
+ "Modified: / 03-05-2017 / 16:28:56 / cg"
+ "Modified: / 14-09-2018 / 17:01:39 / Stefan Vogel"
"Modified (format): / 21-01-2019 / 10:03:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
@@ -1870,7 +1906,7 @@
^ self.
].
- commandToStxPipe := NonPositionableExternalStream makePipe.
+ commandToStxPipe := PipeStream makePipe.
commandToStxPipe isNil ifTrue:[
self warn:(resources string:'Could not create pipe from COMMAND.COM.').
^ self.
@@ -1887,6 +1923,8 @@
outStream := commandToStxPipe at:1.
inStream := stxToCommandPipe at:2.
+ inStream setCommandString:'pty -> stx'.
+ outStream setCommandString:'pty <- stx'.
self defineWindowSize. "/ does not really work on windows (need help)
@@ -1895,7 +1933,7 @@
args := (shellAndArgs at:2) ? ''.
] ifFalse:[
"Use a pseudo-tty"
- pty := NonPositionableExternalStream makePTYPair.
+ pty := PipeStream makePTYPair.
pty isNil ifTrue:[
self warn:(resources string:'Cannot open pty.').
^ self.
@@ -1904,6 +1942,7 @@
"/ pty at:1 is the master;
"/ pty at:2 is the slave
inStream := outStream := (pty at:1).
+ inStream setCommandString:'pty'.
self defineWindowSize.
@@ -1978,6 +2017,10 @@
(stxToCommandPipe at:1) close.
].
+ "/ release those references - the monitor block still has a reference to this (home) context,
+ "/ helps the garbage collector
+ pty := slaveFD := execFdArray := stxToCommandPipe := commandToStxPipe := nil.
+
shellPid isNil ifTrue:[
self warn:(resources string:'Cannot start shell').
self closeStreams.
@@ -1986,6 +2029,7 @@
"Created: / 20-07-1998 / 18:19:32 / cg"
"Modified: / 17-07-2014 / 19:43:00 / cg"
+ "Modified: / 29-10-2018 / 17:52:22 / Claus Gittinger"
!
startCommand:aCommand
@@ -2093,6 +2137,19 @@
self sendTerminateSignal
!
+doSetLineLimit
+ "ask for the lineLimit (the number of buffered lines)"
+
+ |lineString n|
+
+ lineString := Dialog request:'Number of buffered lines:' initialAnswer:(self lineLimit asString).
+ lineString isEmptyOrNil ifTrue:[^ self].
+ n := Integer readFrom:lineString onError:[^ self].
+ self lineLimit:(n max:100).
+
+ "Created: / 01-05-2017 / 10:27:51 / cg"
+!
+
editMenu
"return the view's middleButtonMenu"
@@ -2108,13 +2165,28 @@
('-' )
('Clear' doClear )
('Reset' doReset )
+ ('-' )
+ ('Linebuffer Size...' doSetLineLimit )
).
+ lineEditMode == true ifTrue:[
+ items := items , #(
+ ('Disable Line Edit Mode' disableLineEditMode )
+ ).
+ ] ifFalse:[
+ items := items , #(
+ ('Enable Line Edit Mode' enableLineEditMode )
+ ).
+ ].
+
subMenu := PopUpMenu itemList:items resources:resources.
items := #(
('Open FileBrowser on It' openFileBrowserOnIt )
).
moreMenu := PopUpMenu itemList:items resources:resources.
+ shellDirectory isNil ifTrue:[
+ moreMenu disable:#openFileBrowserOnIt.
+ ].
((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[
m := subMenu.
@@ -2159,7 +2231,7 @@
].
^ m.
- "Modified: / 03-04-2007 / 08:58:26 / cg"
+ "Modified: / 01-05-2017 / 10:28:30 / cg"
!
openFileBrowserOnIt
@@ -2186,10 +2258,10 @@
OperatingSystem interruptProcess:shellPid.
"/ status := OperatingSystem childProcessWait:false pid:shellPid.
] ifFalse:[
- self warn:(resources string:'unimplemented for DOS')
+ 'TerminalView [info]: IRQ unimplemented for DOS' infoPrintCR.
]
] ifFalse:[
- 'VT100: no shell' infoPrintCR.
+ 'TerminalView [info]: no shell' infoPrintCR.
].
"Modified: / 10.6.1998 / 17:49:49 / cg"
@@ -2811,15 +2883,16 @@
readerProcess := nil
]
] fork. "/ forkAt:9.
- readerProcess name:'pty reader'.
+ readerProcess name:'Terminal: pty reader'.
]
"
VT100TerminalView openShell
"
- "Modified: / 5.5.1999 / 17:58:02 / cg"
- "Modified: / 28.1.2002 / 21:10:13 / micha"
+ "Modified: / 05-05-1999 / 17:58:02 / cg"
+ "Modified: / 28-01-2002 / 21:10:13 / micha"
+ "Modified: / 16-08-2018 / 13:22:32 / Claus Gittinger"
!
stopReaderProcess
--- a/VT100TerminalView.st Thu Feb 07 12:16:15 2019 +0000
+++ b/VT100TerminalView.st Mon May 20 13:55:48 2019 +0100
@@ -194,13 +194,13 @@
rgb := #(
#( 0 0 0 ) "/ black fg: ESC[30m / bg: ESC[40m
- #(170 0 0) "/ dark red
+ #(170 0 0) "/ dark red ESC[31m / bg: ESC[41m
#(0 170 0) "/ dark green
#(170 85 0) "/ dark yellow
#(0 0 170) "/ dark blue
#(170 0 170) "/ dark magenta
#(0 170 170 ) "/ dark cyan
- #(170 170 170) "/ dark white eg. light grey).
+ #(170 170 170) "/ dark white eg. light grey). ESC[37m / bg: ESC[47m
#( 85 85 85 ) "/ bright black eg. darkGray fg: ESC[90m / bg: ESC[100m
#(255 85 85) "/ bright red
@@ -209,12 +209,14 @@
#(85 85 255) "/ bright blue
#(255 85 255) "/ bright magenta
#(85 255 255 ) "/ bright cyan
- #(255 255 255) "/ white
+ #(255 255 255) "/ white ESC[97m / bg: ESC[107m
).
^ Color
perform: #'redByte:greenByte:blueByte:'
withArguments:(rgb at:(idx + (bright ifTrue:[8] ifFalse:[0]))).
+
+ "Modified (comment): / 30-05-2017 / 08:48:49 / cg"
!
vt100AlternativeKeyCodes
@@ -343,7 +345,8 @@
!
displayMode:p1
- "Set the current display mode (emphasis) as specified by param 1."
+ "ESC-[-<param1>-m
+ Set the current display mode (emphasis) as specified by param 1."
"/ self endEntry. -- not needed (does not affect characters on screen or buffered or cursor position
p1 == 0 ifTrue:[
@@ -499,8 +502,9 @@
"/ ESC-[-any-m -> normal
self normal.
- "Created: / 10.6.1998 / 15:01:16 / cg"
- "Modified: / 5.5.1999 / 00:53:15 / cg"
+ "Created: / 10-06-1998 / 15:01:16 / cg"
+ "Modified: / 05-05-1999 / 00:53:15 / cg"
+ "Modified (comment): / 30-05-2017 / 08:56:51 / cg"
!
doClearDisplay:arg
@@ -1123,27 +1127,31 @@
].
char == $c ifTrue:[
- "/ terminal-type query 3
+ "/ ESC[c - terminal-type query 3
self reportTerminalType.
^ #sequenceComplete
].
char == $d ifTrue:[
+ "/ ESC[d
self endEntry.
self moveToLine.
^ #sequenceComplete
].
char == $n ifTrue: [
+ "/ ESC[n
self report.
^ #sequenceComplete
].
char == $m ifTrue: [
- "/ character attributes (SGR)
+ "/ ESC[m - character attributes (SGR)
+ self endEntry.
1 to:currentParam do:[:pI |
self displayMode:(self getParameter:pI withDefault:0).
].
^ #sequenceComplete
].
char == $r ifTrue: [
+ "/ ESC[r
self endEntry.
self resetDefaults.
^ #sequenceComplete
@@ -1159,6 +1167,8 @@
^ #sequenceComplete
].
^ #unknown
+
+ "Modified: / 30-05-2017 / 09:24:50 / cg"
!
processStateGotESC:char