FileBrowser.st
author Claus Gittinger <cg@exept.de>
Wed, 29 May 1996 13:23:56 +0200
changeset 581 d1a1ae9d49e4
parent 564 28b766ce6ec5
child 585 be0241bf7268
permissions -rw-r--r--
removed old non-thread support
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     1
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1991 by Claus Gittinger
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
     3
	      All Rights Reserved
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     4
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    10
 hereby transferred.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    11
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    12
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    13
StandardSystemView subclass:#FileBrowser
280
4775fe6326a0 submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents: 267
diff changeset
    14
	instanceVariableNames:'labelView filterField fileListView subView currentDirectory
4775fe6326a0 submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents: 267
diff changeset
    15
		fileList checkBlock checkDelta timeOfLastCheck showLongList
4775fe6326a0 submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents: 267
diff changeset
    16
		showVeryLongList showDotFiles myName killButton compressTabs
4775fe6326a0 submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents: 267
diff changeset
    17
		lockUpdate previousDirectory currentFileName timeOfFileRead
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
    18
		tabSpec commandView commandIndex fileEncoding'
280
4775fe6326a0 submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents: 267
diff changeset
    19
	classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon
4775fe6326a0 submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents: 267
diff changeset
    20
		CommandHistory CommandHistorySize'
4775fe6326a0 submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents: 267
diff changeset
    21
	poolDictionaries:''
4775fe6326a0 submenu strings auch aus resources
Claus Gittinger <cg@exept.de>
parents: 267
diff changeset
    22
	category:'Interface-Browsers'
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    23
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    24
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    25
!FileBrowser class methodsFor:'documentation'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    26
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    27
copyright
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    28
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    29
 COPYRIGHT (c) 1991 by Claus Gittinger
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
    30
	      All Rights Reserved
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    31
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    32
 This software is furnished under a license and may be used
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    37
 hereby transferred.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    38
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    39
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    40
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    41
documentation
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    42
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    43
    this used to be a very simple demo application,
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    44
    but migrated into a quite nice tool, includes all kinds of 
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    45
    warning and information boxes, background processes for directory-
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    46
    reading and internationalized strings. A good example for beginners,
100
claus
parents: 98
diff changeset
    47
    on how to do things .... (and maybe how not to do things ;-, since some
claus
parents: 98
diff changeset
    48
    stuff is historic and was implemented at times when better mechanisms
claus
parents: 98
diff changeset
    49
    were not available)
52
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    50
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    51
    See additional information in 'doc/misc/fbrowser.doc'.
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
    52
52
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    53
    WARNING: files edited with FileBrowser will have leading spaces (multiple-8)
508
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    54
             being replaced by tabs. If tabs are to be preserved at other
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    55
             positions (for example, sendmail-config files) they will be
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    56
             corrupt after being written.
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    57
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    58
    [instance variables]:
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    59
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    60
        checkDelta      <Integer>       number of seconds of check interval
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    61
                                        (looks ever so often if shown directory
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    62
                                         has changed). You may make this number
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    63
                                        higher, if your network-times are
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    64
                                        incorrect and thus, the filebrowser
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    65
                                        checks too often.
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    66
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    67
        compressTabs    <Boolean>       if true, leading spaces will be
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    68
                                        replaced by tabs when saving text
52
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    69
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    70
    some of the defaults (long/short list etc.) can be set by the resource file;
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    71
    see FileBrowser>>initialize for more details..
508
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    72
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    73
    [author:]
8d2ab732fca5 documentation
Claus Gittinger <cg@exept.de>
parents: 495
diff changeset
    74
        Claus Gittinger
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    75
"
203
de8d39d459fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
    76
! !
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    77
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    78
!FileBrowser class methodsFor:'instance creation'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    79
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    80
openOn:aDirectoryPath
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    81
    "start a new FileBrowser in a pathname"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    82
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    83
    ^ (self new currentDirectory:aDirectoryPath) open
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
    84
52
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    85
    "
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    86
     FileBrowser openOn:'aDirectoryPath'
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    87
     FileBrowser openOn:'/etc'
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    88
     FileBrowser openOn:'..'
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    89
     FileBrowser openOn:'.'
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
    90
    "
93
claus
parents: 85
diff changeset
    91
!
claus
parents: 85
diff changeset
    92
claus
parents: 85
diff changeset
    93
openOnFileNamed:aFilename
claus
parents: 85
diff changeset
    94
    "start a new FileBrowser on a file"
claus
parents: 85
diff changeset
    95
claus
parents: 85
diff changeset
    96
    |f browser|
claus
parents: 85
diff changeset
    97
claus
parents: 85
diff changeset
    98
    f := aFilename asFilename.
claus
parents: 85
diff changeset
    99
    browser := self new.
claus
parents: 85
diff changeset
   100
    browser currentDirectory:f directoryName.
claus
parents: 85
diff changeset
   101
    browser showFile:f baseName.
claus
parents: 85
diff changeset
   102
    ^ browser open
claus
parents: 85
diff changeset
   103
claus
parents: 85
diff changeset
   104
    "
claus
parents: 85
diff changeset
   105
     FileBrowser openOnFileNamed:'Makefile'
claus
parents: 85
diff changeset
   106
     FileBrowser openOnFileNamed:'../Makefile'
claus
parents: 85
diff changeset
   107
     FileBrowser openOnFileNamed:'/tmp/foo'
claus
parents: 85
diff changeset
   108
    "
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   109
! !
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   110
73
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   111
!FileBrowser class methodsFor:'defaults'!
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   112
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   113
defaultIcon
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   114
    DefaultIcon isNil ifTrue:[
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   115
	DefaultIcon := Form 
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   116
			fromFile:(ClassResources at:'ICON_FILE' 
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   117
					    default:'FBrowser.xbm')
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   118
			resolution:100.
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   119
    ].
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   120
    ^ DefaultIcon
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   121
! !
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   122
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   123
!FileBrowser methodsFor:'events'!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   124
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   125
mapped 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   126
    super mapped.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   127
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   128
     whant to know about changed history
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   129
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   130
    self updateCurrentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   131
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   132
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   133
visibilityChange:how
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   134
    |wasVisible|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   135
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   136
    wasVisible := shown.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   137
    super visibilityChange:how.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   138
    (wasVisible not and:[shown]) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   139
	"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   140
	 start checking again
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   141
	"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   142
	Processor removeTimedBlock:checkBlock.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   143
	Processor addTimedBlock:checkBlock afterSeconds:checkDelta.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   144
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   145
! !
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   146
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   147
!FileBrowser methodsFor:'fileList user interaction'!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   148
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   149
changeDisplayMode
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   150
    "toggle from long to short listing (and vice-versa)"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   151
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   152
    showLongList := showLongList not.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   153
    self updateCurrentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   154
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   155
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   156
changeDotFileVisibility
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   157
    "turn on/off visibility of files whose name starts with '.'"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   158
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   159
    showDotFiles := showDotFiles not.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   160
    self updateCurrentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   161
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   162
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   163
fileEncoding
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   164
    "open a dialog to allow change of the files character encoding.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   165
     Files are converted to internal encoding when read, and converted back
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   166
     to this encoding when saved.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   167
     The default encoding is nil, which means that files are already in
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   168
     the internal encoding (which is iso8859).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   169
     Notice: currently, not too many encodings are supported by the system."
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   170
495
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   171
    |dialog list descr encodings encodingNames idx|
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   172
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   173
    list := SelectionInList new.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   174
495
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   175
"/    encodings := #(nil msdos mac jis7 euc gb big5).
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   176
"/    encodingNames := #('default (iso8859, ANSI)' 'MSDOS' 'MAC' 'JIS7' 'EUC' 'GB' 'BIG5').
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   177
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   178
    descr := CharacterArray supportedExternalEncodings.
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   179
    encodings := descr at:2.
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   180
    encodingNames := descr at:1.
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   181
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   182
    list list:encodingNames.
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   183
    list selectionIndex:(encodings indexOf:fileEncoding ifAbsent:1).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   184
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   185
    dialog := Dialog new.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   186
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   187
    dialog addTextLabel:(resources string:'ENCODING_MSG') withCRs.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   188
    dialog addVerticalSpace.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   189
    dialog addListBoxOn:list withNumberOfLines:5.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   190
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   191
    dialog addAbortButton; addOkButton.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   192
    dialog open.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   193
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   194
    dialog accepted ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   195
        idx := list selectionIndex.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   196
        fileEncoding := encodings at:idx.
482
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
   197
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
   198
        self validateFontEncodingFor:fileEncoding.
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   199
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   200
495
6d6a6b8feb2b ask characterArray for encodings
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   201
    "Modified: 22.4.1996 / 14:46:24 / cg"
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   202
!
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   203
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   204
fileExecute
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   205
    "if text was modified show a queryBox,
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   206
     otherwise pop up execute box immediately"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   207
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   208
    |action|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   209
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   210
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   211
     this replaces everything by the commands output ...
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   212
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   213
    action := [:command| self doExecuteCommand:command replace:true].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   214
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   215
    (self askIfModified:'contents has not been saved.\\Modifications will be lost when command is executed.'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   216
	      yesButton:'execute') ifFalse:[^ self].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   217
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   218
"/    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   219
"/     this inserts the commands output ...
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   220
"/    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   221
"/    action := [:command| self doExecuteCommand:command replace:false].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   222
"/
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   223
    self askForCommandThenDo:action
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   224
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   225
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   226
fileFileIn
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   227
    "fileIn the selected file(s)"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   228
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   229
    self fileFileInLazy:false 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   230
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   231
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   232
fileFileInLazy
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   233
    "fileIn the selected file(s). Do a quick load (no compilation)"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   234
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   235
    self fileFileInLazy:true 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   236
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   237
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   238
fileFileInLazy:lazy
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   239
    "fileIn the selected file(s)"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   240
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   241
    |aStream here oldPath wasLazy bos|
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   242
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   243
    self selectedFilesDo:[:fileName |
487
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   244
        ((currentDirectory typeOf:fileName) == #regular) ifTrue:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   245
            here := currentDirectory pathName.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   246
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   247
            ((fileName endsWith:'.o') 
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   248
            or:[(fileName endsWith:'.so')
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   249
            or:[fileName endsWith:'.obj']]) ifTrue:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   250
                Object abortSignal catch:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   251
                    |p|
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   252
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   253
                    p := (here , '/' ,fileName).
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   254
                    "/
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   255
                    "/ look if already loaded ...  then unload first
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   256
                    "/
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   257
                    (ObjectFileLoader loadedObjectFiles includes:p) ifTrue:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   258
                        (Dialog confirm:(resources 
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   259
                                            string:'%1 is already loaded; load anyway ?'
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   260
                                            with:p)) ifFalse:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   261
                            ^ self
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   262
                        ].
551
9c94cf577a45 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 540
diff changeset
   263
                        Transcript showCR:'unloading old ' , p , ' ...'.
487
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   264
                        ObjectFileLoader unloadObjectFile:p. 
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   265
                    ].
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   266
551
9c94cf577a45 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 540
diff changeset
   267
                    Transcript showCR:'loading ' , p , ' ...'.
487
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   268
                    ObjectFileLoader loadObjectFile:p.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   269
                    Class addInfoRecord:('fileIn ' , fileName) 
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   270
                ]
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   271
            ] ifFalse:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   272
                (fileName endsWith:'.cls') ifTrue:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   273
                    aStream := FileStream readonlyFileNamed:fileName in:currentDirectory.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   274
                    aStream notNil ifTrue:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   275
                        bos := BinaryObjectStorage onOld:aStream.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   276
                        bos next.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   277
                        bos close
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   278
                    ]
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   279
                ] ifFalse:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   280
                    (fileName endsWith:'.class') ifTrue:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   281
                        JavaClassReader notNil ifTrue:[
525
7bc030853c31 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   282
                            JavaClassReader loadFile:(currentDirectory pathName , '/' , fileName)
487
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   283
                        ]
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   284
                    ] ifFalse:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   285
                        aStream := FileStream readonlyFileNamed:fileName in:currentDirectory.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   286
                        aStream notNil ifTrue:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   287
                            [
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   288
                                Class withoutUpdatingChangesDo:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   289
                                    oldPath := Smalltalk systemPath.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   290
                                    Smalltalk systemPath:(oldPath copy addFirst:here; yourself).
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   291
                                    wasLazy := Compiler compileLazy:lazy.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   292
                                    aStream fileIn.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   293
                                ].
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   294
                                Class addInfoRecord:('fileIn ' , fileName) 
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   295
                            ] valueNowOrOnUnwindDo:[
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   296
                                Compiler compileLazy:wasLazy.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   297
                                Smalltalk systemPath:oldPath.
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   298
                                aStream close
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   299
                            ]
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   300
                        ]
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   301
                    ]
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   302
                ]
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   303
            ]
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   304
        ]
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   305
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   306
551
9c94cf577a45 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 540
diff changeset
   307
    "Modified: 18.5.1996 / 15:45:31 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   308
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   309
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   310
fileGet
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   311
    "get contents of selected file into subView.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   312
     If text was modified show a queryBox,
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   313
     otherwise get it immediately"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   314
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   315
    |fileName msg label|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   316
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   317
    (subView modified not or:[subView contentsWasSaved]) ifTrue:[^ self doFileGet].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   318
    fileName := self getSelectedFileName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   319
    fileName notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   320
	(currentDirectory isDirectory:fileName) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   321
	    msg := 'contents has not been saved.\\Modifications will be lost when directory is changed.'.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   322
	    label := 'change'.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   323
	] ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   324
	    msg := 'contents has not been saved.\\Modifications will be lost when new file is read.'.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   325
	    label := 'get'.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   326
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   327
	(self ask:(resources at:msg) yesButton:label) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   328
	    self doFileGet
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   329
	]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   330
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   331
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   332
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   333
fileGetInfo
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   334
    "show short file (stat)-info"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   335
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   336
    self fileGetInfo:false
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   337
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   338
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   339
fileGetInfo:longInfo
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   340
    "get info on selected file - show it in a box"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   341
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   342
    |string|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   343
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   344
    string := self getFileInfoString:longInfo.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   345
    string notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   346
	self information:string
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   347
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   348
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   349
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   350
fileGetLongInfo
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   351
    "show long stat (file)-info"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   352
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   353
    self fileGetInfo:true
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   354
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   355
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   356
fileInsert
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   357
    "insert contents of file at cursor"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   358
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   359
    |fileName|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   360
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   361
    fileName := self getSelectedFileName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   362
    fileName notNil ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   363
        self showFile:fileName insert:true encoding:fileEncoding
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   364
    ]
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   365
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   366
    "Modified: 22.2.1996 / 14:47:16 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   367
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   368
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   369
fileListMenu
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   370
    "return the menu to show in the fileList"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   371
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   372
    |labels selectors m sel|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   373
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   374
    labels := #(
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   375
                 'spawn'                   
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   376
                 '-'                               
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   377
                 'get contents'                    
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   378
                 'insert contents'                    
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   379
                 'show info'             
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   380
                 'show full info'          
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   381
                 'fileIn'                 
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   382
                 'quick fileIn (lazy)'                 
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   383
                 '-'                               
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   384
                 'update'                 
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   385
                 '-'                               
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   386
                 'execute unix command ...'                
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   387
                 'st/x tools'                
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   388
                 '-'                               
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   389
                 'remove'                 
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   390
                 'rename ...'                 
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   391
                 '-'                               
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   392
                 'display long list'           
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   393
                 'show all files'           
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   394
                 'encoding ...'           
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   395
                 '-'                               
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   396
                 'create directory ...'         
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   397
                 'create file ...'
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   398
               ).             
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   399
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   400
    selectors := #(
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   401
                 fileSpawn
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   402
                 nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   403
                 fileGet
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   404
                 fileInsert
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   405
                 fileGetInfo
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   406
                 fileGetLongInfo
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   407
                 fileFileIn
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   408
                 fileFileInLazy
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   409
                 nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   410
                 updateCurrentDirectory
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   411
                 nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   412
                 fileExecute
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   413
                 stxTools
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   414
                 nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   415
                 fileRemove
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   416
                 fileRename
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   417
                 nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   418
                 changeDisplayMode
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   419
                 changeDotFileVisibility
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   420
                 fileEncoding
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   421
                 nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   422
                 newDirectory
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   423
                 newFile
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   424
                ).
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   425
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   426
    m := PopUpMenu 
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   427
            labels:(resources array:labels)
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   428
            selectors:selectors
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   429
            receiver:self.
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   430
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   431
    showDotFiles ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   432
        m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files')
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   433
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   434
    showLongList ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   435
        m labelAt:#changeDisplayMode put:(resources string:'display short list')
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   436
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   437
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   438
    m subMenuAt:#stxTools 
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   439
            put:(PopUpMenu
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   440
                    labels:(resources array:
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   441
                           #(
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   442
                              'Changes browser'
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   443
                              'Editor'
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   444
                              'HTML reader'
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   445
                              'Image inspect'
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   446
                              'show file differences'
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   447
                            ))
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   448
                    selectors:#(
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   449
                              openChangesBrowser
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   450
                              openEditor
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   451
                              openHTMLReader
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   452
                              openImageInspector
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   453
                              openDiffView
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   454
                              )
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   455
                    receiver:self).
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   456
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   457
    ((sel := fileListView selection) isNil or:[sel isEmpty]) ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   458
        m disableAll:#(fileGet fileInsert
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   459
                       fileGetInfo fileGetLongInfo
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   460
                       fileFileIn fileFileInLazy
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   461
                       fileRemove fileRename).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   462
        (m subMenuAt:#stxTools)
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   463
            disableAll:#(openChangesBrowser openEditor openHTMLReader openImageInspector)
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   464
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   465
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   466
    ^m
252
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   467
487
e96fd6389b15 Java class loading
Claus Gittinger <cg@exept.de>
parents: 482
diff changeset
   468
    "Modified: 18.4.1996 / 19:18:38 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   469
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   470
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   471
filePrint
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   472
    |fileName inStream printStream line|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   473
294
a693bd6d7ae6 read cursor while reading
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   474
    self withWaitCursorDo:[
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   475
	fileName := self getSelectedFileName.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   476
	fileName notNil ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   477
	    ((currentDirectory typeOf:fileName) == #regular) ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   478
		inStream := FileStream readonlyFileNamed:fileName
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   479
						      in:currentDirectory.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   480
		inStream isNil ifFalse:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   481
		    printStream := PrinterStream new.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   482
		    printStream notNil ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   483
			[inStream atEnd] whileFalse:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   484
			    line := inStream nextLine.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   485
			    printStream nextPutAll:line.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   486
			    printStream cr
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   487
			].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   488
			printStream close
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   489
		    ].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   490
		    inStream close
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   491
		]
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   492
	    ]
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   493
	].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
   494
	0 "compiler hint"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   495
    ]
294
a693bd6d7ae6 read cursor while reading
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   496
a693bd6d7ae6 read cursor while reading
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
   497
    "Modified: 14.12.1995 / 20:59:24 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   498
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   499
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   500
fileRemove
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   501
    "remove the selected file(s).
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   502
     Query if user really wants to remove the file.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   503
     - should be enhanced, to look for a ~/.trash directory 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   504
     and move files there if it exists (without asking in this case)."
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   505
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   506
    |sel q|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   507
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   508
    sel := fileListView selection.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   509
    sel notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   510
	sel size > 1 ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   511
	    q := resources string:'remove selected files ?'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   512
	] ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   513
	    q := resources string:'remove ''%1'' ?' with:(fileList at:sel first)
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   514
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   515
	(self ask:q yesButton:'remove') ifTrue:[self doRemove]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   516
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   517
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   518
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   519
fileRename
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   520
    "rename the selected file(s)"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   521
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   522
    |queryBox|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   523
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   524
    queryBox := FilenameEnterBox new.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   525
    queryBox okText:(resources at:'rename').
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   526
    self selectedFilesDo:[:oldName |
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   527
	queryBox title:(resources string:'rename ''%1'' to:' with:oldName).
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   528
	queryBox initialText:oldName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   529
	queryBox action:[:newName | self doRename:oldName to:newName].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   530
	queryBox showAtPointer
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   531
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   532
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   533
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   534
fileSelect:lineNr
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   535
    "selected a file - do nothing here"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   536
    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   537
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   538
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   539
fileSpawn
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   540
    "start another FileBrowser on the selected directory or
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   541
     on the same directory if none is selected."
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   542
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   543
    |any|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   544
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   545
    any := false.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   546
    self selectedFilesDo:[:fileName |
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   547
	(currentDirectory isDirectory:fileName) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   548
	    self class openOn:(currentDirectory pathName , '/' , fileName).
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   549
	    any := true
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   550
	]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   551
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   552
    any ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   553
	self class openOn:currentDirectory pathName
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   554
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   555
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   556
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   557
newDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   558
    "ask for and create a new directory"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   559
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   560
    |queryBox|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   561
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   562
    queryBox := FilenameEnterBox 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   563
		    title:(resources at:'create new directory:') withCRs
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   564
		    okText:(resources at:'create')
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   565
		    action:[:newName | self doCreateDirectory:newName].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   566
"/    queryBox initialText:''.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   567
    queryBox showAtPointer
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   568
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   569
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   570
newFile
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   571
    "ask for and create a new file"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   572
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   573
    |sel queryBox|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   574
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   575
    queryBox := FilenameEnterBox 
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   576
                    title:(resources at:'create new file:') withCRs
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   577
                    okText:(resources at:'create')
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   578
                    action:[:newName | self doCreateFile:newName].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   579
    sel := subView selection.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   580
    sel notNil ifTrue:[
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   581
        queryBox initialText:(sel asString)
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   582
"/    ] ifFalse:[
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   583
"/        queryBox initialText:''
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   584
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   585
    queryBox showAtPointer
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   586
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   587
    "Modified: 21.2.1996 / 01:43:14 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   588
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   589
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   590
openChangesBrowser
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   591
    "open a change browser on the selected file(s)"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   592
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   593
    self openTool:ChangesBrowser
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   594
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   595
252
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   596
openDiffView
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   597
    "open a diff-view"
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   598
488
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   599
    |box name1 name2 text1 text2 d err nm here l1|
252
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   600
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   601
    name1 := '' asValue.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   602
    name2 := self getSelectedFileName asValue.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   603
    here := currentDirectory pathName.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   604
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   605
    box := DialogBox new.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   606
    box addTextLabel:'show difference between:'.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   607
    box addFilenameInputFieldOn:name1 in:here tabable:true.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   608
    box addTextLabel:'and:'.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   609
    box addFilenameInputFieldOn:name2 in:here tabable:true.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   610
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   611
    box addAbortButton; addOkButton.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   612
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   613
    box showAtPointer.
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   614
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   615
    box accepted ifTrue:[
488
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   616
        name1 := name1 value.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   617
        name1 isEmpty ifTrue:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   618
            text1 := subView contents.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   619
            name1 := nil.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   620
            l1 := 'browser contents'
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   621
        ] ifFalse:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   622
            (name1 := name1 value asFilename) isAbsolute ifFalse:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   623
                name1 := here asFilename construct:name1
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   624
            ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   625
            name1 isReadable ifFalse:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   626
                nm := name1.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   627
                name1 exists ifFalse:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   628
                    err := '%1 does not exist'.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   629
                ] ifTrue:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   630
                    err := '%1 is not readable'
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   631
                ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   632
            ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   633
            l1 := name1 pathName
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   634
        ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   635
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   636
        (name2 := name2 value asFilename) isAbsolute ifFalse:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   637
            name2 := here asFilename construct:name2
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   638
        ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   639
        err isNil ifTrue:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   640
            name2 isReadable ifFalse:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   641
                nm := name2.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   642
                name2 exists ifFalse:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   643
                    err := '%1 does not exist'.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   644
                ] ifTrue:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   645
                    err := '%1 is not readable'
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   646
                ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   647
            ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   648
        ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   649
        err notNil ifTrue:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   650
            self warn:(resources string:err with:nm pathName).
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   651
            ^ self
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   652
        ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   653
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   654
        self withWaitCursorDo:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   655
            name1 notNil ifTrue:[
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   656
                text1 := name1 contentsOfEntireFile.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   657
            ].
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   658
            text2 := name2 contentsOfEntireFile.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   659
            d := DiffTextView 
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   660
                    openOn:text1 label:l1
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   661
                    and:text2 label:name2 pathName.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   662
            d label:'file differences'.
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   663
        ]
252
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   664
    ].
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   665
5b9377d69ab2 added file-Diff function
Claus Gittinger <cg@exept.de>
parents: 235
diff changeset
   666
    "Created: 7.12.1995 / 20:33:58 / cg"
488
26f8da377672 allow diff of browsers text with file
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   667
    "Modified: 19.4.1996 / 15:51:03 / cg"
267
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   668
!
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   669
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   670
openEditor
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   671
    self openTool:EditTextView
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   672
!
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   673
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   674
openHTMLReader
556
1549bab879c7 use new documentView
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   675
    self openTool:HTMLDocumentView
1549bab879c7 use new documentView
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   676
1549bab879c7 use new documentView
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   677
    "Modified: 20.5.1996 / 20:30:58 / cg"
267
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   678
!
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   679
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   680
openImageInspector
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   681
    |img|
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   682
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   683
    self selectedFilesDo:[:fileName |
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   684
	(currentDirectory isDirectory:fileName) ifFalse:[
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   685
	    img := Image fromFile:(currentDirectory pathName , '/' , fileName).
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   686
	    img notNil ifTrue:[
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   687
		img inspect
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   688
	    ] ifFalse:[
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   689
		self warn:'unknown format: ' , fileName
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   690
	    ]
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   691
	]
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   692
    ].
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   693
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   694
    "Modified: 17.9.1995 / 17:41:24 / claus"
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   695
!
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   696
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   697
openTool:aToolClass
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   698
    "open a tool on the selected file(s)"
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   699
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   700
    self selectedFilesDo:[:fileName |
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   701
	(currentDirectory isDirectory:fileName) ifFalse:[
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   702
	    aToolClass openOn:(currentDirectory pathName , '/' , fileName).
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   703
	]
03885fd03d97 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 258
diff changeset
   704
    ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   705
! !
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   706
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   707
!FileBrowser methodsFor:'help '!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   708
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   709
helpTextFor:aComponent
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   710
    |s|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   711
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   712
    aComponent == subView ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   713
	s := 'HELP_SUBVIEW'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   714
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   715
    aComponent == fileListView ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   716
	s := 'HELP_FILELIST'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   717
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   718
    aComponent == filterField ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   719
	s := 'HELP_FILTER'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   720
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   721
    aComponent == labelView ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   722
	s := 'HELP_PATHFIELD'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   723
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   724
    aComponent == commandView ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   725
	s := 'HELP_COMMANDVIEW'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   726
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   727
    s notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   728
	^ resources string:s
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   729
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   730
    ^ nil
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   731
! !
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   732
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   733
!FileBrowser methodsFor:'initialization'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   734
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   735
currentDirectory:aDirectoryPath
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   736
    "set the directory to be browsed"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   737
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   738
    currentDirectory := FileDirectory directoryNamed:aDirectoryPath.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   739
    self changed:#path.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   740
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   741
     tell my subview (whatever that is) to start its file-dialog
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   742
     (i.e. save-as etc.) in that directory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   743
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   744
    (subView respondsTo:#directoryForFileDialog:) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   745
	subView directoryForFileDialog:currentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   746
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   747
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   748
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   749
focusSequence
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   750
    "return the sequence in which ALT-CursorRight steps focus"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   751
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   752
    |fs|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   753
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   754
    fs := Array 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   755
	with:filterField 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   756
	with:fileListView 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   757
	with:subView.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   758
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   759
    commandView notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   760
	fs := fs copyWith:commandView
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   761
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   762
    ^fs
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   763
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   764
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   765
initEvents
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   766
    super initEvents.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   767
    self enableEvent:#visibilityChange.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   768
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   769
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   770
initialize
344
3f881dbee13a use a model for the filter field
Claus Gittinger <cg@exept.de>
parents: 333
diff changeset
   771
    |frame spacing halfSpacing v topFrame labelFrame filterModel|
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   772
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   773
    super initialize.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   774
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   775
    fileEncoding := nil.        "/ native ST/X encoding
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   776
52
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   777
    "if true, will replace leading spaces by tabs on
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   778
     file write. If false, they will be written as spaces
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   779
    "
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   780
    compressTabs := resources at:'COMPRESS_TABS' default:true.
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   781
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   782
    "
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   783
     showing long or short by default
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   784
    "
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   785
    showLongList := resources at:'LONG_LIST' default:false.
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   786
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   787
    "
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   788
     show type of contents (somwehat slow) or not ?
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   789
    "
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   790
    showVeryLongList := resources at:'VERYLONG_LIST' default:true.
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   791
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   792
    "
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   793
     show hidden files or not ?
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   794
    "
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   795
    showDotFiles := resources at:'SHOW_DOT_FILES' default:false.
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   796
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   797
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
   798
    lockUpdate := false.
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
   799
132
claus
parents: 126
diff changeset
   800
    CommandHistory isNil ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   801
        CommandHistory := OrderedCollection new.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   802
        CommandHistorySize := 50
132
claus
parents: 126
diff changeset
   803
    ].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   804
    DirectoryHistory isNil ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   805
        DirectoryHistory := OrderedCollection new.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   806
        DirectoryHistoryWhere := OrderedCollection new.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   807
        HistorySize := 15.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   808
    ].
132
claus
parents: 126
diff changeset
   809
    commandIndex := 0.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   810
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   811
    myName := (resources string:self class name).
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   812
    self label:myName.
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
   813
93
claus
parents: 85
diff changeset
   814
    labelFrame := View 
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   815
                        origin:(0.0 @ 0.0)
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   816
                        corner:(1.0 @ (font height * 2))
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   817
                        in:self.
52
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
   818
105
claus
parents: 100
diff changeset
   819
    styleSheet name = #st80 ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   820
        labelFrame level:1
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
   821
    ].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   822
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   823
    spacing := ViewSpacing.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   824
    halfSpacing := spacing // 2.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   825
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   826
    checkBlock := [self checkIfDirectoryHasChanged].
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
   827
    checkDelta := resources at:'CHECK_DELTA' default:10.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   828
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   829
    currentDirectory := FileDirectory directoryNamed:'.'.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   830
344
3f881dbee13a use a model for the filter field
Claus Gittinger <cg@exept.de>
parents: 333
diff changeset
   831
    filterModel := '*' asValue.
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
   832
    filterField := EditField in:labelFrame.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   833
    filterField origin:[((width // 4 * 3) + halfSpacing) @ halfSpacing]
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   834
                corner:(1.0 @ filterField heightIncludingBorder).
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
   835
    filterField rightInset:ViewSpacing-halfSpacing.
344
3f881dbee13a use a model for the filter field
Claus Gittinger <cg@exept.de>
parents: 333
diff changeset
   836
    filterField model:filterModel.
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
   837
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   838
    self initializeFilterPattern.
344
3f881dbee13a use a model for the filter field
Claus Gittinger <cg@exept.de>
parents: 333
diff changeset
   839
    filterModel onChangeSend:#filterPatternChanged to:self.
3f881dbee13a use a model for the filter field
Claus Gittinger <cg@exept.de>
parents: 333
diff changeset
   840
"/    filterField leaveAction:[:key | fileListView scrollToTop. self updateCurrentDirectory].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   841
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
   842
    labelView := Label in:labelFrame.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   843
    labelView origin:(halfSpacing @ halfSpacing)
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   844
              extent:[((width // 4 * 3) - spacing - borderWidth)
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   845
                       @
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   846
                       (filterField heightIncludingBorder)
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   847
                       "(font height + font descent)"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   848
                     ].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   849
    labelView adjust:#right.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   850
    labelView borderWidth:0.
93
claus
parents: 85
diff changeset
   851
    labelView model:self; menu:#labelMenu; aspect:#path; labelMessage:#path.
73
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
   852
    labelFrame model:self; menu:#labelMenu.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   853
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   854
    killButton := Button label:(resources string:'kill') in:self.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   855
    killButton origin:(halfSpacing @ halfSpacing)
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   856
               extent:(killButton width @ filterField height).
331
a12998c7f3c2 use beVisible / beInvisible
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
   857
    killButton beInvisible.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   858
132
claus
parents: 126
diff changeset
   859
    self initializeCommandViewIn:self.
claus
parents: 126
diff changeset
   860
claus
parents: 126
diff changeset
   861
"/    frame := VariableVerticalPanel
claus
parents: 126
diff changeset
   862
"/                 origin:[frame borderWidth negated 
claus
parents: 126
diff changeset
   863
"/                         @ 
claus
parents: 126
diff changeset
   864
"/                         labelFrame height
claus
parents: 126
diff changeset
   865
"/                         "/ (labelView height + labelView origin y + spacing)
claus
parents: 126
diff changeset
   866
"/                        ]
claus
parents: 126
diff changeset
   867
"/                 corner:(1.0 @ 1.0)
claus
parents: 126
diff changeset
   868
"/                     in:self.
claus
parents: 126
diff changeset
   869
claus
parents: 126
diff changeset
   870
    frame := VariableVerticalPanel origin:0.0@0.0 corner:1.0@1.0 in:self.
claus
parents: 126
diff changeset
   871
    frame topInset:labelFrame height.
claus
parents: 126
diff changeset
   872
    commandView notNil ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   873
        frame bottomInset:(commandView height + spacing + spacing)
132
claus
parents: 126
diff changeset
   874
    ].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   875
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   876
    topFrame := ScrollableView for:SelectionInListView in:frame.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   877
    topFrame origin:(0.0 @ 0.0) corner:(1.0 @ 0.3).
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   878
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   879
    fileListView := topFrame scrolledView.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   880
    fileListView action:[:lineNr | self fileSelect:lineNr].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   881
    fileListView doubleClickAction:[:lineNr | self fileSelect:lineNr.
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   882
                                              self fileGet].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   883
    fileListView multipleSelectOk:true.
98
claus
parents: 93
diff changeset
   884
    fileListView menuHolder:self; menuPerformer:self; menuMessage:#fileListMenu.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   885
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   886
    v := self initializeSubViewIn:frame.
132
claus
parents: 126
diff changeset
   887
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   888
    v origin:(0.0 @ 0.3) corner:(1.0 @ 1.0).
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   889
    subView := v scrolledView.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   890
    (subView respondsTo:#directoryForFileDialog:) ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   891
        subView directoryForFileDialog:currentDirectory
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   892
    ].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   893
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   894
    ObjectMemory addDependent:self.
132
claus
parents: 126
diff changeset
   895
claus
parents: 126
diff changeset
   896
    "Modified: 6.9.1995 / 20:26:06 / claus"
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
   897
    "Modified: 22.2.1996 / 14:46:14 / cg"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   898
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
   899
132
claus
parents: 126
diff changeset
   900
initializeCommandViewIn:frame
claus
parents: 126
diff changeset
   901
    "set up the command view - can be redefined in subclasses as empty,
claus
parents: 126
diff changeset
   902
     if no commandView is wanted"
claus
parents: 126
diff changeset
   903
claus
parents: 126
diff changeset
   904
claus
parents: 126
diff changeset
   905
    commandView := EditField origin:0.0@1.0 corner:1.0@1.0 in:frame.
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   906
    commandView allInset:ViewSpacing.
132
claus
parents: 126
diff changeset
   907
    commandView topInset:(commandView preferredExtent y negated - ViewSpacing).
claus
parents: 126
diff changeset
   908
133
claus
parents: 132
diff changeset
   909
"/    commandView contents:'** no commands which require input here **'.
132
claus
parents: 126
diff changeset
   910
142
claus
parents: 139
diff changeset
   911
    commandView entryCompletionBlock:[:contents |
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   912
        |newString|
142
claus
parents: 139
diff changeset
   913
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   914
        newString := Filename 
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   915
                        filenameCompletionFor:contents 
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   916
                        directory:currentDirectory pathName asFilename 
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   917
                        directoriesOnly:false 
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   918
                        filesOnly:false 
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   919
                        ifMultiple:[:dir | commandView flash.].
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   920
        commandView contents:newString.
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   921
        commandView cursorToEndOfLine.
132
claus
parents: 126
diff changeset
   922
    ].
claus
parents: 126
diff changeset
   923
    commandView leaveAction:[:key | 
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   924
        |cmd nCmd empty|
132
claus
parents: 126
diff changeset
   925
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   926
        (key == #CursorDown 
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   927
        or:[key == #CursorUp]) ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   928
            nCmd := CommandHistory size.
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   929
            nCmd == 0 ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   930
                empty := true
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   931
            ] ifFalse:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   932
                key == #CursorUp ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   933
                    commandIndex == nCmd ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   934
                        commandView flash.
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   935
                    ].
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   936
                    commandIndex := (commandIndex + 1) min:nCmd
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   937
                ] ifFalse:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   938
                    commandIndex == 1 ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   939
                        commandView flash.
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   940
                        empty := true.
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   941
                    ].
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   942
                    commandIndex := (commandIndex - 1) max:1.
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   943
                ].
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   944
            ].
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   945
            empty == true ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   946
                commandView contents:nil
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   947
            ] ifFalse:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   948
                commandView contents:(CommandHistory at:commandIndex).
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   949
            ]        
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   950
        ].
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   951
        key == #Return ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   952
            cmd := commandView contents.
132
claus
parents: 126
diff changeset
   953
539
33b603dd30ba replaced ColoredListEntry by Text
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
   954
            subView insertLine:(
33b603dd30ba replaced ColoredListEntry by Text
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
   955
                                Text string:('>> ' , cmd)
540
4c3c76a1af92 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   956
                                     emphasis:(Array with:#bold with:#underline with:(#color->Color blue))
539
33b603dd30ba replaced ColoredListEntry by Text
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
   957
"/                                ColoredListEntry string:('>> ' , cmd) color:Color blue
33b603dd30ba replaced ColoredListEntry by Text
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
   958
                                )
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   959
                    before:(subView cursorLine).
539
33b603dd30ba replaced ColoredListEntry by Text
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
   960
            subView cursorDown:1.
133
claus
parents: 132
diff changeset
   961
claus
parents: 132
diff changeset
   962
"/            subView insertStringAtCursor:cmd.
claus
parents: 132
diff changeset
   963
"/            subView insertCharAtCursor:(Character cr).
132
claus
parents: 126
diff changeset
   964
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   965
            (cmd notNil and:[cmd notEmpty]) ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   966
                CommandHistory notNil ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   967
                    CommandHistory addFirst:cmd.
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   968
                    CommandHistory size > CommandHistorySize ifTrue:[
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   969
                        CommandHistory removeLast
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   970
                    ]
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   971
                ].
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   972
                self doExecuteCommand:cmd replace:false.
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   973
                commandView contents:nil.
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   974
                commandIndex := 0
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   975
            ]
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
   976
        ]
132
claus
parents: 126
diff changeset
   977
    ].
claus
parents: 126
diff changeset
   978
133
claus
parents: 132
diff changeset
   979
    "Modified: 7.9.1995 / 15:48:45 / claus"
540
4c3c76a1af92 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 539
diff changeset
   980
    "Modified: 12.5.1996 / 17:09:45 / cg"
132
claus
parents: 126
diff changeset
   981
!
claus
parents: 126
diff changeset
   982
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   983
initializeFilterPattern
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   984
    "set an initial matchpattern - can be redefined in subclasses"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   985
344
3f881dbee13a use a model for the filter field
Claus Gittinger <cg@exept.de>
parents: 333
diff changeset
   986
    filterField model value:'*'
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   987
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   988
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   989
initializeSubViewIn:frame
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   990
    "set up the contents view - can be redefined in subclasses for
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   991
     different view types (SoundFileBrowser/ImageBrowsers etc.)"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   992
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   993
    ^ HVScrollableView for:CodeView miniScrollerH:true miniScrollerV:false in:frame.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   994
! !
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   995
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   996
!FileBrowser methodsFor:'misc user interaction'!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   997
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   998
destroy
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
   999
    "destroy view and boxes"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1000
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1001
    ObjectMemory removeDependent:self.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1002
    Processor removeTimedBlock:checkBlock.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1003
    checkBlock := nil.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1004
    super destroy
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1005
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1006
346
9ee1f936b7ea *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
  1007
filterPatternChanged
9ee1f936b7ea *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
  1008
    fileListView scrollToTop. 
9ee1f936b7ea *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
  1009
    self updateCurrentDirectory
9ee1f936b7ea *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
  1010
!
9ee1f936b7ea *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 344
diff changeset
  1011
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1012
terminate
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1013
    "exit FileBrowser"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1014
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1015
    (self askIfModified:'contents has not been saved.\\Modifications will be lost when FileBrowser is closed.'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1016
	      yesButton:'close') ifTrue:[self destroy]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1017
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1018
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1019
update:what with:someArgument from:changedObject
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1020
    realized ifFalse:[^ self].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1021
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1022
    (what == #aboutToExit) ifTrue:[
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1023
        "system wants to shut down this
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1024
         - if text was modified, pop up, and ask user and save if requested."
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1025
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1026
        (subView modified and:[subView contentsWasSaved not]) ifTrue:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1027
            self raiseDeiconified.
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1028
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1029
            (self 
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1030
                ask:(resources at:'FileBrowser:\\contents has not been saved.\\Save before exiting ?')
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1031
                yesButton:'save'
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1032
                noButton:'don''t save')
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1033
            ifTrue:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1034
                subView acceptAction notNil ifTrue:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1035
                    subView accept
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1036
                ] ifFalse:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1037
                    subView save
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1038
                ]
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1039
            ]
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1040
        ].
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1041
        ^ self
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1042
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1043
    changedObject == tabSpec ifTrue:[
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1044
        fileListView redraw
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1045
    ].
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1046
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1047
    "Modified: 21.2.1996 / 01:17:53 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1048
! !
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1049
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1050
!FileBrowser methodsFor:'pathField user interaction'!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1051
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1052
changeCurrentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1053
    "if text was modified show a queryBox, 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1054
     otherwise change immediately to directory"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1055
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1056
    (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1057
	      yesButton:'change') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1058
	self queryForDirectoryToChange
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1059
    ]
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1060
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1061
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1062
changeDirectoryTo:aDirectoryName
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1063
    "sent from label menu to change back to a previous directory"
132
claus
parents: 126
diff changeset
  1064
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1065
    self doChangeCurrentDirectoryTo:aDirectoryName updateHistory:false
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1066
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1067
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1068
changeToHomeDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1069
    "if text was modified show a queryBox, 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1070
     otherwise change immediately to directory"
132
claus
parents: 126
diff changeset
  1071
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1072
    (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1073
	      yesButton:'change') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1074
	 self doChangeToHomeDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1075
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1076
!
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1077
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1078
changeToParentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1079
    "if text was modified show a queryBox, 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1080
     otherwise change immediately to directory"
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1081
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1082
    (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1083
	      yesButton:'change') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1084
	 self doChangeToParentDirectory
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1085
    ]
98
claus
parents: 93
diff changeset
  1086
!
claus
parents: 93
diff changeset
  1087
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1088
copyPath
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1089
    "copy current path into cut & paste buffer"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1090
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1091
    Smalltalk at:#CopyBuffer put:currentDirectory pathName
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1092
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1093
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1094
labelMenu
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1095
    |labels selectors args menu|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1096
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1097
    labels := #(
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1098
		   'copy path'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1099
		   '-'                               
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1100
		   'up'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1101
		   'back'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1102
		   'change to home-directory'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1103
		   'change directory ...'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1104
	       ).             
98
claus
parents: 93
diff changeset
  1105
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1106
    selectors := #(
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1107
		    copyPath
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1108
		    nil
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1109
		    changeToParentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1110
		    changeToPreviousDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1111
		    changeToHomeDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1112
		    changeCurrentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1113
		  ).
123
claus
parents: 120
diff changeset
  1114
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1115
    args := Array new:(labels size).
126
claus
parents: 123
diff changeset
  1116
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1117
    DirectoryHistory size > 0 ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1118
	labels := labels copyWith:'-'.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1119
	selectors := selectors copyWith:nil.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1120
	args := args copyWith:nil.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1121
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1122
	DirectoryHistory do:[:dirName |
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1123
	    labels := labels copyWith:dirName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1124
	    selectors := selectors copyWith:#changeDirectoryTo:.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1125
	    args := args copyWith:dirName
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1126
	]
123
claus
parents: 120
diff changeset
  1127
    ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1128
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1129
    menu := PopUpMenu 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1130
		labels:(resources array:labels)
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1131
		selectors:selectors
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1132
		args:args
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1133
		receiver:self.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1134
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1135
    previousDirectory isNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1136
	menu disable:#changeToPreviousDirectory.
132
claus
parents: 126
diff changeset
  1137
    ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1138
    ^menu.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1139
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1140
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1141
queryForDirectoryToChange
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1142
    "query for new directory"
123
claus
parents: 120
diff changeset
  1143
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1144
    |queryBox|
98
claus
parents: 93
diff changeset
  1145
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1146
    queryBox := FilenameEnterBox 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1147
		    title:(resources at:'change directory to:') withCRs
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1148
		    okText:(resources at:'change')
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1149
		    action:[:newName | self doChangeCurrentDirectoryTo:newName updateHistory:true].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1150
"/    queryBox initialText:''.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1151
    queryBox showAtPointer
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1152
! !
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1153
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1154
!FileBrowser methodsFor:'private'!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1155
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1156
ask:question yesButton:yesButtonText
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1157
    "common method to ask a yes/no question; return true or false"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1158
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1159
    ^ self ask:question yesButton:yesButtonText noButton:'cancel' 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1160
!
93
claus
parents: 85
diff changeset
  1161
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1162
ask:question yesButton:yesButtonText noButton:noButtonText
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1163
    "common method to ask a yes/no question"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1164
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1165
    ^ Dialog 
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1166
        confirm:question withCRs
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1167
        yesLabel:(resources at:yesButtonText)
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1168
        noLabel:(resources at:noButtonText)
37
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  1169
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1170
    "Modified: 21.2.1996 / 01:19:21 / cg"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1171
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1172
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1173
askForCommandThenDo:aBlock
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1174
    "setup and launch a querybox to ask for unix command.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1175
     Then evaluate aBlock passing the command-string as argument."
93
claus
parents: 85
diff changeset
  1176
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1177
    |fileName sel box|
93
claus
parents: 85
diff changeset
  1178
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1179
    box := FilenameEnterBox 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1180
		title:(resources at:'execute unix command:')
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1181
	       okText:(resources at:'execute')
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1182
	       action:aBlock.
79
d78f92a07d5d *** empty log message ***
claus
parents: 75
diff changeset
  1183
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1184
    sel := fileListView selection.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1185
    sel size == 1 ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1186
	fileName := fileList at:sel first
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1187
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1188
    fileName notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1189
	self initialCommandFor:fileName into:box.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1190
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1191
    box directory:currentDirectory pathName asFilename.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1192
    box showAtPointer
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1193
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1194
    "Modified: 7.9.1995 / 10:31:54 / claus"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1195
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1196
98
claus
parents: 93
diff changeset
  1197
askIfModified:question yesButton:yesButtonText
claus
parents: 93
diff changeset
  1198
    "tell user, that code has been modified - let her confirm"
claus
parents: 93
diff changeset
  1199
claus
parents: 93
diff changeset
  1200
    (subView modified not or:[subView contentsWasSaved]) ifTrue:[
claus
parents: 93
diff changeset
  1201
	^ true
claus
parents: 93
diff changeset
  1202
    ].
claus
parents: 93
diff changeset
  1203
    ^ self 
claus
parents: 93
diff changeset
  1204
	ask:(resources string:question)
claus
parents: 93
diff changeset
  1205
	yesButton:yesButtonText
claus
parents: 93
diff changeset
  1206
!
claus
parents: 93
diff changeset
  1207
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1208
binaryFileAction:aFilename
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1209
    "for some binary files, if double clicked, we can do some useful
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1210
     action ..."
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1211
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1212
    |isImage img|
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1213
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1214
    (currentDirectory pathName , '/' , aFilename) asFilename isExecutable ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1215
	(OperatingSystem executeCommand:'cd ',currentDirectory pathName, '; ',aFilename)
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1216
	ifTrue:[^true].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1217
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1218
    isImage := false.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1219
    (aFilename endsWith:'.gif') ifTrue:[isImage := true].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1220
    (aFilename endsWith:'.tiff') ifTrue:[isImage := true].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1221
    (aFilename endsWith:'.pnm') ifTrue:[isImage := true].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1222
    (aFilename endsWith:'.xbm') ifTrue:[isImage := true].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1223
    isImage ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1224
	img := Image fromFile:(currentDirectory pathName , '/' , aFilename).
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1225
	img notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1226
	    img inspect.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1227
	    ^ true
120
claus
parents: 118
diff changeset
  1228
	]
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1229
    ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1230
    ^ false
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1231
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1232
    "Created: 14.9.1995 / 10:23:10 / claus"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1233
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1234
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1235
changeToPreviousDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1236
    "if text was modified show a queryBox, 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1237
     otherwise change immediately to previous directory."
93
claus
parents: 85
diff changeset
  1238
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1239
    previousDirectory isNil ifTrue:[^ self].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1240
    (self askIfModified:'contents has not been saved.\\Modifications will be lost when directory is changed.'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1241
	      yesButton:'change') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1242
	self doChangeCurrentDirectoryTo:previousDirectory updateHistory:false 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1243
    ]
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1244
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1245
98
claus
parents: 93
diff changeset
  1246
checkIfDirectoryHasChanged
claus
parents: 93
diff changeset
  1247
    "every checkDelta secs, check if directoy has changed and update the list if so.
claus
parents: 93
diff changeset
  1248
     Also, we check if the file shown has been touched in the meanwhile (for example,
claus
parents: 93
diff changeset
  1249
     from another browser) and say 'outdated' in the label if so. 
claus
parents: 93
diff changeset
  1250
     This avoids confusion if the same file is being edited by two browsers. (or other editors).
claus
parents: 93
diff changeset
  1251
     If the text shown in the codeView has been edited, 'modified' is shown.
claus
parents: 93
diff changeset
  1252
    "
claus
parents: 93
diff changeset
  1253
claus
parents: 93
diff changeset
  1254
    |oldSelection nOld here newState msg newLabel|
claus
parents: 93
diff changeset
  1255
claus
parents: 93
diff changeset
  1256
    shown ifTrue:[
claus
parents: 93
diff changeset
  1257
	currentDirectory notNil ifTrue:[
claus
parents: 93
diff changeset
  1258
	    lockUpdate ifTrue:[
claus
parents: 93
diff changeset
  1259
		Processor removeTimedBlock:checkBlock.
claus
parents: 93
diff changeset
  1260
		Processor addTimedBlock:checkBlock afterSeconds:checkDelta.
claus
parents: 93
diff changeset
  1261
		^ self
claus
parents: 93
diff changeset
  1262
	    ].
claus
parents: 93
diff changeset
  1263
claus
parents: 93
diff changeset
  1264
	    subView modified ifTrue:[
claus
parents: 93
diff changeset
  1265
		newState := ' (modified)'
claus
parents: 93
diff changeset
  1266
	    ].
claus
parents: 93
diff changeset
  1267
claus
parents: 93
diff changeset
  1268
	    here := currentDirectory pathName.
claus
parents: 93
diff changeset
  1269
	    (OperatingSystem isReadable:here) ifTrue:[
claus
parents: 93
diff changeset
  1270
		Processor removeTimedBlock:checkBlock.
claus
parents: 93
diff changeset
  1271
claus
parents: 93
diff changeset
  1272
		(currentDirectory timeOfLastChange > timeOfLastCheck) ifTrue:[
claus
parents: 93
diff changeset
  1273
		    nOld := fileListView numberOfSelections.
claus
parents: 93
diff changeset
  1274
		    oldSelection := fileListView selectionValue.
claus
parents: 93
diff changeset
  1275
		    self updateCurrentDirectory.
claus
parents: 93
diff changeset
  1276
		    nOld ~~ 0 ifTrue:[
claus
parents: 93
diff changeset
  1277
			nOld > 1 ifTrue:[
claus
parents: 93
diff changeset
  1278
			    oldSelection do:[:element  |
claus
parents: 93
diff changeset
  1279
				fileListView addElementToSelection:element
claus
parents: 93
diff changeset
  1280
			    ]
claus
parents: 93
diff changeset
  1281
			] ifFalse:[
claus
parents: 93
diff changeset
  1282
			    fileListView selectElementWithoutScroll:oldSelection
claus
parents: 93
diff changeset
  1283
			]
claus
parents: 93
diff changeset
  1284
		    ].
claus
parents: 93
diff changeset
  1285
		] ifFalse:[
claus
parents: 93
diff changeset
  1286
		    Processor addTimedBlock:checkBlock afterSeconds:checkDelta
claus
parents: 93
diff changeset
  1287
		].
claus
parents: 93
diff changeset
  1288
claus
parents: 93
diff changeset
  1289
		currentFileName notNil ifTrue:[
claus
parents: 93
diff changeset
  1290
		    (currentDirectory exists:currentFileName) ifFalse:[
claus
parents: 93
diff changeset
  1291
			newState := ' (removed)'.
claus
parents: 93
diff changeset
  1292
		    ] ifTrue:[
claus
parents: 93
diff changeset
  1293
			(currentDirectory timeOfLastChange:currentFileName) > timeOfFileRead ifTrue:[
claus
parents: 93
diff changeset
  1294
			    newState := ' (outdated)'.
claus
parents: 93
diff changeset
  1295
			    subView modified ifTrue:[
claus
parents: 93
diff changeset
  1296
				newState := ' (modified & outdated)'
claus
parents: 93
diff changeset
  1297
			    ]
claus
parents: 93
diff changeset
  1298
			].
claus
parents: 93
diff changeset
  1299
		    ].
claus
parents: 93
diff changeset
  1300
		].
claus
parents: 93
diff changeset
  1301
claus
parents: 93
diff changeset
  1302
	    ] ifFalse:[         
claus
parents: 93
diff changeset
  1303
		"
claus
parents: 93
diff changeset
  1304
		 if the directory has been deleted, or is not readable ...
claus
parents: 93
diff changeset
  1305
		"
claus
parents: 93
diff changeset
  1306
		(OperatingSystem isValidPath:here) ifFalse:[
claus
parents: 93
diff changeset
  1307
		    msg := 'FileBrowser:\\directory %1 is gone ?!!?'
claus
parents: 93
diff changeset
  1308
		] ifTrue:[
claus
parents: 93
diff changeset
  1309
		    msg := 'FileBrowser:\\directory %1 is no longer readable ?!!?'
claus
parents: 93
diff changeset
  1310
		].
claus
parents: 93
diff changeset
  1311
		self warn:(resources string:msg with:here) withCRs.
claus
parents: 93
diff changeset
  1312
claus
parents: 93
diff changeset
  1313
		fileListView contents:nil.
claus
parents: 93
diff changeset
  1314
		newLabel := myName , ': directory is gone !!'.
claus
parents: 93
diff changeset
  1315
		"/ Processor addTimedBlock:checkBlock afterSeconds:checkDelta
claus
parents: 93
diff changeset
  1316
	    ].
claus
parents: 93
diff changeset
  1317
claus
parents: 93
diff changeset
  1318
	    newState notNil ifTrue:[
claus
parents: 93
diff changeset
  1319
		newLabel := myName.
claus
parents: 93
diff changeset
  1320
		currentFileName notNil ifTrue:[
claus
parents: 93
diff changeset
  1321
		    newLabel := newLabel , ': ' , currentFileName
claus
parents: 93
diff changeset
  1322
		].
claus
parents: 93
diff changeset
  1323
		newLabel := newLabel , newState.
claus
parents: 93
diff changeset
  1324
	    ].
claus
parents: 93
diff changeset
  1325
	    newLabel notNil ifTrue:[
claus
parents: 93
diff changeset
  1326
		self label:newLabel.
claus
parents: 93
diff changeset
  1327
	    ]
claus
parents: 93
diff changeset
  1328
	]
claus
parents: 93
diff changeset
  1329
    ]
claus
parents: 93
diff changeset
  1330
!
claus
parents: 93
diff changeset
  1331
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1332
defineTabulatorsForLongList
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1333
    "define the tabs for the long list"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1334
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1335
    tabSpec := TabulatorSpecification new.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1336
    tabSpec unit:#inch.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1337
"/  tabSpec positions:#(0     2     2.3   4.3    5.3    6.0      6.5).
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1338
    tabSpec widths:   #(2     0.3   1.7     1      0.5  0.5      1"any").
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1339
    "                   name  type  mode  owner  group  size     type"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1340
    tabSpec align:    #(#left #left #left #right #right #decimal #left).
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1341
    tabSpec addDependent:self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1342
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1343
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1344
doChangeCurrentDirectoryTo:fileName updateHistory:updateHistory 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1345
    "verify argument is name of a readable & executable directory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1346
     and if so, go there"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1347
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1348
    |msg path idx|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1349
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1350
    self label:myName; iconLabel:myName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1351
    fileName notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1352
	(currentDirectory isDirectory:fileName) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1353
	    (currentDirectory isReadable:fileName) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1354
		(currentDirectory isExecutable:fileName) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1355
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1356
		    path := currentDirectory pathName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1357
		    previousDirectory := path.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1358
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1359
		    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1360
		     remember where we are in the fileList
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1361
		     (in case we want to return)
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1362
		    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1363
		    idx := DirectoryHistory indexOf:path.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1364
		    idx ~~ 0 ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1365
			DirectoryHistoryWhere at:idx put:fileListView firstLineShown
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1366
		    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1367
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1368
		    self setCurrentDirectory:fileName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1369
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1370
		    path := currentDirectory pathName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1371
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1372
		    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1373
		     if we have already been there, look for the
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1374
		     position offset, and scroll the fileList
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1375
		    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1376
		    idx := DirectoryHistory indexOf:path.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1377
		    idx ~~ 0 ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1378
			|pos|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1379
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1380
			pos := DirectoryHistoryWhere at:idx.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1381
			pos notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1382
			    fileListView scrollToLine:pos
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1383
			]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1384
		    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1385
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1386
		    updateHistory ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1387
			|pos|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1388
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1389
			(DirectoryHistory includes:path) ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1390
			    DirectoryHistory size >= HistorySize ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1391
				DirectoryHistory removeLast.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1392
				DirectoryHistoryWhere removeLast
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1393
			    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1394
			] ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1395
			    "already been there before; move the entry to
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1396
			     the beginning, so it will fall out later."
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1397
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1398
			    idx := DirectoryHistory indexOf:path.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1399
			    DirectoryHistory removeIndex:idx.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1400
			    pos := DirectoryHistoryWhere at:idx.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1401
			    DirectoryHistoryWhere removeIndex:idx.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1402
			].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1403
			DirectoryHistory addFirst:path.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1404
			DirectoryHistoryWhere addFirst:pos.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1405
		    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1406
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1407
		    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1408
		].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1409
		msg := 'cannot change directory to ''%1'' !!'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1410
	    ] ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1411
		msg := 'cannot read directory ''%1'' !!'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1412
	    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1413
	] ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1414
	    msg := '''%1'' is not a directory !!'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1415
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1416
	self showAlert:(resources string:msg with:fileName) with:nil
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1417
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1418
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1419
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1420
doChangeToHomeDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1421
    "go to home directory"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1422
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1423
    self doChangeCurrentDirectoryTo:(OperatingSystem getHomeDirectory) updateHistory:true
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1424
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1425
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1426
doChangeToParentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1427
    "go to home directory"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1428
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1429
    self doChangeCurrentDirectoryTo:'..' updateHistory:true
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1430
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1431
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1432
doCreateDirectory:newName
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1433
    (currentDirectory includes:newName) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1434
	self warn:'%1 already exists.' with:newName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1435
	^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1436
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1437
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1438
    (currentDirectory createDirectory:newName) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1439
	self updateCurrentDirectory
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1440
    ] ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1441
	self showAlert:(resources string:'cannot create directory ''%1'' !!' with:newName)
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1442
		  with:(OperatingSystem lastErrorString)
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1443
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1444
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1445
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1446
doCreateFile:newName
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1447
    |aStream|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1448
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1449
    (currentDirectory includes:newName) ifTrue:[
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1450
        (self
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1451
            ask:(resources string:'%1 already exists\\truncate ?' with:newName)
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1452
            yesButton:'truncate'
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1453
        ) ifFalse:[^ self].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1454
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1455
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1456
    aStream := FileStream newFileNamed:newName in:currentDirectory.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1457
    aStream notNil ifTrue:[
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1458
        aStream close.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1459
        self updateCurrentDirectory
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1460
    ] ifFalse:[
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1461
        self showAlert:(resources string:'cannot create file ''%1'' !!' with:newName)
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1462
                  with:(FileStream lastErrorString)
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1463
    ]
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1464
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1465
    "Modified: 21.2.1996 / 01:24:16 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1466
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1467
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1468
doExecuteCommand:command replace:replace
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1469
    "execute a unix command inserting the output of the command.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1470
     If replace is true, all text is replaced by the commands output;
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1471
     otherwise, its inserted as selected text at the cursor position."
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1472
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1473
    |stream line lnr myProcess myPriority startLine startCol stopSignal
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1474
     access|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1475
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1476
    access := Semaphore forMutualExclusion.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1477
    stopSignal := Signal new.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1478
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1479
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1480
     must take killButton out of my group
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1481
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1482
    windowGroup removeView:killButton.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1483
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1484
     bring it to front, and turn hidden-mode off
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1485
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1486
    killButton raise.
331
a12998c7f3c2 use beVisible / beInvisible
Claus Gittinger <cg@exept.de>
parents: 310
diff changeset
  1487
    killButton beVisible.
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1488
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1489
     it will make me raise stopSignal when pressed
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1490
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1491
    killButton 
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1492
        action:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1493
            stream notNil ifTrue:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1494
                access critical:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1495
                    myProcess interruptWith:[stopSignal raise].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1496
                ]
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1497
            ]
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1498
        ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1499
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1500
     start it up under its own windowgroup
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1501
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1502
    killButton openAutonomous.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1503
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1504
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1505
     go fork a pipe and read it
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1506
    "
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1507
    self label:(myName , ': executing ' , (command copyTo:(20 min:command size)) , ' ...').
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1508
    [
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1509
      self withWaitCursorDo:[
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1510
        stopSignal catch:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1511
            startLine := subView cursorLine.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1512
            startCol := subView cursorCol.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1513
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1514
            "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1515
             this can be a time consuming operation; therefore lower my priority
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1516
            "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1517
            myProcess := Processor activeProcess.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1518
            myPriority := myProcess priority.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1519
            myProcess priority:(Processor userBackgroundPriority).
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1520
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1521
            stream := PipeStream readingFrom:('cd '
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1522
                                              , currentDirectory pathName
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1523
                                              , '; '
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1524
                                              , command
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1525
                                              , ' 2>&1' ).
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1526
            stream notNil ifTrue:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1527
                [
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1528
                    |codeView lines|
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1529
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1530
                    codeView := subView.
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1531
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1532
                    replace ifTrue:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1533
                        codeView list:nil.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1534
                        lnr := 1.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1535
                    ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1536
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1537
                    [stream atEnd] whileFalse:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1538
                        (stream readWaitWithTimeoutMs:50) ifFalse:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1539
                            "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1540
                             data available
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1541
                            "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1542
                            lines := OrderedCollection new:50.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1543
                            line := stream nextLine.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1544
                            line notNil ifTrue:[lines add:line].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1545
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1546
                            [stream atEnd not
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1547
                            and:[stream canReadWithoutBlocking
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1548
                            and:[lines size < 50]]] whileTrue:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1549
                                line := stream nextLine.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1550
                                line notNil ifTrue:[lines add:line].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1551
                            ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1552
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1553
                            "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1554
                             need this critical section; otherwise,
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1555
                             we could get the signal while waiting for
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1556
                             an expose event ...
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1557
                            "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1558
                            access critical:[                        
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1559
                                lines size > 0 ifTrue:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1560
                                    replace ifTrue:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1561
                                        lines do:[:line |
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1562
                                            codeView at:lnr put:line withTabsExpanded.
539
33b603dd30ba replaced ColoredListEntry by Text
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  1563
                                            codeView cursorToBottom; cursorDown:1.
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1564
                                            lnr := lnr + 1.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1565
                                        ].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1566
                                    ] ifFalse:[
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1567
codeView insertLines:lines before:codeView cursorLine.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1568
codeView cursorDown:lines size.
539
33b603dd30ba replaced ColoredListEntry by Text
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  1569
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1570
"/ lines do:[:line |
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1571
"/     codeView insertLine:line withTabsExpanded before:codeView cursorLine.
539
33b603dd30ba replaced ColoredListEntry by Text
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  1572
"/     codeView cursorDown:1.
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1573
"/ ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1574
"/                                        codeView insertStringAtCursor:line.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1575
"/                                        codeView insertCharAtCursor:(Character cr).
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1576
                                    ]
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1577
                                ].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1578
                            ].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1579
                        ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1580
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1581
                        shown ifTrue:[windowGroup processExposeEvents].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1582
                        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1583
                         give others running at same prio a chance too
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1584
                         (especially other FileBrowsers doing the same)
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1585
                        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1586
                        Processor yield
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1587
                    ].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1588
                ] valueNowOrOnUnwindDo:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1589
                    stream shutDown "close". stream := nil.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1590
                ].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1591
                self updateCurrentDirectory
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1592
            ].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1593
            replace ifTrue:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1594
                subView modified:false.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1595
            ].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1596
        ]
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1597
      ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1598
    ] valueNowOrOnUnwindDo:[
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1599
        |wg|
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1600
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1601
        self label:myName; iconLabel:myName.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1602
        myProcess notNil ifTrue:[myProcess priority:myPriority].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1603
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1604
        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1605
         remove the killButton from its group
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1606
         (otherwise, it will be destroyed when we shut down the group)
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1607
        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1608
        wg := killButton windowGroup.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1609
        killButton windowGroup:nil.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1610
        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1611
         shut down the windowgroup
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1612
        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1613
        wg notNil ifTrue:[
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1614
            wg process terminate.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1615
        ].
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1616
        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1617
         hide the button, and make sure it will stay
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1618
         hidden when we are realized again
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1619
        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1620
        killButton beInvisible.
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1621
        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1622
         clear its action (actually not needed, but
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1623
         releases reference to thisContext earlier)
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1624
        "
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1625
        killButton action:nil.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1626
    ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1627
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1628
    currentFileName isNil ifTrue:[
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1629
        subView modified:false.
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1630
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1631
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1632
    subView size > 10000 ifTrue:[
355
55f1bac567eb command execution kill fixed (for pipes where nothing ever arrives)
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1633
        self warn:'text quite large now - please cut off some lines'
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1634
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1635
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1636
    "Modified: 21.9.1995 / 11:18:46 / claus"
539
33b603dd30ba replaced ColoredListEntry by Text
Claus Gittinger <cg@exept.de>
parents: 525
diff changeset
  1637
    "Modified: 12.5.1996 / 16:56:06 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1638
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1639
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1640
doFileGet
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1641
    "get selected file - show contents in subView"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1642
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1643
    |fileName iconLbl winLbl|
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1644
294
a693bd6d7ae6 read cursor while reading
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1645
    self withReadCursorDo:[
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1646
        fileName := self getSelectedFileName.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1647
        fileName notNil ifTrue:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1648
            (currentDirectory isDirectory:fileName) ifTrue:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1649
                self doChangeCurrentDirectoryTo:fileName updateHistory:true.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1650
                winLbl := myName.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1651
                iconLbl := myName
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1652
            ] ifFalse:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1653
                (currentDirectory exists:fileName) ifFalse:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1654
                    self warn:(resources string:'oops, ''%1'' is gone' with:fileName).
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1655
                    ^ self
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1656
                ].
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1657
                timeOfFileRead := currentDirectory timeOfLastChange:fileName.
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  1658
                self showFile:fileName insert:false encoding:fileEncoding.
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1659
                currentFileName := fileName.
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1660
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1661
                subView acceptAction:[:theCode |
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1662
                    self withCursor:(Cursor write) do:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  1663
                        self writeFile:fileName text:theCode encoding:fileEncoding.
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1664
                        timeOfFileRead := currentDirectory timeOfLastChange:fileName.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1665
                        self label:myName , ': ' , currentFileName
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1666
                    ]
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1667
                ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1668
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1669
                winLbl := myName , ': ' , fileName.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1670
                (currentDirectory isWritable:fileName) ifFalse:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1671
                    winLbl := winLbl , ' (readonly)'
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1672
                ].
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1673
                iconLbl := fileName
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1674
            ].
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1675
            self label:winLbl.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1676
            self iconLabel:iconLbl.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1677
        ]
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1678
    ]
294
a693bd6d7ae6 read cursor while reading
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  1679
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  1680
    "Modified: 22.2.1996 / 15:02:55 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1681
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1682
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1683
doRemove
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1684
    "remove the selected file(s) - no questions asked"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1685
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1686
    |ok msg dir|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1687
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1688
    lockUpdate := true.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1689
    [
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1690
        self selectedFilesDo:[:fileName |
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1691
            ok := false.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1692
            (currentDirectory isDirectory:fileName) ifTrue:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1693
                dir := FileDirectory directoryNamed:fileName in:currentDirectory.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1694
                (dir isEmpty 
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1695
                or:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1696
                    (self 
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1697
                        ask:(resources string:'directory ''%1'' is not empty\remove anyway ?' with:fileName)
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1698
                        yesButton:'remove')])
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1699
                ifTrue:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1700
                    ok := currentDirectory removeDirectory:fileName
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1701
                ].
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1702
            ] ifFalse:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1703
                ok := currentDirectory remove:fileName.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1704
            ].
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1705
            ok ifFalse:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1706
                "was not able to remove it"
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1707
                msg := (resources string:'cannot remove ''%1'' !!' with:fileName).
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1708
                self showAlert:msg with:(OperatingSystem lastErrorString)
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1709
            ] ifTrue:[
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1710
"
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1711
                self show:nil
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1712
"
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1713
            ]
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1714
        ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1715
    ] valueNowOrOnUnwindDo:[
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1716
        lockUpdate := false.
564
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  1717
        fileListView setSelection:nil.
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1718
        self updateCurrentDirectory.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1719
    ]
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  1720
564
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  1721
    "Modified: 25.5.1996 / 13:02:51 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1722
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1723
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1724
doRename:oldName to:newName
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1725
    (oldName notNil and:[newName notNil]) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1726
	(oldName isBlank or:[newName isBlank]) ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1727
	    currentDirectory renameFile:oldName newName:newName.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1728
	    self updateCurrentDirectory.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1729
	]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1730
    ]
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1731
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1732
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1733
getFileInfoString:longInfo
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1734
    "get stat info on selected file - return a string which can be
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1735
     shown in a box"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1736
133
claus
parents: 132
diff changeset
  1737
    |fileName f fullPath text info fileOutput type modeBits modeString s ts|
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1738
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1739
    fileName := self getSelectedFileName.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1740
    fileName isNil ifTrue:[^ nil].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1741
133
claus
parents: 132
diff changeset
  1742
    f := currentDirectory pathName asFilename construct:fileName.
claus
parents: 132
diff changeset
  1743
    info := f info.
claus
parents: 132
diff changeset
  1744
claus
parents: 132
diff changeset
  1745
"/    info := currentDirectory infoOf:fileName.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1746
    info isNil ifTrue:[
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1747
	self showAlert:(resources string:'cannot get info of ''%1'' !!' with:fileName)
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1748
		  with:(OperatingSystem lastErrorString).
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1749
	^ nil
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1750
    ].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1751
59
d8ff572dd357 Text eliminated
claus
parents: 58
diff changeset
  1752
    text := StringCollection new.
133
claus
parents: 132
diff changeset
  1753
    f isSymbolicLink ifTrue:[
claus
parents: 132
diff changeset
  1754
	text add:(resources string:'symbolic link to: %1' with:(f linkInfo at:#path))
claus
parents: 132
diff changeset
  1755
    ].
claus
parents: 132
diff changeset
  1756
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1757
    type := info at:#type.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1758
    (longInfo and:[type == #regular]) ifTrue:[
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1759
	fullPath := currentDirectory pathName , '/' , fileName.
49
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  1760
	fileOutput := fullPath asFilename fileType.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1761
    ].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1762
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1763
    s := (resources at:'type:   ').
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1764
    fileOutput isNil ifTrue:[
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1765
	s := s ,  type asString
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1766
    ] ifFalse:[
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1767
	s := s , 'regular (' , fileOutput , ')'
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1768
    ].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1769
    text add:s.
133
claus
parents: 132
diff changeset
  1770
    text add:(resources string:'size:   %1' with:(info at:#size) printString).
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1771
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1772
    modeBits := (info at:#mode).
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1773
    modeString := self getModeString:modeBits.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1774
    longInfo ifTrue:[
133
claus
parents: 132
diff changeset
  1775
	text add:(resources string:'access: %1 (%2)'
claus
parents: 132
diff changeset
  1776
			      with:modeString 
claus
parents: 132
diff changeset
  1777
			      with:(modeBits printStringRadix:8))
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1778
    ] ifFalse:[
133
claus
parents: 132
diff changeset
  1779
	text add:(resources string:'access: %1' with:modeString)
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1780
    ].
133
claus
parents: 132
diff changeset
  1781
    text add:(resources string:'owner:  %1'
claus
parents: 132
diff changeset
  1782
			  with:(OperatingSystem getUserNameFromID:(info at:#uid))).
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1783
    longInfo ifTrue:[
133
claus
parents: 132
diff changeset
  1784
	text add:(resources string:'group:  %1'
claus
parents: 132
diff changeset
  1785
			      with:(OperatingSystem getGroupNameFromID:(info at:#gid))).
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1786
133
claus
parents: 132
diff changeset
  1787
	ts := info at:#accessed.
claus
parents: 132
diff changeset
  1788
	text add:(resources string:'last access:       %1 %2' 
claus
parents: 132
diff changeset
  1789
			      with:(ts asTime printString)
claus
parents: 132
diff changeset
  1790
			      with:(ts asDate printString)).
claus
parents: 132
diff changeset
  1791
claus
parents: 132
diff changeset
  1792
	ts := info at:#modified.
claus
parents: 132
diff changeset
  1793
	text add:(resources string:'last modification: %1 %2'
claus
parents: 132
diff changeset
  1794
			      with:(ts asTime printString)
claus
parents: 132
diff changeset
  1795
			      with:(ts asDate printString)).
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1796
    ].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1797
    ^ text asString
133
claus
parents: 132
diff changeset
  1798
claus
parents: 132
diff changeset
  1799
    "Modified: 8.9.1995 / 11:59:28 / claus"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1800
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1801
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1802
getInfoFile
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1803
    "get filename of a description-file (.dir.info, README etc.);
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1804
     This file is automatically shown when a directory is enterred.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1805
     You can add more names below if you like."
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1806
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1807
    #( '.dir.info'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1808
       'README'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1809
       'ReadMe'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1810
       'Readme'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1811
       'readme' 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1812
    ) do:[:f |
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1813
	(currentDirectory isReadable:f) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1814
	    (currentDirectory isDirectory:f) ifFalse:[^ f].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1815
	]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1816
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1817
    ^ nil
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1818
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1819
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1820
getModeString:modeBits
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1821
    "convert file-mode bits into a more user-friendly string.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1822
     This is wrong here - should be moved into OperatingSystem."
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1823
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1824
    ^ self getModeString:modeBits 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1825
		    with:#( 'owner:' $r $w $x 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1826
			    ' group:' $r $w $x 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1827
			    ' others:' $r $w $x )
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1828
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1829
37
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  1830
getModeString:modeBits with:texts
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1831
    "convert file-mode bits into a more user-friendly string.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1832
     This is wrong here - should be moved into OperatingSystem."
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1833
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1834
    |bits modeString|
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1835
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1836
    bits := modeBits bitAnd:8r777.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1837
    modeString := ''.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1838
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1839
    #( nil 8r400 8r200 8r100 nil 8r040 8r020 8r010 nil 8r004 8r002 8r001 ) 
37
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  1840
    with: texts do:[:bitMask :access |
116
claus
parents: 111
diff changeset
  1841
	|ch|
claus
parents: 111
diff changeset
  1842
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1843
	bitMask isNil ifTrue:[
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1844
	    modeString := modeString , (resources string:access)
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1845
	] ifFalse:[
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1846
	    (bits bitAnd:bitMask) == 0 ifTrue:[
116
claus
parents: 111
diff changeset
  1847
		ch := $-
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1848
	    ] ifFalse:[
116
claus
parents: 111
diff changeset
  1849
		ch := access
claus
parents: 111
diff changeset
  1850
	    ].
claus
parents: 111
diff changeset
  1851
	    modeString := modeString copyWith:ch 
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  1852
	]
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1853
    ].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1854
    ^ modeString
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1855
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  1856
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1857
getSelectedFileName
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1858
    "returns the currently selected file; shows an error if
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1859
     multiple files are selected"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1860
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1861
    |sel|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1862
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1863
    sel := fileListView selection.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1864
    (sel size > 1) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1865
	self onlyOneSelection
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1866
    ] ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1867
	sel notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1868
	    ^ fileList at:sel first
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1869
	]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1870
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1871
    ^ nil
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1872
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1873
395
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1874
guessEncodingFrom:aBuffer
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1875
    |n "{Class: SmallInteger }"
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1876
     binary|
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1877
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1878
    binary := false.
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1879
    n := aBuffer size.
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1880
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1881
    1 to:n do:[:i |
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1882
        (aBuffer at:i) isPrintable ifFalse:[binary := true].
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1883
    ].
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1884
    binary ifTrue:[
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1885
        "/ look for JIS7 / EUC encoding
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1886
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1887
        (aBuffer findString:(JISEncodedString jis7KanjiEscapeSequence)) ~~ 0 ifTrue:[
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1888
            ^ #jis7
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1889
        ].
396
e5777391727e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  1890
        (aBuffer findString:(JISEncodedString oldJis7KanjiEscapeSequence)) ~~ 0 ifTrue:[
e5777391727e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  1891
            ^ #jis7
e5777391727e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  1892
        ].
395
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1893
        ^ #binary
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1894
    ].
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1895
    ^ #ascii
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1896
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1897
    "Created: 26.2.1996 / 17:43:08 / cg"
396
e5777391727e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 395
diff changeset
  1898
    "Modified: 26.2.1996 / 21:53:39 / cg"
395
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1899
!
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  1900
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1901
initialCommandFor:fileName into:aBox
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1902
    "set a useful initial command for execute box.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1903
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1904
     XXX should be changed to take stuff from a config file
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1905
     XXX or from resources."
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1906
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1907
    ((currentDirectory typeOf:fileName) == #regular) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1908
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1909
	(currentDirectory isExecutable:fileName) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1910
	    aBox initialText:(fileName , '<arguments>').
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1911
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1912
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1913
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1914
	"some heuristics - my personal preferences ...
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1915
	 (actually this should come from a configfile)"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1916
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1917
	(fileName endsWith:'akefile') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1918
	    aBox initialText:'make target' selectFrom:6 to:11.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1919
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1920
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1921
	(fileName endsWith:'.tar.Z') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1922
	    aBox initialText:'zcat ' , fileName , ' | tar tvf -'.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1923
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1924
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1925
	(fileName endsWith:'.taz') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1926
	    aBox initialText:'zcat ' , fileName , ' | tar tvf -'.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1927
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1928
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1929
	(fileName endsWith:'.tar') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1930
	    aBox initialText:'tar tvf ' , fileName selectFrom:1 to:7.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1931
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1932
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1933
	(fileName endsWith:'.zoo') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1934
	    aBox initialText:'zoo -list ' , fileName selectFrom:1 to:9.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1935
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1936
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1937
	(fileName endsWith:'.zip') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1938
	    aBox initialText:'unzip -l ' , fileName selectFrom:1 to:8.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1939
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1940
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1941
	(fileName endsWith:'.Z') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1942
	    aBox initialText:'uncompress ' , fileName selectFrom:1 to:10.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1943
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1944
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1945
	(fileName endsWith:'tar.gz') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1946
	    aBox initialText:('gunzip <' , fileName , ' | tar tvf -' ).
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1947
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1948
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1949
	(fileName endsWith:'.gz') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1950
	    aBox initialText:('gunzip <' , fileName , ' >' , (fileName copyWithoutLast:3 "copyTo:(fileName size - 3)")).
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1951
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1952
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1953
	(fileName endsWith:'.html') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1954
	    aBox initialText:'chimera ' , fileName .
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1955
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1956
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1957
	(fileName endsWith:'.uue') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1958
	    aBox initialText:'uudecode ' , fileName selectFrom:1 to:8.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1959
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1960
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1961
	(fileName endsWith:'.c') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1962
	    aBox initialText:'cc -c ' , fileName selectFrom:1 to:5.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1963
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1964
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1965
	(fileName endsWith:'.cc') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1966
	    aBox initialText:'g++ -c ' , fileName selectFrom:1 to:6.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1967
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1968
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1969
	(fileName endsWith:'.C') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1970
	    aBox initialText:'g++ -c ' , fileName selectFrom:1 to:6.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1971
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1972
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1973
	(fileName endsWith:'.xbm') ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1974
	    aBox initialText:'bitmap ' , fileName selectFrom:1 to:6.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1975
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1976
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1977
	((fileName endsWith:'.ps') or:[fileName endsWith:'.PS']) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1978
	    aBox initialText:'ghostview ' , fileName selectFrom:1 to:9.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1979
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1980
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1981
	((fileName endsWith:'.1') 
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1982
	or:[fileName endsWith:'.man']) ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1983
	    aBox initialText:'nroff -man ' , fileName selectFrom:1 to:10.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1984
	    ^ self
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1985
	].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1986
	aBox initialText:'<cmd> ' , fileName selectFrom:1 to:5
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1987
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1988
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1989
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1990
onlyOneSelection
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1991
    "show a warning, that only one file must be selected for
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1992
     this operation"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1993
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1994
    self warn:'exactly one file must be selected !!'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1995
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1996
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1997
selectedFilesDo:aBlock
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1998
    "evaluate aBlock on all selected files;
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  1999
     show a wait cursor while doing this"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2000
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2001
    |sel|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2002
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2003
    sel := fileListView selection.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2004
    sel notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2005
	self withWaitCursorDo:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2006
	    sel do:[:aSelectionIndex |
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2007
		aBlock value:(fileList at:aSelectionIndex )
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2008
	    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2009
	]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2010
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2011
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2012
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2013
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2014
setCurrentDirectory:aPathName
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2015
    "setup for another directory"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2016
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2017
    |newDirectory|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2018
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2019
    aPathName isEmpty ifTrue:[^ self].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2020
    (currentDirectory isDirectory:aPathName) ifTrue:[
564
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2021
        newDirectory := FileDirectory directoryNamed:aPathName in:currentDirectory.
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2022
        newDirectory notNil ifTrue:[
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2023
            self currentDirectory:newDirectory pathName.
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2024
            currentFileName notNil ifTrue:[
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2025
                fileListView contents:nil.
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2026
                currentFileName := nil.
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2027
            ] ifFalse:[
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2028
                fileListView setSelection:nil.
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2029
                fileListView scrollToTop.
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2030
            ].
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2031
            self updateCurrentDirectory.
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2032
            self showInfo.
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2033
        ]
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2034
    ]
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2035
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2036
    "Modified: 21.9.1995 / 11:22:45 / claus"
564
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2037
    "Modified: 25.5.1996 / 12:27:01 / cg"
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2038
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2039
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2040
show:something
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2041
    "show something in subview and undef acceptAction"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2042
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2043
    subView contents:something.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2044
    subView acceptAction:nil.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2045
    subView modified:false.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2046
    currentFileName := nil
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2047
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2048
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2049
showAlert:aString with:anErrorString
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2050
    "show an alertbox, displaying the last Unix-error"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2051
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2052
    |msg|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2053
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2054
    anErrorString isNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2055
	msg := aString
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2056
    ] ifFalse:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2057
	msg := aString , '\\(' , anErrorString , ')'
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2058
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2059
    self warn:msg withCRs
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2060
!
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2061
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2062
showInfo
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2063
    "show directory info when dir has changed"
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2064
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2065
    |info txt|
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2066
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2067
    info := self getInfoFile.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2068
    info notNil ifTrue:[
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2069
	txt := self readFile:info
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2070
    ].
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2071
    self show:txt.
37
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  2072
!
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  2073
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2074
sizePrintString:size
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2075
    "helper for update-directory to return a string with a files size.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2076
     This one gives the size in byte, Kb or Mb depending on size.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2077
     If you dont like this, just uncomment the first statement below."
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2078
93
claus
parents: 85
diff changeset
  2079
    |unitString n|
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2080
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2081
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2082
    ^ size printString.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2083
"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2084
    unitString := ''.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2085
    size < (500 * 1024) ifTrue:[
93
claus
parents: 85
diff changeset
  2086
	size < 1024 ifTrue:[
claus
parents: 85
diff changeset
  2087
	    n := size
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  2088
	] ifFalse:[
93
claus
parents: 85
diff changeset
  2089
	    n := (size * 10 // 1024 / 10.0).
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  2090
	    unitString := ' Kb'
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  2091
	]
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2092
    ] ifFalse:[
93
claus
parents: 85
diff changeset
  2093
	n := (size * 10 // 1024 // 1024 / 10.0).
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  2094
	unitString := ' Mb'
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2095
    ].
93
claus
parents: 85
diff changeset
  2096
    ^ (n printStringLeftPaddedTo:5) , unitString.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2097
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2098
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2099
updateCurrentDirectory
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2100
    "update listView with directory contents"
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2101
142
claus
parents: 139
diff changeset
  2102
    |files text len line info modeString 
53
2fc78a0165e7 *** empty log message ***
claus
parents: 52
diff changeset
  2103
     prevUid prevGid nameString groupString matchPattern|
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2104
49
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2105
    "the code below may look somewhat complex -
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2106
     it reads the directory first for the names,
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2107
     then (in a second sweep over the files) gets the
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2108
     files type and info. This makes the Filebrowsers
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2109
     list update seem faster, since the fileInfo (i.e. stat-calls)
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2110
     may take long - especially on NFS-mounted directories.
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2111
     The file reading is done at lower priority, to let user continue
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2112
     his work in other views. However, to be fair to other fileBrowser,
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2113
     which may also read directories at low prio, give up the processor
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2114
     after every entry. This shares the cpu among all fileBrowsers, so
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2115
     that browsers reading short directories will finish first.
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2116
     ST/X users love this behavior ;-)
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2117
    "
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2118
294
a693bd6d7ae6 read cursor while reading
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  2119
    self withReadCursorDo:[
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2120
	Processor removeTimedBlock:checkBlock.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2121
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2122
	timeOfLastCheck := AbsoluteTime now.
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  2123
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2124
	files := currentDirectory asOrderedCollection.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2125
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2126
	matchPattern := filterField contents.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2127
	(matchPattern notNil and:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2128
	 matchPattern isEmpty not and:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2129
	 matchPattern ~= '*']]) ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2130
	    files := files select:[:aName | 
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2131
			 ((currentDirectory typeOf:aName) == #directory)
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2132
			 or:[matchPattern match:aName]
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2133
		     ].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2134
	].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2135
	files sort.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2136
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2137
	files size == 0 ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2138
	    self information:('directory ', currentDirectory pathName, ' vanished').
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2139
	    ^ self
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2140
	].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2141
	files := self withoutHiddenFiles:files.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2142
	fileList := files copy.
45
950b84ba89e6 *** empty log message ***
claus
parents: 37
diff changeset
  2143
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2144
	"
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2145
	 this is a time consuming operation (especially, if reading an
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2146
	 NFS-mounted directory); therefore lower my priority while getting
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2147
	 the files info ...
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2148
	"
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2149
	Processor activeProcess withLowerPriorityDo:[
49
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2150
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2151
	    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2152
	     first show the names only - this is relatively fast
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2153
	    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2154
	    fileListView setList:files expandTabs:false.
37
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  2155
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2156
	    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2157
	     then walk over the files, adding more info
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2158
	     (since we have to stat each file, this may take a while longer
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2159
	    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2160
	    showLongList ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2161
		tabSpec isNil ifTrue:[self defineTabulatorsForLongList].
37
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  2162
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2163
		text := OrderedCollection new.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2164
		files keysAndValuesDo:[:lineIndex :aFileName |
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2165
		    |entry col typ f p typeString|
37
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  2166
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2167
		    entry := MultiColListEntry new.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2168
		    entry tabulatorSpecification:tabSpec.
37
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  2169
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2170
		    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2171
		     if multiple FileBrowsers are reading, let others
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2172
		     make some progress too
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2173
		    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2174
		    windowGroup notNil ifTrue:[windowGroup processExposeEvents].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2175
		    Processor yield.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2176
		    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2177
		     could be destroyed in the meanwhile ...
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2178
		    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2179
		    realized ifFalse:[^ self].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2180
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2181
		    len := aFileName size.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2182
		    (len < 20) ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2183
			line := aFileName , (String new:(22 - len))
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2184
		    ] ifFalse:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2185
			"can happen on BSD only"
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2186
			line := (aFileName copyTo:20) , '  '
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2187
		    ].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2188
		    entry colAt:1 put:line.
37
50f59bad66b1 *** empty log message ***
claus
parents: 36
diff changeset
  2189
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2190
		    info := currentDirectory infoOf:aFileName.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2191
		    info isNil ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2192
			"not accessable - usually a symlink,
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2193
			 to a nonexisting/nonreadable file
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2194
			"
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2195
			entry colAt:2 put:'?'.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2196
			entry colAt:3 put:'(bad symbolic link ?)'.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2197
		    ] ifFalse:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2198
			typ := (info at:#type).
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2199
			(typ == #regular) ifFalse:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2200
			    entry colAt:2 put:(typ at:1) asString.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2201
			] ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2202
			    entry colAt:2 put:' '.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2203
			].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2204
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2205
			modeString := self getModeString:(info at:#mode)
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2206
						    with:#( '' $r $w $x 
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2207
							    '  ' $r $w $x 
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2208
							    '  ' $r $w $x ).
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2209
			entry colAt:3 put:modeString.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2210
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2211
			((info at:#uid) ~~ prevUid) ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2212
			    prevUid := (info at:#uid).
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2213
			    nameString := OperatingSystem getUserNameFromID:prevUid.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2214
			    nameString := nameString , (String new:(10 - nameString size))
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2215
			].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2216
			entry colAt:4 put:nameString withoutSpaces.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2217
			((info at:#gid) ~~ prevGid) ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2218
			    prevGid := (info at:#gid).
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2219
			    groupString := OperatingSystem getGroupNameFromID:prevGid.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2220
			    groupString := groupString , (String new:(10 - groupString size))
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2221
			].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2222
			entry colAt:5 put:groupString withoutSpaces.
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2223
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2224
			(typ == #regular) ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2225
			    entry colAt:6 put:(self sizePrintString:(info at:#size)).
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2226
			].
49
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2227
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2228
			f := currentDirectory asFilename:aFileName.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2229
			f isSymbolicLink ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2230
			    p := f linkInfo at:#path.    
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2231
			    typeString := 'symbolic link to ' , p
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2232
			] ifFalse:[        
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2233
			    (showVeryLongList not or:[typ == #directory]) ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2234
				typeString := typ asString
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2235
			    ] ifFalse:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2236
				typeString := f fileType.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2237
			    ].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2238
			].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2239
			entry colAt:7 put:typeString.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2240
			text add:entry
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2241
		    ].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2242
		    fileListView at:lineIndex put:entry
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2243
		].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2244
	    ] ifFalse:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2245
		files keysAndValuesDo:[:lineIndex :aName |
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2246
		    |entry|
49
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2247
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2248
		    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2249
		     if multiple FileBrowsers are reading, let others
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2250
		     make some progress too
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2251
		    "
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2252
		    windowGroup notNil ifTrue:[windowGroup processExposeEvents].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2253
		    Processor yield.
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2254
		    realized ifFalse:[^ self].
49
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2255
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2256
		    ((currentDirectory isDirectory:aName) and:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2257
		    (aName ~= '..') and:[aName ~= '.']]) ifTrue:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2258
			entry := aName , ' ...'
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2259
		    ] ifFalse:[
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2260
			entry := aName
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2261
		    ].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2262
		    fileListView at:lineIndex put:entry
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2263
		].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2264
	    ].
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2265
	].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2266
333
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2267
	"
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2268
	 install a new check after some time
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2269
	"
245f0a972fc9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 331
diff changeset
  2270
	Processor addTimedBlock:checkBlock afterSeconds:checkDelta
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2271
    ]
142
claus
parents: 139
diff changeset
  2272
claus
parents: 139
diff changeset
  2273
    "Modified: 21.9.1995 / 11:40:23 / claus"
294
a693bd6d7ae6 read cursor while reading
Claus Gittinger <cg@exept.de>
parents: 288
diff changeset
  2274
    "Modified: 14.12.1995 / 20:59:09 / cg"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2275
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2276
482
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2277
validateFontEncodingFor:newEncoding
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2278
    "if required, query user if he/she wants to change to another font,
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2279
     which is able to display text encoded as specified by newEncoding"
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2280
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2281
    |fontsEncoding msg filter f|
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2282
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2283
    fontsEncoding := subView font encoding.
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2284
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2285
    ((newEncoding == #jis7) or:[newEncoding == #euc]) ifTrue:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2286
        (fontsEncoding notNil and:[fontsEncoding startsWith:'jis']) ifFalse:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2287
            msg := 'switch to a JIS encoded font ?'.
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2288
            filter := [:f | f encoding notNil 
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2289
                            and:['jis*' match:f encoding]].
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2290
        ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2291
    ] ifFalse:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2292
        (newEncoding == #gb) ifTrue:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2293
            (fontsEncoding notNil and:[fontsEncoding startsWith:'gb']) ifFalse:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2294
                msg := 'switch to a GB encoded font ?'.
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2295
                filter := [:f | f encoding notNil 
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2296
                                and:['gb*' match:f encoding]].
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2297
            ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2298
        ] ifFalse:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2299
            (newEncoding == #big5) ifTrue:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2300
                (fontsEncoding notNil and:[fontsEncoding startsWith:'big5']) ifFalse:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2301
                    msg := 'switch to a BIG-5 encoded font ?'.
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2302
                    filter := [:f | f encoding notNil 
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2303
                                    and:['big5*' match:f encoding]].
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2304
                ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2305
            ] ifFalse:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2306
                fontsEncoding notNil ifTrue:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2307
                    ((fontsEncoding startsWith:'jis')
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2308
                    or:[(fontsEncoding startsWith:'gb')
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2309
                    or:[(fontsEncoding startsWith:'big5')]])
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2310
                    ifTrue:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2311
                        msg := 'switch back to an ASCII encoded font ?'.
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2312
                        filter := [:f | f encoding notNil 
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2313
                                        and:[('ascii' match:f encoding)
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2314
                                             or:['iso*' match:f encoding]]].
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2315
                    ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2316
                ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2317
            ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2318
        ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2319
    ].
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2320
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2321
    msg notNil ifTrue:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2322
        (self confirm:(resources string:msg) withCRs)
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2323
        ifTrue:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2324
            f := FontPanel 
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2325
                fontFromUserInitial:nil
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2326
                              title:(resources string:'font selection')
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2327
                             filter:filter.
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2328
            f notNil ifTrue:[
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2329
                subView font:f
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2330
            ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2331
        ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2332
    ]
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2333
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2334
    "Modified: 17.4.1996 / 18:45:58 / cg"
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2335
    "Created: 17.4.1996 / 18:48:29 / cg"
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2336
!
6017d64e8e4b added big5 & gb support
Claus Gittinger <cg@exept.de>
parents: 415
diff changeset
  2337
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2338
withoutHiddenFiles:aCollection
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2339
    "remove hidden files (i.e. those that start with '.') from
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2340
     the list in aCollection"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2341
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2342
    |newCollection|
52
7b48409ae088 *** empty log message ***
claus
parents: 49
diff changeset
  2343
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2344
    newCollection := aCollection species new.
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2345
    aCollection do:[:fname |
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2346
        |ignore|
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2347
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2348
        ignore := false.
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2349
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2350
        ((fname startsWith:'.') and:[fname ~= '..']) ifTrue:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2351
            showDotFiles ifFalse:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2352
                ignore := true
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2353
            ]
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2354
        ].
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2355
        ignore ifFalse:[
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2356
            newCollection add:fname
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2357
        ]
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2358
    ].
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2359
    ^ newCollection
380
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2360
ec0cfd2b3200 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 355
diff changeset
  2361
    "Modified: 21.2.1996 / 01:33:18 / cg"
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2362
! !
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2363
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2364
!FileBrowser methodsFor:'private-file-I/O'!
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2365
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2366
readFile:fileName
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2367
    "read in the file, answer its contents as StringCollection"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2368
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2369
    ^ self readFile:fileName lineDelimiter:Character cr encoding:nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2370
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2371
    "Modified: 22.2.1996 / 14:57:08 / cg"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2372
!
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2373
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2374
readFile:fileName lineDelimiter:aCharacter encoding:encoding
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2375
    "read in the file, return its contents as StringCollection. 
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2376
     The files lines are delimited by aCharacter.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2377
     If encoding is nonNil, the file is assumed to be coded according to
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2378
     that symbol, and #decodeString: should be able to convert it."
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2379
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2380
    |stream text msg sz|
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2381
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2382
    stream := FileStream readonlyFileNamed:fileName in:currentDirectory.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2383
    stream isNil ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2384
        msg := (resources string:'cannot read file ''%1'' !!' with:fileName).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2385
        self showAlert:msg with:(FileStream lastErrorString).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2386
        ^ nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2387
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2388
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2389
    "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2390
     for very big files, give ObjectMemory a hint, to preallocate more
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2391
    "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2392
    (sz := stream size) > 1000000 ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2393
        Processor activeProcess withLowerPriorityDo:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2394
            ObjectMemory announceSpaceNeed:(sz + (sz // 5)) "/ add 20% for tab expansion
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2395
        ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2396
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2397
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2398
    text := self readStream:stream lineDelimiter:aCharacter encoding:encoding.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2399
    stream close.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2400
    ^ text
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2401
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2402
    "Created: 22.2.1996 / 14:56:48 / cg"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2403
    "Modified: 22.2.1996 / 14:58:16 / cg"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2404
!
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2405
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2406
readStream:aStream
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2407
    "read in from aStream, answer its contents as StringCollection"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2408
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2409
    ^ self readStream:aStream lineDelimiter:Character cr encoding:nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2410
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2411
    "Modified: 22.2.1996 / 14:58:40 / cg"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2412
!
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2413
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2414
readStream:aStream lineDelimiter:aCharacter encoding:encoding 
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2415
    "read from aStream, answer its contents as StringCollection. 
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2416
     The files lines are delimited by aCharacter.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2417
     If encoding is nonNil, the file is assumed to be coded according to
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2418
     that symbol, and #decodeString: should be able to convert it."
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2419
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2420
    |text line|
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2421
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2422
    text := StringCollection new.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2423
    aCharacter == Character cr ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2424
        [aStream atEnd] whileFalse:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2425
            line := aStream nextLine withTabsExpanded.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2426
            encoding notNil ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2427
                line := line decodeFrom:encoding
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2428
            ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2429
            text add:line
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2430
        ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2431
    ] ifFalse:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2432
        [aStream atEnd] whileFalse:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2433
            line := (aStream upTo:aCharacter) withTabsExpanded.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2434
            encoding notNil ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2435
                line := line decodeFrom:encoding
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2436
            ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2437
            text add:line
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2438
        ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2439
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2440
    ^ text
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2441
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2442
    "Created: 22.2.1996 / 14:58:25 / cg"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2443
    "Modified: 22.2.1996 / 15:07:53 / cg"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2444
!
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2445
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2446
showFile:fileName
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2447
    "show contents of fileName in subView"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2448
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2449
    self showFile:fileName insert:false encoding:fileEncoding
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2450
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2451
    "Modified: 22.2.1996 / 14:47:10 / cg"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2452
!
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2453
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2454
showFile:fileName insert:insert encoding:encoding
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2455
    "show/insert contents of fileName in subView"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2456
395
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2457
    |buffer s n i ok convert text msg eol guess|
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2458
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2459
    ((currentDirectory typeOf:fileName) == #regular) ifFalse:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2460
        "asked for a non-file  - ignore it ..."
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2461
        (currentDirectory exists:fileName) ifFalse:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2462
            msg := '''%1'' does not exist !!'.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2463
        ] ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2464
            msg := '''%1'' is not a regular file !!'.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2465
        ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2466
        self warn:(resources string:msg with:fileName).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2467
        ^ self
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2468
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2469
    "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2470
     check if file is a text file
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2471
    "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2472
    s := FileStream readonlyFileNamed:fileName in:currentDirectory.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2473
    s isNil ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2474
        self showAlert:(resources string:'cannot read file ''%1'' !!' with:fileName)
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2475
                  with:(FileStream lastErrorString).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2476
        ^ nil
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2477
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2478
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2479
    buffer := String new:300.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2480
    n := s nextBytes:300 into:buffer.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2481
    s close.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2482
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2483
    ok := true.
395
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2484
    guess := self guessEncodingFrom:buffer.
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2485
    guess == #binary ifTrue:[
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2486
        ok := false.
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2487
        (self binaryFileAction:fileName) ifTrue:[^ self].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2488
        (self confirm:(resources string:'''%1'' seems to be a binary file - show anyway ?' with:fileName))
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2489
        ifFalse:[^ self]
395
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2490
    ] ifFalse:[
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2491
        guess ~~ #ascii ifTrue:[
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2492
            fileEncoding ~~ guess ifTrue:[
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2493
                (self confirm:(resources string:'''%1'' seems to be ' , guess , ' encoded - show anyway ?' with:fileName))
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2494
                ifFalse:[^ self]
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2495
            ]    
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2496
        ].
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2497
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2498
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2499
    convert := false.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2500
    ok ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2501
        "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2502
         check if line delimiter is a cr
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2503
        "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2504
        i := buffer indexOf:Character cr.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2505
        i == 0 ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2506
            "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2507
             no newline found - try cr
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2508
            "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2509
            i := buffer indexOf:(Character value:13).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2510
            i ~~ 0 ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2511
                convert := self confirm:(resources string:'''%1'' seems to have CR as line delimiter - convert to NL ?' with:fileName).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2512
            ]
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2513
        ]
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2514
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2515
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2516
    insert ifFalse:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2517
        "release old text first - we might need the memory in case of huge files
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2518
         (helps if you have a 4Mb file in the view, and click on another biggy)"
395
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2519
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2520
        subView contents:nil.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2521
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2522
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2523
    convert ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2524
        eol := Character value:13
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2525
    ] ifFalse:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2526
        eol := Character cr
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2527
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2528
    text := self readFile:fileName lineDelimiter:eol encoding:encoding.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2529
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2530
    insert ifFalse:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2531
        self show:text
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2532
    ] ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2533
        subView insertSelectedStringAtCursor:text asString
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2534
    ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2535
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2536
    "Created: 22.2.1996 / 14:46:57 / cg"
395
ae713196f3e6 added guess on encoding
Claus Gittinger <cg@exept.de>
parents: 389
diff changeset
  2537
    "Modified: 26.2.1996 / 17:48:24 / cg"
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2538
!
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2539
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2540
writeFile:fileName text:someText encoding:encoding
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2541
    |stream msg startNr nLines string|
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2542
310
8731287abedd minor changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  2543
    stream := FileStream newFileNamed:fileName in:currentDirectory.
8731287abedd minor changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  2544
    stream isNil ifTrue:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2545
        msg := (resources string:'cannot write file ''%1'' !!' with:fileName).
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2546
        self showAlert:msg with:(FileStream lastErrorString)
310
8731287abedd minor changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  2547
    ] ifFalse:[
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2548
        someText isString ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2549
            stream nextPutAll:someText.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2550
        ] ifFalse:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2551
            "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2552
             on some systems, writing linewise is very slow (via NFS)
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2553
             therefore we convert to a string and write it in chunks
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2554
             to avoid creating huge strings, we do it in blocks of 1000 lines
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2555
            "
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2556
            startNr := 1.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2557
            nLines := someText size.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2558
            [startNr <= nLines] whileTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2559
                string := someText asStringWithCRsFrom:startNr
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2560
                                                    to:((startNr + 1000) min:nLines)
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2561
                                          compressTabs:compressTabs.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2562
                encoding notNil ifTrue:[
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2563
                    string := string encodeInto:encoding
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2564
                ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2565
                stream nextPutAll:string.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2566
                startNr := startNr + 1000 + 1.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2567
            ].
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2568
"/                someText do:[:line |
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2569
"/                  line notNil ifTrue:[
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2570
"/                      stream nextPutAll:line.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2571
"/                  ].
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2572
"/                  stream cr.
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2573
"/              ]
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2574
        ].
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2575
        stream close.
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2576
        subView modified:false
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2577
    ]
310
8731287abedd minor changes
Claus Gittinger <cg@exept.de>
parents: 303
diff changeset
  2578
386
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2579
    "Created: 22.2.1996 / 15:03:10 / cg"
3fd24d9116b3 added encodings (experimental)
Claus Gittinger <cg@exept.de>
parents: 381
diff changeset
  2580
    "Modified: 22.2.1996 / 15:08:31 / cg"
36
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2581
! !
ccde5a941840 *** empty log message ***
claus
parents:
diff changeset
  2582
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2583
!FileBrowser methodsFor:'queries'!
73
e332d9c71624 *** empty log message ***
claus
parents: 67
diff changeset
  2584
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2585
path
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2586
    "return my currentDirectories pathName;
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2587
     sent from the pathField label to aquire pathname when I changed directory"
49
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2588
172
3578af8feec6 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 165
diff changeset
  2589
    ^ currentDirectory pathName
49
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2590
! !
6fe62433cfa3 *** empty log message ***
claus
parents: 47
diff changeset
  2591
203
de8d39d459fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
  2592
!FileBrowser class methodsFor:'documentation'!
de8d39d459fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
  2593
de8d39d459fd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 172
diff changeset
  2594
version
564
28b766ce6ec5 selection: / setSelection:
Claus Gittinger <cg@exept.de>
parents: 556
diff changeset
  2595
    ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.90 1996-05-25 11:32:05 cg Exp $'
381
0b715d777c48 slight cleanup
Claus Gittinger <cg@exept.de>
parents: 380
diff changeset
  2596
! !