Avatar for JumJum

JumJum

Member since Oct 2013 • Last active Jul 2021
  • 155 conversations
  • 788 comments

Most recent activity

  • in General
    Avatar for JumJum

    Just checked an idea for "format only the selected code" in my environment.
    At the end it is extremly easy to implement.
    Should be similiar for prettier

    	var code = Espruino.Core.EditorJavaScript.getCode()­;
    	var selected = Espruino.Core.EditorJavaScript.getSelect­edCode();
    	if(selected) code = code.replace(selected,js_beautify(select­ed,options) + "\n"); //had to add linefeed for beautify, don't know wether prettier  needs this
    	else code = js_beautify(code,options);
    	Espruino.Core.EditorJavaScript.setCode(c­ode);
    
    
  • in General
    Avatar for JumJum

    @neshanjo great to see what you did. Your point of adding setCursor, great idea.
    Looking forward to see a pull request for github ;-)

    Thanks for your nice feedback. Applause is what keeps artists going ;-)

    Beautifier was the first I used and it worked.
    At the end, using prettier or beautify does'nt matter (to me).
    BTW, could it be an option/help/possible to use prettier for selected code only ?

  • in General
    Avatar for JumJum

    @MaBe
    thanks but it would need some more work.
    For example:

    • add settings page
    • add options based on settings
    • is there a better tool, prettier for example ?
    • find a better icon
      My intention was to give a starting point ;-)
  • in General
    Avatar for JumJum

    @neshanjo
    A simple example how to add a formatter.
    I used beautifier, because its so easy to add.
    And it does not need an internet connection.
    Steps:

    • add a file to js/plugins with following code
    • add a script tag in main.html to the new plugin
    • add beautify folder in js/libs
    • add beautify-file from github into this new folder
    • add script tag in main.html to beautify-file

      "use strict";
      (function(){
      var iconFolder;
      function init() {
        showIcon();
      }
      function showIcon(){
        iconFolder = Espruino.Core.App.addIcon({
          id: 'formatCode',icon: 'snippets',title: 'Prettyfie',order: 510,
          area: { name: "code",position: "top"},
          click: prettyfie
       });
      }
      function prettyfie(){
         var code = Espruino.Core.EditorJavaScript.getCode()­;
         code = js_beautify(code);
         Espruino.Core.EditorJavaScript.setCode(c­ode);
      }
      Espruino.Plugins.FormatCode = {
        init : init,  
      };
      }());
      
      

      ```

  • in Bangle.js
    Avatar for JumJum

    Implementation of BLE on ESP32 became incomplete.
    Know this because most of it was done by me.
    Espressif changed ESP-IDF and specially BLE a lot with each new (sub) version.
    Last not least there was no support by Espressif for Espruino over the years.
    Therefore my decision was to concentrate on other targets.

  • in JavaScript
    Avatar for JumJum

    Defining the property would loose documentation.
    And it would not be available in jswrapper.c, whatever this means at the end.
    AFAIK, calling jswrap_object_defineProperty expects a JS function for get/set, correct ?
    Let me give another example, getPixel and setPixel, myGraphics.pixel(x,y) = newColor and var pixelcol = myGraphics.pixel(x,y) , how can I do this ?
    At the end, there are lot of ways to do this, but to me it looks more elegant to set/get :-)

    Line 452 in jswrap_object.c has this in JSON-definition for defineProperty
    And it takes its way to reference you sent, see note at the end
    Note: configurable, enumerable, writable, get, and set are not implemented and will be ignored.

  • in JavaScript
    Avatar for JumJum

    To take Graphics as an example only.
    My intention is not to change Graphics. But in myownClass it would be nice to have.
    We have functions to set bgColor and to get bgColor.
    Is there a way to define a writeable property in jswrap_xxx file ?
    So instead of using myGraphics.setBgColor(newColor); it would be myGraphics.BgColor = newColor;
    And instead of var x = myGraphics.getBgColor(); it would be var x = myGraphics.BgColor;
    Following API-description for Object.defineProperty, writeable and get/set are not supported.
    Hmmm, but in jswrap_object_defineProperty get and set are used to create getter and setter

  • in Espruino Work
    Avatar for JumJum

    Take a closer look at this:

    http://www.espruino.com/Extending+Esprui­no+2
    http://www.espruino.com/Extending+Esprui­no+1

    another example how to build extensions is here
    https://github.com/jumjum123/EspruinoExt­ensions/tree/master/General/LEDBoard
    There are some unusual args used for make

Actions