From f40f4075684c0dccfcf95c01ffa420470e800f4c Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 2 Sep 2015 12:46:47 +0200 Subject: [PATCH] Back to not being able to load non-valid UTF-8 files. The replace-process was extremely slow on medium sized files. --- src/source.cc | 2 +- src/sourcefile.cc | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/source.cc b/src/source.cc index adb8d1f..fa1c734 100644 --- a/src/source.cc +++ b/src/source.cc @@ -52,7 +52,7 @@ Source::View::View(const boost::filesystem::path &file_path): file_path(file_pat set_smart_home_end(Gsv::SMART_HOME_END_BEFORE); get_source_buffer()->begin_not_undoable_action(); if(juci::filesystem::read(file_path, get_buffer())==-1) - Singleton::terminal()->print("Warning: "+file_path.string()+" is not a valid UTF-8 file. Saving might corrupt the file.\n", true); + Singleton::terminal()->print("Error: "+file_path.string()+" is not a valid UTF-8 file."); get_source_buffer()->end_not_undoable_action(); get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(0)); search_settings = gtk_source_search_settings_new(); diff --git a/src/sourcefile.cc b/src/sourcefile.cc index 459390e..2ee7219 100644 --- a/src/sourcefile.cc +++ b/src/sourcefile.cc @@ -25,16 +25,20 @@ int juci::filesystem::read(const std::string &path, Glib::RefPtrinsert_at_cursor(ustr); + if(ustr.validate()) + text_buffer->insert_at_cursor(ustr); + else + valid=false; //TODO: maybe correct this, emphasis on maybe: /*std::vector buffer(buffer_size);