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