| 118 NSRange range = NSMakeRange(begin, end-begin); |
118 NSRange range = NSMakeRange(begin, end-begin); |
| 119 NSString *sub = [str substringWithRange:range]; |
119 NSString *sub = [str substringWithRange:range]; |
| 120 return strdup(sub.UTF8String); |
120 return strdup(sub.UTF8String); |
| 121 } |
121 } |
| 122 |
122 |
| 123 void ui_textarea_insert(UiText *text, int pos, char *str) { |
123 void ui_textarea_insert(UiText *text, int pos, const char *str) { |
| 124 NSTextView *textview = (__bridge NSTextView*)text->obj; |
124 NSTextView *textview = (__bridge NSTextView*)text->obj; |
| 125 NSString *s = [[NSString alloc] initWithUTF8String:str]; |
125 NSString *s = [[NSString alloc] initWithUTF8String:str]; |
| 126 NSAttributedString *attributedStr = [[NSAttributedString alloc] initWithString:s]; |
126 NSAttributedString *attributedStr = [[NSAttributedString alloc] initWithString:s]; |
| 127 [textview.textStorage insertAttributedString:attributedStr atIndex:pos]; |
127 [textview.textStorage insertAttributedString:attributedStr atIndex:pos]; |
| 128 } |
128 } |