>>>>> "Kayvan" == Kayvan A Sylvan <[EMAIL PROTECTED]> writes:

Kayvan> I want to Insert->File->ASCII as Lines, but this option is
Kayvan> grayed out along with "LyX Document" and "Ascii as
Kayvan> paragraphs".

This is cured by the following patch.

Andre', this patch also cures the handling of read-only buffers. I
moved the check for read-only to the end of getStatus, now that the
default for "enable" is false.

I'll commit shortly if there is no objection.

JMarc

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1838
diff -u -p -r1.1838 ChangeLog
--- src/ChangeLog	22 Mar 2004 16:22:51 -0000	1.1838
+++ src/ChangeLog	22 Mar 2004 17:04:59 -0000
@@ -1,5 +1,8 @@
 2004-03-22  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
+	* lyxfunc.C (getStatus): handle read-only buffers correctly;
+	handle LFUN_FILE_INSERT_*
+
 	* lyxrc.C (setDefaults, getDescription, output, read): 
 	* lyxrc.h: remove ps_command
 
Index: src/lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.585
diff -u -p -r1.585 lyxfunc.C
--- src/lyxfunc.C	18 Mar 2004 16:41:45 -0000	1.585
+++ src/lyxfunc.C	22 Mar 2004 17:05:00 -0000
@@ -287,25 +287,12 @@ FuncStatus LyXFunc::getStatus(FuncReques
 	setStatusMessage(N_("Command disabled"));
 
 	// Check whether we need a buffer
-	if (!lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
-		// Yes we need a buffer, do we have one?
-		if (buf) {
-			// yes
-			// Can we use a readonly buffer?
-			if (buf->isReadonly() &&
-			    !lyxaction.funcHasFlag(cmd.action,
-						   LyXAction::ReadOnly)) {
-				// no
-				setStatusMessage(N_("Document is read-only"));
-				flag.enabled(false);
-			}
-		} else {
-			// no
-			setStatusMessage(N_("Command not allowed with"
-					    "out any document open"));
-			flag.enabled(false);
-			return flag;
-		}
+	if (!lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer) && !buf) {
+		// no, exit directly
+		setStatusMessage(N_("Command not allowed with"
+				    "out any document open"));
+		flag.enabled(false);
+		return flag;
 	}
 
 	// I would really like to avoid having this switch and rather try to
@@ -503,15 +490,27 @@ FuncStatus LyXFunc::getStatus(FuncReques
 	case LFUN_SET_COLOR:
 	case LFUN_MESSAGE:
 	case LFUN_EXTERNAL_EDIT:
+	case LFUN_FILE_INSERT:
+	case LFUN_FILE_INSERT_ASCII:
+	case LFUN_FILE_INSERT_ASCII_PARA:
 		// these are handled in our dispatch()
 		break;
 
 	default:
 		cur.getStatus(cmd, flag);
-		return flag;
 	}
 
-	flag.enabled(enable);
+	if (!enable)
+		flag.enabled(false);
+
+	// Can we use a readonly buffer?
+	if (buf && buf->isReadonly() 
+	    && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly)
+	    && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)) {
+		setStatusMessage(N_("Document is read-only"));
+		flag.enabled(false);
+	}
+
 	return flag;
 }
 

Reply via email to