# HG changeset patch # User Claus Gittinger # Date 1049790043 -7200 # Node ID 2fb9c342be6fbbda52a6a7dd8b357ccd46bcf986 # Parent 238d5e783f5cdd5af98a5dded96e8ee2a0c3e535 checkin from browser diff -r 238d5e783f5c -r 2fb9c342be6f WorkspaceApplication.st --- a/WorkspaceApplication.st Tue Apr 08 09:25:04 2003 +0200 +++ b/WorkspaceApplication.st Tue Apr 08 10:20:43 2003 +0200 @@ -205,6 +205,21 @@ #translateLabel: true ) #(#MenuItem + #enabled: #hasHistory + #label: 'Paste Last' + #itemValue: #pasteLastDoIt + #translateLabel: true + #submenuChannel: #pasteRecentDoItMenu + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'Select All' + #itemValue: #selectAll + #translateLabel: true + ) + #(#MenuItem #label: '-' ) #(#MenuItem @@ -311,23 +326,6 @@ nil ) ) - #(#MenuItem - #label: '-' - ) - #(#MenuItem - #enabled: #hasHistory - #label: 'Redo Last' - #itemValue: #redoLastDoIt - #translateLabel: true - #submenuChannel: #redoRecentDoItMenu - ) - #(#MenuItem - #enabled: #hasHistory - #label: 'Paste Last' - #itemValue: #pasteLastDoIt - #translateLabel: true - #submenuChannel: #pasteRecentDoItMenu - ) ) nil nil @@ -432,6 +430,16 @@ #label: '-' ) #(#MenuItem + #enabled: #hasHistory + #label: 'Redo Last' + #itemValue: #redoLastDoIt + #translateLabel: true + #submenuChannel: #redoRecentDoItMenu + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem #enabled: #hasSelectionInActiveWorkspace #label: 'TimeIt' #itemValue: #timeIt @@ -933,12 +941,6 @@ ]. ! -babelFishTranslate:fromToModeString - "translate the selected text and paste it after the selection" - - self selectedWorkspace babelFishTranslate:fromToModeString -! - basicInspectIt self inspectIt:true ! @@ -959,86 +961,10 @@ Workspace clearDoItHistory ! -copySelection - self selectedWorkspacesTextView copySelection -! - -cutSelection - self selectedWorkspacesTextView cutSelection -! - doIt self selectedWorkspacesTextView doIt ! -filterText - |template filterBlock newList oldList answer nDeleted deletedLines| - - template := -'"/ general text filter; -"/ the following block should evaluate to true for all lines -"/ you want to keep - lines for which the block returns false will be removed. -"/ Beginner warning: Smalltalk know-how is useful here. - -[:line | - "/ any condition on line. - "/ Notice, that line might be a Text object (i.e. non-string), - "/ so you may want to use line string. - "/ - "/ Useful queries on the line are: - "/ - size the length of the line - "/ - hasChangeOfEmphasis any bold, italic etc. - "/ - startsWith:someString - "/ - endsWith:someString - - "/ example filter (removes all empty lines) - "/ - "/ line size > 0 - - "/ example filter (removes all lines which do not end with some suffix) - "/ - "/ (line asLowercase endsWith:''foo'') not - - "/ dummy filter (keeps all lines) - "/ - true -] -'. - - filterBlock := self askForFilterBlock:'Filter block:' - template:template - rememberIn:#LastFilterBlockString. - filterBlock isNil ifTrue:[^ self]. - - oldList := self selectedWorkspacesTextView list. - oldList := oldList collect:[:lineOrNil | lineOrNil ? '']. - newList := oldList select:filterBlock. - newList := newList collect:[:line | (line isString and:[line size == 0]) ifTrue:[nil] ifFalse:[line]]. - nDeleted := oldList size - newList size. - nDeleted == 0 ifTrue:[ - self information:'No lines were deleted.'. - ^ self - ]. - - answer := Dialog confirmWithCancel:(resources - string:'%1 lines remain (%2 deleted). Change text ?' - with:newList size - with:nDeleted) - labels:#( 'Cancel' 'No, Show Deleted' 'Yes'). - answer isNil ifTrue:[^ self]. - answer ifFalse:[ - deletedLines := oldList reject:filterBlock. - TextBox openOn:(deletedLines asStringCollection) title:'Filtered lines'. - ^ self. - ]. - - self selectedWorkspacesTextView list:newList. -! - -googleSpellingSuggestion - self selectedWorkspacesTextView googleSpellingSuggestion -! - inspectIt self inspectIt:false ! @@ -1139,28 +1065,11 @@ self openHTMLDocument: 'tools/misc/TOP.html#WORKSPACE' ! -paste - self selectedWorkspacesTextView paste -! - -paste:aString - self selectedWorkspacesTextView paste:aString. -! - pasteAndExecute:aString self paste:aString. self printIt ! -pasteLastDoIt - |s| - - s := self lastDoItsString. - s notNil ifTrue:[ - self paste:s - ] -! - printIt self selectedWorkspacesTextView printIt ! @@ -1386,6 +1295,111 @@ self selectedWorkspacesTextView timeIt ! ! +!WorkspaceApplication methodsFor:'menu-actions-editing'! + +babelFishTranslate:fromToModeString + "translate the selected text and paste it after the selection" + + self selectedWorkspace babelFishTranslate:fromToModeString +! + +copySelection + self selectedWorkspacesTextView copySelection +! + +cutSelection + self selectedWorkspacesTextView cutSelection +! + +filterText + |template filterBlock newList oldList answer nDeleted deletedLines| + + template := +'"/ general text filter; +"/ the following block should evaluate to true for all lines +"/ you want to keep - lines for which the block returns false will be removed. +"/ Beginner warning: Smalltalk know-how is useful here. + +[:line | + "/ any condition on line. + "/ Notice, that line might be a Text object (i.e. non-string), + "/ so you may want to use line string. + "/ + "/ Useful queries on the line are: + "/ - size the length of the line + "/ - hasChangeOfEmphasis any bold, italic etc. + "/ - startsWith:someString + "/ - endsWith:someString + + "/ example filter (removes all empty lines) + "/ + "/ line size > 0 + + "/ example filter (removes all lines which do not end with some suffix) + "/ + "/ (line asLowercase endsWith:''foo'') not + + "/ dummy filter (keeps all lines) + "/ + true +] +'. + + filterBlock := self askForFilterBlock:'Filter block:' + template:template + rememberIn:#LastFilterBlockString. + filterBlock isNil ifTrue:[^ self]. + + oldList := self selectedWorkspacesTextView list. + oldList := oldList collect:[:lineOrNil | lineOrNil ? '']. + newList := oldList select:filterBlock. + newList := newList collect:[:line | (line isString and:[line size == 0]) ifTrue:[nil] ifFalse:[line]]. + nDeleted := oldList size - newList size. + nDeleted == 0 ifTrue:[ + self information:'No lines were deleted.'. + ^ self + ]. + + answer := Dialog confirmWithCancel:(resources + string:'%1 lines remain (%2 deleted). Change text ?' + with:newList size + with:nDeleted) + labels:#( 'Cancel' 'No, Show Deleted' 'Yes'). + answer isNil ifTrue:[^ self]. + answer ifFalse:[ + deletedLines := oldList reject:filterBlock. + TextBox openOn:(deletedLines asStringCollection) title:'Filtered lines'. + ^ self. + ]. + + self selectedWorkspacesTextView list:newList. +! + +googleSpellingSuggestion + self selectedWorkspacesTextView googleSpellingSuggestion +! + +paste + self selectedWorkspacesTextView paste +! + +paste:aString + self selectedWorkspacesTextView paste:aString. +! + +pasteLastDoIt + |s| + + s := self lastDoItsString. + s notNil ifTrue:[ + self paste:s + ] +! + +selectAll + self selectedWorkspacesTextView selectAll. +! ! + !WorkspaceApplication methodsFor:'menu-dynamic'! pasteRecentDoItMenu @@ -1570,5 +1584,5 @@ !WorkspaceApplication class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.59 2003-02-25 14:43:00 cg Exp $' + ^ '$Header: /cvs/stx/stx/libtool/WorkspaceApplication.st,v 1.60 2003-04-08 08:20:43 cg Exp $' ! !