Re: [LyX/master] Add support to cross out characters
Le 07/05/2017 à 14:41, Guillaume MM a écrit : LFUN_SECTION_SELECT,// vfr, 20090503 LFUN_FONT_UNDERLINE, LFUN_FONT_STRIKEOUT, +LFUN_FONT_CROSSOUT, // uwestoehr 20170402 LFUN_FONT_UNDERUNDERLINE, // 335 LFUN_FONT_UNDERWAVE, After this addition the comments "// 335" etc. are no longer in sync with the enum value, I fear. You are right, I fixed it. JMarc
Re: [LyX/master] Add support to cross out characters
Le 05/04/2017 à 00:01, Uwe Stöhr a écrit : commit e575e7eebd32d687f3e23be0eeca185adb3b341b Author: Uwe Stöhr Date: Wed Apr 5 00:01:19 2017 +0200 Add support to cross out characters - adds support for the command \xout of the LateX package ulem - fileformat change ... index 4ad5a78..e5328a5 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -431,6 +431,7 @@ enum FuncCode LFUN_SECTION_SELECT,// vfr, 20090503 LFUN_FONT_UNDERLINE, LFUN_FONT_STRIKEOUT, + LFUN_FONT_CROSSOUT, // uwestoehr 20170402 LFUN_FONT_UNDERUNDERLINE, // 335 LFUN_FONT_UNDERWAVE, After this addition the comments "// 335" etc. are no longer in sync with the enum value, I fear.
Re: [LyX/master] Add support to cross out characters
Le 12/04/2017 à 00:45, Uwe Stöhr a écrit : So why should I use an empty length as default? It is a concept I introduced to clean-up odditieds in the InsetBox code. Assume that you want to indicate "I do not have a width". It looks reasonable to indicate this by the value "". And instead of looking inside the Length object to know whether it is default, you can use Length::empty(), which is different from Length==0. Where do you see "-9.99col%" in my commits? You confused me. I was wrong, it was -999% actually. From your commit 22ad7e43: + // "-999col%" is the code for no width + if ((params.width).asString() == "-999col%") + widthCB->setCheckState(Qt::Unchecked); I hope that you can see how using such an arbitrary value as default is not as good as something that says "Hi, I am a llength and I do know that I am the default value, because I am empty". JMarc
Re: [LyX/master] Add support to cross out characters
On Wed, Apr 12, 2017 at 10:04:03PM +0200, Guillaume MM wrote: > Le 11/04/2017 à 10:04, Jean-Marc Lasgouttes a écrit : > > Le 11/04/2017 à 09:45, Guenter Milde a écrit : > > > The Python convention is to leave out "== true" while in C++ this may be > > > required. (Python auto-converts any value to a Boolean if required in an > > > "if" clause.) > > > > I do not see any reason to keep == true in C++ either. > > > > As Günter said this can be necessary if the class does not define > operator(bool). Before C++11, operator bool() could not be made explicit > and therefore defining operator bool() was discouraged. But there is no > longer any reason to define operator==(bool) instead of operator bool() > now that it can be made explicit. Thanks for this explanation. > But this issue will not arise with the LyX source since all occurrences > of "x == true" involve a boolean according to a quick check (this can > probably happen to anybody at the end of a long day...). Good to know. If no one does it before 2.4 cycle begins, I'll do it. Scott signature.asc Description: PGP signature
Re: [LyX/master] Add support to cross out characters
On Tue, Apr 11, 2017 at 07:45:17AM +, Guenter Milde wrote: > Please change the instances in Python, not in C++. In Python, this is > save and can be done for 2.3dev and even backported. If you would like to do this for current master, go ahead. Otherwise I will do it at the beginning of the 2.4 cycle. Scott signature.asc Description: PGP signature
Re: [LyX/master] Add support to cross out characters
El 12.04.2017 a las 11:08, Guenter Milde escribió: 30 pt is not always the default size: Yes this was my big mistake. I even described this for years in the math manual. I fixed this now in the code and the docs. regards Uwe
Re: [LyX/master] Add support to cross out characters
Le 11/04/2017 à 10:04, Jean-Marc Lasgouttes a écrit : Le 11/04/2017 à 09:45, Guenter Milde a écrit : The Python convention is to leave out "== true" while in C++ this may be required. (Python auto-converts any value to a Boolean if required in an "if" clause.) I do not see any reason to keep == true in C++ either. As Günter said this can be necessary if the class does not define operator(bool). Before C++11, operator bool() could not be made explicit and therefore defining operator bool() was discouraged. But there is no longer any reason to define operator==(bool) instead of operator bool() now that it can be made explicit. But this issue will not arise with the LyX source since all occurrences of "x == true" involve a boolean according to a quick check (this can probably happen to anybody at the end of a long day...). Amusingly, there are no occurrences of "== false".
Re: [LyX/master] Add support to cross out characters
On 2017-04-11, Uwe Stöhr wrote: > El 11.04.2017 a las 10:15, Jean-Marc Lasgouttes escribió: > Why are the 30pt a problem? This is by design. 30pt is the default size. 30 pt is not always the default size: fleqn is a standard LaTeX option defined in `fleqn.clo' with \newdimen\mathindent \AtEndOfClass{\mathindent\leftmargini} i.e. by default \mathindent is \leftmargini - the actual value depends on the documentclass, options, loaded packages, and standard font size. E.g. the standard article class defines: \if@twocolumn \setlength\leftmargini {2em} \else \setlength\leftmargini {2.5em} \fi BTW: in contrast to the statement in https://www.quora.com/LaTex-How-do-I-get-my-equations-to-be-left-aligned-instead-of-centered-when-using-the-article-document-class the fleqn option is not "of the amsmath package". However, with amsmath, \mathindent defaults to \leftmargini minus\leftmargini. It may shrink to zero if this prevents overfull lines with wide equations. > So if you just use fleqn as document class option you get 30pt > \mathindent. You *may* get 30pt under certain circumstances (e.g. article, one column, 12pt font size), but not even with the LyX default template (10pt font size). > Therefore I designed it so that you get the default value > as default when using the indent option in LyX. > So why should I use an empty length as default? Two important reasons: a) The default is not a fixed length. With your current code, a user trying to force 30pt may get a nasty surprise if changing the font size. b) If LyX does not write something to the latex file, we use the GUI-label "Default". See, e.g., Document>Settings>Text Layout>Paragraph Separation: [*] Indentation:[Default]# or [Custom] [ ] [bp] With the GUI saying [Default], the user knows that LyX does not write customization into the preamble and she is free to customize the setting in question in the LaTeX preamble. This is, e.g., the standard way to write advanced font selecting commands. So, the GUI could be modelled on the Paragraph Separation entry, e.g., [*] Align Equations. Indentation [Default] [ ][em] ... >> The rest of my remarks are not this important, but ignoring them will >> make me angry. Your choice. > Why are you angry? What do you refer to? I assume that this relates to the naming of the variables. The fleqn option is not about *indenting* display formulas, but about alignment. This should be reflected in both, GUI label and internal variable names. ... >>> You mean that formulas are now also indented within LyX. I indeed never >>> thought about this. (I simply use fleqn for so long that I did not miss >>> the on-screen representation.) I'll have a look but. Actually, without this feedback, I would prefer to leave fleqn a custom document option without a special input box. With equations aligning also in the GUI, I see the actual user benefit and look forward to see this in LyX (be it under Document>Settings>Text or Document>Settings>Math). Günter
Re: [LyX/master] Add support to cross out characters
On Tuesday, 11 April 2017 09.04.59 WEST Jean-Marc Lasgouttes wrote: > I do not see any reason to keep == true in C++ either. > > JMarc I agree that the " == true" is a non-idiomatic expression both for c++ and for python. PS: I am aware that the literal is True in python but the idea is precisely the same. -- José Abílio
Re: [LyX/master] Add support to cross out characters
El 11.04.2017 a las 10:15, Jean-Marc Lasgouttes escribió: But to be clear with you, if the hardcoded 30pt length stays, I will probably ask for reverting the patch. An hint: what you need to use is an empty length for default. Empty length is what I implemented for you to get rid of some ugly "-9.99col%" hardcoded value. If you have problem with understanding what is needed, ask me for further guidance. I appreciate your comments but I don't like to guess what you might mean or want. Why are the 30pt a problem? This is by design. 30pt is the default size. So if you just use fleqn as document class option you get 30pt \mathindent. Therefore I designed it so that you get the default value as default when using the indent option in LyX. So why should I use an empty length as default? Where do you see "-9.99col%" in my commits? You confused me. The rest of my remarks are not this important, but ignoring them will make me angry. Your choice. Why are you angry? What do you refer to? I am a bit lost. I answered to all your mails. If I missed one then please send these important ones also to my mail as CC. This assures that I will read them. (I have no time to read every evening all mailing list posts. I have a quick look what belongs to me and then reply.) You mean that formulas are now also indented within LyX. I indeed never thought about this. (I simply use fleqn for so long that I did not miss the on-screen representation.) I'll have a look but. I can take care of this part. OK, nevertheless I want to learn something. regards Uwe
Re: [LyX/master] Add support to cross out characters
Le 10/04/2017 à 23:20, Uwe Stöhr a écrit : Thanks. It works better but still the number of strokes depends on the zoom level. For example This is \xout{xout text}. gives me 10 or 11 strokes (slashes) depending on the zoom level. I do not think this is a problem (rounding effect). I would not be surprised to see the same in LaTeX when changing font size. Hmm, I did not design ugly screen output. Here it was an acceptable solution. I did not see the problem of Scott. Of course for Scott it was then indeed ugly. I trust that you did not design to be ugly. I just wanted to make clear my point that when one uses hard coded pixel values (and, yes, we still have a lot of these that should be taken care of), one is designing for ugly implicitly. Now, what I would like to see is some action on the lefteqn patch ;) What exactly? I added now a tooltip that I forgot ;-) I posted a code review, I would have expected an answer, even "I don't care". But to be clear with you, if the hardcoded 30pt length stays, I will probably ask for reverting the patch. An hint: what you need to use is an empty length for default. Empty length is what I implemented for you to get rid of some ugly "-9.99col%" hardcoded value. If you have problem with understanding what is needed, ask me for further guidance. The rest of my remarks are not this important, but ignoring them will make me angry. Your choice. You mean that formulas are now also indented within LyX. I indeed never thought about this. (I simply use fleqn for so long that I did not miss the on-screen representation.) I'll have a look but. I can take care of this part. JMarc
Re: [LyX/master] Add support to cross out characters
Le 11/04/2017 à 09:45, Guenter Milde a écrit : The Python convention is to leave out "== true" while in C++ this may be required. (Python auto-converts any value to a Boolean if required in an "if" clause.) I do not see any reason to keep == true in C++ either. JMarc
Re: [LyX/master] Add support to cross out characters
On 2017-04-11, Scott Kostyshak wrote: > On Thu, Apr 06, 2017 at 09:41:57AM +0100, José Abílio Matos wrote: >> On Thursday, 6 April 2017 02.56.51 WEST Scott Kostyshak wrote: >> > I see it's used in other places in lyx2lyx (grep for '== True'), so >> > perhaps this is convention in Python? >> Nope. >> The convention is the former: >> if changed: >> ... > I was going to make this change, but then I checked more globally and > there are instances of the "== true" in our C++ code. The Python convention is to leave out "== true" while in C++ this may be required. (Python auto-converts any value to a Boolean if required in an "if" clause.) > If someone wants me to change this for the instances in our C++ and our > Python code, I will put this on my TODO list after the release of 2.3.0 > (we might as well make this change at the beginning of a cycle). > Otherwise, I will forget about it. Please change the instances in Python, not in C++. In Python, this is save and can be done for 2.3dev and even backported. Günter
Re: [LyX/master] Add support to cross out characters
On Thu, Apr 06, 2017 at 09:41:57AM +0100, José Abílio Matos wrote: > On Thursday, 6 April 2017 02.56.51 WEST Scott Kostyshak wrote: > > I see it's used in other places in lyx2lyx (grep for '== True'), so > > perhaps this is convention in Python? > > Nope. > > The convention is the former: > > if changed: > ... I was going to make this change, but then I checked more globally and there are instances of the "== true" in our C++ code. If someone wants me to change this for the instances in our C++ and our Python code, I will put this on my TODO list after the release of 2.3.0 (we might as well make this change at the beginning of a cycle). Otherwise, I will forget about it. To see instances in other parts of the code, run git grep -i "== true" Scott signature.asc Description: PGP signature
Re: [LyX/master] Add support to cross out characters
On Mon, Apr 10, 2017 at 11:20:51PM +0200, Uwe Stöhr wrote: > El 10.04.2017 a las 10:43, Jean-Marc Lasgouttes escribió: > > > > I have not heard about this rule. > > > > This is why there is the word "propose" in the sentence above. > > OK. Nevertheless I support this rule. Btw. where can I find accepted rules? The only place I know is Development.lyx. Scott signature.asc Description: PGP signature
Re: [LyX/master] Add support to cross out characters
El 10.04.2017 a las 23:20, Uwe Stöhr escribió: You mean that formulas are now also indented within LyX. I'll have a look but. I had a look but failed as often: I cannot find a start point where displayed formulas are painted. I often have to stop at this point. LyX needs like a sitemap where what is done. In this case I know where the different math features are painted but not where the math inset itself is painted. regards Uwe
Re: [LyX/master] Add support to cross out characters
El 10.04.2017 a las 10:43, Jean-Marc Lasgouttes escribió: I have not heard about this rule. This is why there is the word "propose" in the sentence above. OK. Nevertheless I support this rule. Btw. where can I find accepted rules? I could not find a better solution that I proposed. When zooming out a lot one got no stroke at all. I implemented this for you now at 94114fd1. It is even a little bit shorter than the original code, I do not think that the price to pay was so high for something correct. Thanks. It works better but still the number of strokes depends on the zoom level. For example This is \xout{xout text}. gives me 10 or 11 strokes (slashes) depending on the zoom level. But more important, the problem reported by Scott is gone. WYSIWYM is not about "I have the right to give an ugly screen output", it is about having a visually pleasant output that tells you what your output in a meaningful way. The only difference with WYSIWYG is that some things (labels, footnotes, line breaks) are not represented visually, but semantically. Hmm, I did not design ugly screen output. Here it was an acceptable solution. I did not see the problem of Scott. Of course for Scott it was then indeed ugly. So, what I mean is that mimicking LaTeX is not a requirement, it is a trick to help you. OK, I understand. Now, what I would like to see is some action on the lefteqn patch ;) What exactly? I added now a tooltip that I forgot ;-) You mean that formulas are now also indented within LyX. I indeed never thought about this. (I simply use fleqn for so long that I did not miss the on-screen representation.) I'll have a look but. regards Uwe
Re: [LyX/master] Add support to cross out characters
Le 10/04/2017 à 01:00, Uwe Stöhr a écrit : El 06.04.2017 a las 11:10, Jean-Marc Lasgouttes escribió: That is not how it works. Actually, I propose to add a rule to our coding rules that says that no code which does not take in account zoom and DPI when drawing should be accepted (with the usual exceptions, of course). I have not heard about this rule. This is why there is the word "propose" in the sentence above. I also sent the patch to the list for some days before I put it in. I haven't got this info from you. This is why I did not complain about that. But it is not because a patch is in that it is immune of of code review (especially when there are user-visible issues). I don't get it. Seems that I have been away for too long. At first, yes I can read TeX code, yes I experimented with painting including the zoom. I could not find a better solution that I proposed. When zooming out a lot one got no stroke at all. I implemented this for you now at 94114fd1. It is even a little bit shorter than the original code, I do not think that the price to pay was so high for something correct. However, I still think that we should not leave the WYSIWYM track in favor of WYSIWYG. The number of strokes is not important within LyX. The user should see that there will be strokes and that is it. That is the WYSIWYM concept. WYSIWYM is not about "I have the right to give an ugly screen output", it is about having a visually pleasant output that tells you what your output in a meaningful way. The only difference with WYSIWYG is that some things (labels, footnotes, line breaks) are not represented visually, but semantically. As I understand you, you want me to use the currently selected screen font to draw a '/' character over the text that is repeated by 0.35em (in pixels). That is quite complicated (at least for me) and I don't see the benefit. That would be WYSIWYG. Is this really necessary? You got it wrong. What I say is a _requirement_ is to have a good output at a high zoom level (this is a good way to see what HiDPI users will see). Now, how do I find a nice way to have good output at high DPI? Wait, LaTeX does output at high DPI !! Let's see what it does and do the same if it is not too complicated! So, what I mean is that mimicking LaTeX is not a requirement, it is a trick to help you. And don't come tell me that the new code is more complicated than the old one, because it is not. Now, what I would like to see is some action on the lefteqn patch ;) JMarc
Re: [LyX/master] Add support to cross out characters
On Mon, Apr 10, 2017 at 01:00:07AM +0200, Uwe Stöhr wrote: > However, I still think that we should not leave the WYSIWYM track in favor > of WYSIWYG. The number of strokes is not important within LyX. The user > should see that there will be strokes and that is it. That's exactly the problem: For certain zoom levels, I see strokes and that is it. I see no text behind the strokes. See the attached screenshot. Do you see the problem that I'm referring to? Scott signature.asc Description: PGP signature
Re: [LyX/master] Add support to cross out characters
El 06.04.2017 a las 11:10, Jean-Marc Lasgouttes escribió: That is not how it works. Actually, I propose to add a rule to our coding rules that says that no code which does not take in account zoom and DPI when drawing should be accepted (with the usual exceptions, of course). I have not heard about this rule. I also sent the patch to the list for some days before I put it in. I haven't got this info from you. You search for ulem.sty, which is full of horrible code. Then you search in there for the definition of \xout, which is admittedly still weird, but simpler: \def\xout{\bgroup \markoverwith{\hbox to.35em{\hss/\hss}}\ULon} What does it tell us? That the strike out is obtained with a `/' character, and that it is spaced with 0.35em. This should be enough to make an easy and good lookalike screen representation. I don't get it. Seems that I have been away for too long. At first, yes I can read TeX code, yes I experimented with painting including the zoom. I could not find a better solution that I proposed. When zooming out a lot one got no stroke at all. However, I still think that we should not leave the WYSIWYM track in favor of WYSIWYG. The number of strokes is not important within LyX. The user should see that there will be strokes and that is it. That is the WYSIWYM concept. As I understand you, you want me to use the currently selected screen font to draw a '/' character over the text that is repeated by 0.35em (in pixels). That is quite complicated (at least for me) and I don't see the benefit. That would be WYSIWYG. Is this really necessary? thanks and regards Uwe
Re: [LyX/master] Add support to cross out characters
Le 06/04/2017 à 10:59, "Uwe Stöhr" a écrit : If you find a better solution to paint the strokes, please improve my drawing routine accordingly. That is not how it works. Actually, I propose to add a rule to our coding rules that says that no code which does not take in account zoom and DPI when drawing should be accepted (with the usual exceptions, of course). It is not as if we were still in 1995, we have retina screens now. A lot of work has been done recently to take dpi/zoom into account, we do not want that to degrade with new code. As always, the right thing to do is "use the source, Luke". You search for ulem.sty, which is full of horrible code. Then you search in there for the definition of \xout, which is admittedly still weird, but simpler: \def\xout{\bgroup \markoverwith{\hbox to.35em{\hss/\hss}}\ULon} What does it tell us? That the strike out is obtained with a `/' character, and that it is spaced with 0.35em. This should be enough to make an easy and good lookalike screen representation. Is it enough information for you? JMarc
Re: [LyX/master] Add support to cross out characters
Von: "Scott Kostyshak" > Uwe, I've tested but there are a lot of crosses. For example, see the attached screenshot. It seems the number of crosses depends on the level of zoom, which I don't think makes sense. Also, if you change the font size, the number of crosses in the PDF output does not change. It is impossible to draw in every case the same number of strokes. I experimented a bit with including the zoom level but then one could get no stroke for low zooms. I think my solution is a good compromise. LyX is WYSISYM not WYSIWYG. In the output ulem draws as many strokes that will fit to the formatting length. But this length depends of course on the font, the document-wide font size (could also be different for each document class) and the surrounding local font size commands . If you find a better solution to paint the strokes, please improve my drawing routine accordingly. >> + if changed == True: > > Also (comment for anyone), why not just the following? > > if changed: I don't know. I just stole some code from existing lyx2lyx routines to save time. regards Uwe
Re: [LyX/master] Add support to cross out characters
On Thursday, 6 April 2017 02.56.51 WEST Scott Kostyshak wrote: > I see it's used in other places in lyx2lyx (grep for '== True'), so > perhaps this is convention in Python? Nope. The convention is the former: if changed: ... -- José Abílio
Re: [LyX/master] Add support to cross out characters
On Wed, Apr 05, 2017 at 12:01:26AM +0200, Uwe Stöhr wrote: > commit e575e7eebd32d687f3e23be0eeca185adb3b341b > Author: Uwe Stöhr > Date: Wed Apr 5 00:01:19 2017 +0200 > > Add support to cross out characters > > - adds support for the command \xout of the LateX package ulem > - fileformat change > --- Uwe, I've tested but there are a lot of crosses. For example, see the attached screenshot. It seems the number of crosses depends on the level of zoom, which I don't think makes sense. Also, if you change the font size, the number of crosses in the PDF output does not change. > + if changed == True: Also (comment for anyone), why not just the following? if changed: I see it's used in other places in lyx2lyx (grep for '== True'), so perhaps this is convention in Python? Scott signature.asc Description: PGP signature