Wednesday | 04 DEC 2024
[ previous ]
[ next ]

Adding Vim Buffer to EVA

Title:
Date: 2024-02-03
Tags:  EVA, BASIC

Currently pasting in my editor is a bit of a pain. A large body of text that is copy pasted will lose the formatting and take a hot second to input everything. I'm not sure why my editor loses the formatting but I know why the input is slow. In general my input loop to process keystrokes is slow. Luckily I type slow enough that it doesn't bother me but I know that others who type fast have an issue with my editor. The pasting is basically feeding each character into the editor so it's acting like a really fast typist.

Instead of fixing that issue, I instead decided to shell out to vim and paste there and then load that into the paste buffer. This way I can do some fancier stuff like formatting syntax that I don't have formatters for. For example javascript code currently can't be formatted by my editor. I normally paste it somewhere to temp file, format it properly, then open it in EVA and copy the text.

I've now made it part of the editor so that typing vim will result in opening a temp file and then you load all the data you want quickly. Once you exit, the contents of the file is loaded into the paste buffer and you then press p to paste the content.

   END ELSE IF EDITOR.COMMAND = 'vim' THEN
      PASTE.FILENAME = '/tmp/eva.paste.' : USER.NAME : '.txt'
*
      EXECUTE 'SH -c "vim ' : PASTE.FILENAME : '"'
*
      OPENSEQ PASTE.FILENAME TO PASTE.FLAT.FILE THEN
         READBLK YANKED.LINES FROM PASTE.FLAT.FILE, 100000000 THEN
            RELEASE PASTE.FLAT.FILE
            CLOSESEQ PASTE.FLAT.FILE
         END
         YANKED.LINES = YANKED.LINES[1,LEN(YANKED.LINES)-1]
         YANKED.LINES = CHANGE(YANKED.LINES,CHAR(10),@VM)
      END
*
      PRINT @(X.POS,Y.POS) :

This is the current iteration. I did have a few different versions where I had other keys to load data and I was using EVA to open the temp file and manually getting then content. I think the current method is a very simple addition to the editor to get proper copy paste. This is cheaty but it works.

This code is also only going to work on Linux machines and I'm presuming that vim is installed on them.

Incoming Links

  1. [ Ideas in 2024 ]