unsigned char redraw : 1;
unsigned char changed : 1;
unsigned char content_changed : 1;
+ Eina_Bool newline_is_ps : 1;
};
/* private methods for textblock objects */
* Returns true if the item is a paragraph separator, false otherwise
* @def _IS_PARAGRAPH_SEPARATOR(item)
*/
-#define _IS_PARAGRAPH_SEPARATOR(item) \
- (!strcmp(item, "ps")) /* Paragraph separator */
+#define _IS_PARAGRAPH_SEPARATOR(o, item) \
+ (!strcmp(item, "ps") || \
+ (o->newline_is_ps && _IS_LINE_SEPARATOR(item))) /* Paragraph separator */
/**
* @internal
}
else
{
- if ((_IS_PARAGRAPH_SEPARATOR(item)) ||
+ if ((_IS_PARAGRAPH_SEPARATOR(c->o, item)) ||
(_IS_LINE_SEPARATOR(item)))
{
Evas_Object_Textblock_Format_Item *fi;
}
/**
+ * @brief Sets newline mode. When true, newline character will behave
+ * as a paragraph separator.
+ *
+ * @param obj The given textblock object.
+ * @param mode EINA_TRUE for PS mode, EINA_FALSE otherwise.
+ * @since 1.1.0
+ */
+EAPI void
+evas_object_textblock_newline_mode_set(Evas_Object *obj, Eina_Bool mode)
+{
+ TB_HEAD();
+ if (o->newline_is_ps == mode)
+ return;
+
+ o->newline_is_ps = mode;
+ _evas_textblock_text_node_changed(o, obj, NULL);
+}
+
+/**
+ * @brief Gets newline mode. When true, newline character behaves
+ * as a paragraph separator.
+ *
+ * @param obj The given textblock object.
+ * @return EINA_TRUE if in PS mode, EINA_FALSE otherwise.
+ * @since 1.1.0
+ */
+EAPI Eina_Bool
+evas_object_textblock_newline_mode_get(const Evas_Object *obj)
+{
+ TB_HEAD_RETURN(EINA_FALSE);
+ return o->newline_is_ps;
+}
+
+/**
* @brief Get the "replacement character" for given textblock object. Returns
* NULL if no replacement character is in use.
*
cur.obj = obj;
eina_ustrbuf_remove(n->text_node->unicode, index, index + 1);
- if (format && _IS_PARAGRAPH_SEPARATOR(format))
+ if (format && _IS_PARAGRAPH_SEPARATOR(o, format))
{
evas_textblock_cursor_set_at_format(&cur, n);
_evas_textblock_cursor_nodes_merge(&cur);
if (!itr || (itr && (itr->text_node != n)))
{
/* Remove the PS, and return since it's the end of the node */
- if (_IS_PARAGRAPH_SEPARATOR(
+ if (_IS_PARAGRAPH_SEPARATOR(o,
eina_strbuf_string_get(last_node->format)))
{
_evas_textblock_node_format_remove(o, last_node, 0);
/* Advance all the cursors after our cursor */
_evas_textblock_cursors_update_offset(cur, cur->node, cur->pos, 1);
- if (_IS_PARAGRAPH_SEPARATOR(format))
+ if (_IS_PARAGRAPH_SEPARATOR(o, format))
{
_evas_textblock_cursor_break_paragraph(cur, n);
}
/* If there's a PS it must be the last become it delimits paragraphs */
last_fmt = _evas_textblock_node_format_last_at_off(fmt);
format = eina_strbuf_string_get(last_fmt->format);
- if (format && _IS_PARAGRAPH_SEPARATOR(format))
+ if (format && _IS_PARAGRAPH_SEPARATOR(o, format))
{
merge_nodes = 1;
}
o = (Evas_Object_Textblock *)(obj->object_data);
o->cursor->obj = obj;
+ o->newline_is_ps = EINA_TRUE;
}
static void *