TerminalView.st
changeset 4612 e05d68f2d152
parent 4604 1ac8aff09094
child 4614 939148975344
equal deleted inserted replaced
4611:8c77f5d5a201 4612:e05d68f2d152
    19 		filterStream recorderStream localEcho translateNLToCRNL
    19 		filterStream recorderStream localEcho translateNLToCRNL
    20 		inputTranslateCRToNL inputTranslateCRToCRNL
    20 		inputTranslateCRToNL inputTranslateCRToCRNL
    21 		inputTranslateBackspaceToDelete autoWrapFlag masterWindow
    21 		inputTranslateBackspaceToDelete autoWrapFlag masterWindow
    22 		alternateKeypadMode noColors sizeOfOutstandingInputToBeProcessed
    22 		alternateKeypadMode noColors sizeOfOutstandingInputToBeProcessed
    23 		lineEditMode lineBuffer lineBufferCursorPosition
    23 		lineEditMode lineBuffer lineBufferCursorPosition
    24 		lineBufferHistory lineBufferHistoryPosition maxHistorySize'
    24 		lineBufferHistory lineBufferHistoryPosition maxHistorySize doUTF'
    25 	classVariableNames:'Debug DebugKeyboard DefaultMaxHistorySize'
    25 	classVariableNames:'Debug DebugKeyboard DefaultMaxHistorySize'
    26 	poolDictionaries:''
    26 	poolDictionaries:''
    27 	category:'Views-TerminalViews'
    27 	category:'Views-TerminalViews'
    28 !
    28 !
    29 
    29 
  1313     inputTranslateCRToNL := false.
  1313     inputTranslateCRToNL := false.
  1314     inputTranslateCRToCRNL := OperatingSystem isMSWINDOWSlike.
  1314     inputTranslateCRToCRNL := OperatingSystem isMSWINDOWSlike.
  1315     inputTranslateBackspaceToDelete := false.
  1315     inputTranslateBackspaceToDelete := false.
  1316     autoWrapFlag := true.
  1316     autoWrapFlag := true.
  1317     noColors := false.
  1317     noColors := false.
       
  1318     doUTF := UserPreferences current terminalOutputIsUTF8.
  1318     lineEditMode := OperatingSystem isMSWINDOWSlike.
  1319     lineEditMode := OperatingSystem isMSWINDOWSlike.
  1319     maxHistorySize := maxHistorySize ? DefaultMaxHistorySize.
  1320     maxHistorySize := maxHistorySize ? DefaultMaxHistorySize.
  1320 
  1321 
  1321     "/ cursorType := #block.
  1322     "/ cursorType := #block.
  1322     "/ cursorTypeNoFocus := #frame.
  1323     "/ cursorTypeNoFocus := #frame.
  1899      use of the inherited buffered output optimizations (see TextCollector).
  1900      use of the inherited buffered output optimizations (see TextCollector).
  1900      Thus, we collect until an escape sequence is encountered, and flush the buffered stuff then,
  1901      Thus, we collect until an escape sequence is encountered, and flush the buffered stuff then,
  1901      proceed in single-character mode (processState0:) until the sequence is finished, and continue
  1902      proceed in single-character mode (processState0:) until the sequence is finished, and continue
  1902      collecting.
  1903      collecting.
  1903      This makes this terminalView's speed usable and actually competitive with some existing
  1904      This makes this terminalView's speed usable and actually competitive with some existing
  1904      console applications (it is *much* faster than the MSWindows command.com window, btw.)"
  1905      console applications. 
       
  1906      BTW: It is *much* faster than the MSWindows command.com window,
       
  1907      - so much for the 'slow' Smalltalk ;-)"
  1905 
  1908 
  1906     |sensor|
  1909     |sensor|
  1907 
  1910 
  1908     "/ remember how much is in the queue...
  1911     "/ remember how much is in the queue...
  1909     [
  1912     [
  1976                     ]
  1979                     ]
  1977                 ].
  1980                 ].
  1978             ].
  1981             ].
  1979 
  1982 
  1980             stringWithOutControl notNil ifTrue:[
  1983             stringWithOutControl notNil ifTrue:[
       
  1984                 doUTF ifTrue:[ 
       
  1985                     stringWithOutControl := stringWithOutControl utf8Decoded
       
  1986                 ].
  1981                 (cursorCol + outstandingLine size + stringWithOutControl size) >= numberOfColumns ifTrue:[
  1987                 (cursorCol + outstandingLine size + stringWithOutControl size) >= numberOfColumns ifTrue:[
  1982                     "/ characterwise, for correct wrap handling at line end
  1988                     "/ characterwise, for correct wrap handling at line end
  1983                     stringWithOutControl do:[:eachCharacter |
  1989                     stringWithOutControl do:[:eachCharacter |
  1984                         self nextPut:eachCharacter.
  1990                         self nextPut:eachCharacter.
  1985                         self endEntry.
  1991                         self endEntry.
  2181                 self showCursor.
  2187                 self showCursor.
  2182                 (outStream isNil or:[outStream atEnd]) ifTrue:[ ex reject ].
  2188                 (outStream isNil or:[outStream atEnd]) ifTrue:[ ex reject ].
  2183             ] do:[
  2189             ] do:[
  2184                 |n sensor|
  2190                 |n sensor|
  2185 
  2191 
  2186                 Delay waitForSeconds:0.01.
  2192                 "/ Delay waitForSeconds:0.01.
  2187                 outStream readWait.
  2193                 outStream readWait.
  2188                 sensor := self sensor.
  2194                 sensor := self sensor.
  2189                 (sensor notNil and:[sensor hasKeyPressEventFor:self]) ifTrue:[
  2195                 (sensor notNil and:[sensor hasKeyPressEventFor:self]) ifTrue:[
  2190                     true "(sensor userEventCount > 10)" ifTrue:[
  2196                     true "(sensor userEventCount > 10)" ifTrue:[
  2191                         "/ give terminalView a chance to
  2197                         "/ give terminalView a chance to
  2201                         ]
  2207                         ]
  2202                     ] ifFalse:[
  2208                     ] ifFalse:[
  2203                         n == 0 ifTrue:[
  2209                         n == 0 ifTrue:[
  2204                             "/ Windows IPC has a bug - it always
  2210                             "/ Windows IPC has a bug - it always
  2205                             "/ returns 0 (when the command is idle)
  2211                             "/ returns 0 (when the command is idle)
  2206                             "/ and says its at the end (sigh)
  2212                             "/ and says it's at the end (sigh)
  2207 
  2213 
  2208                             OperatingSystem isMSWINDOWSlike ifTrue:[
  2214                             OperatingSystem isMSWINDOWSlike ifTrue:[
  2209                                 Delay waitForSeconds:0.01
  2215                                 Delay waitForSeconds:0.01
  2210                             ] ifFalse:[
  2216                             ] ifFalse:[
  2211                                 outStream atEnd ifTrue:[
  2217                                 outStream atEnd ifTrue:[
  2212                                     self closeStreams.
  2218                                     self closeStreams.
  2213                                     Processor activeProcess terminate.
  2219                                     Processor activeProcess terminate.
  2214                                 ] ifFalse:[
  2220                                 ] ifFalse:[
  2215                                     "/ this should not happen.
  2221                                     "/ this should not happen.
  2216 
       
  2217                                     Delay waitForSeconds:0.05
  2222                                     Delay waitForSeconds:0.05
  2218                                 ]
  2223                                 ]
  2219                             ].
  2224                             ].
  2220                         ]
  2225                         ]
  2221                     ]
  2226                     ]
  2244 
  2249 
  2245 startReaderProcessNow
  2250 startReaderProcessNow
  2246     "Start a reader process, which looks for the commands output,
  2251     "Start a reader process, which looks for the commands output,
  2247      and sends me #processInput:n: events whenever something arrives."
  2252      and sends me #processInput:n: events whenever something arrives."
  2248 
  2253 
       
  2254     self startReaderProcessWhenVisible:false
       
  2255 
       
  2256     "
       
  2257      VT100TerminalView openShell
       
  2258     "
       
  2259 
       
  2260     "Modified: / 5.5.1999 / 17:58:02 / cg"
       
  2261     "Modified: / 28.1.2002 / 21:10:13 / micha"
       
  2262 !
       
  2263 
       
  2264 startReaderProcessWhenVisible
       
  2265     "Start a reader process, which looks for the commands output,
       
  2266      and sends me #processInput:n: events whenever something arrives."
       
  2267 
       
  2268     self startReaderProcessWhenVisible:true
       
  2269 
       
  2270     "
       
  2271      VT100TerminalView openShell
       
  2272     "
       
  2273 
       
  2274     "Modified: / 5.5.1999 / 17:58:02 / cg"
       
  2275     "Modified: / 28.1.2002 / 21:10:13 / micha"
       
  2276 !
       
  2277 
       
  2278 startReaderProcessWhenVisible:whenVisible
       
  2279     "Start a reader process, which looks for the commands output,
       
  2280      and sends me #processInput:n: events whenever something arrives."
       
  2281 
  2249     readerProcess isNil ifTrue:[
  2282     readerProcess isNil ifTrue:[
  2250         readerProcess := [
  2283         readerProcess := [
  2251             [
  2284             [
  2252                 self readerProcessLoop.
  2285                 whenVisible ifTrue:[self waitUntilVisible].
  2253             ] ifCurtailed:[
       
  2254                 readerProcess := nil    
       
  2255             ]
       
  2256         ] fork. "/ forkAt:9.
       
  2257         readerProcess name:'pty reader'.
       
  2258     ]
       
  2259 
       
  2260     "
       
  2261      VT100TerminalView openShell
       
  2262     "
       
  2263 
       
  2264     "Modified: / 5.5.1999 / 17:58:02 / cg"
       
  2265     "Modified: / 28.1.2002 / 21:10:13 / micha"
       
  2266 !
       
  2267 
       
  2268 startReaderProcessWhenVisible
       
  2269     "Start a reader process, which looks for the commands output,
       
  2270      and sends me #processInput:n: events whenever something arrives."
       
  2271 
       
  2272     readerProcess isNil ifTrue:[
       
  2273         readerProcess := [
       
  2274             [
       
  2275                 self waitUntilVisible.
       
  2276                 self readerProcessLoop.
  2286                 self readerProcessLoop.
  2277             ] ifCurtailed:[
  2287             ] ifCurtailed:[
  2278                 readerProcess := nil    
  2288                 readerProcess := nil    
  2279             ]
  2289             ]
  2280         ] fork. "/ forkAt:9.
  2290         ] fork. "/ forkAt:9.
  2463 ! !
  2473 ! !
  2464 
  2474 
  2465 !TerminalView class methodsFor:'documentation'!
  2475 !TerminalView class methodsFor:'documentation'!
  2466 
  2476 
  2467 version
  2477 version
  2468     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.187 2014-06-03 07:55:24 cg Exp $'
  2478     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.188 2014-06-08 07:20:18 cg Exp $'
  2469 !
  2479 !
  2470 
  2480 
  2471 version_CVS
  2481 version_CVS
  2472     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.187 2014-06-03 07:55:24 cg Exp $'
  2482     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.188 2014-06-08 07:20:18 cg Exp $'
  2473 ! !
  2483 ! !
  2474 
  2484 
  2475 
  2485 
  2476 TerminalView initialize!
  2486 TerminalView initialize!