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