The Trunk: Morphic-eem.1704.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-eem.1704.mcz

commits-2
Eliot Miranda uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-eem.1704.mcz

==================== Summary ====================

Name: Morphic-eem.1704
Author: eem
Time: 19 October 2020, 5:18:43.145396 pm
UUID: 1889aef2-4bb4-45ee-a4c9-75c721103c1e
Ancestors: Morphic-mt.1703

Integrate Javier Diaz-Reinoso's kindly contributed improvement to Workspace file editing.

=============== Diff against Morphic-mt.1703 ===============

Item was changed:
  ----- Method: TextEditor>>saveContentsInFile (in category 'menu messages') -----
  saveContentsInFile
  "Save the receiver's contents string to a file, prompting the user for a file-name.  Suggest a reasonable file-name."
 
+ | fileName stringToSave parentWindow labelToUse suggestedName dir |
- | fileName stringToSave parentWindow labelToUse suggestedName |
  stringToSave := paragraph text string.
  stringToSave size = 0 ifTrue: [^self inform: 'nothing to save.'].
  parentWindow := model dependents
  detect: [:dep | dep isKindOf: SystemWindow]
  ifNone: [nil].
+ dir := parentWindow valueOfProperty: #myDir.
+ labelToUse :=
+ parentWindow
+ ifNil: ['Untitled']
+ ifNotNil: [
+ dir  ifNil: [parentWindow label]
+ ifNotNil:[dir fullNameFor:  parentWindow label]].
- labelToUse := parentWindow ifNil: ['Untitled']
- ifNotNil: [parentWindow label].
  suggestedName := nil.
  #(#('Decompressed contents of: ' '.gz')) do:
  [:leaderTrailer | | lastIndex |
  "can add more here..."
 
  (labelToUse beginsWith: leaderTrailer first)
  ifTrue:
  [suggestedName := labelToUse copyFrom: leaderTrailer first size + 1
  to: labelToUse size.
  (labelToUse endsWith: leaderTrailer last)
  ifTrue:
  [suggestedName := suggestedName copyFrom: 1
  to: suggestedName size - leaderTrailer last size]
  ifFalse:
+ [lastIndex := suggestedName lastIndexOf: $. ifAbsent: [0].
+ (lastIndex = 0 or: [lastIndex = 1])
+ ifFalse: [suggestedName := suggestedName copyFrom: 1 to: lastIndex - 1]]]].
+ suggestedName ifNil: [suggestedName := labelToUse.
+ (labelToUse includesSubstring: '.') ifFalse: [suggestedName := suggestedName , '.text']].
+ fileName := UIManager default request: 'File name?'
- [lastIndex := suggestedName lastIndexOf: $..
- lastIndex > 1
- ifTrue: [suggestedName := suggestedName copyFrom: 1 to: lastIndex - 1]]]].
- suggestedName ifNil: [suggestedName := labelToUse , '.text'].
- fileName := UIManager default saveFilenameRequest: 'File name?'
  initialAnswer: suggestedName.
  fileName isEmptyOrNil
  ifFalse:
+ [ |ns|
+ ns := MultiByteFileStream newFileNamed: fileName.
+ ns lineEndConvention: (parentWindow valueOfProperty: #lineConversion).
+ ns nextPutAll: stringToSave;
+ close.
+ suggestedName ~= fileName ifTrue:[parentWindow label: fileName].
+   self morph hasUnacceptedEdits: false.
+ ]!
- [(FileStream newFileNamed: fileName)
- nextPutAll: stringToSave;
- close]!