--- a/ui/cocoa/text.m Fri Apr 25 22:04:30 2025 +0200 +++ b/ui/cocoa/text.m Sun Apr 27 15:17:17 2025 +0200 @@ -44,5 +44,91 @@ UiLayout layout = UI_INIT_LAYOUT(args); ui_container_add(obj, scrollview, &layout, TRUE); + + UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_TEXT); + if(var) { + UiText *text = var->value; + text->obj = (__bridge void*)textview; + ui_textarea_restore(text); + + text->save = ui_textarea_save; + text->destroy = ui_textarea_destroy; + text->restore = ui_textarea_restore; + text->set = ui_textarea_set; + text->get = ui_textarea_get; + text->getsubstr = ui_textarea_getsubstr; + text->insert = ui_textarea_insert; + text->setposition = ui_textarea_setposition; + text->position = ui_textarea_position; + text->setselection = ui_textarea_setselection; + text->selection = ui_textarea_selection; + text->length = ui_textarea_length; + text->remove = ui_textarea_remove; + } + return (__bridge void*)scrollview; } + + + + +void ui_textarea_save(UiText *text) { + +} + +void ui_textarea_destroy(UiText *text) { + (void)(__bridge_transfer NSTextStorage*)text->data1; +} + +void ui_textarea_restore(UiText *text) { + NSTextView *textview = (__bridge NSTextView*)text->obj; + NSTextStorage *textStorage; + if(text->data1) { + textStorage = (__bridge NSTextStorage*)text->data1; + + } else { + textStorage = [[NSTextStorage alloc] init]; + } + [textview.layoutManager replaceTextStorage:textStorage]; + text->data1 = (__bridge_retained void*)textStorage; +} + +void ui_textarea_set(UiText *text, const char *str) { + +} + +char* ui_textarea_get(UiText *text) { + return NULL; +} + +char* ui_textarea_getsubstr(UiText *text, int begin, int end) { + return NULL; +} + +void ui_textarea_insert(UiText *text, int pos, char *str) { + +} + +void ui_textarea_setposition(UiText *text, int pos) { + +} + +int ui_textarea_position(UiText *text) { + return 0; +} + +void ui_textarea_setselection(UiText *text, int begin, int end) { + +} + +void ui_textarea_selection(UiText *text, int *begin, int *end) { + +} + +int ui_textarea_length(UiText *text) { + return 0; +} + +void ui_textarea_remove(UiText *text, int begin, int end) { + +}