]> git.lyx.org Git - lyx.git/commitdiff
preliminary 'global cursor' stuff
authorAndré Pönitz <poenitz@gmx.net>
Wed, 17 Sep 2003 16:44:51 +0000 (16:44 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 17 Sep 2003 16:44:51 +0000 (16:44 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7784 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView_pimpl.C
src/Makefile.am
src/bufferview_funcs.C
src/cursor.C [new file with mode: 0644]
src/cursor.h [new file with mode: 0644]
src/lyxfunc.C

index 8bcd2fb32464169640179151d459e7e6e2bab959..54d25dbb15f95c753ee5b433e423e41b9b797cfa 100644 (file)
@@ -492,7 +492,8 @@ int BufferView::unlockInset(UpdatableInset * inset)
                dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
                finishUndo();
                return 0;
-       } else if (inset && theLockingInset() &&
+       }
+       if (inset && theLockingInset() &&
                   theLockingInset()->unlockInsetInInset(this, inset)) {
                // Tell the paragraph dialog that we changed paragraph
                dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
index 22a9cd4b77485e30cafd089f6917890770fb890d..c1e05f05cedb625c3d68ddb04699b0e5264192e2 100644 (file)
@@ -23,6 +23,7 @@
 #include "buffer_funcs.h"
 #include "bufferlist.h"
 #include "bufferparams.h"
+#include "cursor.h"
 #include "debug.h"
 #include "factory.h"
 #include "FloatList.h"
@@ -456,8 +457,8 @@ void BufferView::Pimpl::resizeCurrentBuffer()
        }
 
 #warning does not help much
-       bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(),
-               bv_->text->ownerParagraphs().end());
+       //bv_->text->redoParagraphs(bv_->text->ownerParagraphs().begin(),
+       //      bv_->text->ownerParagraphs().end());
 
        if (par != bv_->text->ownerParagraphs().end()) {
                bv_->text->selection.set(true);
@@ -1323,7 +1324,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                ev.errorMessage(N_("Unknown function!"));
                break;
 
-       default:
+       default:        
                return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_));
        } // end of switch
 
index 045dd3a3db1379b35f8d8132ebaaf86c1b293824..aba9d4ea5359330c4f980b99f900951e9d3acef2 100644 (file)
@@ -137,6 +137,8 @@ lyx_SOURCES = \
        converter.h \
        counters.C \
        counters.h \
+       cursor.C \
+       cursor.h \
        debug.C \
        debug.h \
        dimension.C \
index 7945e4fbc2c2fde0977cfccd073e534647a3f24b..0d56ad2f6d4800808e5cf1308dcb92df44173723 100644 (file)
@@ -368,8 +368,14 @@ string const currentState(BufferView * bv)
        state << _(", Position: ") << text->cursor.pos();
        RowList::iterator rit = text->cursorRow();
        state << bformat(_(", Row b:%1$d e:%2$d"), rit->pos(), rit->end());
-       state << _(", Inset: ") <<
-               (text->cursor.par()->inInset() ? text->cursor.par()->inInset()->id() : -1);
+       state << _(", Inset: ");
+       InsetOld * inset = text->cursor.par()->inInset();
+       if (inset)
+               state << inset << " id: " << inset->id()
+                     << " text: " << inset->getLyXText(bv, true)
+                                               << " owner: " << inset->owner();
+       else 
+               state << -1;
 #endif
        return state.str();
 }
diff --git a/src/cursor.C b/src/cursor.C
new file mode 100644 (file)
index 0000000..0e1d34b
--- /dev/null
@@ -0,0 +1,78 @@
+/**
+ * \file cursor.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Jürgen Vigna
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "buffer.h"
+#include "BufferView.h"
+#include "cursor.h"
+#include "debug.h"
+#include "iterators.h"
+#include "lyxtext.h"
+#include "paragraph.h"
+
+#include "insets/updatableinset.h"
+
+using std::vector;
+
+
+dispatch_result Cursor::dispatch(FuncRequest const &)
+{
+       for (int i = data_.size() - 1; i >= 0; --i) {
+               lyxerr << "trying to dispatch to " << data_[i].text_ << std::endl;
+       }
+       return UNDISPATCHED;
+}
+
+
+void buildCursor(Cursor & cursor, BufferView & bv)
+{
+       UpdatableInset * inset = bv.theLockingInset();
+       lyxerr << "\nbuildCursor: " << inset << std::endl;
+       if (!inset)
+               return;
+       
+       inset = inset->getLockingInset();
+
+       bool ok = false;
+       ParIterator pit = bv.buffer()->par_iterator_begin();
+       ParIterator end = bv.buffer()->par_iterator_end();
+       for ( ; pit != end && !ok; ++pit) {
+               InsetList::iterator     it = pit->insetlist.begin();
+               InsetList::iterator     iend = pit->insetlist.end();
+               for ( ; it != iend && !ok; ++it) 
+                       if (it->inset == inset || it->inset == inset->owner())
+                               ok = true;
+       }
+
+       if (!ok) {
+               lyxerr << " tli not found! inset: " << inset << std::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()
+                      << " pos: " << cursor.data_[i].pos_
+                      << std::endl;
+       }
+*/
+}
diff --git a/src/cursor.h b/src/cursor.h
new file mode 100644 (file)
index 0000000..bb99d96
--- /dev/null
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+/**
+ * \file cursor.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef CURSOR_H
+#define CURSOR_H
+
+#include "ParagraphList_fwd.h"
+#include "textcursor.h"
+
+#include "support/types.h"
+
+#include "insets/insetbase.h"
+
+#include <vector>
+
+class LyXText;
+
+
+/**
+ * The cursor class describes the position of a cursor within a document.
+ */
+
+class CursorItem : public TextCursor {
+public:
+       ///
+       CursorItem() : text_(0) {}
+public:
+       ///
+       LyXText * text_;
+       ///
+       ParagraphList::iterator pit_;
+       ///
+       int pos_;
+};
+
+
+class Cursor {
+public:
+       ///
+       Cursor() {}
+       ///
+       dispatch_result dispatch(FuncRequest const & cmd);
+public:
+       /// mainly used as stack, bnut wee need random access
+       std::vector<CursorItem> data_;
+};
+
+/// build cursor from current cursor in view
+void buildCursor(Cursor & cursor, BufferView & bv);
+
+/// build cursor from (x,y) coordinates
+void buildCursor(Cursor & cursor, BufferView & bv, int x, int y);
+
+#endif // LYXCURSOR_H
index 13a9d2d8ee022669f83c98ce104b9137d107d139..43b1d9010e802aa1a5d372379bd7c7368544db06 100644 (file)
@@ -27,6 +27,7 @@
 #include "bufferlist.h"
 #include "bufferparams.h"
 #include "BufferView.h"
+#include "cursor.h"
 #include "debug.h"
 #include "encoding.h"
 #include "exporter.h"
@@ -891,6 +892,18 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
        if (view()->available())
                view()->hideCursor();
 
+#if 1
+       {
+               Cursor cursor;
+               buildCursor(cursor, *view());
+               if (cursor.dispatch(FuncRequest(ev, view())) == DISPATCHED) {
+                       lyxerr << "dispatched by Cursor::dispatch()\n";
+                       goto exit_with_message;
+               }
+       }
+#endif
+
+
        if (view()->available() && view()->theLockingInset()) {
                InsetOld::RESULT result;
                if (action > 1 || (action == LFUN_UNKNOWN_ACTION &&