Collections-Text

PluggableTextAttribute
An attribute which evaluates an arbitrary block when it is selected.
actOnClickFor:
Subclasses may override to provide, eg, hot-spot actions
evalBlock:
Text
I represent a character string that has been marked with abstract changes in character appearance. Actual display is performed in the presence of a TextStyle which indicates, for each abstract code, an actual font to be used. A Text associates a set of TextAttributes with each character in its character string. These attributes may be font numbers, emphases such as bold or italic, or hyperling actions. Font numbers are interpreted relative to whatever textStyle appears, along with the text, in a Paragraph. Since most characters have the same attributes as their neighbors, the attributes are stored in a RunArray for efficiency. Each of my instances has
string a String
runs a RunArray
=
Am I equal to the other Text or String?
***** Warning ***** Two Texts are considered equal if they have the same characters in them. They might have completely different emphasis, fonts, sizes, text actions, or embedded morphs. If you need to find out if one is a true copy of the other, you must do (text1 = text2 and: [text1 runs = text2 runs]).
addAttribute:
addAttribute:from:to:
Set the attribute for characters in the interval start to stop.
addAttribute:toArray:
alignmentAt:ifAbsent:
allBold
Force this whole text to be bold.
append:
asDisplayText
Answer a DisplayText whose text is the receiver.
asMorph
Open a morph, as best one can, on the receiver
asNumber
Answer the number created by interpreting the receiver as the textual
representation of a number.
asOctetStringText
asParagraph
Answer a Paragraph whose text is the receiver.
asString
Answer a String representation of the textual receiver.
asStringMorph
Open a StringMorph, as best one can, on the receiver
asStringOrText
Answer the receiver itself.
asText
Answer the receiver itself.
asTextMorph
Open a TextMorph, as best one can, on the receiver
asUrl
asUrlRelativeTo:
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Primitive. Assumes receiver is indexable. Store the argument value in
the indexable element of the receiver indicated by index. Fail if the
index is not an Integer or is out of bounds. Or fail if the value is not of
the right type for this kind of collection. Answer the value that was
stored. Essential. See Object documentation whatIsAPrimitive.
attributesAt:
Answer the code for characters in the run beginning at characterIndex.
attributesAt:do:
Answer the code for characters in the run beginning at characterIndex.
attributesAt:forStyle:
Answer the code for characters in the run beginning at characterIndex.
basicType
Answer a symbol representing the inherent type I hold
colorAt:
copy
Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy.
copyFrom:to:
Answer a copied subrange of the receiver.
copyReplaceFrom:to:with:
Answer a copy of the receiver satisfying the following conditions: If
stop is less than start, then this is an insertion; stop should be exactly
start-1, start = 1 means insert before the first character, start = size+1
means append after last character. Otherwise, this is a replacement; start
and stop have to be within the receiver's bounds.
copyReplaceTokens:with:
Replace all occurrences of oldSubstring that are surrounded
by non-alphanumeric characters
deepCopy
Answer a copy of the receiver with its own copy of each instance
variable.
embeddedMorphs
return the list of morphs embedded in me
embeddedMorphsFrom:to:
return the list of morphs embedded in me
emphasisAt:
Answer the fontfor characters in the run beginning at characterIndex.
find:
Return the first interval over which this attribute applies
findString:startingAt:
Answer the index of subString within the receiver, starting at index
start. If the receiver does not contain subString, answer 0.
findString:startingAt:caseSensitive:
Answer the index of subString within the receiver, starting at index
start. If the receiver does not contain subString, answer 0.
fontAt:withStyle:
Answer the fontfor characters in the run beginning at characterIndex.
fontNumberAt:
Answer the fontNumber for characters in the run beginning at characterIndex.
fromString:
fromUser
hasWideCharacterFrom:to:
hash
#hash is implemented, because #= is implemented. We are now equal to a string with the same characters. Hash must reflect that.
howManyMatch:
initTextConstants
initialize
Subclasses should redefine this method to perform initializations on instance creation
isText
isoToSqueak
lineCount
macToSqueak
Convert the receiver from MacRoman to Squeak encoding
makeBoldFrom:to:
makeSelectorBold
For formatting Smalltalk source code, set the emphasis of that portion of
the receiver's string that parses as a message selector to be bold.
makeSelectorBoldIn:
For formatting Smalltalk source code, set the emphasis of that portion of
the receiver's string that parses as a message selector to be bold.
new:
prepend:
printOn:
Append a sequence of characters that identify the receiver to aStream.
rangeOf:startingAt:
Answer an interval that gives the range of attribute at index position index. An empty interval with start value index is returned when the attribute is not present at position index.
removeAttribute:from:to:
Remove the attribute over the interval start to stop.
removeAttributesThat:replaceAttributesThat:by:
Enumerate all attributes in the receiver. Remove those passing removalBlock and replace those passing replaceBlock after converting it through convertBlock
replaceFrom:to:with:
This destructively replaces elements from start to stop in the receiver.
Answer the receiver itself. Use copyReplaceFrom:to:with: for
insertion/deletion which may alter the size of the result.
replaceFrom:to:with:startingAt:
This destructively replaces elements from start to stop in the receiver starting at index, repStart, in replacementCollection. Do it to both the string and the runs.
reversed
Answer a copy of the receiver with element order reversed.
runLengthFor:
Answer the count of characters remaining in run beginning with
characterIndex.
runs
runs:
setString:setRuns:
setString:setRunsChecking:
Check runs and do the best you can to make them fit...
size
Answer how many elements the receiver contains.
squeakToIso
squeakToMac
Convert the receiver from Squeak to MacRoman encoding
storeOn:
Refer to the comment in Object|storeOn:.
streamContents:
string
Answer the string representation of the receiver.
string:attribute:
string:attributes:
string:emphasis:
string:runs:
unembellished
Return true if the only emphases are the default font and bold
withSqueakLineEndings
Answer a copy of myself in which all sequences of <CR><LF> or <LF> have been changed to <CR>
TextAction
A TextAction is xxxxxxxxx.
Instance Variables
analyze:
Analyze the selected text to find both the parameter to store and the text to emphesize (may be different from original selection). Does not return self!. May be of the form:
3+4
<3+4>
Click Here<3+4>
<3+4>Click Here
dominatedByCmd0
Cmd-0 should turn off active text
emphasizeScanner:
Set the emphasis for text display
info
initialize
Subclasses should redefine this method to perform initializations on instance creation
mayActOnClick
Subclasses may override to provide, eg, hot-spot actions
shoutShouldPreserve
Answer true if Shout should preserve ALL the attributes in the same run as the receiver,
false otherwise
validate:
any format is OK with me
TextAlignment
A TextAlignment is xxxxxxxxx.
Instance Variables
alignment: <Object>
alignment
- xxxxx
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
alignment
alignment:
alignmentSymbol:
centered
dominates:
There can be only one...
emphasizeScanner:
Set the emphasist for text scanning
hash
#hash is re-implemented because #= is re-implemented
justified
leftFlush
rightFlush
writeScanOn:
TextAttribute
Tells a piece of text to be a certain way.
Select text, press Command-6, choose a attribute. If selected text is of the form
Hi There<Smalltalk beep>
the part in angle brackets is saved for action, and the Hi There appears in the paragraph. If selection has no angle brackets, use the whole thing as both the text and the action.
TextDoIt -- eval as a Smalltalk expression (the part in angle brackets)
TextLink -- Show a method, class comment, class hierarchy, or class defintion.
<Point extent:>, <Point Comment>, <Point Hierarchy>, or <Point Defintion> are what you type.
TextURL -- Show the web page. <www.disney.com>
These attributes of text need to be stored on the disk in a regular file-out. It is done in this form: Hi There
in the text, and a Run containing dSmalltalk beep;;
Click here to see the extent:
in the text, and a Run containing method LPoint extent:;
See RunArray class scanFrom: where decoding is done.
actOnClickFor:
Subclasses may override to provide, eg, hot-spot actions
actOnClickFor:in:
actOnClickFor:in:at:
actOnClickFor:in:at:editor:
anchoredMorph
If one hides here, return it
dominatedByCmd0
Subclasses may override if cmd-0 should turn them off
dominates:
Subclasses may override condense multiple attributes
emphasisCode
Subclasses may override to add bold, italic, etc
emphasizeScanner:
Subclasses may override to set, eg, font, color, etc
forFontInStyle:do:
No action is the default. Overridden by font specs
isKern
mayActOnClick
Subclasses may override to provide, eg, hot-spot actions
mayBeExtended
A quality that may be overridden by subclasses, such as TextAnchors, that really only apply to a single character
oldEmphasisCode:
Allows running thorugh possibly multiple attributes
and getting the emphasis out of any that has an emphasis (font number)
reset
Allow subclasses to prepare themselves for merging attributes
set
Respond true to include this attribute (as opposed to, eg, a bold
emphasizer that is clearing the property
shoutShouldPreserve
Answer true if Shout should preserve ALL the attributes in the same run as the receiver,
false otherwise
TextColor
A TextColor encodes a text color change applicable over a given range of text.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
black
blue
color
color:
cyan
dominates:
Subclasses may override condense multiple attributes
emphasizeScanner:
Set the emphasis for text display
gray
green
hash
Answer a SmallInteger whose value is related to the receiver's identity.
May be overridden, and should be overridden in any classes that define =
magenta
printHtmlCloseTagOn:
printHtmlOpenTagOn:
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
red
scanFrom:
white
writeScanOn:
Two formats. c125000255 or cblue;
yellow
TextDoIt
A TextDoIt is xxxxxxxxx.
Instance Variables
evalString: <Object>
evalString
- xxxxx
actOnClickFor:
Note: evalString gets evaluated IN THE CONTEXT OF anObject
-- meaning that self and all instVars are accessible
analyze:
Analyze the selected text to find both the parameter to store and the text to emphesize (may be different from original selection). Does not return self!. May be of the form:
3+4
<3+4>
Click Here<3+4>
<3+4>Click Here
evalString:
info
scanFrom:
writeScanOn:
TextEmphasis
A TextEmphasis, encodes a characteristic applicable to all fonts. The encoding is as follows:
1 bold
2 itallic
4 underlined
8 narrow
16 struck out
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
bold
dominatedByCmd0
Cmd-0 should turn off emphasis
dominates:
Subclasses may override condense multiple attributes
emphasisCode
Subclasses may override to add bold, italic, etc
emphasisCode:
emphasizeScanner:
Set the emphasist for text scanning
hash
#hash is re-implemented because #= is re-implemented
italic
narrow
normal
printHtmlCloseTagOn:
printHtmlOpenTagOn:
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
set
Respond true to include this attribute (as opposed to, eg, a bold
emphasizer that is clearing the property
struckOut
turnOff
underlined
writeScanOn:
TextFontChange
A TextFontChange encodes a font change applicable over a given range of text. The font number is interpreted relative to the textStyle governing display of this text.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
defaultFontChange
dominates:
Subclasses may override condense multiple attributes
emphasizeScanner:
Set the font for text display
font1
font2
font3
font4
fontNumber
fontNumber:
forFontInStyle:do:
No action is the default. Overridden by font specs
hash
#hash is re-implemented because #= is re-implemented
printHtmlCloseTagOn:
printHtmlOpenTagOn:
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
writeScanOn:
TextFontReference
A TextFontReference encodes a font change applicable over a given range of text. The font reference is absolute: unlike a TextFontChange, it is independent of the textStyle governing display of this text.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
emphasizeScanner:
Set the actual font for text display
font
forFontInStyle:do:
No action is the default. Overridden by font specs
hash
#hash is re-implemented because #= is re-implemented
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
toFont:
writeScanOn:
TextIndent
create a hanging indent.
amount
number of tab spaces to indent by
amount:
change the number of tabs to indent by
dominates:
Subclasses may override condense multiple attributes
emphasizeScanner:
Subclasses may override to set, eg, font, color, etc
example
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
tabs:
TextKern
A TextKern encodes a kerning change applicable over a given range of text. Positive values of kern spread letters out, negative kern will cause them to overlap more. Note that kerns other than 0 will display somewhat slower, as kerning is not yet supported in the text scanning primitive.
=
Answer whether the receiver and the argument represent the same
object. If = is redefined in any subclass, consider also redefining the
message hash.
dominatedByCmd0
Cmd-0 should turn off kerning
dominates:
NOTE: The use of active in this code is specific to its use in the method
Text class addAttribute: att toArray: others
emphasizeScanner:
Augment (or diminish) the kerning offset for text display
hash
#hash is re-implemented because #= is re-implemented
isKern
kern
kern:
reset
Allow subclasses to prepare themselves for merging attributes
set
Respond true to include this attribute (as opposed to, eg, a bold
emphasizer that is clearing the property
writeScanOn:
A TextLink is xxxxxxxxx.
Instance Variables
classAndMethod: <Object>
classAndMethod
- xxxxx
actOnClickFor:
Add to the end of the list. 'aClass selector', 'aClass Comment', 'aClass Definition', 'aClass Hierarchy' are the formats allowed.
analyze:
Analyze the selected text to find both the parameter to store and the text to emphesize (may be different from original selection). Does not return self!. May be of the form:
3+4
<3+4>
Click Here<3+4>
<3+4>Click Here
analyze:with:
Initalize this attribute holder with a piece text the user typed into a paragraph. Returns the text to emphesize (may be different from selection) Does not return self!. nonMethod is what to show when clicked, i.e. the last part of specifier (Comment, Definition, or Hierarchy). May be of the form:
Point
<Point>
Click Here<Point>
<Point>Click Here
classAndMethod:
info
scanFrom:
validate:
Can this string be decoded to be Class space Method (or Comment, Definition, Hierarchy)? If so, return it in valid format, else nil
writeScanOn:
TextPrintIt
A TextPrintIt is xxxxxxxxx.
Instance Variables
actOnClickFor:in:at:editor:
Note: evalString gets evaluated IN THE CONTEXT OF anObject
-- meaning that self and all instVars are accessible
writeScanOn:
TextURL
A TextURL is xxxxxxxxx.
Instance Variables
url: <Object>
url
- xxxxx
actOnClickFor:
Do what you can with this URL. Later a web browser.
analyze:
Analyze the selected text to find both the parameter to store and the text to emphesize (may be different from original selection). Does not return self!. May be of the form:
3+4
<3+4>
Click Here<3+4>
<3+4>Click Here
info
printHtmlCloseTagOn:
printHtmlOpenTagOn:
scanFrom:
url:
writeScanOn: