TerminalView.st
author Michael Beyl <mb@exept.de>
Mon, 28 Jan 2002 21:08:59 +0100
changeset 2076 60558bc12d09
parent 2075 ac7da2b56ba6
child 2077 07bd67026b81
permissions -rw-r--r--
public access to filterStream; translateNLToCRNL flag added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
     1
"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
     2
 COPYRIGHT (c) 1998 by eXept Software AG
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
     3
              All Rights Reserved
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
     4
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
     5
 This software is furnished under a license and may be used
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
     6
 only in accordance with the terms of that license and with the
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
     8
 be provided or otherwise made available to, or used by, any
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
     9
 other person.  No title to or ownership of the software is
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    10
 hereby transferred.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    11
"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    12
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    13
1833
69a0c170cd80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1485
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
69a0c170cd80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1485
diff changeset
    15
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
TextCollector subclass:#TerminalView
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
    17
	instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
    18
		escapeSequenceTree currentSequence kbdMap escapeLeadingChars
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
    19
		numberOfColumns numberOfLines shellTerminateAction rangeStartLine
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
    20
		rangeEndLine state savedCursor shellCommand shellDirectory
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
    21
		filterStream localEcho translateNLToCRNL'
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
    22
	classVariableNames:''
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
    23
	poolDictionaries:''
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
    24
	category:'Views-TerminalViews'
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!TerminalView class methodsFor:'documentation'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    29
copyright
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    30
"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    31
 COPYRIGHT (c) 1998 by eXept Software AG
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    32
              All Rights Reserved
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    33
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    34
 This software is furnished under a license and may be used
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    35
 only in accordance with the terms of that license and with the
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    36
 inclusion of the above copyright notice.   This software may not
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    37
 be provided or otherwise made available to, or used by, any
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    38
 other person.  No title to or ownership of the software is
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    39
 hereby transferred.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    40
"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    41
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    42
!
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    43
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
documentation
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    46
    I provide terminal functionality, by interpreting data
1418
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    47
    arriving from some stream (typically connected to a command interpreter 
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    48
    via a pty, or another system via a modem) 
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    49
    and sending my keyboard data to it.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    50
1418
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    51
    I am abstract providing general functionality
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    52
    - concrete terminal characteristics are defined by concrete subclasses 
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    53
    (see VT52TerminalView, VT100TerminalView).
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    54
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    55
    Concrete applications are: 
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    56
        consoles (VT100TerminalView),
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    57
        telnet-views (see TelnetTool)
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    58
        editor wrappers (if you like emacs/vi)
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
1418
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    60
    <<although my class protocol includes common startup protocol
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    61
    (to open a terminalView with a shell or on the output of a command),
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    62
    I can be used as a widget within an application (Modem software).
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    63
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    [author:]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
        Claus Gittinger
915
f2c934efc4da checkin from browser
Claus Gittinger <cg@exept.de>
parents: 914
diff changeset
    66
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    67
    [instance variables:]
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    68
        inStream                stream where keyboard input is
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    69
                                sent to (connected to shells or commands input)
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    70
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    71
        outStream               stream where the output of the
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    72
                                shell or command arrives
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    73
                                (read here and displayed in the view)
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    74
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    75
        readerProcess           process which reads commands    
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    76
                                output and sends it to the view
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    77
915
f2c934efc4da checkin from browser
Claus Gittinger <cg@exept.de>
parents: 914
diff changeset
    78
    [start with:]
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    79
        VT52TerminalView open
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    80
        VT100TerminalView open
915
f2c934efc4da checkin from browser
Claus Gittinger <cg@exept.de>
parents: 914
diff changeset
    81
        VT52TerminalView openShell
919
07e8c17563a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
    82
        VT100TerminalView openShell
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    83
        VT100TerminalView openOnCommand:'ls -l'
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    84
        VT100TerminalView openOnCommand:'dir'
1418
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    85
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    86
    [see also:]
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    87
        TelNetTool
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
1052
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    91
!TerminalView class methodsFor:'defaults'!
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    92
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    93
defaultIcon
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    94
    ^ Image fromFile:'bitmaps/xpmBitmaps/terminal_images/xterm-icon.xpm'
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    95
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    96
    "Created: / 4.8.1998 / 17:48:18 / cg"
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    97
    "Modified: / 4.8.1998 / 17:48:31 / cg"
1317
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
    98
!
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
    99
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   100
defaultNumberOfColumns
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   101
    ^ 80
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   102
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   103
    "Created: / 4.8.1998 / 17:48:18 / cg"
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   104
    "Modified: / 4.8.1998 / 17:48:31 / cg"
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   105
!
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   106
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   107
defaultNumberOfLines
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   108
    ^ 25
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   109
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   110
    "Created: / 4.8.1998 / 17:48:18 / cg"
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   111
    "Modified: / 4.8.1998 / 17:48:31 / cg"
1052
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   112
! !
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   113
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   114
!TerminalView class methodsFor:'opening'!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
928
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   116
open
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   117
    ^ self openShell
928
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   118
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   119
    "
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   120
     VT100TerminalView open
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   121
    "
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   122
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   123
    "Created: / 10.6.1998 / 15:47:25 / cg"
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   124
    "Modified: / 9.7.1998 / 17:55:37 / cg"
928
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   125
!
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   126
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
openDummy
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   128
    "for testing purposes only - opens a dummy tty-view, which simply
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   129
     echoes whatever is typed in"
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   130
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    |in vt52|
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    vt52 := self new.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    in := ForwardingStream on:''.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    in fwdStream:vt52.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    vt52 inStream:in.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    vt52 outStream:in.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    vt52 open
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    "
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
     self openDummy
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    "
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   146
openOnCommand:aCommandString
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   147
    "start a command on a pseudo-TTY, open a terminalView on it
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   148
     (i.e. this is kind of an xterm)"
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   149
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   150
    ^ self openOnCommand:aCommandString onExit:[]
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   151
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   152
    "
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   153
     VT100TerminalView openOnCommand:'ls -l'
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   154
    "
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   155
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   156
    "Created: / 9.7.1998 / 17:50:53 / cg"
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   157
    "Modified: / 9.7.1998 / 17:57:41 / cg"
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   158
!
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   159
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   160
openOnCommand:aCommandString onExit:aBlock
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   161
    "start a command on a pseudo-TTY, open a terminalView on its output
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   162
     (i.e. this is kind of an xterm).
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   163
     When the command finishes, evaluate aBlock."
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   164
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   165
    |in top scr vt52|
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   166
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   167
    top := StandardSystemView new.
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   168
    scr := ScrollableView for:self in:top.
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   169
    scr origin:0.0@0.0 corner:1.0@1.0.
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   170
    vt52 := scr scrolledView.
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   171
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   172
    vt52 startCommand:aCommandString.
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   173
    vt52 shellTerminateAction:[
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   174
        top label:('finished: "' , aCommandString , '"'). aBlock value
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   175
    ].
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   176
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   177
    top extent:(scr preferredExtent).
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   178
    top label:('executing: "' , aCommandString , '"').
1014
c0fdd428990c nice icon.
Claus Gittinger <cg@exept.de>
parents: 1009
diff changeset
   179
    top iconLabel:'command'.
1052
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   180
    top icon:(self defaultIcon).
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   181
    top open.
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   182
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   183
    ^ vt52
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   184
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   185
    "
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   186
     VT100TerminalView openOnCommand:'ls -lR'
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   187
     VT100TerminalView openOnCommand:'vi /etc/hosts'
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   188
    "
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   189
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   190
    "Created: / 9.7.1998 / 17:54:34 / cg"
1052
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   191
    "Modified: / 4.8.1998 / 17:49:02 / cg"
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   192
!
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   193
1014
c0fdd428990c nice icon.
Claus Gittinger <cg@exept.de>
parents: 1009
diff changeset
   194
openOnInput:inStream output:outStream
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   195
    "open a terminalView on the given streams (which are typically some
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   196
     kind of socket or pty). 
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   197
     Keys pressed are sent to inStream, text appearing
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   198
     from outStream is displayed in the terminal view.
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   199
     This can be used to implement things like rlogin
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   200
     or telnet views (if connected to a modem, a com-program can also be
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   201
     implemented this way)."
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   202
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   203
    |in top scr vt|
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   204
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   205
    top := StandardSystemView new.
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   206
    scr := ScrollableView for:self in:top.
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   207
    scr origin:0.0@0.0 corner:1.0@1.0.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   208
    vt := scr scrolledView.
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   209
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   210
    vt inStream:inStream.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   211
    vt outStream:outStream.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   212
    vt startReaderProcess.
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   213
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   214
    top extent:(scr preferredExtent).
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   215
    top label:'shell'.
1014
c0fdd428990c nice icon.
Claus Gittinger <cg@exept.de>
parents: 1009
diff changeset
   216
    top iconLabel:'shell'.
1052
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   217
    top icon:(self defaultIcon).
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   218
    top open.
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   219
    ^ top
974
f47cf9925f7a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
   220
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   221
    "Modified: / 5.5.1999 / 17:25:59 / cg"
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   222
!
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   223
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
openShell
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   225
    "start a shell on a pseudo-TTY, open a terminalView on it
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   226
     (i.e. this is kind of an xterm)"
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   227
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
   228
    ^ self openShellIn:nil
992
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   229
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   230
    "
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   231
     VT100TerminalView openShell
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   232
    "
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   233
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
   234
    "Modified: / 21.7.1998 / 18:24:55 / cg"
992
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   235
!
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   236
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   237
openShellIn:aDirectory
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   238
    "start a shell on a pseudo-TTY, open a terminalView on it
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   239
     (i.e. this is kind of an xterm)"
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   240
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   241
    |in top scr vt lbl|
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    top := StandardSystemView new.
948
b93aba7db15d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
   244
    scr := ScrollableView for:self in:top.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    scr origin:0.0@0.0 corner:1.0@1.0.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   246
    vt := scr scrolledView.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   247
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   248
    vt startShellIn:aDirectory.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   249
    vt shellTerminateAction:[top destroy].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   251
    lbl := OperatingSystem isUNIXlike ifTrue:['shell'] ifFalse:['dos'].
940
16c955286510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
   252
    top extent:(scr preferredExtent).
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   253
    top label:lbl.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   254
    top iconLabel:lbl.
1052
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   255
    top icon:(self defaultIcon).
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   256
    top open.
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   257
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   258
    ^ vt
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    "
992
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   261
     VT100TerminalView openShellIn:'/etc'
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    "
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   263
992
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   264
    "Created: / 20.7.1998 / 18:28:15 / cg"
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   265
    "Modified: / 5.5.1999 / 17:27:10 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   268
!TerminalView class methodsFor:'queries'!
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   269
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   270
isVisualStartable
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   271
    "returns whether this application class can be started via #open"
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   272
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   273
    self == TerminalView ifTrue:[^ false].
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   274
    ^ true
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   275
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   276
    "Created: / 10.6.1998 / 15:48:43 / cg"
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   277
! !
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   278
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
!TerminalView methodsFor:'accessing'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   281
filterStream:something
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   282
    "set a filter stream; if not nil, it gets all incoming data via nextPutAll:.
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   283
     (added to allow saving incoming data to a file, but can also be used to catch/filter/lookAt
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   284
      incoming data by some other program)"
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   285
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   286
    filterStream := something.
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   287
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   288
    "Created: / 28.1.2002 / 20:56:04 / micha"
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   289
    "Modified: / 28.1.2002 / 20:56:11 / micha"
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   290
!
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   291
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
inStream
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
    "return the value of the instance variable 'inStream' (automatically generated)"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   295
    ^ inStream
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   296
!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
inStream:something
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
    "set the value of the instance variable 'inStream' (automatically generated)"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   301
    inStream := something.
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   302
!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   304
localEcho:aBoolean
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   305
    "enable/disable local echo"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   306
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   307
    localEcho := aBoolean
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   308
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   309
    "Created: / 5.5.1999 / 17:53:16 / cg"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   310
!
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   311
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
outStream
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
    "return the value of the instance variable 'outStream' (automatically generated)"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   315
    ^ outStream
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   316
!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
outStream:something
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
    "set the value of the instance variable 'outStream' (automatically generated)"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   321
    outStream := something.
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   322
!
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   323
1004
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   324
readerProcess
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   325
    "return the value of the instance variable 'readerProcess' (automatically generated)"
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   326
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   327
    ^ readerProcess
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   328
!
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   329
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   330
shellTerminateAction:aBlock
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   331
    "set the block which is evaluated when the shell terminates.
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   332
     Can be used to close down the application in this case."
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   333
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   334
    shellTerminateAction := aBlock.
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   335
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   336
    "Created: / 12.6.1998 / 17:02:58 / cg"
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   337
!
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   338
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   339
translateNLToCRNL
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   340
    "return the value of the instance variable 'translateNLToCRNL' (automatically generated)"
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   341
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   342
    ^ translateNLToCRNL
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   343
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   344
    "Created: / 28.1.2002 / 20:32:10 / micha"
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   345
!
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   346
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   347
translateNLToCRNL:something
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   348
    "set the value of the instance variable 'translateNLToCRNL' (automatically generated)"
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   349
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   350
    translateNLToCRNL := something.
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   351
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   352
    "Created: / 28.1.2002 / 20:32:10 / micha"
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   353
! !
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
!TerminalView methodsFor:'cursor handling'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
cursorCol:col
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
    "check of col is a valid cursor position; return a new col-nr if not.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
     Here, the linelength is enforced"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   361
    ^ super cursorCol:(col min:numberOfColumns)
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   363
    "Modified: / 10.6.1998 / 15:09:34 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
933
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   366
cursorDown:n
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   367
    cursorLine + n > list size ifTrue:[
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   368
        list := list , (Array new:n).
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   369
        self textChanged.
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   370
    ].
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   371
    super cursorDown:n
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   372
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   373
    "Modified: / 10.6.1998 / 17:18:41 / cg"
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   374
    "Created: / 10.6.1998 / 17:18:50 / cg"
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   375
!
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   376
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
cursorLine:l col:col
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
    "check of col is a valid cursor position; return a new col-nr if not.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
     Here, the linelength is enforced"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   381
    ^ super cursorLine:l col:(col min:numberOfColumns)
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   383
    "Modified: / 10.6.1998 / 15:09:38 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
968
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   386
cursorMovementAllowed
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   387
    "return true, if the user may move the cursor around
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   388
     (via button-click, or cursor-key with selection).
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   389
     Here false is returned - the cursor is only moved by
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   390
     cursor positioning escape sequences arriving from the
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   391
     stream."
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   392
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   393
    ^ false
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   394
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   395
    "Created: / 18.6.1998 / 14:12:02 / cg"
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   396
!
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   397
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   398
numberOfTerminalColumns
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   399
    ^ numberOfColumns
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   400
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   401
    "Created: / 5.5.1999 / 11:46:25 / cg"
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   402
!
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   403
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   404
numberOfTerminalLines
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   405
    "/ be careful - this is NOT called numberOfLines,
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   406
    "/ since that would interfere with numberOfLines as defined
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   407
    "/ in ListView ...
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   408
    "/ ... one of the bad sides of subclassing
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   409
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   410
    ^ numberOfLines
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   411
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   412
    "Created: / 5.5.1999 / 11:46:18 / cg"
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   413
    "Modified: / 5.5.1999 / 11:47:24 / cg"
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   414
!
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   415
1077
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   416
restoreCursor
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   417
    |l c|
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   418
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   419
    l := savedCursor y.
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   420
    c := savedCursor x.
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   421
    self cursorLine:l col:c.
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   422
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   423
    "Created: / 14.8.1998 / 13:49:24 / cg"
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   424
!
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   425
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   426
saveCursor
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   427
    savedCursor := cursorCol @ cursorLine
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   428
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   429
    "Created: / 14.8.1998 / 13:48:45 / cg"
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   430
    "Modified: / 14.8.1998 / 13:49:32 / cg"
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   431
!
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   432
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
validateCursorCol:col inLine:line
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
    "check of col is a valid cursor position; return a new col-nr if not.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
     Here, the linelength is enforced"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   437
    ^ col min:numberOfColumns
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   439
    "Modified: / 10.6.1998 / 15:09:41 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   442
!TerminalView methodsFor:'defaults'!
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   443
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   444
anyKeyCodes
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   445
    ^ IdentityDictionary withKeysAndValues:
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   446
        #(
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   447
             #Escape      '\e'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   448
             #BackSpace   '\b'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   449
             #Return      '\r'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   450
             #Delete      '\0177'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   451
             #Tab         '\t'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   452
         )
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   453
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   454
    "Created: / 5.5.1999 / 15:00:37 / cg"
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   455
! !
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   456
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
!TerminalView methodsFor:'event handling'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   459
computeNumberOfLinesShown
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   460
    |prevNLines prevNCols|
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   461
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   462
    prevNCols := (innerWidth // font width).
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   463
    prevNLines := nFullLinesShown.
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   464
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   465
    super computeNumberOfLinesShown.
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   466
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   467
    ((innerWidth // font width) ~~ prevNCols
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   468
    or:[prevNLines ~~ nFullLinesShown]) ifTrue:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   469
        self defineWindowSize.
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   470
    ]
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   471
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   472
    "Created: / 12.6.1998 / 22:34:39 / cg"
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   473
    "Modified: / 20.6.1998 / 19:45:28 / cg"
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   474
!
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   475
1359
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   476
contentsChanged
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   477
    super contentsChanged.
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   478
    self defineWindowSize.
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   479
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   480
    "Modified: / 11.6.1998 / 22:51:48 / cg"
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   481
    "Created: / 5.5.1999 / 16:30:15 / cg"
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   482
!
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   483
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   484
defineWindowSize
1359
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   485
    |fd delta prevNumCols prevNumLines|
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   486
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   487
"/self halt.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   488
"/self realized ifFalse:[
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   489
"/    "/ iconfified
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   490
"/    ^ self
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   491
"/].
1359
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   492
    prevNumCols := numberOfColumns.
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   493
    prevNumLines := numberOfLines.
1161
42796d8e6544 handle 'cannot fork' case.
Claus Gittinger <cg@exept.de>
parents: 1077
diff changeset
   494
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   495
    numberOfColumns := (innerWidth // font width).
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   496
    delta := numberOfLines - rangeEndLine.
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   497
    numberOfLines := nFullLinesShown.
1359
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   498
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   499
    ((prevNumCols == numberOfColumns)
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   500
    and:[prevNumLines == numberOfLines]) ifTrue:[
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   501
        ^ self
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   502
    ].
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   503
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   504
    rangeEndLine notNil ifTrue:[
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   505
        rangeEndLine := numberOfLines - delta.
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   506
    ].
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   507
1359
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   508
    "/ any idea, how to do this under windows ?
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   509
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   510
    OperatingSystem isUNIXlike ifTrue:[
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   511
        "/
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   512
        "/ tell the pty;
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   513
        "/ tell the shell;
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   514
        "/
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   515
        (inStream notNil 
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   516
        and:[inStream isExternalStream
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   517
        and:[inStream isOpen]]) ifTrue:[
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   518
"/        Transcript showCR:'VT100: changed len to ', numberOfLines printString.
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   519
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   520
            (OperatingSystem 
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   521
                setWindowSizeOnFileDescriptor:inStream fileDescriptor
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   522
                width:numberOfColumns
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   523
                height:numberOfLines) ifFalse:[
964
43d6e33a4240 keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents: 958
diff changeset
   524
"/            Transcript showCR:'VT100: cannot change windowSize'.
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   525
            ].
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   526
964
43d6e33a4240 keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents: 958
diff changeset
   527
        ].
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   528
        shellPid notNil ifTrue:[
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   529
            OperatingSystem sendSignal:OperatingSystem sigWINCH to:shellPid
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   530
        ]
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   531
    ].
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   532
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   533
    "Created: / 11.6.1998 / 22:51:39 / cg"
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   534
    "Modified: / 5.5.1999 / 19:45:09 / cg"
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   535
!
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   536
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
keyPress:aKey x:x y:y
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   538
    |rest event rawKey seq|
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   539
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   540
    "/ somewhat complicated, since some characters
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   541
    "/ should go untranslated (CTRL-key),
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   542
    "/ even if defined as function keys.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
    inStream isNil ifTrue:[^ self].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   546
"/ Transcript showCR:'----'; show:'key:' ; showCR:aKey printString.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
    aKey isCharacter ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
        "/ send it down to inStream ...
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
        inStream nextPut:aKey.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   551
        localEcho ifTrue:[
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   552
            self nextPut:aKey
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   553
        ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
        ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
1366
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   557
    (#(Control Control_L Control_R
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   558
      Shift Shift_L Shift_R
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   559
      Alt Alt_L Alt_R
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   560
      Cmd Cmd_L Cmd_R
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   561
      Meta Meta_L Meta_R) includes:aKey) ifTrue:[
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   562
        ^ self
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   563
    ].
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   564
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   565
    "/
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   566
    "/ common translations (Tab, Backspace, F-keys etc.)
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   567
    "/
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
    seq := kbdSequences at:aKey ifAbsent:nil.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
    seq notNil ifTrue:[
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   570
"/ Transcript show:'->' ; showCR:seq storeString.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   571
        seq := seq withEscapes.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   572
        inStream nextPutAll:seq.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   573
        localEcho ifTrue:[
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   574
            self nextPutAll:seq
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   575
        ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
        ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   579
    self sensor ctrlDown ifTrue:[
1366
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   580
        (aKey startsWith:'Ctrl') ifTrue:[
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   581
            rawKey := aKey
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   582
        ] ifFalse:[
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   583
            "/ already translated - undo it.
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   584
        
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   585
            event := WindowGroup lastEventQuerySignal query.
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   586
            rawKey := event rawKey.
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   587
            rawKey isCharacter ifTrue:[
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   588
                rawKey := 'Ctrl' , rawKey.
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   589
            ]
1360
fb843effdaea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
   590
        ]
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   591
    ] ifFalse:[
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   592
        rawKey := self keyboardMap keyAtValue:aKey ifAbsent:aKey.
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   593
    ].
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   594
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   595
    "/
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   596
    "/ care for function-keys, which are mapped to Ctrl-x;
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   597
    "/
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   598
"/ Transcript show:'raw ->' ; showCR:rawKey storeString.
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   599
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
    seq := kbdSequences at:rawKey ifAbsent:nil.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
    seq notNil ifTrue:[
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   602
"/ Transcript show:'->' ; showCR:seq storeString.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
        inStream nextPutAll:(seq withEscapes).
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
        ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
    (rawKey startsWith:'Ctrl') ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
        rest := rawKey copyFrom:5.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
        rest size == 1 ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
            rest := rest at:1.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
            (rest >= $a and:[rest <= $z]) ifTrue:[
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   612
"/ Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
                inStream nextPut:(Character value:(rest - $a + 1)).
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
                ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
            ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
            (rest >= $A and:[rest <= $Z]) ifTrue:[
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   617
"/ Transcript show:'->' ; showCR:(Character value:(rest - $a + 1)) storeString.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
                inStream nextPut:(Character value:(rest - $A + 1)).
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
                ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
            ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
        ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   624
    (rawKey startsWith:'Control') ifTrue:[
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   625
        ^ self
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   626
    ].
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   627
    (rawKey startsWith:'Shift') ifTrue:[
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   628
        ^ self
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   629
    ].
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   630
    (rawKey startsWith:'Alt') ifTrue:[
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   631
        ^ self
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   632
    ].
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   633
    (rawKey startsWith:'Cmd') ifTrue:[
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
   634
        ^ super keyPress:aKey x:x y:y
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   635
    ].
1345
cd0939600467 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1343
diff changeset
   636
    (rawKey = 'Ctrl') ifTrue:[
cd0939600467 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1343
diff changeset
   637
        ^ self
cd0939600467 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1343
diff changeset
   638
    ].
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
   639
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   640
"/    Transcript show:'unhandled key: '; showCR:rawKey.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   642
    "Modified: / 5.5.1999 / 18:32:42 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
shellTerminated
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   646
    "shell has terminated"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   647
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   648
"/Delay waitForSeconds:10.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   649
    [self readAnyAvailableData > 0] whileTrue:[Delay waitForSeconds:0.1].
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   650
"/
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
    self closeDownShell.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   652
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   653
    shellTerminateAction notNil ifTrue:[
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   654
        shellTerminateAction value
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   655
    ] ifFalse:[
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   656
        "/ may be removed ...
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   657
        self warn:'shell terminated'.
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   658
    ]
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   659
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   660
    "Modified: / 5.5.1999 / 18:43:22 / cg"
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   661
!
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   662
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   663
sizeChanged:how
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   664
    super sizeChanged:how.
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   665
    self defineWindowSize.
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   666
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   667
    "Modified: / 11.6.1998 / 22:51:48 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
!TerminalView methodsFor:'functions'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
doBackspace
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
    self cursorLeft.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
    self replaceCharAtCursor:(Character space).
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
    self cursorLeft.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   677
    "Modified: / 10.6.1998 / 17:09:12 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   680
doClearDisplay
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   681
    "clear everything"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   682
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   683
    self doClearEntireScreen.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   684
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   685
    "Modified: / 21.7.1998 / 20:05:35 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   686
!
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   687
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   688
doClearEntireLine
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   689
    "clear the cursor line. cursor position remains unchanged"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   690
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   691
    self at:cursorLine put:''
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   692
!
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   693
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   694
doClearEntireScreen
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   695
    "clear everything"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   696
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   697
    firstLineShown to:(list size) do:[:l |
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   698
        self at:l put:''
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   699
    ].
922
c8373b8c7986 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   700
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   701
    "Modified: / 21.7.1998 / 20:00:19 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   702
    "Created: / 21.7.1998 / 20:05:24 / cg"
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   703
!
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   704
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   705
doClearFromBeginningOfLine
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   706
    "clear from beginning of line to the cursorPosition"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   707
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   708
    |l|
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   709
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   710
    l := self listAt:cursorLine.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   711
    l notNil ifTrue:[
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   712
        (l size >= (cursorCol-1)) ifTrue:[
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   713
            l := l copy from:1 to:cursorCol-1 put:(Character space).
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   714
        ] ifFalse:[
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   715
            l := nil.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   716
        ].
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   717
        self withoutRedrawAt:cursorLine put:l.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   718
        self invalidateLine:cursorLine
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   719
        "/ self at:cursorLine put:l.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   720
    ]
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   721
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   722
    "Modified: / 20.6.1998 / 19:10:21 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   723
    "Created: / 21.7.1998 / 20:10:58 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   724
!
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   725
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   726
doClearFromBeginningOfScreen
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   727
    "clear from beginning of the screen to the cursorPosition"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   728
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   729
    self doClearFromBeginningOfLine.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   730
    cursorLine-1 to:firstLineShown do:[:l |
922
c8373b8c7986 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   731
        self at:l put:''
c8373b8c7986 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   732
    ].
c8373b8c7986 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   733
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   734
    "Modified: / 10.6.1998 / 14:45:43 / cg"
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   735
    "Created: / 21.7.1998 / 20:08:29 / cg"
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   736
!
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   737
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   738
doClearToEndOfLine
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   739
    "clear from the cursorPosition to the end of the line"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   740
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   741
    |l|
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   742
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   743
    l := self listAt:cursorLine.
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   744
    (l size >= (cursorCol-1)) ifTrue:[
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   745
        l notNil ifTrue:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   746
            l := l copyTo:cursorCol-1.
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   747
            self withoutRedrawAt:cursorLine put:l.
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   748
            self invalidateLine:cursorLine
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   749
            "/ self at:cursorLine put:l.
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   750
        ]
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   751
    ]
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   752
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   753
    "Created: / 10.6.1998 / 14:45:01 / cg"
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   754
    "Modified: / 20.6.1998 / 19:10:21 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   757
doClearToEndOfScreen
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   758
    "clear from the cursorPosition to the end of the screen"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   759
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   760
    self doClearToEndOfLine.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   761
    cursorLine+1 to:(list size) do:[:l |
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   762
        self at:l put:''
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   763
    ].
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   764
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   765
    "Modified: / 10.6.1998 / 14:45:43 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   766
    "Created: / 21.7.1998 / 20:06:14 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   767
!
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
   768
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   769
doCursorDown:n
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   770
    "move the cursor down by n lines"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   771
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   772
    |wasOn rEnd|
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   773
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   774
"/    rangeEndLine == numberOfLines ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   775
"/        ^ super cursorDown:n
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   776
"/    ].
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   777
    cursorLine + 1 - firstLineShown + n <= rangeEndLine ifTrue:[
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   778
        "/ no special action req'd
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   779
        ^ super cursorDown:n
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   780
    ].
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   781
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   782
    n timesRepeat:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   783
        wasOn := self hideCursor.
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   784
        rEnd := rangeEndLine+firstLineShown-1.
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   785
        cursorLine ==  rEnd ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   786
            self deleteLine:(rangeStartLine+firstLineShown-1).
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   787
            self insertLine:'' before:rEnd.
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   788
        ] ifFalse:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   789
            super cursorDown
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   790
        ].
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   791
        wasOn ifTrue:[self showCursor]. "/ self makeCursorVisibleAndShowCursor:wasOn.
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   792
    ]
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   793
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   794
    "Modified: / 20.6.1998 / 20:29:39 / cg"
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   795
!
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   796
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
doCursorHome
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   798
    "move the cursor to the home position"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   799
938
3e65cc6f22cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
   800
    self cursorVisibleLine:1 col:1
3e65cc6f22cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
   801
    "/ super cursorHome
3e65cc6f22cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
   802
3e65cc6f22cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
   803
    "Modified: / 10.6.1998 / 20:47:31 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   806
doCursorLeft:n
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   807
    "move the cursor to the left by n columns"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   808
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   809
    n timesRepeat:[
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   810
        super cursorLeft
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   811
    ]
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   812
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   813
    "Created: / 11.6.1998 / 22:30:00 / cg"
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   814
!
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   815
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
doCursorNewLine
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   817
    "move the cursor down to the next line (col remains unchanged)"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   818
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   819
    super cursorDown:1
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   820
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   821
    "Modified: / 10.6.1998 / 16:55:57 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
doCursorReturn
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   825
    "move the cursor down and left to the beginning to the next line"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   826
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
    super cursorToBeginOfLine
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   830
doCursorRight:n
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   831
    "move the cursor to the right by n columns"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   832
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   833
    self cursorCol:(cursorCol + n)
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   834
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   835
    "Created: / 10.6.1998 / 15:10:08 / cg"
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   836
!
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   837
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   838
doCursorUp:n
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   839
    "move the cursor up by n lines"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
   840
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   841
    |wasOn rStart|
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   842
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   843
"/    rangeStartLine == 1 ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   844
"/        ^ super cursorUp:n
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   845
"/    ].
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   846
    cursorLine + 1 - firstLineShown - n >= rangeStartLine ifTrue:[
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   847
        "/ no special action req'd
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   848
        ^ super cursorUp:n
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   849
    ].
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   850
    n timesRepeat:[
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   851
        wasOn := self hideCursor.
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   852
        rStart := rangeStartLine+firstLineShown-1.
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   853
        cursorLine == rStart ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   854
            (rangeEndLine+firstLineShown-1) <= list size ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   855
                self deleteLine:(rangeEndLine+firstLineShown-1).
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   856
                self insertLine:'' before:rStart.
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   857
            ].
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   858
        ] ifFalse:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   859
            super cursorUp
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   860
        ].
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   861
        self makeCursorVisibleAndShowCursor:wasOn.
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   862
    ]
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   863
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
   864
    "Created: / 11.6.1998 / 22:29:46 / cg"
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   865
    "Modified: / 20.6.1998 / 20:30:34 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   868
!TerminalView methodsFor:'initialization-shell'!
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   869
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   870
startCommand:aCommand
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   871
    "start a command on a pseudo terminal. If the command arg is nil,
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   872
     a shell is started. The command is started in the current directory.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   873
     Also fork a reader process, to read the shells output and
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   874
     tell me, whenever something arrives"
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   875
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   876
    ^ self startCommand:aCommand in:nil
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   877
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   878
    "Modified: / 20.7.1998 / 18:30:24 / cg"
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   879
!
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   880
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   881
startCommand:aCommand in:aDirectory
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   882
    "start a command on a pseudo terminal. If the command arg is nil,
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   883
     a shell is started. If aDirectory is not nil, the command is
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   884
     executed in that directory.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   885
     Also fork a reader process, to read the shells output and
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   886
     tell me, whenever something arrives"
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   887
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   888
    |p slaveFD execFdArray closeFdArray blocked exitStatus 
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   889
     stxToCommandPipe commandToStxPipe cmd shell args env wDir shellAndArgs|
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   890
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   891
    shellCommand := aCommand.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   892
    shellDirectory := aDirectory.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   893
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   894
    self create.  "/ need my windowID (to pass down in environment)
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   895
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   896
    OperatingSystem isMSWINDOWSlike ifTrue:[
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   897
        "/ must use another mechanism
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   898
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   899
        stxToCommandPipe := OperatingSystem makePipe.
1343
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   900
        (stxToCommandPipe isNil
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   901
        or:[(stxToCommandPipe at:2) < 0
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   902
        or:[(stxToCommandPipe at:2) < 0]]) ifTrue:[
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   903
            ^ self warn:'Could not create pipe to COMMAND.COM.'.
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   904
        ].
1343
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   905
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   906
        commandToStxPipe := OperatingSystem makePipe.
1343
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   907
        (commandToStxPipe isNil 
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   908
        or:[(commandToStxPipe at:2) < 0
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   909
        or:[(commandToStxPipe at:2) < 0]]) ifTrue:[
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   910
            ^ self warn:'Could not create pipe from COMMAND.COM.'.
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   911
        ].
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   912
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   913
        shellAndArgs := OperatingSystem commandAndArgsForOSCommand:aCommand.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   914
        shell := shellAndArgs at:1.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   915
        args  := (shellAndArgs at:2) ? ''.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   916
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   917
        "/ pipe readSide is p at:1;
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   918
        "/      writeSide is p at:2
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   919
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   920
        execFdArray := Array 
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   921
                         with:(stxToCommandPipe at:1)
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   922
                         with:(commandToStxPipe at:2)
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   923
                         with:(commandToStxPipe at:2).
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   924
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   925
        closeFdArray := #(). 
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   926
"/                        Array 
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   927
"/                         with:(stxToCommandPipe at:2)
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   928
"/                         with:(commandToStxPipe at:1).
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   929
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   930
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   931
        outStream := ExternalStream forReadingFromFileDescriptor:(commandToStxPipe at:1).
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   932
        inStream := ExternalStream forWritingToFileDescriptor:(stxToCommandPipe at:2).
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   933
        outStream buffered:false.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   934
        inStream buffered:false.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   935
    ] ifFalse:[
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   936
        p := ExternalStream makePTYPair.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   937
        p isNil ifTrue:[
1343
c4f0077bea7b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1342
diff changeset
   938
            self warn:'Cannot open pty.'.
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   939
            ^ self.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   940
        ].
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   941
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   942
        "/ p at:1 is the master;
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   943
        "/ p at:2 is the slave
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   944
        inStream := outStream := (p at:1).
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   945
        inStream buffered:false.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   946
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   947
        self defineWindowSize.
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   948
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   949
        "/ fork a shell process on the slave-side
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   950
        slaveFD := (p at:2) fileDescriptor.
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   951
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   952
        execFdArray := Array with:slaveFD with:slaveFD with:slaveFD.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   953
        closeFdArray := #().
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   954
        
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   955
        aCommand isNil ifTrue:[
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   956
            shell := OperatingSystem getEnvironment:'SHELL'.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   957
            shell size == 0 ifTrue:[
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   958
                shell := '/bin/sh'.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   959
            ].
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   960
            cmd := shell asFilename baseName.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   961
            args := (Array with:cmd).
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   962
        ] ifFalse:[
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   963
            shell := '/bin/sh'.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   964
            args := (Array with:'sh' with:'-c' with:aCommand).
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   965
        ].
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   966
    ].
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   967
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   968
    blocked := OperatingSystem blockInterrupts.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   969
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   970
    shellPid := Processor
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   971
               monitor:[
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   972
                  OperatingSystem isMSWINDOWSlike ifTrue:[
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   973
                      OperatingSystem
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   974
                          exec:shell
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   975
                          withArguments:args
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   976
                          fileDescriptors:execFdArray
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   977
                          closeDescriptors:closeFdArray
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   978
                          fork:true
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   979
                          newPgrp:true
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   980
                          inDirectory:aDirectory.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   981
                  ] ifFalse:[
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   982
                      env := Dictionary new.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   983
                      env at:'TERM'     put:(self terminalType).
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   984
                      env at:'LINES'    put:(numberOfLines printString).
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   985
                      env at:'COLUMNS'  put:(numberOfColumns printString).
1485
0cb540a9f129 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   986
                      device platformName = 'X11' ifTrue:[  
0cb540a9f129 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   987
                          drawableId notNil ifTrue:[
0cb540a9f129 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   988
                              env at:'WINDOWID' put:(drawableId address printString).
0cb540a9f129 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1420
diff changeset
   989
                          ].
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   990
                      ].
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   991
                      env at:'SHELL'  put:shell.
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
   992
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   993
                      OperatingSystem
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   994
                          exec:shell
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   995
                          withArguments:args
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   996
                          environment:env
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   997
                          fileDescriptors:execFdArray
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   998
                          closeDescriptors:closeFdArray
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   999
                          fork:true
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
  1000
                          newPgrp:true
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
  1001
                          inDirectory:aDirectory.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
  1002
                  ]
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1003
               ]
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1004
               action:[:status |
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1005
"/                  Transcript show:'pid:'; showCR:status pid.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1006
"/                  Transcript show:'status:'; showCR:status status.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1007
"/                  Transcript show:'code:'; showCR:status code.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1008
"/                  Transcript show:'core:'; showCR:status core.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1009
                  status stillAlive ifFalse:[
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1010
                      exitStatus := status.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1011
                      OperatingSystem closePid:shellPid.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1012
                      shellPid := nil.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1013
                      self pushEvent:#shellTerminated
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1014
                  ].
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1015
               ].
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1016
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1017
    blocked ifFalse:[
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1018
        OperatingSystem unblockInterrupts
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1019
    ].
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1020
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1021
    shellPid isNil ifTrue:[
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1022
        self warn:'Cannot start shell'.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1023
        p notNil ifTrue:[
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1024
            (p at:1) close.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1025
            (p at:2) close.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1026
        ]
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1027
    ].
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1028
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1029
    self startReaderProcess.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1030
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1031
    "Created: / 20.7.1998 / 18:19:32 / cg"
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1032
    "Modified: / 5.5.1999 / 17:28:37 / cg"
1329
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1033
!
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1034
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1035
startShell
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1036
    "start a shell on a pseudo terminal in the current directory.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1037
     Also fork a reader process, to read the shells output and
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1038
     tell me, whenever something arrives"
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1039
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1040
    ^ self startCommand:nil
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1041
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1042
    "
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1043
     VT100TerminalView openShell
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1044
    "
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1045
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1046
    "Modified: / 20.7.1998 / 18:29:54 / cg"
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1047
!
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1048
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1049
startShellIn:aDirectory
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1050
    "start a shell on a pseudo terminal in some directory.
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1051
     Also fork a reader process, to read the shells output and
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1052
     tell me, whenever something arrives"
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1053
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1054
    ^ self startCommand:nil in:aDirectory
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1055
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1056
    "
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1057
     VT100TerminalView openShellIn:'/etc'
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1058
    "
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1059
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1060
    "Modified: / 20.7.1998 / 18:29:46 / cg"
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1061
! !
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1062
e0dff849cf82 category change
Claus Gittinger <cg@exept.de>
parents: 1323
diff changeset
  1063
!TerminalView methodsFor:'initialize / release'!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
closeDownShell
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1066
    "shut down my shell process and stop the background reader thread."
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1067
1009
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1068
    |pid|
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1069
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1070
    (pid := shellPid) notNil ifTrue:[
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1071
"/        Transcript print:'killing shell pid='; showCR:pid.
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1072
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1073
        OperatingSystem terminateProcessGroup:pid.
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1074
        OperatingSystem terminateProcess:pid.
925
f9ef1268a21b kill after termination.
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1075
        Delay waitForSeconds:1.
f9ef1268a21b kill after termination.
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1076
        shellPid notNil ifTrue:[
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
  1077
            OperatingSystem isMSWINDOWSlike ifFalse:[
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
  1078
                OperatingSystem killProcessGroup:pid.
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
  1079
            ].
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1080
            OperatingSystem killProcess:pid.
925
f9ef1268a21b kill after termination.
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1081
            shellPid := nil.
f9ef1268a21b kill after termination.
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1082
        ].
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1083
        OperatingSystem closePid:pid.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
1009
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1086
    self stopReaderProcess.
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1087
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
    inStream notNil ifTrue:[
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1089
        inStream isStream ifTrue:[inStream close].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
        inStream := nil
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
    outStream notNil ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
        outStream close.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
        outStream := nil
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
    ].
924
c1d2e1fecd79 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
  1096
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1097
    "Modified: / 5.5.1999 / 18:43:02 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
destroy
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1101
    "destroy myself - shut down the shell, stop the reader thread."
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1102
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
    self closeDownShell.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1104
    self flushInput.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
    super destroy
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1106
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1107
    "Modified: / 5.5.1999 / 18:42:55 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
escapeSequences:codes
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1111
    "setup my escape sequences"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1112
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
    |tree|
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
    tree isNil ifTrue:[tree := escapeSequenceTree := IdentityDictionary new].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
    codes do:[:specEntry |
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
        |sequence function|
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
        sequence := (specEntry at:1) withEscapes.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
        function := specEntry at:2.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
        tree := escapeSequenceTree.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
        sequence keysAndValuesDo:[:idx :char |
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
            |followup|
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
            idx == sequence size ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
                tree at:char put:function
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
            ] ifFalse:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
                followup := tree at:char ifAbsent:nil.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
                followup isNil ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
                    tree at:char put:(followup := IdentityDictionary new).
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
                ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
                tree := followup
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
            ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
        ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
    ].
918
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1139
    escapeLeadingChars := escapeSequenceTree keys asSet.
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1140
    escapeLeadingChars add:(Character cr).
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1141
    escapeLeadingChars add:(Character return).
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1142
    escapeLeadingChars add:(Character backspace).
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1143
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1144
    escapeLeadingChars := escapeLeadingChars asArray
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1145
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1146
    "Modified: / 9.6.1998 / 19:43:12 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1149
flushInput
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1150
    |sensor|
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1151
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1152
    "/ flush any leftover input-processing events
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1153
    (sensor := self sensor) notNil ifTrue:[
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1154
        sensor flushEventsFor:self withType:#processInput:n:.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1155
    ]
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1156
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1157
    "Modified: / 21.7.1998 / 19:00:13 / cg"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1158
    "Created: / 5.5.1999 / 18:41:42 / cg"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1159
!
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1160
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
initialize
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
    super initialize.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
    showMatchingParenthesis := false.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
    insertMode := false.
936
d377fb0f726f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 935
diff changeset
  1166
    alwaysAppendAtEnd := false.
944
c59be5892714 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 943
diff changeset
  1167
    collectSize := 100.
977
785c3ad4eff1 turn off st80Mode
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1168
    st80Mode := false.
785c3ad4eff1 turn off st80Mode
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1169
    trimBlankLines := true.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1170
    localEcho := false.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1172
    numberOfColumns := 80.
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1173
    numberOfLines := 24.
954
4cef50a89ca1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
  1174
    rangeStartLine := 1.
4cef50a89ca1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
  1175
    rangeEndLine := numberOfLines.
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1176
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
    self initializeKeyboardSequences.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
    list := OrderedCollection new:24 withAll:''.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1180
    self initializeKeyboardMap.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
    "
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
     VT52TerminalView openShell
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1184
     VT100TerminalView openShell
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
    "
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1186
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1187
    "Modified: / 5.5.1999 / 17:54:47 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
initializeKeyboardMap
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1191
    |keys ctrlKeys cmdKeys|
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1193
    "/ setup my own keyboardMap, where control-keys 
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1194
    "/ (and some Cmd-keys) are not translated.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
    kbdMap := device keyboardMap copy.
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1196
    keys := kbdMap keys.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1198
    ctrlKeys := keys select:[:key | key startsWith:'Ctrl'].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
    ctrlKeys do:[:key | kbdMap removeKey:key].
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1200
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1201
    cmdKeys := keys select:[:key | key startsWith:'Cmd'].
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1202
    cmdKeys do:[:key | |val|
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1203
        val := kbdMap at:key.
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1204
        val isSymbol ifTrue:[
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1205
            (#(Copy Paste SaveAs Print) includes:val) ifFalse:[
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1206
                kbdMap removeKey:key
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1207
            ]
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1208
        ]
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1209
    ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1210
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1211
    kbdMap removeKey:#Delete ifAbsent:[].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
    kbdMap removeKey:#BackSpace ifAbsent:[].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1214
    "
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
     VT52TerminalView openShell
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
    "
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1217
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1218
    "Modified: / 29.4.1999 / 14:25:24 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1220
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
initializeKeyboardSequences
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1222
    kbdSequences := (self anyKeyCodes)
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1223
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1224
    "Modified: / 5.5.1999 / 15:01:09 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
keyboardMap
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1228
    "return my keyboard map. This has control keys removed and
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1229
     those will be passed unchanged to the shell"
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1230
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1231
    ^ kbdMap
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1232
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1233
    "Modified: / 10.6.1998 / 17:46:59 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1234
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1235
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1236
reinitialize
1833
69a0c170cd80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1485
diff changeset
  1237
    "reinit after a snapIn.
69a0c170cd80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1485
diff changeset
  1238
     this is invoked (by the system thread) after a snapShot image restart"
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1239
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1240
    super reinitialize.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1241
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1242
    shellPid := nil.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1243
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1244
    self stopReaderProcess.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1245
    self flushInput.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1246
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1247
    readerProcess := nil.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1248
    inStream := outStream := nil.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1249
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1250
    "/ must fork at low-prio (to avoid running reader at prio31)
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1251
    [
1322
30150c59eb97 dont delay the reinit
Claus Gittinger <cg@exept.de>
parents: 1321
diff changeset
  1252
       "/ Delay waitForSeconds:0.5.
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1253
        self doClearEntireScreen.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1254
        self cursorLine:1 col:1.
1321
9a312fa98358 also throw away scrolled text whith restart.
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
  1255
        self contents:nil.
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1256
        self flash.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1257
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1258
        "/
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1259
        "/ all I can do is to restart the original command
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1260
        "/
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1261
        self startCommand:shellCommand in:shellDirectory.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1262
    ] forkAt:8
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1263
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1264
    "Modified: / 5.5.1999 / 18:41:55 / cg"
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1265
!
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1266
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1267
startReaderProcess
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1268
    "Start a reader process, which looks for the commands output,
1009
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1269
     and sends me #processInput:n: events whenever something arrives."
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1270
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
    readerProcess isNil ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
        readerProcess := [
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
            [
947
e3baca36e6f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 946
diff changeset
  1274
                self waitUntilVisible.
e3baca36e6f7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 946
diff changeset
  1275
940
16c955286510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
  1276
                Stream streamErrorSignal handle:[:ex |
1339
17bdf3424085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1329
diff changeset
  1277
                    Transcript show:'Terminal [error]: '; showCR:ex errorString.
17bdf3424085 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1329
diff changeset
  1278
                    Transcript show:'Terminal [info]: '; showCR:OperatingSystem lastErrorString.
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
  1279
self halt.
940
16c955286510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
  1280
                ] do:[
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1281
                    [true] whileTrue:[
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1282
                        Object abortSignal handle:[:ex |
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1283
                            self showCursor.
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1284
                        ] do:[
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1285
                            |n sensor|
948
b93aba7db15d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1286
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1287
                            outStream readWait.
1323
b31f7319419c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1288
                            (sensor := self sensor hasKeyPressEventFor:self) ifTrue:[
b31f7319419c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1289
                                true "(sensor userEventCount > 10)" ifTrue:[
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1290
                                    "/ give terminalView a chance to
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1291
                                    "/ send out the character.
1323
b31f7319419c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1292
                                    Delay waitForSeconds:0.01.
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1293
                                ]
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1294
                            ] ifFalse:[
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1295
                                n := self readAnyAvailableData.
945
552cf1a3d47b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 944
diff changeset
  1296
                                n > 0 ifTrue:[
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1297
                                    shellPid notNil ifTrue:[
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1298
                                        self waitForOutputToDrain.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1299
                                    ]
945
552cf1a3d47b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 944
diff changeset
  1300
                                ] ifFalse:[
552cf1a3d47b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 944
diff changeset
  1301
                                    n == 0 ifTrue:[
1342
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1302
                                        "/ Windows IPC has a bug - it always
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1303
                                        "/ returns 0 (when the command is idle)
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1304
                                        "/ and says its at the end (sigh)
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1305
1342
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1306
                                        OperatingSystem isMSWINDOWSlike ifTrue:[
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1307
                                            Delay waitForSeconds:0.01
1323
b31f7319419c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1308
                                        ] ifFalse:[
1342
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1309
                                            outStream atEnd ifTrue:[
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1310
                                                outStream close. outStream := nil.
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1311
                                                inStream close.  inStream := nil.
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1312
                                                
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1313
                                                Processor activeProcess terminate.
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1314
                                            ] ifFalse:[
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1315
                                                "/ this should not happen.
1323
b31f7319419c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1316
1342
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1317
                                                Delay waitForSeconds:0.05
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1318
                                            ]
271a9b90688a somehow working under win32 (process cleanup still wrong ?)
Claus Gittinger <cg@exept.de>
parents: 1341
diff changeset
  1319
                                        ].
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1320
                                    ]
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1321
                                ]
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1322
                            ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1323
                        ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1324
                    ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1325
                ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1326
            ] valueOnUnwindDo:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1327
                readerProcess := nil    
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1328
            ]
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1329
        ] fork. "/ forkAt:9.
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1330
        readerProcess name:'pty reader'.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
    ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1332
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1333
    "
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1334
     VT100TerminalView openShell
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1335
    "
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1336
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1337
    "Modified: / 5.5.1999 / 17:58:02 / cg"
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
  1338
    "Modified: / 28.1.2002 / 19:18:57 / micha"
1009
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1339
!
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1340
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1341
stopReaderProcess
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1342
    "stop the background reader thread"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1343
1009
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1344
    |sensor|
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1345
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1346
    readerProcess notNil ifTrue:[
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1347
        readerProcess terminate.
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1348
        "/ give it a chance to really terminate
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1349
        Processor yield.
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1350
        readerProcess := nil
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1351
    ].
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1352
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1353
    "/ flush any leftover input-processing events
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1354
    (sensor := self sensor) notNil ifTrue:[
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1355
        sensor flushEventsFor:self withType:#processInput:n:.
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1356
    ]
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1357
    "Modified: / 21.7.1998 / 19:00:13 / cg"
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
  1358
! !
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
  1359
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
!TerminalView methodsFor:'menu'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1362
doReset
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1363
    "reset the scroll-range; 
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1364
     may have to reset more in the future (current font-set; color; etc)"
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1365
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1366
    rangeStartLine := 1.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1367
    rangeEndLine := numberOfLines.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1368
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1369
    self normal.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1370
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1371
!
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1372
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1373
doSendInterrupt
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1374
    "send an INT-signal to the shell (UNIX only)"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1375
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1376
    OperatingSystem sendSignal:(OperatingSystem sigINT) to:shellPid negated.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1377
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1378
    "Modified: / 10.6.1998 / 17:49:49 / cg"
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1379
!
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1380
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1381
editMenu
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
    "return the views middleButtonMenu"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1384
    <resource: #keyboard (#Copy #Paste #Print #SaveAs #Print)>
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
    <resource: #programMenu>
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  1387
    |items m sensor|
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
    ((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
        items := #(
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
                        ('Interrupt'      doSendInterrupt)  
1182
c3809bedfd32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
  1392
                        ('-'                                    )
c3809bedfd32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1161
diff changeset
  1393
                        ('Reset'          doReset)  
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
                  ).
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
    ] ifFalse:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
        items := #(
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  1397
                        ('Copy'         copySelection    Copy   )
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  1398
                        ('Paste'        pasteOrReplace   Paste  )
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
                        ('-'                                    )
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  1400
                        ('Font...'      changeFont              )
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1401
                        ('-'                                    )
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  1402
                        ('Save as...'   save             SaveAs )
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  1403
                        ('Print'        doPrint          Print  )
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1404
                  ).
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1405
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1406
"/ disabled - for now;
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1407
"/ need a more intelligent filtering of control characters.
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1408
"/
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1409
"/        filterStream isNil ifTrue:[
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1410
"/           items := items , #(
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1411
"/                        ('-'                                    )
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  1412
"/                        ('Start Save as ...'  startSaveAs       )
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  1413
"/                        ('Start Print'        startPrint        )
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1414
"/                             )
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1415
"/        ] ifFalse:[
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1416
"/           items := items , #(
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1417
"/                        ('-'                                    )
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  1418
"/                        ('Stop filter'  stopFilter              )
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1419
"/                             )
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1420
"/        ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1421
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1422
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
    m := PopUpMenu itemList:items resources:resources.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1424
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1425
    self hasSelection not ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1426
        m disable:#copySelection.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1427
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1428
    ^ m.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1430
    "Modified: / 29.4.1999 / 11:12:56 / cg"
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1431
!
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1432
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1433
startSaveAs
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1434
    "start saving all received data to some file"
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1435
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1436
    |fn|
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1437
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1438
    fn := Dialog requestFileName:'Save received data in file:'.
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1439
    fn size > 0 ifTrue:[
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1440
        filterStream := fn asFilename writeStream
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1441
    ].
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1442
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1443
    "Created: / 29.4.1999 / 11:06:29 / cg"
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1444
!
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1445
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1446
stopFilter
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1447
    "stop saving/printing of received data"
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1448
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1449
    filterStream close.
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1450
    filterStream := nil.
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1451
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1452
    "Created: / 29.4.1999 / 11:07:49 / cg"
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1453
    "Modified: / 29.4.1999 / 11:09:52 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
940
16c955286510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
  1456
!TerminalView methodsFor:'misc'!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1457
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1458
removeTrailingBlankLines
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1459
    ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1460
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1462
!TerminalView methodsFor:'processing - input'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1464
doNothing
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1465
    "private - end of an ignored escape-sequence"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1466
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1467
    self endOfSequence
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1468
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1469
    "Created: / 12.6.1998 / 20:40:43 / cg"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1470
!
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1471
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1472
endOfSequence
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1473
    "private - reset state-machine at end of escape-sequence"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1474
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1475
    state := 0.
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1476
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1477
    "Created: / 12.6.1998 / 20:39:52 / cg"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1478
!
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1479
1017
8af14b2315fa care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1480
nextPutAll:aString
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1481
    "/ self processInput:aString n:aString size
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1482
    self pushEvent:#processInput:n: with:aString with:aString size.
1017
8af14b2315fa care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1483
8af14b2315fa care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1484
    "Created: / 27.7.1998 / 15:10:59 / cg"
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1485
    "Modified: / 27.7.1998 / 23:16:19 / cg"
1017
8af14b2315fa care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1486
!
8af14b2315fa care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  1487
933
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
  1488
processInput:buffer n:count
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1489
    |sensor|
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1490
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1491
    filterStream notNil ifTrue:[
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1492
        filterStream nextPutAll:(buffer copyTo:count).
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1493
    ].
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1494
1077
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  1495
"/    self hideCursor.
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1496
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1497
    "/ the following may not be too clean, but adds a lot of speed.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1498
    "/ instead of passing every individual character through the
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1499
    "/ escape-state machine, collect chunks of non-control text
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1500
    "/ when in state 0, and add them immediately to the pendingLines
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1501
    "/ collection of the textCollectors asynchronous update mechanism.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1502
    "/ This helps a lot if you do something like "ls -lR /" ...
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1503
    "/ For debugging the state machine, reenable the commented lines
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1504
    "/ below.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1505
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1506
"/1 to:count do:[:i|
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1507
"/    self nextPut:(buffer at:i).
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1508
"/].
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1509
"/self showCursor.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1510
"/^ self.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1511
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1512
    access critical:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1513
        |i i2 s crnlFollows|
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1514
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1515
        i := 1.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1516
        [i <= count] whileTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1517
            (state == 0) ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1518
                "/ in initial state.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1519
                "/ quick scan forward for next control character ...
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1520
                i2 := buffer indexOfControlCharacterStartingAt:i.
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1521
                i2 > count ifTrue:[i2 := 0].
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1522
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1523
                i2 == 0 ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1524
                    "/ no control characters - simply append all
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1525
                    "/ to the outstanding lines ...
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1526
                    s := buffer copyFrom:i to:count.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1527
                    i := count + 1. "/ leave loop.
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1528
                    crnlFollows := false.
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1529
                ] ifFalse:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1530
                    i2 > i ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1531
                        s := buffer copyFrom:i to:i2-1.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1532
                        i := i2. "/ proceed withcontrol character
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1533
                        crnlFollows := false.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1534
                        i < (count - 1) ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1535
                            (buffer at:i) == Character return ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1536
                                (buffer at:i+1) == Character nl ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1537
                                    crnlFollows := true.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1538
                                    i := i + 2.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1539
                                ]
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1540
                            ]
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1541
                        ].
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1542
                    ]
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1543
                ].
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1544
            ].
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1545
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1546
            s notNil ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1547
                currentEmphasis notNil ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1548
                    s := s emphasizeAllWith:currentEmphasis
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1549
                ].
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1550
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1551
                outstandingLine size > 0 ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1552
                    outstandingLine := outstandingLine , s.
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1553
                ] ifFalse:[
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1554
                    outstandingLine := s.
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1555
                ].
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1556
                crnlFollows ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1557
                    outstandingLines isNil ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1558
                        outstandingLines := OrderedCollection with:outstandingLine
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1559
                    ] ifFalse:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1560
                        outstandingLines add:outstandingLine.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1561
                    ].
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1562
                    outstandingLine := ''.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1563
                ].
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1564
                s := nil.
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1565
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1566
                collecting ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1567
                    flushPending ifFalse:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1568
                        self installDelayedUpdate
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1569
                    ] ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1570
    "/                    outstandingLines size > collectSize ifTrue:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1571
    "/                        self endEntry
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1572
    "/                    ]
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1573
                    ]
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1574
                ] ifFalse:[
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1575
                    self endEntry
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1576
                ].
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1577
            ] ifFalse:[
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1578
                "/ no chunk to append (in an escape sequence)
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1579
                "/ must handle individual characters
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1580
                "/ to update the state machine.
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1581
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1582
                self nextPut:(buffer at:i).
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1583
                i := i + 1.
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1584
                [state ~~ 0 and:[i <= count]] whileTrue:[
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1585
                    self nextPut:(buffer at:i).
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1586
                    i := i + 1.
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1587
                ]
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1588
            ]
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1589
        ].
933
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
  1590
    ].
948
b93aba7db15d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1591
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1592
    state == 0 ifTrue:[
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1593
        (sensor := self sensor) notNil ifTrue:[
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1594
            "/ if there is no more output pending from the shell,
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1595
            "/ enforce update of the view (asynchronous)
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1596
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1597
            (sensor hasEvent:#processInput:n: for:self) ifFalse:[
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1598
                self endEntry.
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  1599
                self showCursor.
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1600
                "/ self makeCursorVisible.
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1601
            ] ifTrue:[
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1602
                "/ if there is more output pending from the shell,
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1603
                "/ and many lines have already been collected,
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1604
                "/ also enforce update of the view (asynchronous)
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1605
                "/ Thus, it will update at least once for every
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1606
                "/ collectSize lines.
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  1607
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1608
                outstandingLines size > collectSize ifTrue:[ 
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1609
                    self endEntry.
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1610
                    self showCursor.
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1611
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1612
                    "/ make certain that things are really displayed ...
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1613
                    windowGroup notNil ifTrue:[
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1614
                        windowGroup processRealExposeEventsFor:self.
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1615
                    ]
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1616
                ].
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1617
            ]
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  1618
        ].
933
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
  1619
    ].
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
  1620
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
  1621
    "Created: / 10.6.1998 / 17:26:09 / cg"
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  1622
    "Modified: / 29.4.1999 / 11:08:48 / cg"
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
  1623
    "Modified: / 28.1.2002 / 20:41:36 / micha"
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1624
!
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1625
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1626
readAnyAvailableData
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1627
    "read data from the stream,
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1628
     and sends me #processInput:n: events if something arrived.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1629
     Returns the amount of data read."
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1630
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1631
    |buffer n bufferSize|
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1632
1370
165f57ba2b12 care for closed stream in readAnyAvail
Claus Gittinger <cg@exept.de>
parents: 1366
diff changeset
  1633
    outStream isNil ifTrue:[^ 0].
165f57ba2b12 care for closed stream in readAnyAvail
Claus Gittinger <cg@exept.de>
parents: 1366
diff changeset
  1634
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1635
    bufferSize := 512. "/ 1024.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1636
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1637
    buffer := String new:bufferSize.
1371
2b28c00660b3 handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  1638
    ExternalStream readErrorSignal handle:[:ex |
2b28c00660b3 handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  1639
        n := 0
2b28c00660b3 handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  1640
    ] do:[
2b28c00660b3 handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  1641
        n := outStream nextAvailableBytes:bufferSize into:buffer startingAt:1.
2b28c00660b3 handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  1642
    ].
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1643
    n > 0 ifTrue:[
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
  1644
Transcript showCR:'read ' , n printString , ' bytes'.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1645
        self pushEvent:#processInput:n: with:buffer with:n.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1646
    ].
1371
2b28c00660b3 handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  1647
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1648
    ^ n
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1649
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1650
    "Created: / 5.5.1999 / 17:57:39 / cg"
1371
2b28c00660b3 handle readError (pty closed while reading)
Claus Gittinger <cg@exept.de>
parents: 1370
diff changeset
  1651
    "Modified: / 8.5.1999 / 20:14:14 / cg"
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
  1652
    "Modified: / 28.1.2002 / 19:00:56 / micha"
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1653
!
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1654
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1655
sync
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1656
    self waitForOutputToDrain
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1657
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1658
    "Created: / 27.7.1998 / 23:49:44 / cg"
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1659
!
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1660
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1661
waitForOutputToDrain
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1662
    |sensor|
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1663
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1664
    sensor := self sensor.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1665
    (sensor notNil and:[sensor userEventCount > 30]) ifTrue:[
1323
b31f7319419c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  1666
        [sensor userEventCount > 5] whileTrue:[
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1667
            "/ give terminalView a chance to
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1668
            "/ catch up.
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1669
            Delay waitForSeconds:0.1.
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1670
        ]
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1671
    ].
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1672
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  1673
    "Created: / 27.7.1998 / 23:47:22 / cg"
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1674
    "Modified: / 5.5.1999 / 18:51:00 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1675
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1676
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1677
!TerminalView methodsFor:'queries'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1678
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1679
preferredExtent
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1680
    "return my preferred extent - this is computed from my numberOfLines,
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1681
     numberOfCols and font size"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1682
1317
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1683
    ^ (fontWidth * self class defaultNumberOfColumns + (leftMargin * 2))
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1684
      @ 
1317
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1685
      ((self heightForLines:self class defaultNumberOfLines) + 8)
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1686
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1687
    "Modified: / 20.6.1998 / 20:06:57 / cg"
929
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1688
!
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1689
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1690
terminalType
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1691
    "returns a string describing this terminal (usually, this is
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1692
     passed down to the shell as TERM environment variable).
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1693
     Here, 'dump' is returned."
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1694
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  1695
    ^ 'dump'
929
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1696
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  1697
    "Created: / 10.6.1998 / 16:22:30 / cg"
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  1698
    "Modified: / 5.5.1999 / 11:22:32 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1699
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1700
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1701
!TerminalView methodsFor:'selection handling'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1702
1317
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1703
autoMoveCursorToEndOfSelection
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1704
    "Redefined to return false since the cursor should
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1705
     not be affected by selecting"
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1706
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1707
    ^ false
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1708
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1709
!
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  1710
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1711
paste:someText
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1712
    "paste - redefined to send the chars to the shell instead
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1713
     of pasting into the view"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1714
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1715
    |s nLines|
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1716
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1717
    s := someText.
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1718
    s isString ifTrue:[
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1719
        s := s asStringCollection
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1720
    ] ifFalse:[
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1721
        (s isKindOf:StringCollection) ifFalse:[
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1722
            self warn:'selection (' , s class name , ') is not convertable to Text'.
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1723
            ^ self
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1724
        ]
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1725
    ].
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1726
    (nLines := s size) == 0 ifTrue:[^ self].
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1727
    (nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self].
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1728
    s keysAndValuesDo:[:idx :line |
1404
fd15ebe7dd3a checkin from browser
Stefan Vogel <sv@exept.de>
parents: 1371
diff changeset
  1729
        line notNil ifTrue:[inStream nextPutAll:line].
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1730
        idx ~~ nLines ifTrue:[
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1731
            inStream nextPut:(Character return).
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1732
        ]
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1733
    ].
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1734
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1735
    "Modified: / 12.6.1998 / 22:12:47 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1736
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1737
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1738
!TerminalView class methodsFor:'documentation'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1739
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1740
version
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
  1741
    ^ '$Header: /cvs/stx/stx/libwidg2/TerminalView.st,v 1.91 2002-01-28 20:08:59 mb Exp $'
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1742
! !