ui/gtk/text.c

changeset 29
c96169444d88
parent 27
77b09bb52ca0
child 33
458831c574f4
equal deleted inserted replaced
28:794a5c91c479 29:c96169444d88
101 value->set = ui_textarea_set; 101 value->set = ui_textarea_set;
102 value->getsubstr = ui_textarea_getsubstr; 102 value->getsubstr = ui_textarea_getsubstr;
103 value->insert = ui_textarea_insert; 103 value->insert = ui_textarea_insert;
104 value->position = ui_textarea_position; 104 value->position = ui_textarea_position;
105 value->selection = ui_textarea_selection; 105 value->selection = ui_textarea_selection;
106 value->length = ui_textarea_length;
106 value->value = NULL; 107 value->value = NULL;
107 GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_area)); 108 GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_area));
108 value->obj = buf; 109 value->obj = buf;
109 if(!value->undomgr) { 110 if(!value->undomgr) {
110 value->undomgr = ui_create_undomgr(); 111 value->undomgr = ui_create_undomgr();
190 gtk_text_buffer_get_selection_bounds(text->obj, &b, &e); 191 gtk_text_buffer_get_selection_bounds(text->obj, &b, &e);
191 *begin = gtk_text_iter_get_offset(&b); 192 *begin = gtk_text_iter_get_offset(&b);
192 *end = gtk_text_iter_get_offset(&e); 193 *end = gtk_text_iter_get_offset(&e);
193 } 194 }
194 195
196 int ui_textarea_length(UiText *text) {
197 GtkTextBuffer *buf = text->obj;
198 GtkTextIter start;
199 GtkTextIter end;
200 gtk_text_buffer_get_bounds(buf, &start, &end);
201 return gtk_text_iter_get_offset(&end);
202 }
203
195 void ui_textarea_realize_event(GtkWidget *widget, gpointer data) { 204 void ui_textarea_realize_event(GtkWidget *widget, gpointer data) {
196 gtk_widget_grab_focus(widget); 205 gtk_widget_grab_focus(widget);
197 } 206 }
198 207
199 208

mercurial