Levente Uzonyi uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-ul.1323.mcz ==================== Summary ==================== Name: Morphic-ul.1323 Author: ul Time: 27 February 2017, 2:19:54.493351 am UUID: 61ac3aed-c91d-455c-a890-7a5a8eeb4fb8 Ancestors: Morphic-eem.1322 - omit ifAbsent from #index* sends when the default value, 0 would used =============== Diff against Morphic-eem.1322 =============== Item was changed: ----- Method: Editor>>beginningOfParagraph: (in category 'private') ----- beginningOfParagraph: position ^ (self string lastIndexOf: Character cr + startingAt: position) + 1.! - startingAt: position - ifAbsent: [ 0 ]) + 1.! Item was changed: ----- Method: FontChooserTool>>selectedFontIndex (in category 'font list') ----- selectedFontIndex | font textStyleName family | selectedFontIndex ifNotNil: [^selectedFontIndex]. selectedFontIndex := 0. font := (getSelector isSymbol and:[target notNil]) ifTrue:[target perform: getSelector] ifFalse:[getSelector]. font ifNotNil:[ emphasis := font emphasis. pointSize := font pointSize. textStyleName := font textStyleName. family := self fontList detect:[:f | f = textStyleName] ifNone:[]. ]. + selectedFontIndex := self fontList indexOf: family. - selectedFontIndex := self fontList indexOf: family ifAbsent:[0]. self selectedFontIndex: selectedFontIndex. ^selectedFontIndex! Item was changed: ----- Method: Morph>>morphPreceding: (in category 'structure') ----- morphPreceding: aSubmorph "Answer the morph immediately preceding aSubmorph, or nil if none" + | index | + (index := submorphs indexOf: aSubmorph) > 1 ifTrue: [ + ^submorphs at: index - 1 ]. + ^nil! - | anIndex | - anIndex := submorphs indexOf: aSubmorph ifAbsent: [^ nil]. - ^ anIndex > 1 - ifTrue: - [submorphs at: (anIndex - 1)] - ifFalse: - [nil]! Item was changed: ----- Method: TextEditor>>cursorHome: (in category 'nonediting/nontyping keys') ----- cursorHome: aKeyboardEvent "Private - Move cursor from position in current line to beginning of current line. If control key is pressed put cursor at beginning of text" | string | string := paragraph text string. self moveCursor: [ :position | Preferences wordStyleCursorMovement ifTrue:[ (paragraph lines at:(paragraph lineIndexOfCharacterIndex: position)) first] ifFalse:[ (string lastIndexOfAnyOf: CharacterSet crlf + startingAt: position - 1) + 1]] - startingAt: position - 1 - ifAbsent:[0]) + 1]] forward: false event: aKeyboardEvent specialBlock: [:dummy | 1]. ^true! Item was changed: ----- Method: TextEditor>>encompassLine: (in category 'new selection') ----- encompassLine: anInterval "Return an interval that encompasses the entire line" | string left right | string := paragraph text string. + left := (string lastIndexOfAnyOf: CharacterSet crlf startingAt: anInterval first - 1) + 1. - left := (string lastIndexOfAnyOf: CharacterSet crlf startingAt: anInterval first - 1 ifAbsent:[0]) + 1. right := (string indexOfAnyOf: CharacterSet crlf startingAt: anInterval last + 1 ifAbsent: [string size + 1]) - 1. ^left to: right! Item was changed: ----- Method: TextEditor>>querySymbol: (in category 'typing/selecting keys') ----- querySymbol: aKeyboardEvent "Invoked by Ctrl-q to query the Symbol table and display alternate symbols." | hintText lastOffering offering | (self isTypingIn not or: [self history current type ~= #query]) ifTrue: [ self closeTypeIn. self openTypeIn. self selectPrecedingIdentifier. self closeTypeIn]. self openTypeInFor: #query. hintText := self history current contentsBefore string. hintText := hintText copyFrom: (hintText lastIndexOfAnyOf: Character separators, '#' + startingAt: hintText size) + 1 to: hintText size. - startingAt: hintText size ifAbsent: [0])+1 to: hintText size. self selectInvisiblyFrom: self history current intervalBefore first to: self stopIndex-1. lastOffering := self selection string. lastOffering := (lastOffering copyReplaceAll: ': ' with: ':') withBlanksTrimmed. "Only offer suggestions for not-empty tokens." hintText ifEmpty: [morph flash. self closeTypeIn. ^ true]. offering := Symbol thatStarts: hintText skipping: lastOffering. offering ifNil: [offering := Symbol thatStarts: hintText skipping: nil]. offering ifNil: [morph flash. self closeTypeIn. ^ true]. "Add some nice spacing to the suggestion." offering := offering copyReplaceAll: ':' with: ': '. offering last = Character space ifTrue: [offering := offering allButLast]. "Insert the suggestions. (Note that due to previous selection, things will be overwritten and not appended.)" self typeAhead nextPutAll: offering. ^ false! 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 | stringToSave := paragraph text string. stringToSave size = 0 ifTrue: [^self inform: 'nothing to save.']. parentWindow := model dependents detect: [:dep | dep isKindOf: SystemWindow] ifNone: [nil]. 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: $.. + lastIndex > 1 + ifTrue: [suggestedName := suggestedName copyFrom: 1 to: lastIndex - 1]]]]. - [lastIndex := suggestedName lastIndexOf: $. ifAbsent: [0]. - (lastIndex = 0 or: [lastIndex = 1]) - ifFalse: [suggestedName := suggestedName copyFrom: 1 to: lastIndex - 1]]]]. suggestedName ifNil: [suggestedName := labelToUse , '.text']. fileName := UIManager default request: 'File name?' initialAnswer: suggestedName. fileName isEmptyOrNil ifFalse: [(FileStream newFileNamed: fileName) nextPutAll: stringToSave; close]! Item was changed: ----- Method: TextMorph>>anchorMorph:at:type: (in category 'anchors') ----- anchorMorph: aMorph at: aPoint type: anchorType | relPt index newText block | aMorph owner == self ifTrue:[self removeMorph: aMorph]. aMorph textAnchorType: nil. aMorph relativeTextAnchorPosition: nil. self addMorphFront: aMorph. aMorph textAnchorType: anchorType. aMorph relativeTextAnchorPosition: nil. anchorType == #document ifTrue:[^self]. relPt := self transformFromWorld globalPointToLocal: aPoint. index := (self paragraph characterBlockAtPoint: relPt) stringIndex. newText := Text string: (String value: 1) attribute: (TextAnchor new anchoredMorph: aMorph). anchorType == #inline ifTrue:[ self paragraph replaceFrom: index to: index-1 with: newText displaying: false. ] ifFalse:[ index := index min: paragraph text size. + index := paragraph text string lastIndexOf: Character cr startingAt: index. - index := paragraph text string lastIndexOf: Character cr startingAt: index ifAbsent:[0]. block := paragraph characterBlockForIndex: index+1. aMorph relativeTextAnchorPosition: (relPt x - bounds left) @ (relPt y - block top ). self paragraph replaceFrom: index+1 to: index with: newText displaying: false. ]. self fit.! |
Free forum by Nabble | Edit this page |