On top of UPPER, LOWER, PROPER, etc. how about also SENTENCE, OPPOSITE, and ALTERNATING?
Sentence = Sentence case
Opposite = oPOSSITE cASE
Alternating = aLtErNeTiNg CaSe
It is currently March 29th, 2024, 9:14 am
New String Case options?
-
- Posts: 264
- Joined: May 12th, 2019, 8:55 am
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: New String Case options?
I agree if this is possible. In some cases could be a useful possibility.Cariboudjan wrote: ↑December 6th, 2019, 10:54 pm On top of UPPER, LOWER, PROPER, etc. how about also SENTENCE, OPPOSITE, and ALTERNATING?
Sentence = Sentence case
Opposite = oPOSSITE cASE
Alternating = aLtErNeTiNg CaSe
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: New String Case options?
Sentence case you can get today with InlineSettings. I'm not opposed to adding that and the others to the StringCase option of the String meter, but I'm not sure how high a priority that would get. I would also note that Alternating would really need two variants...
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: New String Case options?
In the meantime, if you have a real need for this, Lua can do the job...
Skin:
StringCase.lua:
Skin:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
[Lua]
Measure=Script
ScriptFile=StringCase.lua
Disabled=1
[MeasureString]
Measure=String
String=Upper and Lower Case
[MeterString]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=[MeasureString]#CRLF#[&Lua:Opposite('[&MeasureString]')]#CRLF#[&Lua:AlternateL('[&MeasureString]')]#CRLF#[&Lua:AlternateU('[&MeasureString]')]
Code: Select all
function Opposite(inString)
outString = ''
for i = 1, string.len(inString) do
oneChar = string.sub(inString, i, i)
if oneChar == string.upper(oneChar) then
outString = outString..string.lower(oneChar)
else
outString = outString..string.upper(oneChar)
end
end
return outString
end
function AlternateL(inString)
outString = ''
altFlag = 0
for i = 1, string.len(inString) do
oneChar = string.sub(inString, i, i)
if altFlag == 0 then
outString = outString..string.lower(oneChar)
else
outString = outString..string.upper(oneChar)
end
if string.upper(oneChar) ~= string.lower(oneChar) then altFlag = 1-altFlag end
end
return outString
end
function AlternateU(inString)
outString = ''
altFlag = 0
for i = 1, string.len(inString) do
oneChar = string.sub(inString, i, i)
if altFlag == 0 then
outString = outString..string.upper(oneChar)
else
outString = outString..string.lower(oneChar)
end
if string.upper(oneChar) ~= string.lower(oneChar) then altFlag = 1-altFlag end
end
return outString
end
You do not have the required permissions to view the files attached to this post.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: New String Case options?
Lua definitely can , but it would be nice to not to have to use Lua. Many times would be much easier.
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: New String Case options?
Certainly...
Using Lua or InlineSetting does have some additional flexibility though. For instance, you could easily have it just make all instances of a particular character or a particular substring within the string change case, where the StringCase option is kinda all-or-nothing.
The real disadvantage with Lua for this is that the string.upper()/string.lower() functions only work on English ASCII characters (basically a-zA-Z). ö/Ö for instance won't work right. Verily, Lua was definitely born in, and lives in, an earlier age...
I really think that if there was going to be any change in how Rainmeter works, I would vote for adding the new variants to InlineSetting, in addition to, or perhaps even rather than, StringCase. StringCase feels very brute-force to me.
-
- Posts: 154
- Joined: May 14th, 2018, 4:46 pm
Re: New String Case options?
doN't fOrGET rAnDOm CAsE
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: New String Case options?
That's good as well, because with any of these no additional measures / meters are needed. Lua instead is requiring at least one such additional measure, plus a script file. I don't say can1t be done, however as I said, would be much easier with StringCase or InlineSetting.
Why?
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: New String Case options?
Simply because it must always act on the entire contents of the text being displayed in the meter. InlineSetting / InlinePattern is much more flexible about what text is impacted.
Code: Select all
[MeterString]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=i'm sentence case, i'm upper case
InlineSetting=Case | Sentence
InlinePattern=^(.*),
InlineSetting2=Case | Upper
InlinePattern2=, (.*)$
You do not have the required permissions to view the files attached to this post.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: New String Case options?
Yeah, right. Good point...