Improved Terminal

This commit is contained in:
Devine Lu Linvega 2017-05-21 14:37:04 -10:00
parent a9f76f6100
commit 748fec89f4
9 changed files with 23 additions and 57 deletions

View File

@ -1,4 +1,3 @@
frame.resize 300x300 frame.resize 300x300
frame.select main frame.select main
layer.fill #ff0000 layer.fill #ff0000
@ -12,3 +11,5 @@ type.write 38,262 "RONIN"
type.write 38,252 "B08" type.write 38,252 "B08"
brush:color #000000 brush:color #000000
brush:size 10 brush:size 10
path:line_width 20
path:line_color #999999

View File

@ -117,5 +117,6 @@ function Ronin()
} }
rawFile.send(null); rawFile.send(null);
ronin.widget.update(); ronin.widget.update();
ronin.terminal.update();
} }
} }

View File

@ -14,7 +14,10 @@ function Cursor(rune)
this.update = function(event = null) this.update = function(event = null)
{ {
if(event && event.altKey == true && event.shiftKey == true){ if(ronin.terminal.cmd().module()){
this.set_mode(ronin.terminal.cmd().module());
}
else if(event && event.altKey == true && event.shiftKey == true){
this.set_mode(ronin.frame.active_layer); this.set_mode(ronin.frame.active_layer);
} }
else if(event && event.altKey == true){ else if(event && event.altKey == true){

View File

@ -15,7 +15,7 @@ function Frame(rune)
this.install = function() this.install = function()
{ {
this.blink(); this.blink();
this.select(new Command("background")); this.select(new Command("frame.select main"));
// Canvas // Canvas
var starting_canvas = new Rect(); var starting_canvas = new Rect();
@ -62,7 +62,7 @@ function Frame(rune)
{ {
if(preview){ return; } if(preview){ return; }
var layer_name = params.content; var layer_name = "main";
if(!ronin.frame.layers[layer_name]){ if(!ronin.frame.layers[layer_name]){
this.add_layer(new Layer(layer_name)); this.add_layer(new Layer(layer_name));
} }

View File

@ -11,7 +11,6 @@ function Overlay(rune)
this.draw = function(position,rect) this.draw = function(position,rect)
{ {
if(!this.layer){ this.create_layer(); this.layer.is_blinking = true; } if(!this.layer){ this.create_layer(); this.layer.is_blinking = true; }
this.get_layer().clear();
if(!position){ position = new Position("0,0"); } if(!position){ position = new Position("0,0"); }
@ -163,45 +162,9 @@ function Overlay(rune)
this.context().closePath(); this.context().closePath();
} }
// Cursor this.clear = function()
this.live_draw_from = null;
this.mouse_down = function(position)
{ {
ronin.overlay.clear(); this.layer.remove(this);
ronin.overlay.draw_pointer(position);
this.live_draw_from = position;
// ronin.terminal.input_element.value = "| "+this.live_draw_from.render();
}
this.mouse_move = function(position)
{
if(this.live_draw_from === null){ return; }
ronin.overlay.clear();
var rect = new Rect();
rect.width = position.x - this.live_draw_from.x;
rect.height = position.y - this.live_draw_from.y;
ronin.overlay.draw_rect(this.live_draw_from,rect);
// ronin.terminal.input_element.value = "| "+this.live_draw_from.render()+" "+rect.render();
ronin.terminal.update_hint();
}
this.mouse_up = function(position)
{
this.live_draw_from = null;
// ronin.terminal.input_element.focus();
}
// Widget
this.widget_cursor = function()
{
return "Guide";
} }
this.key_escape = function() this.key_escape = function()

View File

@ -27,7 +27,7 @@ function Path(rune)
context.stroke(new Path2D(cmd.values())); context.stroke(new Path2D(cmd.values()));
context.closePath(); context.closePath();
if(!preview){ this.coordinates = []; this.last_pos = null; } if(!preview){ this.coordinates = []; this.last_pos = null; if(!preview){ this.layer.remove(this); } }
return 1, preview ? "preview" : "ok"; return 1, preview ? "preview" : "ok";
} }

View File

@ -7,19 +7,16 @@ function Source(rune)
this.add_method(new Method("save",["name","rect","format"])); this.add_method(new Method("save",["name","rect","format"]));
this.add_method(new Method("load",["path","position","rect"]),"Add point"); this.add_method(new Method("load",["path","position","rect"]),"Add point");
this.load = function(params,preview = false) // source.load ../assets/todo.jpg 200x200 40,40 this.load = function(params,preview = false) // source.load /01.jpg 0,0 100x100
{ {
if(!params.filepath()){ return 0, "Path?"; } if(!params.filepath()){ return 0, "Path?"; }
if(!params.rect()){ return 0,"Rect?"; } if(!params.rect()){ return 0,"Rect?"; }
this.get_layer(true).clear(); ronin.overlay.draw_rect(position,params.rect());
var target_layer = preview ? this.get_layer(true) : ronin.frame.active_layer; if(preview){ return; }
ronin.overlay.get_layer(true).clear();
var position = params.position() ? params.position() : new Position("0,0"); var position = params.position() ? params.position() : new Position("0,0");
ronin.overlay.draw_rect(position,params.rect());
base_image = new Image(); base_image = new Image();
base_image.src = "../assets/"+params.filepath().path; base_image.src = "../assets/"+params.filepath().path;
@ -38,12 +35,12 @@ function Source(rune)
width = isNaN(width) && height > 0 ? (height*base_image.naturalWidth)/base_image.naturalHeight : width; width = isNaN(width) && height > 0 ? (height*base_image.naturalWidth)/base_image.naturalHeight : width;
height = isNaN(height) && width > 0 ? (width*base_image.naturalHeight)/base_image.naturalWidth : height; height = isNaN(height) && width > 0 ? (width*base_image.naturalHeight)/base_image.naturalWidth : height;
target_layer.context().drawImage(base_image, position.x, position.y, width, height); ronin.frame.active_layer.context().drawImage(base_image, position.x, position.y, width, height);
} }
if(!preview){ ronin.overlay.get_layer(true).clear(); } ronin.overlay.clear();
return 1,"ok"; return 1,"Loaded "+params.filepath().path+" at "+position.render();
} }
this.save = function(params,preview = false) this.save = function(params,preview = false)

View File

@ -41,6 +41,7 @@ function Terminal(rune)
} }
if(setting){ if(setting){
module.settings[setting] = command.values(); module.settings[setting] = command.values();
this.log(new Log(module,setting+" = "+command.values()));
} }
this.hint_element.innerHTML = ""; this.hint_element.innerHTML = "";
this.input.value = ""; this.input.value = "";
@ -48,7 +49,8 @@ function Terminal(rune)
this.update = function(value = null) this.update = function(value = null)
{ {
this.input.value = value ? value : this.input.value; if(value){ this.input.value = value; this.input.focus(); }
var command = this.cmd(); var command = this.cmd();
var module = command.module(); var module = command.module();
var method = command.method(); var method = command.method();
@ -58,7 +60,6 @@ function Terminal(rune)
} }
this.hint_element.innerHTML = "<span class='input'>"+this.input.value+"</span>"+(this.input.value ? " " : "")+(module ? module.hint(method) : this.hint(method)); this.hint_element.innerHTML = "<span class='input'>"+this.input.value+"</span>"+(this.input.value ? " " : "")+(module ? module.hint(method) : this.hint(method));
ronin.cursor.set_mode(module); ronin.cursor.set_mode(module);
this.input.focus();
} }
this.run_multi = function(lines) this.run_multi = function(lines)

View File

@ -23,7 +23,7 @@ function Type(rune)
target_layer.context().fillStyle = color; target_layer.context().fillStyle = color;
target_layer.context().fillText(text,position.x,position.y); target_layer.context().fillText(text,position.x,position.y);
if(!preview){ this.layer.clear(); } if(!preview){ this.layer.remove(this); }
return 1, "Wrote "+text+" at "+position.render(); return 1, "Wrote "+text+" at "+position.render();
} }