Page 1 of 1

Re: InlinePattern now defaults to .*

Posted: February 16th, 2016, 5:36 pm
by jsmorley
We made a small change that makes the InlinePattern option of String meters to default to .*

This means that if you want the entire string to use the new inline options, you no longer need to define a pattern in your skins. The entire string will use the inline option.

So the following would now be valid:

Code: Select all

[SomeStringMeter]
...
InlineSetting=Weight | 900
InlineSetting2=Italic
InlineSetting3=Size | 15
This would make the entire string italic at font size 15 with a 900 bold value (assuming the font supports it, and if it doesn't, it will get as close to 900 as it can).

Here is documentation for the String meter's Inline Settings: https://docs.rainmeter.net/manual-beta/meters/string/inline/

In my view, this is an important change.

The reason is that as I see it, this entirely "deprecates" any need for the following options on String meters:

FontFace
FontSize
FontColor
StringStyle


The InlineSetting equivalents of these options are just as easy to use, and FAR, FAR more flexible and powerful.

The change to make the default for InlinePattern(N) be .* further makes this true, as you no longer have to specify a matching InlinePattern=.* in order to simply set the entire string to the desired option.

There is just no benefit to using:

StringStyle=Bold

When

InlineSetting=Weight | 600

is just as easy, and a hundred times more powerful, since you then have the entire range of weights the font supports available, and not just "Bold" or "Normal".

In addition, keep in mind that things like StringStyle can only have one option on a meter. You can use as many numbered InlineSetting options as you like, with the added benefit that if you DO use InlinePattern, you have complete control over what parts of the string get what format.

Re: InlinePattern now defaults to .*

Posted: February 16th, 2016, 9:35 pm
by FreeRaider
Since InlinePattern uses Perl Compatible Regular Expression (PCRE), would not it be better to use (.*) or ^(.*)$ as default? Honestly, .* reminds me "not capture anything".

Re: InlinePattern now defaults to .*

Posted: February 16th, 2016, 11:41 pm
by jsmorley
FreeRaider wrote:Since InlinePattern uses Perl Compatible Regular Expression (PCRE), would not it be better to use (.*) or ^(.*)$ as default? Honestly, .* reminds me "not capture anything".
Feel free to use InlineSetting=(.*) if you want, it is exactly the same as InliineSetting=.* ;-)
If (parentheses) are used to capture parts of the string, then that is what the setting will be applied to. If (parentheses) are not used, then the part(s) of the string that match the regular expression will be used.
While it is indeed still "off the shelf" PCRE with exactly the same usage and rules that PCRE has in WebParser, what InlineSetting does with the result is somewhat different.

The entire and only point of WebParser is "capturing". The entire and only point of inlinePattern is "matching".

In a sense the (capture groups) are used to "limit" what the format is applied to in the string. The entire string in inlinePattern must match, or if you like, be true. Things in parentheses (captures groups) can be used to identify a match in the context of a longer regular expression string. The ENTIRE regular expression must still "match" or be "true", or the entire setting will fail.

To repeat, the (capture groups) in InlinePattern are about "context".

Look at this example:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureOne]
Measure=String
String=The red, red robin

[MeterOne]
Meter=String
MeasureName=MeasureOne
FontSize=20
FontColor=0,0,0,255
SolidColor=240,240,240,255
Padding=5,5,5,5
AntiAlias=1
If we add an InlineSetting:

Code: Select all

InlineSetting=Color | 255,0,0,255
InlinePattern=red
That will change ANY instance of the word "red" in any order and in any context to the color red.
1.jpg
If we instead add...

Code: Select all

InlineSetting=Color | 255,0,0,255
InlinePattern=The red, (red) robin
That will change ONLY the occurrence of the word "red" in exactly this context (capture group) to the color red.
2.jpg
This InlineSetting:

Code: Select all

InlineSetting=Color | 255,0,0,255
InlinePattern=The red, (.*) robin
Will change any number of characters in exactly that context (capture group) to the color red.
4.jpg
This inlineSetting:

Code: Select all

InlineSetting=Color | 255,0,0,255
InlinePattern=The red, red robin
Will set the entire string to the color red, as the entire regular expression is matched.
5.jpg
So will this InlineSetting:

Code: Select all

InlineSetting=Color | 255,0,0,255
InlinePattern=(The red, red robin)
Its the same thing...
5.jpg
However this InlineSetting:

Code: Select all

InlineSetting=Color | 255,0,0,255
InlinePattern=The red, (red) cardinal
Will fail entirely. The match on the entire regular expression is NOT "true", and so no setting is applied.
3.jpg
In any case, .* is always a match on any string. (.*) is also always a match on any string. In either case, the match is "true", and the entire string will get the setting in question.

----------------------
Under the covers, what the new default setting for InlinePattern actually means is more like: InlinePattern=(?s)^.*$. That's not important though. Just that it means "the entire string value".