It is currently March 28th, 2024, 5:05 pm

line breaks with InputText.dll

Report bugs with the Rainmeter application and suggest features.
glow8
Posts: 4
Joined: April 27th, 2017, 4:04 pm

line breaks with InputText.dll

Post by glow8 »

I'm using this skin

http://rainmeter.deviantart.com/art/RAINMETER-Purity-Notes-Skin-493502692

and looks like I can't make line breaks with Enter

when I try with Ctrl+Enter, everything I write in the new line will be removed

is the code wrong or is it the InputText.dll?

Code: Select all

[MeasureInput]
Measure=Plugin
Plugin=InputText.dll
X=5
Y=44
W=270
H=220
SolidColor=f2f2f2
FontColor=3d3d3d
FontFace=RobotoLightNote
FontSize=9
FocusDismiss=1
DefaultValue=#Text#
Command1=[!WriteKeyValue "Variables" "Text" "$userInput$" "#@#Notes/Note1.txt"][!Refresh]
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:and looks like I can't make line breaks with Enter

when I try with Ctrl+Enter, everything I write in the new line will be removed

is the code wrong or is it the InputText.dll?
I don't think that the described behavior would be a bug, nor of the InputText plugin, nor of the skin. Simply the plugin doesn't support line breaks, because hiting enter determines the plugin to execute the appropriate command, instead of creating new line.
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 »

balala wrote:I don't think that the described behavior would be a bug, nor of the InputText plugin, nor of the skin. Simply the plugin doesn't support line breaks, because hiting enter determines the plugin to execute the appropriate command, instead of creating new line.
CTRL-Enter will work to create a line break in the input, but don't forget that you now have two lines, and unless the defined input box is tall enough, the first line is going to be visibly pushed out of it to the top, and although it's there, (just scroll around with the arrow keys while inputting to see what I mean) you won't see it.

In any case, there is no bug. CTRL-Enter works exactly as expected, and creates a line break in the input.

Code: Select all

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

[MeterSearchBox]
Meter=Shape
Shape=Rectangle 1,1,202,25 | Fill Color 215,215,215,255 | Stroke Color 130,130,130,255
W=202
H=25
LeftMouseUpAction=[!CommandMeasure "MeasureSearchInput" "ExecuteBatch 1"]

[MeasureSearchInput]
Measure=Plugin
Plugin=InputText
X=4
Y=3
W=188
H=22
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontSize=11
AntiAlias=1
FocusDismiss=1
UpdateDivider=-1
Command1=[!Log "$UserInput$"]
That will move the first line up text up so it won't be visible anymore when you hit CTRL-Eneter, as it has only enough room for one line in the input box.

Code: Select all

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

[MeterSearchBox]
Meter=Shape
Shape=Rectangle 1,1,202,50 | Fill Color 215,215,215,255 | Stroke Color 130,130,130,255
W=202
H=50
LeftMouseUpAction=[!CommandMeasure "MeasureSearchInput" "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
Command1=[!Log "$UserInput$"]
That will work as expected...
1.png
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 »

jsmorley wrote:CTRL-Enter will work to create a line break in the input, but don't forget that you now have two lines, and unless the defined input box is tall enough, the first line is going to be visibly pushed out of it to the top, and although it's there, (just scroll around with the arrow keys while inputting to see what I mean) you won't see it.

In any case, there is no bug. CTRL-Enter works exactly as expected, and creates a line break in the input.
In the case of the skin posted by glow8 in his initial question, that's not a problem, because the the string meter which is displaying the entered string is 290 pixels wide and 355 pixels tall. Same size has the appropriate input box, too. Not this is the problem.
But when a text is typed and the enter is hit, the appropriate variable is written into a file. The problem why the second line doesn't appear is that if you add a such second line with CTRL-Enter, the second line is written to the file into a distinct line. Eg, here is the initial content of the mentioned file:

Code: Select all

[Variables]
Align=center
Text=Click here to add note...
If I type one single line, I get this:

Code: Select all

[Variables]
Align=center
Text=First line 
But if I type one more line, this is what I get:

Code: Select all

[Variables]
Align=center
Text=First line
Second one
See that the second line (in the above exemple, the Second one string) is written into a second, new line of the file, so, practically it doesn't belong to the Text variable and that's why it isn't shown by the skin, which shows the Text variable.
At least me can't imagine now a convenient solution how to enter more line of text.
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 »

Ah, I see balala. Yeah, while the input box will handle the linefeed properly, if you use that result to write to a file with !WriteKeyValue, it will be split on two lines, which isn't going to be useful in a .ini format. Might need to pass the result through some Lua to turn the linefeed into a literal string '#CRLF#' before writing it to the file.
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 »

jsmorley wrote:Might need to pass the result through some Lua to turn the linefeed into a literal string '#CRLF#' before writing it to the file.
Instead of the not very simple lua approach, couldn't be passed the result through a String measure, with a properly created regular expression substitution (to substitute the linefeed with a #CRLF#)? Would be much simpler, in my opinion.
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 »

This might work for you...

Code: Select all

[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=$UserInput$
Command2=[!WriteKeyValue Variables TestString "[MeasureSearchInput]" "#CURRENTPATH#Test1.ini"]
That will put a literal "#CRLF#" into the output file, which when read and used should give you the result you want.

Code: Select all

[Variables]
TestString=Line 1#CRLF#Line 2
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 »

jsmorley wrote:This might work for you...

Code: Select all

[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=$UserInput$
Command2=[!WriteKeyValue Variables TestString "[MeasureSearchInput]" "#CURRENTPATH#Test1.ini"]
That will put a literal "#CRLF#" into the output file, which when read and used should give you the result you want.

Code: Select all

[Variables]
TestString=Line 1#CRLF#Line 2
This code doesn't work for me, as it is, in the concreate case of the posted skin, but with a small change, it will.

In the Purity skin, I replaced the Command1 option of the [MeasureInput] measure, with the following one: Command1=[!SetVariable Text "$UserInput$"][!UpdateMeasure "MeasureText"]. For now, the [MeasureText] measure doesn't exists, but I added it:

Code: Select all

[MeasureText]
Measure=String
String=#Text#
RegExpSubstitute=1
Substitute="\r\n":"#*CRLF*#"
OnChangeAction=[!WriteKeyValue Variables Text "[MeasureText]" "#@#Notes/Note1.txt"][!Refresh]
DynamicVariables=1
UpdateDivider=-1
As jsmorley said, when you type a string into the input box and hit enter, the Command1 option of the [MeasureInput] measure sets the Text variable. This variable is taken over by the [MeasureText] measure, which is updated by the !UpdateMeasure bang and through the Substitute option created and posted by jsmorley, replaces the linefeed with the #CRLF# symbol. Now the string is written into the file with this symbol and the skin will show the text into two lines.
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 »

Not sure I see the need for a String measure, as when you hit Enter on an InputText measure, the measure value is instantly changed to the input value, and simply using the value as a [SectionVariable] in subsequent bangs should be all you need. The Substitute will be applied to the measure value instantly as well, so while $UserInput$ won't see the Substitute a [SectionVariable] will.

Having said that, I have not even looked at the original skin in question, so there may be other factors. Carry on...
glow8
Posts: 4
Joined: April 27th, 2017, 4:04 pm

Re: line breaks with InputText.dll

Post by glow8 »

Wow thanks I didn't expect so many comments :)

Okay so the jsmorley code isn't working. At least here. Maybe the bug is only in this skin

https://youtu.be/bUmX-Bg4ePU

Sorry for the music I forgot to turn off the mic and I had to cover it with the youtube editor

Not working with balala's neither. What am I doing wrong?

Code: Select all

[MeasureSearchInput]
Measure=Plugin
Plugin=InputText.dll
X=4
Y=3
W=188
H=39
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=$UserInput$
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
and nothing with balalas change

Code: Select all

[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
Last edited by glow8 on April 28th, 2017, 1:41 pm, edited 6 times in total.
Post Reply