remember last directory in show-diff-text;
use new menu-creation protocol (itemlist)
--- a/FBrowser.st Tue Jul 21 11:50:14 1998 +0200
+++ b/FBrowser.st Tue Jul 21 13:08:19 1998 +0200
@@ -16,7 +16,8 @@
showDotFiles myName killButton pauseToggle compressTabs
lockUpdate previousDirectory currentFileName timeOfFileRead
tabSpec commandView commandIndex fileEncoding tabRulerView
- scrollView icons listUpdateProcess currentFileInFileName'
+ scrollView icons listUpdateProcess currentFileInFileName
+ lastFileDiffDirectory'
classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon
CommandHistory CommandHistorySize Icons DefaultCommandPerSuffix'
poolDictionaries:''
@@ -659,97 +660,49 @@
<resource: #programMenu>
- |labels shorties selectors m sel ns subLabels subSelectors|
-
- labels := #(
- 'spawn'
- '-'
- 'get contents'
- 'insert contents'
- 'show info'
- 'show full info'
+ |items m sel ns subMenu subItems|
+
+ items := #(
+ ('spawn' fileSpawn )
+ ('-' nil )
+ ('get contents' fileGet GotoLine)
+ ('insert contents' fileInsert )
+ ('show info' fileGetInfo InspectIt)
+ ('show full info' fileGetLongInfo CmdI)
).
((ns := Project current defaultNameSpace) notNil
and:[ns ~~ Smalltalk]) ifTrue:[
- labels := labels copyWith:(resources string:'fileIn (into ''%1'')' with:(Project current defaultNameSpace name))
+ items := items copyWith:(Array
+ with:(resources string:'fileIn (into ''%1'')' with:(Project current defaultNameSpace name))
+ with:#fileFileIn
+ with:#Accept)
+
] ifFalse:[
- labels := labels copyWith:'fileIn'
+ items := items copyWith:#( 'fileIn' #fileFileIn #Accept)
].
- labels := labels , #(
- '-'
- 'update'
- '-'
- 'execute unix command ...'
- 'st/x tools'
- '-'
- 'remove'
- 'rename ...'
- '-'
- 'display long list'
- 'show all files'
- 'encoding ...'
- '-'
- 'create directory ...'
- 'create file ...'
+ items := items , #(
+ ('-' )
+ ('update' updateCurrentDirectory Cmdu)
+ ('-' )
+ ('execute unix command ...' fileExecute DoIt)
+ ('st/x tools' stxTools )
+ ('-' )
+ ('remove' fileRemove Delete)
+ ('rename ...' fileRename )
+ ('-' )
+ ('display long list' changeDisplayMode )
+ ('show all files' changeDotFileVisibility )
+ ('encoding ...' fileEncoding )
+ ('-' )
+ ('create directory ...' newDirectory CmdD)
+ ('create file ...' newFile CmdF)
).
- selectors := #(
- fileSpawn
- nil
- fileGet
- fileInsert
- fileGetInfo
- fileGetLongInfo
- fileFileIn
- nil
- updateCurrentDirectory
- nil
- fileExecute
- stxTools
- nil
- fileRemove
- fileRename
- nil
- changeDisplayMode
- changeDotFileVisibility
- fileEncoding
- nil
- newDirectory
- newFile
- ).
-
- shorties := #(
- nil
- nil
- GotoLine
- nil
- InspectIt
- CmdI
- Accept
- nil
- Cmdu
- nil
- DoIt
- nil
- nil
- Delete
- nil
- nil
- nil
- nil
- nil
- nil
- CmdD
- CmdF
- ).
-
m := PopUpMenu
- labels:(resources array:labels)
- selectors:selectors
- accelerators:shorties
- receiver:self.
+ itemList:items
+ resources:resources.
showDotFiles ifTrue:[
m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files')
@@ -758,36 +711,26 @@
m labelAt:#changeDisplayMode put:(resources string:'display short list')
].
- subLabels := #(
- 'Changes browser'
- 'Editor'
- 'HTML reader'
- 'Image inspect'
- 'show file differences'
- 'terminal'
+ items := #(
+ ('Changes browser' openChangesBrowser )
+ ('Editor' openEditor )
+ ('HTML reader' openHTMLReader )
+ ('Image inspect' openImageInspector )
+ ('show file differences' openDiffView )
+ ('terminal' openTerminal )
).
- subSelectors := #(
- openChangesBrowser
- openEditor
- openHTMLReader
- openImageInspector
- openDiffView
- openTerminal
- ).
-
JavaInterpreter notNil ifTrue:[
- subLabels := subLabels , #('Java Applet Viewer').
- subSelectors := subSelectors , #(openAppletViewer).
+ items := items , #( ('Java Applet Viewer' openAppletViewer)).
].
m subMenuAt:#stxTools
put:(PopUpMenu
- labels:(resources array:subLabels)
- selectors:subSelectors
- receiver:self).
-
- ((sel := fileListView selection) isNil or:[sel isEmpty]) ifTrue:[
+ itemList:items
+ resources:resources).
+
+ ((sel := fileListView selection) isNil
+ or:[sel isEmpty]) ifTrue:[
m disableAll:#(fileGet fileInsert
fileGetInfo fileGetLongInfo
fileFileIn fileFileInLazy
@@ -803,7 +746,7 @@
^m
"Modified: / 16.1.1998 / 16:42:59 / stefan"
- "Modified: / 20.7.1998 / 18:17:18 / cg"
+ "Modified: / 21.7.1998 / 12:55:49 / cg"
!
filePrint
@@ -972,9 +915,22 @@
openDiffView
"open a diff-view"
- |box name1 name2 text1 text2 d err nm here l1|
-
- name1 := ValueHolder newString.
+ |sel box orgName1 name1 name2 text1 text2 f d err nm here l1|
+
+ sel := self getSelectedFileName.
+
+ orgName1 := ''.
+ (sel size > 0
+ and:[lastFileDiffDirectory notNil
+ and:[lastFileDiffDirectory asFilename isDirectory]]) ifTrue:[
+ f := lastFileDiffDirectory asFilename construct:sel.
+ (f exists
+ and:[f isReadable]) ifTrue:[
+ orgName1 := f name
+ ]
+ ].
+
+ name1 := orgName1 asValue.
name2 := self getSelectedFileName asValue.
here := currentDirectory pathName.
@@ -1024,6 +980,9 @@
].
self withWaitCursorDo:[
+ name1 name ~= orgName1 ifTrue:[
+ lastFileDiffDirectory := name1 directoryName
+ ].
name1 notNil ifTrue:[
text1 := name1 contents.
].
@@ -1041,7 +1000,7 @@
"Created: / 7.12.1995 / 20:33:58 / cg"
"Modified: / 18.9.1997 / 17:31:46 / stefan"
- "Modified: / 21.7.1998 / 11:46:02 / cg"
+ "Modified: / 21.7.1998 / 12:19:54 / cg"
!
openEditor
@@ -1670,71 +1629,64 @@
<resource: #programMenu>
- |labels selectors args menu|
-
- labels := #(
- 'copy path'
- '-'
- 'up'
- 'back'
- 'change to home-directory'
- 'change to default-directory'
- 'change directory ...'
- ).
-
- selectors := #(
- copyPath
- nil
- changeToParentDirectory
- changeToPreviousDirectory
- changeToHomeDirectory
- changeToDefaultDirectory
- changeCurrentDirectory
- ).
+ |items menu|
+
+ items := #(
+ ('copy path' copyPath )
+ ('-' )
+ ('up' changeToParentDirectory )
+ ('back' changeToPreviousDirectory )
+ ('change to home-directory' changeToHomeDirectory )
+ ('change to default-directory' changeToDefaultDirectory )
+ ('change directory ...' changeCurrentDirectory )
+ ).
(JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
- labels := labels , #('-' 'add to JavaClassPath' 'add to JavaSourcePath' 'remove from JavaClassPath' 'remove from JavaSourcePath').
- selectors := selectors , #(nil #addDirToJavaClassPath #addDirToJavaSourcePath #removeDirFromJavaClassPath #removeDirFromJavaSourcePath).
+ items := items , #(
+ ( '-')
+ ( 'add to JavaClassPath' addDirToJavaClassPath)
+ ( 'add to JavaSourcePath' addDirToJavaSourcePath)
+ ( 'remove from JavaClassPath' removeDirFromJavaClassPath)
+ ( 'remove from JavaSourcePath' removeDirFromJavaSourcePath)
+ ).
].
- args := Array new:(labels size).
-
DirectoryHistory size > 0 ifTrue:[
- labels := labels copyWith:'-'.
- selectors := selectors copyWith:nil.
- args := args copyWith:nil.
-
- DirectoryHistory do:[:dirName |
- labels := labels copyWith:dirName.
- selectors := selectors copyWith:#changeDirectoryTo:.
- args := args copyWith:dirName
- ]
+ items := items copyWith:#('-').
+ items := items ,
+ (DirectoryHistory
+ collect:[:dirName |
+ Array
+ with:dirName
+ with:#changeDirectoryTo:
+ with:nil
+ with:dirName
+ ]
+ ).
].
menu := PopUpMenu
- labels:(resources array:labels)
- selectors:selectors
- args:args
- receiver:self.
+ itemList:items
+ resources:resources.
previousDirectory isNil ifTrue:[
- menu disable:#changeToPreviousDirectory.
+ menu disable:#changeToPreviousDirectory.
].
(JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
- (Java classPath includes:currentDirectory pathName) ifTrue:[
- menu disable:#addDirToJavaClassPath
- ] ifFalse:[
- menu disable:#removeDirFromJavaClassPath
- ].
- (Java sourcePath includes:currentDirectory pathName) ifTrue:[
- menu disable:#addDirToJavaSourcePath
- ] ifFalse:[
- menu disable:#removeDirFromJavaSourcePath
- ].
+ (Java classPath includes:currentDirectory pathName) ifTrue:[
+ menu disable:#addDirToJavaClassPath
+ ] ifFalse:[
+ menu disable:#removeDirFromJavaClassPath
+ ].
+ (Java sourcePath includes:currentDirectory pathName) ifTrue:[
+ menu disable:#addDirToJavaSourcePath
+ ] ifFalse:[
+ menu disable:#removeDirFromJavaSourcePath
+ ].
].
^menu.
- "Modified: / 17.1.1998 / 10:49:16 / cg"
+ "Modified: / 21.7.1998 / 13:05:42 / cg"
!
pathChanged:newPath
@@ -4080,5 +4032,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.231 1998-07-21 09:50:14 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/Attic/FBrowser.st,v 1.232 1998-07-21 11:08:19 cg Exp $'
! !
--- a/FileBrowser.st Tue Jul 21 11:50:14 1998 +0200
+++ b/FileBrowser.st Tue Jul 21 13:08:19 1998 +0200
@@ -16,7 +16,8 @@
showDotFiles myName killButton pauseToggle compressTabs
lockUpdate previousDirectory currentFileName timeOfFileRead
tabSpec commandView commandIndex fileEncoding tabRulerView
- scrollView icons listUpdateProcess currentFileInFileName'
+ scrollView icons listUpdateProcess currentFileInFileName
+ lastFileDiffDirectory'
classVariableNames:'DirectoryHistory DirectoryHistoryWhere HistorySize DefaultIcon
CommandHistory CommandHistorySize Icons DefaultCommandPerSuffix'
poolDictionaries:''
@@ -659,97 +660,49 @@
<resource: #programMenu>
- |labels shorties selectors m sel ns subLabels subSelectors|
-
- labels := #(
- 'spawn'
- '-'
- 'get contents'
- 'insert contents'
- 'show info'
- 'show full info'
+ |items m sel ns subMenu subItems|
+
+ items := #(
+ ('spawn' fileSpawn )
+ ('-' nil )
+ ('get contents' fileGet GotoLine)
+ ('insert contents' fileInsert )
+ ('show info' fileGetInfo InspectIt)
+ ('show full info' fileGetLongInfo CmdI)
).
((ns := Project current defaultNameSpace) notNil
and:[ns ~~ Smalltalk]) ifTrue:[
- labels := labels copyWith:(resources string:'fileIn (into ''%1'')' with:(Project current defaultNameSpace name))
+ items := items copyWith:(Array
+ with:(resources string:'fileIn (into ''%1'')' with:(Project current defaultNameSpace name))
+ with:#fileFileIn
+ with:#Accept)
+
] ifFalse:[
- labels := labels copyWith:'fileIn'
+ items := items copyWith:#( 'fileIn' #fileFileIn #Accept)
].
- labels := labels , #(
- '-'
- 'update'
- '-'
- 'execute unix command ...'
- 'st/x tools'
- '-'
- 'remove'
- 'rename ...'
- '-'
- 'display long list'
- 'show all files'
- 'encoding ...'
- '-'
- 'create directory ...'
- 'create file ...'
+ items := items , #(
+ ('-' )
+ ('update' updateCurrentDirectory Cmdu)
+ ('-' )
+ ('execute unix command ...' fileExecute DoIt)
+ ('st/x tools' stxTools )
+ ('-' )
+ ('remove' fileRemove Delete)
+ ('rename ...' fileRename )
+ ('-' )
+ ('display long list' changeDisplayMode )
+ ('show all files' changeDotFileVisibility )
+ ('encoding ...' fileEncoding )
+ ('-' )
+ ('create directory ...' newDirectory CmdD)
+ ('create file ...' newFile CmdF)
).
- selectors := #(
- fileSpawn
- nil
- fileGet
- fileInsert
- fileGetInfo
- fileGetLongInfo
- fileFileIn
- nil
- updateCurrentDirectory
- nil
- fileExecute
- stxTools
- nil
- fileRemove
- fileRename
- nil
- changeDisplayMode
- changeDotFileVisibility
- fileEncoding
- nil
- newDirectory
- newFile
- ).
-
- shorties := #(
- nil
- nil
- GotoLine
- nil
- InspectIt
- CmdI
- Accept
- nil
- Cmdu
- nil
- DoIt
- nil
- nil
- Delete
- nil
- nil
- nil
- nil
- nil
- nil
- CmdD
- CmdF
- ).
-
m := PopUpMenu
- labels:(resources array:labels)
- selectors:selectors
- accelerators:shorties
- receiver:self.
+ itemList:items
+ resources:resources.
showDotFiles ifTrue:[
m labelAt:#changeDotFileVisibility put:(resources string:'hide hidden files')
@@ -758,36 +711,26 @@
m labelAt:#changeDisplayMode put:(resources string:'display short list')
].
- subLabels := #(
- 'Changes browser'
- 'Editor'
- 'HTML reader'
- 'Image inspect'
- 'show file differences'
- 'terminal'
+ items := #(
+ ('Changes browser' openChangesBrowser )
+ ('Editor' openEditor )
+ ('HTML reader' openHTMLReader )
+ ('Image inspect' openImageInspector )
+ ('show file differences' openDiffView )
+ ('terminal' openTerminal )
).
- subSelectors := #(
- openChangesBrowser
- openEditor
- openHTMLReader
- openImageInspector
- openDiffView
- openTerminal
- ).
-
JavaInterpreter notNil ifTrue:[
- subLabels := subLabels , #('Java Applet Viewer').
- subSelectors := subSelectors , #(openAppletViewer).
+ items := items , #( ('Java Applet Viewer' openAppletViewer)).
].
m subMenuAt:#stxTools
put:(PopUpMenu
- labels:(resources array:subLabels)
- selectors:subSelectors
- receiver:self).
-
- ((sel := fileListView selection) isNil or:[sel isEmpty]) ifTrue:[
+ itemList:items
+ resources:resources).
+
+ ((sel := fileListView selection) isNil
+ or:[sel isEmpty]) ifTrue:[
m disableAll:#(fileGet fileInsert
fileGetInfo fileGetLongInfo
fileFileIn fileFileInLazy
@@ -803,7 +746,7 @@
^m
"Modified: / 16.1.1998 / 16:42:59 / stefan"
- "Modified: / 20.7.1998 / 18:17:18 / cg"
+ "Modified: / 21.7.1998 / 12:55:49 / cg"
!
filePrint
@@ -972,9 +915,22 @@
openDiffView
"open a diff-view"
- |box name1 name2 text1 text2 d err nm here l1|
-
- name1 := ValueHolder newString.
+ |sel box orgName1 name1 name2 text1 text2 f d err nm here l1|
+
+ sel := self getSelectedFileName.
+
+ orgName1 := ''.
+ (sel size > 0
+ and:[lastFileDiffDirectory notNil
+ and:[lastFileDiffDirectory asFilename isDirectory]]) ifTrue:[
+ f := lastFileDiffDirectory asFilename construct:sel.
+ (f exists
+ and:[f isReadable]) ifTrue:[
+ orgName1 := f name
+ ]
+ ].
+
+ name1 := orgName1 asValue.
name2 := self getSelectedFileName asValue.
here := currentDirectory pathName.
@@ -1024,6 +980,9 @@
].
self withWaitCursorDo:[
+ name1 name ~= orgName1 ifTrue:[
+ lastFileDiffDirectory := name1 directoryName
+ ].
name1 notNil ifTrue:[
text1 := name1 contents.
].
@@ -1041,7 +1000,7 @@
"Created: / 7.12.1995 / 20:33:58 / cg"
"Modified: / 18.9.1997 / 17:31:46 / stefan"
- "Modified: / 21.7.1998 / 11:46:02 / cg"
+ "Modified: / 21.7.1998 / 12:19:54 / cg"
!
openEditor
@@ -1670,71 +1629,64 @@
<resource: #programMenu>
- |labels selectors args menu|
-
- labels := #(
- 'copy path'
- '-'
- 'up'
- 'back'
- 'change to home-directory'
- 'change to default-directory'
- 'change directory ...'
- ).
-
- selectors := #(
- copyPath
- nil
- changeToParentDirectory
- changeToPreviousDirectory
- changeToHomeDirectory
- changeToDefaultDirectory
- changeCurrentDirectory
- ).
+ |items menu|
+
+ items := #(
+ ('copy path' copyPath )
+ ('-' )
+ ('up' changeToParentDirectory )
+ ('back' changeToPreviousDirectory )
+ ('change to home-directory' changeToHomeDirectory )
+ ('change to default-directory' changeToDefaultDirectory )
+ ('change directory ...' changeCurrentDirectory )
+ ).
(JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
- labels := labels , #('-' 'add to JavaClassPath' 'add to JavaSourcePath' 'remove from JavaClassPath' 'remove from JavaSourcePath').
- selectors := selectors , #(nil #addDirToJavaClassPath #addDirToJavaSourcePath #removeDirFromJavaClassPath #removeDirFromJavaSourcePath).
+ items := items , #(
+ ( '-')
+ ( 'add to JavaClassPath' addDirToJavaClassPath)
+ ( 'add to JavaSourcePath' addDirToJavaSourcePath)
+ ( 'remove from JavaClassPath' removeDirFromJavaClassPath)
+ ( 'remove from JavaSourcePath' removeDirFromJavaSourcePath)
+ ).
].
- args := Array new:(labels size).
-
DirectoryHistory size > 0 ifTrue:[
- labels := labels copyWith:'-'.
- selectors := selectors copyWith:nil.
- args := args copyWith:nil.
-
- DirectoryHistory do:[:dirName |
- labels := labels copyWith:dirName.
- selectors := selectors copyWith:#changeDirectoryTo:.
- args := args copyWith:dirName
- ]
+ items := items copyWith:#('-').
+ items := items ,
+ (DirectoryHistory
+ collect:[:dirName |
+ Array
+ with:dirName
+ with:#changeDirectoryTo:
+ with:nil
+ with:dirName
+ ]
+ ).
].
menu := PopUpMenu
- labels:(resources array:labels)
- selectors:selectors
- args:args
- receiver:self.
+ itemList:items
+ resources:resources.
previousDirectory isNil ifTrue:[
- menu disable:#changeToPreviousDirectory.
+ menu disable:#changeToPreviousDirectory.
].
(JavaClassReader notNil and:[JavaClassReader isLoaded]) ifTrue:[
- (Java classPath includes:currentDirectory pathName) ifTrue:[
- menu disable:#addDirToJavaClassPath
- ] ifFalse:[
- menu disable:#removeDirFromJavaClassPath
- ].
- (Java sourcePath includes:currentDirectory pathName) ifTrue:[
- menu disable:#addDirToJavaSourcePath
- ] ifFalse:[
- menu disable:#removeDirFromJavaSourcePath
- ].
+ (Java classPath includes:currentDirectory pathName) ifTrue:[
+ menu disable:#addDirToJavaClassPath
+ ] ifFalse:[
+ menu disable:#removeDirFromJavaClassPath
+ ].
+ (Java sourcePath includes:currentDirectory pathName) ifTrue:[
+ menu disable:#addDirToJavaSourcePath
+ ] ifFalse:[
+ menu disable:#removeDirFromJavaSourcePath
+ ].
].
^menu.
- "Modified: / 17.1.1998 / 10:49:16 / cg"
+ "Modified: / 21.7.1998 / 13:05:42 / cg"
!
pathChanged:newPath
@@ -4080,5 +4032,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.231 1998-07-21 09:50:14 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.232 1998-07-21 11:08:19 cg Exp $'
! !