228 lines
6.3 KiB
Smalltalk
228 lines
6.3 KiB
Smalltalk
Class {
|
|
#name : #GrafoscopioLine,
|
|
#superclass : #Object,
|
|
#instVars : [
|
|
'from',
|
|
'to',
|
|
'fontCode',
|
|
'lastUsedConfiguration'
|
|
],
|
|
#category : #'Grafoscopio-Rub'
|
|
}
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> baseline [
|
|
^ 10
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> bottom [
|
|
^ 10
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> bottomRight [
|
|
^ self right@ self bottom
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> configurationFor: text with: style at: lastIndex [
|
|
| attributes |
|
|
attributes := text attributesAt: lastIndex forStyle: style.
|
|
(lastUsedConfiguration isNotNil and: [lastUsedConfiguration attributes = attributes ]) ifFalse: [
|
|
lastUsedConfiguration := GrafoscopioLineConfiguration new.
|
|
lastUsedConfiguration loadDefaultsFromStyle: style and: attributes.
|
|
.
|
|
].
|
|
^ lastUsedConfiguration .
|
|
|
|
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> display: text textStyle: style on: bitBlt at: lastPos startDrawingAt: destX withBaseline: baselineY from: startIndex upTo: lastIndex [
|
|
| configuration kern font emphasisCode |
|
|
|
|
configuration := self configurationFor: text with: style at: lastIndex .
|
|
|
|
kern := configuration kern.
|
|
font := configuration font.
|
|
emphasisCode := configuration emphasisCode.
|
|
|
|
|
|
lastIndex >= startIndex
|
|
ifTrue: [ bitBlt
|
|
displayString: text string
|
|
from: startIndex
|
|
to: lastIndex
|
|
at: lastPos
|
|
kern: kern
|
|
baselineY: baselineY
|
|
font: font ].
|
|
(emphasisCode allMask: 4)
|
|
ifTrue: [ font
|
|
displayUnderlineOn: bitBlt
|
|
from: lastPos x @ baselineY
|
|
to: destX @ baselineY ].
|
|
(emphasisCode allMask: 16)
|
|
ifTrue: [ font
|
|
displayStrikeoutOn: bitBlt
|
|
from: lastPos x @ baselineY
|
|
to: destX @ baselineY ]
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> first [
|
|
^ from
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> fontCodeFor: aGrafoscopioPillarASText [
|
|
fontCode
|
|
ifNil: [ (aGrafoscopioPillarASText runs at: self first)
|
|
do: [ :d | d emphasizeScanner: self ] ].
|
|
^ fontCode
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> from: anInteger to: anInteger2 [
|
|
from := anInteger.
|
|
to := anInteger2
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> height [
|
|
^ 30
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> last [
|
|
^ to
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> left [
|
|
^ 1
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> leftMargin [
|
|
^ self left
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> leftMarginForAlignment: anInteger [
|
|
^ 1
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> lineHeight [
|
|
^ 30
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> right [
|
|
^ 10000
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> rightMargin [
|
|
^ self right
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> scanAndDrawCharactersFrom: startIndex to: stopIndex in: text rightX: rightX stopConditions: stopConditions kern: kernDelta firstDestX:d style: textStyle on: bitBlt at: lastPos withBaseline: baselineY [
|
|
|bundle lastIndex stopCondition destX |
|
|
|
|
bundle := self scanCharactersFrom: startIndex to: stopIndex
|
|
in: text rightX: rightX stopConditions: stopConditions
|
|
kern: kernDelta firstDestX:d.
|
|
|
|
lastIndex := bundle first.
|
|
stopCondition := bundle second.
|
|
destX := bundle fourth.
|
|
self display: text textStyle: textStyle on: bitBlt at: lastPos startDrawingAt: destX withBaseline: baselineY from: startIndex upTo: (stopCondition == #endOfRun ifTrue:[lastIndex] ifFalse:[lastIndex-1]) .
|
|
^ bundle
|
|
]
|
|
|
|
{ #category : #scanning }
|
|
GrafoscopioLine >> scanCharactersFrom: startIndex to: stopIndex in: text rightX: rightX stopConditions: stops kern: kernDelta firstDestX:d [
|
|
| ascii encoding f nextDestX maxAscii startEncoding floatDestX widthAndKernedWidth nextChar atEndOfRun font lastIndex pendingKernX destX spaceWidth source |
|
|
|
|
source := text string.
|
|
startIndex > stopIndex
|
|
ifTrue: [ lastIndex := stopIndex.
|
|
^ {lastIndex . stops endOfRun . 0 . d } ].
|
|
lastIndex := startIndex.
|
|
startEncoding := (source at: startIndex) leadingChar.
|
|
" font := self fontFor: text at: startIndex."
|
|
destX := d .
|
|
font ifNil: [font := TextStyle defaultFont fontArray at: 1].
|
|
font isFontSet ifTrue: [
|
|
f := [font fontArray at: startEncoding + 1]
|
|
on: Exception do: [:ex | nil].
|
|
f ifNil: [ f := font fontArray at: 1].
|
|
maxAscii := f maxAscii.
|
|
spaceWidth := f widthOf: Character space.
|
|
] ifFalse: [
|
|
maxAscii := font maxAscii.
|
|
].
|
|
floatDestX := destX.
|
|
widthAndKernedWidth := Array new: 2.
|
|
atEndOfRun := false.
|
|
[lastIndex <= stopIndex] whileTrue: [
|
|
encoding := (source at: lastIndex) leadingChar.
|
|
encoding ~= startEncoding ifTrue: [lastIndex := lastIndex - 1. ^ stops endOfRun].
|
|
ascii := (source at: lastIndex) charCode.
|
|
ascii > maxAscii ifTrue: [ascii := maxAscii].
|
|
(encoding = 0 and: [ascii < stops size and: [(stops at: ascii + 1) ~~ nil]]) ifTrue: [
|
|
self haltOnce.
|
|
^ {lastIndex .(stops at: ascii + 1) . pendingKernX . destX }].
|
|
|
|
nextChar := (lastIndex + 1 <= stopIndex)
|
|
ifTrue:[source at: lastIndex + 1]
|
|
ifFalse:[
|
|
atEndOfRun := true.
|
|
"if there is a next char in sourceString, then get the kern
|
|
and store it in pendingKernX"
|
|
lastIndex + 1 <= source size
|
|
ifTrue:[source at: lastIndex + 1]
|
|
ifFalse:[ nil]].
|
|
font
|
|
widthAndKernedWidthOfLeft: (source at: lastIndex)
|
|
right: nextChar
|
|
into: widthAndKernedWidth.
|
|
nextDestX := floatDestX + (widthAndKernedWidth at: 1).
|
|
nextDestX > rightX ifTrue: [^ {lastIndex . stops crossedX . pendingKernX . destX }].
|
|
floatDestX := floatDestX + kernDelta + (widthAndKernedWidth at: 2).
|
|
atEndOfRun
|
|
ifTrue:[
|
|
pendingKernX := (widthAndKernedWidth at: 2) - (widthAndKernedWidth at: 1).
|
|
floatDestX := floatDestX - pendingKernX].
|
|
destX := floatDestX .
|
|
lastIndex := lastIndex + 1.
|
|
].
|
|
lastIndex := stopIndex.
|
|
^ {lastIndex . stops endOfRun . pendingKernX . destX }
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> setFont: anInteger [
|
|
fontCode := anInteger
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> size [
|
|
^ (self last - self first ) + 1
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> top [
|
|
^ 1
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
GrafoscopioLine >> topLeft [
|
|
^ self left @ self top
|
|
]
|