*
This commit is contained in:
@@ -4,7 +4,7 @@ function Brush(rune)
|
||||
|
||||
// this.parameters = {"offset":Position,"mirror":Rect,"angle":Angle,"reset":Bang};
|
||||
this.parameters = [];
|
||||
this.settings = {"color":"#ff0000","size":1};
|
||||
this.settings = {"color":"#ff0000","size":4};
|
||||
this.pointers = [new Pointer(new Position("0,0"))];
|
||||
|
||||
this.add_method(new Method("add_pointer",["Position"]));
|
||||
@@ -18,7 +18,8 @@ function Brush(rune)
|
||||
this.pointers.push(pointer);
|
||||
|
||||
ronin.terminal.log(new Log(this,"Added pointer at: "+pointer.offset.render()));
|
||||
ronin.widget.update();
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.passive = function(cmd)
|
||||
|
||||
@@ -12,7 +12,7 @@ function Pointer(offset = new Position(), color = new Color('000000'))
|
||||
{
|
||||
var ratio = 10/this.position().distance_to(this.position_prev[0]);
|
||||
ratio = ratio > 1 ? 1 : ratio;
|
||||
return ronin.brush.settings["size"].float * ratio;
|
||||
return parseInt(ronin.brush.settings["size"]) * ratio;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -130,6 +130,8 @@ function Cursor(rune)
|
||||
|
||||
this.update = function(event)
|
||||
{
|
||||
// this.set_mode(ronin.brush);
|
||||
return;
|
||||
if(event.altKey == true && event.shiftKey == true){
|
||||
this.set_mode(ronin.frame.active_layer);
|
||||
}
|
||||
@@ -157,10 +159,10 @@ function Cursor(rune)
|
||||
if(this.mode.constructor.name != Cursor.name){
|
||||
this.mode.mouse_from = this.position;
|
||||
this.mode.mouse_held = true;
|
||||
this.mode.mouse_down(this.position);
|
||||
if(!position.is_outside()){
|
||||
this.mode.mouse_down(this.position);
|
||||
}
|
||||
}
|
||||
|
||||
ronin.terminal.update_hint();
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
@@ -184,7 +186,7 @@ function Cursor(rune)
|
||||
this.mode.mouse_move(this.position,rect);
|
||||
this.mode.mouse_prev = this.position;
|
||||
}
|
||||
ronin.terminal.update_hint();
|
||||
// ronin.terminal.update_hint();
|
||||
}
|
||||
|
||||
this.mouse_up = function(position)
|
||||
@@ -195,15 +197,25 @@ function Cursor(rune)
|
||||
rect.width = this.position.x - this.mode.mouse_from.x;
|
||||
rect.height = this.position.y - this.mode.mouse_from.y;
|
||||
|
||||
if(!this.mode){ return; }
|
||||
|
||||
if(this.mode.constructor.name != Cursor.name){
|
||||
this.mode.mouse_up(this.position,rect);
|
||||
if(!position.is_outside()){
|
||||
this.mode.mouse_up(this.position,rect);
|
||||
}
|
||||
this.mode.mouse_held = false;
|
||||
}
|
||||
ronin.terminal.input_element.focus();
|
||||
ronin.terminal.update_hint();
|
||||
this.mode.mouse_from = null;
|
||||
}
|
||||
|
||||
this.release = function()
|
||||
{
|
||||
this.mode.mouse_held = false;
|
||||
this.mode.mouse_from = null;
|
||||
this.mode = ronin.brush;
|
||||
ronin.terminal.textarea.focus();
|
||||
}
|
||||
|
||||
this.widget = function()
|
||||
{
|
||||
return this.mode.mouse_mode();
|
||||
|
||||
@@ -3,34 +3,8 @@ function Default(rune)
|
||||
Module.call(this,rune);
|
||||
|
||||
this.hint = function()
|
||||
{
|
||||
if(ronin.terminal.input_element.value == ""){
|
||||
var s = "";
|
||||
for(module in ronin.modules){
|
||||
s += ronin.modules[module].constructor.name+" ";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
var candidates = [];
|
||||
|
||||
for(module in ronin.modules){
|
||||
for(method in ronin.modules[module].methods){
|
||||
candidates.push(module.toLowerCase()+"."+method);
|
||||
}
|
||||
}
|
||||
|
||||
var s = "";
|
||||
|
||||
for(candidate in candidates){
|
||||
if(candidates[candidate].indexOf(ronin.terminal.input_element.value) > -1){
|
||||
s += candidates[candidate]+" ";
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
// Cursor
|
||||
|
||||
@@ -17,7 +17,7 @@ function Eye(rune)
|
||||
{
|
||||
var imgData = ronin.frame.context().getImageData(position.x*2, position.y*2, 1, 1).data;
|
||||
var c = new Color();
|
||||
ronin.terminal.input_element.value = "* "+(c.rgb_to_hex(imgData));
|
||||
// ronin.terminal.input_element.value = "* "+(c.rgb_to_hex(imgData));
|
||||
ronin.terminal.update_hint();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,11 @@ function Frame(rune)
|
||||
this.install = function()
|
||||
{
|
||||
this.blink();
|
||||
var l = new Layer("background");
|
||||
this.add_layer(l);
|
||||
this.select_layer(l);
|
||||
|
||||
this.resize(new Command(["300x300"]));
|
||||
}
|
||||
|
||||
// Methods
|
||||
@@ -34,10 +39,10 @@ function Frame(rune)
|
||||
ronin.frame.element.height = this.settings["size"].height * 2;
|
||||
ronin.frame.element.style.width = this.settings["size"].width+"px";
|
||||
ronin.frame.element.style.height = this.settings["size"].height+"px";
|
||||
ronin.frame.element.style.marginLeft = -(this.settings["size"].width/2);
|
||||
ronin.frame.element.style.marginTop = -(this.settings["size"].height/2);
|
||||
|
||||
ronin.on_resize();
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.crop = function(params, preview = false)
|
||||
@@ -61,6 +66,8 @@ function Frame(rune)
|
||||
this.select_layer(this.layers[layer_name]);
|
||||
ronin.modules["layer"] = this.layers[layer_name];
|
||||
ronin.layer = this.layers[layer_name];
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.context = function()
|
||||
@@ -132,7 +139,7 @@ function Frame(rune)
|
||||
|
||||
this.mouse_move = function(position,rect)
|
||||
{
|
||||
ronin.terminal.input_element.value = "frame."+ronin.terminal.method_name+" "+this.mouse_from.render()+" "+rect.render()+" ";
|
||||
// ronin.terminal.input_element.value = "frame."+ronin.terminal.method_name+" "+this.mouse_from.render()+" "+rect.render()+" ";
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ function Layer(name,manager = null)
|
||||
ronin.frame.context().rotate(-angle*Math.PI/180);
|
||||
ronin.frame.context().restore();
|
||||
ronin.render.get_layer().clear();
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.translate = function(params,preview = false)
|
||||
@@ -62,6 +64,8 @@ function Layer(name,manager = null)
|
||||
this.clear();
|
||||
this.context().putImageData(data, params.position().x * 2, params.position().y * 2);
|
||||
ronin.overlay.get_layer(true).clear();
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.fill = function(params,preview = false)
|
||||
@@ -76,7 +80,8 @@ function Layer(name,manager = null)
|
||||
this.context().rect(position.x, position.y, rect.width, rect.height);
|
||||
this.context().fillStyle = params.color().hex;
|
||||
this.context().fill();
|
||||
ronin.terminal.log(new Log(this,"Filled layer "+this.name+": "+params.color().hex));
|
||||
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.rename = function(params, preview = false)
|
||||
@@ -150,7 +155,7 @@ function Layer(name,manager = null)
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
ronin.terminal.input_element.value = "layer."+ronin.terminal.method_name+" 0,0";
|
||||
// ronin.terminal.input_element.value = "layer."+ronin.terminal.method_name+" 0,0";
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
|
||||
@@ -163,7 +168,7 @@ function Layer(name,manager = null)
|
||||
ronin.overlay.draw_cross(position);
|
||||
ronin.overlay.draw_line(this.mouse_from,position);
|
||||
|
||||
ronin.terminal.input_element.value = "layer."+ronin.terminal.method_name+" "+offset.render();
|
||||
// ronin.terminal.input_element.value = "layer."+ronin.terminal.method_name+" "+offset.render();
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
|
||||
@@ -176,7 +181,7 @@ function Layer(name,manager = null)
|
||||
ronin.overlay.draw_circle(this.mouse_from);
|
||||
ronin.overlay.draw_line(this.mouse_from,position);
|
||||
|
||||
ronin.terminal.input_element.value = "layer."+ronin.terminal.method_name+" "+offset.render();
|
||||
// ronin.terminal.input_element.value = "layer."+ronin.terminal.method_name+" "+offset.render();
|
||||
ronin.terminal.passive();
|
||||
|
||||
// if(this.coordinates.length == 0){
|
||||
|
||||
@@ -26,6 +26,9 @@ function Magnet(rune)
|
||||
if(!rect){ rect = new Rect("20x20"); }
|
||||
if(!grid){ grid = new Position("4,4"); }
|
||||
|
||||
this.settings["grid"] = rect;
|
||||
this.settings["marker"] = grid;
|
||||
|
||||
if(rect.width < 5 || rect.height < 5){ return; }
|
||||
|
||||
var horizontal = ronin.frame.settings["size"].width/rect.width;
|
||||
|
||||
@@ -41,8 +41,7 @@ function Module(rune)
|
||||
this.update_setting = function(name,value)
|
||||
{
|
||||
this.settings[name] = value.content.join(" ");
|
||||
ronin.terminal.log(new Log(this,"Updated setting: "+name+", to "+this.settings[name]));
|
||||
ronin.widget.update();
|
||||
return 1, "ok";
|
||||
}
|
||||
|
||||
this.add_method = function(method)
|
||||
|
||||
@@ -180,7 +180,7 @@ function Overlay(rune)
|
||||
ronin.overlay.clear();
|
||||
ronin.overlay.draw_pointer(position);
|
||||
this.live_draw_from = position;
|
||||
ronin.terminal.input_element.value = "| "+this.live_draw_from.render();
|
||||
// ronin.terminal.input_element.value = "| "+this.live_draw_from.render();
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
@@ -194,7 +194,7 @@ function Overlay(rune)
|
||||
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.input_element.value = "| "+this.live_draw_from.render()+" "+rect.render();
|
||||
|
||||
ronin.terminal.update_hint();
|
||||
}
|
||||
@@ -202,7 +202,7 @@ function Overlay(rune)
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
this.live_draw_from = null;
|
||||
ronin.terminal.input_element.focus();
|
||||
// ronin.terminal.input_element.focus();
|
||||
}
|
||||
|
||||
// Widget
|
||||
|
||||
@@ -26,6 +26,8 @@ function Path(rune)
|
||||
context.strokeStyle = this.settings["line_color"];
|
||||
context.stroke(new Path2D(params.content));
|
||||
context.closePath();
|
||||
|
||||
return 1, preview ? "preview" : "ok";
|
||||
}
|
||||
|
||||
this.fill = function(params,preview = false)
|
||||
@@ -38,6 +40,8 @@ function Path(rune)
|
||||
|
||||
context.fillStyle = this.settings["fill_color"];
|
||||
context.fill(new Path2D(params.content));
|
||||
|
||||
return 1, preview ? "preview" : "ok";
|
||||
}
|
||||
|
||||
// Tools
|
||||
@@ -87,15 +91,15 @@ function Path(rune)
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
ronin.terminal.input_element.value = "path."+ronin.terminal.method_name+" "+this.create_path();
|
||||
ronin.terminal.input_element.value += "M"+position.render();
|
||||
// ronin.terminal.input_element.value = "path."+ronin.terminal.method_name+" "+this.create_path();
|
||||
// ronin.terminal.input_element.value += "M"+position.render();
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
ronin.terminal.input_element.value = "path."+ronin.terminal.method_name+" "+this.create_path();
|
||||
ronin.terminal.input_element.value += "L"+position.render();
|
||||
// ronin.terminal.input_element.value = "path."+ronin.terminal.method_name+" "+this.create_path();
|
||||
// ronin.terminal.input_element.value += "L"+position.render();
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
|
||||
@@ -121,7 +125,7 @@ function Path(rune)
|
||||
}
|
||||
}
|
||||
|
||||
ronin.terminal.input_element.value = "path."+ronin.terminal.method_name+" "+this.create_path();
|
||||
// ronin.terminal.input_element.value = "path."+ronin.terminal.method_name+" "+this.create_path();
|
||||
this.last_pos = position;
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
@@ -131,7 +135,7 @@ function Path(rune)
|
||||
if(this.layer){ this.layer.remove(this); }
|
||||
this.coordinates = [];
|
||||
this.last_pos = null;
|
||||
ronin.terminal.input_element.value = "";
|
||||
// ronin.terminal.input_element.value = "";
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,8 @@ function Source(rune)
|
||||
|
||||
this.load = function(params,preview = false) // source.load ../assets/todo.jpg 200x200 40,40
|
||||
{
|
||||
if(!params.filepath() || !params.rect()){ ronin.terminal.log(new Log(this,"Missing image path.","error")); return; }
|
||||
if(!params.filepath()){ return 0, "Path?"; }
|
||||
if(!params.rect()){ return 0,"Rect?"; }
|
||||
|
||||
this.get_layer(true).clear();
|
||||
|
||||
@@ -41,6 +42,8 @@ function Source(rune)
|
||||
}
|
||||
|
||||
if(!preview){ ronin.overlay.get_layer(true).clear(); }
|
||||
|
||||
return 1,"ok";
|
||||
}
|
||||
|
||||
this.save = function(params,preview = false)
|
||||
|
||||
@@ -2,11 +2,12 @@ function Terminal(rune)
|
||||
{
|
||||
Module.call(this,">");
|
||||
|
||||
this.element = null;
|
||||
this.input_element = document.createElement("input");
|
||||
this.element = document.createElement("div");
|
||||
this.textarea = document.createElement("textarea");
|
||||
this.hint_element = document.createElement("hint");
|
||||
this.logs_element = document.createElement("logs");
|
||||
this.menu_element = document.createElement("menu");
|
||||
this.status_element = document.createElement("status");
|
||||
|
||||
this.history = [];
|
||||
this.locks = [];
|
||||
@@ -15,120 +16,68 @@ function Terminal(rune)
|
||||
this.add_method(new Method("load",["path"]));
|
||||
this.add_method(new Method("display",["mini/hide/full"]));
|
||||
|
||||
this.load = function readTextFile(params, preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
|
||||
this.locks = [];
|
||||
|
||||
var file = "presets/"+params.content+'?'+new Date().getTime();
|
||||
var rawFile = new XMLHttpRequest();
|
||||
rawFile.open("GET", file, false);
|
||||
rawFile.onreadystatechange = function ()
|
||||
{
|
||||
if(rawFile.readyState === 4)
|
||||
{
|
||||
if(rawFile.status === 200 || rawFile.status == 0)
|
||||
{
|
||||
var allText = rawFile.responseText;
|
||||
ronin.terminal.query(allText);
|
||||
}
|
||||
}
|
||||
}
|
||||
rawFile.send(null);
|
||||
}
|
||||
|
||||
this.display = function(params,preview = false)
|
||||
{
|
||||
if(preview){ return; }
|
||||
this.element.setAttribute("class",params.content);
|
||||
}
|
||||
|
||||
// Module
|
||||
this.install = function(cmd)
|
||||
{
|
||||
this.element.appendChild(this.input_element);
|
||||
this.element.appendChild(this.textarea);
|
||||
this.element.appendChild(this.hint_element);
|
||||
this.element.appendChild(this.logs_element);
|
||||
this.element.appendChild(this.menu_element);
|
||||
this.element.appendChild(this.status_element);
|
||||
|
||||
this.hint_element.innerHTML = "_";
|
||||
this.status_element.innerHTML = "Ready.";
|
||||
this.textarea.value = "frame.select background\nframe.resize 400x400\nbrush:color #ff0000\nbrush.add_pointer 1,1\nbrush.add_pointer 2,2\nlayer.fill #A1A1A1\nrender.stencil #72dec2\ntype:size 50\ntype.write 50,150 \"RONIN\"\ntype:size 15\ntype.write 55,180 \"VER 0.1\""
|
||||
this.hint_element.innerHTML = "";
|
||||
|
||||
this.update_log();
|
||||
this.validation_timer();
|
||||
this.load("default.rin");
|
||||
this.timer = 20;
|
||||
}
|
||||
|
||||
this.active = function(cmd)
|
||||
this.timer = 0;
|
||||
this.history = "";
|
||||
|
||||
this.validation_timer = function()
|
||||
{
|
||||
this.timer += 1;
|
||||
setTimeout(function(){ ronin.terminal.validation_timer(); }, 100);
|
||||
this.validate();
|
||||
}
|
||||
|
||||
this.cmd = function()
|
||||
this.has_changed = function()
|
||||
{
|
||||
var content = this.input_element.value.trim();
|
||||
var key = content[0];
|
||||
var cmd = new Command(content.substring(1).trim().split(" "));
|
||||
return cmd;
|
||||
return ronin.terminal.history != ronin.terminal.textarea.value ? true : false;
|
||||
}
|
||||
|
||||
// Locks
|
||||
|
||||
this.lock = function(key)
|
||||
this.validate = function()
|
||||
{
|
||||
console.log("Added lock: ",key);
|
||||
this.locks.push(key);
|
||||
this.element.setAttribute("class","locked");
|
||||
}
|
||||
if(this.timer < 10){ return; }
|
||||
|
||||
this.unlock = function(key)
|
||||
{
|
||||
console.log("Removed lock: ",key);
|
||||
this.locks.splice(this.locks.indexOf(key), 1);
|
||||
|
||||
if(this.locks.length < 1){
|
||||
this.element.setAttribute("class","unlocked");
|
||||
if(ronin.terminal.has_changed() == true){
|
||||
ronin.terminal.run();
|
||||
}
|
||||
}
|
||||
|
||||
// Queue
|
||||
this.update_status();
|
||||
|
||||
this.queue = [];
|
||||
|
||||
this.query = function(input_str)
|
||||
{
|
||||
if(input_str.trim() == ""){ return; }
|
||||
if(this.locks.length > 0){ console.warn("Trying: "+input_str+", Locked: ",this.locks); return; }
|
||||
|
||||
this.lock("query");
|
||||
this.input_element.value = "";
|
||||
|
||||
if(input_str.indexOf(";") > 0){
|
||||
var parts = input_str.replace("\n","").split(";");
|
||||
for(id in parts){
|
||||
parts[id] = parts[id].replace("\n","").trim();
|
||||
}
|
||||
this.queue = parts;
|
||||
}
|
||||
else{
|
||||
this.queue = [];
|
||||
this.queue.push(input_str)
|
||||
}
|
||||
this.run();
|
||||
this.history = this.textarea.value;
|
||||
this.timer = 0;
|
||||
}
|
||||
|
||||
this.run = function()
|
||||
{
|
||||
if(!ronin.terminal.queue[0]){ this.unlock("query"); return; }
|
||||
|
||||
var entry = ronin.terminal.queue.shift();
|
||||
console.info(entry);
|
||||
active(entry);
|
||||
ronin.widget.update();
|
||||
|
||||
setTimeout(function(){ ronin.terminal.run(); }, 100);
|
||||
this.hint_element.innerHTML = "";
|
||||
var queue = ronin.terminal.textarea.value.split("\n")
|
||||
for(id in queue){
|
||||
this.hint_element.innerHTML += "<line><text class='input'>"+this.syntax_highlight(queue[id])+"</text><text class='status'>"+this.run_line(queue.length - id,queue[id])+"</text></line><br />";
|
||||
}
|
||||
}
|
||||
|
||||
function active(content)
|
||||
this.run_line = function(id,line)
|
||||
{
|
||||
ronin.terminal.log(new Log(ronin.terminal,content,"input"));
|
||||
var content = line;
|
||||
|
||||
if(content.trim() == ""){ return "~"; }
|
||||
if(content.trim()[0] == "~"){ return "~"; }
|
||||
|
||||
if(content.indexOf(".") > -1){
|
||||
var module_name = content.split(" ")[0].split(".")[0]
|
||||
@@ -146,133 +95,90 @@ function Terminal(rune)
|
||||
var parameters = content.split(" "); parameters.shift();
|
||||
var parameters = new Command(parameters);
|
||||
|
||||
if(id == 1){ ronin.cursor.set_mode(ronin[module_name]); }
|
||||
|
||||
if(ronin[module_name] && ronin[module_name][method_name]){
|
||||
ronin[module_name][method_name](parameters);
|
||||
return ronin[module_name][method_name](parameters,id == 1 ? true : false);
|
||||
}
|
||||
else if(ronin[module_name] && ronin[module_name].settings[setting_name]){
|
||||
ronin[module_name].update_setting(setting_name,parameters);
|
||||
return ronin[module_name].update_setting(setting_name,parameters);
|
||||
}
|
||||
else if(ronin["render"].collection[method_name]){
|
||||
ronin["render"].collection[method_name].render(parameters);
|
||||
return ronin["render"].collection[method_name].render(parameters);
|
||||
}
|
||||
else if(ronin[module_name]){
|
||||
ronin.terminal.log(new Log(ronin.terminal,"Unknown method: "+method_name));
|
||||
return 0, "Unknown Method";
|
||||
}
|
||||
else if(module_name == "render"){
|
||||
ronin.terminal.log(new Log(ronin.terminal,"Unknown filter: "+method_name));
|
||||
return 0, "Unknown Filter";
|
||||
}
|
||||
else{
|
||||
ronin.terminal.log(new Log(ronin.terminal,"Unknown module: "+module_name));
|
||||
return 0, "Unknown Module";
|
||||
}
|
||||
return 0, "Unknown";
|
||||
}
|
||||
|
||||
this.module_name = null;
|
||||
this.method_name = null;
|
||||
this.method_params = null;
|
||||
|
||||
this.passive = function()
|
||||
this.syntax_highlight = function(line)
|
||||
{
|
||||
var content = this.input_element.value;
|
||||
var parts = content.split(" ");
|
||||
var key = parts.shift();
|
||||
|
||||
this.module_name = key.split(".")[0];
|
||||
this.method_name = key.indexOf(".") > -1 ? key.split(".")[1] : null;
|
||||
this.method_params = new Command(parts);
|
||||
|
||||
if(ronin[this.module_name]){
|
||||
ronin.cursor.set_mode(ronin[this.module_name]);
|
||||
if(ronin[this.module_name][this.method_name]){
|
||||
ronin[this.module_name][this.method_name](this.method_params,true);
|
||||
}
|
||||
}
|
||||
else{
|
||||
ronin.cursor.set_mode();
|
||||
}
|
||||
|
||||
this.hint(content);
|
||||
return line;
|
||||
}
|
||||
|
||||
// Hint
|
||||
|
||||
this.update_hint = function(content = this.input_element.value)
|
||||
this.update_active_line = function(new_line)
|
||||
{
|
||||
var module_name = content.indexOf(".") > -1 ? content.split(" ")[0].split(".")[0] : content.split(" ")[0];
|
||||
var lines = this.textarea.value.split("\n");
|
||||
|
||||
if(ronin[module_name]){
|
||||
this.hint_element.innerHTML = this.pad(content)+ronin[module_name].hint(content.replace(module_name+".",""));
|
||||
}
|
||||
else{
|
||||
this.hint_element.innerHTML = this.pad(content)+ronin["default"].hint(content);
|
||||
}
|
||||
lines[lines.length-1] = new_line;
|
||||
|
||||
this.textarea.value = lines.join("\n");
|
||||
this.timer = 10;
|
||||
}
|
||||
|
||||
this.update_menu = function()
|
||||
this.update_status = function()
|
||||
{
|
||||
this.menu_element.innerHTML = ronin.terminal.history.length;
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
this.input_element.value = "";
|
||||
}
|
||||
|
||||
this.key_arrow_up = function()
|
||||
{
|
||||
this.history_index -= 1;
|
||||
|
||||
if(this.history_index < 0){ this.history_index = 0; }
|
||||
|
||||
ronin.terminal.input_element.value = "> "+ronin.terminal.history[this.history_index];
|
||||
}
|
||||
|
||||
this.key_arrow_down = function()
|
||||
{
|
||||
this.history_index += 1;
|
||||
|
||||
if(this.history_index >= this.history.length){ this.history_index = this.history.length-1; }
|
||||
|
||||
ronin.terminal.input_element.value = "> "+ronin.terminal.history[this.history_index];
|
||||
}
|
||||
|
||||
this.pad = function(input)
|
||||
{
|
||||
var s = "";
|
||||
for (i = 0; i < input.length+1; i++){
|
||||
s += "_";
|
||||
if(ronin.terminal.has_changed() == true){
|
||||
this.status_element.innerHTML = "Changes Pending.";
|
||||
}
|
||||
return "<span style='color:#000'>"+s+"</span>";
|
||||
else{
|
||||
this.status_element.innerHTML = "Idle.";
|
||||
}
|
||||
|
||||
this.status_element.innerHTML += "<span class='details'>"+this.textarea.value.length+"c "+this.textarea.value.split("\n").length+"l</span>";
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
this.logs = [];
|
||||
|
||||
this.log = function(log)
|
||||
{
|
||||
this.logs.push(log);
|
||||
|
||||
}
|
||||
|
||||
this.update_log = function()
|
||||
{
|
||||
if(ronin.terminal.logs[0]){
|
||||
ronin.terminal.logs_element.appendChild(ronin.terminal.logs[0].element);
|
||||
ronin.terminal.logs.shift();
|
||||
this.load = function readTextFile(name)
|
||||
{
|
||||
var file = "presets/"+name+'?'+new Date().getTime();
|
||||
var rawFile = new XMLHttpRequest();
|
||||
rawFile.open("GET", file, false);
|
||||
rawFile.onreadystatechange = function ()
|
||||
{
|
||||
if(rawFile.readyState === 4)
|
||||
{
|
||||
if(rawFile.status === 200 || rawFile.status == 0)
|
||||
{
|
||||
var allText = rawFile.responseText;
|
||||
ronin.terminal.textarea.value = allText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(function(){ ronin.terminal.update_log(); }, 200);
|
||||
rawFile.send(null);
|
||||
}
|
||||
}
|
||||
|
||||
// Log
|
||||
|
||||
function Log(host,message,type = "default")
|
||||
function Log(host,message,error = false)
|
||||
{
|
||||
this.host = host;
|
||||
this.message = message;
|
||||
this.type = type;
|
||||
this.error = error;
|
||||
this.element = document.createElement("log");
|
||||
this.element.setAttribute("class",type);
|
||||
this.element.setAttribute("class",error ? "error" : "okay");
|
||||
this.element.innerHTML = "<span class='rune'>"+(host.rune ? host.rune : ">")+"</span> "+message;
|
||||
console.log(this.host.constructor.name,this.message)
|
||||
console.log(this.host.constructor.name,this.message);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ function Widget(rune)
|
||||
|
||||
this.install = function()
|
||||
{
|
||||
ronin.element.appendChild(this.element);
|
||||
ronin.terminal.element.appendChild(this.element);
|
||||
}
|
||||
|
||||
this.update = function()
|
||||
@@ -23,7 +23,7 @@ function Type(rune)
|
||||
target_layer.context().fillStyle = color;
|
||||
target_layer.context().fillText(text,position.x,position.y);
|
||||
|
||||
console.log(target_layer.context());
|
||||
return 1, preview ? "preview" : "ok";
|
||||
}
|
||||
|
||||
// Mouse
|
||||
@@ -35,26 +35,26 @@ function Type(rune)
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
ronin.terminal.input_element.value = "type."+ronin.terminal.method_name+" "+position.render();
|
||||
ronin.terminal.passive();
|
||||
var line = "type.write "+position.render()+" \"Placeholder\"";
|
||||
ronin.terminal.update_active_line(line);
|
||||
}
|
||||
|
||||
this.mouse_move = function(position,rect)
|
||||
{
|
||||
ronin.terminal.input_element.value = "type."+ronin.terminal.method_name+" "+position.render();
|
||||
ronin.terminal.passive();
|
||||
var line = "type.write "+position.render()+" \"Placeholder\"";
|
||||
ronin.terminal.update_active_line(line);
|
||||
}
|
||||
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
ronin.terminal.input_element.value = "type."+ronin.terminal.method_name+" "+position.render();
|
||||
ronin.terminal.passive();
|
||||
var line = "type.write "+position.render()+" \"Placeholder\"";
|
||||
ronin.terminal.update_active_line(line);
|
||||
ronin.terminal.textarea.value += "\n";
|
||||
ronin.cursor.release();
|
||||
}
|
||||
|
||||
this.key_escape = function()
|
||||
{
|
||||
if(this.layer){ this.layer.remove(this); }
|
||||
ronin.terminal.input_element.value = "";
|
||||
ronin.terminal.passive();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user