TerminalView.st
changeset 4604 1ac8aff09094
parent 4603 e6736a82809f
child 4612 e05d68f2d152
equal deleted inserted replaced
4603:e6736a82809f 4604:1ac8aff09094
    15 	instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences
    15 	instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences
    16 		escapeSequenceTree currentSequence kbdMap escapeLeadingChars
    16 		escapeSequenceTree currentSequence kbdMap escapeLeadingChars
    17 		numberOfColumns numberOfLines shellTerminateAction rangeStartLine
    17 		numberOfColumns numberOfLines shellTerminateAction rangeStartLine
    18 		rangeEndLine state savedCursor shellCommand shellDirectory
    18 		rangeEndLine state savedCursor shellCommand shellDirectory
    19 		filterStream recorderStream localEcho translateNLToCRNL
    19 		filterStream recorderStream localEcho translateNLToCRNL
    20 		inputTranslateCRToNL inputTranslateBackspaceToDelete autoWrapFlag
    20 		inputTranslateCRToNL inputTranslateCRToCRNL
    21 		masterWindow alternateKeypadMode noColors
    21 		inputTranslateBackspaceToDelete autoWrapFlag masterWindow
    22 		sizeOfOutstandingInputToBeProcessed lineEditMode lineBuffer
    22 		alternateKeypadMode noColors sizeOfOutstandingInputToBeProcessed
    23 		lineBufferCursorPosition lineBufferHistory
    23 		lineEditMode lineBuffer lineBufferCursorPosition
    24 		lineBufferHistoryPosition maxHistorySize'
    24 		lineBufferHistory lineBufferHistoryPosition maxHistorySize'
    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 
   859         "/ as the pty is in echo mode,
   859         "/ as the pty is in echo mode,
   860         "/ we should either disable echo for the following,
   860         "/ we should either disable echo for the following,
   861         "/ or remove from the textview and let the program redraw them.
   861         "/ or remove from the textview and let the program redraw them.
   862         "/ the second alternative looks easier for now...
   862         "/ the second alternative looks easier for now...
   863         clearLine value.
   863         clearLine value.
   864 
   864         self sendCR:lineBuffer.
   865         lineBuffer do:[:ch |
   865 
   866             self sendCharacter:ch.
       
   867         ].
       
   868         inputTranslateCRToNL ifTrue:[
       
   869             self sendCharacter:(Character nl).
       
   870         ] ifFalse:[
       
   871             self sendCharacter:(Character return).
       
   872         ].
       
   873         lineBufferHistory isNil ifTrue:[
   866         lineBufferHistory isNil ifTrue:[
   874             lineBufferHistory := OrderedCollection new.
   867             lineBufferHistory := OrderedCollection new.
   875         ].
   868         ].
   876         (lineBufferHistory size > 0 and:[lineBufferHistory last isEmpty]) ifTrue:[
   869         (lineBufferHistory size > 0 and:[lineBufferHistory last isEmpty]) ifTrue:[
   877             lineBufferHistory removeLast
   870             lineBufferHistory removeLast
  1316     sizeOfOutstandingInputToBeProcessed := 0.
  1309     sizeOfOutstandingInputToBeProcessed := 0.
  1317     st80Mode := false.
  1310     st80Mode := false.
  1318     trimBlankLines := true.
  1311     trimBlankLines := true.
  1319     localEcho := false.
  1312     localEcho := false.
  1320     inputTranslateCRToNL := false.
  1313     inputTranslateCRToNL := false.
       
  1314     inputTranslateCRToCRNL := OperatingSystem isMSWINDOWSlike.
  1321     inputTranslateBackspaceToDelete := false.
  1315     inputTranslateBackspaceToDelete := false.
  1322     autoWrapFlag := true.
  1316     autoWrapFlag := true.
  1323     noColors := false.
  1317     noColors := false.
  1324     lineEditMode := false.
  1318     lineEditMode := OperatingSystem isMSWINDOWSlike.
  1325     maxHistorySize := maxHistorySize ? DefaultMaxHistorySize.
  1319     maxHistorySize := maxHistorySize ? DefaultMaxHistorySize.
  1326 
  1320 
  1327     "/ cursorType := #block.
  1321     "/ cursorType := #block.
  1328     "/ cursorTypeNoFocus := #frame.
  1322     "/ cursorTypeNoFocus := #frame.
  1329 
  1323 
  1819 
  1813 
  1820 !TerminalView methodsFor:'misc'!
  1814 !TerminalView methodsFor:'misc'!
  1821 
  1815 
  1822 removeTrailingBlankLines
  1816 removeTrailingBlankLines
  1823     ^ self
  1817     ^ self
  1824 !
       
  1825 
       
  1826 send:aString
       
  1827     "send aString to the underlying program's stdinput"
       
  1828 
       
  1829     aString notEmptyOrNil ifTrue:[
       
  1830         recorderStream notNil ifTrue:[
       
  1831             recorderStream nextPutAll:aString
       
  1832         ].
       
  1833         Debug == true ifTrue:[
       
  1834             Transcript showCR:'send <',aString,'>'
       
  1835         ].
       
  1836         inStream nextPutAll:aString
       
  1837     ].
       
  1838 
       
  1839     "Created: / 29-07-2013 / 18:18:24 / cg"
       
  1840 !
       
  1841 
       
  1842 sendCR:aString
       
  1843     "send aString followed by a return to the underlying program's stdinput"
       
  1844 
       
  1845     self send:aString.
       
  1846     inputTranslateCRToNL ifTrue:[
       
  1847         self send:(String lf)
       
  1848     ] ifFalse:[
       
  1849         self send:(String cr)
       
  1850     ]
       
  1851 
       
  1852     "Created: / 29-07-2013 / 18:20:15 / cg"
       
  1853 !
       
  1854 
       
  1855 sendCharacter:aCharacter
       
  1856     "send a single character to the underlying program's stdinput"
       
  1857 
       
  1858     aCharacter bitsPerCharacter > 8 ifTrue:[
       
  1859         Transcript showCR:(self class name,': invalid (non-8bit) character ignored').
       
  1860         ^ self
       
  1861     ].
       
  1862 
       
  1863     recorderStream notNil ifTrue:[
       
  1864         recorderStream nextPut:aCharacter
       
  1865     ].
       
  1866     Debug == true ifTrue:[
       
  1867         Transcript showCR:'send <',aCharacter,'>'
       
  1868     ].
       
  1869 
       
  1870     inStream nextPut:aCharacter.
       
  1871 
       
  1872     "Created: / 29-07-2013 / 18:18:24 / cg"
       
  1873 ! !
  1818 ! !
  1874 
  1819 
  1875 !TerminalView methodsFor:'processing-input'!
  1820 !TerminalView methodsFor:'processing-input'!
  1876 
  1821 
  1877 doNothing
  1822 doNothing
  2133     "Created: / 10-06-1998 / 17:26:09 / cg"
  2078     "Created: / 10-06-1998 / 17:26:09 / cg"
  2134     "Modified: / 28-01-2002 / 20:41:36 / micha"
  2079     "Modified: / 28-01-2002 / 20:41:36 / micha"
  2135     "Modified: / 30-07-2013 / 10:47:19 / cg"
  2080     "Modified: / 30-07-2013 / 10:47:19 / cg"
  2136 !
  2081 !
  2137 
  2082 
  2138 sendLine:aString
       
  2139     Debug ifTrue:[
       
  2140         'VT100: sendline: ' print. aString asByteArray hexPrintString printCR
       
  2141     ].
       
  2142 
       
  2143     self send:aString.
       
  2144     self sendLineEnd
       
  2145 !
       
  2146 
       
  2147 sendLineEnd
       
  2148     OperatingSystem isMSDOSlike ifTrue:[
       
  2149         self send:String crlf.
       
  2150     ] ifFalse:[
       
  2151         self send:String cr.
       
  2152     ].
       
  2153 !
       
  2154 
       
  2155 sync
  2083 sync
  2156     self waitForOutputToDrain
  2084     self waitForOutputToDrain
  2157 
  2085 
  2158     "Created: / 27.7.1998 / 23:49:44 / cg"
  2086     "Created: / 27.7.1998 / 23:49:44 / cg"
  2159 !
  2087 !
  2460         ].
  2388         ].
  2461     ].
  2389     ].
  2462     ^ StringCollection with:(sel asStringWith:'').
  2390     ^ StringCollection with:(sel asStringWith:'').
  2463 ! !
  2391 ! !
  2464 
  2392 
       
  2393 !TerminalView methodsFor:'sending'!
       
  2394 
       
  2395 send:aString
       
  2396     "send aString to the underlying program's stdinput"
       
  2397 
       
  2398     aString notEmptyOrNil ifTrue:[
       
  2399         recorderStream notNil ifTrue:[
       
  2400             recorderStream nextPutAll:aString
       
  2401         ].
       
  2402         Debug == true ifTrue:[
       
  2403             Transcript showCR:'send <',aString,'>'
       
  2404         ].
       
  2405         inStream nextPutAll:aString
       
  2406     ].
       
  2407 
       
  2408     "Created: / 29-07-2013 / 18:18:24 / cg"
       
  2409 !
       
  2410 
       
  2411 sendCR:aString
       
  2412     "send aString followed by a return to the underlying program's stdinput"
       
  2413 
       
  2414     self send:aString.
       
  2415     inputTranslateCRToNL ifTrue:[
       
  2416         self sendCharacter:(Character nl).
       
  2417     ] ifFalse:[
       
  2418         inputTranslateCRToCRNL ifTrue:[
       
  2419             self send:(String crlf).
       
  2420         ] ifFalse:[
       
  2421             self sendCharacter:(Character return).
       
  2422         ]
       
  2423     ]
       
  2424 
       
  2425     "Created: / 29-07-2013 / 18:20:15 / cg"
       
  2426 !
       
  2427 
       
  2428 sendCharacter:aCharacter
       
  2429     "send a single character to the underlying program's stdinput"
       
  2430 
       
  2431     aCharacter bitsPerCharacter > 8 ifTrue:[
       
  2432         Transcript showCR:(self class name,': invalid (non-8bit) character ignored').
       
  2433         ^ self
       
  2434     ].
       
  2435 
       
  2436     recorderStream notNil ifTrue:[
       
  2437         recorderStream nextPut:aCharacter
       
  2438     ].
       
  2439     Debug == true ifTrue:[
       
  2440         Transcript showCR:'send <',aCharacter,'>'
       
  2441     ].
       
  2442 
       
  2443     inStream nextPut:aCharacter.
       
  2444 
       
  2445     "Created: / 29-07-2013 / 18:18:24 / cg"
       
  2446 !
       
  2447 
       
  2448 sendLine:aString
       
  2449     Debug ifTrue:[
       
  2450         'VT100: sendline: ' print. aString asByteArray hexPrintString printCR
       
  2451     ].
       
  2452 
       
  2453     self send:aString.
       
  2454     self sendLineEnd
       
  2455 !
       
  2456 
       
  2457 sendLineEnd
       
  2458     OperatingSystem isMSDOSlike ifTrue:[
       
  2459         self send:String crlf.
       
  2460     ] ifFalse:[
       
  2461         self send:String cr.
       
  2462     ].
       
  2463 ! !
       
  2464 
  2465 !TerminalView class methodsFor:'documentation'!
  2465 !TerminalView class methodsFor:'documentation'!
  2466 
  2466 
  2467 version
  2467 version
  2468     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.186 2014-06-02 13:20:36 cg Exp $'
  2468     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.187 2014-06-03 07:55:24 cg Exp $'
  2469 !
  2469 !
  2470 
  2470 
  2471 version_CVS
  2471 version_CVS
  2472     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.186 2014-06-02 13:20:36 cg Exp $'
  2472     ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.187 2014-06-03 07:55:24 cg Exp $'
  2473 ! !
  2473 ! !
  2474 
  2474 
  2475 
  2475 
  2476 TerminalView initialize!
  2476 TerminalView initialize!