You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hi,

    Popups are a bit tricky because as the code runs on Espruino, there's not a clear path from Espruino back to the UI. You could however do something like console.log("+++Your Error"); on the code that is sent to Espruino, and then you can detect that text arriving in terminal.js and can use it to show off the alert.

    It's also made a bit more difficult in chrome web apps because for some reason you're banned from using window.alert. You'd have to use the popup window code that's in the IDE (it's best to look at how other code does it).

    In a way it might be nicer to make terminal.js handle the VT100 character colour commands, and then you could just display the message in the terminal.

    As far as accepting input in the terminal, if you're trying to do that in Espruino itseslf you've got to move the original terminal out of the way, and write your own handler for characters:

    function getInput() {
     echo(0);
     LoopbackA.setConsole();
     line = "";
     USB.onData(function(d) {
      if ((line!="" && d.data=="\r") || d.data=="\3") {
       USB.onData(undefined);
       USB.setConsole();
       echo(1);
       console.log("Got text "+line);
      } else if (d.data!="\r")
        line += d.data;
     });
    }
    

    Note the "\3" check, which checks for Ctrl+C so you can break out of it.

    For mouse input, you'd have to check on the Blockly forums. There are already handlers in terminal.js (the terminal area) for mouse clicks and stuff, so you could potentially add something to those... Maybe even sending the VT100 escape codes, which you could then detect on Espruino with the USB.onData handler (like above).

About

Avatar for Gordon @Gordon started