[TW5] Need to count number of characters

112 views
Skip to first unread message

Mat

unread,
Dec 29, 2015, 10:52:02 AM12/29/15
to TiddlyWiki
Is there any macro or other solution to count the number of characters in a text?

..or, actually, the goal is to set the height of a a text area editor to match the content. For instance, in the SideEditor opening the sideeditor for a tiddler that has not previously been opened by it (and thus has not saved size values) the editor shows only a few rows, regardless of actual text length.

It's enough with an approximate height for the frame, perhaps +/-10% for longer texts, so my idea is to (somehow) get the number of characters, divide it by a hard coded estimated number of characters in a row (or is there any chance to count characters until line wrap? I'd be surprised!) and divide the two to get a rough estimate for how many lines the editor should show by default.

It seems there are many small javascript solutions to pick from... but that ain't TW so I don't know how to use it.  I'm thinking there might already be a solution for "numbers of characters in a text" in tiddlyverse?

I did find @Skeeves Wordcount macro and @Jeds Wordcount - neither of which I get to work (hm!?) and I'd really prefer number of characters rather than the number of words, for this. There's also the steamingly fresh Count filter by @Tobias which counts number of tiddler titles - again not what I'm hoping for.

Hoping to get pointers or ideas. Thank you!

<:-)

Tobias Beer

unread,
Dec 29, 2015, 11:18:21 AM12/29/15
to TiddlyWiki
Hi Mat,

If it can be avoided, let's not reinvent the wheel.
The EditTextWidget already allows to specify autoHeight.

Best wishes,

Tobias. 

Mat

unread,
Dec 29, 2015, 2:33:21 PM12/29/15
to TiddlyWiki
Thanks Tobias

I don't know why, but autoHeight doesn't work here and I suspect it has to do with the circumstances I'm putting these text areas into. Now... um... it's part of a concept that I hope to present to the community soon (yes, it's revolutionary "No Mat, you don't say!") but I'd rather not link to it publically until some fundamental bits are working, of which the text area issue is one. (I wouldn't mind showing it to you though, can I? Come to think of it, it's very likely some of your recent creations will come in handy so maybe it's even a good idea!)

@everyone - meanwhile, my original question still holds. Anybody's got a spare letter counter...?

<:-)

Tobias Beer

unread,
Dec 29, 2015, 2:44:03 PM12/29/15
to TiddlyWiki
Hi Mat,
 
I don't know why, but autoHeight doesn't work here and I suspect it has to do with the circumstances I'm putting these text areas into.

Can you describe more clearly why it won't work here?
If it is because you're not using a state or temporary tiddler,
I'd recommend you consider using one.
 
I wouldn't mind showing it to you though, can I?

Sure, drop a line with a pointer to some dropbox or such here:


Come to think of it, it's very likely some of your recent creations will come in handy so maybe it's even a good idea!)

Perhaps, only you can tell. ;-)

Best wishes,

Tobias.

Mat

unread,
Dec 29, 2015, 4:30:05 PM12/29/15
to TiddlyWiki
Can you describe more clearly why it won't work here?

I probably can not, but the circumstance I'm referring to is similar to that in my SideEditor plugin where, btw, the problem with faulty autoheight also occurs - sometimes. But I feel it is not a great example because the SideEditor does store a lot of meta data in a state tiddler about the size of the editor whereas the "new concept" does not.
 
If it is because you're not using a state or temporary tiddler,
I'd recommend you consider using one.

Hm, if that is how it ought to be, then maybe the whole EditTextWidget should have this build in, no? And how would one go about this in a good way?
And does this have to do with the very last sentences in the docs for that widget, i.e
In short the EditTextWidget can not change properties of the tiddler it is embedded in or part of. It can only change fields of other tiddlers. One could use ShadowTiddlers to accomplish the field storage if needed.
 
I wouldn't mind showing it to you though, can I?

Sure, drop a line with a pointer to some dropbox or such here:

Great. Later tonight or tomorrow.

Come to think of it, it's very likely some of your recent creations will come in handy so maybe it's even a good idea!)

Perhaps, only you can tell. ;-)

You'll see. For instance if I install your new appear plugin I will probably [quoting you] "come up with or implement some fancy use-casesthat are not already listed in the examples" :-)


<:-)

Tobias Beer

unread,
Dec 30, 2015, 1:46:37 AM12/30/15
to TiddlyWiki
Hi Mat,
 
maybe the whole EditTextWidget should have this build in, no?

I think it does. I mean: I'm not sure what you're missing.
 
And how would one go about this in a good way?
And does this have to do with the very last sentences in the docs for that widget, i.e
In short the EditTextWidget can not change properties of the tiddler it is embedded in or part of. It can only change fields of other tiddlers. One could use ShadowTiddlers to accomplish the field storage if needed.
So, yes, you'd need some basic or otherwise temporary / state tiddler for the EditTextWidget to modify, i.e. it won't just give you a textarea providing autoHeight unless it is bound to some tiddler field. Should you have noticed bugs around autoHeight in the EditTextWidget, we should probably focus on fixing those rather than fiddle with other ways of making it all the way to Rome.
 
You'll see. For instance if I install your new appear plugin I will probably [quoting you] "come up with or implement some fancy use-casesthat are not already listed in the examples" :-)

Looking forward to that :)

Best wishes,

Tobias. 

Alex Hough

unread,
Dec 30, 2015, 11:29:41 AM12/30/15
to TiddlyWiki
Mat

WordCount macro has its own wiki


It has options for character count



Alex

--
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/504de202-878d-48c8-bad7-b03716cadd72%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages