the patch reenables LFUN_{SUB|SUPER}SCRIPT and thus the insertion of scripts 
via Insert->Special Formatting.

There are still some remaining annoyances:

1. Most importantly: the crash described in bug 1598
(http://bugzilla.lyx.org/show_bug.cgi?id=1598)

2. LFUN_FREEFONT_APPLY (in math_nestinset) inserts a math_colorbox, which 
insists to draw an (editable!), IMO very distracting label "[none]" (the 
color name) while the cursor is inside the math inset. The patch fixes the 
handling of color "none" in math_colorbox itself, though (which is of course 
\normalcolor, not \color{none}), so at least the thing gets compiled now.

3. freefont-apply does not do what I'd expect from it (i.e., inheriting the 
font from the co-text in the scriptinset).

(2 and 3 can be backed out easily. The old definition of LFUN_FREEFONT_APPLY, 
which is hardcoded to textrm, is still in the sources).

I'll leave all those to Andr� (I do not have time to dig deeper into mathed 
now). For 1.5, I'd like to implement a real InsetScript for texted (using 
\textsuperscript and the \textsubscript macro from the TUG FAQ resp. KOMA).

J�rgen
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.275
diff -u -r1.275 text3.C
--- text3.C	27 Dec 2004 18:26:11 -0000	1.275
+++ text3.C	27 Dec 2004 18:29:00 -0000
@@ -1338,6 +1338,14 @@
 			//cur.nextInset()->edit(cur, true);
 		}
 		break;
+		
+	// passthrough hat and underscore outside mathed:
+	case LFUN_SUBSCRIPT:
+		mathDispatch(cur, FuncRequest(LFUN_SELFINSERT, "_"), false);
+		break;
+	case LFUN_SUPERSCRIPT:
+		mathDispatch(cur, FuncRequest(LFUN_SELFINSERT, "^"), false);
+		break;
 
 	case LFUN_INSERT_MATH:
 	case LFUN_INSERT_MATRIX:
@@ -1908,6 +1916,8 @@
 	case LFUN_INSERT_MATH:
 	case LFUN_INSERT_MATRIX:
 	case LFUN_MATH_DELIM:
+	case LFUN_SUBSCRIPT:
+	case LFUN_SUPERSCRIPT:
 	case LFUN_DEFAULT:
 	case LFUN_UNDERLINE:
 	case LFUN_FONT_SIZE:
Index: mathed/math_colorinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_colorinset.C,v
retrieving revision 1.10
diff -u -r1.10 math_colorinset.C
--- mathed/math_colorinset.C	23 Nov 2004 23:04:50 -0000	1.10
+++ mathed/math_colorinset.C	27 Dec 2004 18:29:10 -0000
@@ -23,6 +23,17 @@
 using std::auto_ptr;
 
 
+namespace {
+
+// color "none" (reset to default) needs special treatment
+bool normalcolor(MathArray const & ar)
+{
+	return (asString(ar) == "none");
+}
+
+} // namespace anon
+
+
 MathColorInset::MathColorInset(bool oldstyle)
 	: MathNestInset(2), oldstyle_(oldstyle)
 {}
@@ -75,13 +86,16 @@
 void MathColorInset::validate(LaTeXFeatures & features) const
 {
 	MathNestInset::validate(features);
-	features.require("color");
+	if (!normalcolor(cell(0)))
+		features.require("color");
 }
 
 
 void MathColorInset::write(WriteStream & os) const
 {
-	if (oldstyle_)
+	if (normalcolor(cell(0)))
+		os << "{\\normalcolor " << cell(1) << '}';
+	else if (oldstyle_)
 		os << "{\\color" << '{' << cell(0) << '}' << cell(1) << '}';
 	else
 		os << "\\textcolor" << '{' << cell(0) << "}{" << cell(1) << '}';
Index: mathed/math_nestinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_nestinset.C,v
retrieving revision 1.141
diff -u -r1.141 math_nestinset.C
--- mathed/math_nestinset.C	30 Nov 2004 01:59:49 -0000	1.141
+++ mathed/math_nestinset.C	27 Dec 2004 18:29:12 -0000
@@ -784,6 +784,18 @@
 		recordUndo(cur, Undo::ATOMIC);
 		interpret(cur, '\\');
 		break;
+		
+	case LFUN_SUBSCRIPT:
+		// interpret this as if a _ was typed
+		recordUndo(cur, Undo::ATOMIC);
+		interpret(cur, '_');
+		break;
+		
+	case LFUN_SUPERSCRIPT:
+		// interpret this as if a ^ was typed
+		recordUndo(cur, Undo::ATOMIC);
+		interpret(cur, '^');
+		break;
 
 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
 // handling such that "self-insert" works on "arbitrary stuff" too, and

Reply via email to