TerminalView.st
author Claus Gittinger <cg@exept.de>
Wed, 11 Sep 2019 15:30:17 +0200
changeset 6143 3ed63f769dc5
parent 6132 a15871e06ccd
child 6186 dd919a19b802
permissions -rw-r--r--
#BUGFIX by exept class: LinkButtonController changed: #buttonPress:x:y: #buttonRelease:x:y:
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
"
1833
69a0c170cd80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1485
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
69a0c170cd80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1485
diff changeset
    13
4718
382e2e8d430e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4668
diff changeset
    14
"{ NameSpace: Smalltalk }"
382e2e8d430e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4668
diff changeset
    15
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
TextCollector subclass:#TerminalView
5156
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    17
	instanceVariableNames:'inStream outStream readerProcess shellPid kbdSequences
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    18
		escapeSequenceTree currentSequence kbdMap escapeLeadingChars
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    19
		numberOfColumns numberOfLines shellTerminateAction rangeStartLine
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    20
		rangeEndLine state savedCursor shellCommand shellDirectory
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    21
		filterStream recorderStream localEcho translateNLToCRNL
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    22
		inputTranslateCRToNL inputTranslateCRToCRNL
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    23
		inputTranslateBackspaceToDelete autoWrapFlag masterWindow
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    24
		alternateKeypadMode noColors sizeOfOutstandingInputToBeProcessed
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    25
		lineEditMode lineBuffer lineBufferCursorPosition
5288
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
    26
		lineBufferHistory lineBufferHistoryPosition
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
    27
		lineBufferHistoryChanged maxHistorySize doUTF ignoreOutput
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
    28
		sendControlKeys lastSelectedLineBufferHistoryPosition inputIsUTF8
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
    29
		outputIsUTF8 signalControlKeys filterOnly'
5156
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    30
	classVariableNames:'Debug DebugKeyboard DefaultMaxHistorySize'
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    31
	poolDictionaries:''
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
    32
	category:'Views-TerminalViews'
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!TerminalView class methodsFor:'documentation'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    37
copyright
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    38
"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    39
 COPYRIGHT (c) 1998 by eXept Software AG
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    40
              All Rights Reserved
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
 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
    43
 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
    44
 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
    45
 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
    46
 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
    47
 hereby transferred.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    48
"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    49
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    50
!
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    51
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
documentation
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
"
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    54
    I provide terminal functionality, by interpreting data
1418
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    55
    arriving from some stream (typically connected to a command interpreter 
4597
c0c195dcf0c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4596
diff changeset
    56
    via a pty, or another system via a modem) and sending my keyboard data to it.
c0c195dcf0c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4596
diff changeset
    57
c0c195dcf0c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4596
diff changeset
    58
    I am abstract providing general functionality -
c0c195dcf0c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4596
diff changeset
    59
    concrete terminal characteristics (i.e. escape sequences) are defined 
c0c195dcf0c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4596
diff changeset
    60
    by concrete subclasses (see VT52TerminalView, VT100TerminalView).
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    61
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    62
    Concrete applications are: 
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    63
        consoles (VT100TerminalView),
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    64
        telnet-views (see TelnetTool)
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
    65
        editor wrappers (if you like emacs/vi)
4597
c0c195dcf0c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4596
diff changeset
    66
        gdb terminal subviews (see GDBApplication)
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
4223
020aad6311b5 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4222
diff changeset
    68
    Although my class protocol includes common startup protocol
1418
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    69
    (to open a terminalView with a shell or on the output of a command),
4223
020aad6311b5 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4222
diff changeset
    70
    I can be used as a widget within an application (modem software).
1418
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
    71
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
    72
    Implementation notice: 
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
    73
        some of my pty functionality and handling is being extracted to
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
    74
        the separate TerminalSession class (which allows communicating with a
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
    75
        program without having its output displayed).   
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
    76
        So currently, some ugly code duplication is present.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
    77
        Once stable, code will be refactored.   
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
    78
        For now, as terminalView is being used in
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
    79
        some of our critical applications, this refactoring has not yet been done.
4597
c0c195dcf0c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4596
diff changeset
    80
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    81
    Line Editing mode:
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    82
     Cursor keys allow for th user to navigate through previously entered input (as in cmd.exe and bash).
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    83
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    84
     Special: <SHIFT>-cursor up goes back to the previously selected history line.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    85
     (not to the previous line).
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    86
     For example, if the user types:
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    87
        a <RETURN>
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    88
        b <RETURN>
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    89
        c <RETURN>
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    90
        <CURSOR-UP> -> shows 'c'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    91
        <CURSOR-UP> -> shows 'b'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    92
        <CURSOR-UP> -> shows 'a'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    93
        123 <RETURN> -> resends 'a123'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    94
        <SHIFT-CURSOR-UP> -> shows 'a' again which is the previously selected history line(not a123)
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    95
        <CURSOR-DOWN> -> shows 'b'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    96
        <RETURN> -> sends 'b'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
    97
    
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    [author:]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
        Claus Gittinger
915
f2c934efc4da checkin from browser
Claus Gittinger <cg@exept.de>
parents: 914
diff changeset
   100
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   101
    [instance variables:]
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   102
        inStream                stream where keyboard input is
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   103
                                sent to (connected to shells or commands input)
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   104
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   105
        outStream               stream where the output of the
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   106
                                shell or command arrives
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   107
                                (read here and displayed in the view)
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   108
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   109
        readerProcess           process which reads commands    
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   110
                                output and sends it to the view
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   111
5307
a3f7aa762f87 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5306
diff changeset
   112
        lineEditMode            if on, do readLine-alike input history and editing
4598
d2f5d944f538 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4597
diff changeset
   113
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   114
        signalControlKeys       if on, CTRL-C sends an interrupt (for Windows)
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   115
2204
145b2cc35537 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2202
diff changeset
   116
    [class variables]:
145b2cc35537 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2202
diff changeset
   117
        Debug := true           trace incoming characters
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   118
        Debug := false           
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   119
        DebugKeyboard := true   trace outgoing characters
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   120
        DebugKeyboard := false 
2204
145b2cc35537 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2202
diff changeset
   121
145b2cc35537 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2202
diff changeset
   122
915
f2c934efc4da checkin from browser
Claus Gittinger <cg@exept.de>
parents: 914
diff changeset
   123
    [start with:]
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   124
        VT52TerminalView open
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   125
        VT100TerminalView open
915
f2c934efc4da checkin from browser
Claus Gittinger <cg@exept.de>
parents: 914
diff changeset
   126
        VT52TerminalView openShell
919
07e8c17563a2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   127
        VT100TerminalView openShell
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   128
        VT100TerminalView openOnCommand:'ls -l'
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   129
        VT100TerminalView openOnCommand:'dir'
1418
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   130
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   131
    [see also:]
32a6131b304b documentation
Claus Gittinger <cg@exept.de>
parents: 1404
diff changeset
   132
        TelNetTool
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
"
3758
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   134
!
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   135
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   136
examples
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   137
"
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   138
  start a shell in the current directory:
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   139
                                                                [exBegin]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   140
    TerminalView openShell
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   141
                                                                [exEnd]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   142
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   143
  start a shell in a given directory:
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   144
                                                                [exBegin]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   145
    TerminalView openShellIn:(OperatingSystem getHomeDirectory)
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   146
                                                                [exEnd]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   147
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   148
  start another program current directory:
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   149
                                                                [exBegin]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   150
    TerminalView openOnCommand:'ls -l'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   151
                                                                [exEnd]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   152
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   153
  start another program in some given directory:
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   154
                                                                [exBegin]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   155
    TerminalView openOnCommand:'ls' in:'/etc'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   156
                                                                [exEnd]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   157
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   158
  specify how to react when the shell terminates:
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   159
                                                                [exBegin]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   160
    TerminalView openOnCommand:'ls' in:'/etc' onExit:[:vt | vt topView destroy]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   161
    TerminalView openOnCommand:'ls' in:'/etc' onExit:[:vt | Dialog information:'finished'. vt topView destroy]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   162
                                                                [exEnd]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   163
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   164
  special low level usage: no shell command, interact with the user myself
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   165
  (i.e. read the user's input, and intepret it myself):
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   166
                                                                [exBegin]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   167
    |terminal in out inputLine|
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   168
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   169
    in := InternalPipeStream new.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   170
    out := InternalPipeStream new.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   171
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   172
    terminal := TerminalView openOnInput:in output:out.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   173
    terminal localEcho:true.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   174
    terminal inputTranslateCRToNL:true.
5149
7c471b54fe48 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
   175
    terminal translateNLToCRNL:true.
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   176
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   177
    out nextPutLine:'Hello world - please type at me:'.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   178
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   179
    [
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   180
        inputLine := in nextLine asString.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   181
        inputLine ~= '#exit' ifTrue:[
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   182
            out nextPutLine:(Compiler evaluate:inputLine) printString.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   183
        ].
5149
7c471b54fe48 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
   184
        (inputLine = '#exit') or:[ terminal isOpen not ]
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   185
    ] whileFalse.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   186
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   187
    terminal topView destroy.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   188
                                                                [exEnd]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   189
"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
2207
d352a2f0a83a no changes on terminal device anymore
penk
parents: 2205
diff changeset
   192
!TerminalView class methodsFor:'initialization'!
2205
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   193
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   194
initialize
2207
d352a2f0a83a no changes on terminal device anymore
penk
parents: 2205
diff changeset
   195
4294
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
   196
    Debug := DebugKeyboard := false.
4602
a5c14fbf63cf class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4601
diff changeset
   197
    DefaultMaxHistorySize := 1000.
2207
d352a2f0a83a no changes on terminal device anymore
penk
parents: 2205
diff changeset
   198
4294
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
   199
    "
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
   200
     self initialize
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
   201
    "
2205
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   202
! !
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
   203
1052
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   204
!TerminalView class methodsFor:'defaults'!
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   205
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   206
defaultIcon
4030
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   207
    "This resource specification was automatically generated
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   208
     by the ImageEditor of ST/X."
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   209
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   210
    "Do not manually edit this!! If it is corrupted,
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   211
     the ImageEditor may not be able to read the specification."
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   212
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   213
    "
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   214
     self defaultIcon inspect
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   215
     ImageEditor openOnClass:self andSelector:#defaultIcon
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   216
     Icon flushCachedIcons
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   217
    "
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   218
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   219
    <resource: #image>
4028
33d2fd47db90 set icon resource
Stefan Vogel <sv@exept.de>
parents: 3758
diff changeset
   220
4030
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   221
    ^Icon
4725
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   222
        constantNamed:'TerminalView defaultIcon'
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   223
        ifAbsentPut:[(Depth4Image new) width:48; height:36; bits:(ByteArray fromPackedString:'
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   224
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@CL3L3L3L3L3L3L3L3L0@@@@@@@@@@@@@5UUUUUUUUUUUUUUUUUS@@@@@@@@@@@@MUUUUUUUUUUUUUUUUUUU
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   225
DP@@@@@@@@@@MUQDQDQDQDQDQDQDQEUUDP@@@@@@@@@@MUQDQDQDQDQDQDQDQDUUDQ@@@@@@@@@@MUQBIBQBP"H$P$QDQDUUDQ@@@@@@@@@@MUQDQDQDQDQD
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   226
QDQDQDUUDQD@@@@@@@@@MUQBH"P"P"IDQDQDQDUUDQD@@@@@@@@@MUQDQDQDQDQDQDQDQDUUDQDP@@@@@@@@MUQBH"H"H"P"H"QDQDUUDQDP@@@@@@@@MUQD
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   227
QDQDQDQDQDQDQDUUDQDP@@@@@@@@MUQBH$H"IBIDH"QDQDUUDQDP@@@@@@@@MUQDQDQDQDQDQDQDQDUUDQDP@@@@@@@@MUQBQDQDQDQDQDQDQDUUDQDP@@@@
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   228
@@@@MUQDQDQDQDQDQDQDQDUUDQDP@@@@@@@@MUQBH"P$H"P$QDQDQDUUDQDP@@@@@@@@MUQDQDQDQDQDQDQDQDUUDQDP@@@@@@@@MUQBP"H$QDQDQDQDQDUU
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   229
DQDP@@@@@@@@MUUDQDQDQDQDQDQDQEUUDQD@@@@@@@@@MUUUUUUUUUUUUUUUUUUUDQ@@@@@@@@@@@5UUUUUUUUUUUUUUUUUQDP@@@@@@@@@@@@@QDQDQDQDQ
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   230
DQDQDQDSL1D@@@@@@@@@@@@CL3L3L3L3L3L3L3L3LQD@@@@@@@@@@@@QDQDQDQDQDQDQDQDQDQD@@@@@@@@@@AUUUUUUUUUUUUUUUUUUDQD3@3@@@@@@@AUU
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   231
UUUUUUUUUU@@@@AUDQD@L@L@@@@@DQDQDQDQDQDQDQDQDQUUDQ@@@C@@@@@AUUUUUUUUUUUUUUUUUQDQD@@@@0@@@@@UUUUUUUUUUUUUUUUUTQ@@@@DQDQ@@
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   232
@@@UT"H"H"H"H"H"H%UUTQ@@DQDSL1@@@@EUUUUUUUUUUUUUUUUUDP@AEUTQL1@@@AURH"H"H"H"H"H"IUUQD@@AUUUSLP@@@UUUUUUUUUUUUUUUUUTQ@@@A
1596ff7d02e0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4718
diff changeset
   233
L3L1D@@@@QDQDQDQDQDQDQDQDQDP@@@ADQDQ@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@') ; colorMapFromArray:#[0 0 0 80 78 80 255 255 255 140 140 140 40 58 10 196 194 190]; mask:((ImageMask new) width:48; height:36; bits:(ByteArray fromPackedString:'
4030
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   234
@@@@@@@@@O???>@@@_????@@@?????0@@?????0@@?????8@@?????8@@?????<@@?????<@@?????>@@?????>@@?????>@@?????>@@?????>@@?????>@
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   235
@?????>@@?????>@@?????>@@?????>@@?????<@@?????8@@_????0@@C????<@@A????<@@C????<@@O?????X@O????<$@?????8HA????? PC????8G8
98bab0fabce9 changed: #defaultIcon
Stefan Vogel <sv@exept.de>
parents: 4028
diff changeset
   236
C????8?8G????1?8O????!!?0_????A? _???>A?@@@@@@@@@') ; yourself); yourself]
1317
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   237
!
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   238
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   239
defaultNumberOfColumns
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   240
    ^ 80
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   241
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   242
    "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
   243
    "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
   244
!
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   245
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   246
defaultNumberOfLines
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   247
    ^ 25
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   248
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
   249
    "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
   250
    "Modified: / 4.8.1998 / 17:48:31 / cg"
1052
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   251
! !
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   252
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   253
!TerminalView class methodsFor:'opening'!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
928
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   255
open
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   256
    ^ self openShell
928
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   257
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   258
    "
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   259
     VT100TerminalView open
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
   260
     VT52TerminalView open
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
   261
     TerminalView open
928
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   262
    "
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   263
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   264
    "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
   265
    "Modified: / 9.7.1998 / 17:55:37 / cg"
928
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   266
!
f9a117cb2bcc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 926
diff changeset
   267
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
openDummy
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   269
    "for testing purposes only - opens a dummy tty-view, which simply
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   270
     echoes whatever is typed in"
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   271
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    |in vt52|
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   274
    ForwardingStream isNil ifTrue:[ Smalltalk loadPackage:'stx:goodies' ].
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   275
    
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
    vt52 := self new.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    in := ForwardingStream on:''.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    in fwdStream:vt52.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    vt52 inStream:in.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    vt52 outStream:in.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    vt52 open
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    "
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
     self openDummy
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    "
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   289
openOnCommand:aCommandString
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   290
    "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
   291
     (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
   292
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   293
    ^ self openOnCommand:aCommandString onExit:[]
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   294
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   295
    "
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   296
     VT100TerminalView openOnCommand:'ls -l'
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   297
    "
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   298
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   299
    "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
   300
    "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
   301
!
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   302
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   303
openOnCommand:aCommand in:aDirectory
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   304
    "start a shell on a pseudo-TTY, open a terminalView on it
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   305
     (i.e. this is kind of an xterm)"
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   306
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   307
    ^ self openOnCommand:aCommand in:aDirectory onExit:[]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   308
        
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   309
    "
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   310
     TerminalView openOnCommand:'ls'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   311
     TerminalView openOnCommand:'ls' in:'/etc'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   312
    "
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   313
!
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   314
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   315
openOnCommand:aCommandString in:aDirectory onExit:exitBlockOrNil
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   316
    "start a command on a pseudo-TTY, open a terminalView on its output
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   317
     (i.e. this is kind of an xterm).
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   318
     When the command finishes, evaluate aBlock."
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   319
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   320
    ^ self 
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   321
        openWithAction: [:vt | vt startCommand:aCommandString in:aDirectory ]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   322
        onExit: exitBlockOrNil.
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   323
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   324
    "
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   325
     VT100TerminalView openOnCommand:'ls -l' in:'/etc' onExit:[]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   326
     VT100TerminalView openOnCommand:'ls -l' in:'/etc' onExit:[:vt | vt topView destroy]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   327
     VT100TerminalView openOnCommand:'ls -l' in:'/etc' onExit:[:vt | Dialog information:'Shell terminated'. vt topView destroy ]
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   328
    "
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   329
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   330
    "Created: / 9.7.1998 / 17:54:34 / cg"
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   331
    "Modified: / 4.8.1998 / 17:49:02 / cg"
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   332
!
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   333
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   334
openOnCommand:aCommandString onExit:aBlock
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   335
    "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
   336
     (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
   337
     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
   338
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   339
    ^ self openOnCommand:aCommandString in:nil onExit:aBlock
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   340
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   341
    "
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   342
     VT100TerminalView 
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   343
        openOnCommand:'ls -lR' 
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   344
        onExit:[:vt | 
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   345
            Dialog information:'Press OK to close'.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   346
            vt topView close.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   347
        ].
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   348
    "
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   349
!
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   350
1014
c0fdd428990c nice icon.
Claus Gittinger <cg@exept.de>
parents: 1009
diff changeset
   351
openOnInput:inStream output:outStream
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   352
    "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
   353
     kind of socket or pty). 
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   354
     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
   355
     from outStream is displayed in the terminal view.
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   356
     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
   357
     or telnet views (if connected to a modem, a com-program can also be
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   358
     implemented this way)."
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   359
4268
fe5165e5e997 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4267
diff changeset
   360
    |top vt|
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   361
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   362
    top := StandardSystemView new.
4268
fe5165e5e997 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4267
diff changeset
   363
    vt := self openOnInput:inStream output:outStream in:top.
fe5165e5e997 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4267
diff changeset
   364
    vt masterWindow:top.
2078
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   365
4268
fe5165e5e997 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4267
diff changeset
   366
    top extent:(vt preferredExtent).
2078
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   367
    top label:'shell'.
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   368
    top iconLabel:'shell'.
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   369
    top icon:(self defaultIcon).
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   370
    top open.
4268
fe5165e5e997 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4267
diff changeset
   371
    ^ vt
2078
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   372
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   373
    "Modified: / 5.5.1999 / 17:25:59 / cg"
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   374
!
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   375
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   376
openOnInput:inStream output:outStream in:aView
2778
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
   377
    "open a terminalView on the given streams 
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
   378
     (which are typically some kind of socket or pty). 
2078
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   379
     Keys pressed are sent to inStream, text appearing
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   380
     from outStream is displayed in the terminal view.
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   381
     This can be used to implement things like rlogin
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   382
     or telnet views (if connected to a modem, a com-program can also be
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   383
     implemented this way)."
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   384
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   385
    |scr vt|
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   386
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   387
    scr := ScrollableView for:self in:aView.
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   388
    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
   389
    vt := scr scrolledView.
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   390
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   391
    vt inStream:inStream.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   392
    vt outStream:outStream.
2778
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
   393
    vt startReaderProcessWhenVisible.
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   394
2078
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   395
    ^ scr
974
f47cf9925f7a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 972
diff changeset
   396
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   397
    "Modified: / 5.5.1999 / 17:25:59 / cg"
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   398
!
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   399
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
openShell
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   401
    "start a shell on a pseudo-TTY, open a terminalView on it
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   402
     (i.e. this is kind of an xterm)"
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   403
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
   404
    ^ self openShellIn:nil
992
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   405
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   406
    "
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   407
     VT100TerminalView openShell
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   408
    "
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   409
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
   410
    "Modified: / 21.7.1998 / 18:24:55 / cg"
992
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   411
!
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   412
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   413
openShellIn:aDirectory
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   414
    "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
   415
     (i.e. this is kind of an xterm)"
2f4282cab560 added startIn:someDir.
Claus Gittinger <cg@exept.de>
parents: 985
diff changeset
   416
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   417
    ^ self openWithAction:[:vt | vt startShellIn:aDirectory]
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   418
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   419
    "
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   420
     TerminalView openShellIn:'/etc'
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   421
     VT52TerminalView openShellIn:'/etc'
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   422
     VT100TerminalView openShellIn:'/etc'
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   423
    "
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   424
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   425
    "Created: / 20.7.1998 / 18:28:15 / cg"
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   426
    "Modified: / 5.5.1999 / 17:27:10 / cg"
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   427
!
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   428
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   429
openShellIn:aDirectory onExit:exitAction
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   430
    "start a shell on a pseudo-TTY, open a terminalView on it
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   431
     (i.e. this is kind of an xterm)"
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   432
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   433
    ^ self openWithAction:[:vt | vt startShellIn:aDirectory] onExit:exitAction
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   434
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   435
    "
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   436
     TerminalView openShellIn:'/etc' onExit:[ Dialog information:'Shell terminated' ]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   437
    "
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   438
!
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   439
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   440
openWithAction:setupAction
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   441
    "open a terminalView, let it start its command via setupAction, 
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   442
     which gets the instantiated terminalView as argument."
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   443
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   444
    ^ self openWithAction:setupAction onExit:[:vt | vt topView destroy]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   445
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   446
    "
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   447
     TerminalView openWithAction:[:vt | vt startShellIn:'/etc']
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   448
     TerminalView openWithAction:[:vt | vt startCommand:'ls -l' in:'/etc'.  vt shellTerminateAction:[].]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   449
    "
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   450
!
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   451
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   452
openWithAction:setupAction onExit:exitBlockOrNil
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   453
    "open a terminalView, let it start its command via setupAction, 
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   454
     which gets the instantiated terminalView as argument.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   455
     The default exitAction is to destroy the topView."
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   456
2163
a54248bd5ac6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2155
diff changeset
   457
    | top scr vt lbl|
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   459
    lbl := OperatingSystem isUNIXlike ifTrue:['shell'] ifFalse:['dos'].
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   460
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
    top := StandardSystemView new.
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
   462
    scr := HVScrollableView for:self in:top.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
    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
   464
    vt := scr scrolledView.
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   465
    exitBlockOrNil isNil ifTrue:[
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   466
        vt shellTerminateAction:[ top destroy ]
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   467
    ] ifFalse:[        
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   468
        vt shellTerminateAction:[
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   469
            top label:(lbl,' - terminated').
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   470
            exitBlockOrNil valueWithOptionalArgument:vt.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   471
        ].
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   472
    ].
4220
958b9bc73680 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4215
diff changeset
   473
    vt masterWindow: top.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
940
16c955286510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
   475
    top extent:(scr preferredExtent).
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   476
    top label:lbl.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   477
    top iconLabel:lbl.
1052
732fd3255894 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   478
    top icon:(self defaultIcon).
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   479
    top open.
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
   480
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   481
    setupAction value:vt.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   482
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   483
    ^ vt
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
    "
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   486
     TerminalView openWithAction:[:vt | vt startShellIn:'/etc']
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   487
     TerminalView openWithAction:[:vt | vt startCommand:'ls -l' in:'/etc'.  vt shellTerminateAction:[].]
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
    "
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
972
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   491
!TerminalView class methodsFor:'queries'!
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   492
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   493
isVisualStartable
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   494
    "returns whether this application class can be started via #open"
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   495
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   496
    self == TerminalView ifTrue:[^ false].
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   497
    ^ true
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   498
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   499
    "Created: / 10.6.1998 / 15:48:43 / cg"
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   500
! !
b7c2386d8c60 checkin from browser
ca
parents: 969
diff changeset
   501
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
!TerminalView methodsFor:'accessing'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
4897
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   504
filterStream
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   505
    "get a filter stream if any; if not nil, it gets all incoming data via nextPutAll:.
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   506
     Added to allow saving incoming data to a file, but can also be used to catch/filter/lookAt
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   507
     incoming data by some other program"
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   508
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   509
    ^ filterStream
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   510
!
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   511
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   512
filterStream:aStream
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   513
    "set a filter stream; if not nil, it gets all incoming data via nextPutAll:.
4317
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   514
     Added to allow saving incoming data to a file, but can also be used to catch/filter/lookAt
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   515
     incoming data by some other program"
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   516
4897
d933b75e436f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4886
diff changeset
   517
    filterStream := aStream.
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   518
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   519
    "Created: / 28.1.2002 / 20:56:04 / micha"
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   520
    "Modified: / 28.1.2002 / 20:56:11 / micha"
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   521
!
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   522
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
inStream
5140
3592eebfeb56 #DOCUMENTATION by mawalch
mawalch
parents: 5062
diff changeset
   524
    "return the stream, which gets all input data (i.e. keyboard input)"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   526
    ^ inStream
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   527
!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
inStream:something
5140
3592eebfeb56 #DOCUMENTATION by mawalch
mawalch
parents: 5062
diff changeset
   530
    "set the stream, which gets all input data (i.e. keyboard input)"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   532
    inStream := something.
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   533
!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
4639
8f2da8f007db class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   535
lineBufferHistory
8f2da8f007db class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   536
    ^ lineBufferHistory
8f2da8f007db class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   537
!
8f2da8f007db class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   538
8f2da8f007db class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   539
lineBufferHistory:aCollection
4799
99ae54e3d35d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4777
diff changeset
   540
    aCollection isNil ifTrue:[
99ae54e3d35d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4777
diff changeset
   541
        lineBufferHistory := OrderedCollection new.
99ae54e3d35d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4777
diff changeset
   542
    ] ifFalse:[
99ae54e3d35d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4777
diff changeset
   543
        lineBufferHistory := OrderedCollection withAll:aCollection.
99ae54e3d35d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4777
diff changeset
   544
    ].
4640
39bdcd978170 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4639
diff changeset
   545
    lineBufferHistoryPosition := lineBufferHistory size + 1.
5288
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
   546
    lineBufferHistoryChanged := false.
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
   547
!
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
   548
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
   549
lineBufferHistoryChanged
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
   550
    "true if it changed since either set explicitly or since the terminal was opened"
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
   551
    
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
   552
    ^ lineBufferHistoryChanged ? false
4639
8f2da8f007db class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   553
!
8f2da8f007db class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4634
diff changeset
   554
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   555
masterWindow:aTopView
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   556
    "if set, and a corresponding osCommand escape sequence is received,
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   557
     that topView's title, icon or other attribute is changed.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   558
     Needed to support xterm's 'set window title' escape sequence"
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   559
     
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   560
    masterWindow := aTopView.
4299
50d20c3d24cc class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4295
diff changeset
   561
!
50d20c3d24cc class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4295
diff changeset
   562
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
outStream
2954
d9d43dc5d4a5 coments
Claus Gittinger <cg@exept.de>
parents: 2810
diff changeset
   564
    "return the stream, which is used to present data in the view (i.e. shell output)"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   566
    ^ outStream
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   567
!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
outStream:something
2954
d9d43dc5d4a5 coments
Claus Gittinger <cg@exept.de>
parents: 2810
diff changeset
   570
    "set the stream, which is used to present data in the view (i.e. shell output)"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   572
    outStream := something.
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
   573
!
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   574
1004
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   575
readerProcess
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   576
    ^ readerProcess
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   577
!
8742d3af41a4 readerProcess access
tz
parents: 1000
diff changeset
   578
4317
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   579
recorderStream:aWriteStream
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   580
    "set a recorder stream; if not nil, it gets all user input (keyboard) data via nextPut:.
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   581
     Allows saving of user input to a file, for later replay of a session"
4317
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   582
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   583
    recorderStream := aWriteStream.
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   584
!
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   585
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   586
shellDirectory:aPathname
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   587
    "the directory, in which the shell/command should be executed.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   588
     By default, the 'current' directory is used"
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   589
     
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   590
    shellDirectory := aPathname.
4630
dccaedc34013 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4614
diff changeset
   591
!
dccaedc34013 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4614
diff changeset
   592
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   593
shellTerminateAction:aBlock
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   594
    "set the block which is evaluated when the shell terminates.
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   595
     Can be used to close down the application or perform any other cleanup action.
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
   596
     The default shows a dialog, that the shell/command has terminated"
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   597
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   598
    shellTerminateAction := aBlock.
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   599
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   600
    "Created: / 12.6.1998 / 17:02:58 / cg"
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   601
! !
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   602
5638
df7b96c04c11 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5538
diff changeset
   603
!TerminalView methodsFor:'accessing-behavior'!
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   604
5763
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
   605
disableLineEditMode
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
   606
    self lineEditMode:false.
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
   607
!
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
   608
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
   609
enableLineEditMode
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
   610
    self lineEditMode:true.
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
   611
!
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
   612
5249
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   613
filterOnly:aBoolean
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   614
    "if true, any output from the program is ONLY
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   615
     sent to the filterStream (if any), not to the window.
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   616
     Can be used to divert output to a file, without showing
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   617
     it (eg. for mass-data recording)"
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   618
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   619
    filterOnly := aBoolean
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   620
!
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   621
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   622
ignoreOutput:aBoolean
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   623
    "if true, any output from the program is ignored
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   624
     (not processed at all).
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   625
     Can be used to temporarily disable processing
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   626
     (for example via a button) when huge mass-output is 
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   627
     coming which we want to ignore."
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   628
    
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   629
    ignoreOutput := aBoolean
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   630
!
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
   631
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   632
inputTranslateBackspaceToDelete
5149
7c471b54fe48 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
   633
   "translating backspace to delete on user input"
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   634
   
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   635
    ^ inputTranslateBackspaceToDelete
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   636
!
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   637
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   638
inputTranslateBackspaceToDelete:aBoolean
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   639
    inputTranslateBackspaceToDelete := aBoolean.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   640
!
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   641
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   642
inputTranslateCRToNL
5149
7c471b54fe48 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
   643
    "translating <RETURN> to <NL> on user input"
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   644
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   645
    ^ inputTranslateCRToNL
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   646
!
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   647
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   648
inputTranslateCRToNL:aBoolean
5149
7c471b54fe48 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
   649
    "translate <RETURN> to <NL> on user input"
7c471b54fe48 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
   650
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   651
    inputTranslateCRToNL := aBoolean.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   652
!
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   653
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   654
lineEditMode:aBoolean
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   655
    "if true, I do some limited line editing for the user's input;
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   656
     the user can use cursor keys to navigate in the input history and
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   657
     reissue a previously entered input line.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   658
     Special: <SHIFT>-cursor up goes back to the previously selected history line.
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   659
     (not to the previous line).
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   660
     For example, if the user types:
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   661
        a <RETURN>
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   662
        b <RETURN>
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   663
        c <RETURN>
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   664
        <CURSOR-UP> -> shows 'c'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   665
        <CURSOR-UP> -> shows 'b'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   666
        <CURSOR-UP> -> shows 'a'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   667
        123 <RETURN> -> resends 'a123'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   668
        <SHIFT-CURSOR-UP> -> shows 'a' again which is the previously selected history line(not a123)
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   669
        <CURSOR-DOWN> -> shows 'b'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   670
        <RETURN> -> sends 'b'
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   671
    "
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   672
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   673
    lineEditMode := aBoolean.
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   674
!
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   675
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   676
localEcho:aBoolean
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   677
    "enable/disable local echo"
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   678
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   679
    localEcho := aBoolean
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   680
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   681
    "Created: / 5.5.1999 / 17:53:16 / cg"
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   682
!
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   683
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   684
noColors
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   685
    "the noColors boolean disables color changes (from color rendition escape sequences)"
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   686
    
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   687
    ^ noColors
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   688
!
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   689
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   690
noColors:aBoolean
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   691
    "the noColors boolean disables color changes (from color rendition escape sequences)"
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   692
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   693
    noColors := aBoolean.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   694
!
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   695
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   696
sendControlKeys
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   697
    "there is some conflict with control key handling, for keys such as CTRL-c:
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   698
     it is both a shortcut (eg. Copy) and sometimes required in the terminal (interrupt key).
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   699
     For this, we look if there is a current selection, and if so, always treat it as a 
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   700
     shortcut (and NOT sending it to the terminal's program).
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   701
     Otherwise, if there is no selection, look at the 'sendControlKeys' boolean.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   702
     If it is set (which is the default), then send it to the terminal, otherwise perform the editor op.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   703
     Thus, an application containing me can offer a menu function (or toggle), 
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   704
     to control this behavior on the UI level."
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   705
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   706
    ^ sendControlKeys
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   707
!
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   708
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   709
sendControlKeys:aBoolean
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   710
    "there is some conflict with control key handling, for keys such as CTRL-c:
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   711
     it is both a shortcut (eg. Copy) and sometimes required in the terminal (interrupt key).
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   712
     For this, we look if there is a current selection, and if so, always treat it as a 
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   713
     shortcut (and NOT sending it to the terminal's program).
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   714
     Otherwise, if there is no selection, look at the 'sendControlKeys' boolean.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   715
     If it is set (which is the default), then send it to the terminal, otherwise perform the editor op.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   716
     Thus, an application containing me can offer a menu function (or toggle), 
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   717
     to control this behavior on the UI level."
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   718
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   719
    sendControlKeys := aBoolean
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   720
!
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   721
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   722
signalControlKeys
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   723
    "if true (default on Windows), CTRL-C sends an interrupt to 
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   724
     the program. Otherwise, it is sent as a character (0x03)"
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   725
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   726
    ^ signalControlKeys
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   727
!
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   728
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   729
signalControlKeys:aBoolean
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   730
    "if true (default on Windows), CTRL-C sends an interrupt to 
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   731
     the program. Otherwise, it is sent as a character (0x03)"
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   732
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   733
    signalControlKeys := aBoolean
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   734
!
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
   735
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   736
translateNLToCRNL
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   737
    "translate NL to CRNL on output"
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   738
    
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   739
    ^ translateNLToCRNL
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   740
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   741
    "Created: / 28.1.2002 / 20:32:10 / micha"
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   742
!
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   743
4266
0113eb73167c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4265
diff changeset
   744
translateNLToCRNL:aBoolean
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   745
    "translate NL to CRNL on output"
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
   746
4266
0113eb73167c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4265
diff changeset
   747
    translateNLToCRNL := aBoolean.
2076
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   748
60558bc12d09 public access to filterStream;
Michael Beyl <mb@exept.de>
parents: 2075
diff changeset
   749
    "Created: / 28.1.2002 / 20:32:10 / micha"
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
   750
! !
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
!TerminalView methodsFor:'cursor handling'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
933
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   754
cursorDown:n
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   755
    cursorLine + n > list size ifTrue:[
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   756
        list := list , (Array new:n).
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   757
        self textChanged.
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   758
    ].
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   759
    super cursorDown:n
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   760
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   761
    "Modified: / 10.6.1998 / 17:18:41 / cg"
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   762
    "Created: / 10.6.1998 / 17:18:50 / cg"
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   763
!
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
   764
968
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   765
cursorMovementAllowed
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   766
    "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
   767
     (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
   768
     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
   769
     cursor positioning escape sequences arriving from the
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   770
     stream."
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   771
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   772
    ^ false
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   773
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   774
    "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
   775
!
1cb313e6635b do not allow cursor movement (via buttonPress).
Claus Gittinger <cg@exept.de>
parents: 964
diff changeset
   776
2169
132759c9c32c numberOfTerminalCols query
Claus Gittinger <cg@exept.de>
parents: 2163
diff changeset
   777
numberOfTerminalCols
132759c9c32c numberOfTerminalCols query
Claus Gittinger <cg@exept.de>
parents: 2163
diff changeset
   778
    ^ numberOfColumns
132759c9c32c numberOfTerminalCols query
Claus Gittinger <cg@exept.de>
parents: 2163
diff changeset
   779
!
132759c9c32c numberOfTerminalCols query
Claus Gittinger <cg@exept.de>
parents: 2163
diff changeset
   780
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   781
numberOfTerminalColumns
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   782
    ^ numberOfColumns
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   783
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   784
    "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
   785
!
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   786
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   787
numberOfTerminalLines
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   788
    "/ 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
   789
    "/ 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
   790
    "/ in ListView ...
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   791
    "/ ... 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
   792
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   793
    ^ numberOfLines
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   794
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   795
    "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
   796
    "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
   797
!
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   798
1077
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   799
restoreCursor
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   800
    |l c|
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   801
2192
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   802
    savedCursor isNil ifTrue:[
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   803
        l := c := 1.
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   804
    ] ifFalse:[
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   805
        l := savedCursor y.
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   806
        c := savedCursor x.
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   807
    ].
1077
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   808
    self cursorLine:l col:c.
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   809
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   810
    "Created: / 14.8.1998 / 13:49:24 / cg"
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   811
!
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   812
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   813
saveCursor
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   814
    savedCursor := cursorCol @ cursorLine
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   815
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   816
    "Created: / 14.8.1998 / 13:48:45 / cg"
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   817
    "Modified: / 14.8.1998 / 13:49:32 / cg"
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   818
!
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
   819
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
validateCursorCol:col inLine:line
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
    "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
   822
     Here, the linelength is enforced"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
2268
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
   824
    col > numberOfColumns ifTrue:[
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
   825
        autoWrapFlag ifTrue:[
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
   826
            self endEntry.
4452
ff2a970ba725 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4450
diff changeset
   827
            self cursorLine:(self cursorLine + 1) col:1 " (col-numberOfColumns) ".
2268
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
   828
            ^ 1.
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
   829
        ].
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
   830
    ].
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   831
    ^ col min:numberOfColumns
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
   833
    "Modified: / 10.6.1998 / 15:09:41 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   836
!TerminalView methodsFor:'defaults'!
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   837
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   838
anyKeyCodes
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   839
    ^ IdentityDictionary withKeysAndValues:
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   840
        #(
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   841
             #Escape      '\e'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   842
             #BackSpace   '\b'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   843
             #Return      '\r'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   844
             #Delete      '\0177'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   845
             #Tab         '\t'
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   846
         )
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   847
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   848
    "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
   849
! !
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   850
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
!TerminalView methodsFor:'event handling'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   853
computeNumberOfLinesShown
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   854
    |prevNLines prevNCols|
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   855
4518
e2bd93d275e5 class: TerminalView
Stefan Vogel <sv@exept.de>
parents: 4492
diff changeset
   856
    prevNCols := (innerWidth // gc font width).
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   857
    prevNLines := nFullLinesShown.
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   858
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   859
    super computeNumberOfLinesShown.
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   860
4518
e2bd93d275e5 class: TerminalView
Stefan Vogel <sv@exept.de>
parents: 4492
diff changeset
   861
    ((innerWidth // gc font width) ~~ prevNCols
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   862
    or:[prevNLines ~~ nFullLinesShown]) ifTrue:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   863
        self defineWindowSize.
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   864
    ]
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   865
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   866
    "Created: / 12.6.1998 / 22:34:39 / cg"
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
   867
    "Modified: / 20.6.1998 / 19:45:28 / cg"
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   868
!
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
   869
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   870
defineWindowSize
2192
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   871
    | delta prevNumCols prevNumLines|
1359
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   872
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
   873
    self assert:(rangeEndLine notNil).
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
   874
    self assert:(numberOfLines notNil).
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   875
"/self halt.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   876
"/self realized ifFalse:[
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   877
"/    "/ iconfified
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   878
"/    ^ self
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   879
"/].
4518
e2bd93d275e5 class: TerminalView
Stefan Vogel <sv@exept.de>
parents: 4492
diff changeset
   880
    numberOfColumns := (innerWidth // gc font width).
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   881
    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
   882
    numberOfLines := nFullLinesShown.
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
   883
    ((prevNumCols == numberOfColumns) and:[prevNumLines == numberOfLines]) ifTrue:[
1359
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   884
        ^ self
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   885
    ].
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   886
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
   887
    rangeEndLine := numberOfLines - delta.
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
   888
    self assert:(rangeEndLine notNil).
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   889
1359
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   890
    "/ any idea, how to do this under windows ?
c571a792c5b0 resize if font changes
Claus Gittinger <cg@exept.de>
parents: 1358
diff changeset
   891
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   892
    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
   893
        "/
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   894
        "/ 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
   895
        "/ 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
   896
        "/
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   897
        (inStream notNil 
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   898
        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
   899
        and:[inStream isOpen]]) ifTrue:[
4285
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
   900
            Debug ifTrue:[
4287
22ed06f6e073 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
   901
                Transcript showCR:'VT100: windowSize changed nLines to ', numberOfLines printString.
4285
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
   902
            ].
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   903
            (OperatingSystem 
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   904
                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
   905
                width:numberOfColumns
4285
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
   906
                height:numberOfLines
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
   907
            ) ifFalse:[
2192
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   908
                Debug ifTrue:[
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   909
                    Transcript showCR:'VT100: cannot change windowSize'.
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   910
                ].
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   911
            ].
964
43d6e33a4240 keep cursor off while more input is arriving.
Claus Gittinger <cg@exept.de>
parents: 958
diff changeset
   912
        ].
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   913
        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
   914
            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
   915
        ]
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   916
    ].
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   917
4655
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
   918
    prevNumCols := numberOfColumns.
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
   919
    prevNumLines := numberOfLines.
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
   920
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
   921
    "Created: / 11-06-1998 / 22:51:39 / cg"
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
   922
    "Modified: / 17-07-2014 / 19:40:45 / cg"
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   923
!
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
   924
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
keyPress:aKey x:x y:y
4164
7ed0d0bbc7cd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   926
    <resource: #keyboard (#Control #Control_L #Control_R
7ed0d0bbc7cd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   927
                          #Shift #Shift_L #Shift_R
7ed0d0bbc7cd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   928
                          #Alt #Alt_L #Alt_R
7ed0d0bbc7cd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   929
                          #Cmd #Cmd_L #Cmd_R
7ed0d0bbc7cd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   930
                          #Meta #Meta_L #Meta_R
7ed0d0bbc7cd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   931
                          #Return)>
7ed0d0bbc7cd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
   932
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
   933
    |rest event rawKey seq shortCut|
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   934
5278
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
   935
    ( #(ZoomIn ZoomOut ZoomInAll ZoomOutAll) includes:aKey) ifTrue:[
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
   936
        super keyPress:aKey x:x y:y.
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
   937
    ].
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
   938
    
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   939
    "/ somewhat complicated, since some characters
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   940
    "/ should go untranslated (CTRL-key),
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   941
    "/ even if defined as function keys.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   943
    inStream isNil ifTrue:[^ self].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   944
4294
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
   945
    DebugKeyboard ifTrue:[
2192
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   946
        Transcript showCR:'----'; show:'keyPress:' ; showCR:aKey printString.
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   947
    ].
4601
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
   948
    self shouldProcessInputInLineEditMode ifTrue:[
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
   949
        (self keyPressInLineEditMode:aKey) ifTrue:[^ self].
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
   950
    ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
    aKey isCharacter ifTrue:[
2466
f986a03f160f deselect on regular key
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   953
        self deselect.
f986a03f160f deselect on regular key
Claus Gittinger <cg@exept.de>
parents: 2450
diff changeset
   954
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   955
        localEcho ifTrue:[
3758
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   956
            self nextPut:aKey.
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   957
            self flush.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   958
        ].
4290
bad371611ba6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4288
diff changeset
   959
        "/ send it down to inStream ...
4317
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   960
        self sendCharacter:aKey.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
        ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
1366
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   964
    (#(Control Control_L Control_R
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   965
      Shift Shift_L Shift_R
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   966
      Alt Alt_L Alt_R
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   967
      Cmd Cmd_L Cmd_R
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   968
      Meta Meta_L Meta_R) includes:aKey) ifTrue:[
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   969
        ^ self
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   970
    ].
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
   971
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   972
    "/
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
   973
    "/ 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
   974
    "/
2078
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   975
    (aKey == #Return
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   976
    and:[inputTranslateCRToNL]) ifTrue:[
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   977
        seq := '\n'.
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   978
    ] ifFalse:[
4324
f45610b1f1ad class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4322
diff changeset
   979
        (aKey == #BackSpace
f45610b1f1ad class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4322
diff changeset
   980
        and:[inputTranslateBackspaceToDelete]) ifTrue:[
f45610b1f1ad class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4322
diff changeset
   981
            seq := kbdSequences at:#Delete ifAbsent:[ kbdSequences at:aKey ifAbsent:nil ].
f45610b1f1ad class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4322
diff changeset
   982
        ] ifFalse:[
f45610b1f1ad class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4322
diff changeset
   983
            seq := kbdSequences at:aKey ifAbsent:nil.
f45610b1f1ad class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4322
diff changeset
   984
        ].
2078
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   985
    ].
3758
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   986
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
    seq notNil ifTrue:[
4294
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
   988
        DebugKeyboard ifTrue:[
2192
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   989
            Transcript show:'->' ; showCR:seq storeString.
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
   990
        ].
4105
a77be3c32b6d changed:
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
   991
        seq := seq withoutCEscapes.
2078
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
   992
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   993
        localEcho ifTrue:[
3758
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   994
            seq do:[:k | self nextPut:k].
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
   995
            self flush.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
   996
        ].
4317
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
   997
        self send:seq.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
        ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1001
    self sensor ctrlDown ifTrue:[
1366
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1002
        (aKey startsWith:'Ctrl') ifTrue:[
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1003
            rawKey := aKey
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1004
        ] ifFalse:[
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1005
            "/ already translated - undo it.
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1006
        
5874
00c0cc2441a9 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5763
diff changeset
  1007
            event := WindowGroup lastEvent.
1366
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1008
            rawKey := event rawKey.
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1009
            rawKey isCharacter ifTrue:[
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1010
                rawKey := 'Ctrl' , rawKey.
137876addbea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1363
diff changeset
  1011
            ]
1360
fb843effdaea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1359
diff changeset
  1012
        ]
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1013
    ] ifFalse:[
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1014
        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
  1015
    ].
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1016
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1017
    "/
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1018
    "/ 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
  1019
    "/
4294
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
  1020
    DebugKeyboard ifTrue:[
2192
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
  1021
        Transcript show:'raw ->' ; showCR:rawKey storeString.
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
  1022
    ].
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1023
    
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1024
    "/ there is some conflict here, for keys such as CTRL-c:
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1025
    "/ it is both a shortcut (eg. Copy) and sometimes required in the terminal (interrupt key).
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1026
    "/ For this, we look if there is a current selection, and if so, always treat it as a 
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1027
    "/ shortcut (and NOT sending it to the terminal's program).
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1028
    "/ Otherwise, if there is no selection, look at the "sendControlKeys" boolean.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1029
    "/ If it is set (which is the default), then send it to the terminal, otherwise perform the editor op.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1030
    "/ Thus, an application containing me can offer a menu function (or toggle), to control this behavior
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1031
    "/ on the UI level.
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1032
    
5006
22bdac1a5826 device access
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
  1033
    shortCut := device keyboardMap at:aKey ifAbsent:nil.
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1034
    (shortCut notNil and:[shortCut isSymbol]) ifTrue:[
4811
ef8ec8a8dbb6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4809
diff changeset
  1035
        (sendControlKeys not or:[ self hasSelection or:[ shortCut == #Paste] ]) ifTrue:[
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  1036
            DebugKeyboard ifTrue:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  1037
                Transcript showCR:'internal handling'.
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  1038
            ].
4811
ef8ec8a8dbb6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4809
diff changeset
  1039
            ^ super keyPress:shortCut x:x y:y
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  1040
        ].
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1041
    ].    
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1042
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
    seq := kbdSequences at:rawKey ifAbsent:nil.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
    seq notNil ifTrue:[
4294
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
  1045
        DebugKeyboard ifTrue:[
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  1046
            Transcript show:'seq ->' ; showCR:seq storeString.
3758
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
  1047
        ].
4317
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
  1048
        self send:(seq withoutCEscapes).
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
        ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
    ].
6044
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1051
    rawKey notNil ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1052
        (rawKey startsWith:'Ctrl') ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1053
            rest := rawKey copyFrom:5.
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1054
            rest size == 1 ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1055
                rest := rest at:1.
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1056
                (rest asLowercase between:$a and:$z) ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1057
                    DebugKeyboard ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1058
                        Transcript show:'ctrl ->' ; showCR:(Character controlCharacter:rest) storeString.
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1059
                    ].
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1060
                    (signalControlKeys and:[rawKey == #Ctrlc]) ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1061
                        self doSendInterrupt.
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1062
                        ^ self.
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1063
                    ].
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1064
                    self sendCharacter:(Character controlCharacter:rest).
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1065
                    ^ self
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  1066
                ].
6044
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1067
            ]
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1068
        ].
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1069
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1070
        ((rawKey startsWith:'Control')
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1071
            or:[ (rawKey startsWith:'Shift')
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1072
            or:[ (rawKey startsWith:'Alt')
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1073
            or:[ (rawKey = 'Ctrl')
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1074
        ]]]) ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1075
            DebugKeyboard ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1076
                Transcript showCR:'modifier ignored'.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
            ].
6044
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1078
            ^ self
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1079
        ].
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1080
        (rawKey startsWith:'Cmd') ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1081
            DebugKeyboard ifTrue:[
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1082
                Transcript showCR:'CMD handled internal'.
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1083
            ].
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1084
            ^ super keyPress:aKey x:x y:y
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1085
        ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
    ].
6044
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1087
    
4294
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
  1088
    DebugKeyboard ifTrue:[
6044
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1089
        Transcript showCR:'unhandled: %1' with:(rawKey ? aKey).
2192
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
  1090
    ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
4294
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
  1092
    "
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
  1093
     DebugKeyboard := true
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
  1094
    "
44d208158d1e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4290
diff changeset
  1095
4105
a77be3c32b6d changed:
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
  1096
    "Modified: / 25-01-2012 / 10:43:06 / cg"
6044
e7fd53f408b8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6023
diff changeset
  1097
    "Modified: / 26-04-2019 / 09:55:40 / Claus Gittinger"
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
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1100
keyPressInLineEditMode:aKey
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1101
    "readline alike line editing.
4815
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1102
     cursorUp/down select a previous line from the history (unix shell bahevior).
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1103
     shift cursorUp selects a previous selected history line from the history (windows shell bahevior).
4816
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1104
     cursor left/right/^A/^E/backspace position/edit inside that line.
4815
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1105
     Return true, if the character was processed,
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1106
     false if not. Then, the caller should proceed as usual."
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1107
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1108
    |clearLine|
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1109
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1110
    clearLine :=
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1111
        [
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1112
            lineBufferCursorPosition-1 timesRepeat:[ self deleteCharBeforeCursor ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1113
            (lineBuffer size-(lineBufferCursorPosition-1)) timesRepeat:[ self deleteCharAtCursor].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1114
        ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1115
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1116
    "/ in lineEditMode, defer sending to the pty, until a newline is entered
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1117
    lineBuffer isNil ifTrue:[
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1118
        lineBuffer := String new.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1119
        lineBufferCursorPosition := 1.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1120
    ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1121
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1122
    aKey isCharacter ifTrue:[
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1123
        lineBuffer := (lineBuffer copyTo:lineBufferCursorPosition-1)
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1124
                      , aKey
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1125
                      , (lineBuffer copyFrom:lineBufferCursorPosition).
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1126
        self insertCharAtCursor:aKey.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1127
        lineBufferCursorPosition := lineBufferCursorPosition + 1.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1128
        ^ true.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1129
    ].
4601
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1130
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1131
    aKey == #Return ifTrue:[
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1132
        "/ as the pty is in echo mode,
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1133
        "/ we should either disable echo for the following,
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1134
        "/ or remove from the textview and let the program redraw them.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1135
        "/ the second alternative looks easier for now...
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1136
        clearLine value.
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  1137
        self sendCR:lineBuffer.
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  1138
4815
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1139
        lastSelectedLineBufferHistoryPosition := lineBufferHistoryPosition.
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1140
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1141
        lineBufferHistory isNil ifTrue:[
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1142
            lineBufferHistory := OrderedCollection new.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1143
        ].
5904
7b379fe88950 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 5888
diff changeset
  1144
        (lineBufferHistory notEmpty and:[lineBufferHistory last isEmpty]) ifTrue:[
5288
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
  1145
            lineBufferHistory removeLast.
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
  1146
            lineBufferHistoryChanged := true.
4594
344e42610a24 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4593
diff changeset
  1147
        ].
5234
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1148
        "/ do not remember blank lines
5904
7b379fe88950 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 5888
diff changeset
  1149
        (lineBuffer notNil and:[lineBuffer isBlank not]) ifTrue:[
5234
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1150
            "/ do not remember repetitions
5904
7b379fe88950 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 5888
diff changeset
  1151
            (lineBufferHistory notEmpty and:[lineBufferHistory last = lineBuffer]) ifFalse:[
5234
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1152
                lineBufferHistory addLast:lineBuffer.
5288
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
  1153
                lineBufferHistoryChanged := true.
5234
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1154
            ].
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1155
            lineBufferHistoryPosition := lineBufferHistory size + 1.
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1156
            lineBuffer := nil.
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1157
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1158
            maxHistorySize notNil ifTrue:[
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1159
                [ lineBufferHistory size > maxHistorySize] whileTrue:[
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1160
                    lineBufferHistory removeFirst.
5288
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
  1161
                    lineBufferHistoryChanged := true.
5234
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1162
                ].
4602
a5c14fbf63cf class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4601
diff changeset
  1163
            ].
a5c14fbf63cf class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4601
diff changeset
  1164
        ].
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1165
        ^ true.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1166
    ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1167
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1168
    aKey == #BackSpace ifTrue:[
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1169
        lineBufferCursorPosition > 1 ifFalse:[
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1170
            self beep.  
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1171
            ^ true
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1172
        ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1173
        lineBuffer := (lineBuffer copyTo:lineBufferCursorPosition-2)
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1174
                      , (lineBuffer copyFrom:lineBufferCursorPosition).
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1175
        self deleteCharBeforeCursor.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1176
        lineBufferCursorPosition := lineBufferCursorPosition - 1.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1177
        ^ true.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1178
    ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1179
4817
a76ea4e5d859 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1180
    ((aKey == #BeginOfText) or:[aKey == #Ctrla]) ifTrue:[
4816
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1181
        lineBufferCursorPosition > 1 ifFalse:[
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1182
            self beep.  
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1183
            ^ true
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1184
        ].
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1185
        lineBufferCursorPosition := 1.
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1186
        self cursorToBeginOfLine.
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1187
        ^ true.
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1188
    ].
4817
a76ea4e5d859 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1189
    ((aKey == #EndOfText) or:[aKey == #Ctrle]) ifTrue:[
4816
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1190
        lineBufferCursorPosition := lineBuffer size.
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1191
        self cursorToEndOfLine.
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1192
        ^ true.
7d46a1566c69 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4815
diff changeset
  1193
    ].
5538
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1194
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1195
    aKey == #Ctrlr ifTrue:[
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1196
        lineBufferHistory size >= lineBufferHistoryPosition ifTrue:[
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1197
            lineBufferHistory at:lineBufferHistoryPosition put:lineBuffer.
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1198
        ] ifFalse:[
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1199
            lineBufferHistory add:lineBuffer.
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1200
        ].
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1201
        
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1202
        clearLine value.
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1203
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1204
        lineBuffer := lineBufferHistory at:lineBufferHistoryPosition ifAbsent:[lineBufferHistory last].
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1205
        self insertStringAtCursor:lineBuffer.
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1206
        lineBufferCursorPosition := lineBuffer size + 1.
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1207
        self makeCursorVisible.
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1208
        ^ true.    
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1209
    ].
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1210
    
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1211
    aKey == #CursorLeft ifTrue:[
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1212
        lineBufferCursorPosition > 1 ifFalse:[
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1213
            self beep.  
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1214
            ^ true
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1215
        ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1216
        lineBufferCursorPosition := lineBufferCursorPosition - 1.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1217
        self cursorLeft.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1218
        ^ true.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1219
    ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1220
    aKey == #CursorRight ifTrue:[
4641
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  1221
        lineBufferCursorPosition <= lineBuffer size ifFalse:[
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1222
            self beep.  
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1223
            ^ true
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1224
        ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1225
        lineBufferCursorPosition := lineBufferCursorPosition + 1.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1226
        self cursorRight.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1227
        ^ true.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1228
    ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1229
    aKey == #CursorUp ifTrue:[
5703
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1230
        |p|
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1231
4603
e6736a82809f class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4602
diff changeset
  1232
        (lineBufferHistoryPosition notNil and:[lineBufferHistoryPosition > 1]) ifFalse:[
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1233
            self beep.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1234
            ^ true
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1235
        ].
5234
a63a39bc4b18 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5231
diff changeset
  1236
    
4595
b6bca31ea81b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4594
diff changeset
  1237
        "/ remember the current lineBuffer (but only if it is the last)
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1238
        lineBufferHistoryPosition > lineBufferHistory size ifTrue:[
5703
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1239
            "/ do not remember repetitions
5904
7b379fe88950 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 5888
diff changeset
  1240
            (lineBufferHistory notEmpty and:[lineBufferHistory last = lineBuffer]) ifFalse:[
5703
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1241
                lineBufferHistory add:lineBuffer.
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1242
                lineBufferHistoryChanged := true.
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1243
            ].
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1244
        ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1245
        clearLine value.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1246
4815
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1247
        (self sensor shiftDown and:[lastSelectedLineBufferHistoryPosition notNil]) ifTrue:[
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1248
            lineBufferHistoryPosition := lastSelectedLineBufferHistoryPosition.
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1249
        ] ifFalse:[
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1250
            lineBufferHistoryPosition := lineBufferHistoryPosition - 1.
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1251
        ].
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1252
        "/ lastSelectedLineBufferHistoryPosition := lineBufferHistoryPosition.
5703
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1253
        p := lineBufferHistoryPosition.
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1254
        [
5704
a74a4de7393a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5703
diff changeset
  1255
            lineBuffer := lineBufferHistory at:p ifAbsent:[nil].
5703
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1256
            p := p - 1.
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1257
        ] doUntil:[
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1258
            p == 0 or:[ lineBuffer notEmptyOrNil ]
f6122d30bce9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5702
diff changeset
  1259
        ].
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1260
        self insertStringAtCursor:lineBuffer.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1261
        lineBufferCursorPosition := lineBuffer size + 1.
4819
99724ae276bd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4817
diff changeset
  1262
        self makeCursorVisible.
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1263
        ^ true.    
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1264
    ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1265
    aKey == #CursorDown ifTrue:[
4603
e6736a82809f class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4602
diff changeset
  1266
        (lineBufferHistoryPosition notNil and:[lineBufferHistoryPosition < lineBufferHistory size]) ifFalse:[
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1267
            self beep.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1268
            ^ true
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1269
        ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1270
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1271
        clearLine value.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1272
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1273
        lineBufferHistoryPosition := lineBufferHistoryPosition + 1.
4815
c5204a7261c1 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4813
diff changeset
  1274
        "/ lastSelectedLineBufferHistoryPosition := lineBufferHistoryPosition.
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1275
        lineBuffer := lineBufferHistory at:lineBufferHistoryPosition.
4594
344e42610a24 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4593
diff changeset
  1276
        lineBufferHistoryPosition >= lineBufferHistory size ifTrue:[
344e42610a24 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4593
diff changeset
  1277
            lineBufferHistory removeLast.
5288
b4e6f1bf9ea6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5278
diff changeset
  1278
            lineBufferHistoryChanged := true.
4594
344e42610a24 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4593
diff changeset
  1279
        ].
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1280
        self insertStringAtCursor:lineBuffer.
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1281
        lineBufferCursorPosition := lineBuffer size + 1.
4819
99724ae276bd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4817
diff changeset
  1282
        self makeCursorVisible.
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1283
        ^ true.    
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1284
    ].
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1285
    ^ false.
5538
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1286
f4a375bbf778 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5537
diff changeset
  1287
    "Modified: / 03-05-2017 / 16:28:56 / cg"
5904
7b379fe88950 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 5888
diff changeset
  1288
    "Modified: / 14-09-2018 / 17:01:39 / Stefan Vogel"
4593
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1289
!
370db87f8232 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  1290
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1291
shellTerminated
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1292
    "shell has terminated"
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1293
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1294
"/Delay waitForSeconds:10.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1295
    [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
  1296
"/
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1297
    self closeDownShellAndStopReaderProcess.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1298
946
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1299
    shellTerminateAction notNil ifTrue:[
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1300
        shellTerminateAction value
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1301
    ]
45e3eac9c087 added shellTerminateAction
Claus Gittinger <cg@exept.de>
parents: 945
diff changeset
  1302
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1303
    "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
  1304
!
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1305
4601
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1306
shouldProcessInputInLineEditMode
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1307
    "should input be processed in the readline edit mode?"
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1308
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1309
    |termiosInfo|
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1310
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1311
    lineEditMode == true ifFalse:[^ false].
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1312
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1313
    "/ check if tty is in raw mode - then don't do lineEditMode
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1314
    (OperatingSystem isUNIXlike
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1315
    and:[ inStream isExternalStream ]) ifTrue:[
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1316
        termiosInfo := inStream tcgetattr.
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1317
        ((termiosInfo at:#lflags) at:#icanon) ifFalse:[^ false].
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1318
    ].
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1319
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1320
    "/ don't know how to do that on non-unix systems
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1321
    ^ true
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1322
!
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  1323
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1324
sizeChanged:how
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1325
    super sizeChanged:how.
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
  1326
    self defineWindowSize.
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1327
943
9eea2d5095b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 942
diff changeset
  1328
    "Modified: / 11.6.1998 / 22:51:48 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1330
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
!TerminalView methodsFor:'functions'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1332
5244
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  1333
autoMargin:aBoolean
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  1334
    "set/clear autowrap at end of line (not yet fully implemented).
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  1335
     This may come from a CSI sequence, or set programmatically."
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  1336
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  1337
    autoWrapFlag := aBoolean
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  1338
!
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  1339
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
doBackspace
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
    self cursorLeft.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
    self replaceCharAtCursor:(Character space).
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
    self cursorLeft.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1344
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
  1345
    "Modified: / 10.6.1998 / 17:09:12 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1348
doClearDisplay
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1349
    "clear everything"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1350
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1351
    self doClearEntireScreen.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1352
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1353
    "Modified: / 21.7.1998 / 20:05:35 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1354
!
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1355
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1356
doClearEntireLine
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1357
    "clear the cursor line. cursor position remains unchanged"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1358
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1359
    self at:cursorLine put:''
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1360
!
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1361
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1362
doClearEntireScreen
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1363
    "clear everything"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1364
4668
19aefa940f4d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4655
diff changeset
  1365
    firstLineShown to:(list size) do:[:lNr |
19aefa940f4d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4655
diff changeset
  1366
        self at:lNr put:''
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1367
    ].
922
c8373b8c7986 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1368
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1369
    "Modified: / 21.7.1998 / 20:00:19 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1370
    "Created: / 21.7.1998 / 20:05:24 / cg"
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1371
!
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1372
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1373
doClearFromBeginningOfLine
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1374
    "clear from beginning of line to the cursorPosition"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1375
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1376
    |l|
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1377
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1378
    l := self listAt:cursorLine.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1379
    l notNil ifTrue:[
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1380
        (l size >= (cursorCol-1)) ifTrue:[
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1381
            l := l copy from:1 to:cursorCol-1 put:(Character space).
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1382
        ] ifFalse:[
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1383
            l := nil.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1384
        ].
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1385
        self withoutRedrawAt:cursorLine put:l.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1386
        self invalidateLine:cursorLine
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1387
        "/ self at:cursorLine put:l.
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1388
    ]
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1389
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1390
    "Modified: / 20.6.1998 / 19:10:21 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1391
    "Created: / 21.7.1998 / 20:10:58 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1392
!
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1393
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1394
doClearFromBeginningOfScreen
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1395
    "clear from beginning of the screen to the cursorPosition"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1396
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1397
    self doClearFromBeginningOfLine.
4668
19aefa940f4d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4655
diff changeset
  1398
    cursorLine-1 to:firstLineShown do:[:lNr |
19aefa940f4d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4655
diff changeset
  1399
        self at:lNr put:''
922
c8373b8c7986 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1400
    ].
c8373b8c7986 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
  1401
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1402
    "Modified: / 10.6.1998 / 14:45:43 / cg"
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1403
    "Created: / 21.7.1998 / 20:08:29 / cg"
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1404
!
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1405
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1406
doClearToEndOfLine
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1407
    "clear from the cursorPosition to the end of the line"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1408
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1409
    |l|
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1410
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1411
    l := self listAt:cursorLine.
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
  1412
    (l size >= (cursorCol-1)) ifTrue:[
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1413
        l notNil ifTrue:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1414
            l := l copyTo:cursorCol-1.
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1415
            self withoutRedrawAt:cursorLine put:l.
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1416
            self invalidateLine:cursorLine
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1417
            "/ self at:cursorLine put:l.
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1418
        ]
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1419
    ]
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1420
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1421
    "Created: / 10.6.1998 / 14:45:01 / cg"
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1422
    "Modified: / 20.6.1998 / 19:10:21 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1424
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1425
doClearToEndOfScreen
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1426
    "clear from the cursorPosition to the end of the screen"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1427
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1428
    self doClearToEndOfLine.
4668
19aefa940f4d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4655
diff changeset
  1429
    cursorLine+1 to:(list size) do:[:lNr |
19aefa940f4d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4655
diff changeset
  1430
        self at:lNr put:''
1000
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1431
    ].
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1432
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1433
    "Modified: / 10.6.1998 / 14:45:43 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1434
    "Created: / 21.7.1998 / 20:06:14 / cg"
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1435
!
879d9578e4b6 additional clear functions.
Claus Gittinger <cg@exept.de>
parents: 999
diff changeset
  1436
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1437
doCursorDown:n
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1438
    "move the cursor down by n lines"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1439
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1440
    |wasOn rEnd|
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1441
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1442
"/    rangeEndLine == numberOfLines ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1443
"/        ^ super cursorDown:n
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1444
"/    ].
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
  1445
    (cursorLine + 1 - firstLineShown + n) <= rangeEndLine ifTrue:[
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1446
        "/ no special action req'd
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1447
        ^ super cursorDown:n
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1448
    ].
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1449
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1450
    n timesRepeat:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1451
        wasOn := self hideCursor.
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1452
        rEnd := rangeEndLine+firstLineShown-1.
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1453
        cursorLine ==  rEnd ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1454
            self deleteLine:(rangeStartLine+firstLineShown-1).
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1455
            self insertLine:'' before:rEnd.
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1456
        ] ifFalse:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1457
            super cursorDown
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1458
        ].
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1459
        wasOn ifTrue:[self showCursor]. "/ self makeCursorVisibleAndShowCursor:wasOn.
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1460
    ]
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1461
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1462
    "Modified: / 20.6.1998 / 20:29:39 / cg"
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1463
!
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1464
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
doCursorHome
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1466
    "move the cursor to the home position"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1467
938
3e65cc6f22cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
  1468
    self cursorVisibleLine:1 col:1
3e65cc6f22cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
  1469
    "/ super cursorHome
3e65cc6f22cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
  1470
3e65cc6f22cd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 936
diff changeset
  1471
    "Modified: / 10.6.1998 / 20:47:31 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1472
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1473
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1474
doCursorLeft:n
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1475
    "move the cursor to the left by n columns"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1476
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1477
    n timesRepeat:[
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1478
        super cursorLeft
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1479
    ]
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1480
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1481
    "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
  1482
!
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1483
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
doCursorNewLine
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1485
    "move the cursor down to the next line (col remains unchanged)"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1486
931
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
  1487
    super cursorDown:1
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
  1488
3dfdf1f7bd5d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
  1489
    "Modified: / 10.6.1998 / 16:55:57 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1490
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
doCursorReturn
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1493
    "move the cursor down and left to the beginning to the next line"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1494
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
    super cursorToBeginOfLine
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1498
doCursorRight:n
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1499
    "move the cursor to the right by n columns"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1500
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1501
    self cursorCol:(cursorCol + n)
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1502
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1503
    "Created: / 10.6.1998 / 15:10:08 / cg"
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1504
!
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1505
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1506
doCursorUp:n
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1507
    "move the cursor up by n lines"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1508
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1509
    |wasOn rStart|
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1510
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1511
"/    rangeStartLine == 1 ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1512
"/        ^ super cursorUp:n
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1513
"/    ].
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1514
    cursorLine + 1 - firstLineShown - n >= rangeStartLine ifTrue:[
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1515
        "/ no special action req'd
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1516
        ^ super cursorUp:n
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1517
    ].
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1518
    n timesRepeat:[
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1519
        wasOn := self hideCursor.
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1520
        rStart := rangeStartLine+firstLineShown-1.
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1521
        cursorLine == rStart ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1522
            (rangeEndLine+firstLineShown-1) <= list size ifTrue:[
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1523
                self deleteLine:(rangeEndLine+firstLineShown-1).
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1524
                self insertLine:'' before:rStart.
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1525
            ].
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1526
        ] ifFalse:[
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1527
            super cursorUp
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1528
        ].
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  1529
        self makeCursorVisibleAndShowCursor:wasOn.
942
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1530
    ]
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1531
1f4fa3a6faec send a sigWINCH whenever the views size changes.
Claus Gittinger <cg@exept.de>
parents: 940
diff changeset
  1532
    "Created: / 11.6.1998 / 22:29:46 / cg"
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1533
    "Modified: / 20.6.1998 / 20:30:34 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1534
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1535
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1536
!TerminalView methodsFor:'initialization & release'!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1537
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1538
closeDownShell
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1539
    "shut down my shell process."
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1540
1009
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1541
    |pid|
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1542
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1543
    (pid := shellPid) notNil ifTrue:[
2192
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
  1544
        Debug ifTrue:[
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1545
            Transcript show:'killing shell pid='; showCR:pid.
2192
5f3bf896d334 vt100 perform now only cr and not cr-nl
penk
parents: 2191
diff changeset
  1546
        ].
4958
9f4cc33b6a49 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4956
diff changeset
  1547
        OperatingSystem isMSWINDOWSlike ifFalse:[
9f4cc33b6a49 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4956
diff changeset
  1548
            OperatingSystem terminateProcessGroup:pid.
9f4cc33b6a49 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4956
diff changeset
  1549
        ].
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1550
        OperatingSystem terminateProcess:pid.
4959
590855d4df09 class: TerminalSession
Claus Gittinger <cg@exept.de>
parents: 4958
diff changeset
  1551
        Delay waitForSeconds:0.2.
925
f9ef1268a21b kill after termination.
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1552
        shellPid notNil ifTrue:[
4959
590855d4df09 class: TerminalSession
Claus Gittinger <cg@exept.de>
parents: 4958
diff changeset
  1553
            "/ Delay waitForSeconds:1.
4958
9f4cc33b6a49 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4956
diff changeset
  1554
            shellPid notNil ifTrue:[
9f4cc33b6a49 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4956
diff changeset
  1555
                OperatingSystem isMSWINDOWSlike ifFalse:[
9f4cc33b6a49 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4956
diff changeset
  1556
                    OperatingSystem killProcessGroup:pid.
9f4cc33b6a49 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4956
diff changeset
  1557
                ].
9f4cc33b6a49 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4956
diff changeset
  1558
                OperatingSystem killProcess:pid.
9f4cc33b6a49 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 4956
diff changeset
  1559
                shellPid := nil.
1341
3467ffd6eb35 first attempt in supporting win32;
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
  1560
            ].
925
f9ef1268a21b kill after termination.
Claus Gittinger <cg@exept.de>
parents: 924
diff changeset
  1561
        ].
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1562
        OperatingSystem closePid:pid.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1563
    ].
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1564
!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1565
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1566
closeDownShellAndStopReaderProcess
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1567
    "shut down my shell process and stop the background reader thread."
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1568
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1569
    self closeDownShell.
1009
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1570
    self stopReaderProcess.
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1571
    self closeStreams
1009
4cfed4bac6f0 added #stopReaderProcess
Claus Gittinger <cg@exept.de>
parents: 1005
diff changeset
  1572
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1573
    "Modified: / 5.5.1999 / 18:43:02 / cg"
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1574
!
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1575
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1576
closeStreams
4576
313dc2dc2b7b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4518
diff changeset
  1577
    |s|
313dc2dc2b7b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4518
diff changeset
  1578
313dc2dc2b7b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4518
diff changeset
  1579
    (s := inStream) notNil ifTrue:[
313dc2dc2b7b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4518
diff changeset
  1580
        inStream := nil.
4654
553b6d874375 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4641
diff changeset
  1581
        (s isStream and:[s isOpen]) ifTrue:[
553b6d874375 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4641
diff changeset
  1582
            s close
553b6d874375 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4641
diff changeset
  1583
        ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1584
    ].
4576
313dc2dc2b7b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4518
diff changeset
  1585
    (s := outStream) notNil ifTrue:[
313dc2dc2b7b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4518
diff changeset
  1586
        outStream := nil.
4654
553b6d874375 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4641
diff changeset
  1587
        (s isStream and:[s isOpen]) ifTrue:[
553b6d874375 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4641
diff changeset
  1588
            s close.
553b6d874375 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4641
diff changeset
  1589
        ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1590
    ].
924
c1d2e1fecd79 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 923
diff changeset
  1591
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1592
    "Modified: / 5.5.1999 / 18:43:02 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1593
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1594
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1595
escapeSequences:codes
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1596
    "setup my escape sequences"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  1597
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
    |tree|
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
    tree isNil ifTrue:[tree := escapeSequenceTree := IdentityDictionary new].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1602
    codes do:[:specEntry |
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1603
        |sequence function|
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1604
4105
a77be3c32b6d changed:
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
  1605
        sequence := (specEntry at:1) withoutCEscapes.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1606
        function := specEntry at:2.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1607
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1608
        tree := escapeSequenceTree.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
        sequence keysAndValuesDo:[:idx :char |
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1611
            |followup|
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1612
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1613
            idx == sequence size ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
                tree at:char put:function
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1615
            ] ifFalse:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1616
                followup := tree at:char ifAbsent:nil.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1617
                followup isNil ifTrue:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
                    tree at:char put:(followup := IdentityDictionary new).
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1619
                ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
                tree := followup
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1621
            ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1622
        ]
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1623
    ].
918
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1624
    escapeLeadingChars := escapeSequenceTree keys asSet.
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1625
    escapeLeadingChars add:(Character cr).
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1626
    escapeLeadingChars add:(Character return).
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1627
    escapeLeadingChars add:(Character backspace).
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1628
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1629
    escapeLeadingChars := escapeLeadingChars asArray
2d6a4c91c4bd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 917
diff changeset
  1630
4105
a77be3c32b6d changed:
Claus Gittinger <cg@exept.de>
parents: 4030
diff changeset
  1631
    "Modified: / 25-01-2012 / 10:42:46 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1632
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1633
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1634
flushInput
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1635
    |sensor|
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
    "/ flush any leftover input-processing events
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1638
    (sensor := self sensor) notNil ifTrue:[
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1639
        sensor flushEventsFor:self withType:#processInput:n:.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1640
    ]
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1641
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1642
    "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
  1643
    "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
  1644
!
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1645
2163
a54248bd5ac6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2155
diff changeset
  1646
initStyle
a54248bd5ac6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2155
diff changeset
  1647
    super initStyle.
a54248bd5ac6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2155
diff changeset
  1648
"/    self foregroundColor:Color green.
a54248bd5ac6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2155
diff changeset
  1649
"/    self backgroundColor:Color black.
a54248bd5ac6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2155
diff changeset
  1650
!
a54248bd5ac6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2155
diff changeset
  1651
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1652
initialize
2194
d008bb991def adding comments
penk
parents: 2192
diff changeset
  1653
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1654
    super initialize.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1655
4803
2d7001dae28c class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4799
diff changeset
  1656
    sendControlKeys := true.
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  1657
    signalControlKeys := OperatingSystem isMSWINDOWSlike.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1658
    showMatchingParenthesis := false.
4288
2cf48c1738f7 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  1659
    self insertMode: false.
936
d377fb0f726f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 935
diff changeset
  1660
    alwaysAppendAtEnd := false.
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  1661
    collectSize := 4096.
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  1662
    sizeOfOutstandingInputToBeProcessed := 0.
977
785c3ad4eff1 turn off st80Mode
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1663
    st80Mode := false.
785c3ad4eff1 turn off st80Mode
Claus Gittinger <cg@exept.de>
parents: 976
diff changeset
  1664
    trimBlankLines := true.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1665
    localEcho := false.
2078
96c664b79c19 + inputTranslateCRtoCRNL
Claus Gittinger <cg@exept.de>
parents: 2077
diff changeset
  1666
    inputTranslateCRToNL := false.
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  1667
    inputTranslateCRToCRNL := OperatingSystem isMSWINDOWSlike.
4324
f45610b1f1ad class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4322
diff changeset
  1668
    inputTranslateBackspaceToDelete := false.
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  1669
    inputIsUTF8 := UserPreferences current terminalInputIsUTF8.
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  1670
    outputIsUTF8 := false. "/ currently unused.
2268
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
  1671
    autoWrapFlag := true.
4299
50d20c3d24cc class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4295
diff changeset
  1672
    noColors := false.
4612
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  1673
    doUTF := UserPreferences current terminalOutputIsUTF8.
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  1674
    lineEditMode := OperatingSystem isMSWINDOWSlike.
4602
a5c14fbf63cf class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4601
diff changeset
  1675
    maxHistorySize := maxHistorySize ? DefaultMaxHistorySize.
4641
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  1676
    ignoreOutput := false.
5249
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  1677
    filterOnly := false.
4602
a5c14fbf63cf class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4601
diff changeset
  1678
2268
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
  1679
    "/ cursorType := #block.
4452
ff2a970ba725 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4450
diff changeset
  1680
    "/ cursorTypeNoFocus := #frame.
ff2a970ba725 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4450
diff changeset
  1681
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  1682
    state := 0.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1683
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1684
    numberOfColumns := 80.
979
32f75cd56edc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 977
diff changeset
  1685
    numberOfLines := 24.
954
4cef50a89ca1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
  1686
    rangeStartLine := 1.
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
  1687
    rangeEndLine := 24.
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1688
2423
d2685982f94f tabs are always in multiples of 8 (no matter what users pref are)
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1689
    self setTab8.
d2685982f94f tabs are always in multiples of 8 (no matter what users pref are)
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1690
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1691
    self initializeKeyboardSequences.
6023
8689f323e116 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6017
diff changeset
  1692
    list := OrderedCollection new:numberOfLines withAll:''.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1693
2577
6dc84e11433a windows fix: sequence for RETURN
ca
parents: 2573
diff changeset
  1694
    OperatingSystem isMSWINDOWSlike ifTrue:[
6dc84e11433a windows fix: sequence for RETURN
ca
parents: 2573
diff changeset
  1695
        kbdSequences at:#Return put:'\r\n'.
6dc84e11433a windows fix: sequence for RETURN
ca
parents: 2573
diff changeset
  1696
    ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1697
    self initializeKeyboardMap.
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1698
    self initializeShellTerminateAction.
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1699
    
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1700
    "
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1701
     VT52TerminalView openShell
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1702
     VT100TerminalView openShell
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1703
    "
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  1704
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  1705
    "Modified: / 30-07-2013 / 10:43:07 / cg"
6023
8689f323e116 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6017
diff changeset
  1706
    "Modified: / 04-03-2019 / 08:05:34 / Claus Gittinger"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1707
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1708
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1709
initializeKeyboardMap
5278
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1710
    "setup my own keyboardMap, where control-keys 
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1711
     (and some Cmd-keys) are not translated."
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1712
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1713
    |keys ctrlKeys cmdKeys|
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1714
5006
22bdac1a5826 device access
Claus Gittinger <cg@exept.de>
parents: 4983
diff changeset
  1715
    kbdMap := device keyboardMap copy.
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1716
    keys := kbdMap keys.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1718
    ctrlKeys := keys select:[:key | key startsWith:'Ctrl'].
5278
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1719
    ctrlKeys do:[:key |
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1720
        |val|
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1721
        
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1722
        val := kbdMap at:key.
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1723
        (
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1724
            #(ZoomIn ZoomOut
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1725
        ) includesIdentical:val) ifFalse:[
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1726
            kbdMap removeKey:key
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1727
        ]
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1728
    ].
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1729
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1730
    cmdKeys := keys select:[:key | key startsWith:'Cmd'].
5278
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1731
    cmdKeys do:[:key | 
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1732
        |val|
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1733
        
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1734
        val := kbdMap at:key.
5278
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1735
        (
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1736
            #(Copy Paste SaveAs Print Find FindNext FindPrev GotoLine
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1737
        ) includesIdentical:val) ifFalse:[
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1738
            kbdMap removeKey:key
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1739
        ]
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1740
    ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1741
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1742
    kbdMap removeKey:#Delete ifAbsent:[].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1743
    kbdMap removeKey:#BackSpace ifAbsent:[].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1744
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1745
    "
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1746
     VT52TerminalView openShell
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1747
    "
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  1748
1349
f2489f1bacd4 oops - care for Alt-GR keys
Claus Gittinger <cg@exept.de>
parents: 1347
diff changeset
  1749
    "Modified: / 29.4.1999 / 14:25:24 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
initializeKeyboardSequences
1358
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1753
    kbdSequences := (self anyKeyCodes)
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1754
ec94a03e4585 Ctrl-keys which are mapped to function keys
Claus Gittinger <cg@exept.de>
parents: 1354
diff changeset
  1755
    "Modified: / 5.5.1999 / 15:01:09 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1756
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1757
5144
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1758
initializeShellTerminateAction
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1759
    shellTerminateAction := 
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1760
        [
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1761
            "/ may be removed with shellTerminateAction:...
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1762
            self warn:(resources string:'shell terminated').
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1763
        ]
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1764
!
e3c1660ebede #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5140
diff changeset
  1765
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1766
keyboardMap
5278
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1767
    "return my own, private keyboard map. 
7c0c386f9228 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5249
diff changeset
  1768
     This has control keys removed and
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1769
     those will be passed unchanged to the shell"
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1770
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
    ^ kbdMap
934
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1772
b450dbaeedac checkin from browser
Claus Gittinger <cg@exept.de>
parents: 933
diff changeset
  1773
    "Modified: / 10.6.1998 / 17:46:59 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1774
!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1775
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1776
reinitialize
1833
69a0c170cd80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1485
diff changeset
  1777
    "reinit after a snapIn.
69a0c170cd80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1485
diff changeset
  1778
     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
  1779
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1780
    super reinitialize.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1781
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1782
    shellPid := nil.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1783
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1784
    self stopReaderProcess.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1785
    self flushInput.
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1786
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1787
    readerProcess := nil.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1788
    inStream := outStream := nil.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1789
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1790
    "/ 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
  1791
    [
1322
30150c59eb97 dont delay the reinit
Claus Gittinger <cg@exept.de>
parents: 1321
diff changeset
  1792
       "/ Delay waitForSeconds:0.5.
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1793
        self doClearEntireScreen.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1794
        self cursorLine:1 col:1.
1321
9a312fa98358 also throw away scrolled text whith restart.
Claus Gittinger <cg@exept.de>
parents: 1320
diff changeset
  1795
        self contents:nil.
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1796
        self flash.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1797
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1798
        "/
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1799
        "/ 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
  1800
        "/
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1801
        self startCommand:shellCommand in:shellDirectory.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1802
    ] forkAt:8
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1803
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  1804
    "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
  1805
!
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  1806
2155
b007892599e4 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
  1807
release
b007892599e4 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
  1808
    "release myself - shut down the shell, stop the reader thread."
b007892599e4 destroy - release
Claus Gittinger <cg@exept.de>
parents: 2126
diff changeset
  1809
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1810
    [
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1811
        self closeDownShellAndStopReaderProcess.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  1812
        self flushInput.
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  1813
    ] forkAt:(Processor systemBackgroundPriority).
4655
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
  1814
    super release.
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
  1815
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
  1816
    "Modified: / 17-07-2014 / 19:29:55 / cg"
985
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
  1817
! !
275897f12b52 added #openOnCommand:, to allow view on any (non-shell)
Claus Gittinger <cg@exept.de>
parents: 979
diff changeset
  1818
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1819
!TerminalView methodsFor:'initialization-shell'!
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1820
2778
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1821
basicStartCommand:aCommand in:aDirectory
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1822
    "start a command on a pseudo terminal. If the command arg is nil,
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1823
     a shell is started. If aDirectory is not nil, the command is
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1824
     executed in that directory.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1825
     Also fork a reader process, to read the shells output and
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1826
     tell me, whenever something arrives"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1827
6012
a85c5316417b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1828
    |pty master slave slaveFD slaveName execFdArray blocked exitStatus 
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1829
     stxToCommandPipe commandToStxPipe cmd shell args env shellAndArgs|
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1830
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1831
    shellCommand := aCommand.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1832
    shellDirectory := aDirectory.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1833
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1834
    self create.  "/ need my windowID (to pass down in environment)
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1835
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1836
    OperatingSystem isMSWINDOWSlike ifTrue:[
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1837
        "use two pipes to COMMAND.COM"
6132
a15871e06ccd #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6125
diff changeset
  1838
        stxToCommandPipe := PipeStream makePipe.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1839
        stxToCommandPipe isNil ifTrue:[
4250
7c940d59fc4e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4223
diff changeset
  1840
            self warn:(resources string:'Could not create pipe to COMMAND.COM.'). 
7c940d59fc4e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4223
diff changeset
  1841
            ^ self.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1842
        ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1843
5929
0ca982cfa457 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1844
        commandToStxPipe := PipeStream makePipe.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1845
        commandToStxPipe isNil ifTrue:[
4250
7c940d59fc4e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4223
diff changeset
  1846
            self warn:(resources string:'Could not create pipe from COMMAND.COM.'). 
7c940d59fc4e class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4223
diff changeset
  1847
            ^ self.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1848
        ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1849
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1850
        "/ pipe readSide is p at:1;
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1851
        "/      writeSide is p at:2
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1852
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1853
        slaveFD := (commandToStxPipe at:2) fileDescriptor.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1854
        execFdArray := Array 
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1855
                         with:(stxToCommandPipe at:1) fileDescriptor        "stdin"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1856
                         with:slaveFD                                       "stdout"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1857
                         with:slaveFD.                                      "stderr"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1858
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1859
        outStream := commandToStxPipe at:1.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1860
        inStream  := stxToCommandPipe at:2.
5929
0ca982cfa457 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1861
        inStream setCommandString:'pty -> stx'.
0ca982cfa457 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1862
        outStream setCommandString:'pty <- stx'.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1863
4655
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
  1864
        self defineWindowSize.  "/ does not really work on windows (need help)
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
  1865
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1866
        shellAndArgs := OperatingSystem commandAndArgsForOSCommand:aCommand.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1867
        shell := shellAndArgs at:1.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1868
        args  := (shellAndArgs at:2) ? ''.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1869
    ] ifFalse:[
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1870
        "Use a pseudo-tty"
6132
a15871e06ccd #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6125
diff changeset
  1871
        pty := UnixPTYStream makePTYPair.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1872
        pty isNil ifTrue:[
5062
e0a5de3ff115 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5021
diff changeset
  1873
            self warn:(resources string:'Cannot open pty.').
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1874
            ^ self.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1875
        ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1876
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1877
        "/ pty at:1 is the master;
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1878
        "/ pty at:2 is the slave
6012
a85c5316417b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1879
        master := (pty at:1).
a85c5316417b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1880
        slave := (pty at:2).
6132
a15871e06ccd #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6125
diff changeset
  1881
        slaveName := pty at:3 ifAbsent:'pty?'.
6012
a85c5316417b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1882
        inStream := outStream := master.
6132
a15871e06ccd #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 6125
diff changeset
  1883
        inStream setCommandString:slaveName.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1884
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1885
        self defineWindowSize.
4655
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
  1886
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1887
        "/ fork a shell process on the slave-side
6012
a85c5316417b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1888
        slaveFD := slave fileDescriptor.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1889
        execFdArray := Array with:slaveFD with:slaveFD with:slaveFD.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1890
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1891
        aCommand isNil ifTrue:[
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1892
            shell := OperatingSystem getEnvironment:'SHELL'.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1893
            shell size == 0 ifTrue:[
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1894
                shell := '/bin/sh'.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1895
            ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1896
            cmd := shell asFilename baseName.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1897
            args := (Array with:cmd).
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1898
        ] ifFalse:[
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1899
            shell := '/bin/sh'.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1900
            args := (Array with:'sh' with:'-c' with:aCommand).
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1901
        ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1902
        env := Dictionary new.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1903
        env at:'SHELL'    put:shell.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1904
        env at:'TERM'     put:(self terminalType).
4222
7de7ab92ac71 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4220
diff changeset
  1905
        env at:'HOME'     put:(OperatingSystem getEnvironment:'HOME').
7de7ab92ac71 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4220
diff changeset
  1906
        env at:'USER'     put:(OperatingSystem getEnvironment:'USER').
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1907
        env at:'LINES'    put:(numberOfLines printString).
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1908
        env at:'COLUMNS'  put:(numberOfColumns printString).
6096
4de6a6b2f700 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6078
diff changeset
  1909
        (device isX11Platform and:[self drawableId notNil]) ifTrue:[
4518
e2bd93d275e5 class: TerminalView
Stefan Vogel <sv@exept.de>
parents: 4492
diff changeset
  1910
            env at:'WINDOWID' put:(self drawableId address printString).
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1911
        ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1912
    ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1913
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1914
    blocked := OperatingSystem blockInterrupts.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1915
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1916
    shellPid := Processor
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1917
               monitor:[
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1918
                  OperatingSystem
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1919
                      exec:shell
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1920
                      withArguments:args
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1921
                      environment:env
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1922
                      fileDescriptors:execFdArray
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1923
                      fork:true
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1924
                      newPgrp:true
5231
9637e8584b30 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5223
diff changeset
  1925
                      inDirectory:aDirectory
9637e8584b30 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5223
diff changeset
  1926
                      showWindow:false.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1927
               ]
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1928
               action:[:status |
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1929
                    Debug ifTrue:[
4325
ac76719332a6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4324
diff changeset
  1930
                        Transcript showCR:'shell status change'.
ac76719332a6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4324
diff changeset
  1931
                        Transcript show:'  pid:'; showCR:status pid.
ac76719332a6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4324
diff changeset
  1932
                        Transcript show:'  status:'; showCR:status status.
ac76719332a6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4324
diff changeset
  1933
                        Transcript show:'  code:'; showCR:status code.
ac76719332a6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4324
diff changeset
  1934
                        Transcript show:'  core:'; showCR:status core.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1935
                    ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1936
                    status stillAlive ifFalse:[
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1937
                        exitStatus := status.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1938
                        OperatingSystem closePid:shellPid.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1939
                        shellPid := nil.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1940
                        self pushEvent:#shellTerminated
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1941
                    ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1942
               ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1943
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1944
    blocked ifFalse:[
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1945
        OperatingSystem unblockInterrupts
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1946
    ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1947
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1948
    "close the slave side of the pty/pipes (only used by the child)"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1949
    pty notNil ifTrue:[
6012
a85c5316417b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1950
        slave close.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1951
    ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1952
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1953
    commandToStxPipe notNil ifTrue:[
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1954
        (commandToStxPipe at:2) close.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1955
        (stxToCommandPipe at:1) close.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1956
    ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1957
5930
171b5e2e8820 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5929
diff changeset
  1958
    "/ release those references - the monitor block still has a reference to this (home) context,
171b5e2e8820 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5929
diff changeset
  1959
    "/ helps the garbage collector
6012
a85c5316417b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5950
diff changeset
  1960
    pty := master := slave := execFdArray := stxToCommandPipe := commandToStxPipe := nil.
5930
171b5e2e8820 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5929
diff changeset
  1961
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1962
    shellPid isNil ifTrue:[
5062
e0a5de3ff115 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5021
diff changeset
  1963
        self warn:(resources string:'Cannot start shell').
4327
9fa4f8804902 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
  1964
        self closeStreams.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1965
        ^ self.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1966
    ].
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1967
4655
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
  1968
    "Created: / 20-07-1998 / 18:19:32 / cg"
f28763424647 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4654
diff changeset
  1969
    "Modified: / 17-07-2014 / 19:43:00 / cg"
6096
4de6a6b2f700 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6078
diff changeset
  1970
    "Modified: / 25-07-2019 / 12:32:11 / Claus Gittinger"
2778
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1971
!
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1972
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1973
startCommand:aCommand
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1974
    "start a command on a pseudo terminal. If the command arg is nil,
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1975
     a shell is started. The command is started in the current directory.
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1976
     Also fork a reader process, to read the shells output and
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1977
     tell me, whenever something arrives"
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1978
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1979
    self startCommand:aCommand in:nil
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1980
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1981
    "Modified: / 20.7.1998 / 18:30:24 / cg"
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1982
!
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1983
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1984
startCommand:aCommand in:aDirectory
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1985
    "start a command on a pseudo terminal. If the command arg is nil,
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1986
     a shell is started. If aDirectory is not nil, the command is
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1987
     executed in that directory.
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1988
     Also fork a reader process, to read the shells output and
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1989
     tell me, whenever something arrives"
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1990
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1991
    self basicStartCommand:aCommand in:aDirectory.
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  1992
    self startReaderProcessWhenVisible.
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1993
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1994
    "Created: / 20.7.1998 / 18:19:32 / cg"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1995
    "Modified: / 5.5.1999 / 17:28:37 / cg"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1996
!
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1997
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1998
startShell
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  1999
    "start a shell on a pseudo terminal in the current directory.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2000
     Also fork a reader process, to read the shells output and
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2001
     tell me, whenever something arrives"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2002
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2003
    ^ self startCommand:nil
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2004
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2005
    "
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2006
     VT100TerminalView openShell
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2007
    "
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2008
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2009
    "Modified: / 20.7.1998 / 18:29:54 / cg"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2010
!
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2011
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2012
startShellIn:aDirectory
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2013
    "start a shell on a pseudo terminal in some directory.
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2014
     Also fork a reader process, to read the shells output and
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2015
     tell me, whenever something arrives"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2016
2778
796ab4177728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2678
diff changeset
  2017
    self startCommand:nil in:aDirectory
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2018
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2019
    "
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2020
     VT100TerminalView openShellIn:'/etc'
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2021
    "
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2022
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2023
    "Modified: / 20.7.1998 / 18:29:46 / cg"
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2024
! !
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2498
diff changeset
  2025
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2026
!TerminalView methodsFor:'menu'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2027
3225
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2028
doClear
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2029
    "reset the scroll-range etc, clear the text buffer"
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2030
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2031
    rangeStartLine := 1.
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2032
    rangeEndLine := numberOfLines.
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
  2033
    self assert:(rangeEndLine notNil).
3225
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2034
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2035
    self normal.
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2036
    self clear.
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2037
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2038
    "Created: / 03-04-2007 / 08:58:59 / cg"
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2039
!
65c338f35160 clear menu function
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  2040
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2041
doReset
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2042
    "reset the scroll-range; 
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2043
     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
  2044
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2045
    rangeStartLine := 1.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2046
    rangeEndLine := numberOfLines.
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
  2047
    self assert:(rangeEndLine notNil).
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2048
    self normal.
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2049
!
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2050
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2051
doSendInterrupt
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2052
    "send an INT-signal to the shell (UNIX only)"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2053
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2054
    DebugKeyboard ifTrue:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2055
        Transcript showCR:'interrupt!!'.
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2056
    ].
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2057
    self sendInterruptSignal
1319
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2058
!
0f19d022f577 restart shell when coming up via a snapshot
Claus Gittinger <cg@exept.de>
parents: 1317
diff changeset
  2059
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2060
doSendKillSignal
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2061
    "send a KILL-signal to the shell (UNIX only)"
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2062
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2063
    DebugKeyboard ifTrue:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2064
        Transcript showCR:'kill!!'.
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2065
    ].
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2066
    self sendKillSignal
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2067
!
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2068
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2069
doSendTerminateSignal
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2070
    "send a TERM-signal to the shell (UNIX only)"
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2071
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2072
    DebugKeyboard ifTrue:[
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2073
        Transcript showCR:'terminate!!'.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2074
    ].
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2075
    self sendTerminateSignal
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2076
!
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2077
5537
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2078
doSetLineLimit
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2079
    "ask for the lineLimit (the number of buffered lines)"
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2080
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2081
    |lineString n|
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2082
    
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2083
    lineString := Dialog request:'Number of buffered lines:' initialAnswer:(self lineLimit asString).
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2084
    lineString isEmptyOrNil ifTrue:[^ self].
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2085
    n := Integer readFrom:lineString onError:[^ self].
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2086
    self lineLimit:(n max:100).
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2087
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2088
    "Created: / 01-05-2017 / 10:27:51 / cg"
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2089
!
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2090
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2091
editMenu
5354
2c03b274f76a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5330
diff changeset
  2092
    "return the view's middleButtonMenu"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2093
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2094
    <resource: #keyboard (#Copy #Paste #Print #SaveAs #Print)>
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2095
    <resource: #programMenu>
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2096
4487
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2097
    |items subMenu moreMenu m sensor|
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2098
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2099
    items := #(
5537
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2100
                    ('Interrupt'          doSendInterrupt )  
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2101
                    ('Terminate'          doSendTerminateSignal )  
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2102
                    ('Kill'               doSendKillSignal)  
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2103
                    ('-'                                  )
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2104
                    ('Clear'              doClear         )  
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2105
                    ('Reset'              doReset         ) 
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2106
                    ('-'                                  )
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2107
                    ('Linebuffer Size...' doSetLineLimit  )  
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2108
              ).
5763
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2109
    lineEditMode == true ifTrue:[
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2110
        items := items , #(
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2111
                    ('Disable Line Edit Mode' disableLineEditMode  )  
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2112
              ).
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2113
    ] ifFalse:[
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2114
        items := items , #(
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2115
                    ('Enable Line Edit Mode' enableLineEditMode  )  
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2116
              ).
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2117
    ].
68a1a475ad31 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5753
diff changeset
  2118
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2119
    subMenu := PopUpMenu itemList:items resources:resources.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2120
4487
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2121
    items := #(
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2122
                    ('Open FileBrowser on It'      openFileBrowserOnIt )  
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2123
              ).
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2124
    moreMenu := PopUpMenu itemList:items resources:resources.
5753
56884612657a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5716
diff changeset
  2125
    shellDirectory isNil ifTrue:[
56884612657a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5716
diff changeset
  2126
        moreMenu disable:#openFileBrowserOnIt.
56884612657a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5716
diff changeset
  2127
    ].
4487
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2128
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2129
    ((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2130
        m := subMenu.
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2131
    ] ifFalse:[
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2132
        items := #(
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  2133
                        ('Copy'         copySelection    Copy   )
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  2134
                        ('Paste'        pasteOrReplace   Paste  )
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2135
                        ('-'                                    )
2506
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2136
                        ('Search...'    search           Find)
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2137
                        ('-'                                    )
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  2138
                        ('Font...'      changeFont              )
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  2139
                        ('-'                                    )
2448
6d912d8ec69d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2423
diff changeset
  2140
                        ('Save As...'   save             SaveAs )
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  2141
                        ('Print'        doPrint          Print  )
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2142
                        ('='                               )
4487
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2143
                        ('More'         more                )
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2144
                        ('Shell'        others           Ctrl   )
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2145
                  ).
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2146
        m := PopUpMenu itemList:items resources:resources.
4487
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2147
        m subMenuAt:#more put:moreMenu.
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2148
        m subMenuAt:#others put:subMenu.
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2149
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2150
"/ disabled - for now;
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2151
"/ need a more intelligent filtering of control characters.
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2152
"/
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2153
"/        filterStream isNil ifTrue:[
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2154
"/           items := items , #(
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2155
"/                        ('-'                                    )
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  2156
"/                        ('Start Save as ...'  startSaveAs       )
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  2157
"/                        ('Start Print'        startPrint        )
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2158
"/                             )
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2159
"/        ] ifFalse:[
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2160
"/           items := items , #(
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2161
"/                        ('-'                                    )
2075
ac7da2b56ba6 upper case menu
Claus Gittinger <cg@exept.de>
parents: 1833
diff changeset
  2162
"/                        ('Stop filter'  stopFilter              )
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2163
"/                             )
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2164
"/        ].
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2165
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2166
2810
d57cc02787de refactored intention revealing code:
Claus Gittinger <cg@exept.de>
parents: 2778
diff changeset
  2167
    self hasSelection ifFalse:[
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2168
        m disable:#copySelection.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2169
    ].
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2170
    ^ m.
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2171
5537
29c409638778 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5354
diff changeset
  2172
    "Modified: / 01-05-2017 / 10:28:30 / cg"
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2173
!
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2174
4487
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2175
openFileBrowserOnIt
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2176
    "open a fileBrowser on the selected fileName"
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2177
4836
0001f4870dfd #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4819
diff changeset
  2178
    |selection fileName|
4487
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2179
4630
dccaedc34013 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4614
diff changeset
  2180
    shellDirectory notNil ifTrue:[
4836
0001f4870dfd #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4819
diff changeset
  2181
        selection := self selectionAsString.
0001f4870dfd #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4819
diff changeset
  2182
        fileName := selection asFilename.
0001f4870dfd #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4819
diff changeset
  2183
        fileName isAbsolute ifFalse:[
4837
c2f163a6f437 #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 4836
diff changeset
  2184
            fileName := shellDirectory construct:selection.
4836
0001f4870dfd #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4819
diff changeset
  2185
        ].
0001f4870dfd #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4819
diff changeset
  2186
        self openFileBrowserOnFileNamed:fileName pathName
4630
dccaedc34013 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4614
diff changeset
  2187
    ].
4487
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2188
!
2f12b83177ce class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4479
diff changeset
  2189
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2190
sendInterruptSignal
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2191
    "send an INT-signal to the shell (UNIX only)"
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2192
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2193
    shellPid notNil ifTrue:[
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2194
        OperatingSystem isUNIXlike ifTrue:[
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2195
            OperatingSystem interruptProcessGroup:shellPid.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2196
            OperatingSystem interruptProcess:shellPid.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2197
            "/ status := OperatingSystem childProcessWait:false pid:shellPid.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2198
        ] ifFalse:[
5659
7a69d3fdca24 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5638
diff changeset
  2199
            'TerminalView [info]: IRQ unimplemented for DOS' infoPrintCR.
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2200
        ]
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2201
    ] ifFalse:[
5659
7a69d3fdca24 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5638
diff changeset
  2202
        'TerminalView [info]: no shell' infoPrintCR.
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2203
    ].
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2204
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2205
    "Modified: / 10.6.1998 / 17:49:49 / cg"
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2206
!
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2207
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2208
sendKillSignal
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2209
    "send a KILL-signal to the shell (UNIX only)"
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2210
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2211
    |status|
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2212
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2213
    shellPid notNil ifTrue:[
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2214
        OperatingSystem isUNIXlike ifTrue:[
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2215
            OperatingSystem killProcessGroup:shellPid.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2216
            OperatingSystem killProcess:shellPid.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2217
            status := OperatingSystem childProcessWait:false pid:shellPid.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2218
        ] ifFalse:[
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2219
            self warn:(resources string:'unimplemented for DOS')
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2220
        ]
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2221
    ] ifFalse:[
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2222
        'VT100: no shell' infoPrintCR.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2223
    ]
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2224
!
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2225
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2226
sendTerminateSignal
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2227
    "send a TERM-signal to the shell (UNIX only)"
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2228
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2229
    shellPid notNil ifTrue:[
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2230
        OperatingSystem terminateProcessGroup:shellPid.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2231
        OperatingSystem terminateProcess:shellPid.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2232
        "/ status := OperatingSystem childProcessWait:false pid:shellPid.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2233
    ] ifFalse:[
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2234
        'VT100: no shell' infoPrintCR.
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2235
    ].
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2236
!
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2237
4295
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2238
setGreenDisplayMode
5164
ea62d7ad1bf9 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5156
diff changeset
  2239
    self foregroundColor:Color green backgroundColor:self blackColor.
ea62d7ad1bf9 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5156
diff changeset
  2240
    self cursorForegroundColor:self blackColor backgroundColor:Color green.
4295
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2241
!
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2242
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2243
setNormalDisplayMode
5164
ea62d7ad1bf9 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5156
diff changeset
  2244
    self foregroundColor:self blackColor backgroundColor:self whiteColor.
ea62d7ad1bf9 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5156
diff changeset
  2245
    self cursorForegroundColor:self whiteColor backgroundColor:self blackColor.
4295
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2246
!
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2247
4300
2bdb9d15ed44 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4299
diff changeset
  2248
setRedDisplayMode
5164
ea62d7ad1bf9 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5156
diff changeset
  2249
    self foregroundColor:(self whiteColor) backgroundColor:(Color red:80).
ea62d7ad1bf9 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5156
diff changeset
  2250
    self cursorForegroundColor:(Color red:80) backgroundColor:(self whiteColor).
4300
2bdb9d15ed44 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4299
diff changeset
  2251
!
2bdb9d15ed44 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4299
diff changeset
  2252
4295
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2253
setReverseDisplayMode
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2254
    |fg bg|
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2255
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2256
    fg := self foregroundColor.
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2257
    bg := self backgroundColor.
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2258
    self foregroundColor:bg backgroundColor:fg.
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2259
    self cursorForegroundColor:fg backgroundColor:bg.
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2260
!
5bd43114a67b class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4294
diff changeset
  2261
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2262
startSaveAs
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2263
    "start saving all received data to some file"
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2264
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2265
    |fn|
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2266
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2267
    fn := Dialog requestFileName:'Save received data in file:'.
6017
4d87665db62d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6012
diff changeset
  2268
    fn size ~~ 0 ifTrue:[
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2269
        filterStream := fn asFilename writeStream
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2270
    ].
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2271
6017
4d87665db62d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6012
diff changeset
  2272
    "Created: / 29-04-1999 / 11:06:29 / cg"
4d87665db62d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6012
diff changeset
  2273
    "Modified: / 01-03-2019 / 16:13:13 / Claus Gittinger"
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2274
!
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2275
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2276
stopFilter
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2277
    "stop saving/printing of received data"
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2278
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2279
    filterStream close.
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2280
    filterStream := nil.
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2281
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2282
    "Created: / 29.4.1999 / 11:07:49 / cg"
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2283
    "Modified: / 29.4.1999 / 11:09:52 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2284
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2285
940
16c955286510 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 938
diff changeset
  2286
!TerminalView methodsFor:'misc'!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2287
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2288
debugPrintCharacter:aCharacter as:what
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2289
    Transcript show:what; show:' <'.
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2290
    aCharacter codePoint < 32 ifTrue:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2291
        Transcript show:'\x'; show:(aCharacter codePoint hexPrintString:2)
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2292
    ] ifFalse:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2293
        Transcript show:aCharacter
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2294
    ].
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2295
    Transcript showCR:'>'
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2296
!
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2297
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2298
removeTrailingBlankLines
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2299
    ^ self
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2300
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2301
2498
4b4f91e57dd0 method category rename
Claus Gittinger <cg@exept.de>
parents: 2466
diff changeset
  2302
!TerminalView methodsFor:'processing-input'!
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2303
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2304
doNothing
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2305
    "private - end of an ignored escape-sequence"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2306
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2307
    self endOfSequence
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2308
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2309
    "Created: / 12.6.1998 / 20:40:43 / cg"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2310
!
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2311
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2312
endOfSequence
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2313
    "private - reset state-machine at end of escape-sequence"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2314
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
  2315
    self assert:(rangeEndLine notNil).
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2316
    state := 0.
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2317
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2318
    "Created: / 12.6.1998 / 20:39:52 / cg"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2319
!
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2320
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2321
nextPut:char
6125
712bc32afde8 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6122
diff changeset
  2322
    "process a character (i.e. the shell's output).
712bc32afde8 #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6122
diff changeset
  2323
     Answer char"
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2324
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
  2325
    self assert:(rangeEndLine notNil).
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
  2326
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2327
    "/ Debug := true
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2328
    "/ Debug := false
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2329
    Debug ifTrue:[
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2330
        Transcript show:state; show:' <'; show:(char codePoint hexPrintString:2); showCR:'>'.
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2331
    ].
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2332
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2333
    (char == Character nl) ifTrue:[ 
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2334
        self endEntry.
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2335
        self doCursorDown:1.
6122
57e3e348928f #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6114
diff changeset
  2336
        self endEntry.
57e3e348928f #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6114
diff changeset
  2337
        ^ char
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2338
    ].
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2339
    (char == Character return) ifTrue:[ 
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2340
        self endEntry.
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2341
        self cursorToBeginOfLine.
6122
57e3e348928f #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6114
diff changeset
  2342
        ^ char.
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2343
    ].
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2344
    (char == Character backspace) ifTrue:[ 
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2345
        self endEntry.
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2346
        self doCursorLeft:1. "/ doBackspace
6122
57e3e348928f #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6114
diff changeset
  2347
        self endEntry.
57e3e348928f #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6114
diff changeset
  2348
        ^ char
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2349
    ].
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2350
    (char == Character bell) ifTrue:[
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2351
        self beep.
6122
57e3e348928f #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6114
diff changeset
  2352
        ^ char 
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2353
    ].
5156
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
  2354
    char codePoint < 32 ifTrue:[
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2355
        char ~~ Character tab ifTrue:[
5156
5d9fc3da65f1 #OTHER by mawalch
mawalch
parents: 5151
diff changeset
  2356
            char codePoint ~~ 0 ifTrue:[
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2357
                Debug ifTrue:[
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2358
                    Transcript show:'unhandled control key: '; showCR:char storeString.
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2359
                ].
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2360
            ].
6122
57e3e348928f #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6114
diff changeset
  2361
            ^ char.
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2362
        ]
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2363
    ].
5145
6f4398bdb18c #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5144
diff changeset
  2364
    self show:char; endEntry.
6122
57e3e348928f #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6114
diff changeset
  2365
    ^ char
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2366
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2367
    "Modified: / 21.7.1998 / 20:06:04 / cg"
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2368
!
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2369
1017
8af14b2315fa care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  2370
nextPutAll:aString
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2371
    "/ self processInput:aString n:aString size
2594
63c4f60955be no defineWindowSize on contentsChanged
penk
parents: 2577
diff changeset
  2372
4285
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2373
    Debug ifTrue:[
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2374
        Transcript                                                       
6078
08c9e2a47dc5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6044
diff changeset
  2375
            show:(self className); show:': nextPutAll - state: '; show:state;
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2376
            show:' got: <'.
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2377
        aString do:[:ch |
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2378
            Transcript show:'<'; show:(ch codePoint hexPrintString:2); show:'>'
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2379
        ].
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2380
        Transcript cr; endEntry.
4285
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2381
    ].
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2382
    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
  2383
6078
08c9e2a47dc5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6044
diff changeset
  2384
    "Created: / 27-07-1998 / 15:10:59 / cg"
08c9e2a47dc5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6044
diff changeset
  2385
    "Modified: / 27-07-1998 / 23:16:19 / cg"
08c9e2a47dc5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6044
diff changeset
  2386
    "Modified: / 28-06-2019 / 09:20:08 / Claus Gittinger"
1017
8af14b2315fa care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  2387
!
8af14b2315fa care for non-external-stream when window size changes.
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
  2388
933
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
  2389
processInput:buffer n:count
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2390
    "actually: output coming from the connected application (aka input to me);
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2391
     the stuff coming from the application is a mix of plain text and CSI escape sequences.
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2392
     If we process each character individually, things are trivial, but slow.
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2393
     Therefore, we collect big chunks of non-escaped text and buffer them to make
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2394
     use of the inherited buffered output optimizations (see TextCollector).
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2395
     Thus, we collect until an escape sequence is encountered, and flush the buffered stuff then,
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2396
     proceed in single-character mode (processState0:) until the sequence is finished, and continue
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2397
     collecting.
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2398
     This makes this terminalView's speed usable and actually competitive with some existing
4612
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2399
     console applications. 
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2400
     BTW: It is *much* faster than the MSWindows command.com window,
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2401
     - so much for the 'slow' Smalltalk ;-)"
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2402
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2403
    |sensor|
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2404
6114
90913a584a2b #OTHER by exept
Claus Gittinger <cg@exept.de>
parents: 6100
diff changeset
  2405
    self assert:(rangeEndLine notNil).
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2406
    "/ remember how much is in the queue...
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2407
    [
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2408
        sizeOfOutstandingInputToBeProcessed := sizeOfOutstandingInputToBeProcessed - count.
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2409
    ] valueUninterruptably.
4449
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2410
    "/ Debug := true
4450
9f436d767165 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  2411
    "/ Debug := false
4285
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2412
    Debug ifTrue:[
6078
08c9e2a47dc5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6044
diff changeset
  2413
        Transcript show:self className; show:': processInput - state: '; show: state;
4446
02b5fbf621d3 refactored character processing
Claus Gittinger <cg@exept.de>
parents: 4338
diff changeset
  2414
                   show:' got: '; showCR: count.
4285
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2415
    ].
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2416
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2417
    filterStream notNil ifTrue:[
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2418
        filterStream nextPutAll:(buffer copyTo:count).
5249
0eed79a64938 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  2419
        filterOnly ifTrue:[^ self].
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2420
    ].
4267
5dca73a13f04 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  2421
    "/ '*' print. (buffer copyTo:count) asByteArray hexPrintString printCR.
1347
a98c0c7ff8c8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1345
diff changeset
  2422
1077
49525bbae21c added #saveCursor / #restoreCursor
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
  2423
"/    self hideCursor.
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2424
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2425
    "/ the following may not be too clean, but adds a lot of speed.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2426
    "/ instead of passing every individual character through the
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2427
    "/ escape-state machine, collect chunks of non-control text
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2428
    "/ when in state 0, and add them immediately to the pendingLines
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2429
    "/ collection of the textCollectors asynchronous update mechanism.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2430
    "/ This helps a lot if you do something like "ls -lR /" ...
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2431
    "/ For debugging the state machine, reenable the commented lines
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2432
    "/ below.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2433
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2434
"/1 to:count do:[:i|
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2435
"/    self nextPut:(buffer at:i).
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2436
"/].
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2437
"/self showCursor.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2438
"/^ self.
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2439
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2440
    access critical:[
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2441
        |index controlCharIndex stringWithOutControl crnlFollows 
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2442
         nFit nCharsInLine charIdx oldCollectSize|
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2443
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2444
        index := 1.
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2445
        [index <= count] whileTrue:[
4290
bad371611ba6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4288
diff changeset
  2446
            stringWithOutControl := nil.
bad371611ba6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4288
diff changeset
  2447
4321
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2448
            (state == 0) ifTrue:[
4267
5dca73a13f04 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  2449
                "/ in initial state:
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2450
                "/ quick scan forward for next control character ...
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2451
                controlCharIndex := buffer indexOfControlCharacterStartingAt:index.
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2452
                controlCharIndex > count ifTrue:[controlCharIndex := 0].
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2453
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2454
                controlCharIndex == 0 ifTrue:[
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2455
                    "/ no control characters - simply append all
4267
5dca73a13f04 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  2456
                    "/ to the outstanding lines...
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2457
                    stringWithOutControl := buffer copyFrom:index to:count.
4267
5dca73a13f04 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  2458
                    crnlFollows := false.
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2459
                    index := count + 1. "/ leave loop.
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2460
                ] ifFalse:[
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2461
                    controlCharIndex > index ifTrue:[
4267
5dca73a13f04 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  2462
                        "/ some more regular character(s) before control character
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2463
                        stringWithOutControl := buffer copyFrom:index to:controlCharIndex-1.
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2464
                        index := controlCharIndex. "/ proceed withcontrol character
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2465
                        crnlFollows := false.
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2466
                        index < (count - 1) ifTrue:[
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2467
                            (buffer at:index) == Character return ifTrue:[
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2468
                                (buffer at:index+1) == Character nl ifTrue:[
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2469
                                    crnlFollows := true.
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2470
                                    index := index + 2.
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2471
                                ]
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2472
                            ]
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2473
                        ].
4267
5dca73a13f04 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  2474
                    ] ifFalse:[
5dca73a13f04 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4266
diff changeset
  2475
                        "/ controlchr immediately follows
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2476
                    ]
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2477
                ].
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2478
            ].
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2479
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2480
            stringWithOutControl notNil ifTrue:[
4614
939148975344 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4612
diff changeset
  2481
                doUTF ifTrue:[
939148975344 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4612
diff changeset
  2482
                    Error handle:[:ex |
939148975344 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4612
diff changeset
  2483
                    ] do:[
939148975344 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4612
diff changeset
  2484
                        stringWithOutControl := stringWithOutControl utf8Decoded
939148975344 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4612
diff changeset
  2485
                    ].
4612
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2486
                ].
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2487
                nCharsInLine := stringWithOutControl size.
5244
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  2488
                (autoWrapFlag 
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  2489
                    and:[ (cursorCol + outstandingLine size + nCharsInLine) >= numberOfColumns ]
005f195c0795 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5243
diff changeset
  2490
                ) ifTrue:[
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2491
                    charIdx := 1.
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2492
                    nFit := numberOfColumns - outstandingLine size - cursorCol - 1.
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2493
                    nFit > 0 ifTrue:[
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2494
                        access critical:[
6017
4d87665db62d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6012
diff changeset
  2495
                            outstandingLine size ~~ 0 ifTrue:[
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2496
                                outstandingLine := outstandingLine , (stringWithOutControl copyTo:nFit).
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2497
                            ] ifFalse:[
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2498
                                outstandingLine := (stringWithOutControl copyTo:nFit).
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2499
                            ].
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2500
                        ].
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2501
                        charIdx := nFit + 1.
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2502
                    ].
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2503
                    "/ Transcript show:'idx: '; show:charIdx; show:' n:'; showCR:nCharsInLine.
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2504
                    oldCollectSize := collectSize.
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2505
                    collectSize := 32*1024.
4321
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2506
                    "/ characterwise, for correct wrap handling at line end
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2507
                    [charIdx <= nCharsInLine] whileTrue:[
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2508
                        |eachCharacter|
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2509
                        
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2510
                        eachCharacter := stringWithOutControl at:charIdx.
2268
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
  2511
                        self nextPut:eachCharacter.
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2512
"/                        self endEntry.
4452
ff2a970ba725 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4450
diff changeset
  2513
                        cursorCol >= numberOfColumns ifTrue:[ 
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2514
                            "/ self endEntry.
4452
ff2a970ba725 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4450
diff changeset
  2515
                            self validateCursorCol:cursorCol inLine:cursorLine.
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2516
                            "/ Transcript show:'col now: '; showCR:cursorCol.
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2517
                            nFit := numberOfColumns - cursorCol - charIdx.
5243
9f14ff0f4dd7 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5242
diff changeset
  2518
                            "/ Transcript show:'nFit now: '; showCR:nFit.
4452
ff2a970ba725 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4450
diff changeset
  2519
                        ].
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2520
                        charIdx := charIdx + 1.
2268
e3b57c072b89 wrap line at end
penk
parents: 2207
diff changeset
  2521
                    ].
2356
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2522
                    crnlFollows ifTrue:[
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2523
                        self nextPut:Character return.
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2524
                        self nextPut:Character nl.
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2525
                    ].
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2526
                    self endEntry.
5242
52e70453f0c3 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5236
diff changeset
  2527
                    collectSize := oldCollectSize.
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2528
                ] ifFalse:[
2356
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2529
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2530
                    Debug ifTrue:[
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2531
                        Transcript showCR:'String:<', stringWithOutControl, '>'.
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2532
                        stringWithOutControl do:[:ch |
4811
ef8ec8a8dbb6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4809
diff changeset
  2533
"/ ch codePoint > 255 ifTrue:[self halt].
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2534
                            Transcript show:'<'; show:(ch codePoint hexPrintString:2); show:'>'
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2535
                        ].
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2536
                        Transcript cr.
2356
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2537
                    ].
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2538
                    currentEmphasis notNil ifTrue:[
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2539
                        stringWithOutControl := stringWithOutControl emphasizeAllWith:currentEmphasis
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2540
                    ].
9a25fc1f8333 wrap bug
Claus Gittinger <cg@exept.de>
parents: 2341
diff changeset
  2541
4449
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2542
                    access critical:[
6017
4d87665db62d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6012
diff changeset
  2543
                        outstandingLine size ~~ 0 ifTrue:[
4449
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2544
                            outstandingLine := outstandingLine , stringWithOutControl.
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2545
                        ] ifFalse:[
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2546
                            outstandingLine := stringWithOutControl.
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2547
                        ].
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2548
                        crnlFollows ifTrue:[
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2549
                            "/ 'xp' printCR.
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2550
                            outstandingLines isNil ifTrue:[
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2551
                                outstandingLines := OrderedCollection with:outstandingLine
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2552
                            ] ifFalse:[
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2553
                                outstandingLines add:outstandingLine.
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2554
                            ].
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2555
                            outstandingLine := ''.
d6ba0c7976c0 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4446
diff changeset
  2556
                        ].
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2557
                    ].
4321
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2558
"/                    collecting ifTrue:[
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2559
"/                        flushPending ifFalse:[
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2560
"/                            self installDelayedUpdate
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2561
"/                        ] ifTrue:[
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2562
"/        "/                    outstandingLines size > collectSize ifTrue:[
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2563
"/        "/                        self endEntry
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2564
"/        "/                    ]
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2565
"/                        ]
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2566
"/                    ] ifFalse:[
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2567
"/                        self endEntry
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2568
"/                    ].
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2569
                ].
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2570
            ] ifFalse:[
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2571
                "/ no chunk to append (in an escape sequence)
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2572
                "/ must handle individual characters
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2573
                "/ 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
  2574
4290
bad371611ba6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4288
diff changeset
  2575
                "/ self endEntry.
2207
d352a2f0a83a no changes on terminal device anymore
penk
parents: 2205
diff changeset
  2576
                self nextPut:(buffer at:index).
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2577
                index := index + 1.
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2578
                [state ~~ 0 and:[index <= count]] whileTrue:[
2207
d352a2f0a83a no changes on terminal device anymore
penk
parents: 2205
diff changeset
  2579
                    self nextPut:(buffer at:index).
2191
221cae81c950 variable name more significant
penk
parents: 2169
diff changeset
  2580
                    index := index + 1.
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2581
                ]
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2582
            ]
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2583
        ].
4321
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2584
"/        inFlush := false.    
933
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
  2585
    ].
948
b93aba7db15d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  2586
4321
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2587
    (state == 0 and:[self shown]) ifTrue:[
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2588
        (sensor := self sensor) notNil ifTrue:[
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2589
            "/ 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
  2590
            "/ enforce update of the view (asynchronous)
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2591
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2592
            (sensor hasEvent:#processInput:n: for:self) ifFalse:[
997
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2593
                self endEntry.
c899373aac1d speedup (line buffering)
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
  2594
                self showCursor.
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2595
                "/ self makeCursorVisible.
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2596
            ] ifTrue:[
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2597
                "/ 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
  2598
                "/ 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
  2599
                "/ 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
  2600
                "/ 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
  2601
                "/ collectSize lines.
1015
61f7ea3e5463 comment
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
  2602
1055
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2603
                outstandingLines size > collectSize ifTrue:[ 
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2604
                    self endEntry.
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2605
                    self showCursor.
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2606
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2607
                    "/ 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
  2608
                    windowGroup notNil ifTrue:[
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2609
                        windowGroup processRealExposeEventsFor:self.
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2610
                    ]
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2611
                ].
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2612
            ]
eebff36e25e9 stay in slow-loop, while state ~~ 0 (in processInput:).
Claus Gittinger <cg@exept.de>
parents: 1052
diff changeset
  2613
        ].
933
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
  2614
    ].
de456e07697e much better asynchronous display
Claus Gittinger <cg@exept.de>
parents: 931
diff changeset
  2615
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2616
    "Created: / 10-06-1998 / 17:26:09 / cg"
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2617
    "Modified: / 28-01-2002 / 20:41:36 / micha"
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2618
    "Modified: / 30-07-2013 / 10:47:19 / cg"
6078
08c9e2a47dc5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6044
diff changeset
  2619
    "Modified: / 28-06-2019 / 09:20:12 / Claus Gittinger"
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  2620
!
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  2621
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2622
sync
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2623
    self waitForOutputToDrain
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2624
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2625
    "Created: / 27.7.1998 / 23:49:44 / cg"
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2626
!
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2627
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2628
waitForOutputToDrain
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2629
    |sensor|
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2630
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2631
    sensor := self sensor.
1363
7297da8a2e02 dont flush input when shell has terminated
Claus Gittinger <cg@exept.de>
parents: 1360
diff changeset
  2632
    (sensor notNil and:[sensor userEventCount > 30]) ifTrue:[
1323
b31f7319419c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1322
diff changeset
  2633
        [sensor userEventCount > 5] whileTrue:[
1021
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2634
            "/ give terminalView a chance to
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2635
            "/ catch up.
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2636
            Delay waitForSeconds:0.1.
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2637
        ]
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2638
    ].
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2639
c3963e925eb5 added #sync; better asynchronous display.
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
  2640
    "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
  2641
    "Modified: / 5.5.1999 / 18:51:00 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2642
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2643
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2644
!TerminalView methodsFor:'queries'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2645
5950
756275df9939 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5930
diff changeset
  2646
computePreferredExtent
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2647
    "return my preferred extent - this is computed from my numberOfLines,
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2648
     numberOfCols and font size"
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2649
5330
d158258898fb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5307
diff changeset
  2650
    ^ (fontWidth * self class defaultNumberOfColumns + ((leftMargin + margin) * 2))
951
a9e48f549763 fixed scroll-range
Claus Gittinger <cg@exept.de>
parents: 950
diff changeset
  2651
      @ 
1317
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  2652
      ((self heightForLines:self class defaultNumberOfLines) + 8)
926
df8d2a821687 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 925
diff changeset
  2653
5950
756275df9939 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5930
diff changeset
  2654
    "Created: / 09-11-2018 / 20:02:19 / Claus Gittinger"
756275df9939 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5930
diff changeset
  2655
!
756275df9939 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5930
diff changeset
  2656
756275df9939 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5930
diff changeset
  2657
isKeyboardConsumer
756275df9939 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5930
diff changeset
  2658
    "return true, if the receiver is a keyboard consumer;
756275df9939 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5930
diff changeset
  2659
     Always return true here"
756275df9939 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5930
diff changeset
  2660
756275df9939 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5930
diff changeset
  2661
    ^ true
929
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2662
!
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2663
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2664
terminalType
1420
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2665
    "returns a string describing this terminal (usually, this is
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2666
     passed down to the shell as TERM environment variable).
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2667
     Here, 'dump' is returned."
7564d09aa1b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1418
diff changeset
  2668
1354
94e7e8be960f must keep track of nLines/nCols in sizeChange (even if not unix)
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
  2669
    ^ 'dump'
929
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2670
30a2a3329055 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
  2671
    "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
  2672
    "Modified: / 5.5.1999 / 11:22:32 / cg"
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2673
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2674
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2675
!TerminalView methodsFor:'reader process'!
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2676
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2677
readAnyAvailableData
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2678
    "read data from the stream,
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2679
     and sends me #processInput:n: events if something arrived.
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2680
     Returns the amount of data read."
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2681
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2682
    |buffer n bufferSize|
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2683
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2684
    outStream isNil ifTrue:[^ 0].
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2685
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2686
    "/ avoid too many processInput messages to be in the buffer,
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2687
    "/ otherwise, the reaction on ctrl-s/ctrl-c is too slow, as
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2688
    "/ many processInput messages are in the sensor's queue before the keypress
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2689
    "/ event. We need another queue, actually so the sensor's keypress events
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2690
    "/ are not blocked while reading a lot of input.
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2691
    [sizeOfOutstandingInputToBeProcessed > 4096] whileTrue:[
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2692
        Delay waitForSeconds:0.1
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2693
    ].
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2694
4641
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  2695
    bufferSize := 1024*2.
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2696
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2697
    buffer := String new:bufferSize.
5306
a44a4afb98a8 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5288
diff changeset
  2698
    (StreamNotOpenError,ReadError) handle:[:ex |
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2699
        n := 0
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2700
    ] do:[
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2701
        n := outStream nextAvailableBytes:bufferSize into:buffer startingAt:1.
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2702
    ].
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2703
    n > 0 ifTrue:[
4641
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  2704
        ignoreOutput ifFalse:[
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  2705
            "/ Transcript showCR:n.
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  2706
            self pushEvent:#processInput:n: with:buffer with:n.
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  2707
            "/ remember how much is in the queue...
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  2708
            [
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  2709
                sizeOfOutstandingInputToBeProcessed := sizeOfOutstandingInputToBeProcessed + n.
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  2710
            ] valueUninterruptably
71968f0dd751 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4640
diff changeset
  2711
        ].
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2712
    ].
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2713
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2714
    ^ n
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2715
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2716
    "Created: / 05-05-1999 / 17:57:39 / cg"
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2717
    "Modified: / 28-01-2002 / 21:10:25 / micha"
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2718
    "Modified (comment): / 30-07-2013 / 10:50:03 / cg"
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2719
!
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2720
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2721
readerProcessLoop
4777
eaf5633d05dc class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4725
diff changeset
  2722
    "look for the command's output,
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2723
     and send me #processInput:n: events whenever something arrives."
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2724
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2725
    StreamError handle:[:ex |
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2726
        Transcript show:'Terminal(PTY-reader) [error]: '; showCR:ex description.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2727
    ] do:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2728
        [true] whileTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2729
            AbortOperationRequest handle:[:ex |
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2730
                self showCursor.
4457
afd08dab4722 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4452
diff changeset
  2731
                (outStream isNil or:[outStream atEnd]) ifTrue:[ ex reject ].
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2732
            ] do:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2733
                |n sensor|
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2734
4612
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2735
                "/ Delay waitForSeconds:0.01.
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2736
                outStream readWait.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2737
                sensor := self sensor.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2738
                (sensor notNil and:[sensor hasKeyPressEventFor:self]) ifTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2739
                    true "(sensor userEventCount > 10)" ifTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2740
                        "/ give terminalView a chance to
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2741
                        "/ send out the character.
4321
4803ecdf9a7a class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4317
diff changeset
  2742
                        "/ Transcript showCR:'d'.
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2743
                        Delay waitForSeconds:0.01.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2744
                    ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2745
                ] ifFalse:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2746
                    n := self readAnyAvailableData.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2747
                    n > 0 ifTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2748
                        shellPid notNil ifTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2749
                            self waitForOutputToDrain.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2750
                        ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2751
                    ] ifFalse:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2752
                        n == 0 ifTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2753
                            "/ Windows IPC has a bug - it always
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2754
                            "/ returns 0 (when the command is idle)
4612
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2755
                            "/ and says it's at the end (sigh)
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2756
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2757
                            OperatingSystem isMSWINDOWSlike ifTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2758
                                Delay waitForSeconds:0.01
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2759
                            ] ifFalse:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2760
                                outStream atEnd ifTrue:[
4327
9fa4f8804902 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4325
diff changeset
  2761
                                    self closeStreams.
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2762
                                    Processor activeProcess terminate.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2763
                                ] ifFalse:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2764
                                    "/ this should not happen.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2765
                                    Delay waitForSeconds:0.05
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2766
                                ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2767
                            ].
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2768
                        ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2769
                    ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2770
                ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2771
            ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2772
        ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2773
    ]
4315
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2774
1db44a2c0293 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4313
diff changeset
  2775
    "Modified: / 30-07-2013 / 10:30:38 / cg"
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2776
!
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2777
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2778
startReaderProcess
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2779
    "Start a reader process, which looks for the commands output,
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2780
     and sends me #processInput:n: events whenever something arrives."
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2781
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2782
    self obsoleteMethodWarning.    
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2783
    self startReaderProcessWhenVisible.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2784
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2785
    "
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2786
     VT100TerminalView openShell
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2787
    "
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2788
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2789
    "Modified: / 5.5.1999 / 17:58:02 / cg"
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2790
    "Modified: / 28.1.2002 / 21:10:13 / micha"
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2791
!
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2792
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2793
startReaderProcessNow
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2794
    "Start a reader process, which looks for the commands output,
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2795
     and sends me #processInput:n: events whenever something arrives."
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2796
4612
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2797
    self startReaderProcessWhenVisible:false
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2798
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2799
    "
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2800
     VT100TerminalView openShell
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2801
    "
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2802
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2803
    "Modified: / 5.5.1999 / 17:58:02 / cg"
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2804
    "Modified: / 28.1.2002 / 21:10:13 / micha"
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2805
!
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2806
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2807
startReaderProcessWhenVisible
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2808
    "Start a reader process, which looks for the commands output,
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2809
     and sends me #processInput:n: events whenever something arrives."
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2810
4612
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2811
    self startReaderProcessWhenVisible:true
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2812
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2813
    "
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2814
     VT100TerminalView openShell
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2815
    "
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2816
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2817
    "Modified: / 5.5.1999 / 17:58:02 / cg"
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2818
    "Modified: / 28.1.2002 / 21:10:13 / micha"
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2819
!
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2820
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2821
startReaderProcessWhenVisible:whenVisible
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2822
    "Start a reader process, which looks for the commands output,
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2823
     and sends me #processInput:n: events whenever something arrives."
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2824
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2825
    readerProcess isNil ifTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2826
        readerProcess := [
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2827
            [
4612
e05d68f2d152 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4604
diff changeset
  2828
                whenVisible ifTrue:[self waitUntilVisible].
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2829
                self readerProcessLoop.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2830
            ] ifCurtailed:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2831
                readerProcess := nil    
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2832
            ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2833
        ] fork. "/ forkAt:9.
5888
b0a0be3361d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5874
diff changeset
  2834
        readerProcess name:'Terminal: pty reader'.
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2835
    ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2836
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2837
    "
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2838
     VT100TerminalView openShell
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2839
    "
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2840
5888
b0a0be3361d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5874
diff changeset
  2841
    "Modified: / 05-05-1999 / 17:58:02 / cg"
b0a0be3361d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5874
diff changeset
  2842
    "Modified: / 28-01-2002 / 21:10:13 / micha"
b0a0be3361d1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5874
diff changeset
  2843
    "Modified: / 16-08-2018 / 13:22:32 / Claus Gittinger"
4265
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2844
!
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2845
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2846
stopReaderProcess
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2847
    "stop the background reader thread"
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2848
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2849
    |sensor|
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2850
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2851
    readerProcess notNil ifTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2852
        readerProcess terminate.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2853
        "/ give it a chance to really terminate
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2854
        Processor yield.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2855
        readerProcess := nil
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2856
    ].
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2857
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2858
    "/ flush any leftover input-processing events
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2859
    (sensor := self sensor) notNil ifTrue:[
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2860
        sensor flushEventsFor:self withType:#processInput:n:.
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2861
    ]
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2862
    "Modified: / 21.7.1998 / 19:00:13 / cg"
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2863
! !
76d3fea328d6 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  2864
2506
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2865
!TerminalView methodsFor:'searching'!
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2866
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2867
startPositionForSearchBackward
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2868
    ^ self startPositionForSearchBackwardBasedOnSelection
2506
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2869
!
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2870
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2871
startPositionForSearchForward
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2872
    ^ self startPositionForSearchForwardBasedOnSelection
2506
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2873
! !
f12c7c321131 menu (search and goto)
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
  2874
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2875
!TerminalView methodsFor:'selection handling'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2876
1317
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  2877
autoMoveCursorToEndOfSelection
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  2878
    "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
  2879
     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
  2880
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  2881
    ^ false
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  2882
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  2883
!
dace272367a7 do not move the cursor when double-clicking for a selection.
Claus Gittinger <cg@exept.de>
parents: 1316
diff changeset
  2884
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2885
copySelection
5716
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2886
    "the inherited code would leave the cursor behin the selection;
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2887
     we always want it to stay at the end.
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2888
     However: cursorToEndOfText ignores trailing spaces!!
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2889
    "
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2890
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2891
    |cLine cCol|
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2892
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2893
    cLine := cursorLine.
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2894
    cCol := cursorCol.
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2895
    super copySelection.
5716
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2896
    "/ self cursorToEndOfText
aa0c8adb8c29 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5704
diff changeset
  2897
    self cursorLine:cLine col:cCol.
5151
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2898
!
23a4207e38af #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  2899
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2900
paste:someText
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2901
    "paste - redefined to send the chars to the shell instead
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2902
     of pasting into the view"
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2903
5223
38366ed20368 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
  2904
    |s nLines doLineEditMode|
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2905
2573
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2906
    inStream isNil ifTrue:[
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2907
        self flash.
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2908
        ^ self           "/ already closed
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2909
    ]. 
9ef4727d2a57 menu changes (goto does not make sense);
Claus Gittinger <cg@exept.de>
parents: 2539
diff changeset
  2910
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2911
    s := someText.
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2912
    s isString ifTrue:[
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2913
        s := s asStringCollection
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2914
    ] ifFalse:[
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2915
        (s isKindOf:StringCollection) ifFalse:[
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2916
            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
  2917
            ^ self
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2918
        ]
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2919
    ].
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2920
    (nLines := s size) == 0 ifTrue:[^ self].
5223
38366ed20368 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
  2921
    (nLines == 1 and:[(s at:1) isEmptyOrNil]) ifTrue:[^ self].
38366ed20368 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
  2922
38366ed20368 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
  2923
    doLineEditMode := ((nLines == 1) and:[self shouldProcessInputInLineEditMode]).
38366ed20368 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
  2924
    
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2925
    s keysAndValuesDo:[:idx :line |
4285
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2926
        line notNil ifTrue:[
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2927
            (Debug or:[DebugKeyboard]) ifTrue:[
4285
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2928
                Transcript showCR:'send paste line: ',line asByteArray hexPrintString
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2929
            ].
e07bad437b90 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4268
diff changeset
  2930
        ].
5223
38366ed20368 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
  2931
        doLineEditMode ifTrue:[
4601
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  2932
            line do:[:ch | self keyPressInLineEditMode:ch ].
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  2933
            idx ~~ nLines ifTrue:[
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  2934
                self keyPressInLineEditMode:#Return
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  2935
            ]
4317
4c2fd0c98fcb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4315
diff changeset
  2936
        ] ifFalse:[
5223
38366ed20368 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5164
diff changeset
  2937
            self send:(line ? '').
4601
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  2938
            idx ~~ nLines ifTrue:[
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  2939
                self sendLineEnd
7a5e33b7f079 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4600
diff changeset
  2940
            ]
950
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2941
        ]
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2942
    ].
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2943
9e5834388a79 fixed paste & command keys
Claus Gittinger <cg@exept.de>
parents: 948
diff changeset
  2944
    "Modified: / 12.6.1998 / 22:12:47 / cg"
4490
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2945
!
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2946
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2947
selection
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2948
    |sel|
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2949
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2950
    sel := super selection.
4492
dec9b2a7afeb class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4490
diff changeset
  2951
    sel isNil ifTrue:[^ sel].
4490
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2952
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2953
    "/ if it is a line-wise collection, return multiple lines;
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2954
    "/ otherwise, concatenate to make it one long string.
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2955
    "/ this allows for multi-line commands (many args) to be copy-pasted easily
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2956
    selectionStartCol == 1 ifTrue:[
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2957
        selectionEndCol == 0 ifTrue:[
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2958
            ^ sel "/ a full-line (3xclick selection)
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2959
        ].
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2960
    ].
5b2f706431fe class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4487
diff changeset
  2961
    ^ StringCollection with:(sel asStringWith:'').
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2962
! !
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2963
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2964
!TerminalView methodsFor:'sending'!
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2965
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2966
send:aString
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2967
    "send aString to the underlying program's stdinput"
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2968
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2969
    aString notEmptyOrNil ifTrue:[
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2970
        aString containsNon7BitAscii ifTrue:[
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2971
            aString do:[:each |
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2972
                self sendCharacter:each
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2973
            ].
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2974
        ] ifFalse:[
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2975
            recorderStream notNil ifTrue:[
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2976
                recorderStream nextPutAll:aString
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2977
            ].
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2978
            (Debug or:[DebugKeyboard]) ifTrue:[
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2979
                Transcript showCR:'send <',aString,'>'
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2980
            ].
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2981
            inStream nextPutAll:aString
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2982
        ].
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2983
    ].
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2984
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2985
    "Created: / 29-07-2013 / 18:18:24 / cg"
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2986
!
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2987
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2988
sendCR:aString
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2989
    "send aString followed by a return to the underlying program's stdinput"
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2990
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2991
    self send:aString.
4983
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  2992
    self sendLineEnd.
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2993
!
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2994
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2995
sendCharacter:aCharacter
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  2996
    "send a single character to the underlying program's stdin"
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  2997
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2998
    aCharacter codePoint > 16r7F ifTrue:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  2999
        inputIsUTF8 ifTrue:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3000
            aCharacter utf8Encoded do:[:eachUTFChar|
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3001
                (Debug or:[DebugKeyboard]) ifTrue:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3002
                    self debugPrintCharacter:eachUTFChar as:'send utf'.
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3003
                ].
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3004
                recorderStream notNil ifTrue:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3005
                    recorderStream nextPut:eachUTFChar
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3006
                ].
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3007
                inStream nextPut:eachUTFChar.
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  3008
            ].
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3009
            ^ self
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3010
        ].
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3011
        aCharacter bitsPerCharacter > 8 ifTrue:[
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  3012
            "/ ignore
6078
08c9e2a47dc5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6044
diff changeset
  3013
            Transcript showCR:(self className,': invalid (non-8bit) character ignored').
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3014
            ^ self
4809
720e12243076 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  3015
        ].
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3016
        "/ send normal
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3017
    ].
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3018
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3019
    recorderStream notNil ifTrue:[
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3020
        recorderStream nextPut:aCharacter
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3021
    ].
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3022
    (Debug or:[DebugKeyboard]) ifTrue:[
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3023
        self debugPrintCharacter:aCharacter as:'send'.
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3024
    ].
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3025
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3026
    inStream nextPut:aCharacter.
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3027
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3028
    "Created: / 29-07-2013 / 18:18:24 / cg"
6078
08c9e2a47dc5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6044
diff changeset
  3029
    "Modified: / 28-06-2019 / 09:20:15 / Claus Gittinger"
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3030
!
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3031
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3032
sendLine:aString
5008
2c183e39345e #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5006
diff changeset
  3033
    (Debug or:[DebugKeyboard]) ifTrue:[
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3034
        'VT100: sendline: ' print. aString asByteArray hexPrintString printCR
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3035
    ].
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3036
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3037
    self send:aString.
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3038
    self sendLineEnd
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3039
!
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3040
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3041
sendLineEnd
4983
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3042
    inputTranslateCRToNL ifTrue:[
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3043
        self sendCharacter:(Character nl).
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3044
    ] ifFalse:[
4983
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3045
        inputTranslateCRToCRNL ifTrue:[
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3046
            self send:(String crlf).
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3047
        ] ifFalse:[
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3048
            self sendCharacter:(Character return).
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3049
        ]
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3050
    ]
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3051
"/    OperatingSystem isMSDOSlike ifTrue:[
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3052
"/        self send:String crlf.
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3053
"/    ] ifFalse:[
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3054
"/        self send:String return.
a5e2fc0f4a99 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 4982
diff changeset
  3055
"/    ].
4604
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3056
! !
1ac8aff09094 class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4603
diff changeset
  3057
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3058
!TerminalView class methodsFor:'documentation'!
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3059
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3060
version
4799
99ae54e3d35d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4777
diff changeset
  3061
    ^ '$Header$'
3758
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
  3062
!
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
  3063
59fe4398679a added: #example
Claus Gittinger <cg@exept.de>
parents: 3225
diff changeset
  3064
version_CVS
4799
99ae54e3d35d class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4777
diff changeset
  3065
    ^ '$Header$'
914
7ac6d1a53bab initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3066
! !
2205
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
  3067
4164
7ed0d0bbc7cd class: TerminalView
Claus Gittinger <cg@exept.de>
parents: 4105
diff changeset
  3068
2205
Claus Gittinger <cg@exept.de>
parents: 2204
diff changeset
  3069
TerminalView initialize!