]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
the spellcheck cleanup
[lyx.git] / src / lyxfunc.C
index 25350974e1e3a187d0c9b907e99ace5242dcfc71..a4bac22fb7dadafc68621160c4b1f061c35ed74e 100644 (file)
@@ -29,6 +29,7 @@
 #include "BufferView.h"
 #include "cursor.h"
 #include "debug.h"
+#include "dispatchresult.h"
 #include "encoding.h"
 #include "exporter.h"
 #include "format.h"
@@ -446,11 +447,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                                disable = true;
                        }
                } else {
-                       static InsetTabular inset(*owner->buffer(), 1, 1);
-                       FuncStatus ret;
-
+                       static InsetTabular inset(*buf, 1, 1);
                        disable = true;
-                       ret = inset.getStatus(ev.argument);
+                       FuncStatus ret = inset.getStatus(ev.argument);
                        if (ret.onoff(true) || ret.onoff(false))
                                flag.setOnOff(false);
                }
@@ -473,9 +472,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                disable = buf->isUnnamed() || buf->isClean();
                break;
        case LFUN_BOOKMARK_GOTO:
-               disable =  !view()->
+               disable = !view()->
                        isSavedPosition(strToUnsignedInt(ev.argument));
                break;
+
        case LFUN_MERGE_CHANGES:
        case LFUN_ACCEPT_CHANGE:
        case LFUN_REJECT_CHANGE:
@@ -483,6 +483,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_REJECT_ALL_CHANGES:
                disable = !buf->params().tracking_changes;
                break;
+
        case LFUN_INSET_TOGGLE: {
                LyXText * lt = view()->getLyXText();
                disable = !(isEditableInset(lt->getInset())
@@ -709,19 +710,18 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                        code = InsetOld::SPACE_CODE;
                break;
        case LFUN_INSET_DIALOG_SHOW: {
-                       LyXText * lt = view()->getLyXText();
-                       InsetOld * inset = lt->getInset();
-                       disable = !inset;
-                       if (!disable) {
-                               code = inset->lyxCode();
-                               if (!(code == InsetOld::INCLUDE_CODE
-                                       || code == InsetOld::BIBTEX_CODE
-                                       || code == InsetOld::FLOAT_LIST_CODE
-                                       || code == InsetOld::TOC_CODE))
-                                       disable = true;
-                       }
+               InsetOld * inset = view()->getLyXText()->getInset();
+               disable = !inset;
+               if (!disable) {
+                       code = inset->lyxCode();
+                       if (!(code == InsetOld::INCLUDE_CODE
+                               || code == InsetOld::BIBTEX_CODE
+                               || code == InsetOld::FLOAT_LIST_CODE
+                               || code == InsetOld::TOC_CODE))
+                               disable = true;
                }
                break;
+       }
        default:
                break;
        }
@@ -881,20 +881,27 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
        if (view()->available())
                view()->hideCursor();
 
-#if 0
+#if 1
        {
                Cursor cursor;
                buildCursor(cursor, *view());
-               if (cursor.dispatch(FuncRequest(func, view())) == DISPATCHED) {
+               DispatchResult result =
+                       cursor.dispatch(FuncRequest(func, view()));
+
+               if (result.dispatched()) {
+                       if (result.update()) {
+                               view()->update();
+                       }
                        lyxerr << "dispatched by Cursor::dispatch()\n";
                        goto exit_with_message;
                }
+               lyxerr << "### NOT DispatchResult(true, true) BY Cursor::dispatch() ###\n";
        }
 #endif
 
 
        if (view()->available() && view()->theLockingInset()) {
-               dispatch_result result;
+               DispatchResult result;
                if (action > 1 || (action == LFUN_UNKNOWN_ACTION &&
                                     !keyseq.deleted()))
                {
@@ -904,10 +911,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                        int dummy_y;
                        inset->getCursorPos(view(), inset_x, dummy_y);
 #endif
-                       if (action == LFUN_UNKNOWN_ACTION
-                           && argument.empty()) {
+                       if (action == LFUN_UNKNOWN_ACTION && argument.empty())
                                argument = encoded_last_key;
-                       }
 
                        // the insets can't try to handle this,
                        // a table cell in the dummy position will
@@ -934,12 +939,15 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
 
                        // Hand-over to inset's own dispatch:
                        result = inset->dispatch(FuncRequest(view(), action, argument));
-                       if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
+                       if (result.dispatched()) {
+                               if (result.update())
+                                       view()->update();
+
                                goto exit_with_message;
                        }
 
-                       // If UNDISPATCHED, just soldier on
-                       if (result == FINISHED) {
+                       // If DispatchResult(false), just soldier on
+                       if (result.val() == FINISHED) {
                                owner->clearMessage();
                                goto exit_with_message;
                                // We do not need special RTL handling here:
@@ -947,14 +955,14 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                // one position after the inset.
                        }
 
-                       if (result == FINISHED_RIGHT) {
+                       if (result.val() == FINISHED_RIGHT) {
                                view()->text->cursorRight(view());
                                moveCursorUpdate();
                                owner->clearMessage();
                                goto exit_with_message;
                        }
 
-                       if (result == FINISHED_UP) {
+                       if (result.val() == FINISHED_UP) {
                                LyXText * text = view()->text;
                                ParagraphList::iterator pit = text->cursorPar();
                                Row const & row = *pit->getRow(text->cursor.pos());
@@ -964,7 +972,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                                text->cursor.x() + inset_x,
                                                text->cursor.y() -
                                                row.baseline() - 1);
-                                       text->cursor.x_fix(text->cursor.x());
+                                       view()->x_target(text->cursor.x());
 #else
                                        text->cursorUp(view());
 #endif
@@ -976,7 +984,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                goto exit_with_message;
                        }
 
-                       if (result == FINISHED_DOWN) {
+                       if (result.val() == FINISHED_DOWN) {
                                LyXText * text = view()->text;
                                ParagraphList::iterator pit = text->cursorPar();
                                Row const & row = *pit->getRow(text->cursor.pos());
@@ -987,7 +995,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                                text->cursor.y() -
                                                row.baseline() +
                                                row.height() + 1);
-                                       text->cursor.x_fix(text->cursor.x());
+                                       view()->x_target(text->cursor.x());
 #else
                                        text->cursorDown(view());
 #endif
@@ -1000,7 +1008,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                        }
 
 #warning I am not sure this is still right, please have a look! (Jug 20020417)
-                       // result == UNDISPATCHED
+                       // result == DispatchResult()
                        //setMessage(N_("Text mode"));
                        switch (action) {
                        case LFUN_UNKNOWN_ACTION:
@@ -1079,7 +1087,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                }
                bool fw = (action == LFUN_WORDFINDFORWARD);
                if (!searched_string.empty())
-                       lyx::find::find(view(), searched_string, fw);
+                       lyx::find::find(view(), searched_string,
+                                       true, false, fw);
                break;
        }
 
@@ -1197,8 +1206,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                QuitLyX();
                break;
 
-       case LFUN_TOCVIEW:
-       {
+       case LFUN_TOCVIEW: {
                InsetCommandParams p("tableofcontents");
                string const data = InsetCommandMailer::params2string("toc", p);
                owner->getDialogs().show("toc", data, 0);
@@ -1245,8 +1253,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
 //#warning Find another implementation here (or another lyxfunc)!
 #endif
 #endif
-       case LFUN_HELP_OPEN:
-       {
+
+       case LFUN_HELP_OPEN: {
                string const arg = argument;
                if (arg.empty()) {
                        setErrorMessage(N_("Missing argument"));
@@ -1485,12 +1493,12 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                break;
        }
 
-       case LFUN_DIALOG_SHOW_NEXT_INSET: 
+       case LFUN_DIALOG_SHOW_NEXT_INSET:
                break;
 
        case LFUN_INSET_DIALOG_SHOW: {
                InsetOld * inset = view()->getLyXText()->getInset();
-               if (inset) 
+               if (inset)
                        inset->dispatch(FuncRequest(view(), LFUN_INSET_DIALOG_SHOW));
                break;
        }
@@ -1556,7 +1564,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                argument = split(argument, countstr, ' ');
                istringstream is(countstr);
                int count = 0;
-               is >> count;    
+               is >> count;
                lyxerr << "repeat: count: " << count << " cmd: " << argument << endl;
                for (int i = 0; i < count; ++i)
                        dispatch(lyxaction.lookupFunc(argument));
@@ -1631,7 +1639,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                if (isStrInt(argument)) {
                        pid_t const pid = strToInt(argument);
                        ForkedcallsController & fcc = ForkedcallsController::get();
-                       fcc.kill(pid);  
+                       fcc.kill(pid);
                }
                break;