It is currently October 19th, 2020, 3:39 pm

New String Case options?

Report bugs with the Rainmeter application and suggest features.
User avatar
Cariboudjan
Posts: 98
Joined: May 12th, 2019, 8:55 am

New String Case options?

Post by Cariboudjan »

On top of UPPER, LOWER, PROPER, etc. how about also SENTENCE, OPPOSITE, and ALTERNATING?

Sentence = Sentence case
Opposite = oPOSSITE cASE
Alternating = aLtErNeTiNg CaSe
User avatar
balala
Rainmeter Sage
Posts: 11572
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: New String Case options?

Post by balala »

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
I agree if this is possible. In some cases could be a useful possibility. :thumbup:
User avatar
jsmorley
Developer
Posts: 21421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New String Case options?

Post by jsmorley »

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...
User avatar
jsmorley
Developer
Posts: 21421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New String Case options?

Post by jsmorley »

In the meantime, if you have a real need for this, Lua can do the job...

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]')]
StringCase.lua:

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

1.png
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 11572
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: New String Case options?

Post by balala »

jsmorley wrote: December 7th, 2019, 2:49 pm In the meantime, if you have a real need for this, Lua can do the job...
Lua definitely can :thumbup: , but it would be nice to not to have to use Lua. Many times would be much easier.
User avatar
jsmorley
Developer
Posts: 21421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New String Case options?

Post by jsmorley »

balala wrote: December 7th, 2019, 2:56 pm Lua definitely can :thumbup: , but it would be nice to not to have to use Lua. Many times would be much easier.
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.
oZone
Posts: 133
Joined: May 14th, 2018, 4:46 pm

Re: New String Case options?

Post by oZone »

doN't fOrGET rAnDOm CAsE :D
User avatar
balala
Rainmeter Sage
Posts: 11572
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: New String Case options?

Post by balala »

jsmorley wrote: December 7th, 2019, 2:57 pm 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.
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.
jsmorley wrote: December 7th, 2019, 2:57 pm StringCase feels very brute-force to me.
Why?
User avatar
jsmorley
Developer
Posts: 21421
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New String Case options?

Post by jsmorley »

balala wrote: December 7th, 2019, 6:52 pm Why?
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=, (.*)$


1.png
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 11572
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: New String Case options?

Post by balala »

jsmorley wrote: December 7th, 2019, 6:57 pm 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.
Yeah, right. Good point...