Grafoscopio/src/Grafoscopio/GrafoscopioPillarTextAnnota...

66 lines
1.7 KiB
Smalltalk
Raw Normal View History

2020-03-30 17:02:46 +00:00
Class {
#name : #GrafoscopioPillarTextAnnotator,
#superclass : #PRVisitor,
#instVars : [
'texts',
2020-04-09 13:01:20 +00:00
'formatter',
'lastStop'
2020-03-30 17:02:46 +00:00
],
#category : #'Grafoscopio-Pillar'
}
{ #category : #'visiting-document' }
2020-04-09 13:01:20 +00:00
GrafoscopioPillarTextAnnotator >> formatter: aFormatter [
formatter := aFormatter
2020-03-30 17:02:46 +00:00
]
{ #category : #'visiting-document' }
2020-04-09 13:01:20 +00:00
GrafoscopioPillarTextAnnotator >> initialize [
super initialize.
texts := OrderedCollection new.
formatter := GrafoscopioTextFormatter default.
2020-03-30 17:02:46 +00:00
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitCodeblock: aTextObject [
self visitText: aTextObject
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitCommentedLine: aTextObject [
self visitText: aTextObject
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitDocument: aDoc [
lastStop := 1 .
2020-04-09 13:01:20 +00:00
aDoc accept: formatter.
2020-03-30 17:02:46 +00:00
super visitDocument: aDoc.
2020-04-12 01:00:53 +00:00
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarTextAnnotator >> visitFormatText: aGrafoscopioFormatTextNode [
" for the annotator, a format text is a much as regular text"
self visitText: aGrafoscopioFormatTextNode
2020-03-30 17:02:46 +00:00
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitLineBreak: anObject [
^ self visitText: anObject
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitRaw: aTextObject [
self visitText: aTextObject
]
{ #category : #'visiting-document' }
GrafoscopioPillarTextAnnotator >> visitText: aTextObject [
2020-04-09 13:01:20 +00:00
texts ifNotEmpty: [ texts last next: aTextObject ].
2020-03-30 17:02:46 +00:00
texts add: aTextObject.
aTextObject propertyAt: #textStart put: lastStop.
2020-04-12 01:00:53 +00:00
lastStop := lastStop + aTextObject text size.
2020-04-09 13:01:20 +00:00
aTextObject propertyAt: #textStop put: lastStop .
2020-03-30 17:02:46 +00:00
]