If anybody received my previous empty message, I'm sorry. I messed up
with my mail client ending up sending the message before writing it...
Fortunately, it seems to have been stopped at some point, so maybe
nobody got it.
Le 10/07/2012 10:20, Neil Hodgson a �crit :
Trying to fix this I ended up writing a new and a little more complete
lexer. It behaves like the old one but follows a little better the
language like defined by Gettext[1] and as understood by Gettext's
`msgftm` tool; and provides a few more styles [2].
However, I'm not 100% sure about how I dealt with what used the static
variable before. The thing is that there are 3 string styles, and the
chosen one depends on what precedes it, which can be lines before, and
moreover that is separated by the default style. For example, given the
code below:
1. msgid "foo"
2. "foo string continues"
3. msgstr "bar"
4.
5. "bar string continues"
the style for the strings foo and bar are different, and especially line
4 should be styled with no (default) style. This leads to two problems:
1) to style line 2 and 5, I need to look behind and find what is the
previous non-default style.
2) doing so will break when changing e.g. "msgstr" to "msgid" since line
5 won't be restyled (but it now should use another style).
So, what I finally did is adding 3 "default" styles (
SCE_PO_MSGCTXT_TEXT_DEFAULT, SCE_PO_MSGID_TEXT_DEFAULT and
SCE_PO_MSGSTR_TEXT_DEFAULT) that are used in place of the default styles
when the various string types are expected, using those to remember how
a string should be styled here. This removes the need to look behind,
and fixes the restyling issue at the same time.
Again, I'm not sure it's the right approach, but I don't see another way
of keeping the information through many lines without styling everything
with the string style -- which would not be really great either. I'm
open to comments :)
Attached are two patches, one is the new lexer patch, the other adds the
PO properties to SciTE (which didn't seem to exist at all yet).
Thanks for reading,
Colomban
[1]
https://www.gnu.org/software/gettext/manual/gettext.html#PO-Files
[2] SCE_PO_PROGRAMMER_COMMENT, SCE_PO_REFERENCE, SCE_PO_FLAGS,
SCE_PO_MSGID_TEXT_EOL, SCE_PO_MSGSTR_TEXT_EOL, SCE_PO_MSGCTXT_TEXT_EOL,
SCE_PO_ERROR and the three SCE_PO_MSGID_TEXT_DEFAULT,
SCE_PO_MSGSTR_TEXT_DEFAULT and SCE_PO_MSGCTXT_TEXT_DEFAULT.