It is currently March 28th, 2024, 9:07 pm

line breaks with InputText.dll

Report bugs with the Rainmeter application and suggest features.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: line breaks with InputText.dll

Post by balala »

glow8 wrote:Okay so the balala code isn't working. At least here. Maybe the bug is only in this skin
Ok, please post here the code of the incriminated skin.
glow8
Posts: 4
Joined: April 27th, 2017, 4:04 pm

Re: line breaks with InputText.dll

Post by glow8 »

balala wrote:Ok, please post here the code of the incriminated skin.

Code: Select all

[Rainmeter]
Update=1000

[Metadata]
Name=Quick Notes
Author=rasvob.deviantart.com
Version=1.0
;End of added Metadata

@include2=#@#Notes/Note1.txt
@include3=#@#Vars.inc

[Background]
Meter=Image
ImageName=#@#images\Notes\white_bg.png
W=280
H=275
Y=5

[MeterTopImg]
Meter=Image
ImageName=#top_slim#
W=280

[TextNotes]
Meter=STRING
MeterStyle=RobotoLight
FontSize=20
FontColor=#color4#
X=0
Y=8
Text=Notas

[MeterSettings]
Meter=Button
X=260
Y=20
ButtonImage=#top_slim_btn#
ButtonCommand=[!ShowMeterGroup Cfg][!ShowMeter MeterSettings_off][!HideMeter MeterSettings][!Redraw]

[MeterSettings_off]
Meter=Button
X=260
Y=20
Hidden=1
ButtonImage=#top_slim_btn#
ButtonCommand=[!HideMeterGroup Cfg][!ShowMeter MeterSettings][!HideMeter MeterSettings_off][!Redraw]

[NoteText]
Meter=STRING
FontFace=RobotoLightNote
FontSize=9
FontColor=#color2#
AntiAlias=1
X=5
Y=44
W=270
H=230
Clipstring=1
Text=#Text#
LeftMouseUpAction=!RainmeterPluginBang "MeasureInput ExecuteBatch 1"

[MeasureSearchInput]
Measure=Plugin
Plugin=InputText
X=4
Y=3
W=188
H=44
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontSize=11
AntiAlias=1
FocusDismiss=1
UpdateDivider=-1
RegExpSubstitute=1
Substitute="\r\n":"#*CRLF*#"
Command1=[!SetVariable Text "$UserInput$"][!UpdateMeasure "MeasureText"]
Command2=[!WriteKeyValue Variables TestString "[MeasureSearchInput]" "#CURRENTPATH#Test1.ini"]

[MeasureText]
Measure=String
String=#Text#
RegExpSubstitute=1
Substitute="\r\n":"#*CRLF*#"
OnChangeAction=[!WriteKeyValue Variables Text "[MeasureText]" "#@#Notes/Note1.txt"][!Refresh]
DynamicVariables=1
UpdateDivider=-1

[Over]
Meter=Image
W=270
H=215
X=5
Y=44
SolidColor=0,0,0,210
Hidden=1
Group=Cfg

[TextColorScheme]
Meter=STRING
MeterStyle=RobotoLight
FontSize=20
FontColor=#color1#
X=70	
Y=50
Text="Color theme"

[Box1]
Meter=Image
W=60
H=60
X=80
Y=100
SolidColor=#color_orange#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #orange_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #orange_slim_btn# "#@#Vars.inc"][!Refresh]

[Box2]
Meter=Image
W=60
H=60
X=160
Y=100
SolidColor=#color_red#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #red_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #red_slim_btn# "#@#Vars.inc"][!Refresh]

[Box3]
Meter=Image
W=60
H=60
X=80
Y=180
SolidColor=#color_blue#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #blue_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #blue_slim_btn# "#@#Vars.inc"][!Refresh]

[Box4]
Meter=Image
W=60
H=60
X=160
Y=180
SolidColor=#color_green#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #green_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #green_slim_btn# "#@#Vars.inc"][!Refresh]

Then it has a notes .txt with whatever you wrote, and a few themes
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: line breaks with InputText.dll

Post by balala »

The greatest problem of this last posted code is that in the LeftMouseUpAction option of the [NoteText] meter, you have the following bang: LeftMouseUpAction=!RainmeterPluginBang "[color=#FF0000]MeasureInput[/color] ExecuteBatch 1", but the appropriate measure isn't named [MeasureInput] (as used in !RainmeterPluginBang), but [MeasureSearchInput] (immediately after the [NoteText] meter). This makes the InputText plugin to not work.
Another missing option would be a DefaultValue=#Text#, which should be added to the InputText plugin measure (either [MeasureInput], or [MeasureSearchInput], depending how you finally will name it).
Also note that:
  • The !Rainmeter... bang prefix is deprecated, you shouldn't have to use it.
  • The !PluginBang (or !RainmeterPluginBang) bang is deprecated as well, you should replace it with the newer !CommandMeasure. Replace the above mentioned option, with the following one: LeftMouseUpAction=[!CommandMeasure "MeasureInput[color=#FF0000]" "[/color]ExecuteBatch 1"]. Note the extra quotation marks, unlike in the !RainmeterPluginBang bang.
  • Although that's not a problem which would make the skin to not work, in Rainmeter the usual symbol which separates the folders in paths, is not the slash (/), but the backslash (\). You've used the slash more times, I replaced them.
Taking into account all these, I rewrote a few options / sections of your last posted code, please check this new one:

Code: Select all

[Rainmeter]
Update=1000

[Metadata]
Name=Quick Notes
Author=rasvob.deviantart.com
Version=1.0
;End of added Metadata

@include2=#@#Notes\Note1.txt
@include3=#@#Vars.inc

[Background]
Meter=Image
ImageName=#@#images\Notes\white_bg.png
W=280
H=275
Y=5

[MeterTopImg]
Meter=Image
ImageName=#top_slim#
W=280

[TextNotes]
Meter=STRING
MeterStyle=RobotoLight
FontSize=20
FontColor=#color4#
X=0
Y=8
Text=Notas

[MeterSettings]
Meter=Button
X=260
Y=20
ButtonImage=#top_slim_btn#
ButtonCommand=[!ShowMeterGroup Cfg][!ShowMeter MeterSettings_off][!HideMeter MeterSettings][!Redraw]

[MeterSettings_off]
Meter=Button
X=260
Y=20
Hidden=1
ButtonImage=#top_slim_btn#
ButtonCommand=[!HideMeterGroup Cfg][!ShowMeter MeterSettings][!HideMeter MeterSettings_off][!Redraw]

[NoteText]
Meter=STRING
FontFace=RobotoLightNote
FontSize=9
FontColor=#color2#
AntiAlias=1
X=5
Y=44
W=270
H=230
Clipstring=1
Text=#Text#
LeftMouseUpAction=[!CommandMeasure "MeasureInput" "ExecuteBatch 1"]

[MeasureInput]
Measure=Plugin
Plugin=InputText
X=5
Y=44
W=270
H=230
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontSize=9
AntiAlias=1
FocusDismiss=1
DefaultValue=#Text#
Command1=[!SetVariable Text "$UserInput$"][!UpdateMeasure "MeasureText"]

[MeasureText]
Measure=String
String=#Text#
RegExpSubstitute=1
Substitute="\r\n":"#*CRLF*#"
OnChangeAction=[!WriteKeyValue Variables Text "[MeasureText]" "#@#Notes\Note1.txt"][!Refresh]
DynamicVariables=1
UpdateDivider=-1

[Over]
Meter=Image
W=270
H=215
X=5
Y=44
SolidColor=0,0,0,210
Hidden=1
Group=Cfg

[TextColorScheme]
Meter=STRING
MeterStyle=RobotoLight
FontSize=20
FontColor=#color1#
X=70   
Y=50
Text="Color theme"

[Box1]
Meter=Image
W=60
H=60
X=80
Y=100
SolidColor=#color_orange#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #orange_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #orange_slim_btn# "#@#Vars.inc"][!Refresh]

[Box2]
Meter=Image
W=60
H=60
X=160
Y=100
SolidColor=#color_red#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #red_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #red_slim_btn# "#@#Vars.inc"][!Refresh]

[Box3]
Meter=Image
W=60
H=60
X=80
Y=180
SolidColor=#color_blue#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #blue_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #blue_slim_btn# "#@#Vars.inc"][!Refresh]

[Box4]
Meter=Image
W=60
H=60
X=160
Y=180
SolidColor=#color_green#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #green_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #green_slim_btn# "#@#Vars.inc"][!Refresh]
This code is my way of approach.
But you can also take into account jsmorley's advices. The same code, according to his approach:

Code: Select all

[Rainmeter]
Update=1000

[Metadata]
Name=Quick Notes
Author=rasvob.deviantart.com
Version=1.0
;End of added Metadata

@include2=#@#Notes\Note1.txt
@include3=#@#Vars.inc

[Background]
Meter=Image
ImageName=#@#images\Notes\white_bg.png
W=280
H=275
Y=5

[MeterTopImg]
Meter=Image
ImageName=#top_slim#
W=280

[TextNotes]
Meter=STRING
MeterStyle=RobotoLight
FontSize=20
FontColor=#color4#
X=0
Y=8
Text=Notas

[MeterSettings]
Meter=Button
X=260
Y=20
ButtonImage=#top_slim_btn#
ButtonCommand=[!ShowMeterGroup Cfg][!ShowMeter MeterSettings_off][!HideMeter MeterSettings][!Redraw]

[MeterSettings_off]
Meter=Button
X=260
Y=20
Hidden=1
ButtonImage=#top_slim_btn#
ButtonCommand=[!HideMeterGroup Cfg][!ShowMeter MeterSettings][!HideMeter MeterSettings_off][!Redraw]

[NoteText]
Meter=STRING
FontFace=RobotoLightNote
FontSize=9
FontColor=#color2#
AntiAlias=1
X=5
Y=44
W=270
H=230
Clipstring=1
Text=#Text#
LeftMouseUpAction=[!CommandMeasure "MeasureInput" "ExecuteBatch 1-2"]

[MeasureInput]
Measure=Plugin
Plugin=InputText
X=5
Y=44
W=270
H=230
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontSize=9
AntiAlias=1
FocusDismiss=1
DefaultValue=#Text#
RegExpSubstitute=1
Substitute="\r\n":"#*CRLF*#"
Command1=$UserInput$
Command2=[!WriteKeyValue Variables Text "[MeasureInput]" "#@#Notes\Note1.txt"][!Refresh]

[Over]
Meter=Image
W=270
H=215
X=5
Y=44
SolidColor=0,0,0,210
Hidden=1
Group=Cfg

[TextColorScheme]
Meter=STRING
MeterStyle=RobotoLight
FontSize=20
FontColor=#color1#
X=70   
Y=50
Text="Color theme"

[Box1]
Meter=Image
W=60
H=60
X=80
Y=100
SolidColor=#color_orange#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #orange_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #orange_slim_btn# "#@#Vars.inc"][!Refresh]

[Box2]
Meter=Image
W=60
H=60
X=160
Y=100
SolidColor=#color_red#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #red_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #red_slim_btn# "#@#Vars.inc"][!Refresh]

[Box3]
Meter=Image
W=60
H=60
X=80
Y=180
SolidColor=#color_blue#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #blue_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #blue_slim_btn# "#@#Vars.inc"][!Refresh]

[Box4]
Meter=Image
W=60
H=60
X=160
Y=180
SolidColor=#color_green#
Hidden=1
Group=Cfg
LeftMouseUpAction=[!WriteKeyValue Variables top_slim #green_slim# "#@#Vars.inc"][!WriteKeyValue Variables top_slim_btn #green_slim_btn# "#@#Vars.inc"][!Refresh]
Note that with this last one approach, the [MeasureText] measure really isn't needed any more, so maybe this one indeed is a simpler one.
glow8
Posts: 4
Joined: April 27th, 2017, 4:04 pm

Re: line breaks with InputText.dll

Post by glow8 »

WOW thank you very much for explaining it so clearly and giving the code <3 Now it's working perfectly with your version. Thank you!!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: line breaks with InputText.dll

Post by balala »

Glad to help.
ariefcfa
Posts: 18
Joined: October 7th, 2012, 3:37 pm

Re: line breaks with InputText.dll

Post by ariefcfa »

one question, the [MeasureInput] InputText DefaultValue=#Text# which is contain literal #CRLF#. But the #CRLF# is not displayed as new line break in input tex box when we edit it.

i try to add a new measure to substitute #CRLF# become "\r\n" and make DefaultValue=[MeasureTextedit]

Code: Select all

[MeasureTextEdit]
Measure=String
String=#Text#
RegExpSubstitute=1
Substitute="#CRLF#":"\r\n"
assume Text=January#CRLF#February

The input text will display it as January\r\nFebruary which is interpret literal \r\n not as line break.

Is there a way to anticipate this?
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: line breaks with InputText.dll

Post by jsmorley »

ariefcfa wrote:one question, the [MeasureInput] InputText DefaultValue=#Text# which is contain literal #CRLF#. But the #CRLF# is not displayed as new line break in input tex box when we edit it.

i try to add a new measure to substitute #CRLF# become "\r\n" and make DefaultValue=[MeasureTextedit]

Code: Select all

[MeasureTextEdit]
Measure=String
String=#Text#
RegExpSubstitute=1
Substitute="#CRLF#":"\r\n"
assume Text=January#CRLF#February

The input text will display it as January\r\nFebruary which is interpret literal \r\n not as line break.

Is there a way to anticipate this?
Unfortunately, the InputText plugin is not aware of the #CRLF# special variable in Rainmeter.

And Rainmeter doesn't treat escape characters in a string as control characters, any more than these forums do if I type in \r\n. << See? ;-)

But there is a solution, and you don't need a String measure and a Substitute, unless you want it for some reason.

https://docs.rainmeter.net/manual/variables/character-variables/
DefaultValue=Hello[\13][\10]World

That should work for you.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: line breaks with InputText.dll

Post by fonpaolo »

You can use the opposite, if you use Ctrl + Enter in your ImputText and then add this substitution in your measure:

Code: Select all

RegExpSubstitute=1
Substitute="\r\n":"#*CRLF*#"
...it works.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: line breaks with InputText.dll

Post by jsmorley »

fonpaolo wrote:You can use the opposite, if you use Ctrl + Enter in your ImputText and then add this substitution in your measure:

Code: Select all

RegExpSubstitute=1
Substitute="\r\n":"#*CRLF*#"
...it works.
Right. While that doesn't solve his particular problem, you can use \r\n as control characters in a regular expression Substitute.

His situation is that he has a variable, say myText=Hello#CRLF#World, and wants to use that variable as the DefaultValue option on an InputText measure, say DefaultValue=#myText#.

The problem is that InputText is not dealing with the embedded #CRLF# variable correctly, so his not-unreasonable thinking is to Substitute the #CRLF# for something it does understand as a carriage return / linefeed control sequence.

He can do it with a RegExpSubstitute on a String measure, similar (but reversed) from what you suggest, or he can just use the [\CharacterVariable] solution to do it right in the DefaultValue option.

My suggestion would be either:

[InputTextMeasure]
DefaultValue=Hello[\13][\10]World

or

[Variables]
myText=Hello[\13][\10]World

[inputTextMeasure]
DefaultValue=#myText#

Keep in mind that [Variables] are NEVER "resolved" in any way in the [Variables] section itself. They are resolved when and where they are "used". It just so happens that #CRLF# is not properly understood when it is "used" in an InputText measure, but [\13][\10] is. It's really kind of inconsistent and icky, but we are not likely to do much with the InputText measure unless and until we just replace it with something entirely different and better at some point. InputText in general is a bit of a bag on the side of the machine...
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: line breaks with InputText.dll

Post by fonpaolo »

Sorry, reading about ImputText and #CRLF# my brain has pointed me to a solution, but, as usual, not the right one. :17oops