Browse Source

Back to not being able to load non-valid UTF-8 files. The replace-process was extremely slow on medium sized files.

merge-requests/365/head
eidheim 10 years ago
parent
commit
f40f407568
  1. 2
      src/source.cc
  2. 10
      src/sourcefile.cc

2
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();

10
src/sourcefile.cc

@ -25,16 +25,20 @@ int juci::filesystem::read(const std::string &path, Glib::RefPtr<Gtk::TextBuffer
Glib::ustring ustr=std::move(ss.str());
bool valid=true;
Glib::ustring::iterator iter;
//This was way too slow...
/*Glib::ustring::iterator iter;
while(!ustr.validate(iter)) {
auto next_char_iter=iter;
next_char_iter++;
ustr.replace(iter, next_char_iter, "?");
if(valid)
valid=false;
}
}*/
text_buffer->insert_at_cursor(ustr);
if(ustr.validate())
text_buffer->insert_at_cursor(ustr);
else
valid=false;
//TODO: maybe correct this, emphasis on maybe:
/*std::vector<char> buffer(buffer_size);

Loading…
Cancel
Save