~ubuntu-branches/ubuntu/jaunty/geany/jaunty

« back to all changes in this revision

Viewing changes to src/document.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2007-02-25 21:12:13 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20070225211213-nqjkqq5yxkyxja9n
Tags: upstream-0.10.2
Import upstream version 0.10.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *      document.c - this file is part of Geany, a fast and lightweight IDE
3
3
 *
4
 
 *      Copyright 2006 Enrico Troeger <enrico.troeger@uvena.de>
 
4
 *      Copyright 2005-2007 Enrico Tröger <enrico.troeger@uvena.de>
 
5
 *      Copyright 2006-2007 Nick Treleaven <nick.treleaven@btinternet.com>
5
6
 *
6
7
 *      This program is free software; you can redistribute it and/or modify
7
8
 *      it under the terms of the GNU General Public License as published by
17
18
 *      along with this program; if not, write to the Free Software
18
19
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20
 *
20
 
 * $Id: document.c 1120 2006-12-18 15:58:00Z ntrel $
 
21
 * $Id: document.c 1316 2007-02-22 12:41:48Z ntrel $
21
22
 */
22
23
 
23
24
#include "geany.h"
74
75
 
75
76
 
76
77
 
77
 
/* returns the index of the notebook page which has the given filename
 
78
/* returns the document index which has the given filename.
78
79
 * is_tm_filename is needed when passing TagManager filenames because they are
79
80
 * dereferenced, and would not match the link filename. */
80
81
gint document_find_by_filename(const gchar *filename, gboolean is_tm_filename)
98
99
}
99
100
 
100
101
 
101
 
/* returns the index of the notebook page which has sci */
 
102
/* returns the document index which has sci */
102
103
gint document_find_by_sci(ScintillaObject *sci)
103
104
{
104
105
        guint i;
113
114
}
114
115
 
115
116
 
 
117
/* returns the index of the notebook page from the document index */
 
118
gint document_get_notebook_page(gint doc_idx)
 
119
{
 
120
        if (! DOC_IDX_VALID(doc_idx)) return -1;
 
121
 
 
122
        return gtk_notebook_page_num(GTK_NOTEBOOK(app->notebook),
 
123
                GTK_WIDGET(doc_list[doc_idx].sci));
 
124
}
 
125
 
 
126
 
116
127
/* returns the index of the given notebook page in the document list */
117
128
gint document_get_n_idx(guint page_num)
118
129
{
207
218
        new_doc->sci = NULL;
208
219
        new_doc->undo_actions = NULL;
209
220
        new_doc->redo_actions = NULL;
 
221
        new_doc->scroll_percent = -1.0F;
210
222
}
211
223
 
212
224
 
348
360
                doc_list[idx].encoding = NULL;
349
361
                doc_list[idx].has_bom = FALSE;
350
362
                doc_list[idx].tm_file = NULL;
 
363
                doc_list[idx].scroll_percent = -1.0F;
351
364
                document_undo_clear(idx);
352
365
                if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0)
353
366
                {
405
418
        if (ft == NULL) filetypes[GEANY_FILETYPES_ALL]->style_func_ptr(doc_list[idx].sci);
406
419
        ui_set_window_title(idx);
407
420
        build_menu_update(idx);
 
421
 
408
422
        doc_list[idx].mtime = time(NULL);
409
423
        doc_list[idx].changed = FALSE;
 
424
 
 
425
        document_update_tag_list(idx, FALSE);
410
426
        document_set_text_changed(idx);
411
427
        ui_document_show_hide(idx); //update the document menu
412
428
 
421
437
}
422
438
 
423
439
 
 
440
typedef struct
 
441
{
 
442
        gchar           *data;  // null-terminated file data
 
443
        gsize            len;   // string length of data
 
444
        gchar           *enc;
 
445
        gboolean         bom;
 
446
        time_t           mtime; // modification time, read by stat::st_mtime
 
447
        gboolean         readonly;
 
448
} FileData;
 
449
 
 
450
 
424
451
// reload file with specified encoding
425
452
static gboolean
426
 
handle_forced_encoding(gchar **data, gsize *size, const gchar *forced_enc, gchar **enc,
427
 
        gboolean *bom)
 
453
handle_forced_encoding(FileData *filedata, const gchar *forced_enc)
428
454
{
 
455
        GeanyEncodingIndex enc_idx;
 
456
 
429
457
        if (utils_str_equal(forced_enc, "UTF-8"))
430
458
        {
431
 
                if (! g_utf8_validate(*data, *size, NULL))
 
459
                if (! g_utf8_validate(filedata->data, filedata->len, NULL))
432
460
                {
433
461
                        return FALSE;
434
462
                }
435
 
                else
436
 
                {
437
 
                        *bom = utils_str_equal(utils_scan_unicode_bom(*data), "UTF-8");
438
 
                        *enc = g_strdup(forced_enc);
439
 
                }
440
463
        }
441
464
        else
442
465
        {
443
466
                gchar *converted_text = encodings_convert_to_utf8_from_charset(
444
 
                                                                                                        *data, *size, forced_enc, FALSE);
 
467
                                                                                filedata->data, filedata->len, forced_enc, FALSE);
445
468
                if (converted_text == NULL)
446
469
                {
447
470
                        return FALSE;
448
471
                }
449
472
                else
450
473
                {
451
 
                        g_free(*data);
452
 
                        *data = (void*)converted_text;
453
 
                        *size = strlen(converted_text);
454
 
                        *bom = utils_str_equal(utils_scan_unicode_bom(*data), "UTF-8");
455
 
                        *enc = g_strdup(forced_enc);
 
474
                        g_free(filedata->data);
 
475
                        filedata->data = converted_text;
 
476
                        filedata->len = strlen(converted_text);
456
477
                }
457
478
        }
 
479
        enc_idx = encodings_scan_unicode_bom(filedata->data, filedata->len, NULL);
 
480
        filedata->bom = (enc_idx == GEANY_ENCODING_UTF_8);
 
481
        filedata->enc = g_strdup(forced_enc);
458
482
        return TRUE;
459
483
}
460
484
 
461
485
 
 
486
// detect encoding and convert to UTF-8 if necessary
462
487
static gboolean
463
 
handle_encoding(gchar **data, gsize *size, gchar **enc, gboolean *bom)
 
488
handle_encoding(FileData *filedata)
464
489
{
465
 
        if (*size > 0)
466
 
        {       // the usual way to detect encoding and convert to UTF-8
467
 
                if (*size >= 4)
468
 
                {
469
 
                        *enc = utils_scan_unicode_bom(*data);
470
 
                }
471
 
                if (*enc != NULL)
472
 
                {
473
 
                        *bom = TRUE;
474
 
                        if ((*enc)[4] != '8') // the BOM indicated something else than UTF-8
 
490
        g_return_val_if_fail(filedata->enc == NULL, FALSE);
 
491
        g_return_val_if_fail(filedata->bom == FALSE, FALSE);
 
492
 
 
493
        if (filedata->len == 0)
 
494
        {
 
495
                // we have no data so assume UTF-8
 
496
                filedata->enc = g_strdup("UTF-8");
 
497
        }
 
498
        else
 
499
        {
 
500
                // first check for a BOM
 
501
                GeanyEncodingIndex enc_idx =
 
502
                        encodings_scan_unicode_bom(filedata->data, filedata->len, NULL);
 
503
 
 
504
                if (enc_idx != GEANY_ENCODING_NONE)
 
505
                {
 
506
                        filedata->enc = g_strdup(encodings[enc_idx].charset);
 
507
                        filedata->bom = TRUE;
 
508
 
 
509
                        if (enc_idx != GEANY_ENCODING_UTF_8) // the BOM indicated something else than UTF-8
475
510
                        {
476
511
                                gchar *converted_text = encodings_convert_to_utf8_from_charset(
477
 
                                                                                                                        *data, *size, *enc, FALSE);
478
 
                                if (converted_text == NULL)
 
512
                                                                                filedata->data, filedata->len, filedata->enc, FALSE);
 
513
                                if (converted_text != NULL)
479
514
                                {
480
 
                                        g_free(*enc);
481
 
                                        *enc = NULL;
482
 
                                        *bom = FALSE;
 
515
                                        g_free(filedata->data);
 
516
                                        filedata->data = converted_text;
 
517
                                        filedata->len = strlen(converted_text);
483
518
                                }
484
519
                                else
485
520
                                {
486
 
                                        g_free(*data);
487
 
                                        *data = (void*)converted_text;
488
 
                                        *size = strlen(converted_text);
 
521
                                        // there was a problem converting data from BOM encoding type
 
522
                                        g_free(filedata->enc);
 
523
                                        filedata->enc = NULL;
 
524
                                        filedata->bom = FALSE;
489
525
                                }
490
526
                        }
491
527
                }
492
 
                // this if is important, else doesn't work because enc can be altered in the above block
493
 
                if (*enc == NULL)
 
528
 
 
529
                if (filedata->enc == NULL)      // either there was no BOM or the BOM encoding failed
494
530
                {
495
 
                        if (g_utf8_validate(*data, *size, NULL))
 
531
                        // try UTF-8 first
 
532
                        if (g_utf8_validate(filedata->data, filedata->len, NULL))
496
533
                        {
497
 
                                *enc = g_strdup("UTF-8");
 
534
                                filedata->enc = g_strdup("UTF-8");
498
535
                        }
499
536
                        else
500
537
                        {
501
 
                                gchar *converted_text = encodings_convert_to_utf8(*data, *size, enc);
 
538
                                // detect the encoding
 
539
                                gchar *converted_text = encodings_convert_to_utf8(filedata->data,
 
540
                                        filedata->len, &filedata->enc);
502
541
 
503
542
                                if (converted_text == NULL)
504
543
                                {
505
544
                                        return FALSE;
506
545
                                }
507
 
                                else
508
 
                                {
509
 
                                        g_free(*data);
510
 
                                        *data = (void*)converted_text;
511
 
                                        *size = strlen(converted_text);
512
 
                                }
 
546
                                g_free(filedata->data);
 
547
                                filedata->data = converted_text;
 
548
                                filedata->len = strlen(converted_text);
513
549
                        }
514
550
                }
515
551
        }
516
 
        else
517
 
        {
518
 
                *enc = g_strdup("UTF-8");
519
 
        }
520
552
        return TRUE;
521
553
}
522
554
 
523
555
 
524
556
static void
525
 
handle_bom(gchar **data)
526
 
{
527
 
        gchar *data_without_bom;
528
 
        data_without_bom = g_strdup(*data + 3);
529
 
        g_free(*data);
530
 
        *data = data_without_bom;
 
557
handle_bom(FileData *filedata)
 
558
{
 
559
        guint bom_len;
 
560
 
 
561
        encodings_scan_unicode_bom(filedata->data, filedata->len, &bom_len);
 
562
        g_return_if_fail(bom_len != 0);
 
563
 
 
564
        filedata->len -= bom_len;
 
565
        // overwrite the BOM with the remainder of the file contents, plus the NULL terminator.
 
566
        g_memmove(filedata->data, filedata->data + bom_len, filedata->len + 1);
 
567
        filedata->data = g_realloc(filedata->data, filedata->len + 1);
 
568
}
 
569
 
 
570
 
 
571
/* loads textfile data, verifies and converts to forced_enc or UTF-8. Also handles BOM. */
 
572
static gboolean load_text_file(const gchar *locale_filename, const gchar *utf8_filename,
 
573
                FileData *filedata, const gchar *forced_enc)
 
574
{
 
575
        GError *err = NULL;
 
576
        struct stat st;
 
577
 
 
578
        filedata->data = NULL;
 
579
        filedata->len = 0;
 
580
        filedata->enc = NULL;
 
581
        filedata->bom = FALSE;
 
582
        filedata->readonly = FALSE;
 
583
 
 
584
        if (stat(locale_filename, &st) != 0)
 
585
        {
 
586
                msgwin_status_add(_("Could not open file %s (%s)"), utf8_filename, g_strerror(errno));
 
587
                return FALSE;
 
588
        }
 
589
 
 
590
        filedata->mtime = st.st_mtime;
 
591
 
 
592
#ifdef G_OS_WIN32
 
593
        if (! g_file_get_contents(utf8_filename, &filedata->data, NULL, &err))
 
594
#else
 
595
        if (! g_file_get_contents(locale_filename, &filedata->data, NULL, &err))
 
596
#endif
 
597
        {
 
598
                msgwin_status_add(err->message);
 
599
                g_error_free(err);
 
600
                return FALSE;
 
601
        }
 
602
 
 
603
        // use strlen to check for null chars
 
604
        filedata->len = strlen(filedata->data);
 
605
 
 
606
        /* check whether the size of the loaded data is equal to the size of the file in the filesystem */
 
607
        if (filedata->len != (gsize) st.st_size)
 
608
        {
 
609
                gchar *warn_msg = _("The file \"%s\" could not be opened properly and has been truncated. "
 
610
                                "This can occur if the file contains a NULL byte. "
 
611
                                "Be aware that saving it can cause data loss.\nThe file was set to read-only.");
 
612
 
 
613
                if (app->main_window_realized)
 
614
                        dialogs_show_msgbox(GTK_MESSAGE_WARNING, warn_msg, utf8_filename);
 
615
 
 
616
                msgwin_status_add(warn_msg, utf8_filename);
 
617
 
 
618
                // set the file to read-only mode because saving it is probably dangerous
 
619
                filedata->readonly = TRUE;
 
620
        }
 
621
 
 
622
        /* Determine character encoding and convert to UTF-8 */
 
623
        if (forced_enc != NULL)
 
624
        {
 
625
                // the encoding should be ignored(requested by user), so open the file "as it is"
 
626
                if (utils_str_equal(forced_enc, encodings[GEANY_ENCODING_NONE].charset))
 
627
                {
 
628
                        filedata->bom = FALSE;
 
629
                        filedata->enc = g_strdup(encodings[GEANY_ENCODING_NONE].charset);
 
630
                }
 
631
                else if (! handle_forced_encoding(filedata, forced_enc))
 
632
                {
 
633
                        msgwin_status_add(_("The file \"%s\" is not valid %s."), utf8_filename, forced_enc);
 
634
                        utils_beep();
 
635
                        g_free(filedata->data);
 
636
                        return FALSE;
 
637
                }
 
638
        }
 
639
        else if (! handle_encoding(filedata))
 
640
        {
 
641
                msgwin_status_add(
 
642
                        _("The file \"%s\" does not look like a text file or the file encoding is not supported."),
 
643
                        utf8_filename);
 
644
                utils_beep();
 
645
                g_free(filedata->data);
 
646
                return FALSE;
 
647
        }
 
648
 
 
649
        if (filedata->bom)
 
650
                handle_bom(filedata);
 
651
        return TRUE;
 
652
}
 
653
 
 
654
 
 
655
/* Sets the cursor position on opening a file. First it sets the line when cl_options.goto_line
 
656
 * is set, otherwise it sets the line when pos is greater than zero. */
 
657
static void set_cursor_position(gint idx, gint pos)
 
658
{
 
659
        if (cl_options.goto_line >= 0)
 
660
        {       // goto line which was specified on command line and then undefine the line
 
661
                sci_goto_line(doc_list[idx].sci, cl_options.goto_line - 1, TRUE);
 
662
                doc_list[idx].scroll_percent = 0.5F;
 
663
                cl_options.goto_line = -1;
 
664
        }
 
665
        else if (pos > 0)
 
666
        {
 
667
                sci_set_current_position(doc_list[idx].sci, pos, FALSE);
 
668
                doc_list[idx].scroll_percent = 0.5F;
 
669
        }
531
670
}
532
671
 
533
672
 
541
680
                                           const gchar *forced_enc)
542
681
{
543
682
        gint editor_mode;
544
 
        gsize size;
545
683
        gboolean reload = (idx == -1) ? FALSE : TRUE;
546
 
        struct stat st;
547
 
        gboolean bom = FALSE;
548
 
        gchar *enc = NULL;
549
684
        gchar *utf8_filename = NULL;
550
685
        gchar *locale_filename = NULL;
551
 
        GError *err = NULL;
552
 
        gchar *data = NULL;
553
686
        filetype *use_ft;
 
687
        FileData filedata;
554
688
 
555
689
        //struct timeval tv, tv1;
556
690
        //struct timezone tz;
585
719
                        g_free(utf8_filename);
586
720
                        g_free(locale_filename);
587
721
                        utils_check_disk_status(idx, TRUE);     // force a file changed check
 
722
                        set_cursor_position(idx, pos);
588
723
                        return idx;
589
724
                }
590
725
        }
591
726
 
592
 
        if (stat(locale_filename, &st) != 0)
593
 
        {
594
 
                msgwin_status_add(_("Could not open file %s (%s)"), utf8_filename, g_strerror(errno));
595
 
                g_free(utf8_filename);
596
 
                g_free(locale_filename);
597
 
                return -1;
598
 
        }
599
 
 
600
 
#ifdef G_OS_WIN32
601
 
        if (! g_file_get_contents(utf8_filename, &data, NULL, &err))
602
 
#else
603
 
        if (! g_file_get_contents(locale_filename, &data, NULL, &err))
604
 
#endif
605
 
        {
606
 
                msgwin_status_add(err->message);
607
 
                g_error_free(err);
608
 
                g_free(utf8_filename);
609
 
                g_free(locale_filename);
610
 
                return -1;
611
 
        }
612
 
 
613
 
        /* check whether the size of the loaded data is equal to the size of the file in the filesystem */
614
 
        //size = strlen(data);
615
 
        size = strlen(data);
616
 
        if (size != (gsize) st.st_size)
617
 
        {
618
 
                gchar *warn_msg = _("The file \"%s\" could not opened properly and probably was truncated. "
619
 
                                "Be aware that saving it can cause data loss.\nThe file was set to read-only.");
620
 
 
621
 
                if (app->main_window_realized)
622
 
                        dialogs_show_msgbox(GTK_MESSAGE_WARNING, warn_msg, utf8_filename);
623
 
 
624
 
                msgwin_status_add(warn_msg, utf8_filename);
625
 
 
626
 
                // set the file to read-only mode because saving it is probably dangerous
627
 
                readonly = TRUE;
628
 
        }
629
 
 
630
 
        /* Determine character encoding and convert to UTF-8 */
631
 
        if (forced_enc != NULL)
632
 
        {
633
 
                // the encoding should be ignored(requested by user), so open the file "as it is"
634
 
                if (utils_str_equal(forced_enc, encodings[GEANY_ENCODING_NONE].charset))
635
 
                {
636
 
                        bom = FALSE;
637
 
                        enc = g_strdup(encodings[GEANY_ENCODING_NONE].charset);
638
 
                }
639
 
                else if (! handle_forced_encoding(&data, &size, forced_enc, &enc, &bom))
640
 
                {
641
 
                        msgwin_status_add(_("The file \"%s\" is not valid %s."), utf8_filename, forced_enc);
642
 
                        utils_beep();
643
 
                        g_free(data);
644
 
                        g_free(utf8_filename);
645
 
                        g_free(locale_filename);
646
 
                        return -1;
647
 
                }
648
 
        }
649
 
        else if (! handle_encoding(&data, &size, &enc, &bom))
650
 
        {
651
 
                msgwin_status_add(
652
 
                        _("The file \"%s\" does not look like a text file or the file encoding is not supported."),
653
 
                        utf8_filename);
654
 
                utils_beep();
655
 
                g_free(data);
656
 
                g_free(utf8_filename);
657
 
                g_free(locale_filename);
658
 
                return -1;
659
 
        }
660
 
 
661
 
        if (bom) handle_bom(&data);
 
727
        if (! load_text_file(locale_filename, utf8_filename, &filedata, forced_enc))
 
728
        {
 
729
                g_free(utf8_filename);
 
730
                g_free(locale_filename);
 
731
                return -1;
 
732
        }
662
733
 
663
734
        if (! reload) idx = document_create_new_sci(utf8_filename);
664
 
        if (idx == -1) return -1;       // really should not happen
 
735
        g_return_val_if_fail(idx != -1, -1);    // really should not happen
665
736
 
666
 
        // set editor mode and add the text to the ScintillaObject
667
737
        sci_set_undo_collection(doc_list[idx].sci, FALSE); // avoid creation of an undo action
668
738
        sci_empty_undo_buffer(doc_list[idx].sci);
669
 
        sci_set_text(doc_list[idx].sci, data);  // NULL terminated data
670
 
 
671
 
        editor_mode = utils_get_line_endings(data, size);
 
739
 
 
740
        // add the text to the ScintillaObject
 
741
        sci_set_text(doc_list[idx].sci, filedata.data); // NULL terminated data
 
742
 
 
743
        // detect & set line endings
 
744
        editor_mode = utils_get_line_endings(filedata.data, filedata.len);
672
745
        sci_set_eol_mode(doc_list[idx].sci, editor_mode);
673
 
        sci_set_line_numbers(doc_list[idx].sci, app->show_linenumber_margin, 0);
 
746
        g_free(filedata.data);
674
747
 
675
748
        sci_set_undo_collection(doc_list[idx].sci, TRUE);
676
749
 
677
 
        doc_list[idx].mtime = st.st_mtime; // get the modification time from file and keep it
 
750
        doc_list[idx].mtime = filedata.mtime; // get the modification time from file and keep it
678
751
        doc_list[idx].changed = FALSE;
679
752
        g_free(doc_list[idx].encoding); // if reloading, free old encoding
680
 
        doc_list[idx].encoding = enc;
681
 
        doc_list[idx].has_bom = bom;
 
753
        doc_list[idx].encoding = filedata.enc;
 
754
        doc_list[idx].has_bom = filedata.bom;
682
755
        store_saved_encoding(idx);      // store the opened encoding for undo/redo
683
756
 
684
 
        if (cl_options.goto_line >= 0)
685
 
        {       // goto line which was specified on command line and then undefine the line
686
 
                sci_goto_line(doc_list[idx].sci, cl_options.goto_line - 1, TRUE);
687
 
                sci_scroll_to_line(doc_list[idx].sci, -1, 0.5);
688
 
                cl_options.goto_line = -1;
689
 
        }
690
 
        else if (pos >= 0)
691
 
        {
692
 
                sci_goto_pos(doc_list[idx].sci, pos, FALSE);
693
 
                if (reload)
694
 
                        sci_scroll_to_line(doc_list[idx].sci, -1, 0.5);
695
 
        }
 
757
        doc_list[idx].readonly = readonly || filedata.readonly;
 
758
        sci_set_readonly(doc_list[idx].sci, doc_list[idx].readonly);
 
759
 
 
760
        // update line number margin width
 
761
        sci_set_line_numbers(doc_list[idx].sci, app->show_linenumber_margin, 0);
 
762
 
 
763
        // set the cursor position according to pos, cl_options.goto_line and cl_options.goto_column
 
764
        set_cursor_position(idx, pos);
696
765
 
697
766
        if (! reload)
698
767
        {
699
 
                doc_list[idx].readonly = readonly;
700
 
                sci_set_readonly(doc_list[idx].sci, readonly);
701
 
 
702
768
                // "the" SCI signal (connect after initial setup(i.e. adding text))
703
769
                g_signal_connect((GtkWidget*) doc_list[idx].sci, "sci-notify",
704
770
                                        G_CALLBACK(on_editor_notification), GINT_TO_POINTER(idx));
716
782
        document_set_text_changed(idx); // also updates tab state
717
783
        ui_document_show_hide(idx);     // update the document menu
718
784
 
719
 
        g_free(data);
720
 
 
721
785
 
722
786
        // finally add current file to recent files menu, but not the files from the last session
723
787
        if (! app->opening_session_files) ui_add_recent_file(utf8_filename);
840
904
        sci_convert_eols(doc_list[idx].sci, sci_get_eol_mode(doc_list[idx].sci));
841
905
 
842
906
        len = sci_get_length(doc_list[idx].sci) + 1;
843
 
        if (doc_list[idx].has_bom && utils_is_unicode_charset(doc_list[idx].encoding))
 
907
        if (doc_list[idx].has_bom && encodings_is_unicode_charset(doc_list[idx].encoding))
844
908
        {
845
909
                data = (gchar*) g_malloc(len + 3);      // 3 chars for BOM
846
910
                data[0] = 0xef;
979
1043
        {
980
1044
                sci_set_selection_start(doc_list[idx].sci, ttf.chrgText.cpMin);
981
1045
                sci_set_selection_end(doc_list[idx].sci, ttf.chrgText.cpMax);
982
 
                sci_scroll_to_line(doc_list[idx].sci, -1, 0.3);
 
1046
                doc_list[idx].scroll_percent = 0.3F;
983
1047
        }
984
1048
        else
985
1049
        {
1027
1091
        if (search_pos != -1)
1028
1092
        {
1029
1093
                if (scroll)
1030
 
                        sci_scroll_to_line(doc_list[idx].sci, -1, 0.3);
 
1094
                        doc_list[idx].scroll_percent = 0.3F;
1031
1095
        }
1032
1096
        else
1033
1097
        {
1552
1616
        gint max_lines = sci_get_line_count(doc_list[idx].sci);
1553
1617
        gint line;
1554
1618
 
 
1619
        sci_start_undo_action(doc_list[idx].sci);
 
1620
 
1555
1621
        for (line = 0; line < max_lines; line++)
1556
1622
        {
1557
1623
                gint line_start = sci_get_position_from_line(doc_list[idx].sci, line);
1571
1637
                        sci_target_replace(doc_list[idx].sci, "", FALSE);
1572
1638
                }
1573
1639
        }
 
1640
        sci_end_undo_action(doc_list[idx].sci);
1574
1641
}
1575
1642
 
1576
1643
 
1611
1678
 
1612
1679
        ui_update_statusbar(idx, -1);
1613
1680
        gtk_widget_set_sensitive(lookup_widget(app->window, "menu_write_unicode_bom1"),
1614
 
                        utils_is_unicode_charset(doc_list[idx].encoding));
 
1681
                        encodings_is_unicode_charset(doc_list[idx].encoding));
1615
1682
}
1616
1683
 
1617
1684