diff --git a/gnoemoe/gm-editor.c b/gnoemoe/gm-editor.c index 8fd03d4..68b5a84 100644 --- a/gnoemoe/gm-editor.c +++ b/gnoemoe/gm-editor.c @@ -123,38 +123,9 @@ gm_editor_lines_free(GmEditor *editor) { editor->priv->lines = NULL; } -void -gm_editor_add_line(GmEditor *editor, gchar *line, GList **lastptr) { - if (!editor->priv->lines) { - editor->priv->lines = g_list_append(NULL, line); - *lastptr = editor->priv->lines; - } else { - g_list_append(*lastptr, line); - *lastptr = (*lastptr)->next; - } -} - void gm_editor_set_lines_from_string(GmEditor *editor, gchar const *text) { - gchar *fptr, *line; - GList *lastptr; - - gm_editor_lines_free(editor); - - while ((fptr = g_utf8_strchr(text, -1, '\n'))) { - line = g_strndup(text, fptr - text); - gm_string_remove_char(line, '\r'); - - gm_editor_add_line(editor, line, &lastptr); - text = g_utf8_next_char(fptr); - } - - if (*text != '\0') { - line = g_strdup(text); - gm_string_remove_char(line, '\r'); - - gm_editor_add_line(editor, line, &lastptr); - } + editor->priv->lines = gm_string_split(text); } void