Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-24 Thread Jean-Marc Lasgouttes

Le 20/04/17 à 23:17, Uwe Stöhr a écrit :

In your changes you reverted the allowMathIndent() routine in
GuiDocument. This is necessary because now we have a bug:
- set default math indent
- now change to custom and input a length and press Apply
- now uncheck "Indent Formulas"
result: the length fields are still active.

I am tending to re-introduce allowMathIndent() therefore.


I removed that by mistake.

JMarc


Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-20 Thread Uwe Stöhr

El 20.04.2017 a las 23:17, Uwe Stöhr escribió:

I have seen your changes but now LyX has no longer the GlueLength 
ability as you noted.


Sorry. This ability was not in LyX. glue lengths are not allowed as 
parameter of \setspace. So having HSpace there was indeed never necessary.


thanks and regards
Uwe


Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-20 Thread Uwe Stöhr

El 20.04.2017 a las 18:11, Jean-Marc Lasgouttes escribió:

I turns out that I committed it by mistake. Please complain if something 
is wrong.


I did in my previous mail and just put in a fix for the error I get.

thanks for your work and regards
Uwe


Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-20 Thread Uwe Stöhr

El 19.04.2017 a las 11:58, Jean-Marc Lasgouttes escribió:

HSpace is a class that contains a GlueLength, a complex class that 
handles subleties of a length like 1cm-2mm+3mm. Is that "just a string" 
to you??


"1cm-2mm+3mm" is a string to me, yes. I did not need the special 
features of the Length class, but I guess for the on screen 
visualization it is necessary.


I have seen your changes but now LyX has no longer the GlueLength 
ability as you noted. I cannot remember what I had in mind 8 years ago 
when implementing it, but I remember that glue length are useful and 
were even requested by users. So maybe there was a good reason to allow 
glue lengths for the paragraph indentation.


In your changes you reverted the allowMathIndent() routine in 
GuiDocument. This is necessary because now we have a bug:

- set default math indent
- now change to custom and input a length and press Apply
- now uncheck "Indent Formulas"
result: the length fields are still active.

I am tending to re-introduce allowMathIndent() therefore.


Do as you want, I am not going to write UI after all.


OK.

regards Uwe


Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-20 Thread Jean-Marc Lasgouttes

Le 19/04/2017 à 18:15, Jean-Marc Lasgouttes a écrit :

The attached patches (1) revert your patch and (2) use a Length object
instead of HSpace (as well as rename variables with the shorter
mathindent name).

If it is OK with you I will commit these, and then commit a change to
make the indentation visible on screen.


I turns out that I committed it by mistake. Please complain if something 
is wrong.


JMarc



Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-19 Thread Jean-Marc Lasgouttes

Le 18/04/2017 à 15:54, Jean-Marc Lasgouttes a écrit :

Getting rid of the proper length in favor of the weird string version
was definitely not what I had in mind. What I meant is that the HSpace
class is not useful and that a simple Length class would have been a
better choice.

I'll see what I can do. I will propose a patch that reverts your this
commit and does something similar to what I did for parindent.


The attached patches (1) revert your patch and (2) use a Length object 
instead of HSpace (as well as rename variables with the shorter 
mathindent name).


If it is OK with you I will commit these, and then commit a change to 
make the indentation visible on screen.


JMarc



From d86954eb815b8018eb216bfbc1ab344c45e18ebe Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes 
Date: Wed, 19 Apr 2017 16:19:18 +0200
Subject: [PATCH 1/2] Revert "BufferParams: get rid of the HSpace class for
 mathindent as requested by JMarc"

This reverts commit d9a2a4026800865b15da186620ffab4c6b409765.

This is not the right way of getting rid of HSpace. We need a proper
Length, not a string.
---
 src/Buffer.cpp|2 +-
 src/BufferParams.cpp  |   25 +
 src/BufferParams.h|5 
 src/frontends/qt4/GuiDocument.cpp |   56 +
 src/frontends/qt4/GuiDocument.h   |1 -
 5 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 36fb8d2..4795892 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -916,7 +916,7 @@ int Buffer::readHeader(Lexer & lex)
 	params().headheight.erase();
 	params().headsep.erase();
 	params().footskip.erase();
-	params().math_indentation = "default";
+	params().math_indentation.erase();
 	params().columnsep.erase();
 	params().fonts_cjk.erase();
 	params().listings_params.clear();
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 9f05fe8..863e802 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -342,6 +342,7 @@ public:
 	 * and for detached paragraphs in "indented" documents.
 	 */
 	VSpace defskip;
+	HSpace math_indentation;
 	PDFOptions pdfoptions;
 	LayoutFileIndex baseClass_;
 	FormatList exportableFormatList;
@@ -628,6 +629,18 @@ PDFOptions const & BufferParams::pdfoptions() const
 }
 
 
+HSpace const & BufferParams::getMathIndentation() const
+{
+	return pimpl_->math_indentation;
+}
+
+
+void BufferParams::setMathIndentation(HSpace const & indent)
+{
+	pimpl_->math_indentation = indent;
+}
+
+
 Length const & BufferParams::getParIndent() const
 {
 	return pimpl_->parindent;
@@ -838,7 +851,9 @@ string BufferParams::readToken(Lexer & lex, string const & token,
 	} else if (token == "\\is_math_indent") {
 		lex >> is_math_indent;
 	} else if (token == "\\math_indentation") {
-		lex >> math_indentation;
+		lex.next();
+		string math_indentation = lex.getString();
+		pimpl_->math_indentation = HSpace(math_indentation);
 	} else if (token == "\\quotes_style") {
 		string qstyle;
 		lex >> qstyle;
@@ -1337,8 +1352,8 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
 	else
 		os << "\n\\defskip " << getDefSkip().asLyXCommand();
 	os << "\n\\is_math_indent " << is_math_indent;
-	if (is_math_indent && math_indentation != "default")
-		os << "\n\\math_indentation " << math_indentation;
+	if (is_math_indent && getMathIndentation().asLyXCommand() != "default")
+		os << "\n\\math_indentation " << getMathIndentation().asLyXCommand();
 	os << "\n\\quotes_style "
 	   << string_quotes_style[quotes_style]
 	   << "\n\\dynamic_quotes " << dynamic_quotes
@@ -1950,9 +1965,9 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 	if (is_math_indent) {
 		// when formula indentation
 		// only output something when it is not the default
-		if (math_indentation != "default") {
+		if (getMathIndentation().asLyXCommand() != "default") {
 			os << "\\setlength{\\mathindent}{"
-			   << from_utf8(math_indentation)
+			   << from_utf8(getMathIndentation().asLatexCommand())
 			   << "}\n";
 		}
 	}
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 437d00b..14935a9 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -102,6 +102,11 @@ public:
 	///
 	void setDefSkip(VSpace const & vs);
 
+	///
+	HSpace const & getMathIndentation() const;
+	///
+	void setMathIndentation(HSpace const & indent);
+
 	/// Whether formulas are indented
 	bool is_math_indent;
 
diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp
index 691bb2c..64975fe 100644
--- a/src/frontends/qt4/GuiDocument.cpp
+++ b/src/frontends/qt4/GuiDocument.cpp
@@ -727,8 +727,6 @@ GuiDocument::GuiDocument(GuiView & lv)
 
 	connect(textLayoutModule->MathIndentCB, SIGNAL(toggled(bool)),
 		this, SLOT(change_adaptor()));
-	connect(textLayoutModule->MathIndentCB, SIGNAL(toggled(bool)),
-		this, SLOT(allowMathIndent()));
 	connect(textLayoutModule->MathIndentCO, SIGNAL(activated(int)),
 		

Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-19 Thread Jean-Marc Lasgouttes

Le 18/04/2017 à 22:45, Uwe Stöhr a écrit :

El 18.04.2017 a las 15:54, Jean-Marc Lasgouttes escribió:


Getting rid of the proper length in favor of the weird string version
was definitely not what I had in mind.


I cannot follow you anymore. What i did is just what the HSpace class
does - it is a string using "default" ads default value. If you prefer
an empty string or the Length class, fine by me. If possible I would had
it over to you because i think you have something different in mind as I
have. So please feel free to override my changes and to transform it as
you like.


HSpace is a class that contains a GlueLength, a complex class that 
handles subleties of a length like 1cm-2mm+3mm. Is that "just a string" 
to you??


I agree that the extra complexity of GlueLength vs Length may not be 
needed, but it is you who chose that, not me.


A length should be kept in a Length object.
A glue length should be kept in a GlueLength object.

How do you get the length of a string in inches?


Besides this I insist on having the math indentation settings in the
math panel for LyX 2.3. Günter agreed as well and I haven't heard other
opinions. I am insisting because I will send right now a patch that also
supports the document class option "lineno". No matter if this will make
it in for LyX 2.3.0 or not, I think both options belong together and the
place of the formula numbering is definitely nothing that belongs to text.


Do as you want, I am not going to write UI after all.

JMarc



Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-18 Thread Uwe Stöhr

El 18.04.2017 a las 22:45, Uwe Stöhr escribió:


I am insisting because I will send right now a patch


I sent it now and CCed you. Could you please have a look?

thanks and regards
Uwe


Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-18 Thread Uwe Stöhr

El 18.04.2017 a las 15:54, Jean-Marc Lasgouttes escribió:

Getting rid of the proper length in favor of the weird string version 
was definitely not what I had in mind.


I cannot follow you anymore. What i did is just what the HSpace class 
does - it is a string using "default" ads default value. If you prefer 
an empty string or the Length class, fine by me. If possible I would had 
it over to you because i think you have something different in mind as I 
have. So please feel free to override my changes and to transform it as 
you like.


Besides this I insist on having the math indentation settings in the 
math panel for LyX 2.3. Günter agreed as well and I haven't heard other 
opinions. I am insisting because I will send right now a patch that also 
supports the document class option "lineno". No matter if this will make 
it in for LyX 2.3.0 or not, I think both options belong together and the 
place of the formula numbering is definitely nothing that belongs to text.


thanks and regards
Uwe


Re: [LyX/master] BufferParams: get rid of the HSpace class for mathindent as requested by JMarc

2017-04-18 Thread Jean-Marc Lasgouttes

Le 17/04/2017 à 20:32, Uwe Stöhr a écrit :

commit d9a2a4026800865b15da186620ffab4c6b409765
Author: Uwe Stöhr 
Date:   Mon Apr 17 20:32:31 2017 +0200

BufferParams: get rid of the HSpace class for mathindent as requested by 
JMarc


Getting rid of the proper length in favor of the weird string version 
was definitely not what I had in mind. What I meant is that the HSpace 
class is not useful and that a simple Length class would have been a 
better choice.


I'll see what I can do. I will propose a patch that reverts your this 
commit and does something similar to what I did for parindent.


JMarc