VimArea - Day 25 - VA_REC
VA_REC stands for VimArea Recorder. It records a live session and could replay it later.

Using command :varec will start / end a recording session. Exported data can be replayed using  VimArea.demo( data ); .

Concept

The concept of this feature was easy. Just record all the intervals and what keys are pressed for the recording bit. Then replay them by firing KeyEvents to the VimArea.

But what takes my time is to determine how data are recorded. And to ensure the results are accurately replayed ( which I am considering using it for automated test ).

Here's the list of structure I've thought of:
[ [ 100, "b" ], [ 200, "f" ], [ 10, "i" ] ... ]
func( "abcGhiijkll ..", [ 100, 200, 23, 33 ... ] )
[ 100, 75, 94, 941, 596, 495, 556 ... ]
Option 1 has the highest readability, and users can directly edit them. But parse "b", "c" is not a good idea when keys become "C-A", "S-H", etc.
Option 2 tried to make them easier to parse.
Option 3 is easiest to parse but have 0 readabilities.

I toke option 3 because fuck humans ... well not really, I am sacrificing readabilities for option 3 because of the following reasons:
- This is the simplest structure. Can easily transform to different format / language / syntax. So it facilitates when writing a converter.
- Compactness
- Can safely transfer via various protocols. Didn't violate html formats. You can even strip off the [] brackets if needed.
- Very easy to parse ( lesser codes, low times cost )
- People don't actually edit sessions because it generally mess up the entire sequence

Difficulties

There are some difficulties to figure out where to inject key recorder as it might mess up the user input.

Namespace, Class and Scopes concerns

This is similar to creating a custom plugin. So I should put it under Components.Vim.Actions namespace with limited capabilities. i.e. The Control class within the VimArea is private and local to constructor only. Even VimArea.demo() itself cannot access it. So to fire custom events I'll have to stop the existing listeners and have another Controls instance to handle the inputs. This also effectively stopping user inputs when replaying sessions.

Displaying recorded session data

Initially I used window.prompt to have the session exporting inside a popup window. But then I figure a popup window is very unfriendly since it will just block the entire page and somewhat stops script from running / page from rendering. So I made a small features that can flip the window to display any texts and partially revert controls back to the original textarea. Giving instructions and having data automatically highlighted is also a good idea too!

I am also thinking this could also be used as a container to paste text inside and have functions bind to that input. But this is out of the original Vim's functionalities which users might not like or even know it. So a flip screen is the primary purpose I presume.

Articles in the series


Useful Links

Project home | Demo
Tag(s): vim BotanJS
Profile picture
斟酌 鵬兄
Tue Jan 31 2017 03:38:44 GMT+0000 (Coordinated Universal Time)
Last modified: Tue Jan 31 2017 03:41:58 GMT+0000 (Coordinated Universal Time)
Comments
No comments here.
Do you even comment?
website: 
Not a valid website
Invalid email format
Please enter your email
*Name: 
Please enter a name
Submit
抱歉,Google Recaptcha 服務被牆掉了,所以不能回覆了