From cce5a57fd05d92b66e7eb143cdf27f76ff706aac Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 16 Nov 2016 11:36:11 -0800 Subject: [PATCH] Added history to the commander. --- README.md | 14 ++++---------- scripts/commander.js | 22 +++++++++++++++++++++- scripts/keyboard.js | 2 ++ scripts/ronin.hint.js | 2 -- scripts/ronin.vector.js | 8 +++----- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7a83654..6bf26bc 100644 --- a/README.md +++ b/README.md @@ -41,10 +41,10 @@ $ ! ; Clear temporary storage | ! ; Remove all guides ``` -##Vector(SVG Path) +##Vector(SVG) ``` -+ M10 10 h 80 v 80 h -80 Z ; Draw a square outline -+ M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80 ; Draw a bezier ++ M10 10 h 80 v 80 h -80 Z ; Draw a square outline ++ M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80 ; Draw a bezier + M 100, 100 m -75, 0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0 ; Draw a circle ``` @@ -74,13 +74,7 @@ $ ! ; Clear temporary storage = ! ; Zoom 100% ``` -##Layers* -``` -# 3 ; Layer 3 -# ! ; Layer 1 -``` - -#Units* +#Units ``` 5 ; value: 5 5,7 ; position: 5x 7y diff --git a/scripts/commander.js b/scripts/commander.js index 9001a37..ae6cf4d 100644 --- a/scripts/commander.js +++ b/scripts/commander.js @@ -4,6 +4,7 @@ function Commander(element,element_input) this.element_input = element_input; this.cmd = null; this.storage = []; + this.storage_index = 0; this.show = function() { @@ -17,8 +18,28 @@ function Commander(element,element_input) this.element_input.value = ""; } + this.clear = function() + { + this.element_input.value = ""; + } + + this.next_cmd = function() + { + this.storage_index += this.storage_index < this.storage.length ? 1 : 0; + this.element_input.value = this.storage[this.storage_index] ? this.storage[this.storage_index] : ""; + } + + this.prev_cmd = function() + { + this.storage_index -= this.storage_index < 1 ? 0 : 1; + this.element_input.value = this.storage[this.storage_index]; + } + this.active = function(content) { + this.storage.push(content.join(" ")); + this.storage_index = this.storage.length; + var key = content[0]; content.shift(); var cmd = new Command(content); @@ -58,7 +79,6 @@ function Commander(element,element_input) ronin.vector.active(cmd); break; } - this.storage.push(content); this.hide(); } diff --git a/scripts/keyboard.js b/scripts/keyboard.js index 5fe2ca4..0c7777f 100644 --- a/scripts/keyboard.js +++ b/scripts/keyboard.js @@ -85,10 +85,12 @@ function Keyboard() this.key_arrow_up = function() { + commander.prev_cmd(); } this.key_arrow_down = function() { + commander.next_cmd(); } this.key_arrow_left = function() diff --git a/scripts/ronin.hint.js b/scripts/ronin.hint.js index 7e44b1a..46f4e78 100644 --- a/scripts/ronin.hint.js +++ b/scripts/ronin.hint.js @@ -13,7 +13,5 @@ function Hint(element) else{ this.element.style.display = "none"; } - - console.log(ronin.module); } } \ No newline at end of file diff --git a/scripts/ronin.vector.js b/scripts/ronin.vector.js index 454ad60..01e7d0c 100644 --- a/scripts/ronin.vector.js +++ b/scripts/ronin.vector.js @@ -10,18 +10,16 @@ function Vector() this.active = function(cmd) { - var path = new Path2D(cmd.content.join(" ")); - - console.log(ronin.size); - ronin.canvas.context().lineCap="round"; ronin.canvas.context().lineWidth = ronin.brush.size; ronin.canvas.context().strokeStyle = ronin.brush.color.rgba(); - ronin.canvas.context().stroke(path); + ronin.canvas.context().stroke(Path2D(cmd.content.join(" "))); } this.hint = function(cmd) { return "Vector: " } + + // M100,100 h200 a20,20 0 0 1 20,20 v200 a20,20 0 0 1 -20,20 h-200 a20,20 0 0 1 -20,-20 v-200 a20,20 0 0 1 20,-20 z } \ No newline at end of file