On Mon, Oct 29, 2007 at 12:30:42PM +0100, Abdelrazak Younes wrote:
> Jean-Marc Lasgouttes wrote:
>> Abdelrazak Younes <[EMAIL PROTECTED]> writes:
>>> If you mean an unified interface for Paragraph then I'd agree. The
>>> Range template I am talking about would be private to Paragraph. Then,
>>> if we could have:
>>>
>>>   CharAttributes Paragraph::getAttributes(pos_type)
>>>
>>> that will replace Paragraph::getFont(pos_type) and that will provide
>>> all attributes in one go by looking up and gathering relevant Font,
>>> Language and Change Tracking information.
>> This (getting attributes at _one_ point) is much less useful and does
>> not gain anything.
>
> Might be useful for painting but anyway, you're right. My point is that we 
> don't have to make the range inter-dependent in order to provide a nice API 
> at Paragraph level.
>
>> I was thinking about a nice way of accessing ranges
>> from the paragraph api.
>
> OK, then we just need some interface methods that would give that 
> information by looking up the inner independent ranges, ex:
>
> struct AttributeRange {
>       pos_type start;
>       pos_type end;
>       FontInfo font;
>       Change change;
>       Language * language;
>       vector<AttributeRange *> nested;
> }

I am not sure about the 'nested' part.

> AttributeRange Paragraph::getAttributeRange(
>       pos_type pos, // the position we're interested in.
>       bool lookup_nested) // whether to look for nested range or not.
> {
>       AttributeRange att;
>       // lookup here the innermost range that will enclose pos
>       // att.start <= pos < att.end
>       // att.nested will be empty if there's no nested range
>       // between start and end.
> }
>
> Does that sound interesting?

I was thinking long the lines of

struct Attribute {
        FontInfo font;
        Change change;
        Language * language;
};

struct Range {
        int from;
        int to;
        Attribute attribute;
};

typedef std::vector<Range> Ranges;


or even

struct Attribute {}

struct FontAttribute : Attribute {
        FontInfo font;
};

struct LanguageAttribute : ...
struct ChangeAttribute : ...

struct Range {
        int from;
        int to;
        // with value semantics
        Attribute * attribute;
};

Reply via email to