As you may have noticed, quote-insert is broken in current cvs (always inserts 
raw quotes). IMHO this is due to this change:
http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/src/text3.C.diff?r1=1.214&r2=1.215

                BufferParams const & bufparams = bv->buffer()->params();
                if (style->pass_thru ||
-                   pit->getFontSettings(bufparams,pos).language()->lang() == "hebrew" 
||
-                   !bv->insertInset(new InsetQuotes(c, bufparams)))
+                   pit->getFontSettings(bufparams,pos).language()->lang() == "hebrew")
+                 bv->insertInset(new InsetQuotes(c, bufparams));
+               else
                        bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
                break;
        }

Should be something like
                BufferParams const & bufparams = bv->buffer()->params();
-               if (style->pass_thru ||
-                   pit->getFontSettings(bufparams,pos).language()->lang() == "hebrew" 
||
-                   !bv->insertInset(new InsetQuotes(c, bufparams)))
+               if (!style->pass_thru &&
+                   pit->getFontSettings(bufparams,pos).language()->lang() != "hebrew")
+                 bv->insertInset(new InsetQuotes(c, bufparams));
+               else
if I didn't miss all logic.

I fixed this on the way to a first step towards better quotation mark 
handling: the attached patch introduces lfun arguments "quote-insert [inner|
outer]" where single and double quotation marks can be accessed directly.
I think this is much more convenient than toggling single/double in 
document->language [1].
What do you think?

Jürgen.

[1] I think we could get rid of the toggle and bind "quote-insert inner" to 
M-" or whatever.
Index: src/text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.227
diff -u -r1.227 text3.C
--- src/text3.C	16 Feb 2004 17:26:09 -0000	1.227
+++ src/text3.C	18 Feb 2004 16:58:14 -0000
@@ -45,6 +45,7 @@
 #include "insets/insetcommand.h"
 #include "insets/insetfloatlist.h"
 #include "insets/insetnewline.h"
+#include "insets/insetquotes.h"
 #include "insets/insetspecialchar.h"
 #include "insets/insettext.h"
 
@@ -1030,9 +1031,20 @@
 		LyXLayout_ptr const & style = par.layout();
 
 		BufferParams const & bufparams = bv->buffer()->params();
-		if (style->pass_thru ||
-		    par.getFontSettings(bufparams, pos).language()->lang() == "hebrew")
-		  cur.insert(new InsetQuotes(c, bufparams));
+		if (!style->pass_thru &&
+		    par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
+		    	string arg = cmd.argument;
+			if (arg == "inner")
+				cur.insert(new InsetQuotes(c,
+				    bufparams.quotes_language, 
+				    InsetQuotes::SingleQ));
+			else if (arg == "outer")
+				cur.insert(new InsetQuotes(c,
+				    bufparams.quotes_language, 
+				    InsetQuotes::DoubleQ));
+			else
+		  		cur.insert(new InsetQuotes(c, bufparams));
+			}
 		else
 			bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\""));
 		break;
Index: src/insets/insethfill.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insethfill.C,v
retrieving revision 1.15
diff -u -r1.15 insethfill.C
--- src/insets/insethfill.C	11 Dec 2003 15:23:15 -0000	1.15
+++ src/insets/insethfill.C	18 Feb 2004 16:58:17 -0000
@@ -79,3 +79,9 @@
 {
 	os << "\n\\hfill \n";
 }
+
+
+bool InsetHFill::isSpace() const
+{
+	return true;
+}
Index: src/insets/insethfill.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insethfill.h,v
retrieving revision 1.19
diff -u -r1.19 insethfill.h
--- src/insets/insethfill.h	5 Nov 2003 12:06:15 -0000	1.19
+++ src/insets/insethfill.h	18 Feb 2004 16:58:17 -0000
@@ -43,6 +43,9 @@
 	void write(Buffer const & buf, std::ostream & os) const;
 	/// We don't need \begin_inset and \end_inset
 	bool directWrite() const { return true; }
+	/// is this equivalent to a space (which is BTW different from
+	// a line separator)?
+	bool isSpace() const;
 
 };
 
Index: src/insets/insetnewline.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnewline.C,v
retrieving revision 1.21
diff -u -r1.21 insetnewline.C
--- src/insets/insetnewline.C	28 Nov 2003 08:55:10 -0000	1.21
+++ src/insets/insetnewline.C	18 Feb 2004 16:58:17 -0000
@@ -126,3 +126,9 @@
 
 	pi.pain.lines(xp, yp, 3, LColor::eolmarker);
 }
+
+
+bool InsetNewline::isSpace() const
+{
+	return true;
+}
Index: src/insets/insetnewline.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnewline.h,v
retrieving revision 1.18
diff -u -r1.18 insetnewline.h
--- src/insets/insetnewline.h	5 Nov 2003 12:06:16 -0000	1.18
+++ src/insets/insetnewline.h	18 Feb 2004 16:58:17 -0000
@@ -47,6 +47,9 @@
 	virtual void write(Buffer const & buf, std::ostream & os) const;
 	/// We don't need \begin_inset and \end_inset
 	virtual bool directWrite() const { return true; }
+	/// is this equivalent to a space (which is BTW different from
+	// a line separator)?
+	bool isSpace() const;
 };
 
 #endif // INSET_NEWLINE_H
Index: src/insets/insetquotes.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetquotes.C,v
retrieving revision 1.112
diff -u -r1.112 insetquotes.C
--- src/insets/insetquotes.C	5 Nov 2003 12:06:16 -0000	1.112
+++ src/insets/insetquotes.C	18 Feb 2004 16:58:18 -0000
@@ -94,12 +94,23 @@
 InsetQuotes::InsetQuotes(char c, BufferParams const & params)
 	: language_(params.quotes_language), times_(params.quotes_times)
 {
+	getPosition(c);
+}
+
+
+InsetQuotes::InsetQuotes(char c, quote_language l, quote_times t)
+	: language_(l), times_(t)
+{
+	getPosition(c);
+}
+
+
+void InsetQuotes::getPosition(char c)
+{
 	// Decide whether left or right
 	switch (c) {
 	case ' ': case '(':
-#warning eh ? I am lost here ...
-	//case Paragraph::META_HFILL:
-	// case Paragraph::META_NEWLINE:
+	// FIXME: what about '['? (jspitzm)
 		side_ = LeftQ;   // left quote
 		break;
 	default:
Index: src/insets/insetquotes.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetquotes.h,v
retrieving revision 1.59
diff -u -r1.59 insetquotes.h
--- src/insets/insetquotes.h	5 Nov 2003 12:06:17 -0000	1.59
+++ src/insets/insetquotes.h	18 Feb 2004 16:58:18 -0000
@@ -67,6 +67,8 @@
 	InsetQuotes(std::string const & str = "eld");
 	/// Create the right quote inset after character c
 	InsetQuotes(char c, BufferParams const & params);
+	/// Direct access to inner/outer quotation marks
+	InsetQuotes(char c, quote_language l, quote_times t);
 	///
 	virtual std::auto_ptr<InsetBase> clone() const;
 	///
@@ -97,7 +99,7 @@
 	void validate(LaTeXFeatures &) const;
 	///
 	InsetOld::Code lyxCode() const;
-	// should this inset be handled like a normal charater
+	// should this inset be handled like a normal character
 	bool isChar() const { return true; }
 
 private:
@@ -112,6 +114,8 @@
 	    side and the multiplicity of the quote.
 	 */
 	InsetQuotes(quote_language l, quote_side s, quote_times t);
+	/// Decide whether we need left or right quotation marks
+	void getPosition(char c);
 	///
 	void parseString(std::string const &);
 	///

Reply via email to