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