]> git.lyx.org Git - lyx.git/blobdiff - src/callback.cpp
Allow dissolution of insets inside mathed
[lyx.git] / src / callback.cpp
index 022181e7444743f108d0148f8fd18e87610f9c99..e21172a6bc7d748c4cb920b037a9d94cf8bd78ae 100644 (file)
@@ -195,10 +195,12 @@ bool writeAs(Buffer * buffer, string const & newname)
        buffer->markDirty();
        bool unnamed = buffer->isUnnamed();
        buffer->setUnnamed(false);
+       buffer->saveCheckSum(fname);
 
        if (!menuWrite(buffer)) {
                buffer->setFileName(oldname);
                buffer->setUnnamed(unnamed);
+               buffer->saveCheckSum(oldname);
                return false;
        }
 
@@ -212,8 +214,8 @@ namespace {
 class AutoSaveBuffer : public ForkedProcess {
 public:
        ///
-       AutoSaveBuffer(BufferView & bv, FileName const & fname)
-               : bv_(bv), fname_(fname) {}
+       AutoSaveBuffer(Buffer & buffer, FileName const & fname)
+               : buffer_(buffer), fname_(fname) {}
        ///
        virtual shared_ptr<ForkedProcess> clone() const
        {
@@ -225,7 +227,7 @@ private:
        ///
        virtual int generateChild();
        ///
-       BufferView & bv_;
+       Buffer & buffer_;
        FileName fname_;
 };
 
@@ -253,7 +255,7 @@ int AutoSaveBuffer::generateChild()
 
                FileName const tmp_ret(tempName(FileName(), "lyxauto"));
                if (!tmp_ret.empty()) {
-                       bv_.buffer()->writeFile(tmp_ret);
+                       buffer_.writeFile(tmp_ret);
                        // assume successful write of tmp_ret
                        if (!rename(tmp_ret, fname_)) {
                                failed = true;
@@ -269,12 +271,11 @@ int AutoSaveBuffer::generateChild()
 
                if (failed) {
                        // failed to write/rename tmp_ret so try writing direct
-                       if (!bv_.buffer()->writeFile(fname_)) {
+                       if (!buffer_.writeFile(fname_)) {
                                // It is dangerous to do this in the child,
                                // but safe in the parent, so...
                                if (pid == -1) // emit message signal.
-                                       bv_.buffer()
-                                         ->message(_("Autosave failed!"));
+                                       buffer_.message(_("Autosave failed!"));
                        }
                }
                if (pid == 0) { // we are the child so...
@@ -291,29 +292,27 @@ void autoSave(BufferView * bv)
        // should probably be moved into BufferList (Lgb)
        // Perfect target for a thread...
 {
-       if (!bv->buffer())
-               return;
-
-       if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) {
+       Buffer & buf = bv->buffer();
+       if (buf.isBakClean() || buf.isReadonly()) {
                // We don't save now, but we'll try again later
-               bv->buffer()->resetAutosaveTimers();
+               buf.resetAutosaveTimers();
                return;
        }
 
        // emit message signal.
-       bv->buffer()->message(_("Autosaving current document..."));
+       buf.message(_("Autosaving current document..."));
 
        // create autosave filename
-       string fname = bv->buffer()->filePath();
+       string fname = buf.filePath();
        fname += '#';
-       fname += onlyFilename(bv->buffer()->fileName());
+       fname += onlyFilename(buf.fileName());
        fname += '#';
 
-       AutoSaveBuffer autosave(*bv, FileName(fname));
+       AutoSaveBuffer autosave(buf, FileName(fname));
        autosave.start();
 
-       bv->buffer()->markBakClean();
-       bv->buffer()->resetAutosaveTimers();
+       buf.markBakClean();
+       buf.resetAutosaveTimers();
 }
 
 
@@ -324,7 +323,7 @@ void autoSave(BufferView * bv)
 // create new file with template
 // SERVERCMD !
 //
-void newFile(BufferView * bv, string const & filename)
+void newFile(LyXView & lv, string const & filename)
 {
        // Split argument by :
        string name;
@@ -335,16 +334,13 @@ void newFile(BufferView * bv, string const & filename)
 
        Buffer * const b = newFile(name, tmpname);
        if (b)
-               bv->setBuffer(b);
+               lv.setBuffer(b);
 }
 
 
 // Insert plain text file (if filename is empty, prompt for one)
 void insertPlaintextFile(BufferView * bv, string const & f, bool asParagraph)
 {
-       if (!bv->buffer())
-               return;
-
        docstring const tmpstr =
          getContentsOfPlaintextFile(bv, f, asParagraph);
 
@@ -373,7 +369,7 @@ docstring const getContentsOfPlaintextFile(BufferView * bv, string const & f,
                                     : LFUN_FILE_INSERT_PLAINTEXT) );
 
                FileDialog::Result result =
-                       fileDlg.open(from_utf8(bv->buffer()->filePath()),
+                       fileDlg.open(from_utf8(bv->buffer().filePath()),
                                     FileFilterList(), docstring());
 
                if (result.first == FileDialog::Later)
@@ -441,14 +437,15 @@ docstring const getContentsOfPlaintextFile(BufferView * bv, string const & f,
 
 // This function runs "configure" and then rereads lyx.defaults to
 // reconfigure the automatic settings.
-void reconfigure(LyXView & lv)
+void reconfigure(LyXView & lv, string const & option)
 {
        // emit message signal.
        lv.message(_("Running configure..."));
 
        // Run configure in user lyx directory
        support::Path p(package().user_support());
-       string const configure_command = package().configure_command();
+       string configure_command = package().configure_command();
+       configure_command += option;
        Systemcall one;
        one.startscript(Systemcall::Wait, configure_command);
        p.pop();