TerminalApplication.st
branchjv
changeset 13289 cc75e3cd0362
parent 13250 0decde6c459d
parent 13260 c3f318979431
child 15566 184cea584be5
equal deleted inserted replaced
13255:90f5185cb746 13289:cc75e3cd0362
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libtool' }"
    12 "{ Package: 'stx:libtool' }"
    13 
    13 
    14 MultiViewToolApplication subclass:#TerminalApplication
    14 MultiViewToolApplication subclass:#TerminalApplication
    15 	instanceVariableNames:'initialDirectory'
    15 	instanceVariableNames:'initialDirectory keepAlive keepAliveProcess'
    16 	classVariableNames:''
    16 	classVariableNames:''
    17 	poolDictionaries:''
    17 	poolDictionaries:''
    18 	category:'Interface-Smalltalk'
    18 	category:'Interface-Smalltalk'
    19 !
    19 !
    20 
    20 
   168                 )
   168                 )
   169                (MenuItem
   169                (MenuItem
   170                   label: 'Green'
   170                   label: 'Green'
   171                   itemValue: setGreenDisplayMode
   171                   itemValue: setGreenDisplayMode
   172                 )
   172                 )
       
   173                (MenuItem
       
   174                   label: 'Red'
       
   175                   itemValue: setRedDisplayMode
       
   176                 )
       
   177                (MenuItem
       
   178                   label: '-'
       
   179                 )
       
   180                (MenuItem
       
   181                   label: 'Ignore Text Color Commands'
       
   182                   indication: noColors:
       
   183                 )
   173                )
   184                )
   174               nil
   185               nil
   175               nil
   186               nil
   176             )
   187             )
   177           )
   188           )
   243                 )
   254                 )
   244                (MenuItem
   255                (MenuItem
   245                   label: '-'
   256                   label: '-'
   246                 )
   257                 )
   247                (MenuItem
   258                (MenuItem
       
   259                   label: 'Send "~." (ssh/telnet quit)'
       
   260                   itemValue: doSendTildeStop
       
   261                 )
       
   262                (MenuItem
       
   263                   label: 'Keep Connection Alive'
       
   264                   indication: keepSSHConnectionAliveHolder
       
   265                 )
       
   266                (MenuItem
       
   267                   label: '-'
       
   268                 )
       
   269                (MenuItem
   248                   label: 'Reset Terminal'
   270                   label: 'Reset Terminal'
   249                   itemValue: doReset
   271                   itemValue: doReset
   250                 )
   272                 )
   251                )
   273                )
   252               nil
   274               nil
   277           )
   299           )
   278          )
   300          )
   279         nil
   301         nil
   280         nil
   302         nil
   281       )
   303       )
       
   304 
       
   305     "Modified: / 30-07-2013 / 11:01:18 / cg"
   282 !
   306 !
   283 
   307 
   284 tabMenu
   308 tabMenu
   285     "This resource specification was automatically generated
   309     "This resource specification was automatically generated
   286      by the MenuEditor of ST/X."
   310      by the MenuEditor of ST/X."
   340 
   364 
   341     "
   365     "
   342      TerminalApplication open
   366      TerminalApplication open
   343      TerminalApplication openIn:'/etc'
   367      TerminalApplication openIn:'/etc'
   344     "
   368     "
       
   369 ! !
       
   370 
       
   371 !TerminalApplication methodsFor:'aspects'!
       
   372 
       
   373 keepSSHConnectionAliveHolder
       
   374     keepAlive isNil ifTrue:[
       
   375         keepAlive := false asValue.
       
   376         keepAlive onChangeSend:#keepSSHConnectionAliveHolderChanged to:self.
       
   377     ].
       
   378     ^ keepAlive
       
   379 
       
   380     "Created: / 30-07-2013 / 07:51:59 / cg"
   345 ! !
   381 ! !
   346 
   382 
   347 !TerminalApplication methodsFor:'menu-actions'!
   383 !TerminalApplication methodsFor:'menu-actions'!
   348 
   384 
   349 addWorkspace
   385 addWorkspace
   392 
   428 
   393 doSendKillSignal
   429 doSendKillSignal
   394     self selectedWorkspacesTextView doSendKillSignal.
   430     self selectedWorkspacesTextView doSendKillSignal.
   395 !
   431 !
   396 
   432 
       
   433 doSendTildeStop
       
   434     self selectedWorkspacesTextView send:'~.'.
       
   435 
       
   436     "Created: / 29-07-2013 / 18:20:36 / cg"
       
   437 !
       
   438 
       
   439 keepSSHConnectionAliveHolderChanged
       
   440     keepAlive value ifTrue:[
       
   441         self startKeepAliveProcess
       
   442     ] ifFalse:[
       
   443         self stopKeepAliveProcess
       
   444     ]
       
   445 
       
   446     "Created: / 30-07-2013 / 07:53:12 / cg"
       
   447 !
       
   448 
   397 menuPlayback
   449 menuPlayback
   398     |file suff|
   450     |file suff|
   399 
   451 
   400     suff := 'sh'.
   452     suff := 'sh'.
   401 
   453 
   404     file size > 0 ifTrue:[
   456     file size > 0 ifTrue:[
   405         self playbackFile:file
   457         self playbackFile:file
   406     ]
   458     ]
   407 !
   459 !
   408 
   460 
       
   461 noColors
       
   462     ^ self selectedWorkspacesTextView noColors
       
   463 !
       
   464 
       
   465 noColors:aBoolean
       
   466     self selectedWorkspacesTextView noColors:aBoolean.
       
   467 !
       
   468 
   409 openDocumentation
   469 openDocumentation
   410     "opens the documentation file"
   470     "opens the documentation file"
   411 
   471 
   412     self openHTMLDocument: 'tools/misc/TOP.html#TERMINAL'
   472     self openHTMLDocument: 'tools/misc/TOP.html#TERMINAL'
   413 !
   473 !
   432 
   492 
   433 setNormalDisplayMode
   493 setNormalDisplayMode
   434     self selectedWorkspacesTextView setNormalDisplayMode.
   494     self selectedWorkspacesTextView setNormalDisplayMode.
   435 !
   495 !
   436 
   496 
       
   497 setRedDisplayMode
       
   498     self selectedWorkspacesTextView setRedDisplayMode.
       
   499 !
       
   500 
   437 setReverseDisplayMode
   501 setReverseDisplayMode
   438     self selectedWorkspacesTextView setReverseDisplayMode.
   502     self selectedWorkspacesTextView setReverseDisplayMode.
   439 ! !
   503 ! !
   440 
   504 
   441 !TerminalApplication methodsFor:'private'!
   505 !TerminalApplication methodsFor:'private'!
   442 
   506 
   443 isModifiedWorkspace:aView
   507 isModifiedWorkspace:aView
   444     ^ false
   508     ^ false
       
   509 !
       
   510 
       
   511 startKeepAliveProcess
       
   512     "keep alive, by sending a return from time to time.
       
   513      Raise to top, if connection is lost"
       
   514 
       
   515     keepAliveProcess isNil ifTrue:[
       
   516         keepAliveProcess :=
       
   517             [
       
   518                 [true] whileTrue:[
       
   519                     self selectedWorkspacesTextView sendCR:''.
       
   520                     Delay waitForSeconds:30.
       
   521                 ].
       
   522             ] newProcess.
       
   523         keepAliveProcess resume.
       
   524     ].
       
   525 
       
   526     "Created: / 30-07-2013 / 09:14:36 / cg"
       
   527 !
       
   528 
       
   529 stopKeepAliveProcess
       
   530     |p|
       
   531 
       
   532     (p := keepAliveProcess) notNil ifTrue:[
       
   533         keepAliveProcess := nil.
       
   534         p terminate
       
   535     ].
       
   536 
       
   537     "Created: / 30-07-2013 / 09:15:05 / cg"
   445 ! !
   538 ! !
   446 
   539 
   447 !TerminalApplication methodsFor:'startup'!
   540 !TerminalApplication methodsFor:'startup'!
       
   541 
       
   542 startShellInSelectedWindow
       
   543     |vt|
       
   544 
       
   545     vt := self selectedWorkspacesTextView.
       
   546     (vt notNil and:[vt superView realized]) ifFalse:[
       
   547         self window sensor pushUserEvent:#startShellInSelectedWindow for:self.
       
   548         ^ self.
       
   549     ].
       
   550 
       
   551     vt startShellIn:initialDirectory.
       
   552     vt shellTerminateAction:[self shellFinishedInWorkspace:vt].
       
   553     vt masterWindow:(self window).  "/ to change window title
       
   554 
       
   555     "Modified: / 07-04-2011 / 09:03:55 / cg"
       
   556     "Modified: / 03-04-2012 / 10:31:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   557 ! !
       
   558 
       
   559 !TerminalApplication methodsFor:'startup & release'!
   448 
   560 
   449 initialDirectory:aDirectory
   561 initialDirectory:aDirectory
   450     initialDirectory := aDirectory
   562     initialDirectory := aDirectory
   451 !
   563 !
   452 
   564 
   461 !
   573 !
   462 
   574 
   463 postOpenWith:aBuilder
   575 postOpenWith:aBuilder
   464     self startShellInSelectedWindow.
   576     self startShellInSelectedWindow.
   465     super postOpenWith:aBuilder
   577     super postOpenWith:aBuilder
       
   578 !
       
   579 
       
   580 release
       
   581     self stopKeepAliveProcess.
       
   582     super release.
       
   583 
       
   584     "Created: / 30-07-2013 / 07:54:16 / cg"
   466 !
   585 !
   467 
   586 
   468 shellFinishedInWorkspace:aView
   587 shellFinishedInWorkspace:aView
   469     "/ vt backgroundColor:(Color red).
   588     "/ vt backgroundColor:(Color red).
   470     aView 
   589     aView 
   471         cr; 
   590         cr; 
   472         nextPutLine:('>> shell terminated.' asText allBold colorizeAllWith:Color red).
   591         nextPutLine:('>> shell terminated.' asText allBold colorizeAllWith:Color red).
   473 !
       
   474 
       
   475 startShellInSelectedWindow
       
   476     |vt|
       
   477 
       
   478     vt := self selectedWorkspacesTextView.
       
   479     (vt notNil and:[vt superView realized]) ifFalse:[
       
   480         self window sensor pushUserEvent:#startShellInSelectedWindow for:self.
       
   481         ^ self.
       
   482     ].
       
   483 
       
   484     vt startShellIn:initialDirectory.
       
   485     vt shellTerminateAction:[self shellFinishedInWorkspace:vt].
       
   486     vt masterWindow:(self window).  "/ to change window title
       
   487 
       
   488     "Modified: / 07-04-2011 / 09:03:55 / cg"
       
   489     "Modified: / 03-04-2012 / 10:31:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   490 ! !
   592 ! !
   491 
   593 
   492 !TerminalApplication class methodsFor:'documentation'!
   594 !TerminalApplication class methodsFor:'documentation'!
   493 
   595 
       
   596 version
       
   597     ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.19 2013-07-30 09:02:01 cg Exp $'
       
   598 !
       
   599 
   494 version_CVS
   600 version_CVS
   495     ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.13 2013-07-23 21:08:55 cg Exp $'
   601     ^ '$Header: /cvs/stx/stx/libtool/TerminalApplication.st,v 1.19 2013-07-30 09:02:01 cg Exp $'
   496 !
   602 !
   497 
   603 
   498 version_HG
   604 version_HG
   499 
   605 
   500     ^ '$Changeset: <not expanded> $'
   606     ^ '$Changeset: <not expanded> $'