ui/gtk/text.c

changeset 27
77b09bb52ca0
parent 22
bcf880b29bc3
child 29
c96169444d88
equal deleted inserted replaced
26:a137277f9173 27:77b09bb52ca0
99 if(value) { 99 if(value) {
100 value->get = ui_textarea_get; 100 value->get = ui_textarea_get;
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;
105 value->selection = ui_textarea_selection;
104 value->value = NULL; 106 value->value = NULL;
105 GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_area)); 107 GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_area));
106 value->obj = buf; 108 value->obj = buf;
107 if(!value->undomgr) { 109 if(!value->undomgr) {
108 value->undomgr = ui_create_undomgr(); 110 value->undomgr = ui_create_undomgr();
173 GtkTextIter offset; 175 GtkTextIter offset;
174 gtk_text_buffer_get_iter_at_offset(text->obj, &offset, pos); 176 gtk_text_buffer_get_iter_at_offset(text->obj, &offset, pos);
175 gtk_text_buffer_insert(text->obj, &offset, str, -1); 177 gtk_text_buffer_insert(text->obj, &offset, str, -1);
176 } 178 }
177 179
180 int ui_textarea_position(UiText *text) {
181 GtkTextIter begin;
182 GtkTextIter end;
183 gtk_text_buffer_get_selection_bounds(text->obj, &begin, &end);
184 return gtk_text_iter_get_offset(&begin);
185 }
186
187 void ui_textarea_selection(UiText *text, int *begin, int *end) {
188 GtkTextIter b;
189 GtkTextIter e;
190 gtk_text_buffer_get_selection_bounds(text->obj, &b, &e);
191 *begin = gtk_text_iter_get_offset(&b);
192 *end = gtk_text_iter_get_offset(&e);
193 }
194
178 void ui_textarea_realize_event(GtkWidget *widget, gpointer data) { 195 void ui_textarea_realize_event(GtkWidget *widget, gpointer data) {
179 gtk_widget_grab_focus(widget); 196 gtk_widget_grab_focus(widget);
180 } 197 }
181 198
182 199

mercurial