It is currently October 12th, 2024, 3:27 am

Continue Long Statements on Multiple Lines

Report bugs with the Rainmeter application and suggest features.
User avatar
exper1mental
Posts: 269
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: 2738
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: 139
Joined: September 27th, 2017, 6:32 pm
Location: Netherlands

Re: Continue Long Statements on Multiple Lines

Post by JelleDekkers »

Just make your editor wrap the lines?
¯\_(ツ)_/¯
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5540
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.
jn_meter
Posts: 139
Joined: December 27th, 2016, 12:04 pm

Re: Continue Long Statements on Multiple Lines

Post by jn_meter »

The workaround posted above might well be usable (I have not tried it, except in the form of a kind of manual implementation). Still: actually adjusting the syntax to allow a long-line to be split over multiple lines would be a considerable productivity boon. So I hope that some clever-clogs can implement it some day.
User avatar
Yincognito
Rainmeter Sage
Posts: 8421
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Continue Long Statements on Multiple Lines

Post by Yincognito »

jn_meter wrote: April 12th, 2023, 10:10 pm The workaround posted above might well be usable (I have not tried it, except in the form of a kind of manual implementation). Still: actually adjusting the syntax to allow a long-line to be split over multiple lines would be a considerable productivity boon. So I hope that some clever-clogs can implement it some day.
Well, I don't know about implementing it since other folks handle that, but, if you really want to and you use the same window size in Notepad++ (I'm on a 1920x1080 laptop monitor, 100% Windows scaling), you could use View / Word Wrap from the menu, then space things until they appear on multiple lines (I didn't found a method to copy paste the same number of spaces and achieve the below yet, it was mainly manual, but it works):

Code: Select all

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

[SomeMeter]
Meter=String
X=50
Y=50
W=100
H=100
SolidColor=255,128,64,255
FontFace=Tahoma
FontSize=15
FontWeight=700
StringAlign=CenterCenter
AntiAlias=1
Text=Press Me!
LeftMouseUpAction=[!Log "Hello"]                                                                                                                                                                                                      [!Log "There"]                                                                                                                                                                                                                        [!Log "Wrap Lines and Space bangs a lot"]                                                                                                                                                                                             [!Log "Now it should work"]                                                                                                                                                                                                           [!Log "But spacing is variable and differs from line to line..."]
Editor.jpg
Hopefully the forum code doesn't mess up my post trimming stuff and such, because this should work for a maximized Notepad++ window on a 1920x1080 monitor at 100% scaling. The code works as well, as it can be seen:
Log.jpg
So, JelleDekkers was right. I also use eclectic-tech's method very rarely when I not only need temporary readability but also want to copy paste slightly modified groups of bangs.

Apart from that, in theory, a Rainmeter "saver skin" could probably be made to save two versions of the same edited file:
- one, on multiple lines, but that would require some command line to instruct Notepad++ to do so like here, via the WindowMessage plugin or AutoHotkey
- the other, on single lines, by parsing and making the first one compact via Lua or WebParser + regex + !WriteKeyValue bangs
Then, you would edit stuff normally on multiple lines in Notepad++, and use the said saver skin to click and save both versions (of which only the second will be the skin loaded by Rainmeter, with the first kept only for editing). If there wasn't the inherent redundancy and making things more cumbersome than normal, I could probably try to do it just for the challenge of it, but then I doubt it would be a truly viable or attractive option to edit skins for regular users, so I only mentioned it as an idea to achieve the desired outcome. The only question is, like always, how much does one REALLY want it. ;-)

P.S. Or, you can try recording a Notepad++ macro to do the double saving of the two versions, and see if it can be applied to any file you edit.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
jn_meter
Posts: 139
Joined: December 27th, 2016, 12:04 pm

Re: Continue Long Statements on Multiple Lines

Post by jn_meter »

Thanks, Yincognito.

I myself use SublimeText as my one editor (on my Windows PC and on my Linux laptops) and I do not want to replace or supplement that.
User avatar
Yincognito
Rainmeter Sage
Posts: 8421
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Continue Long Statements on Multiple Lines

Post by Yincognito »

jn_meter wrote: April 13th, 2023, 1:35 am Thanks, Yincognito.

I myself use SublimeText as my one editor (on my Windows PC and on my Linux laptops) and I do not want to replace or supplement that.
Ah, I see - no problem with that.

However, Sublime Text, as far as I could see, has the ability to record and play macros or use regex search and replace as well, so you can try and see if it works like that (after you take some reasonable precautionary measures to avoid saving in the wrong place or over the wrong file and such). The only question would be whether those saved macros can be applied to a volatile but selective file name, that's all - after that, it would be just a matter of pressing the hotkey / button / whatever you assigned to that saved macro and let it do its job.

Even if a macro doing that and match all the requirements for the purpose would not be possible, every Windows program communicates using windows messages, so a WindowsMessage plugin or AutoHotKey solution involving a saver skin would still be in the cards, albeit a bit more complex than using a macro.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth