Can typing in editor be used to trigger actions?

48 views
Skip to first unread message

Mat

unread,
May 2, 2020, 5:46:25 AM5/2/20
to TiddlyWikiDev
In attempting to make a TitlePicker, a fellow tiddleur proposed how tying [[ in the editor should automatically add closing brackets and put the caret in between, as is done in some other software. Is this possible? I.e to trigger an action when a string is typed in the edtior, including controlling the position of the caret?

The background is that, for the TitlePicker (and many other similar tools to come) it is problematic to identify a string segment via regexp when it is unclear what distinguishes the end of the segment - for example to know if [[this tiddler title ends here or here or here... as there are no closing brackets. The problem would totally solved if the closing brackets were automatically added as soon as [[ was typed and one continued to type between the bracket pairs.

<:-)

Jeremy Ruston

unread,
May 2, 2020, 8:04:11 AM5/2/20
to TiddlyWikiDev
Hi Mat

In attempting to make a TitlePicker, a fellow tiddleur proposed how tying [[ in the editor should automatically add closing brackets and put the caret in between, as is done in some other software. Is this possible? I.e to trigger an action when a string is typed in the edtior, including controlling the position of the caret?

The background is that, for the TitlePicker (and many other similar tools to come) it is problematic to identify a string segment via regexp when it is unclear what distinguishes the end of the segment - for example to know if [[this tiddler title ends here or here or here... as there are no closing brackets. The problem would totally solved if the closing brackets were automatically added as soon as [[ was typed and one continued to type between the bracket pairs.

Yes, that sounds like an interesting experiment, and I think feasible.

Best wishes

Jeremy


<:-)


--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/5d2a0412-d7eb-4dc5-b7b1-5e42a3a3c526%40googlegroups.com.

Vaughn Papenhausen

unread,
May 2, 2020, 11:56:23 AM5/2/20
to TiddlyWikiDev
One place to look for ideas might be this: the CodeMirror editor plugin has an addon that lets it autocomplete brackets, so perhaps you can take ideas from it? See here: 1https://codemirror.net/doc/manual.html#addon_matchbrackets

Mat

unread,
May 2, 2020, 3:35:26 PM5/2/20
to TiddlyWikiDev
Vaughn Papenhausen wrote:
One place to look for ideas might be this: the CodeMirror editor plugin has an addon that lets it autocomplete brackets, so perhaps you can take ideas from it? See here: 1https://codemirror.net/doc/manual.html#addon_matchbrackets

Thanks Vaughn. I'm thinking the function just below that one looks more useful, i.e https://codemirror.net/doc/manual.html#addon_closebrackets
Here's the demo for it where you type in e.g [ to get []. Really nice! And it seems to be exactly what is needed.

<:-)

 

Vaughn Papenhausen

unread,
May 2, 2020, 3:40:41 PM5/2/20
to TiddlyWikiDev
Haha that's the one I meant lol! I must have gotten them mixed up. Anyway, I hope it works for you.

Mat

unread,
May 2, 2020, 3:43:57 PM5/2/20
to TiddlyWikiDev
Vaughn Papenhausen wrote:
Anyway, I hope it works for you.

Well, I can't js code so hopefully some of the big boys can help out... and then I'll do the wikitext coding! 

<:-)
Reply all
Reply to author
Forward
0 new messages