@@ -403,14 +403,14 @@ LIB_EXPORT bool l_edit_is_empty(struct l_edit *edit)
return (edit->main->len == 0);
}
-LIB_EXPORT char *l_edit_enter(struct l_edit *edit)
+LIB_EXPORT int l_edit_enter(struct l_edit *edit, char **line)
{
struct input_buf *buf;
char *str;
size_t len;
if (!edit)
- return NULL;
+ return -EINVAL;
/* Convert the wide character string into the multibyte string
* representation like UTF-8 for example.
@@ -458,9 +458,15 @@ LIB_EXPORT char *l_edit_enter(struct l_edit *edit)
}
edit->main = edit->head;
+
update_display(edit);
- return str;
+ if (line)
+ *line = str;
+ else
+ l_free(str);
+
+ return 0;
}
LIB_EXPORT int l_edit_reset(struct l_edit *edit, const char *input)
@@ -36,7 +36,7 @@ int l_edit_set_max_input_length(struct l_edit *edit, size_t len);
int l_edit_set_history_size(struct l_edit *edit, unsigned int size);
int l_edit_refresh(struct l_edit *edit);
bool l_edit_is_empty(struct l_edit *edit);
-char *l_edit_enter(struct l_edit *edit);
+int l_edit_enter(struct l_edit *edit, char **line);
int l_edit_reset(struct l_edit *edit, const char *input);
int l_edit_insert(struct l_edit *edit, wint_t ch);
int l_edit_delete(struct l_edit *edit);