483
483
gtk_text_buffer_delete(doc->buffer, &it1,&it2);
484
484
doc_unre_new_group(doc);
488
doc_move_selection(Tdocument *doc, gboolean up)
493
if (!gtk_text_buffer_get_selection_bounds(doc->buffer, &so, &eo)) {
496
/* so and eo are guaranteed to be in ascending order */
497
doc_unre_new_group(doc);
498
doc_block_undo_reg(doc);
500
offset = gtk_text_iter_get_offset(&so);
501
size = gtk_text_iter_get_offset(&eo)-offset;
502
text = gtk_text_buffer_get_text(doc->buffer,&so,&eo,TRUE);
503
/*g_print("doc_move_selection, got selection %d:%d\n",offset,offset+size);*/
504
gtk_text_buffer_delete(doc->buffer, &so, &eo);
505
doc_unre_add(doc, text, offset, offset+size, UndoDelete);
507
/* now we have to move the cursor up */
508
gtk_text_buffer_get_iter_at_offset(doc->buffer, &so, offset);
510
gtk_text_iter_backward_line(&so);
512
gtk_text_iter_forward_line(&so);
514
offset = gtk_text_iter_get_offset(&so);
515
gtk_text_buffer_insert(doc->buffer,&so,text,-1);
516
doc_unre_add(doc, text, offset, offset+size, UndoInsert);
519
doc_unblock_undo_reg(doc);
520
doc_set_modified(doc, 1);
521
doc_unre_new_group(doc);
523
/* and select the text again */
524
/*g_print("doc_move_selection, select %d:%d\n",offset,offset+size);*/
525
gtk_text_buffer_get_iter_at_offset(doc->buffer, &so, offset);
526
gtk_text_buffer_get_iter_at_offset(doc->buffer, &eo, offset+size);
527
gtk_text_buffer_select_range(doc->buffer,&so,&eo);
531
doc_insert_filename(Tdocument *doc, gboolean relative)
533
gchar *tmp, *relativeto=NULL;
534
if (relative && doc->uri) {
535
relativeto = g_file_get_uri(doc->uri);
537
tmp = run_file_select_dialog(GTK_WINDOW(BFWIN(doc->bfwin)->main_window)
538
, NULL, relativeto,GTK_FILE_CHOOSER_ACTION_OPEN);
540
doc_insert_two_strings(doc, tmp, NULL);