From fac74b21f81e0ed5f88a18d12642bc0bc820635e Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 14 Jul 2019 13:54:30 +0900 Subject: [PATCH] Cmd+Shift+R to "reload run" --- desktop/sources/index.html | 1 + desktop/sources/scripts/library.js | 13 +++++++------ desktop/sources/scripts/ronin.js | 1 + examples/shapes.lisp | 24 ++++++++++++++++++++++-- examples/test1.lisp | 9 --------- 5 files changed, 31 insertions(+), 17 deletions(-) delete mode 100644 examples/test1.lisp diff --git a/desktop/sources/index.html b/desktop/sources/index.html index 985ea54..a775c71 100644 --- a/desktop/sources/index.html +++ b/desktop/sources/index.html @@ -41,6 +41,7 @@ ronin.controller.addRole('default', 'Edit', 'delete') ronin.controller.addRole('default', 'Edit', 'selectall') ronin.controller.add("default","Project","Run",() => { ronin.commander.run(); },"CmdOrCtrl+R"); + ronin.controller.add("default","Project","Reload Run",() => { ronin.source.revert(); ronin.commander.run(); },"CmdOrCtrl+Shift+R"); ronin.controller.add("default","Commander","Toggle",() => { ronin.commander.toggle(); },"CmdOrCtrl+K"); ronin.controller.commit(); ronin.install(document.body); diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 0fdfacc..29978d0 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -85,11 +85,11 @@ function Library (ronin) { this.range = (start, end, step = 1) => { let arr = [] if (step > 0) { - for(let i = start; i <= end ; i+= step) { + for (let i = start; i <= end; i += step) { arr.push(i) } } else { - for(let i = start; i >= end ; i+= step) { + for (let i = start; i >= end; i += step) { arr.push(i) } } @@ -212,13 +212,14 @@ function Library (ronin) { // Generics this.echo = (...args) => { - console.log(args.reduce((acc, val) => { return acc + val + ' ' }, '')) + const msg = args.reduce((acc, val) => { return acc + val + ' ' }, '') + ronin.log(msg) return args } - this.print = (arg) => { - console.log(arg) - return arg + this.print = (msg) => { + ronin.log(msg) + return msg } this.str = (...args) => { diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index 90e7700..7cf3dd4 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -49,6 +49,7 @@ function Ronin () { } this.log = function (msg) { + console.log(msg) this.commander.setStatus(msg) } diff --git a/examples/shapes.lisp b/examples/shapes.lisp index cbe07a4..c42747a 100644 --- a/examples/shapes.lisp +++ b/examples/shapes.lisp @@ -1,4 +1,24 @@ ; Shapes -( - (stroke (circle (div (of (frame) "w") 2) (div (of (frame) "h") 2) 100) 2 "red")) \ No newline at end of file +((clear) + + ; variables + (def center-w (div (of (frame) "w") 2)) + (def center-h (div (of (frame) "h") 2)) + (def rad (div (of (frame) "h") 4)) + + ; draw circle + (stroke + (circle center-w center-h rad) 2 "red") + + ; draw rect + (stroke + (rect + (sub center-w rad) (sub center-h rad) center-h center-h) 2 "red") + + ; draw line + (stroke + (line + (pos (sub center-w rad) center-h) + (pos (add center-w rad) center-h))) + ) \ No newline at end of file diff --git a/examples/test1.lisp b/examples/test1.lisp deleted file mode 100644 index abb7834..0000000 --- a/examples/test1.lisp +++ /dev/null @@ -1,9 +0,0 @@ -; test file - -((clear) - (stroke (rect 15 15 120 80) 2 "red") - (fill (rect 30 30 120 80) "#72dec2") - (clear (rect 45 45 45 45)) - (clone (rect 0 0 200 200) (rect 100 100 200 200)) - (stroke (line (pos 15 15) (pos 200 200)) 10 "red") -) \ No newline at end of file