Page MenuHomePhabricator

Evas textblock: add annotation API
Closed, ResolvedPublic

Description

General

The annotation API is planned to replace our way of formatting the text.
In general, we need a way to use API and set a specific style to a given range in the text.

The API should be straightforward and look like the following:
evas_obj_textblock_annotate_set(tb, start, end, format);

General API

annotation_insert

The provided format is a string and reflects our current formatting scheme e.g. color=#ff0 and its counterpart /color=#ff0. This will return an Evas_Textblock_Annotation handle.

Given start, end will essentially create both opening and closing format nodes for the style at their respective offsets and text nodes.

annotation_get/from_range_get/get_all

Return an iterator on all the Evas_Textblock_Annotation handles, that take effect in the given range.

annotation_set(tb, 0, 10, "color=#0ff");
annotation_set(tb, 5, 10, "font_weight=bold");
formats = annotation_get(tb, 6, 8);
//formats = [color=#off, font_wight=bold]

Annotation API

evas_object_textblock_annotation_del(tb, annotation) - removes the annotation
evas_object_textblock_annotation_replace(tb, annotation, format) - replaces the annotation format with a new format

herdsman created this task.Mar 23 2016, 7:11 AM
herdsman added a project: efl.
herdsman updated the task description. (Show Details)Mar 27 2016, 8:33 AM

Hi, how is start and end going to behave if some text is added

  • before start
  • between start and end
herdsman added a comment.EditedMar 28 2016, 12:49 AM

@bu5hm4n, thanks for taking an interest in this ;)
As expected, the previously set range will grow as you add text to it. It's the same as the current system we have with markups.
So, before start - The formatting (if any) applied up to (not including) start; between start and end - the formatting applied on that range.

herdsman added a subscriber: tasn.Mar 28 2016, 12:51 AM

thank you :) happy with this :P

herdsman renamed this task from Add Annotation API for Textblock to Evas textblock: Add Annotation API.Mar 29 2016, 8:01 AM
herdsman renamed this task from Evas textblock: Add Annotation API to Evas textblock: add Annotation API.
herdsman updated the task description. (Show Details)Mar 29 2016, 8:03 AM
herdsman renamed this task from Evas textblock: add Annotation API to Evas textblock: add annotation API.
herdsman updated the task description. (Show Details)Mar 31 2016, 6:51 AM
herdsman updated the task description. (Show Details)
herdsman updated the task description. (Show Details)
herdsman updated the task description. (Show Details)Apr 14 2016, 12:46 AM
herdsman updated the task description. (Show Details)
herdsman updated the task description. (Show Details)Apr 14 2016, 12:54 AM
herdsman closed this task as Resolved.Sep 11 2017, 12:11 AM