|
runarray Specification SheetPortable Object Compiler (c) 1997,98,99. All Rights Reserved.
RunArrayInherits from: CltnMaturity Index: Experimental
Class DescriptionThis class is used by the Text class, to associate lists of TextAttribute instances, to segments of characters in a string (slices of text with the same formatting properties, called runs).
AccessingA RunArray is not indexed by segment number.Rather, it is indexed by character offsets : the message at: or runLengthAt: takes a character offset as argument, and translates this offset to a segment offset (the segment to which the character belongs) and returns the attributes or segment length, for that segment. The size of a RunArray is the largest character offset plus one;it is not the number of segments.
Method typesCreationAccessing
PrintingMethodsnew+newCreates an empty RunArray collection.
free-free values-valuesReturns a collection of OrdCltn instances (each element being a list of TextAttribute instances).
runs-runsReturns the run array (array of int).
at:-at:(unsigned)iReturns a collection of TextAttributes for the i-th character. This method translates a character offset into a segment number. The segment number is cached so that a subsequent call to at: or runLengthAt: doesn't have to recompute it.
runLengthAt:- (unsigned)runLengthAt:(unsigned)iReturns the number of remaining characters in the string segment to which the character at position i belongs. If i is the first character of a run, this method returns the size of the run. Otherwise it returns the size minus the index of character in the run.
size- (unsigned)sizeReturns the size of the RunArray, which is the same as the size of the String instance for this RunArray object. The number of runs can be obtained by sending a size message to the object returned by values.
addAttribute:from:size:-addAttribute:attribfrom:(unsigned)psize:(unsigned)sAdds attrib to the attribute lists for the s characters from position p. Note: This method is optimized for adding at the end of the RunArray.
at:insert:count:-at:(unsigned)anOffsetinsert:(char*)aStringcount:(int)n deleteFrom:to:-deleteFrom:(unsigned)pto:(unsigned)q concat:-concat:b coalesce-coalesceMerges adjacent lists of TextAttribute instances, by testing whether they are equal (in the sense of TextAttribute's isEqual method).
printOn:-printOn:(IOD)aFilePrints the RunArray values.
|