Size on edit-text widget

102 views
Skip to first unread message

TonyM

unread,
May 29, 2019, 8:27:29 PM5/29/19
to TiddlyWiki
Hi,

I am using the edit-text widget to edit fields. I am using tag=input and it is possible to set the size of the field in number of characters. The default is 20 (HTML doco)

However I would like this size to be set to the length of the value contained in the field, or ideally only if it is greater than already set.

Does anyone know how to do this please?

Tony

TonyM

unread,
Jun 5, 2019, 9:16:52 PM6/5/19
to TiddlyWiki
Bump,

Is there a way to obtain the length of a string?

It appears to be coming in 5.1.20 but before ?

For example if there was a length operator I could do this
{{{ [length{!!caption}] }}}

Placing it in the size= parameter of edit-text widget would be great.

Regards
Tony

Mark S.

unread,
Jun 6, 2019, 12:26:10 AM6/6/19
to TiddlyWiki
You'll either need a math library, or upgrade to 5.1.20.

But here's a way for strings that are 50 characters or less:

\define length2(str,len)
<$vars reg="^.{$len$}$">
<$set name="result" filter="[title[$str$]regexp<reg>]" value="""$len$""" emptyValue="" >
<<result>>
</$set>
</
$vars>
\end
\define length(str)
<$list filter="[range[1,50]]" variable="cnt">
<$macrocall $name="length2" str="""$str$""" len=<<cnt>>/>
</
$list>
\end

Length: <<length "How long am I">>


You can, of course, extend it to possible longer numbers. But it's not very efficient (it will check every possible length between 1 and 50 even AFTER it has found the correct length).

Mark

TonyM

unread,
Jun 6, 2019, 1:18:41 AM6/6/19
to TiddlyWiki
Mark,

Thanks- that seams a reasonable solution for sizing small fields.

What maths library would you be thinking of me using? 

I Know about Evans Formula plugin and remember a calc widget somewhere.

Regards
Tony

Mark S.

unread,
Jun 6, 2019, 1:26:08 AM6/6/19
to TiddlyWiki
I was thinking of Evan's -- I think he has everything. You could also borrow the code from 5.1.20 until it's actually released -- that way it's backward (forward?) compatible.

It looks like mathcell.tiddlyspot.com may also have something useful.

Typing "math" into the tiddly toolmaps suggests some other options, though I think they may be showing their age.

-- Mark

TonyM

unread,
Jun 6, 2019, 4:45:11 AM6/6/19
to TiddlyWiki
Thanks Mark

How do I borrow the code from 5.1.20 sounds intriguing?. This could be important for my application.

Thanks
Tony

Mark S.

unread,
Jun 6, 2019, 1:50:56 PM6/6/19
to TiddlyWiki
Looks like you can just drag and drop

$:/core/modules/filters/strings.js

from the pre-release into your TW (but don't know how far back the compatibility extends)

Jeremy Ruston

unread,
Jun 7, 2019, 3:42:10 AM6/7/19
to 'Mark S.' via TiddlyWiki
Looks like you can just drag and drop

$:/core/modules/filters/strings.js

from the pre-release into your TW (but don't know how far back the compatibility
extends)

Just to add my usual warning: PLEASE DON'T DO THIS! (except for cautious experimentation)

You'll be making a frankenstein core that consists of different bits of different versions of the core. It makes it impossible for the community to provide meaningful support because you've created a whole load of potential compatibility problems that could manifest themselves at any point in the future.

If you want the latest and greatest then use the prerelease. It's risky, but at least we're all using the same thing at the same time, which eases support. If you don't want the latest and greatest, then use the latest official release. There's no viable middle ground.

Part of what makes TiddlyWiki powerful is the community behind it, and part of what makes that possible is the commonality of us all using the same thing.

Best wishes

Jeremy


On Thursday, June 6, 2019 at 1:45:11 AM UTC-7, TonyM wrote:
Thanks Mark

How do I borrow the code from 5.1.20 sounds intriguing?. This could be important for my application.

Thanks
Tony

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/73c23dc9-b92a-43f2-b817-1c1ccdaf8b1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TonyM

unread,
Jun 7, 2019, 4:49:33 AM6/7/19
to TiddlyWiki
Jeremy,

Thanks for the warning. I am only building a specific wiki at this point so I do not expect a Frankenstein to proliferate, however it is to be used in a production environment so I will stay with the stable release and add a maths related plugin. I will document the specific use of maths and review them when 5.1.20 even +1 is available.

With no pressure have we an approximate timeframe for 5.1.20 release?

Regards
Tony

Reply all
Reply to author
Forward
0 new messages