acarril / StataLinux

Sublime Text 3 plugin that adds support for Stata (all versions) in Linux.
MIT License
7 stars 2 forks source link

Suggestion #17

Open jibanes opened 3 years ago

jibanes commented 3 years ago

I would like to suggest to do without xdotool (and xstata entirely), just relying on stata 16.1+. The way I would see it is that Stata starts a python aiohttp server from within stata (non graphical is okay) and communicate back and forth from sublime to stata using this channel.

The aiohttp wrapper could have a POST http handler that accepts commands to be run (the Stata Python api allows arbitrary commands), prior to running a command it would do a "capture: log using /tmp/statalinuxEPOCHinMilliseconds, replace text", run the command and send the output as an HTTP answer to the POST query aforementioned; then delete ("log close _all" or such) the intermediary log file. Sublime would then display the result.

Edge cases and open questions:

Happy to write a stub that starts the aiohttp thread within Stata and expose it via HTTP; let me know; happy to do that. I'd make it synchronous so there wouldn't be "merged commands" or "merged outputs".

Let me know if it's something you'd like to work together on. Note: it's not very different from what the jupyter stata kernel does, see https://github.com/TiesdeKok/ipystata/blob/master/ipystata/ipystata_magic.py#L326 at the difference that it can pretty print a few different objects.

acarril commented 3 years ago

This would be super cool. I don't have enough time right now to work on it myself, but I'd be happy to collaborate on specifics if you took the lead.