Re: AtkText attributes



Bill & Others:

As a quick aside, you mentioned that the atktext.h fuction
get_row_col_at_offset() may be pulled from the atktext.h API.  I'm
not sure of the reasons I'm remembering you saying this to me.
Anyway I haven't yet implemented this function, and am wondering what
to do with this.  Should I remove it from the API, change it, or just
implement it as it is?

On with the atk_text_get_attributes() issue...

Bill Haneman wrote...
>
> Brian Cameron wrote:
> > 
> > Bill & Others:
> > 
> > > We've had a couple of conversations about removing our current Pango
> > > dependency from ATK.  Though we think Pango is great and will of
> > > course depend on it heavily in GAIL, the only pango dependency that I
> > > know of in ATK is the use of PangoAttributeSet as the means of
> > > indicating text attributes.
> > 
> > Aside from returning the data as name/value paris, there are some
> > issues with returning the attirbutes from the GtkTextWidget.
> > 
> > First of all, all PangoAttributes have a start_index and an end_index,
> > (for example describing that the text uses a certain font in this
> > range).  What if a TextBuffer has font 1 defined for characters
> > 10-30, font2 defined for characters 31-50, and the user calls
> > atk_text_get_range_attributes asking for the attributes between
> > characters 25 and 40.  The "Font" attribute will have two different
> > values within this range.  I'm not sure that this level of detail
> > is returned via the current atk_text_get_range_attributes interface.
> 
> The idea was for atk_text_get_attributes() to return only those
> attributes that are the same across the range given, so in the case
> you cite Font would not show up.

We can certainly implement this function as you describe, but is it
really all that  useful to return just *some* of the attributes that
apply to the range?

Also, what if the specified range has two fonts (in the above example if
the user asks for range from 10-50, will it return both font attributes
since both fonts fall within this range?

Another example, If font 1 is used for characters 10-30, font 2 is used
for characters 31-50, and font 3 is used for characters 51-70.  In this
scenario it is impossible for me to find out what the font attribute
is for character #35 unless I am able to guess that the range values
should be 31 to 50.  Am I interpreting this correctly?

I'm not sure how useful attributes are without the range information.

> This may not be what one expects, but otherwise I think the returned
> data structs get too complex.

Certainly, but a complicated & useful structure is better than a simple
one that doesn't work well.

> The Java API only returns a set of
> attributes for a single character, and I'd like to do a little
> better.  We've discussed adding a means of getting an attribute "run"
> to the SPI, and I think we should, which would require a similar
> function in ATK.  One way to do this is by adding a new TEXT_BOUNDARY
> type, and possibly adding API to allow us to get boundary offsets as
> well as just character strings.  Thus:

Does the Java API tell you of all attributes that affect the single
character even if the attribute is part of a larger range?  If so, I
am unsure why the Gail "range" version shouldn't also work this way.
Still, providing range information for each attribute that falls within
the range seems necessary to handle situations where the same attribute
has different values in the range.
 
> startOffset = atk_text_get_prev_boundary (text, offset,
> ATK_TEXT_BOUNDARY_TYPE_ATTRIBUTES);
> endOffset = offset = atk_text_get_next_boundary (text, offset,
> ATK_TEXT_BOUNDARY_TYPE_ATTRIBUTES);
> 
> attributesOverRange = atk_text_get_attributes (text, startOffset,
> endOffset);

But different attributes have different ranges.  I can have characters 
10-30 in font 1 and characters 31-50 in font 2, but characters 20-40
are in italics.  Which "attribute boundry" should be used when they
overlap like this?

> > Perhaps one step of the solution is to return something more complicated
> > than a (name value) pair, but instead something like a (name, value,
> > start position, end position) structure.  This way multiple "font"
> > attributes could be returned.
> > 
> > However, since font1 is used from position 10-30 and font2 is used
> > from position 31-50, and the user asked for info for positions 25-40,
> > does the function say font1 is used from 1-30 or from 25-30, and
> > that font2 is used from 31-40 or 31-50?  Not sure if I'm making sense
> > here, but it's not clear how the function should work.
> > 
> > One solution would be to make the function not range based.  If the
> > function were just a atk_text_get_attributes() and returned an array
> > of (name, value, start position, end position) structures for the
> > whole buffer, then this would resolve any potential confusion about
> > how to handle ranges.  This would pass all the info about the buffer
> > back to the user and let them extract what interests them.
> 
> This is OK until the text buffer becomes very large, in which case,
> ugh.
> 
> So maybe that is not the right solution.

But why not just return the attributes that fall within the specified range,
and return each attributes start/end values.  This is workable, useful for
the user, and resolves the issue of returning back *all* of the information
(which is too much as you correctly point out).

Brian





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]