Hello,

This patch replaces BufferView->LyXView->getLyXFunc() with theApp->lyxFunc().

I am not sure yet how to proceed with the LyXView/LyXFunc interaction and the dispatch machinery.

Right now there is only one LyXView for one LyXFunc. There are two way forward for the multiple LyXView problem.

1) Application maintains a map of LyXFunc indexed by the LyXView ID as given but the Gui class when you create a new view.

2) We add a new member to FuncRequest (view_id_)that will be used only if this action is related to a LyXView. It would then be the used of the one unique LyXFunc::dispatch() method to dispatch the FuncRequest to the proper LyXView.

I personnally think that 2) is more elegant because that will force us to clean up a bit more the dispatch machinery. But there might be other solutions out there so please, if you have an idea...

With regard to this patch, I think it can go in right now.

Comments? Opinions? Ideas?

Abdel.
Index: cursor.C
===================================================================
--- cursor.C    (revision 15119)
+++ cursor.C    (working copy)
@@ -1105,13 +1105,13 @@
 
 void LCursor::message(docstring const & msg) const
 {
-       bv().owner()->getLyXFunc().setMessage(msg);
+       theApp->lyxFunc().setMessage(msg);
 }
 
 
 void LCursor::errorMessage(docstring const & msg) const
 {
-       bv().owner()->getLyXFunc().setErrorMessage(msg);
+       theApp->lyxFunc().setErrorMessage(msg);
 }
 
 
Index: frontends/LyXView.h
===================================================================
--- frontends/LyXView.h (revision 15119)
+++ frontends/LyXView.h (working copy)
@@ -87,6 +87,15 @@
        /// return the buffer currently shown in this window
        Buffer * buffer() const;
 
+       /* FIXME: Abdel 22/09/71
+       there is only one lyxFunc() for now but there is maybe a need
+       for more in the feature. Something like that:
+       
+               LyXFunc & getLyXFunc() { return theApp->lyxFunc(id_); }
+
+       where id_ would be the this LyXView ID.
+       That's the reason why I didn't remove these methods for now.
+       */
        /// return the LyX function handler for this view
        LyXFunc & getLyXFunc() { return theApp->lyxFunc(); }
        ///
Index: insets/insetref.C
===================================================================
--- insets/insetref.C   (revision 15119)
+++ insets/insetref.C   (working copy)
@@ -48,7 +48,7 @@
        case LFUN_MOUSE_PRESS:
                // Eventually trigger dialog with button 3 not 1
                if (cmd.button() == mouse_button::button3)
-                       cur.bv().owner()->dispatch(FuncRequest(LFUN_LABEL_GOTO, 
getContents()));
+                       theApp->lyxFunc().dispatch(FuncRequest(LFUN_LABEL_GOTO, 
getContents()));
                else {
                        InsetCommandMailer("ref", *this).showDialog(&cur.bv());
                        cur.undispatched();
Index: mathed/InsetMathHull.C
===================================================================
--- mathed/InsetMathHull.C      (revision 15119)
+++ mathed/InsetMathHull.C      (working copy)
@@ -1264,7 +1264,7 @@
                view_->getIntl()->getTransManager().TranslateAndInsert(*cit, 
lt);
 
        // remove ourselves
-       //view_->owner()->dispatch(LFUN_ESCAPE);
+       //theApp->lyxFunc().dispatch(LFUN_ESCAPE);
 #endif
 }
 
Index: text2.C
===================================================================
--- text2.C     (revision 15119)
+++ text2.C     (working copy)
@@ -366,13 +366,13 @@
        if (lyxlayout->is_environment) {
                // move everything in a new environment inset
                lyxerr[Debug::DEBUG] << "setting layout " << layout << endl;
-               bv.owner()->dispatch(FuncRequest(LFUN_LINE_BEGIN));
-               bv.owner()->dispatch(FuncRequest(LFUN_LINE_END_SELECT));
-               bv.owner()->dispatch(FuncRequest(LFUN_CUT));
+               theApp->lyxFunc().dispatch(FuncRequest(LFUN_LINE_BEGIN));
+               theApp->lyxFunc().dispatch(FuncRequest(LFUN_LINE_END_SELECT));
+               theApp->lyxFunc().dispatch(FuncRequest(LFUN_CUT));
                InsetBase * inset = new InsetEnvironment(params, layout);
                insertInset(cur, inset);
                //inset->edit(cur, true);
-               //bv.owner()->dispatch(FuncRequest(LFUN_PASTE));
+               //theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE));
                return;
        }
 
Index: text3.C
===================================================================
--- text3.C     (revision 15119)
+++ text3.C     (working copy)
@@ -266,7 +266,7 @@
        recordUndo(cur);
        bool gotsel = false;
        if (cur.selection()) {
-               cur.bv().owner()->dispatch(FuncRequest(LFUN_CUT));
+               theApp->lyxFunc().dispatch(FuncRequest(LFUN_CUT));
                gotsel = true;
        }
        text->insertInset(cur, inset);
@@ -275,7 +275,7 @@
                inset->edit(cur, true);
 
        if (gotsel && pastesel) {
-               cur.bv().owner()->dispatch(FuncRequest(LFUN_PASTE));
+               theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE));
                // reset first par to default
                if (cur.lastpit() != 0 || cur.lastpos() != 0) {
                        LyXLayout_ptr const layout =
@@ -936,16 +936,16 @@
                        cur.posRight();
                }
                else
-                       bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT, 
"\""));
+                       
theApp->lyxFunc().dispatch(FuncRequest(LFUN_SELF_INSERT, "\""));
                break;
        }
 
        case LFUN_DATE_INSERT:
                if (cmd.argument().empty())
-                       bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
+                       theApp->lyxFunc().dispatch(FuncRequest(LFUN_SELF_INSERT,
                                lyx::formatted_time(lyx::current_time())));
                else
-                       bv->owner()->dispatch(FuncRequest(LFUN_SELF_INSERT,
+                       theApp->lyxFunc().dispatch(FuncRequest(LFUN_SELF_INSERT,
                                lyx::formatted_time(lyx::current_time(), 
lyx::to_utf8(cmd.argument()))));
                break;
 
@@ -980,7 +980,7 @@
                // we have to check this first
                bool paste_internally = false;
                if (cmd.button() == mouse_button::button2 && cur.selection()) {
-                       bv->owner()->dispatch(FuncRequest(LFUN_COPY));
+                       theApp->lyxFunc().dispatch(FuncRequest(LFUN_COPY));
                        paste_internally = true;
                }
 
@@ -991,9 +991,9 @@
                // insert this
                if (cmd.button() == mouse_button::button2) {
                        if (paste_internally)
-                               bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
+                               
theApp->lyxFunc().dispatch(FuncRequest(LFUN_PASTE));
                        else
-                               
bv->owner()->dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, "paragraph"));
+                               
theApp->lyxFunc().dispatch(FuncRequest(LFUN_PRIMARY_SELECTION_PASTE, 
"paragraph"));
                }
 
                break;
@@ -1384,7 +1384,7 @@
        case LFUN_ACCENT_HUNGARIAN_UMLAUT:
        case LFUN_ACCENT_CIRCLE:
        case LFUN_ACCENT_OGONEK:
-               bv->owner()->getLyXFunc().handleKeyFunc(cmd.action);
+               theApp->lyxFunc().handleKeyFunc(cmd.action);
                if (!cmd.argument().empty())
                        // FIXME: Are all these characters encoded in one byte 
in utf8?
                        bv->getIntl().getTransManager()

Reply via email to