Workbench icon indicating copy to clipboard operation
Workbench copied to clipboard

Refactor languages support

Open sonnyp opened this issue 2 years ago • 5 comments

See https://github.com/sonnyp/Workbench/issues/17

In https://github.com/sonnyp/Workbench/pull/38 - we added Vala support

It was done quickly and with the least possible changes to prove the case. However, adding new languages shouldn't require fiddling in multiple JS files – let's refactor to make it simpler and scale.

sonnyp avatar May 19 '22 16:05 sonnyp

JS API should probably be something like

const my_favorite_lang = Language({
  compile_cmd: ...,
  extension: '.rs',
  run_cmd: ...
  name: 'Rust',
  id: 'rust',
  format_cmd:
  bookmarks: []
});

and that's all there would be to do in JS side

sonnyp avatar May 19 '22 16:05 sonnyp

I would have the compilation handled by a js function that is passed to the object, and that also submits the compiled binary/whatever to the previewer themself. That is why it should also have access to the Previewer js instance with the convenience functions of submitting the dbus commands. That should be controlled by the language, because each language could do something different. The Vala "compiler" would send a loadable module to the previewer, whereas the python "compiler" would send the python code as a string to the previewer probably, which would be a different dbus method.

Also the sourceview highlighting type "xml" or "blueprint", etc. should be given to Language().

lw64 avatar May 19 '22 17:05 lw64

Any chance this could have gtk-rs support?

VarLad avatar Nov 20 '22 16:11 VarLad

Yes, if someone is willing to commit to implement Rust support , I'm happy to do the refactor work soon.

sonnyp avatar Nov 21 '22 13:11 sonnyp

python would be really nice as well. I would happily help implement it

henrique-smr avatar Feb 18 '23 14:02 henrique-smr