'From VisualWorks(R) Release 2.0 of 4 August 1994 on 22 June 1995 at 7:47:49 pm'! !StateEntRef methodsFor: 'accessing'! handle "Handles an entity, until aCharacter is not alphanumeric. If a space is encountered before a ';', that means the document is not a correct HTML 1.0 document. Just treat all the char in buffer as text." | aChar | buffer isEmpty ifTrue: [ self appendLocalBuffer: scanner hereChar]. self getAnyChar. scanner hereChar = $; ifTrue: [ self changeState: StateText. aChar := scanner dtd atEntity: self buffer asLowercase asSymbol. aChar isNil ifTrue: [^self]. ^scanner appendBuffer: aChar]. scanner hereChar = Character space ifTrue: [self changeState: StateText. scanner appendBuffer: $&. self buffer do: [:each | scanner appendBuffer: each]. scanner appendBuffer: scanner hereChar]. ^self appendLocalBuffer: scanner hereChar! ! !SMWeb methodsFor: 'accessing'! inputStream: aBinaryStream | filter header viewer | header := self retrieveResponseHeaderFor: model from: aBinaryStream. (self isResponseOK: header) ifFalse: [^self putNilOutStream]. "filter isNil ifTrue: [^self putNilOutStream]." viewer := self initViewer: header. self spawn & viewer notNil ifTrue: [self view: aBinaryStream by: viewer] ifFalse: [filter := self initFilter: header. self process: aBinaryStream by: filter]. self broadcastForCache: header! ! !StateTag methodsFor: 'accessing'! handle "A < was read. Accumulate the first word as the tag." | tag element | self getNextUsefulChar. scanner hereChar isAlphaNumeric ifTrue: [^scanner appendHereCharToBuffer]. scanner hereChar = $> ifTrue: [tag := scanner buffer asUppercase. ^self selectState: tag]. element := scanner atElement: scanner buffer. element isNil ifTrue: [^self changeState: StateJunkTag] ifFalse: [self changeState: StateTagGap. ^scanner endOneBlockWithType: #tag value: scanner buffer asLowercase]! ! !ResponseHeader methodsFor: 'accessing'! attributes ^attributes! ! RecursiveComposite comment: 'RecursiveComposite overwrites the hitDetect: method of its superclass. Instead of returning an immediate child from hiDetect:, RecursiveComposite return the youngest generation child(leaf). '! !NetFish class methodsFor: 'examples'! example1 "You need to modify the tmp directory. Temporary files will be written in the temp directory you supply. These files are deleted when you exit Netfish through the File|exit menu. You may also want to use another homepage of your preference." "Other url you may want to try are file://.../somelocalfilename http://st-www.cs.uiuc.edu/users/mchung/mcheung05.gif http://st-www.cs.uiuc.edu/users/mchung/test.mchung" "NetFish example1" | browser | browser := NetFish new tmpDirName: '/tmp/'. browser homepage: 'http://st-www.cs.uiuc.edu/users/chai/research/netfish/'. NetFish openOn: browser! ! !RenderPolicy methodsFor: 'private'! getEmptyBlockWithHeight: height width: width component: anObject | ctext vLink | ctext := ComposedText withText: ' ' asText style: nil compositionWidth: width. ctext compositionWidth: width; setHeight: height. vLink := self makeVisualLink: anObject visualComponent: ctext. ^self wrapperClass on: vLink! ! !ImagePolicy methodsFor: 'private'! getImage "If image is cached in the instance variable, then return it. Otherwise, check if renderer has cached it. If not, then read from filename. If there is error in reading the image from the file, then return the defaultImage." image notNil ifTrue: [^image]. filename notNil ifTrue: [image := renderer visualComponentForFile: filename. image isNil ifTrue: [image := Object errorSignal handle: [:ex | self defaultImage] do: [(ImageReader fromFile: filename) image]. self changed: #builtVisualComponent with: (OrderedCollection with: filename with: image)]. ^image]. ^self defaultImage! getImageBackup "Currently, only the ParcPlace logo is returned." image notNil ifTrue: [^image]. filename notNil ifTrue: [image := renderer visualComponentForFile: filename. image isNil ifTrue: [image := Object errorSignal handle: [:ex | self defaultImage] do: [(ImageReader fromFile: filename) image]. self changed: #builtVisualComponent with: (OrderedCollection with: filename with: image)]. ^image]. ^self defaultImage! ! !ParagraphPolicy methodsFor: 'accessing'! formatInto: aContainer | vComp | vComp := self wrapperClass on: (self getEmptyBlockWithHeight: 25 width: self maxWidth component: component). aContainer addWrapper: vComp. ^vComp! ! VisualLink comment: 'I consist of two components -- the structural component and the visual component. The visual component is responsible for the visual appearance of a VisualLink. The Structural component contains information about a VisualLink. This information can be nil or anything such as a node in the parse tree or a String. Several methods of VisualLinks are frequently used by LinkResolvers and Controllers: #visualComponent, #structuralComponent, #structualComponent:at:, #allStructuralComponents:at:. Instance Variables: structuralComponent '! !VisualLink methodsFor: 'accessing'! allStructuralComponents ^OrderedCollection with: self structuralComponent! allStructuralComponentsAt: aPoint "Return the structural component(s) at aPoint in a Collection. " ^self allStructuralComponents! ! VisualLink removeSelector: #wordAt:! VisualLink removeSelector: #infoString:! !StructuredTextLink methodsFor: 'accessing'! structuralComponentAt: aPoint "There may be more than one struucturalComponents at aPoint. Not sure which one is needed. Just return the first one. If other structuralComponents at that point is needed, #allStructuralComponentsAt: should be used." ^(self allStructuralComponentsAt: aPoint) first! ! CompositeLink comment: 'My structuralComponent is a WebComposite. I expect a RecursiveComposite as my visualComponent.'! StateCData removeSelector: #getNextUsefulChar! !HtmlParser methodsFor: 'accessing'! parse: aStream "Parse aStream and sends the output to outputStream." scanner input: aStream. [(currentToken := scanner nextToken) isNil] whileFalse: [self perform: currentToken type withArguments: #()]. self flush.! ! !HtmlParser methodsFor: 'private'! defaultOutputStream ^HyperComposite new type: #html! ! HtmlParser removeSelector: #statusline! HtmlParser removeSelector: #responseHeader! !StateEndTag methodsFor: 'accessing'! handle "'<' & '\' was read before. Accumulates the end tag." self getNextUsefulChar. scanner hereChar isAlphaNumeric ifTrue: [^scanner appendHereCharToBuffer]. scanner hereChar = $> ifTrue: [| element | element := scanner atElement: scanner buffer. element isNil ifTrue: [^self changeState: StateJunkTag]. self changeState: StateText. ^scanner endOneBlockWithType: #endTag value: scanner buffer]. self changeState: StateTagGap. ^scanner endOneBlock! ! !StateRCData methodsFor: 'accessing'! handle self getAnyChar. scanner hereChar = $< ifTrue: [^self doAfterSmallerThan]. scanner hereChar = $& ifTrue: [^self doAfterAmp]. ^scanner appendHereCharToBuffer! ! StructuredText comment: 'For hypertext application, sometimes, different portions of a Text has different meanings. For example, "

This is an example for StructuredText" In the above HTML, it is formatted into a ComposedText with the text content "This is an example for StructuredText" The tag information is gone when it is displayed. Sometimes, we may want to know whether the letter $e in ''example'' is contained in the node , and sometimes we want to know if it is contained in the node

. I am capable of storing this information just like Text stores its emphasis. For example, in the above example, I would return #( node(H1), node(B)) if I receive the message structuresAt: 13, that is the position of the character $x in the word example. For structuresAt: 2, the $h in the word ''This'', I would return#( node(H1)). node(x) means a parse tree node with type x for the sake for this discussion. Instance Varialbes: structuralRuns of anything. '! Model subclass: #HyperApp instanceVariableNames: 'inputStream linkAccessor renderer currentLink resolvers document ' classVariableNames: '' poolDictionaries: '' category: 'HyperTalk-Framework'! !WebClient methodsFor: 'accessing'! jumpTo: aHyperLink "Setup all the steps for retrieving and parsing..." | parsedStream | super jumpTo: aHyperLink. streamMgr spawn: true; link: aHyperLink; inputStream: linkAccessor outputStream. parsedStream := streamMgr outputStream. document := parsedStream. parsedStream isNil ifTrue: [self handleEmptyStream] ifFalse: [renderer inputStream: parsedStream. self changed: #currentLink with: aHyperLink. responseHeader notNil ifTrue: [document attributes: responseHeader attributes]]! ! !HyperComponent methodsFor: 'accessing'! container: anObject "anObject points to me. My subclass may want to remember that."! ! !HyperComposite methodsFor: 'accessing'! add: aHyperComponent content add: aHyperComponent. aHyperComponent container: self! ! WebComposite removeSelector: #add:!