]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
LFUN_EXTERNAL_EDIT.
[lyx.git] / src / lyxfunc.C
index 1ce5d3adb1a0afde10c09f54c8b2fe0740a0ef85..332f0eb267e73c260b93ada64eb4de96a49e1b99 100644 (file)
@@ -15,6 +15,7 @@
 #include "kbmap.h"
 #include "lyxrow.h"
 #include "bufferlist.h"
+#include "buffer.h"
 #include "BufferView.h"
 #include "lyxserver.h"
 #include "intl.h"
@@ -43,6 +44,7 @@
 #include "ParagraphParameters.h"
 
 #include "insets/insetcommand.h"
+#include "insets/insetexternal.h"
 #include "insets/insettabular.h"
 
 #include "mathed/formulamacro.h"
@@ -63,6 +65,7 @@
 #include "support/FileInfo.h"
 #include "support/forkedcontr.h"
 #include "support/lstrings.h"
+#include "support/tostr.h"
 #include "support/path.h"
 #include "support/lyxfunctional.h"
 
@@ -489,7 +492,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_INSET_SETTINGS: {
                disable = true;
                UpdatableInset * inset = view()->theLockingInset();
-               
+
                if (!inset)
                        break;
 
@@ -499,7 +502,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                // jump back to owner if an InsetText, so
                // we get back to the InsetTabular or whatever
                if (inset->lyxCode() == Inset::TEXT_CODE)
-                       inset = static_cast<UpdatableInset*>(inset->owner());
+                       inset = inset->owner();
 
                Inset::Code code = inset->lyxCode();
                switch (code) {
@@ -643,9 +646,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_TOC_INSERT:
                code = Inset::TOC_CODE;
                break;
-       case LFUN_PARENTINSERT:
-               code = Inset::PARENT_CODE;
-               break;
        case LFUN_HTMLURL:
        case LFUN_URL:
                code = Inset::URL_CODE;
@@ -662,10 +662,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_END_OF_SENTENCE:
                code = Inset::SPECIALCHAR_CODE;
                break;
-       case LFUN_PROTECTEDSPACE:
+       case LFUN_SPACE_INSERT:
                // slight hack: we know this is allowed in math mode
                if (!mathcursor)
-                       code = Inset::SPECIALCHAR_CODE;
+                       code = Inset::SPACE_CODE;
                break;
        default:
                break;
@@ -835,6 +835,19 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                            && argument.empty()) {
                                argument = encoded_last_key;
                        }
+
+                       // the insets can't try to handle this,
+                       // a table cell in the dummy position will
+                       // lock its insettext, the insettext will
+                       // pass it the bufferview, and succeed,
+                       // so it will stay not locked. Not good
+                       // if we've just done LFUN_ESCAPE (which
+                       // injects an LFUN_PARAGRAPH_UPDATE)
+                       if (action == LFUN_PARAGRAPH_UPDATE) {
+                               view()->dispatch(ev);
+                               goto exit_with_message;
+                       }
+
                        // Undo/Redo is a bit tricky for insets.
                        if (action == LFUN_UNDO) {
                                view()->undo();
@@ -1044,14 +1057,14 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                        string const str = bformat(_("Saving document %1$s..."),
                           MakeDisplayPath(owner->buffer()->fileName()));
                        owner->message(str);
-                       MenuWrite(view(), owner->buffer());
+                       MenuWrite(owner->buffer());
                        owner->message(str + _(" done."));
                } else
-                       WriteAs(view(), owner->buffer());
+                       WriteAs(owner->buffer());
                break;
 
        case LFUN_WRITEAS:
-               WriteAs(view(), owner->buffer(), argument);
+               WriteAs(owner->buffer(), argument);
                break;
 
        case LFUN_MENURELOAD: {
@@ -1125,14 +1138,6 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                owner->getDialogs().showSearch();
                break;
 
-       case LFUN_REMOVEERRORS:
-               if (view()->removeAutoInsets()) {
-#warning repaint() or update() or nothing ?
-                       view()->repaint();
-                       view()->fitCursor();
-               }
-               break;
-
        case LFUN_DEPTH_MIN:
                changeDepth(view(), TEXT(false), DEC_DEPTH, false);
                owner->view_state_changed();
@@ -1352,23 +1357,24 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
 
                int id;
                istr >> id;
-               Paragraph * par = &*owner->buffer()->getParFromID(id);
-               if (par == 0) {
+               ParIterator par = owner->buffer()->getParFromID(id);
+               if (par == owner->buffer()->par_iterator_end()) {
                        lyxerr[Debug::INFO] << "No matching paragraph found! ["
                                            << id << ']' << endl;
                        break;
                } else {
-                       lyxerr[Debug::INFO] << "Paragraph " << par->id()
+                       lyxerr[Debug::INFO] << "Paragraph " << (*par)->id()
                                            << " found." << endl;
                }
 
                if (view()->theLockingInset())
                        view()->unlockInset(view()->theLockingInset());
-               if (par->inInset()) {
-                       par->inInset()->edit(view());
+               if ((*par)->inInset()) {
+                       FuncRequest cmd(view(), LFUN_INSET_EDIT, "left");
+                       (*par)->inInset()->localDispatch(cmd);
                }
                // Set the cursor
-               view()->getLyXText()->setCursor(par, 0);
+               view()->getLyXText()->setCursor(*par, 0);
                view()->switchKeyMap();
                owner->view_state_changed();
 
@@ -1583,6 +1589,12 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                owner->getDialogs().toggleTooltips();
                break;
 
+       case LFUN_EXTERNAL_EDIT: {
+               InsetExternal()
+                       .localDispatch(FuncRequest(view(), action, argument));
+               break;
+       }
+
        default:
                // Then if it was none of the above
                // Trying the BufferView::pimpl dispatch: