See attached.

Still inactive (but 'dispatch to tip' starts to become functional...)

Andr'e
-- 
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.4
diff -u -p -r1.4 cursor.C
--- cursor.C    29 Oct 2003 10:47:12 -0000      1.4
+++ cursor.C    29 Oct 2003 11:01:44 -0000
@@ -22,12 +22,20 @@
 #include "insets/updatableinset.h"
 
 using std::vector;
+using endl;
 
 
-DispatchResult Cursor::dispatch(FuncRequest const &)
+DispatchResult Cursor::dispatch(FuncRequest const & cmd)
 {
        for (int i = data_.size() - 1; i >= 0; --i) {
-               lyxerr << "trying to dispatch to " << data_[i].text_ << std::endl;
+               lyxerr << "trying to dispatch to inset" << data_[i].inset_ << endl;
+               DispatchResult result = data_[i].inset_->dispatch(cmd);
+               lyxerr << "   result: " << result << endl;
+               if (result == DISPATCHED)
+                       return result;
+               if (result == DISPATCHED_NOUPDATE)
+                       return result;
+               lyxerr << "# unhandled result: " << result << endl;
        }
        return UNDISPATCHED;
 }
@@ -36,7 +44,7 @@ DispatchResult Cursor::dispatch(FuncRequ
 void buildCursor(Cursor & cursor, BufferView & bv)
 {
        UpdatableInset * inset = bv.theLockingInset();
-       lyxerr << "\nbuildCursor: " << inset << std::endl;
+       lyxerr << "\nbuildCursor: " << inset << endl;
        if (!inset)
                return;
 
@@ -54,26 +62,17 @@ void buildCursor(Cursor & cursor, Buffer
        }
 
        if (!ok) {
-               lyxerr << " tli not found! inset: " << inset << std::endl;
+               lyxerr << " tli not found! inset: " << inset << endl;
                return;
        }
 
-       vector<ParagraphList::iterator> pits;
-       vector<ParagraphList const *>   plists;
-       vector<LyXText *>               texts;
-/*
-       pit.getPits(pits, plists, texts);
-
-       cursor.data_.resize(pits.size());
-       for (size_t i = 0, n = pits.size(); i != n; ++i) {
-               cursor.data_[i].text_ = texts[i];
-               cursor.data_[i].pit_  = pits[i];
-               //cursor.data_[i].pos_ = texts[i]->cursor.pos();
-               cursor.data_[i].pos_ = 0;
-               lyxerr << " text: " << cursor.data_[i].text_
-                      << " pit: " << cursor.data_[i].pit_->id()
+       pit.asCursor(cursor);
+       for (size_t i = 0, n = cursor.data_.size(); i != n; ++i) {
+               lyxerr << " inset: " << cursor.data_[i].inset_
+                      << " idx: " << cursor.data_[i].idx_
+                      << " text: " << cursor.data_[i].text_
+                      << " par: " << cursor.data_[i].par_
                       << " pos: " << cursor.data_[i].pos_
-                      << std::endl;
+                      << endl;
        }
-*/
 }
Index: cursor.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.h,v
retrieving revision 1.2
diff -u -p -r1.2 cursor.h
--- cursor.h    18 Sep 2003 11:21:53 -0000      1.2
+++ cursor.h    29 Oct 2003 11:01:44 -0000
@@ -12,7 +12,6 @@
 #ifndef CURSOR_H
 #define CURSOR_H
 
-#include "ParagraphList_fwd.h"
 #include "textcursor.h"
 
 #include "support/types.h"
@@ -20,6 +19,7 @@
 #include <vector>
 
 class BufferView;
+class InsetOld;
 class DispatchResult;
 class FuncRequest;
 class LyXText;
@@ -32,12 +32,16 @@ class LyXText;
 class CursorItem : public TextCursor {
 public:
        ///
-       CursorItem() : text_(0) {}
+       CursorItem() : inset_(0), text_(0), idx_(0), par_(0), pos_(0) {}
 public:
        ///
+       InsetOld * inset_;
+       ///
        LyXText * text_;
        ///
-       ParagraphList::iterator pit_;
+       int idx_;
+       ///
+       int par_;
        ///
        int pos_;
 };
Index: iterators.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.C,v
retrieving revision 1.22
diff -u -p -r1.22 iterators.C
--- iterators.C 15 Oct 2003 08:49:42 -0000      1.22
+++ iterators.C 29 Oct 2003 11:01:44 -0000
@@ -13,16 +13,13 @@
 
 #include "iterators.h"
 #include "paragraph.h"
-#include "debug.h"
+#include "cursor.h"
 
 #include "insets/inset.h"
 
 #include <boost/next_prior.hpp>
 #include <boost/optional.hpp>
 
-// it's conceptionally a stack, but undo needs random access...
-//#include <stack>
-
 using boost::next;
 using boost::optional;
 using std::vector;
@@ -175,6 +172,22 @@ int ParIterator::index() const
                return 0;
 
        return *(pimpl_->positions[pimpl_->positions.size() - 2].index);
+}
+
+
+void ParIterator::asCursor(Cursor & cursor) const
+{
+       cursor.data_.clear();
+       for (size_t i = 1, n = size(); i < n; ++i) {
+               ParPosition const & pos = pimpl_->positions[i - 1];
+               CursorItem item;
+               item.inset_ = (*pos.it)->inset;
+               item.idx_   = (*pos.index);
+               item.text_  = (*pos.it)->inset->getText(*pos.index);
+               item.par_   = 0;
+               item.pos_   = 0;
+               cursor.data_.push_back(item);
+       }
 }
 
 
Index: iterators.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/iterators.h,v
retrieving revision 1.18
diff -u -p -r1.18 iterators.h
--- iterators.h 15 Oct 2003 08:49:42 -0000      1.18
+++ iterators.h 29 Oct 2003 11:01:44 -0000
@@ -18,6 +18,7 @@
 
 class LyXText;
 class InsetOld;
+class Cursor;
 
 class ParIterator {
 public:
@@ -50,6 +51,8 @@ public:
        int index() const;
        ///
        size_t size() const;
+       ///
+       void asCursor(Cursor & cursor) const;
        ///
        friend
        bool operator==(ParIterator const & iter1, ParIterator const & iter2);
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.527
diff -u -p -r1.527 lyxfunc.C
--- lyxfunc.C   29 Oct 2003 10:47:12 -0000      1.527
+++ lyxfunc.C   29 Oct 2003 11:01:44 -0000
@@ -447,11 +447,9 @@ FuncStatus LyXFunc::getStatus(FuncReques
                                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);
                }
@@ -474,9 +472,10 @@ FuncStatus LyXFunc::getStatus(FuncReques
                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:
@@ -484,6 +483,7 @@ FuncStatus LyXFunc::getStatus(FuncReques
        case LFUN_REJECT_ALL_CHANGES:
                disable = !buf->params().tracking_changes;
                break;
+
        case LFUN_INSET_TOGGLE: {
                LyXText * lt = view()->getLyXText();
                disable = !(isEditableInset(lt->getInset())
@@ -710,19 +710,18 @@ FuncStatus LyXFunc::getStatus(FuncReques
                        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;
        }
@@ -882,7 +881,7 @@ void LyXFunc::dispatch(FuncRequest const
        if (view()->available())
                view()->hideCursor();
 
-#if 0
+#if 0
        {
                Cursor cursor;
                buildCursor(cursor, *view());
@@ -890,6 +889,7 @@ void LyXFunc::dispatch(FuncRequest const
                        lyxerr << "dispatched by Cursor::dispatch()\n";
                        goto exit_with_message;
                }
+               lyxerr << "### NOT DISPATCHED BY Cursor::dispatch() ###\n";
        }
 #endif
 
@@ -905,10 +905,8 @@ void LyXFunc::dispatch(FuncRequest const
                        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
@@ -1198,8 +1196,7 @@ void LyXFunc::dispatch(FuncRequest const
                QuitLyX();
                break;
 
-       case LFUN_TOCVIEW:
-       {
+       case LFUN_TOCVIEW: {
                InsetCommandParams p("tableofcontents");
                string const data = InsetCommandMailer::params2string("toc", p);
                owner->getDialogs().show("toc", data, 0);
@@ -1246,8 +1243,8 @@ void LyXFunc::dispatch(FuncRequest const
 //#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"));
Index: paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.337
diff -u -p -r1.337 paragraph.C
--- paragraph.C 27 Oct 2003 12:41:20 -0000      1.337
+++ paragraph.C 29 Oct 2003 11:01:45 -0000
@@ -1327,7 +1327,8 @@ Paragraph::value_type Paragraph::getChar
        // This is in the critical path!
        pos_type const siz = text_.size();
 
-       BOOST_ASSERT(0 <= pos && pos <= siz);
+       BOOST_ASSERT(0 <= pos);
+       BOOST_ASSERT(pos <= siz);
 
        if (pos == siz) {
                lyxerr << "getChar() on pos " << pos << " in par id "
Index: text.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v
retrieving revision 1.490
diff -u -p -r1.490 text.C
--- text.C      29 Oct 2003 10:47:13 -0000      1.490
+++ text.C      29 Oct 2003 11:01:45 -0000
@@ -1485,26 +1477,10 @@ void LyXText::changeCase(LyXText::TextCa
 void LyXText::Delete()
 {
        // this is a very easy implementation
-
        LyXCursor old_cursor = cursor;
-       int const old_cur_par_id = cursorPar()->id();
-       int const old_cur_par_prev_id =
-               old_cursor.par() ? getPar(old_cursor.par() - 1)->id() : -1;
 
        // just move to the right
        cursorRight(bv());
-
-       // CHECK Look at the comment here.
-       // This check is not very good...
-       // The cursorRightIntern calls DeleteEmptyParagraphMechanism
-       // and that can very well delete the par or par->previous in
-       // old_cursor. Will a solution where we compare paragraph id's
-       //work better?
-       int iid = cursor.par() ? getPar(cursor.par() - 1)->id() : -1;
-       if (iid == old_cur_par_prev_id && cursorPar()->id() != old_cur_par_id) {
-               // delete-empty-paragraph-mechanism has done it
-               return;
-       }
 
        // if you had success make a backspace
        if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
Index: undo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v
retrieving revision 1.24
diff -u -p -r1.24 undo.C
--- undo.C      27 Oct 2003 10:03:04 -0000      1.24
+++ undo.C      29 Oct 2003 11:01:45 -0000
@@ -147,12 +147,9 @@ void recordUndo(Undo::undo_kind kind,
        ParagraphList::iterator last = plist.begin();
        advance(last, last_par);
 
-       for (ParagraphList::iterator it = first; it != last; ++it) {
+       for (ParagraphList::iterator it = first; it != last; ++it)
                undo_pars.push_back(*it);
-               undo_pars.back().id(it->id());
-       }
        undo_pars.push_back(*last);
-       undo_pars.back().id(last->id());
 
        // and make sure that next time, we should be combining if possible
        undo_finished = false;
Index: support/types.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/types.h,v
retrieving revision 1.13
diff -u -p -r1.13 types.h
--- support/types.h     13 Oct 2003 09:43:15 -0000      1.13
+++ support/types.h     29 Oct 2003 11:01:45 -0000
@@ -18,8 +18,8 @@
 
 #include <cstddef>
 
-namespace lyx
-{
+namespace lyx {
+
        /// a type for positions used in paragraphs
        // needs to be signed for a while to hold the special value -1 that is
        // used there...
@@ -88,6 +88,6 @@ namespace lyx
                NEXT_WORD
        };
 
-}
+} // namespace lyx
 
 #endif // LYX_TYPES_H

Reply via email to