Small stuff.
But maybe we're ready now for the next long shot...
Andre'
Index: cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.14
diff -u -p -r1.14 cursor.C
--- cursor.C 6 Nov 2003 11:56:09 -0000 1.14
+++ cursor.C 6 Nov 2003 16:37:39 -0000
@@ -41,8 +41,9 @@ std::ostream & operator<<(std::ostream &
std::ostream & operator<<(std::ostream & os, LCursor const & cursor)
{
+ os << "\n";
for (size_t i = 0, n = cursor.data_.size(); i != n; ++i)
- os << " " << cursor.data_[i];
+ os << " " << cursor.data_[i] << "\n";
return os;
}
@@ -68,11 +69,11 @@ bool LCursor::handleResult(DispatchResul
lyxerr << "LCursor::handleResult: " << res.val() << endl;
switch (res.val()) {
case FINISHED:
- pop();
+ ///pop();
return true;
case FINISHED_RIGHT: {
- pop();
+ ///pop();
//InsetText * inset = static_cast<InsetText *>(innerInset());
//if (inset)
// inset->moveRightIntern(bv_, false, false);
@@ -83,7 +84,7 @@ bool LCursor::handleResult(DispatchResul
}
case FINISHED_UP: {
- pop();
+ ///pop();
//InsetText * inset = static_cast<InsetText *>(inset());
//if (inset)
// result = inset->moveUp(bv);
@@ -91,7 +92,7 @@ bool LCursor::handleResult(DispatchResul
}
case FINISHED_DOWN: {
- pop();
+ ///pop();
//InsetText * inset = static_cast<InsetText *>(inset());
//if (inset)
// result = inset->moveDown(bv);
@@ -99,7 +100,6 @@ bool LCursor::handleResult(DispatchResul
}
default:
- break;
lyxerr << "# unhandled result: " << res.val() << endl;
return false;
}
@@ -114,12 +114,15 @@ LCursor::LCursor(BufferView * bv)
void LCursor::push(InsetOld * inset, LyXText * text)
{
+ lyxerr << "LCursor::push() inset: " << inset << " text: " << text
+ << endl;
data_.push_back(CursorItem(inset, text));
}
void LCursor::pop()
{
+ lyxerr << "LCursor::pop() " << endl;
//BOOST_ASSERT(!data_.empty());
if (data_.empty())
lyxerr << "### TRYING TO POP FROM EMPTY CURSOR" << endl;
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.537
diff -u -p -r1.537 lyxfunc.C
--- lyxfunc.C 6 Nov 2003 10:30:43 -0000 1.537
+++ lyxfunc.C 6 Nov 2003 16:37:39 -0000
@@ -882,10 +882,17 @@ void LyXFunc::dispatch(FuncRequest const
view()->hideCursor();
#if 1
- if (view()->cursor().innerInset() != view()->theLockingInset()) {
- lyxerr << "### CURSOR OUT OF SYNC: tli: "
- << view()->theLockingInset()
- << "\ncursor: " << view()->cursor() << endl;
+ {
+ UpdatableInset * innerinset = view()->theLockingInset();
+ for (UpdatableInset * tmp = innerinset; tmp; tmp = tmp->lockingInset())
+ innerinset = tmp;
+
+ if (view()->cursor().innerInset() != innerinset) {
+ lyxerr << "### CURSOR OUT OF SYNC: tli: "
+ << view()->theLockingInset() << " inner: "
+ << innerinset
+ << "\ncursor: " << view()->cursor() << endl;
+ }
}
if (0) {
Index: text2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v
retrieving revision 1.493
diff -u -p -r1.493 text2.C
--- text2.C 5 Nov 2003 21:47:25 -0000 1.493
+++ text2.C 6 Nov 2003 16:37:39 -0000
@@ -1629,10 +1629,8 @@ void LyXText::cursorUp(bool selecting)
int y2 = y1;
y -= topy;
InsetOld * inset_hit = checkInsetHit(x, y1);
- if (inset_hit && isHighlyEditableInset(inset_hit)) {
+ if (inset_hit && isHighlyEditableInset(inset_hit))
inset_hit->edit(bv(), x, y - (y2 - y1));
- bv()->cursor().push(inset_hit, inset_hit->getText(0));
- }
}
#else
lyxerr << "cursorUp: y " << cursor.y() << " bl: " <<
@@ -1657,10 +1655,8 @@ void LyXText::cursorDown(bool selecting)
int y2 = y1;
y -= topy;
InsetOld * inset_hit = checkInsetHit(x, y1);
- if (inset_hit && isHighlyEditableInset(inset_hit)) {
- bv()->cursor().push(inset_hit, inset_hit->getText(0));
+ if (inset_hit && isHighlyEditableInset(inset_hit))
inset_hit->edit(bv(), x, y - (y2 - y1));
- }
}
#else
setCursorFromCoordinates(bv()->x_target(),
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.169
diff -u -p -r1.169 text3.C
--- text3.C 4 Nov 2003 12:36:54 -0000 1.169
+++ text3.C 6 Nov 2003 16:37:39 -0000
@@ -376,10 +376,8 @@ void doInsertInset(LyXText * lt, FuncReq
gotsel = true;
}
if (bv->insertInset(inset)) {
- if (edit) {
+ if (edit)
inset->edit(bv, true);
- bv->cursor().push(inset, inset->getText(0));
- }
if (gotsel && pastesel)
bv->owner()->dispatch(FuncRequest(LFUN_PASTE));
}
@@ -596,7 +594,6 @@ DispatchResult LyXText::dispatch(FuncReq
InsetOld * tmpinset = cursorPar()->getInset(cursor.pos());
cmd.message(tmpinset->editMessage());
tmpinset->edit(bv, !is_rtl);
- bv->cursor().push(tmpinset, tmpinset->getText(0));
break;
}
if (!is_rtl)
@@ -1247,8 +1244,7 @@ DispatchResult LyXText::dispatch(FuncReq
}
// Single-click on work area
- case LFUN_MOUSE_PRESS:
- {
+ case LFUN_MOUSE_PRESS: {
if (!bv->buffer())
break;
@@ -1292,6 +1288,8 @@ DispatchResult LyXText::dispatch(FuncReq
break;
}
bv->unlockInset(bv->theLockingInset());
+ lyxerr << "Re-initializing cursor" << endl;
+ bv->cursor() = LCursor(bv);
}
if (!inset_hit)
@@ -1304,13 +1302,15 @@ DispatchResult LyXText::dispatch(FuncReq
// Single left click in math inset?
if (isHighlyEditableInset(inset_hit)) {
- // Highly editable inset, like math
+ lyxerr << "click on highly editable inset, like math" << endl;
UpdatableInset * inset = static_cast<UpdatableInset
*>(inset_hit);
selection_possible = false;
bv->owner()->message(inset->editMessage());
// We just have to lock the inset before calling a PressEvent
on it!
if (!bv->lockInset(inset))
- lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+ lyxerr << "Cannot lock inset" << endl;
+#warning cell 0 is certainly not always good.
+ bv->cursor().push(inset, inset->getText(0));
FuncRequest cmd1(bv, LFUN_MOUSE_PRESS, x, y, cmd.button());
inset->dispatch(cmd1);
break;
Index: insets/insetbase.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.C,v
retrieving revision 1.13
diff -u -p -r1.13 insetbase.C
--- insets/insetbase.C 4 Nov 2003 12:36:54 -0000 1.13
+++ insets/insetbase.C 6 Nov 2003 16:37:39 -0000
@@ -11,6 +11,7 @@
#include <config.h>
#include "insetbase.h"
+#include "debug.h"
#include "dispatchresult.h"
@@ -38,10 +39,13 @@ InsetBase::priv_dispatch(FuncRequest con
void InsetBase::edit(BufferView *, bool)
-{}
+{
+ lyxerr << "InsetBase: edit left/right" << std::endl;
+}
void InsetBase::edit(BufferView * bv, int, int)
{
+ lyxerr << "InsetBase: edit xy" << std::endl;
edit(bv, true);
}
Index: insets/insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.197
diff -u -p -r1.197 insetcollapsable.C
--- insets/insetcollapsable.C 5 Nov 2003 12:06:07 -0000 1.197
+++ insets/insetcollapsable.C 6 Nov 2003 16:37:39 -0000
@@ -16,6 +16,7 @@
#include "buffer.h"
#include "BufferView.h"
+#include "cursor.h"
#include "debug.h"
#include "dispatchresult.h"
#include "LColor.h"
@@ -276,9 +277,10 @@ bool InsetCollapsable::hitButton(FuncReq
void InsetCollapsable::edit(BufferView * bv, bool left)
{
- lyxerr << "InsetCollapsable: edit" << endl;
+ lyxerr << "InsetCollapsable: edit left/right" << endl;
if (!bv->lockInset(this))
lyxerr << "InsetCollapsable: can't lock" << endl;
+ bv->cursor().push(this, inset.getText(0));
inset.edit(bv, left);
first_after_edit = true;
open(bv);
@@ -309,6 +311,7 @@ void InsetCollapsable::edit(BufferView *
void InsetCollapsable::edit(BufferView * bv, int x, int y)
{
+ lyxerr << "InsetCollapsable: edit xy" << endl;
if (collapsed_) {
collapsed_ = false;
// set this only here as it should be recollapsed only if
@@ -328,16 +331,15 @@ void InsetCollapsable::edit(BufferView *
inset.edit(bv, x,
ascent() + y - (height_collapsed() + inset.ascent()));
}
+ bv->cursor().push(this, inset.getText(0));
}
DispatchResult
-InsetCollapsable::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
+InsetCollapsable::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
{
//lyxerr << "InsetCollapsable::localDispatch: "
// << cmd.action << " '" << cmd.argument << "'\n";
- BufferView * bv = cmd.view();
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
if (!collapsed_ && cmd.y > button_dim.y2)
Index: insets/insetcollapsable.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v
retrieving revision 1.142
diff -u -p -r1.142 insetcollapsable.h
--- insets/insetcollapsable.h 5 Nov 2003 12:06:07 -0000 1.142
+++ insets/insetcollapsable.h 6 Nov 2003 16:37:39 -0000
@@ -157,6 +157,8 @@ protected:
void edit(BufferView *, bool);
///
void edit(BufferView *, int, int);
+ ///
+ UpdatableInset * lockingInset() const { return inset.lockingInset(); }
private:
///
Index: insets/insettabular.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.369
diff -u -p -r1.369 insettabular.C
--- insets/insettabular.C 5 Nov 2003 12:06:17 -0000 1.369
+++ insets/insettabular.C 6 Nov 2003 16:37:39 -0000
@@ -15,6 +15,7 @@
#include "buffer.h"
#include "bufferparams.h"
#include "BufferView.h"
+#include "cursor.h"
#include "debug.h"
#include "dispatchresult.h"
#include "funcrequest.h"
@@ -641,8 +642,9 @@ void InsetTabular::lfunMouseMotion(FuncR
void InsetTabular::edit(BufferView * bv, bool left)
{
- lyxerr << "InsetTabular::edit: " << this << " first cell: "
- << &tabular.cell_info[0][0].inset << endl;
+ lyxerr << "InsetTabular::edit: " << this
+ << " first text: " << tabular.cell_info[0][0].inset.getText(0)
+ << " first cell: " << &tabular.cell_info[0][0].inset << endl;
if (!bv->lockInset(this)) {
lyxerr << "InsetTabular::Cannot lock inset" << endl;
@@ -669,6 +671,7 @@ void InsetTabular::edit(BufferView * bv,
clearSelection();
resetPos(bv);
bv->fitCursor();
+ bv->cursor().push(this, 0);
}
@@ -696,6 +699,7 @@ void InsetTabular::edit(BufferView * bv,
inset_y = cursory_;
activateCellInset(bv, x - inset_x, y - inset_y);
}
+ bv->cursor().push(this, tabular.getCellInset(actcell).getText(0));
}
@@ -714,8 +718,11 @@ InsetTabular::priv_dispatch(FuncRequest
return result;
}
- if (cmd.action < 0 && cmd.argument.empty())
+ if (cmd.action < 0 && cmd.argument.empty()) {
+ lyxerr << "InsetTabular: cursor pop 2" << endl;
+ bv->cursor().pop();
return DispatchResult(false, FINISHED);
+ }
bool hs = hasSelection();
@@ -1403,8 +1411,11 @@ DispatchResult InsetTabular::moveRight(B
} else {
bool moved = isRightToLeft(bv)
? movePrevCell(bv) : moveNextCell(bv);
- if (!moved)
+ if (!moved) {
+ lyxerr << "InsetTabular: cursor pop 3" << endl;
+ bv->cursor().pop();
return DispatchResult(false, FINISHED_RIGHT);
+ }
if (lock && activateCellInset(bv))
return DispatchResult(true, true);
}
@@ -1416,8 +1427,11 @@ DispatchResult InsetTabular::moveRight(B
DispatchResult InsetTabular::moveLeft(BufferView * bv, bool lock)
{
bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
- if (!moved)
+ if (!moved) {
+ lyxerr << "InsetTabular: cursor pop 4" << endl;
+ bv->cursor().pop();
return DispatchResult(false, FINISHED);
+ }
// behind the inset
if (lock && activateCellInset(bv, 0, 0, true))
return DispatchResult(true, true);
@@ -1430,8 +1444,11 @@ DispatchResult InsetTabular::moveUp(Buff
{
int const ocell = actcell;
actcell = tabular.getCellAbove(actcell);
- if (actcell == ocell) // we moved out of the inset
+ if (actcell == ocell) { // we moved out of the inset
+ lyxerr << "InsetTabular: cursor pop 5" << endl;
+ bv->cursor().pop();
return DispatchResult(false, FINISHED_UP);
+ }
resetPos(bv);
if (lock) {
int x = 0;
@@ -1451,8 +1468,11 @@ DispatchResult InsetTabular::moveDown(Bu
{
int const ocell = actcell;
actcell = tabular.getCellBelow(actcell);
- if (actcell == ocell) // we moved out of the inset
+ if (actcell == ocell) { // we moved out of the inset
+ lyxerr << "InsetTabular: cursor pop 6" << endl;
+ bv->cursor().pop();
return DispatchResult(false, FINISHED_DOWN);
+ }
resetPos(bv);
if (lock) {
int x = 0;
@@ -1986,6 +2006,7 @@ bool InsetTabular::activateCellInset(Buf
//inset_x = cursorx_ - top_x + tabular.getBeginningOfTextInCell(actcell);
//inset_y = cursory_;
inset.edit(bv, x, y);
+ bv->cursor().push(&inset, inset.getText(0));
if (!the_locking_inset)
return false;
updateLocal(bv);
Index: insets/insettabular.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettabular.h,v
retrieving revision 1.162
diff -u -p -r1.162 insettabular.h
--- insets/insettabular.h 5 Nov 2003 12:06:18 -0000 1.162
+++ insets/insettabular.h 6 Nov 2003 16:37:39 -0000
@@ -273,6 +273,8 @@ private:
int & srow, int & erow) const;
///
bool insertAsciiString(BufferView *, std::string const & buf, bool usePaste);
+ ///
+ UpdatableInset * lockingInset() const { return the_locking_inset; }
//
// Private structures and variables
Index: insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.532
diff -u -p -r1.532 insettext.C
--- insets/insettext.C 6 Nov 2003 11:56:10 -0000 1.532
+++ insets/insettext.C 6 Nov 2003 16:37:39 -0000
@@ -584,9 +584,10 @@ void InsetText::edit(BufferView * bv, bo
setViewCache(bv);
if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+ lyxerr << "Cannot lock inset" << endl;
return;
}
+ lyxerr << "InsetText: edit left/right" << endl;
locked = true;
the_locking_inset = 0;
@@ -620,9 +621,10 @@ void InsetText::edit(BufferView * bv, bo
void InsetText::edit(BufferView * bv, int x, int y)
{
if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+ lyxerr << "Cannot lock inset" << endl;
return;
}
+ lyxerr << "InsetText: edit xy" << endl;
locked = true;
the_locking_inset = 0;
@@ -720,7 +722,6 @@ InsetText::priv_dispatch(FuncRequest con
if (result.val() >= FINISHED) {
updateLocal(bv, false);
bv->unlockInset(this);
- bv->cursor().pop();
}
break;
case FINISHED_DOWN:
@@ -728,7 +729,6 @@ InsetText::priv_dispatch(FuncRequest con
if (result.val() >= FINISHED) {
updateLocal(bv, false);
bv->unlockInset(this);
- bv->cursor().pop();
}
break;
default:
@@ -795,9 +795,11 @@ InsetText::priv_dispatch(FuncRequest con
break;
case LFUN_PRIOR:
- if (crow() == text_.firstRow())
+ if (crow() == text_.firstRow()) {
result.val(FINISHED_UP);
- else {
+ lyxerr << "InsetText: cursor pop 1" << endl;
+ bv->cursor().pop();
+ } else {
text_.cursorPrevious();
text_.clearSelection();
result.dispatched(true);
@@ -805,9 +807,11 @@ InsetText::priv_dispatch(FuncRequest con
break;
case LFUN_NEXT:
- if (crow() == text_.lastRow())
+ if (crow() == text_.lastRow()) {
result.val(FINISHED_DOWN);
- else {
+ lyxerr << "InsetText: cursor pop 2" << endl;
+ bv->cursor().pop();
+ } else {
text_.cursorNext();
text_.clearSelection();
result.dispatched(true);
@@ -954,7 +958,6 @@ InsetText::priv_dispatch(FuncRequest con
if (result.val() >= FINISHED) {
result.val(NONE);
bv->unlockInset(this);
- bv->cursor().pop();
}
return result;
@@ -1078,8 +1081,11 @@ InsetText::moveRightIntern(BufferView *
{
ParagraphList::iterator c_par = cpar();
- if (boost::next(c_par) == paragraphs.end() && cpos() >= c_par->size())
+ if (boost::next(c_par) == paragraphs.end() && cpos() >= c_par->size()) {
+ lyxerr << "InsetText: cursor pop 3" << endl;
+ bv->cursor().pop();
return DispatchResult(false, FINISHED_RIGHT);
+ }
if (activate_inset && checkAndActivateInset(bv, front))
return DispatchResult(true, true);
text_.cursorRight(bv);
@@ -1093,8 +1099,11 @@ DispatchResult
InsetText::moveLeftIntern(BufferView * bv, bool front,
bool activate_inset, bool selecting)
{
- if (cpar() == paragraphs.begin() && cpos() <= 0)
+ if (cpar() == paragraphs.begin() && cpos() <= 0) {
+ lyxerr << "InsetText: cursor pop 4" << endl;
+ bv->cursor().pop();
return DispatchResult(false, FINISHED);
+ }
text_.cursorLeft(bv);
if (!selecting)
text_.clearSelection();
@@ -1106,8 +1115,11 @@ InsetText::moveLeftIntern(BufferView * b
DispatchResult InsetText::moveUp(BufferView * bv)
{
- if (crow() == text_.firstRow())
+ if (crow() == text_.firstRow()) {
+ lyxerr << "InsetText: cursor pop 5" << endl;
+ bv->cursor().pop();
return DispatchResult(false, FINISHED_UP);
+ }
text_.cursorUp(bv);
text_.clearSelection();
return DispatchResult(true);
@@ -1116,8 +1128,11 @@ DispatchResult InsetText::moveUp(BufferV
DispatchResult InsetText::moveDown(BufferView * bv)
{
- if (crow() == text_.lastRow())
+ if (crow() == text_.lastRow()) {
+ lyxerr << "InsetText: cursor pop 6" << endl;
+ bv->cursor().pop();
return DispatchResult(false, FINISHED_DOWN);
+ }
text_.cursorDown(bv);
text_.clearSelection();
return DispatchResult(true);
Index: insets/insettext.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.h,v
retrieving revision 1.224
diff -u -p -r1.224 insettext.h
--- insets/insettext.h 5 Nov 2003 12:06:18 -0000 1.224
+++ insets/insettext.h 6 Nov 2003 16:37:39 -0000
@@ -183,6 +183,8 @@ public:
void edit(BufferView *, bool);
///
void edit(BufferView *, int, int);
+ ///
+ UpdatableInset * lockingInset() const { return the_locking_inset; }
///
int numParagraphs() const { return 1; }
Index: insets/updatableinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/updatableinset.h,v
retrieving revision 1.22
diff -u -p -r1.22 updatableinset.h
--- insets/updatableinset.h 4 Nov 2003 12:01:15 -0000 1.22
+++ insets/updatableinset.h 6 Nov 2003 16:37:39 -0000
@@ -88,6 +88,8 @@ public:
virtual bool showInsetDialog(BufferView *) const { return false; }
///
virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {}
+ ///
+ virtual UpdatableInset * lockingInset() const { return 0; }
protected:
/// An updatable inset could handle lyx editing commands