It is currently April 25th, 2024, 8:19 am

Inline option issue

Get help with creating, editing & fixing problems with skins
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Inline option issue

Post by pul53dr1v3r »

jsmorley wrote: October 26th, 2019, 1:46 pm You just need to \escape the | pipe character(s) as that character is reserved in regular expression and means "OR".

Code: Select all

InlinePattern=^(.*)\|
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern2=.*\|(.*)#deg#$
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
While it won't hurt, the trailing $ is really not needed, as it will stop capturing when it hits #deg#. To be honest, the leading ^ is also not really needed, as it will always start at the beginning of the string. It both cases though, it does no harm, and may make it a bit clearer as to the intent.

The difference between * (zero or more) and + (one or more) is not really important in this case, although I tend to use + when (capturing) in InlinePattern, as the logic of "color this red if there are none of them" offends me at some level...
Ok, thx a lot for the help. At the end, it turned out as an easy issue, though it looked kind of serious in the beginning, even as a bug, at elast for me.
:bow:
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Inline option issue

Post by jsmorley »

Glad to help. Regular Expression is VERY powerful and useful, but far from the easiest or most intuitive thing to use.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Inline option issue

Post by pul53dr1v3r »

Code: Select all

InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern=([-]*[\d]+)
InlineSetting2=Color | 255,51,51,#colorText2Alpha#
InlinePattern2=([-]*[\d]+)
Text=%1 %2#deg#
what would be a simpler solution for this occurrence, when there is no any (visible) sign between the two values, %1 and %2 and what if there is not the space at all? The values can be negative as well. Tightly related with the previous posts.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Inline option issue

Post by balala »

Pul53dr1v3r wrote: January 19th, 2020, 8:31 pm what would be a simpler solution for this occurrence, when there is no any (visible) sign between the two values, %1 and %2 and what if there is not the space at all? The values can be negative as well. Tightly related with the previous posts.
What would you want? I didn't understand, but supposing you'd like to color the second numeric value, try this: InlinePattern=^-?[\d]+\s*(-?[\d]+)#deg#$.
Sorry if I misunderstood you.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Inline option issue

Post by pul53dr1v3r »

balala wrote: January 19th, 2020, 9:36 pm What would you want? I didn't understand, but supposing you'd like to color the second numeric value, try this: InlinePattern=^-?[\d]+\s*(-?[\d]+)#deg#$.
Sorry if I misunderstood you.
no, it's my mistake. i didn't explain well what i want. So, the i'd like to maintain the same colors using a simple way like Morle's provided for the previous case,

Code: Select all

InlinePattern=^(.*)\|
InlineSetting=Color | 102,178,255,#colorText2Alpha#
InlinePattern2=.*\|(.*)#deg#$
InlineSetting2=Color | 255,51,51,#colorText2Alpha#


but now without the vertical bar sign "|", but with simple blank space.

To be honest, i don't know how to determine the end of the 1st InlinePattern and the begining of the second... It must be very easy.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Inline option issue

Post by balala »

Pul53dr1v3r wrote: January 19th, 2020, 11:27 pm To be honest, i don't know how to determine the end of the 1st InlinePattern and the begining of the second... It must be very easy.
Post please the code of the measure which has the posted InlineSetting / InliniPattern options set on.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Inline option issue

Post by pul53dr1v3r »

balala wrote: January 20th, 2020, 9:55 am Post please the code of the measure which has the posted InlineSetting / InliniPattern options set on.

Code: Select all

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

[Variables]
color1=255,0,0
color2=0,0,255

[styleGlobal]
FontColor=255,255,255

[Measure1]
Measure=Calc
Formula=15

[Measure2]
Measure=Calc
Formula=-10

[Meter]
Meter=String
MeterStyle=styleGlobal
MeasureName=Measure1
MeasureName2=Measure2
InlineSetting=Color | #color1#
InlinePattern=
InlineSetting2=Color | #color2#
InlinePattern2=
Text=%1 %2°
here is the whole test code. so the first character must have color1, the second color2 and the "°" is untouched.
This mr. Morley's advice might be helpful not to make a complicated formula: link
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Inline option issue

Post by balala »

Pul53dr1v3r wrote: January 20th, 2020, 3:35 pm here is the whole test code. so the first character must have color1, the second color2 and the "°" is untouched.
Try this:

Code: Select all

[Meter]
...
InlineSetting=Color | #color1#
InlinePattern=^(-?[\d]+)\s*-?[\d]+[\x00B0]$
InlineSetting2=Color | #color2#
InlinePattern2=^-?[\d]+\s*(-?[\d]+)[\x00B0]$
Note that I replaced the ° character with [\x00B0]. It is much better, here you can find out why.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Inline option issue

Post by pul53dr1v3r »

ok, not the simplest but thx anyway.
i found that this one gives the same result, but not quite sure the result will be the same in all the possible cases:

Code: Select all

InlineSetting=Color | #color1#
InlinePattern=^(.+)\s
InlineSetting2=Color | #color2#
InlinePattern2=\s(.+)[\x00B0]
And what in case where any of the values can be either positive or negative, numeric and non-numeric but without the whitespace (\s).

Code: Select all

Text=%1%2[\x00B0]
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Inline option issue

Post by balala »

pul53dr1v3r wrote: January 21st, 2020, 9:13 pm i found that this one gives the same result, but not quite sure the result will be the same in all the possible cases:

Code: Select all

InlineSetting=Color | #color1#
InlinePattern=^(.+)\s
InlineSetting2=Color | #color2#
InlinePattern2=\s(.+)[\x00B0]
Probably good, as well. The InlineSetting colors with #color1# everything from the beginning to the first space (defined by the \s symbol). InlineSetting2 colors with #color2# the string placed between the first space (\s) and the degree character ([\x00B0]).
What is different is that if there are no numbers but strings (replacing for instance the Calc measure with String ones), your solution works as well, while mine works only for numbers.
pul53dr1v3r wrote: January 21st, 2020, 9:13 pm And what in case where any of the values can be either positive or negative, numeric and non-numeric but without the whitespace (\s).
If there is no space, what do you use between the two temperature values? I'm not sure I follow.