It is currently March 28th, 2024, 7:49 pm

[QUESTION] Trimming Trailing Spaces

Report bugs with the Rainmeter application and suggest features.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

[QUESTION] Trimming Trailing Spaces

Post by Yincognito »

Sample Skin:

Code: Select all

[Variables]

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

---Meters---

[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTest
Text="Test = abc   "
DynamicVariables=1
Preview:
Trimmed Trailing Spaces.jpg
As you can see, Rainmeter trims the trailing spaces from end of the meter / skin.
On the other hand, if one adds another character, even a zero-width space character like [\x200B] at the end of the Text option's string, the meter / skin won't trim the "trailing" spaces anymore (well, technically they're not trailing in this case, since they precede the [\x200B] character).

Preview:
Untrimmed Trailing Spaces.jpg
Now, while this couldn't exactly be classified as a "bug", but rather as a "feature" (it should be mentioned in the manual though, as a small note), I'm interested in something else: would this "feature" be persistent in future Rainmeter versions, or it could be subject to change depending on, say, an actual bug report? I'm asking because I think about using this "feature" in my skins, in order to avoid creating duplicated variables just because of a few trailing space difference between some similar strings used in different contexts, and I need to know if I can rely on this behavior in the future or there is a possibility of another Rainmeter version breaking this behavior (and hence, my "trick").
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [QUESTION] Trimming Trailing Spaces

Post by jsmorley »

Yincognito wrote: April 25th, 2020, 1:36 pm Sample Skin:

Code: Select all

[Variables]

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

---Meters---

[MeterTest]
Meter=STRING
X=0
Y=0
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=MeasureTest
Text="Test = abc   "
DynamicVariables=1
Preview:
Trimmed Trailing Spaces.jpg
As you can see, Rainmeter trims the trailing spaces from end of the meter / skin.
On the other hand, if one adds another character, even a zero-width space character like [\x200B] at the end of the Text option's string, the meter / skin won't trim the "trailing" spaces anymore (well, technically they're not trailing in this case, since they precede the [\x200B] character).
Preview:
Untrimmed Trailing Spaces.jpg
Now, while this couldn't exactly be classified as a "bug", but rather as a "feature" (it should be mentioned in the manual though, as a small note), I'm interested in something else: would this "feature" be persistent in future Rainmeter versions, or it could be subject to change depending on, say, an actual bug report? I'm asking because I think about using this "feature" in my skins, in order to avoid creating duplicated variables just because of a few trailing space difference between some similar strings used in different contexts, and I need to know if I can rely on this behavior in the future or there is a possibility of another Rainmeter version breaking this behavior (and hence, my "trick").

This won't change. Rainmeter will always trim trailing spaces from an option value, but won't trim characters that are not an ASCII 32 or a real "space".

Keep in mind that trying to trick it with something like:

Text="Hello World "

Won't work, as the starting and ending quotes are simply ignored and thrown away, and the spaces will still be trimmed.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [QUESTION] Trimming Trailing Spaces

Post by Yincognito »

jsmorley wrote: April 25th, 2020, 1:38 pm This won't change. Rainmeter will always trim trailing spaces from an option value, but won't trim characters that are not an ASCII 32 or a real "space".

Keep in mind that trying to trick it with something like:

Text="Hello World "

Won't work, as the starting and ending quotes are simply ignored and thrown away, and the spaces will still be trimmed.
Ok, thanks for the confirmation. No, the trick is simply using in one instance a meter with just this type of string, and in the other instance a meter that has other strings following the "trailing spaces", something along the lines of:

Code: Select all

Text="Hello World       "
vs

Code: Select all

Text="Hello World       Hello Universe"
I want the first instance (right aligned) trimming the trailing spaces, and the second as it is - which is the current behavior, of course.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [QUESTION] Trimming Trailing Spaces

Post by jsmorley »

Yincognito wrote: April 25th, 2020, 1:55 pm Ok, thanks for the confirmation. No, the trick is simply using in one instance a meter with just this type of string, and in the other instance a meter that has other strings following the "trailing spaces", something along the lines of:

Code: Select all

Text="Hello World       "
vs

Code: Select all

Text="Hello World       Hello Universe"
I want the first instance (right aligned) trimming the trailing spaces, and the second as it is - which is the current behavior, of course.
Right.