Re: [PATCH] It's Christmas time!

2004-12-27 Thread Jean-Marc Lasgouttes
 Jean-Marc == Jean-Marc Lasgouttes [EMAIL PROTECTED] writes:

Jean-Marc For as long as LyX has been in use, or almost, people have
Jean-Marc been complaining that there is no word count feature. Since
Jean-Marc even abiword has that now ;), I thought it was a good idea
Jean-Marc to implement it.

I applied it, and anybody who thinks it's too crude is welcome to
improve it.

I did not find a place to document it in the user guide, though.

JMarc


Re: LFUN_MATH_MODE

2004-12-27 Thread Jean-Marc Lasgouttes
 Juergen == Juergen Spitzmueller [EMAIL PROTECTED] writes:

Juergen Andre Poenitz wrote:
 There is also a check for the argument on in math_nestinset.C. I
 
  guess André forgot to check for that argument in other places
 (text3.C et  al.).
 
 Indeed. Would be nice if you could fix that.

Juergen Fix attached. OK to commit?

I am not sure why we want to enable something like math-mode
content. Actually, when Andre posted
  http://marc.theaimsgroup.com/?l=lyx-develm=110379007315837w=2
I read it as saying that math-mode should not do the work of
math-insert. 

However, if your patch is really what Andre' meant, go ahead.

JMarc


Re: LyX + MinGW + MinSYS + GPLed QT/Win32 --- success!

2004-12-27 Thread Jean-Marc Lasgouttes
 Ruurd == Ruurd Reitsma [EMAIL PROTECTED] writes:

Ruurd Jean-Marc Lasgouttes [EMAIL PROTECTED] wrote in
Ruurd message news:[EMAIL PROTECTED]

 I do not remember whether I already pointed it out, but there is a
 hack in lyx_gui.C for LyX/Mac that fixes such a problem. This is
 lyx_gui::needs_ugly_metrics_hack() in src/frontends/qt2/lyx_gui.C.
 Did you try to make it return 'true' for LyX/Win?

Ruurd Yes, but it didn´t work This is what happens.

Seeing that menu separator is also badly drawn, I would suggest that
there is a bug in the implementation of QPainter::drawPolyline in
qt3/win32. It would be nice to find a test program that shows a bad
behaviour, so that it can be fixed.

JMarc


Re: LFUN_MATH_MODE

2004-12-27 Thread Juergen Spitzmueller
Jean-Marc Lasgouttes wrote:
 Juergen Fix attached. OK to commit?

 I am not sure why we want to enable something like math-mode
 content. 

That's how it always used to be (at least in 1.3 and 1.4cvs). And this is also 
the reason for the bug I'm fixing.

 Actually, when Andre posted 
   http://marc.theaimsgroup.com/?l=lyx-develm=110379007315837w=2
 I read it as saying that math-mode should not do the work of
 math-insert.
 However, if your patch is really what Andre' meant, go ahead.

I am not sure. 
Should it just swallow any argument (on will be recognized anyway in 
math_nestinset), or should LFUN_MATH_MODE do something like

case LFUN_MATH_MODE:
if (cmd.argument.empty())
mathDispatch(cur, cmd, false);
else if (cmd.argument == on)
// don't pass on as argument
mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
else {
mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);  
mathDispatch(cur, FuncRequest(LFUN_INSERT_MATH, 
cmd.argument), false);  
}
break;

OTOH I thought that this is what mathDispatch does anyway (using 
LFUN_INSERT_MATH), so it should be functionally equivalent to my patch.

Jürgen


Re: LFUN_MATH_MODE

2004-12-27 Thread Jean-Marc Lasgouttes
 Juergen == Juergen Spitzmueller [EMAIL PROTECTED] writes:

Juergen Jean-Marc Lasgouttes wrote: Fix attached. OK to commit?
  I am not sure why we want to enable something like math-mode
 content.

Juergen That's how it always used to be (at least in 1.3 and 1.4cvs).
Juergen And this is also the reason for the bug I'm fixing.

OK, go for your patch, then.

JMarc



Re: Configure problems for lyx-140 on Mac

2004-12-27 Thread Jean-Marc Lasgouttes
 Andreas == Andreas Vox [EMAIL PROTECTED] writes:

 IMHO the only viable in-lyx solution is to disable concept-checking
 for darwin.

Andreas What's wrong with my idea?

It is too complicated. I know we have a lot of these clever hacks in
the configure code (I am partly to blame for that), but we should
avoid it as much as possible.

What happens if we disable it for darwin? Well, the mac developpers
will not some some specialized compile-time errors that the linux
developers will see and fix anyway. Big deal...

JMarc


Re: [patch] float - string #1

2004-12-27 Thread Juergen Spitzmueller
Jean-Marc Lasgouttes wrote:
 Hmm, I'd rather store LyXLength internally. Not being able to convert
 correctly is a poor excuse for storing a string that take time to
 parse.

The cases I am addressing do not have units, these are simply floats or 
doubles (rotation angle, scale value, screen font size and such things). Is 
LyXLength really the right thing here?

Note that I do not really care about the solution (either fix lexical_cast, 
use something else than lexical_cast, store strings or something else). I am 
just waiting until you have come to an agreement.

Jürgen 


[patch] small mathed fixes

2004-12-27 Thread Juergen Spitzmueller
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 -	1.275
+++ text3.C	27 Dec 2004 18:29:00 -
@@ -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 -	1.10
+++ mathed/math_colorinset.C	27 Dec 2004 18:29:10 -
@@ -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 -	1.141
+++ mathed/math_nestinset.C	27 Dec 2004 18:29:12 -
@@ -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


Re: Setting LyX's various paths --- request for testers

2004-12-27 Thread Georg Baum
Angus Leeming wrote:

 All the fun is in package.C. It should now be (fairly)
 understandable... ;-)

Indeed. Plus, I tried to break it (on linux) but failed :-)

 See you all after Christmas.
 Angus

I hope you all had nice Christmas days and maybe some additional holidays
too.


Georg



Re: [PATCH] It's Christmas time!

2004-12-27 Thread Jean-Marc Lasgouttes
> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

Jean-Marc> For as long as LyX has been in use, or almost, people have
Jean-Marc> been complaining that there is no word count feature. Since
Jean-Marc> even abiword has that now ;), I thought it was a good idea
Jean-Marc> to implement it.

I applied it, and anybody who thinks it's too crude is welcome to
improve it.

I did not find a place to document it in the user guide, though.

JMarc


Re: LFUN_MATH_MODE

2004-12-27 Thread Jean-Marc Lasgouttes
> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes:

Juergen> Andre Poenitz wrote:
>> There is also a check for the argument "on" in math_nestinset.C. I
>> 
>> > guess André forgot to check for that argument in other places
>> (text3.C et > al.).
>> 
>> Indeed. Would be nice if you could fix that.

Juergen> Fix attached. OK to commit?

I am not sure why we want to enable something like "math-mode
". Actually, when Andre posted
  http://marc.theaimsgroup.com/?l=lyx-devel=110379007315837=2
I read it as saying that math-mode should not do the work of
math-insert. 

However, if your patch is really what Andre' meant, go ahead.

JMarc


Re: LyX + MinGW + MinSYS + GPLed QT/Win32 --- success!

2004-12-27 Thread Jean-Marc Lasgouttes
> "Ruurd" == Ruurd Reitsma <[EMAIL PROTECTED]> writes:

Ruurd> "Jean-Marc Lasgouttes" <[EMAIL PROTECTED]> wrote in
Ruurd> message news:[EMAIL PROTECTED]

>> I do not remember whether I already pointed it out, but there is a
>> hack in lyx_gui.C for LyX/Mac that fixes such a problem. This is
>> lyx_gui::needs_ugly_metrics_hack() in src/frontends/qt2/lyx_gui.C.
>> Did you try to make it return 'true' for LyX/Win?

Ruurd> Yes, but it didn´t work This is what happens.

Seeing that menu separator is also badly drawn, I would suggest that
there is a bug in the implementation of QPainter::drawPolyline in
qt3/win32. It would be nice to find a test program that shows a bad
behaviour, so that it can be fixed.

JMarc


Re: LFUN_MATH_MODE

2004-12-27 Thread Juergen Spitzmueller
Jean-Marc Lasgouttes wrote:
> Juergen> Fix attached. OK to commit?
>
> I am not sure why we want to enable something like "math-mode
> ". 

That's how it always used to be (at least in 1.3 and 1.4cvs). And this is also 
the reason for the bug I'm fixing.

> Actually, when Andre posted 
>   http://marc.theaimsgroup.com/?l=lyx-devel=110379007315837=2
> I read it as saying that math-mode should not do the work of
> math-insert.
> However, if your patch is really what Andre' meant, go ahead.

I am not sure. 
Should it just swallow any argument ("on" will be recognized anyway in 
math_nestinset), or should LFUN_MATH_MODE do something like

case LFUN_MATH_MODE:
if (cmd.argument.empty())
mathDispatch(cur, cmd, false);
else if (cmd.argument == "on")
// don't pass "on" as argument
mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);
else {
mathDispatch(cur, FuncRequest(LFUN_MATH_MODE), false);  
mathDispatch(cur, FuncRequest(LFUN_INSERT_MATH, 
cmd.argument), false);  
}
break;

OTOH I thought that this is what mathDispatch does anyway (using 
LFUN_INSERT_MATH), so it should be functionally equivalent to my patch.

Jürgen


Re: LFUN_MATH_MODE

2004-12-27 Thread Jean-Marc Lasgouttes
> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes:

Juergen> Jean-Marc Lasgouttes wrote: Fix attached. OK to commit?
>>  I am not sure why we want to enable something like "math-mode
>> ".

Juergen> That's how it always used to be (at least in 1.3 and 1.4cvs).
Juergen> And this is also the reason for the bug I'm fixing.

OK, go for your patch, then.

JMarc



Re: Configure problems for lyx-140 on Mac

2004-12-27 Thread Jean-Marc Lasgouttes
> "Andreas" == Andreas Vox <[EMAIL PROTECTED]> writes:

>> IMHO the only viable in-lyx solution is to disable concept-checking
>> for darwin.

Andreas> What's wrong with my idea?

It is too complicated. I know we have a lot of these clever hacks in
the configure code (I am partly to blame for that), but we should
avoid it as much as possible.

What happens if we disable it for darwin? Well, the mac developpers
will not some some specialized compile-time errors that the linux
developers will see and fix anyway. Big deal...

JMarc


Re: [patch] float -> string #1

2004-12-27 Thread Juergen Spitzmueller
Jean-Marc Lasgouttes wrote:
> Hmm, I'd rather store LyXLength internally. Not being able to convert
> correctly is a poor excuse for storing a string that take time to
> parse.

The cases I am addressing do not have units, these are simply floats or 
doubles (rotation angle, scale value, screen font size and such things). Is 
LyXLength really the right thing here?

Note that I do not really care about the solution (either fix lexical_cast, 
use something else than lexical_cast, store strings or something else). I am 
just waiting until you have come to an agreement.

Jürgen 


[patch] small mathed fixes

2004-12-27 Thread Juergen Spitzmueller
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 -	1.275
+++ text3.C	27 Dec 2004 18:29:00 -
@@ -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 -	1.10
+++ mathed/math_colorinset.C	27 Dec 2004 18:29:10 -
@@ -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 -	1.141
+++ mathed/math_nestinset.C	27 Dec 2004 18:29:12 -
@@ -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


Re: Setting LyX's various paths --- request for testers

2004-12-27 Thread Georg Baum
Angus Leeming wrote:

> All the fun is in package.C. It should now be (fairly)
> understandable... ;-)

Indeed. Plus, I tried to break it (on linux) but failed :-)

> See you all after Christmas.
> Angus

I hope you all had nice Christmas days and maybe some additional holidays
too.


Georg