ui/gtk/text.c

changeset 8
84a541c6e093
parent 6
05a18c56d9ca
child 9
e70e855cea89
equal deleted inserted replaced
7:431dde3c5fbe 8:84a541c6e093
128 UiUndoMgr *mgr = value->undomgr; 128 UiUndoMgr *mgr = value->undomgr;
129 if(!mgr->event) { 129 if(!mgr->event) {
130 return; 130 return;
131 } 131 }
132 132
133 printf("insert\n");
134 if(mgr->cur) { 133 if(mgr->cur) {
135 UcxList *elm = mgr->cur->next; 134 UcxList *elm = mgr->cur->next;
136 while(elm) { 135 while(elm) {
137 ui_free_textbuf_op(elm->data); 136 ui_free_textbuf_op(elm->data);
138 UcxList *next = elm->next; 137 UcxList *next = elm->next;
183 UiUndoMgr *mgr = value->undomgr; 182 UiUndoMgr *mgr = value->undomgr;
184 if(!mgr->event) { 183 if(!mgr->event) {
185 return; 184 return;
186 } 185 }
187 186
188 printf("delete\n");
189 if(mgr->cur) { 187 if(mgr->cur) {
190 UcxList *elm = mgr->cur->next; 188 UcxList *elm = mgr->cur->next;
191 while(elm) { 189 while(elm) {
192 ui_free_textbuf_op(elm->data); 190 ui_free_textbuf_op(elm->data);
193 UcxList *next = elm->next; 191 UcxList *next = elm->next;
278 mgr->cur = mgr->cur->prev; 276 mgr->cur = mgr->cur->prev;
279 } 277 }
280 } 278 }
281 279
282 void ui_text_redo(UiText *value) { 280 void ui_text_redo(UiText *value) {
283 281 UiUndoMgr *mgr = value->undomgr;
284 } 282
283 UcxList *elm = NULL;
284 if(mgr->cur) {
285 if(mgr->cur->next) {
286 elm = mgr->cur->next;
287 }
288 } else if(mgr->begin) {
289 elm = mgr->begin;
290 }
291
292 if(elm) {
293 UiTextBufOp *op = elm->data;
294 mgr->event = 0;
295 switch(op->type) {
296 case UI_TEXTBUF_INSERT: {
297 GtkTextIter begin;
298 GtkTextIter end;
299 gtk_text_buffer_get_iter_at_offset(value->obj, &begin, op->start);
300 gtk_text_buffer_get_iter_at_offset(value->obj, &end, op->end);
301 gtk_text_buffer_insert(value->obj, &begin, op->text, op->len);
302 break;
303 }
304 case UI_TEXTBUF_DELETE: {
305 GtkTextIter begin;
306 GtkTextIter end;
307 gtk_text_buffer_get_iter_at_offset(value->obj, &begin, op->start);
308 gtk_text_buffer_get_iter_at_offset(value->obj, &end, op->end);
309 gtk_text_buffer_delete(value->obj, &begin, &end);
310 break;
311 }
312 }
313 mgr->event = 1;
314 mgr->cur = elm;
315 }
316 }

mercurial