~ubuntu-branches/ubuntu/trusty/bluefish/trusty

« back to all changes in this revision

Viewing changes to src/doc_text_tools.c

  • Committer: Package Import Robot
  • Author(s): Daniel Leidert
  • Date: 2012-06-27 22:28:39 UTC
  • mfrom: (1.2.9)
  • Revision ID: package-import@ubuntu.com-20120627222839-5g0f5s6gpaezfhve
Tags: 2.2.3-1
* New upstream release.
* debian/control: Dropped DM-Upload-Allowed.
  (Maintainer): Set to my new address.
  (Suggests): Calculate browsers depending on distribution.
  (Depends): Added python depends for newly shipped Python scripts.
* debian/copyright: Minor update. Link to GPLv2 text.
* debian/rules: Enabled hardening. Added python2 module. Calculate brwoser
  dependencies via dpkg-vendor.
* debian/patches/LP810663_blacklist_from_appmenu.patch: Adjusted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
483
483
        gtk_text_buffer_delete(doc->buffer, &it1,&it2);
484
484
        doc_unre_new_group(doc);
485
485
}
 
486
 
 
487
void
 
488
doc_move_selection(Tdocument *doc, gboolean up)
 
489
{
 
490
        GtkTextIter so, eo;
 
491
        gchar *text;
 
492
        gint offset, size;
 
493
        if (!gtk_text_buffer_get_selection_bounds(doc->buffer, &so, &eo)) {
 
494
                return;
 
495
        }
 
496
        /* so and eo are guaranteed to be in ascending order */
 
497
        doc_unre_new_group(doc);
 
498
        doc_block_undo_reg(doc);
 
499
        
 
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);
 
506
 
 
507
        /* now we have to move the cursor up */
 
508
        gtk_text_buffer_get_iter_at_offset(doc->buffer, &so, offset);
 
509
        if (up) {
 
510
                gtk_text_iter_backward_line(&so);
 
511
        } else {
 
512
                gtk_text_iter_forward_line(&so);
 
513
        }
 
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);
 
517
        g_free(text);
 
518
 
 
519
        doc_unblock_undo_reg(doc);
 
520
        doc_set_modified(doc, 1);
 
521
        doc_unre_new_group(doc);
 
522
        
 
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);
 
528
}
 
529
 
 
530
void
 
531
doc_insert_filename(Tdocument *doc, gboolean relative)
 
532
{
 
533
        gchar *tmp, *relativeto=NULL;
 
534
        if (relative && doc->uri) {
 
535
                relativeto = g_file_get_uri(doc->uri);
 
536
        }
 
537
        tmp = run_file_select_dialog(GTK_WINDOW(BFWIN(doc->bfwin)->main_window)
 
538
                                                        , NULL, relativeto,GTK_FILE_CHOOSER_ACTION_OPEN);
 
539
        if (tmp)
 
540
                doc_insert_two_strings(doc, tmp, NULL); 
 
541
        g_free(relativeto);
 
542
        g_free(tmp);
 
543
}