--- a/ui/motif/text.c Fri Mar 28 20:03:49 2014 +0100 +++ b/ui/motif/text.c Sat Mar 29 12:15:39 2014 +0100 @@ -48,8 +48,10 @@ // bind value if(value) { + value->set = ui_textarea_set; value->get = ui_textarea_get; - value->set = ui_textarea_set; + value->getsubstr = ui_textarea_getsubstr; + value->insert = ui_textarea_insert; value->value = NULL; value->obj = text_area; @@ -79,12 +81,30 @@ void ui_textarea_set(UiText *text, char *str) { if(text->value) { XtFree(text->value); - text->value = NULL; } text->value = NULL; XmTextSetString(text->obj, str); } +char* ui_textarea_getsubstr(UiText *text, int begin, int end) { + if(text->value) { + XtFree(text->value); + } + int length = end - begin; + char *str = XtMalloc(length + 1); + XmTextGetSubstring(text->obj, begin, length, length + 1, str); + text->value = str; + return str; +} + +void ui_textarea_insert(UiText *text, int pos, char *str) { + if(text->value) { + XtFree(text->value); + } + text->value = NULL; + XmTextInsert(text->obj, pos, str); +} + UiUndoMgr* ui_create_undomgr() { UiUndoMgr *mgr = malloc(sizeof(UiUndoMgr)); mgr->begin = NULL;