ui/gtk/text.c

changeset 90
2019fdbaadfd
parent 65
4697592e24ba
child 94
d51e334c1439
equal deleted inserted replaced
89:9a7e4a335b2b 90:2019fdbaadfd
108 108
109 value->get = ui_textarea_get; 109 value->get = ui_textarea_get;
110 value->set = ui_textarea_set; 110 value->set = ui_textarea_set;
111 value->getsubstr = ui_textarea_getsubstr; 111 value->getsubstr = ui_textarea_getsubstr;
112 value->insert = ui_textarea_insert; 112 value->insert = ui_textarea_insert;
113 value->setposition = ui_textarea_setposition;
113 value->position = ui_textarea_position; 114 value->position = ui_textarea_position;
114 value->selection = ui_textarea_selection; 115 value->selection = ui_textarea_selection;
115 value->length = ui_textarea_length; 116 value->length = ui_textarea_length;
116 value->remove = ui_textarea_remove; 117 value->remove = ui_textarea_remove;
117 value->value = NULL; 118 value->value = NULL;
196 GtkTextIter offset; 197 GtkTextIter offset;
197 gtk_text_buffer_get_iter_at_offset(text->obj, &offset, pos); 198 gtk_text_buffer_get_iter_at_offset(text->obj, &offset, pos);
198 gtk_text_buffer_insert(text->obj, &offset, str, -1); 199 gtk_text_buffer_insert(text->obj, &offset, str, -1);
199 } 200 }
200 201
202 void ui_textarea_setposition(UiText *text, int pos) {
203 GtkTextIter iter;
204 gtk_text_buffer_get_iter_at_offset(text->obj, &iter, pos);
205 gtk_text_buffer_place_cursor(text->obj, &iter);
206 }
207
201 int ui_textarea_position(UiText *text) { 208 int ui_textarea_position(UiText *text) {
202 GtkTextIter begin; 209 GtkTextIter begin;
203 GtkTextIter end; 210 GtkTextIter end;
204 gtk_text_buffer_get_selection_bounds(text->obj, &begin, &end); 211 gtk_text_buffer_get_selection_bounds(text->obj, &begin, &end);
205 return gtk_text_iter_get_offset(&begin); 212 text->pos = gtk_text_iter_get_offset(&begin);
213 return text->pos;
206 } 214 }
207 215
208 void ui_textarea_selection(UiText *text, int *begin, int *end) { 216 void ui_textarea_selection(UiText *text, int *begin, int *end) {
209 GtkTextIter b; 217 GtkTextIter b;
210 GtkTextIter e; 218 GtkTextIter e;

mercurial