Evas textblock: Added evas_textblock_cursor_content_get.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 5 Sep 2010 08:28:58 +0000 (08:28 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 5 Sep 2010 08:28:58 +0000 (08:28 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@51898 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/Evas.h
src/lib/canvas/evas_object_textblock.c

index 2bca64a..1f19f72 100644 (file)
@@ -1413,6 +1413,7 @@ typedef void (*Evas_Object_Image_Pixels_Get_Cb) (void *data, Evas_Object *o);
    EAPI const char                  *evas_textblock_cursor_paragraph_text_get(const Evas_Textblock_Cursor *cur) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
    EAPI int                          evas_textblock_cursor_paragraph_text_length_get(const Evas_Textblock_Cursor *cur) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
    EAPI char                        *evas_textblock_cursor_range_text_get(const Evas_Textblock_Cursor *cur1, const Evas_Textblock_Cursor *cur2, Evas_Textblock_Text_Type format) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
+   EAPI char                        *evas_textblock_cursor_content_get(const Evas_Textblock_Cursor *cur) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
 
    EAPI int                          evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch, Evas_Textblock_Cursor_Type ctype) EINA_ARG_NONNULL(1);
    EAPI int                          evas_textblock_cursor_char_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) EINA_ARG_NONNULL(1);
index 1f2f99c..1a4c2c1 100644 (file)
@@ -6185,6 +6185,40 @@ evas_textblock_cursor_range_delete(Evas_Textblock_Cursor *cur1, Evas_Textblock_C
    _evas_textblock_changed(o, cur1->obj);
 }
 
+
+/**
+ * Return the content of the cursor.
+ *
+ * @param cur the cursor
+ * @return the text in the range
+ */
+EAPI char *
+evas_textblock_cursor_content_get(const Evas_Textblock_Cursor *cur)
+{
+   const Eina_Unicode *ustr;
+   Eina_Unicode buf[2];
+   char *s;
+   if (!cur || !cur->node) return NULL;
+   if (evas_textblock_cursor_format_is_visible_get(cur))
+     {
+           if (evas_textblock_cursor_format_is_visible_get(cur))
+             {
+                const char *tmp;
+                tmp  = evas_textblock_node_format_text_get(
+                      _evas_textblock_node_visible_at_pos_get(
+                      evas_textblock_cursor_format_get(cur)));
+                return strdup(tmp);
+             }
+     }
+
+   ustr = eina_ustrbuf_string_get(cur->node->unicode);
+   buf[0] = ustr[cur->pos];
+   buf[1] = 0;
+   s = evas_common_encoding_unicode_to_utf8(buf, NULL);
+
+   return s;
+}
+
 /**
  * Return the text in the range between cur1 and cur2
  *