From VisualWorks®, 7.6 of February 8, 2008 on March 3, 2008 at 9:41:46 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <name>VisitedHyperlinks</name> <environment>Core.CharacterArray</environment> <private>false</private> <constant>false</constant> <category>visited links</category> <initializer>Set new</initializer> <attributes> <package>ExternalWebBrowser-Text</package> </attributes> <methods> UI.Cursor class <category>constants</category>
pendingHyperlink ^self fingerPointer
</methods> <methods> Graphics.CharacterAttributes class <category>accessing</category>
hrefColor: aString ^aString isVisitedHyperlink ifTrue: [ColorValue purple] ifFalse: [ColorValue blue]
</methods> <methods> UI.ParagraphEditor <category>event driven</category>
exitEvent: anEvent "Make sure we restore the cursor and remove temporary underlining if need be." self text exciseAnyPendingLinkEmphases ifTrue: [self view simpleRedisplay]. Cursor normal show. super exitEvent: anEvent
hrefAtEvent: anEvent "Find whether the emphases at anEvent includes an #href association, and if so return it." | point characterBlock index emphasis | point := self sensor cursorPointFor: anEvent. characterBlock := view characterBlockAtPoint: point. index := characterBlock stringIndex. (index between: 1 and: self text size) ifFalse: [^nil]. (self isLineBreakCharacterBlock: characterBlock) ifTrue: [^nil]. emphasis := self text emphasisAt: index. ((emphasis isKindOf: Association) and: [emphasis key = #href]) ifTrue: [^emphasis]. (emphasis isKindOf: Array) ifFalse: [^nil]. ^emphasis detect: [:each | (each isKindOf: Association) and: [each key = #href]] ifNone: [nil]
isLineBreakCharacterBlock: aCharacterBlock "When line wrapping occurs, it inserts character blocks for characters that aren't really there, but the index points to the next element, we have to make sure we're not over one of those." | index | index := aCharacterBlock stringIndex. ^(self text at: index) ~= aCharacterBlock character
</methods> <methods> UI.ParagraphEditor <category>events</category>
mouseMovedEvent: anEvent "Each time we move the mouse, update the cursor if we're over an href link. Also note whether styling changes took place in the text and redisplay if necessary." | updateNeeded | (self hrefAtEvent: anEvent) ifNotNil: [:hrefEmphasis | Cursor pendingHyperlink show. updateNeeded := self text assurePendingLinkEmphasesAlong: hrefEmphasis] ifNil: [Cursor normal show. updateNeeded := self text exciseAnyPendingLinkEmphases]. updateNeeded ifTrue: [self view simpleRedisplay]
redButtonReleasedEvent: anEvent self hasRangeSelection ifTrue: [^self]. #{ExternalWebBrowser} ifDefinedDo: [:webBrowserInterface | (self hrefAtEvent: anEvent) ifNotNil: [:hrefEmphasis | | link | link := hrefEmphasis value. link rememberHyperlinkVisit. self view simpleRedisplay. webBrowserInterface open: link]]. super redButtonReleasedEvent: anEvent
</methods> <methods> UI.TextSelectionTracker <category>events</category>
redButtonReleasedEvent: aMouseButtonEvent super redButtonReleasedEvent: aMouseButtonEvent. controller redButtonReleasedEvent: aMouseButtonEvent
</methods> <methods> Core.PeekableStream <category>accessing</category>
skipWhile: aTestBlock [self atEnd or: [(aTestBlock value: self peek) not]] whileFalse: [self next]
</methods> <methods> Core.Text <category>accessing</category>
addHrefLink: aLink from: start to: stop self addEmphasis: (Array with: #href -> aLink) removeEmphasis: nil allowDuplicates: false from: start to: stop
addHrefLinkFrom: start to: stop self addHrefLink: (self copyFrom: start to: stop) asString from: start to: stop
addHyperlinkEmphases "This API is deprecated." ^self styleEmbeddedHttps
assurePendingLinkEmphasesAlong: anEmphasis "Place a #temporaryUnderline in parallel to anEmphasis, return true if that indeed happens." | added | added := false. runs := runs collect: [:each | (each isKindOf: Array) ifTrue: [((each includes: anEmphasis) and: [(each includes: #temporaryUnderline) not]) ifTrue: [added := true. each copyWith: #temporaryUnderline] ifFalse: [each]] ifFalse: [each = anEmphasis ifTrue: [added := true. Array with: each with: #temporaryUnderline] ifFalse: [each]]]. ^added
exciseAnyPendingLinkEmphases "We exploit the fact that we know it has to show up next to an href in an array of emphases. Return whether we actually made any changes or not." | removed | removed := false. runs := runs collect: [:each | (each isKindOf: Array) ifTrue: [(each includes: #temporaryUnderline) ifTrue: [| replacement | removed := true. replacement := each copyWithout: #temporaryUnderline. replacement size = 1 ifTrue: [replacement first] ifFalse: [replacement]] ifFalse: [each]] ifFalse: [each]]. ^removed
styleEmbeddedHttps | stream start stop | stream := string readStream. [stream atEnd] whileFalse: [stream skipThroughAll: 'http://'. stream atEnd ifFalse: [start := stream position. stream skipWhile: [:char | char isAlphaNumeric or: ['-_.!~*''():@&=+$,;/?:@&=+$,#' includes: char]]. ['.)?!' includes: (string at: stream position)] whileTrue: [stream skip: -1]. stop := stream position. stop > start ifTrue: [self addHrefLinkFrom: start - 6 to: stop]]]
</methods> <methods> Core.CharacterArray <category>testing</category>
isVisitedHyperlink "Keep track of the reciever as a link that has been 'visited' in the hyperlink sense." ^VisitedHyperlinks includes: self asString
</methods> <methods> Core.CharacterArray <category>accessing</category>
rememberHyperlinkVisit VisitedHyperlinks add: self asString
</methods> <methods> Core.RunArray <category>enumerating</category>
collect: aBlock "Assume that the result is to have the same run layout as the reciever and visit the value for each span only once." ^self class runs: runs copy values: (values collect: aBlock)
</methods> <methods> Graphics.CharacterAttributes class <category>class initialization</category>
addHyperlinkStyles: aDictionary <stylesWithOrder: 10> aDictionary at: #href put: [:query :value | query boldness: 1.0. query color: (self hrefColor: value)]. aDictionary at: #temporaryUnderline put: [:query | query underline: true]
</methods> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>TextSelectionTracker</name> <environment>UI</environment> <super>UI.ScrollingTracker</super> <private>false</private> none pivotBlock currentBlock nextBlock showingCaret gc prevStartBlock prevStopBlock <imports></imports> <category>Interface-Events-Trackers</category> <attributes> <package>Interface-Events-Trackers</package> </attributes> </class> <class> <name>CharacterArray</name> <environment>Core</environment> <super>Core.ArrayedCollection</super> <private>false</private> none <imports></imports> <category>Collections-Text</category> <attributes> <package>Collections-Text</package> </attributes> </class> <class> <name>Text</name> <environment>Core</environment> <super>Core.CharacterArray</super> <private>false</private> none string runs <imports> private Graphics.TextConstants.* </imports> <category>Collections-Text</category> <attributes> <package>Collections-Text</package> </attributes> </class> <class> <name>ParagraphEditor</name> <environment>UI</environment> <super>UI.ControllerWithMenu</super> <private>false</private> none beginTypeInIndex anchorIndex emphasisHere dispatchTable charComposer textHasChanged feelPolicy supportCodeEditingFeels localMenuItems extendingDown <imports> private Graphics.TextConstants.* </imports> <category>UIBasics-Support</category> <attributes> <package>UIBasics-Support</package> </attributes> </class> <class> <name>PeekableStream</name> <environment>Core</environment> <super>Core.Stream</super> <private>false</private> none <imports></imports> <category>Collections-Streams</category> <attributes> <package>Collections-Streams</package> </attributes> </class> <class> <name>RunArray</name> <environment>Core</environment> <super>Core.ArrayedCollection</super> <private>false</private> none runs values cacheRun cacheRunStart <imports></imports> <category>Collections-Arrayed</category> <attributes> <package>Collections-Arrayed</package> </attributes> </class>