--- a/TextView.st Fri Sep 01 14:24:45 2017 +0200
+++ b/TextView.st Fri Sep 01 14:30:38 2017 +0200
@@ -2104,6 +2104,57 @@
"Modified: 27.2.1996 / 00:53:51 / cg"
!
+compareAgainst:otherText named:whatIsIt
+ "common code for compate with file and compare with clipboard"
+
+ |myText|
+
+ otherText isEmptyOrNil ifTrue:[
+ Dialog information:(resources string:'%1 is empty.' with:whatIsIt).
+ ^ self.
+ ].
+
+ self hasSelection ifTrue:[
+ myText := self selectionAsString.
+ ] ifFalse:[
+ myText := self contents asString
+ ].
+ myText := myText string.
+
+ myText = otherText ifTrue:[
+ Dialog information:(resources string:'Strings are equal.').
+ ^ self.
+ ].
+ DiffTextView
+ openOn:myText label:'Editor'
+ and:otherText label:whatIsIt
+
+ "Created: / 01-09-2017 / 14:11:20 / cg"
+!
+
+compareWithClipboard
+ "compare the selection against the clipboard contents"
+
+ self compareAgainst:(self getClipboardText) named:'Clipboard'
+
+ "Modified: / 01-09-2017 / 14:11:44 / cg"
+!
+
+compareWithFile
+ "compare the selection or the whole text against the contents of a file"
+
+ |fn fileText|
+
+ fn := Dialog requestFileName:(resources string:'Compare against file:')
+ default:defaultFileNameForFileDialog.
+ fn isEmptyOrNil ifTrue:[^ self].
+
+ fileText := fn asFilename contentsOfEntireFile.
+ self compareAgainst:fileText named:'File'
+
+ "Modified: / 01-09-2017 / 14:11:15 / cg"
+!
+
copySelection
"copy contents into smalltalk copybuffer"
@@ -2280,6 +2331,37 @@
"Modified: / 30-03-2017 / 23:05:07 / stefan"
!
+openFileBrowserOnFileNamed:fileNameString
+ "open a fileBrowser on the given fileNameString"
+
+ |fn|
+
+ fn := fileNameString asFilename.
+ fn exists ifFalse:[
+ fn := fileNameString withoutSeparators withoutQuotes asFilename.
+ fn exists ifFalse:[
+ ^ self warn:(resources
+ string:'Sorry - file "%1" was not found in directory "%2"'
+ with:fn baseName allBold
+ with:fn directory baseName allBold).
+ ].
+ ].
+ FileBrowser default openOn:fn
+
+ "Modified: / 01-09-2017 / 14:03:54 / cg"
+!
+
+openFileBrowserOnIt
+ "open a fileBrowser on the selected fileName"
+
+ |fileNameString|
+
+ fileNameString := self selectionAsString.
+ self openFileBrowserOnFileNamed:fileNameString
+
+ "Modified: / 06-09-2012 / 14:47:22 / cg"
+!
+
openSaveDialog
"Ask user for filename using a fileSelectionBox
and save contents into that file."
@@ -2600,6 +2682,17 @@
"Created: / 08-03-2012 / 14:02:59 / cg"
!
+openWorkspaceWithIt
+ "open a workspace containing the selected text"
+
+ |text|
+
+ text := self selectionAsString.
+ WorkspaceApplication openWith:text selected:true
+
+ "Created: / 26-05-2007 / 06:05:22 / cg"
+!
+
replace:someText
"replace the selection by someText. I am readonly, so this is a no-op here.
Subclasses may redefine me."