ShellView.st
author Claus Gittinger <cg@exept.de>
Sun, 01 Feb 2015 14:16:33 +0100
changeset 3178 58100b56595d
parent 874 ab93fcd829c5
permissions -rw-r--r--
class: MenuEditor fixed the following redraw bug in ModelListView (which is already fixed in SelectionInListView): if a colored item is shown with selection, the color attribute should be removed (or relaxed), to avoid drawing the label invisible. I.e. if the text color is blue or grey, and the selection bg is blue. we should draw white-on-blue, instead of blue/grey on blue. For this to work, the info whether drawing a selection must be passed down through the renderer to the item's draw routine.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
     1
"
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
     3
              All Rights Reserved
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
     4
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
     5
 This software is furnished under a license and may be used
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
     7
 inclusion of the above copyright notice. This software may not
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
     9
 other person. No title to or ownership of the software is
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    10
 hereby transferred.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    11
"
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    12
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    13
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    14
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    15
ApplicationModel subclass:#ShellView
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    16
	instanceVariableNames:'task directory commands currentCommand numberOfMaxLines'
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    17
	classVariableNames:''
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    18
	poolDictionaries:''
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    19
	category:'Interface-Support'
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    20
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    21
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    22
!ShellView class methodsFor:'documentation'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    23
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    24
copyright
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    25
"
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    26
 COPYRIGHT (c) 1997 by eXept Software AG
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    27
              All Rights Reserved
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    28
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    29
 This software is furnished under a license and may be used
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    31
 inclusion of the above copyright notice. This software may not
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    33
 other person. No title to or ownership of the software is
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    34
 hereby transferred.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    35
"
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    36
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    37
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    38
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    39
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    40
documentation
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    41
"
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    42
    [author:]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    43
        Thomas Zwick
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    44
"
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    45
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    46
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    47
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    48
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    49
!ShellView class methodsFor:'interface specs'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    50
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    51
windowSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    52
    "This resource specification was automatically generated
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    53
     by the UIPainter of ST/X."
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    54
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    55
    "Do not manually edit this!! If it is corrupted,
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    56
     the UIPainter may not be able to read the specification."
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    57
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    58
    "
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    59
     UIPainter new openOnClass:ShellView andSelector:#windowSpec
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    60
     ShellView new openInterface:#windowSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    61
     ShellView open
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    62
    "
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    63
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    64
    <resource: #canvas>
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    65
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    66
    ^
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    67
     
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    68
       #(#FullSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    69
          #window: 
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    70
           #(#WindowSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    71
              #name: 'unnamed canvas'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    72
              #layout: #(#LayoutFrame 252 0 229 0 551 0 497 0)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    73
              #label: 'unnamed canvas'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    74
              #min: #(#Point 10 10)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    75
              #max: #(#Point 1152 864)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    76
              #bounds: #(#Rectangle 252 229 552 498)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    77
              #usePreferredExtent: false
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    78
          )
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    79
          #component: 
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    80
           #(#SpecCollection
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    81
              #collection: 
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    82
               #(
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    83
                 #(#TextEditorSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    84
                    #name: 'fileContentsView'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    85
                    #layout: #(#LayoutFrame 0 0 0 0.0 0 1 -22 1)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    86
                    #model: #valueOfFileContents
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    87
                    #hasHorizontalScrollBar: true
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    88
                    #hasVerticalScrollBar: true
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    89
                    #miniScrollerHorizontal: true
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    90
                )
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
    91
                 #(#SequenceViewSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    92
                    #name: 'shellOutputView'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    93
                    #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -22 1.0)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    94
                    #model: #selectionOfShellOutput
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    95
                    #style: #(#FontDescription #courier #medium #roman 12)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    96
                    #hasHorizontalScrollBar: true
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    97
                    #hasVerticalScrollBar: true
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    98
                    #doubleClickSelector: #listDoubleClicked:
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
    99
                    #useIndex: true
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   100
                    #sequenceList: #listOfShellOutput
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   101
                )
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   102
                 #(#ActionButtonSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   103
                    #name: 'fileNameButton'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   104
                    #layout: #(#LayoutFrame 0 0.0 -22 1 -60 1.0 0 1.0)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   105
                    #model: #toggleViews
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   106
                )
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   107
                 #(#ActionButtonSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   108
                    #name: 'saveButton'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   109
                    #layout: #(#LayoutFrame -60 1 -22 1 0 1.0 0 1.0)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   110
                    #label: 'Save'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   111
                    #model: #saveFileContents
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   112
                )
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   113
                 #(#ActionButtonSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   114
                    #name: 'stopButton'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   115
                    #layout: #(#LayoutFrame 0 0 -22 1 0 1.0 0 1)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   116
                    #label: 'Stop'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   117
                    #model: #terminateTask
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   118
                )
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   119
                 #(#InputFieldSpec
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   120
                    #name: 'commandInputField'
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   121
                    #layout: #(#LayoutFrame 0 0 -22 1 0 1.0 0 1)
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   122
                    #model: #valueOfCommand
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   123
                    #type: #string
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   124
                    #acceptOnReturn: false
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   125
                    #acceptOnTab: false
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   126
                )
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   127
              )
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   128
          )
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   129
      )
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   130
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   131
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   132
!ShellView methodsFor:'accessing'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   133
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   134
directory
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   135
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   136
    ^directory ? (directory := Filename currentDirectory asAbsoluteFilename name) 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   137
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   138
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   139
directory: aDirectory
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   140
782
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   141
    |dir|
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   142
    (directory ~= (dir := aDirectory asFilename asAbsoluteFilename name))
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   143
    ifTrue:
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   144
    [
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   145
        directory := dir.
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   146
        self listOfShellOutput
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   147
                at: self listOfShellOutput size
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   148
                put: self getDirectoryTextString
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   149
    ]
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   150
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   151
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   152
numberOfMaxLines
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   153
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   154
    ^numberOfMaxLines ? (numberOfMaxLines := 500)
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   155
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   156
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   157
numberOfMaxLines: anInteger
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   158
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   159
    numberOfMaxLines := anInteger
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   160
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   161
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   162
!ShellView methodsFor:'accessing - views'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   163
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   164
commandInputField
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   165
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   166
    ^builder componentAt: #commandInputField
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   167
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   168
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   169
fileContentsView
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   170
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   171
    ^builder componentAt: #fileContentsView
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   172
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   173
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   174
fileNameButton
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   175
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   176
    ^builder componentAt: #fileNameButton
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   177
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   178
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   179
saveButton
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   180
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   181
    ^builder componentAt: #saveButton
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   182
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   183
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   184
shellOutputView
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   185
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   186
    ^builder componentAt: #shellOutputView
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   187
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   188
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   189
stopButton
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   190
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   191
    ^builder componentAt: #stopButton
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   192
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   193
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   194
!ShellView methodsFor:'actions'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   195
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   196
executeCommand: aCommand
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   197
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   198
    |s|       
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   199
    aCommand isNil | task notNil | directory isNil ifTrue: [^nil].
757
d28fb65967a9 execute command bug fixed
tz
parents: 643
diff changeset
   200
    aCommand isString ifTrue: [^self executeCommands: (Array with: aCommand)].
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   201
    aCommand key size = 0 ifTrue: [^aCommand key: ''].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   202
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   203
    self valueOfCommand value: ''.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   204
    self listOfShellOutput
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   205
        at: self listOfShellOutput size
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   206
        put: self getDirectoryTextString, (Text string: aCommand key color: Color blue).
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   207
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   208
    aCommand key trimBlanks = 'clear'
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   209
    ifTrue: 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   210
    [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   211
        self shellOutputView raise.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   212
        ^self listOfShellOutput contents: (Array with: self getDirectoryTextString).
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   213
    ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   214
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   215
    (((s := aCommand key readStream) nextWord = 'cd') and: [(s next = Character space) | s atEnd])
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   216
    ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   217
    [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   218
        s := s upToEnd trimBlanks.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   219
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   220
        s size = 0
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   221
        ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   222
        [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   223
            s := Filename homeDirectory
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   224
        ]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   225
        ifFalse: 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   226
        [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   227
            s first = $/
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   228
                ifTrue: [s := s asFilename]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   229
                ifFalse: [s := self directory asFilename constructDirectory: s]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   230
        ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   231
        (s exists and: [s isDirectory])
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   232
        ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   233
        [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   234
            directory := s name.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   235
            ^self listOfShellOutput contents: (Array with: self getDirectoryTextString).
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   236
        ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   237
    ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   238
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   239
    self stopButton raise.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   240
    self shellOutputView raise.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   241
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   242
    self
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   243
        execute: aCommand key
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   244
        exit:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   245
        [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   246
            self commandInputField raise.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   247
            aCommand value: true. 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   248
            self executeNextCommand.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   249
            self append: self getDirectoryTextString
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   250
        ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   251
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   252
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   253
!ShellView methodsFor:'aspects'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   254
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   255
listOfShellOutput
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   256
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   257
    |holder|
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   258
    (holder := builder bindingAt:#listOfShellOutput) isNil ifTrue:[
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   259
        builder aspectAt:#listOfShellOutput put:(holder :=  List new).
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   260
        holder add: self getDirectoryTextString
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   261
    ].  
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   262
    ^holder
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   263
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   264
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   265
selectionOfShellOutput
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   266
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   267
    |holder|              
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   268
    (holder := builder bindingAt:#selectionOfShellOutput) isNil ifTrue:[
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   269
        builder aspectAt:#selectionOfShellOutput put: (holder := 1 asValue)
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   270
    ]. 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   271
    ^holder
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   272
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   273
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   274
valueOfCommand
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   275
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   276
    |holder|
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   277
    (holder := builder bindingAt:#valueOfCommand) isNil ifTrue:[
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   278
        builder aspectAt:#valueOfCommand put:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   279
            (holder :=  AspectAdaptor new subject: self; forAspect: #currentCommand).
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   280
    ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   281
    ^ holder       
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   282
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   283
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   284
valueOfFileContents
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   285
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   286
    |holder|
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   287
    (holder := builder bindingAt:#valueOfFileContents) isNil ifTrue:[
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   288
        builder aspectAt:#valueOfFileContents put:(holder :=  ValueHolder new).
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   289
    ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   290
    ^holder    
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   291
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   292
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   293
!ShellView methodsFor:'callbacks'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   294
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   295
listDoubleClicked: anLineIndex
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   296
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   297
    |stream streamAtLine possibleFileName selectedFileName fileFound|
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   298
    possibleFileName := ''.
782
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   299
    stream := (self listOfShellOutput at: anLineIndex) string readStream.
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   300
    fileFound := false.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   301
    [stream atEnd | fileFound]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   302
    whileFalse: 
782
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   303
    [                
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   304
        possibleFileName := possibleFileName, stream next.
762
ba7c3153f9d1 possibleFileName
tz
parents: 757
diff changeset
   305
        (("((selectedFileName := possibleFileName) asFilename exists) or:"
ba7c3153f9d1 possibleFileName
tz
parents: 757
diff changeset
   306
        (selectedFileName := directory, Filename separator, possibleFileName) asFilename exists)
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   307
         and: [selectedFileName asFilename isDirectory not])
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   308
        ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   309
        [   
782
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   310
            |possibleLineIndex listSize lineNumber|   
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   311
            fileFound := true.  
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   312
            self openFile: selectedFileName.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   313
            [stream atEnd | lineNumber notNil]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   314
            whileFalse: 
782
62f2cd2978d5 #directory: must not delete line
tz
parents: 762
diff changeset
   315
            [            
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   316
                lineNumber := Integer readFrom: stream nextAlphaNumericWord onError: nil.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   317
            ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   318
            lineNumber := lineNumber ? 1.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   319
            listSize := self fileContentsView list size.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   320
            (lineNumber between: 1 and: listSize)
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   321
            ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   322
            [          
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   323
                self fileContentsView selectLine: lineNumber
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   324
            ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   325
            lineNumber > listSize
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   326
            ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   327
            [          
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   328
                self fileContentsView selectLine: listSize
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   329
            ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   330
        ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   331
    ]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   332
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   333
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   334
874
ab93fcd829c5 create builder
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   335
!ShellView methodsFor:'initialization'!
ab93fcd829c5 create builder
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   336
ab93fcd829c5 create builder
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   337
initialize
ab93fcd829c5 create builder
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   338
    super initialize.
ab93fcd829c5 create builder
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   339
    self createBuilder
ab93fcd829c5 create builder
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   340
ab93fcd829c5 create builder
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   341
    "Created: / 20.6.1998 / 15:30:48 / cg"
ab93fcd829c5 create builder
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   342
! !
ab93fcd829c5 create builder
Claus Gittinger <cg@exept.de>
parents: 782
diff changeset
   343
643
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   344
!ShellView methodsFor:'private'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   345
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   346
append:anElement
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   347
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   348
    anElement notNil
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   349
    ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   350
    [   
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   351
        self listOfShellOutput size > self numberOfMaxLines
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   352
        ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   353
        [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   354
            self listOfShellOutput contents: (self listOfShellOutput copyFrom:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   355
                self listOfShellOutput size - (self numberOfMaxLines//5)
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   356
                to: self listOfShellOutput size)
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   357
        ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   358
        self listOfShellOutput add: anElement.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   359
        self selectionOfShellOutput value: self listOfShellOutput size.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   360
    ]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   361
           
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   362
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   363
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   364
execute: cmd exit:exitAction
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   365
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   366
    |outStream|
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   367
    self terminateTask.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   368
    outStream:= PipeStream readingFrom: cmd errorDisposition:#inline inDirectory: directory.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   369
    task :=
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   370
    [          
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   371
        [      
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   372
            outStream canReadWithoutBlocking
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   373
            ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   374
            [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   375
                outStream readWait.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   376
                self append: (outStream upTo: Character cr).
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   377
            ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   378
        ] doWhile:[outStream atEnd not]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   379
    ] forkAt: Processor userBackgroundPriority.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   380
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   381
    task addExitAction:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   382
    [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   383
        task := nil.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   384
        outStream shutDown.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   385
        exitAction value
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   386
    ]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   387
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   388
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   389
executeNextCommand
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   390
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   391
    self executeCommand: (commands detect: [:str| str value = false] ifNone: nil)
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   392
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   393
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   394
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   395
getDirectoryTextString
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   396
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   397
    ^Text string: ('[',self directory, '] > ') emphasis: #bold
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   398
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   399
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   400
listDirectory: dir
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   401
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   402
    |s match d|   
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   403
    match := (dir name copy reverse upTo: Filename separator) reverse.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   404
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   405
    s := dir name copy reverse readStream.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   406
    s through: Filename separator.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   407
    s := s upToEnd reverse.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   408
    dir name = Filename separator asString ifTrue: [s := Filename separator asString].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   409
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   410
    ((d := dir) isDirectory or:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   411
    [((d := s asFilename) isDirectory or:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   412
    [(d := directory asFilename construct: s) isDirectory])])
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   413
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   414
     ifTrue: [        
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   415
    d directoryContents do:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   416
    [:dirEntry|      
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   417
        ((match, '*') match: dirEntry) ifTrue: [self append:dirEntry]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   418
    ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   419
    self append: self getDirectoryTextString
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   420
    ]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   421
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   422
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   423
!ShellView methodsFor:'selection'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   424
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   425
currentCommand
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   426
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   427
    ^currentCommand
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   428
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   429
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   430
currentCommand: aString
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   431
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   432
    self commandInputField crAction: [self executeCommands: (Array with: currentCommand)].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   433
    self commandInputField entryCompletionBlock:[:contents |
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   434
        |newString|
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   435
        newString := Filename 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   436
                        filenameCompletionFor:contents 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   437
                        directory:directory asFilename
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   438
                        directoriesOnly:false 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   439
                        filesOnly:false 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   440
                        ifMultiple:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   441
                            [:dir |
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   442
                                self listDirectory: dir.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   443
                                self commandInputField flash.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   444
                            ].            
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   445
        self commandInputField contents:newString.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   446
        self commandInputField cursorToEndOfLine.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   447
    ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   448
    currentCommand := aString.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   449
    self listOfShellOutput size > 0
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   450
    ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   451
    [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   452
        self listOfShellOutput
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   453
            at: self listOfShellOutput size
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   454
            put: self getDirectoryTextString, currentCommand
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   455
    ].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   456
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   457
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   458
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   459
!ShellView methodsFor:'user actions'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   460
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   461
executeCommands: aStingCollection
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   462
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   463
    commands := aStingCollection collect: [:str| str->false].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   464
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   465
    self executeNextCommand
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   466
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   467
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   468
openFile: aFileName
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   469
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   470
    |fileName|
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   471
    task isNil & (((fileName := aFileName asFilename) exists)
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   472
    or: [(fileName := directory asFilename construct: fileName) exists])
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   473
    ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   474
    [        
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   475
        self fileNameButton raise; sizeFixed: true;label: fileName name.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   476
        self fileContentsView raise.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   477
        self saveButton raise.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   478
        Stream readErrorSignal
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   479
        handle:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   480
        [:ex|
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   481
            self warn: 'Reading file contents failed!!'.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   482
            self toggleViews.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   483
        ]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   484
        do:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   485
        [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   486
            self valueOfFileContents value: fileName contentsOfEntireFile
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   487
        ]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   488
    ]  
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   489
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   490
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   491
saveFileContents
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   492
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   493
    self fileContentsView saveAs: self fileNameButton label
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   494
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   495
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   496
terminateTask
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   497
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   498
    task notNil ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   499
    [ 
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   500
        task terminate.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   501
        task := nil
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   502
    ]   
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   503
!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   504
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   505
toggleViews
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   506
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   507
    self fileNameButton label isEmpty
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   508
    ifFalse:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   509
    [
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   510
        task notNil
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   511
            ifTrue: [self stopButton raise]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   512
            ifFalse: [self commandInputField raise].
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   513
        self shellOutputView raise.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   514
        self fileNameButton sizeFixed: true; label: ''.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   515
        self valueOfFileContents value: ''.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   516
    ]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   517
    ifTrue:
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   518
    [         
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   519
        self fileNameButton raise.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   520
        self infoLabel raise.
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   521
        self fileContentsView raise
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   522
    ]
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   523
! !
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   524
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   525
!ShellView class methodsFor:'documentation'!
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   526
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   527
version
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   528
    ^ '$Header$'
d6e1a9fced34 initial checkin
tz
parents:
diff changeset
   529
! !