>>>>> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes:

Georg> And I know now why: the statement

Georg> flag = view()->getStatus(cmd);

Georg> in LyXFunc::getStatus() cleared the message. 

Indeed. The right solution is to use |= instead of =.

Georg> I added it a second time (not very elegant, but I know no
Georg> better solution). Is the attached patch ok?

Actually, setting the default error message at the end rather than the
beginning is better in my opinion. I planned to do it after the
problem is really solved, since I was afraid it would hide real
problem.

The following patch merges your patch with my earlier patch. It seems
to work here, but I have not been very imaginative in my testing.

JMarc

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2049
diff -u -p -r1.2049 ChangeLog
--- src/ChangeLog	30 Nov 2004 09:21:10 -0000	1.2049
+++ src/ChangeLog	2 Dec 2004 09:39:02 -0000
@@ -1,3 +1,17 @@
+2004-12-01  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* lyxfunc.C (getStatus): do not lose previous information when
+	calling BufferView::getStatus; do not set a default "Command
+	disabled" message at the beginning, but just before returning.
+
+2004-11-30  Georg Baum  <[EMAIL PROTECTED]>
+
+	* cursor.h (getStatus): add better comment from src/cursor.C
+
+2004-11-30  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* text3.C (getStatus): return false when the lfun is not handled
+
 2004-11-29  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* broken_headers.h: remove
@@ -21,7 +35,7 @@
 
 	* bufferview_funcs.[Ch]: introduce coordOffset, getPos, status,
 	CurStatus enum.
-  	
+
 	* coordcache.[Ch]: add paragraph cache and helpers
 
 	* CursorSlice.[Ch]: rename CursorSlice::par to CursorSlice::pit,
Index: src/cursor.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.h,v
retrieving revision 1.67
diff -u -p -r1.67 cursor.h
--- src/cursor.h	30 Nov 2004 01:59:33 -0000	1.67
+++ src/cursor.h	2 Dec 2004 09:39:03 -0000
@@ -42,7 +42,12 @@ public:
 	void dispatch(FuncRequest const & cmd);
 	/// get the resut of the last dispatch
 	DispatchResult result() const;
-	/// are we willing to handle this event?
+        /**
+	 * \returns true if this function made a definitive decision on
+	 * whether the inset at this cursor position wants to handle the
+	 * request \p cmd or not. The result of this decision is put into
+	 * \p status.
+	 */
 	bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
 
 	/// add a new cursor slice
Index: src/lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.633
diff -u -p -r1.633 lyxfunc.C
--- src/lyxfunc.C	30 Nov 2004 01:59:33 -0000	1.633
+++ src/lyxfunc.C	2 Dec 2004 09:39:03 -0000
@@ -308,10 +308,11 @@ FuncStatus LyXFunc::getStatus(FuncReques
 		return flag;
 	}
 
-	// the default error message if we disable the command
-	flag.message(N_("Command disabled"));
-	if (!flag.enabled())
+	if (!flag.enabled()) {
+		if (flag.message().empty())
+			flag.message(N_("Command disabled"));
 		return flag;
+	}
 
 	// Check whether we need a buffer
 	if (!lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer) && !buf) {
@@ -523,7 +524,7 @@ FuncStatus LyXFunc::getStatus(FuncReques
 	default:
 
 		if (!cur.getStatus(cmd, flag))
-			flag = view()->getStatus(cmd);
+			flag |= view()->getStatus(cmd);
 	}
 
 	if (!enable)
@@ -537,7 +538,10 @@ FuncStatus LyXFunc::getStatus(FuncReques
 		flag.enabled(false);
 	}
 
-	//lyxerr << "LyXFunc::getStatus: got: " << flag.enabled() << endl;
+	// the default error message if we disable the command
+	if (!flag.enabled() && flag.message().empty())
+		flag.message(N_("Command disabled"));
+
 	return flag;
 }
 
Index: src/text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.272
diff -u -p -r1.272 text3.C
--- src/text3.C	30 Nov 2004 01:59:41 -0000	1.272
+++ src/text3.C	2 Dec 2004 09:39:03 -0000
@@ -1627,7 +1627,7 @@ void LyXText::dispatch(LCursor & cur, Fu
 
 
 bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
-	FuncStatus & flag) const
+			FuncStatus & flag) const
 {
 	BOOST_ASSERT(cur.text() == this);
 	LyXFont const & font = real_current_font;
@@ -1969,8 +1969,7 @@ bool LyXText::getStatus(LCursor & cur, F
 		break;
 
 	default:
-		enable = false;
-		break;
+		return false;
 	}
 	flag.enabled(enable);
 	return true;
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.1083
diff -u -p -r1.1083 ChangeLog
--- src/insets/ChangeLog	30 Nov 2004 01:59:46 -0000	1.1083
+++ src/insets/ChangeLog	2 Dec 2004 09:39:03 -0000
@@ -1,3 +1,7 @@
+2004-11-30  Georg Baum  <[EMAIL PROTECTED]>
+
+	* insetbase.h (getStatus): add better comment from src/cursor.C
+
 2004-11-26  Alfredo Braunstein  <[EMAIL PROTECTED]>
 
 	* insettabular.[Ch]: adjust, introduce "do not draw
Index: src/insets/insetbase.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbase.h,v
retrieving revision 1.46
diff -u -p -r1.46 insetbase.h
--- src/insets/insetbase.h	30 Nov 2004 01:59:46 -0000	1.46
+++ src/insets/insetbase.h	2 Dec 2004 09:39:03 -0000
@@ -79,9 +79,13 @@ public:
 	/// true for 'math' math inset, but not for e.g. mbox
 	virtual bool inMathed() const { return false; }
 
-	// the real dispatcher
+	/// the real dispatcher
 	void dispatch(LCursor & cur, FuncRequest & cmd);
-	/// do we want to handle this event?
+	/**
+	 * \returns true if this function made a definitive decision on
+	 * whether the inset wants to handle the request \p cmd or not.
+	 * The result of this decision is put into \p status.
+	 */
 	virtual bool getStatus(LCursor & cur, FuncRequest const & cmd,
 		FuncStatus & status) const;
 

Reply via email to