On 04/09/2010 03:06 PM, Uwe Stöhr wrote:
rgheck schrieb:
The display fonts for notes, etc, are actually controlled by the InsetLayouts associated with them. At the moment, however, the declared color has to be one of the color names known to LyX. A simple idea would be to allow this:
    Color mynewcolor #CF0209
in the layout files. Then you could do:
    InsetLayout Note:Greyedout
        Font
            Color mynewcolor
        EndFont
    End
to get the new display color. And then display could be controlled by layout, as it should be.

That is basically the same concept like the one proposed by Pavel. However, I wasn't able to work on as I doesn't know the InsetLayout code yet. I would be happy if you could point me to the code that needs to be changed or even provide a patch.

I'm going to try to get to this shortly. But if you want to have a go, InsetLayout doesn't need to be touched at all. The code would go into TextClass.cpp and be kind of like the readCiteFormat() code, except that, instead of creating a new citation format, it would enter a new color name into the ColorSet. This can probably be done just by calling: lcolor.setColor(lyxname, hexstring). The thing to check is that this doesn't mess up the color setting stuff in the preferences. I.e., that the new color doesn't appear there. And, of course, that it doesn't mess anything else up.

(For now I cannot do anything because my PC crashed yesterday and the repair takes about a week :-( So I will also not be very responsive the next days.)

Not as bad as Kornel's broken arm, but still pretty bad!

Concerning http://www.lyx.org/trac/changeset/34103 I know that this was a hack as I just stated, but why was it dangerous?

I can't point to a specific reason, other than that invoking the dispatch mechanism while we are in the process of trying to open a buffer seems dangerous. It just "feels wrong". LyX is in a delicate state then, with things half created, and the dispatch mechanism has all kinds of side effects. The sort of call you were making might trigger a screen redraw, for example. After all, you've changed one of the display colors. But the buffer isn't even loaded yet. So what is going to happen? I don't actually know, but it's pure luck if it isn't bad.

As a rule, one shouldn't dispatch except when it's obviously OK to do so: When we're responding to various kinds of events. Then it is good to use the dispatch mechanism, even when you could bypass it with a little cleverness. This is because dispatch() takes care of figuring out whether we need an update, etc, etc.

Richard

Reply via email to