It is currently July 12th, 2020, 2:19 am

Continue Long Statements on Multiple Lines

Report bugs with the Rainmeter application and suggest features.
User avatar
exper1mental
Posts: 284
Joined: January 9th, 2013, 7:52 pm
Location: Clemson University

Continue Long Statements on Multiple Lines

Post by exper1mental »

Hi guys!

I'm on break from college so I've been playing around in Rainmeter and working on some projects. In the process of this, I noticed a small but powerful feature of many programming languages was missing: the ability to continue long segments of code on multiple lines. In Python we have \ and the MATLAB we have .... It would be awesome if we could have something like this for Rainmeter.

For example:

Code: Select all

LeftMouseUpAction=[!CommandMeasure Transition "Fade('#CURRENTSECTION#', '[CalcAccentColorAlpha]', 'ButtonAlpha6', 3)"][!ShowMeterGroup VolumePopButtons][!CommandMeasure Transition "Fade('VolumeAPop', #AccentColorAlpha#, 'VolumePopAAlpha', 6)"][!CommandMeasure Transition "Fade('VolumeBPop', #BackgroundColorAlpha#, 'VolumePopBAlpha', 6)"][!CommandMeasure Transition "Fade('VolumePPop', #PrimaryColorAlpha#, 'VolumePopPAlpha', 6)"][!CommandMeasure Transition "Fade('VolumeSPop', #SecondaryColorAlpha#, 'VolumePopSAlpha', 6)"][!CommandMeasure Transition "Fade('VolumeBar', #AccentColorAlpha#, 'VolumeBarAlpha', 8)"][!HideMeterGroup BGGroup][!Redraw]
Could become:

Code: Select all

LeftMouseUpAction=[!CommandMeasure Transition "Fade('#CURRENTSECTION#', '[CalcAccentColorAlpha]', 'ButtonAlpha6', 3)"]...
     [!ShowMeterGroup VolumePopButtons][!CommandMeasure Transition "Fade('VolumeAPop', #AccentColorAlpha#, 'VolumePopAAlpha', 6)"]...
     [!CommandMeasure Transition "Fade('VolumeBPop', #BackgroundColorAlpha#, 'VolumePopBAlpha', 6)"]...
     [!CommandMeasure Transition "Fade('VolumePPop', #PrimaryColorAlpha#, 'VolumePopPAlpha', 6)"]...
     [!CommandMeasure Transition "Fade('VolumeSPop', #SecondaryColorAlpha#, 'VolumePopSAlpha', 6)"]...
     [!CommandMeasure Transition "Fade('VolumeBar', #AccentColorAlpha#, 'VolumeBarAlpha', 8)"]...
     [!HideMeterGroup BGGroup][!Redraw]
This would make it much easier to read and work with long statements in Rainmeter. Let me know what you think!

Merry Christmas!


Sincerely,
Exper1mental
Image
User avatar
Brian
Developer
Posts: 2025
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Continue Long Statements on Multiple Lines

Post by Brian »

I believe this request has come up before (or at least I remember talking it over with the dev team in the past).

Traditional ini formatting does not allow for "multi-line" key=value pairs. While it might be possible to implement, it would require a significant rewrite to our ini parsing functions. We heavily rely on the winapi for these ini parsing functions, so I highly doubt we would go in this direction.

I think the best alternative is to use variables for long statements (usually bangs). You can even jump to lua if you are really desperate.

-Brian
User avatar
JelleDekkers
Posts: 58
Joined: September 27th, 2017, 6:32 pm

Re: Continue Long Statements on Multiple Lines

Post by JelleDekkers »

Just make your editor wrap the lines?
¯\_(ツ)_/¯
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4040
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Continue Long Statements on Multiple Lines

Post by eclectic-tech »

exper1mental wrote:
December 25th, 2019, 3:43 am
Hi guys!

I'm on break from college so I've been playing around in Rainmeter and working on some projects. In the process of this, I noticed a small but powerful feature of many programming languages was missing: the ability to continue long segments of code on multiple lines. In Python we have \ and the MATLAB we have .... It would be awesome if we could have something like this for Rainmeter.

For example:

Code: Select all

LeftMouseUpAction=[!CommandMeasure Transition "Fade('#CURRENTSECTION#', '[CalcAccentColorAlpha]', 'ButtonAlpha6', 3)"][!ShowMeterGroup VolumePopButtons][!CommandMeasure Transition "Fade('VolumeAPop', #AccentColorAlpha#, 'VolumePopAAlpha', 6)"][!CommandMeasure Transition "Fade('VolumeBPop', #BackgroundColorAlpha#, 'VolumePopBAlpha', 6)"][!CommandMeasure Transition "Fade('VolumePPop', #PrimaryColorAlpha#, 'VolumePopPAlpha', 6)"][!CommandMeasure Transition "Fade('VolumeSPop', #SecondaryColorAlpha#, 'VolumePopSAlpha', 6)"][!CommandMeasure Transition "Fade('VolumeBar', #AccentColorAlpha#, 'VolumeBarAlpha', 8)"][!HideMeterGroup BGGroup][!Redraw]
Could become:

Code: Select all

LeftMouseUpAction=[!CommandMeasure Transition "Fade('#CURRENTSECTION#', '[CalcAccentColorAlpha]', 'ButtonAlpha6', 3)"]...
     [!ShowMeterGroup VolumePopButtons][!CommandMeasure Transition "Fade('VolumeAPop', #AccentColorAlpha#, 'VolumePopAAlpha', 6)"]...
     [!CommandMeasure Transition "Fade('VolumeBPop', #BackgroundColorAlpha#, 'VolumePopBAlpha', 6)"]...
     [!CommandMeasure Transition "Fade('VolumePPop', #PrimaryColorAlpha#, 'VolumePopPAlpha', 6)"]...
     [!CommandMeasure Transition "Fade('VolumeSPop', #SecondaryColorAlpha#, 'VolumePopSAlpha', 6)"]...
     [!CommandMeasure Transition "Fade('VolumeBar', #AccentColorAlpha#, 'VolumeBarAlpha', 8)"]...
     [!HideMeterGroup BGGroup][!Redraw]
This would make it much easier to read and work with long statements in Rainmeter. Let me know what you think!

Merry Christmas!


Sincerely,
Exper1mental
As Brian mentioned, it is unlikely that this will ever be viable in Rainmeter.

But you can utilize Find-And-Replace in most editors, to quickly change the view from a working skin, to one with each bang on a separate line.

I always enclose, even my single bangs, in brackets [!...], which then allows me to search and replace the beginning of every bang, with a line break for easier editing. When I am done editing a quick reversal makes the skin compatible with Rainmeter's "everything on 1 line" functionality.

An example using Notepad++
Take any Rainmeter ini file and open it in Notepad++.
Select the "Replace..." icon.
In the dialog box for "Find what:" enter [! then in "Replace with:" enter \n[!. Finally, tick the box to use "Extended (...)", and click "Replace All'.

Every bang will be on a separate line for easier viewing and editing.

This working code:

Code: Select all

ContextTitle=Open Wallpaper Folder
ContextAction=["#CurrentPath#DownloadFile\Bing"]
ContextTitle2=Open Bing Wallpaper Site
ContextAction2=["http://www.bing.com/Images"]
ContextTitle3=---
ContextTitle4=Show Today's Wallpaper
ContextAction4=[!WriteKeyValue Variables DisableBing 0][!SetVariable DisableBing 0][!WriteKeyValue Variables RandomWall (1-#RandomWall#)][!SetVariable RandomWall (1-#RandomWall#)][!SetVariable SlideWall 0][!EnableMeasure MeasureQuote][!UpdateMeasure MeasureQuote][!DisableMeasure MeasureQuote]
ContextTitle5=[\x25cb] Time Change Disabled
ContextAction5=[!WriteKeyValue Variables ChangeRate 0][!SetVariable ChangeRate 0][!WriteKeyValue Variables RandomWall 0][!SetVariable RandomWall 0][!SetVariable SlideWall 0][!Update]
ContextTitle6=[\x25cb] Slideshow Wallpapers
ContextAction6=[!WriteKeyValue Variables SlideWall 1][!SetVariable SlideWall 1][!WriteKeyValue Variables ChangeRate #SlideRate#][!SetVariable ChangeRate #SlideRate#][!WriteKeyValue Variables RandomWall 1][!SetVariable RandomWall 1][!Update]
ContextTitle7=[\x25cb] Change Every 30 Minutes
ContextAction7=[!WriteKeyValue Variables ChangeRate 1800][!SetVariable ChangeRate 1800][!WriteKeyValue Variables RandomWall 1][!SetVariable RandomWall 1][!SetVariable SlideWall 0][!Update]
ContextTitle8=[\x25cb] Change Every Hour
ContextAction8=[!WriteKeyValue Variables ChangeRate 3600][!SetVariable ChangeRate 3600][!WriteKeyValue Variables RandomWall 1][!SetVariable RandomWall 1][!SetVariable SlideWall 0][!Update]
ContextTitle9=[\x25cb] Change Every 3 Hours
ContextAction9=[!WriteKeyValue Variables ChangeRate 10800][!SetVariable ChangeRate 10800][!WriteKeyValue Variables RandomWall 1][!SetVariable RandomWall 1][!SetVariable SlideWall 0][!Update]
ContextTitle10=[\x25cb] Change Every 6 Hours
ContextAction10=[!WriteKeyValue Variables ChangeRate ‭21600‬][!SetVariable ChangeRate 21600][!WriteKeyValue Variables RandomWall 1][!SetVariable RandomWall 1][!SetVariable SlideWall 0][!Update]
ContextTitle11=---
ContextTitle12=Toggle MouseOver Views
ContextAction12=[!ToggleMouseAction Rainmeter "MouseOverAction|MouseLeaveAction"]
ContextTitle13=---
ContextTitle14=Rainmeter Menu >
ContextAction14=[!SkinMenu]
Becomes easier to read and edit

Code: Select all

ContextTitle=Open Wallpaper Folder
ContextAction=["#CurrentPath#DownloadFile\Bing"]
ContextTitle2=Open Bing Wallpaper Site
ContextAction2=["http://www.bing.com/Images"]
ContextTitle3=---
ContextTitle4=Show Today's Wallpaper
ContextAction4=
[!WriteKeyValue Variables DisableBing 0]
[!SetVariable DisableBing 0]
[!WriteKeyValue Variables RandomWall (1-#RandomWall#)]
[!SetVariable RandomWall (1-#RandomWall#)]
[!SetVariable SlideWall 0]
[!EnableMeasure MeasureQuote]
[!UpdateMeasure MeasureQuote]
[!DisableMeasure MeasureQuote]
ContextTitle5=[\x25cb] Time Change Disabled
ContextAction5=
[!WriteKeyValue Variables ChangeRate 0]
[!SetVariable ChangeRate 0]
[!WriteKeyValue Variables RandomWall 0]
[!SetVariable RandomWall 0]
[!SetVariable SlideWall 0]
[!Update]
ContextTitle6=[\x25cb] Slideshow Wallpapers
ContextAction6=
[!WriteKeyValue Variables SlideWall 1]
[!SetVariable SlideWall 1]
[!WriteKeyValue Variables ChangeRate #SlideRate#]
[!SetVariable ChangeRate #SlideRate#]
[!WriteKeyValue Variables RandomWall 1]
[!SetVariable RandomWall 1]
[!Update]
ContextTitle7=[\x25cb] Change Every 30 Minutes
ContextAction7=
[!WriteKeyValue Variables ChangeRate 1800]
[!SetVariable ChangeRate 1800]
[!WriteKeyValue Variables RandomWall 1]
[!SetVariable RandomWall 1]
[!SetVariable SlideWall 0]
[!Update]
ContextTitle8=[\x25cb] Change Every Hour
ContextAction8=
[!WriteKeyValue Variables ChangeRate 3600]
[!SetVariable ChangeRate 3600]
[!WriteKeyValue Variables RandomWall 1]
[!SetVariable RandomWall 1]
[!SetVariable SlideWall 0]
[!Update]
ContextTitle9=[\x25cb] Change Every 3 Hours
ContextAction9=
[!WriteKeyValue Variables ChangeRate 10800]
[!SetVariable ChangeRate 10800]
[!WriteKeyValue Variables RandomWall 1]
[!SetVariable RandomWall 1]
[!SetVariable SlideWall 0]
[!Update]
ContextTitle10=[\x25cb] Change Every 6 Hours
ContextAction10=
[!WriteKeyValue Variables ChangeRate ‭21600‬]
[!SetVariable ChangeRate 21600]
[!WriteKeyValue Variables RandomWall 1]
[!SetVariable RandomWall 1]
[!SetVariable SlideWall 0]
[!Update]
ContextTitle11=---
ContextTitle12=Toggle MouseOver Views
ContextAction12=
[!ToggleMouseAction Rainmeter "MouseOverAction|MouseLeaveAction"]
ContextTitle13=---
ContextTitle14=Rainmeter Menu >
ContextAction14=
[!SkinMenu]
Once you are done editing, simply repeat the process, reversing the "Find what:" and "Replace with:" values: in the dialog box for "Find what:" enter \n[! then in "Replace with:" enter [!. Finally, tick the box to use "Extended (...)", and click "Replace All'.

Not as good as being able to actually extend bangs on separate lines in a working skin, but the change from one view to the other is simple, reliable, and quick. :rosegift:

EDIT: The one exception to this is the sound bang PLAY which does not use an exclamation punctuation mark. But that is a unique case.