'From Squeak3.1alpha of 28 February 2001 [latest update: #4212] on 26 July 2001 at 8:45:20 am'! "Change Set: GMailDoit-tk Date: 26 July 2001 Author: Ted Kaehler Stop a GeeMail or other text from scrolling when the user clicks in a piece of action text. Used to keep the old selection (far away) and scroll there after the action. Now simply puts the insertion point into the text, even if it has an action attribute. Made MethodLinks (available with Cmd-6) work in GeeMails. Fixed bug in Cmd-6 in the limited menu in GeeMails, Books, and Stacks."! !ParagraphEditor methodsFor: 'editing keys' stamp: 'tk 7/25/2001 14:46'! changeEmphasis: characterStream "Change the emphasis of the current selection or prepare to accept characters with the change in emphasis. Emphasis change amounts to a font change. Keeps typeahead." | keyCode attribute oldAttributes index thisSel colors extras | "control 0..9 -> 0..9" keyCode _ ('0123456789-=' indexOf: sensor keyboard ifAbsent: [1]) - 1. oldAttributes _ paragraph text attributesAt: startBlock stringIndex forStyle: paragraph textStyle. thisSel _ self selection. "Decipher keyCodes for Command 0-9..." (keyCode between: 1 and: 5) ifTrue: [attribute _ TextFontChange fontNumber: keyCode]. keyCode = 6 ifTrue: [colors _ #(black magenta red yellow green blue cyan white). extras _ ((self class name = #TextMorphEditor) and: [(self morph isKindOf: TextMorphForEditView) not]) "not a system window" ifTrue: [#()] ifFalse: [#('Link to comment of class' 'Link to definition of class' 'Link to hierarchy of class' 'Link to method')]. index _ (PopUpMenu labelArray: colors , #('choose color...' 'Do it'), extras, #('be a web URL link' 'Edit hidden info' 'Copy hidden info') lines: (Array with: colors size +1)) startUp. index = 0 ifTrue: [^ true]. index <= colors size ifTrue: [attribute _ TextColor color: (Color perform: (colors at: index))] ifFalse: [index _ index - colors size - 1. "Re-number!!!!!!" index = 0 ifTrue: [attribute _ self chooseColor]. index = 1 ifTrue: [attribute _ TextDoIt new. thisSel _ attribute analyze: self selection asString]. (extras size = 0) & (index > 1) ifTrue: [index _ index + 4]. "skip those" index = 2 ifTrue: [attribute _ TextLink new. thisSel _ attribute analyze: self selection asString with: 'Comment']. index = 3 ifTrue: [attribute _ TextLink new. thisSel _ attribute analyze: self selection asString with: 'Definition']. index = 4 ifTrue: [attribute _ TextLink new. thisSel _ attribute analyze: self selection asString with: 'Hierarchy']. index = 5 ifTrue: [attribute _ TextLink new. thisSel _ attribute analyze: self selection asString]. index = 6 ifTrue: [attribute _ TextURL new. thisSel _ attribute analyze: self selection asString]. index = 7 ifTrue: ["Edit hidden info" thisSel _ self hiddenInfo. "includes selection" attribute _ TextEmphasis normal]. index = 8 ifTrue: ["Copy hidden info" self copyHiddenInfo. ^ true]. "no other action" thisSel ifNil: [^ true]]. "Could not figure out what to link to" ]. (keyCode between: 7 and: 11) ifTrue: [sensor leftShiftDown ifTrue: [keyCode = 10 ifTrue: [attribute _ TextKern kern: -1]. keyCode = 11 ifTrue: [attribute _ TextKern kern: 1]] ifFalse: [attribute _ TextEmphasis perform: (#(bold italic narrow underlined struckOut) at: keyCode - 6). oldAttributes do: [:att | (att dominates: attribute) ifTrue: [attribute turnOff]]]]. (keyCode = 0) ifTrue: [attribute _ TextEmphasis normal]. beginTypeInBlock ~~ nil ifTrue: "only change emphasisHere while typing" [self insertTypeAhead: characterStream. emphasisHere _ Text addAttribute: attribute toArray: oldAttributes. ^ true]. self replaceSelectionWith: (thisSel asText addAttribute: attribute). ^ true! ! !TextMorphEditor methodsFor: 'events' stamp: 'tk 7/26/2001 08:02'! mouseDown: evt "An attempt to break up the old processRedButton code into threee phases" | clickPoint | oldInterval _ startBlock stringIndex to: stopBlock stringIndex - 1. clickPoint _ evt cursorPoint. (paragraph clickAt: clickPoint for: model controller: self) ifTrue: [ "oldInterval _ pivotBlock _ nil." "don't change selection based on this click" stopBlock _ startBlock _ pivotBlock _ paragraph characterBlockAtPoint: clickPoint. evt hand releaseKeyboardFocus: self. ^ self]. evt shiftPressed ifFalse: [self closeTypeIn. stopBlock _ startBlock _ pivotBlock _ paragraph characterBlockAtPoint: clickPoint] ifTrue: [(paragraph characterBlockAtPoint: clickPoint) <= startBlock ifTrue: [stopBlock _ startBlock. pivotBlock _ stopBlock] ifFalse: [startBlock _ stopBlock. pivotBlock _ startBlock]. self closeTypeIn. self mouseMove: evt]. self storeSelectionInParagraph! ! !TextPlusMorph methodsFor: 'as yet unclassified' stamp: 'tk 7/26/2001 08:44'! addItem: classAndMethod "Make a linked message list and put this method in it" Model new addItem: classAndMethod "let him do all the work"! !