95 UiContainer *ct = uic_get_current_container(obj); |
97 UiContainer *ct = uic_get_current_container(obj); |
96 ct->add(ct, scroll_area); |
98 ct->add(ct, scroll_area); |
97 |
99 |
98 // bind value |
100 // bind value |
99 if(value) { |
101 if(value) { |
|
102 GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_area)); |
|
103 |
|
104 if(value->value) { |
|
105 gtk_text_buffer_set_text(buf, value->value, -1); |
|
106 } |
|
107 |
100 value->get = ui_textarea_get; |
108 value->get = ui_textarea_get; |
101 value->set = ui_textarea_set; |
109 value->set = ui_textarea_set; |
102 value->getsubstr = ui_textarea_getsubstr; |
110 value->getsubstr = ui_textarea_getsubstr; |
103 value->insert = ui_textarea_insert; |
111 value->insert = ui_textarea_insert; |
104 value->position = ui_textarea_position; |
112 value->position = ui_textarea_position; |
105 value->selection = ui_textarea_selection; |
113 value->selection = ui_textarea_selection; |
106 value->length = ui_textarea_length; |
114 value->length = ui_textarea_length; |
|
115 value->remove = ui_textarea_remove; |
107 value->value = NULL; |
116 value->value = NULL; |
108 GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_area)); |
|
109 value->obj = buf; |
117 value->obj = buf; |
110 if(!value->undomgr) { |
118 if(!value->undomgr) { |
111 value->undomgr = ui_create_undomgr(); |
119 value->undomgr = ui_create_undomgr(); |
112 } |
120 } |
113 |
121 |
197 GtkTextBuffer *buf = text->obj; |
216 GtkTextBuffer *buf = text->obj; |
198 GtkTextIter start; |
217 GtkTextIter start; |
199 GtkTextIter end; |
218 GtkTextIter end; |
200 gtk_text_buffer_get_bounds(buf, &start, &end); |
219 gtk_text_buffer_get_bounds(buf, &start, &end); |
201 return gtk_text_iter_get_offset(&end); |
220 return gtk_text_iter_get_offset(&end); |
|
221 } |
|
222 |
|
223 void ui_textarea_remove(UiText *text, int begin, int end) { |
|
224 GtkTextBuffer *buf = text->obj; |
|
225 GtkTextIter ib; |
|
226 GtkTextIter ie; |
|
227 gtk_text_buffer_get_iter_at_offset(buf, &ib, begin); |
|
228 gtk_text_buffer_get_iter_at_offset(buf, &ie, end); |
|
229 gtk_text_buffer_delete(buf, &ib, &ie); |
202 } |
230 } |
203 |
231 |
204 void ui_textarea_realize_event(GtkWidget *widget, gpointer data) { |
232 void ui_textarea_realize_event(GtkWidget *widget, gpointer data) { |
205 gtk_widget_grab_focus(widget); |
233 gtk_widget_grab_focus(widget); |
206 } |
234 } |