Thursday, November 19, 2020

Re: best library for data forms entry in vim

You know, the more I'm thinking about it, the more I think vim needs an internal templating system. 

As it stands, I get how this is done in vim now - you use vimscript to create the template for you, in other words you need to program the look and feel. It has a lot in common with approaches like asciimatics in python (https://github.com/peterbrittain/asciimatics). 

This is IMO a lot more difficult than it need be. For example, leandro posted a todo application for me to see how its done (https://github.com/freitass/todo.txt-vim) and I looked at it - about 250 lines of vimscript code to get the formatting where you can enter in todo lines. I'd rather have vim itself do the formatting for me, and just worry about the actual logic behind it. So that app would become

todo.tmpl

----
Todo
----
Done                                                                    Name                                                                                       Status
[[ {{ type=box, name=_donebox align=left }} {{ type=string[35], name = _task, align=left, color=red }} {{type=string[35], name=_status, align=left }} ]]



where you could define the elements you want in your application inline and attach pieces of code to them to do any variable manipulation. Arrays of lines could be designated by  [[.   ]],  Any user input could directly map onto python or perl in the form of python/perl arrays, or perhaps arrays of hashes - and each element would have its own coderef associated with it if you needed to process the output in any way.

I've mocked this up by making vim separately called from perl, memoizing all the variables that are defined in the template, and then responding to user input by hack - the user needs to close the actual vim session in order for perl to actually do the recalculation and realignment. This works (after a fashion) but it really is a hack and wouldn't be usable for what i want to do. But i'm hoping that perhaps a templating system could make its way into a newer version of vim.

On Thursday, November 19, 2020 at 3:30:17 AM UTC-6 Shlomi Fish wrote:
Hi Gabriele,

On Wed, 18 Nov 2020 09:36:30 +0100
Gabriele <gb...@tiscali.it> wrote:

> On 18/11/2020 9.14, Shlomi Fish wrote:
> > I can recommend *against* using m4, which although part of the POSIX
> > standard, is limited and vile in both syntax and behaviour. I have a page
> > on my site with a roundup of similar text-processing tools and links
> > including preprocessors, and template systems:
> >
> > https://www.shlomifish.org/open-source/resources/text-processing-tools/
>
> Well as we're at it I can strongly recommend against GPP, which I see
> listed first on that page.
>
> I haven't had experience with the linked logological.org version though,
> it's not entirely impossible that they improved it a lot.
>

Thanks for the information. I should also note that the distinction between
template systems and preprocessors is often blurred, similarly to the
distinction between text editors and IDEs. I used to list m4 first in that
section, but someone thought I somehow recommend or endorse it due to that.

> Of course this has still nothing to do with what the thread author wanted
>

Right, I've only replied due to
https://explainxkcd.com/wiki/index.php/386:_Duty_Calls .


--

Shlomi Fish https://www.shlomifish.org/
https://youtu.be/GoEn1YfYTBM - Tiffany Alvord - "Fall Together"

Every successful open source project will eventually spawn a sub‐project.
https://www.shlomifish.org/humour/fortunes/osp_rules.html

Please reply to list if it's a mailing list post - https://shlom.in/reply .

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/153a5cd7-e7af-4547-8a97-80ea57a3a00cn%40googlegroups.com.

No comments: