Ok, I think the system should be sane enough now to be usable.
Some comments adjusted.

It still feels somewhat hackish, so if someone sees some obvious
improvement...

Andre'

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)
Index: cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.47
diff -u -p -r1.47 cursor.C
--- cursor.C    3 Feb 2004 16:44:56 -0000       1.47
+++ cursor.C    3 Feb 2004 17:00:36 -0000
@@ -79,17 +79,19 @@ DispatchResult LCursor::dispatch(FuncReq
 {
        //lyxerr << "\nLCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
        FuncRequest cmd = cmd0;
-
-       for (int i = cursor_.size() - 1; i >= 1; --i) {
-               current_ = i;
-               CursorSlice const & citem = cursor_[i];
-               lyxerr << "trying to dispatch to inset " << citem.inset_ << endl;
+       // Note that the 'current_' index can be changed by some
+       // inset::dispatch by e.g. calling 'pop'. This is e.g.
+       // necessary for moving the cursor out of some deeply nested
+       // inset in a collapsable inset while collapsing the inset.
+       for (current_ = cursor_.size() - 1; current_ >= 1; --current_) {
+               lyxerr << "trying to dispatch to inset " << inset() << endl;
                DispatchResult res = inset()->dispatch(*this, cmd);
                if (res.dispatched()) {
-                       lyxerr << " successfully dispatched to inset " << citem.inset_ 
<< endl;
+                       lyxerr << " successfully dispatched to inset " << inset() << 
endl;
                        return DispatchResult(true, true);
                }
-               // remove one level of cursor
+               // "Mutate" the request for semi-handled requests that need
+               // additional handling in outer levels.
                switch (res.val()) {
                        case FINISHED:
                                cmd = FuncRequest(LFUN_FINISHED_LEFT);
@@ -104,15 +106,16 @@ DispatchResult LCursor::dispatch(FuncReq
                                cmd = FuncRequest(LFUN_FINISHED_DOWN);
                                break;
                        default:
-                               lyxerr << "not handled on level " << i << " val: " << 
res.val() << endl;
+                               //lyxerr << "not handled on level " << current_
+                               //      << " val: " << res.val() << endl;
                                break;
                }
        }
-       current_ = 0;
+       BOOST_ASSERT(current_ == 0);
        lyxerr << "trying to dispatch to main text " << bv_->text()
                << " with cursor: " << *this << endl;
        DispatchResult res = bv_->text()->dispatch(*this, cmd);
-       lyxerr << "   result: " << res.val() << endl;
+       //lyxerr << "   result: " << res.val() << endl;
        return res;
 }
 
Index: insets/insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.230
diff -u -p -r1.230 insetcollapsable.C
--- insets/insetcollapsable.C   3 Feb 2004 16:44:57 -0000       1.230
+++ insets/insetcollapsable.C   3 Feb 2004 17:00:36 -0000
@@ -137,7 +137,6 @@ int InsetCollapsable::height_collapsed()
 
 void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       //lyxerr << "InsetCollapsable::metrics:  width: " << mi.base.textwidth << endl;
        if (status_ == Inlined) {
                inset.metrics(mi, dim);
        } else {
@@ -150,7 +149,6 @@ void InsetCollapsable::metrics(MetricsIn
                }
        }
        dim_ = dim;
-       //lyxerr << "InsetCollapsable::metrics:  dim.wid: " << dim.wid << endl;
 }
 
 
@@ -217,8 +215,6 @@ InsetCollapsable::lfunMouseRelease(LCurs
                if (hitButton(cmd)) {
                        lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
                        setStatus(Collapsed);
-                       // drop one level
-                       cur.bv().cursor() = cur;
                        return DispatchResult(false, FINISHED_RIGHT);
                }
                lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;

Reply via email to