Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to vim api and context from a containing app #52

Open
pieper opened this issue Feb 23, 2024 · 1 comment
Open

Access to vim api and context from a containing app #52

pieper opened this issue Feb 23, 2024 · 1 comment

Comments

@pieper
Copy link

pieper commented Feb 23, 2024

What is an issue which you want to solve with your feature request?

We have a Qt-based desktop application for medical image processing and we use python code as a kind of macro language to extend and automate the program.

We'd like to be able to use a full featured editor integrated within the application to work with our python code.

Because our app uses Qt, we have the QWebEngine available and can embed a full featured web browser in our app, and we can call browser's javascript environment from python (e.g. like in this test code). Note that it's all asynchronous on both the javascript and python sides.

Recently the question came up about using a full editor to edit the python code in our app, and I found that I can run you vim.wasm code in our embedded browser:

https://discourse.slicer.org/t/directly-interacting-with-python-console/34455/7

But I don't see any easy way to get/set the contents of the editor window or be notified in javascript of vim events.

Describe the solution you'd like

I'd like to be able to start the vim.wasm context in the browser and then call a javascript function to populate the current text buffer for editing. Then I'd like to be able to use vim keystrokes to trigger javascript code in the browser that would make calls back to the python code, for example to send selection buffers to python for execution.

Additional context (if any)

I tried using the ?debug argument to set the vim object as window.vim and while I could access vim in the debug console I didn't see any way to set or get the values of the current vim buffers. It would be great if window.vim were available to interact with the browser's javascript enviornment.

Thanks in advance - I'm a long-time vi/vim user and having this available would make me very happy : )

@pieper
Copy link
Author

pieper commented Feb 23, 2024

Update: I was able to host your simple example page and run if from our app. From there I was able to access the vim object from the debug console by setting window.vim = vim in index.js.

But I'm still not seeing any way to get/set the contents of the vim buffer from javascript. Would this require changes to the vim c / wasm code?

Or maybe I can do it by sending synthetic keystrokes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant