VScode?

Posted on
  • This might have already been asked but is there anyway I can use vscode for Espruino or are we stuck with the web ide?

  • Yes - you just install the Espruino command-line app from https://www.npmjs.com/package/espruino

    Worth noting that on Windows it can be tricky trying to get Bluetooth Low Energy comms to work nicely from Node.js. It's one of the reasons the Web IDE really helps.

    If it were possible to detect changes in a file using a web file API then we could make some changes and it'd be possible for you to use the Web IDE as just a terminal/upload tool for whatever editor you wanted - but it seems it isn't right now

  • If it were possible to detect changes in a file using a web file API then we could make some changes and it'd be possible for you to use the Web IDE as just a terminal/upload tool for whatever editor you wanted - but it seems it isn't right now

    With which browser did you test this behavior? I think I used an application a few years ago which detected changes in a textfile on disk and it only worked w/ chrome.

  • With which browser did you test this behavior?

    I just did a quick search to see if it was possible and it seemed from the results that it wasn't. From a Chrome Web App it might be but they are getting deprecated soon.

    I don't profess to be an expert though. If you can find some code that works - or even better if you could modify the Web IDE at https://github.com/espruino/EspruinoWebI­DE to make it work then it'd be amazing!

  • The Website where I saw it working is http://www.pokerstoker.com. Its not an Chrome Web App. It loads a HandHistory.txt file. And everytime a new hand is added to the file the view updates.

    ATM I just want to code my Bangle to fit my needs, maybe after that I will take a look at the IDE :)

  • So I did some research. We could use the new "File System Access" API -> https://developer.mozilla.org/en-US/docs­/Web/API/FileSystemFileHandle

    The WebApi would need to poll for filechanges tho. After a set interval it would check if lastModified of the file changed and would reload if needed.

    Would that solution be accepted?

  • Thanks! That sounds great!

    Are you able to implement it? It seems like you've got two options...

    • Add a plugin (https://github.com/espruino/EspruinoWebI­DE/blob/master/js/plugins/_examplePlugin­.js) that displays a new 'watch file' button. Once the file is selected you update the editor contents (Espruino.Core.Code.set...) and callEspruino.Core.Code.getEspruinoCode(Espru­ino.Core.CodeWriter.writeToEspruino);` to write the data.
    • Actually modify the existing 'open' button to use the new API. It could have a drop-down like the upload button does at the moment to choose whether to watch the file for changes or not.

    The benefit of the 'open' modification is we could actually get save working nicely too (without a popup each time) which would be a really nice addition

  • https://github.com/espruino/EspruinoWebI­DE/pull/254 ;)

    not sure if you approve async functions or destructuring or any of the other stuff I used. Disclaimer: it's not very thoroughly tested.

  • Thanks! Sorry for the delay - I'll take a look when I get through all my messages after the holiday!

  • More details on https://github.com/espruino/EspruinoWebI­DE/pull/254, but if you try the development IDE (for now) at https://espruino.github.io/EspruinoWebID­E...

    open a file (which is as normal), then click the down-arrow to choose what happens. If you choose the 'upload' option then every time the file changes, the editor contents will be reloaded and the file sent to the device - which should be great for integration with VSCode/etc.

    You can also pull the middle of the window over, so all you see is the terminal window each time.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

VScode?

Posted by Avatar for user130486 @user130486

Actions