**
** Return the styled segments for the given zero based line index.
** The result is a list of Int/RichTextStyle pairs where the Int
** specifies a zero based char offset of the line.
**
List lineStyling(Int lineIndex)
a really awkward API? I kept trying to think of a way to put pairs into a list, until finally I looked at some example code and realize that no, it wants a list that goes [int, style, int, style...]. And then I had to read the docs several times, and try an experiment, to be sure whether it meant the Int was, an index from the beginning of this particular line, or, an index of the line in the full text.
That just seems really awkward and error-prone, to me. On the other hand, I don't really have any suggestions for how to fix it. :-)
JohnDGThu 30 Apr 2009
An ordered map from region to style is a good solution.
brianThu 30 Apr 2009
I agree it is a litle awkward, but at the same time that is one of the most performance critical APIs in the text editor. So I want to avoid created complicated deep structures. Since styles are often immutable, I can't really think of anything better then just a list.
KevinKelley Thu 30 Apr 2009
Is it just me, or is
a really awkward API? I kept trying to think of a way to put
pairs
into a list, until finally I looked at some example code and realize that no, it wants a list that goes[int, style, int, style...]
. And then I had to read the docs several times, and try an experiment, to be sure whether it meant the Int was, an index from the beginning of this particular line, or, an index of the line in the full text.That just seems really awkward and error-prone, to me. On the other hand, I don't really have any suggestions for how to fix it. :-)
JohnDG Thu 30 Apr 2009
An ordered map from region to style is a good solution.
brian Thu 30 Apr 2009
I agree it is a litle awkward, but at the same time that is one of the most performance critical APIs in the text editor. So I want to avoid created complicated deep structures. Since styles are often immutable, I can't really think of anything better then just a list.