Alfredo Braunstein <[EMAIL PROTECTED]> writes:

| Pretty funny actually :-) Once you get over the claustrophobia...

I have a patch that solves the problem for me.

Unless you find huge problems with this I will commit it.

? Config
? dispatch-4.diff
? dispatch-5.diff
? dispatch-6.diff
? dispatch-7.diff
? dispatch-8.diff
? doit.sh
? newfile1.lyx
? src/doit.sh
? src/insets/doit.sh
? src/mathed/doit.sh
Index: src/cursor.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
retrieving revision 1.10
diff -u -p -r1.10 cursor.C
--- src/cursor.C	3 Nov 2003 19:52:41 -0000	1.10
+++ src/cursor.C	4 Nov 2003 00:08:22 -0000
@@ -28,6 +28,8 @@ using std::endl;
 DispatchResult Cursor::dispatch(FuncRequest const & cmd)
 {
 	for (int i = data_.size() - 1; i >= 0; --i) {
+		CursorItem & citem = data_[i];
+
 		lyxerr << "trying to dispatch to inset" << data_[i].inset_ << endl;
 		DispatchResult res = data_[i].inset_->dispatch(cmd);
 		lyxerr << "   result: " << res.val() << endl;
Index: src/dispatchresult.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dispatchresult.h,v
retrieving revision 1.6
diff -u -p -r1.6 dispatchresult.h
--- src/dispatchresult.h	3 Nov 2003 19:52:41 -0000	1.6
+++ src/dispatchresult.h	4 Nov 2003 00:08:22 -0000
@@ -53,6 +53,9 @@ public:
 	DispatchResult(bool dis, dispatch_result_t val)
 		: dispatched_(dis), update_(false), val_(val) {}
 	dispatch_result_t val() const { return val_; }
+	void val(dispatch_result_t drt) {
+		val_ = drt;
+	}
 	bool dispatched() const {
 		return dispatched_;
 	}
Index: src/insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.524
diff -u -p -r1.524 insettext.C
--- src/insets/insettext.C	3 Nov 2003 19:52:46 -0000	1.524
+++ src/insets/insettext.C	4 Nov 2003 00:08:23 -0000
@@ -676,14 +676,16 @@ InsetText::priv_dispatch(FuncRequest con
 
 	DispatchResult result = UpdatableInset::priv_dispatch(cmd, idx, pos);
 	if (result.dispatched())
-		return DispatchResult(true, true);
+		return result;
 
-	result = DispatchResult(true, true);
+#if 0
+	// This looks utterly strange. (Lgb)
 	if (cmd.action == LFUN_UNKNOWN_ACTION && cmd.argument.empty())
 		return DispatchResult(false, FINISHED);
+#endif
 
 	if (the_locking_inset) {
-		result = the_locking_inset->dispatch(cmd);
+		DispatchResult result = the_locking_inset->dispatch(cmd);
 
 		if (result.dispatched()) {
 			if (result.update()) {
@@ -696,7 +698,8 @@ InsetText::priv_dispatch(FuncRequest con
 		switch (result.val()) {
 		case FINISHED_RIGHT:
 			moveRightIntern(bv, false, false);
-			result = DispatchResult(true, true);
+			result.dispatched(true);
+			result.update(true);
 			break;
 		case FINISHED_UP:
 			result = moveUp(bv);
@@ -713,7 +716,8 @@ InsetText::priv_dispatch(FuncRequest con
 			}
 			break;
 		default:
-			result = DispatchResult(true, true);
+			result.dispatched(true);
+			result.update(true);
 			break;
 		}
 		the_locking_inset = 0;
@@ -722,10 +726,8 @@ InsetText::priv_dispatch(FuncRequest con
 		bv->owner()->clearMessage();
 		return result;
 	}
-	bool updflag = false;
 
 	switch (cmd.action) {
-
 	// Normal chars
 	case LFUN_SELFINSERT:
 		if (bv->buffer()->isReadonly()) {
@@ -753,8 +755,8 @@ InsetText::priv_dispatch(FuncRequest con
 					TranslateAndInsert(cmd.argument[i], &text_);
 		}
 		text_.selection.cursor = text_.cursor;
-		updflag = true;
-		result = DispatchResult(true);
+		result.dispatched(true);
+		result.update(true);
 		break;
 
 	// cursor movements that need special handling
@@ -778,21 +780,21 @@ InsetText::priv_dispatch(FuncRequest con
 
 	case LFUN_PRIOR:
 		if (crow() == text_.firstRow())
-			result = DispatchResult(false, FINISHED_UP);
+			result.val(FINISHED_UP);
 		else {
 			text_.cursorPrevious();
 			text_.clearSelection();
-			result = DispatchResult(true);
+			result.dispatched(true);
 		}
 		break;
 
 	case LFUN_NEXT:
 		if (crow() == text_.lastRow())
-			result = DispatchResult(false, FINISHED_DOWN);
+			result.val(FINISHED_DOWN);
 		else {
 			text_.cursorNext();
 			text_.clearSelection();
-			result = DispatchResult(true);
+			result.dispatched(true);
 		}
 		break;
 
@@ -801,7 +803,8 @@ InsetText::priv_dispatch(FuncRequest con
 			text_.cutSelection(true, false);
 		else
 			text_.backspace();
-		updflag = true;
+#warning should be also set dispatched here?
+		result.update(true);
 		break;
 
 	case LFUN_DELETE:
@@ -809,7 +812,8 @@ InsetText::priv_dispatch(FuncRequest con
 			text_.cutSelection(true, false);
 		else
 			text_.Delete();
-		updflag = true;
+#warning should be also set dispatched here?
+		result.update(true);
 		break;
 
 	case LFUN_PASTE:
@@ -831,38 +835,45 @@ InsetText::priv_dispatch(FuncRequest con
 			text_.pasteSelection(sel_index);
 			// bug 393
 			text_.clearSelection();
-			updflag = true;
+#warning should be also set dispatched here?
+			result.update(true);
 		}
 		break;
 
 	case LFUN_BREAKPARAGRAPH:
 		if (!autoBreakRows_) {
-			result = DispatchResult(true, true);
+			result.dispatched(true);
+			result.update(true);
 		} else {
 			replaceSelection(bv->getLyXText());
 			text_.breakParagraph(paragraphs, 0);
-			updflag = true;
+#warning should be also set dispatched here?
+			result.update(true);
 		}
 		break;
 
 	case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
 		if (!autoBreakRows_) {
-			result = DispatchResult(true, true);
+			result.dispatched(true);
+			result.update(true);
 		} else {
 			replaceSelection(bv->getLyXText());
 			text_.breakParagraph(paragraphs, 1);
-			updflag = true;
+#warning should be also set dispatched here?
+			result.update(true);
 		}
 		break;
 
 	case LFUN_BREAKLINE: {
 		if (!autoBreakRows_) {
-			result = DispatchResult(true, true);
+			result.dispatched(true);
+			result.update(true);
 		} else {
 			replaceSelection(bv->getLyXText());
 			auto_ptr<InsetNewline> ins(new InsetNewline);
 			text_.insertInset(ins.release());
-			updflag = true;
+#warning should be also set dispatched here?
+			result.update(true);
 		}
 		break;
 	}
@@ -897,7 +908,8 @@ InsetText::priv_dispatch(FuncRequest con
 				cur_layout = layout;
 				text_.setLayout(layout);
 				bv->owner()->setLayout(cpar()->layout()->name());
-				updflag = true;
+#warning should be also set dispatched here?
+				result.update(true);
 			}
 		} else {
 			// reset the layout box
@@ -906,13 +918,14 @@ InsetText::priv_dispatch(FuncRequest con
 		break;
 
 	default:
-		if (!bv->dispatch(cmd))
-			result = DispatchResult(false);
 		break;
 	}
 
-	updateLocal(bv, updflag);
-
+	if (result.update()) {
+		result.update(false);
+		updateLocal(bv, true);
+	}
+	
 	/// If the action has deleted all text in the inset, we need to change the
 	// language to the language of the surronding text.
 	if (!was_empty && paragraphs.begin()->empty() &&
@@ -922,11 +935,11 @@ InsetText::priv_dispatch(FuncRequest con
 		setFont(bv, font, false);
 	}
 
-	if (result.val() >= FINISHED)
+	if (result.val() >= FINISHED) {
+		result.val(NONE);
 		bv->unlockInset(this);
+	}
 
-	if (result.val() == NONE)
-		result = DispatchResult(true, true);
 	return result;
 }
 
-- 
        Lgb

Reply via email to