summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2010-09-20 09:44:48 +0000
committerTom Hacohen <tom@stosb.com>2010-09-20 09:44:48 +0000
commite8c10dbce78a59bdb02b44e61ccea05822190261 (patch)
tree727ede5bdd58b5ccee938a2c4af7b8e981405398 /legacy
parent4b73f639d243e664c151dd6154a5eb7792566222 (diff)
Evas textblock: Added evas_textblock_node_format_remove_pair to remove formats.
SVN revision: 52484
Diffstat (limited to 'legacy')
-rw-r--r--legacy/evas/src/lib/Evas.h1
-rw-r--r--legacy/evas/src/lib/canvas/evas_object_textblock.c65
2 files changed, 66 insertions, 0 deletions
diff --git a/legacy/evas/src/lib/Evas.h b/legacy/evas/src/lib/Evas.h
index a13e94f46a..bceb764749 100644
--- a/legacy/evas/src/lib/Evas.h
+++ b/legacy/evas/src/lib/Evas.h
@@ -1389,6 +1389,7 @@ typedef void (*Evas_Object_Image_Pixels_Get_Cb) (void *data, Evas_Object *o);
1389 EAPI const Evas_Object_Textblock_Node_Format *evas_textblock_node_format_last_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); 1389 EAPI const Evas_Object_Textblock_Node_Format *evas_textblock_node_format_last_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
1390 EAPI const Evas_Object_Textblock_Node_Format *evas_textblock_node_format_next_get(const Evas_Object_Textblock_Node_Format *n) EINA_ARG_NONNULL(1); 1390 EAPI const Evas_Object_Textblock_Node_Format *evas_textblock_node_format_next_get(const Evas_Object_Textblock_Node_Format *n) EINA_ARG_NONNULL(1);
1391 EAPI const Evas_Object_Textblock_Node_Format *evas_textblock_node_format_prev_get(const Evas_Object_Textblock_Node_Format *n) EINA_ARG_NONNULL(1); 1391 EAPI const Evas_Object_Textblock_Node_Format *evas_textblock_node_format_prev_get(const Evas_Object_Textblock_Node_Format *n) EINA_ARG_NONNULL(1);
1392 EAPI void evas_textblock_node_format_remove_pair(Evas_Object *obj, Evas_Object_Textblock_Node_Format *n) EINA_ARG_NONNULL(1, 2);
1392 EAPI void evas_textblock_cursor_set_at_format(Evas_Textblock_Cursor *cur, const Evas_Object_Textblock_Node_Format *n) EINA_ARG_NONNULL(1, 2); 1393 EAPI void evas_textblock_cursor_set_at_format(Evas_Textblock_Cursor *cur, const Evas_Object_Textblock_Node_Format *n) EINA_ARG_NONNULL(1, 2);
1393 EAPI const Evas_Object_Textblock_Node_Format *evas_textblock_cursor_format_get(const Evas_Textblock_Cursor *cur) EINA_ARG_NONNULL(1); 1394 EAPI const Evas_Object_Textblock_Node_Format *evas_textblock_cursor_format_get(const Evas_Textblock_Cursor *cur) EINA_ARG_NONNULL(1);
1394 EAPI const char *evas_textblock_node_format_text_get(const Evas_Object_Textblock_Node_Format *cur) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); 1395 EAPI const char *evas_textblock_node_format_text_get(const Evas_Object_Textblock_Node_Format *cur) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
diff --git a/legacy/evas/src/lib/canvas/evas_object_textblock.c b/legacy/evas/src/lib/canvas/evas_object_textblock.c
index f684fcc1b2..e0ed433cb5 100644
--- a/legacy/evas/src/lib/canvas/evas_object_textblock.c
+++ b/legacy/evas/src/lib/canvas/evas_object_textblock.c
@@ -4294,6 +4294,71 @@ evas_textblock_node_format_prev_get(const Evas_Object_Textblock_Node_Format *n)
4294} 4294}
4295 4295
4296/** 4296/**
4297 * Remove a format node and it's match. i.e, removes a <tag> </tag> pair.
4298 * Assumes the node is the first part of <tag> i.e, this won't work if
4299 * n is a closing tag.
4300 *
4301 * @param obj the evas object of the textblock - not null.
4302 * @param n the current format node - not null.
4303 */
4304EAPI void
4305evas_textblock_node_format_remove_pair(Evas_Object *obj,
4306 Evas_Object_Textblock_Node_Format *n)
4307{
4308 Evas_Object_Textblock_Node_Text *tnode;
4309 Evas_Object_Textblock_Node_Format *fmt, *pnode;
4310 int level;
4311 TB_HEAD();
4312
4313 if (!n) return;
4314
4315 pnode = NULL;
4316 fmt = n;
4317 tnode = fmt->text_node;
4318 level = 0;
4319
4320 do
4321 {
4322 const char *fstr = eina_strbuf_string_get(fmt->format);
4323
4324 if (fstr && (*fstr == '+'))
4325 {
4326 level++;
4327 }
4328 else if (fstr && (*fstr == '-'))
4329 {
4330 level--;
4331 }
4332
4333 pnode = fmt;
4334 fmt = _NODE_FORMAT(EINA_INLIST_GET(fmt)->next);
4335 }
4336 while (fmt && (level > 0));
4337
4338 if (n->visible)
4339 {
4340 size_t index = _evas_textblock_node_format_pos_get(n);
4341 const char *format = eina_strbuf_string_get(n->format);
4342 Evas_Textblock_Cursor cur;
4343 cur.obj = obj;
4344
4345 eina_ustrbuf_remove(n->text_node->unicode, index, index + 1);
4346 if (format && _IS_PARAGRAPH_SEPARATOR(format))
4347 {
4348 evas_textblock_cursor_set_at_format(&cur, n);
4349 _evas_textblock_cursor_nodes_merge(&cur);
4350 }
4351 _evas_textblock_cursors_update_offset(&cur, n->text_node, index, -1);
4352 }
4353 _evas_textblock_node_format_remove(o, n, 1);
4354 if (pnode && (pnode != n))
4355 {
4356 _evas_textblock_node_format_remove(o, pnode, 0);
4357 }
4358 _evas_textblock_changed(o, obj);
4359}
4360
4361/**
4297 * Sets the cursor to the start of the first text node. 4362 * Sets the cursor to the start of the first text node.
4298 * 4363 *
4299 * @param cur the cursor to update. 4364 * @param cur the cursor to update.