Saving RIN file

This commit is contained in:
Devine Lu Linvega
2017-03-11 15:00:52 -07:00
parent 52a044b78e
commit 4040964505
14 changed files with 103 additions and 269 deletions

View File

@@ -1,41 +0,0 @@
function Hint(element)
{
Module.call(this);
this.element = element;
this.update = function()
{
var module = ronin.module;
var cmd = commander.cmd();
if(module){
this.element.innerHTML = this.message(module,cmd);
this.element.style.display = "block";
}
else if(commander && commander.element_input.value != ""){
this.element.innerHTML = commander.element_input.value;
this.element.style.display = "block";
}
else{
this.element.innerHTML = this.default();
this.element.style.display = "block";
}
}
this.message = function(module,cmd)
{
return module.hint(cmd);
}
this.default = function()
{
var s = "<span class='module'>Modules</span>";
for (var key in ronin.modules){
s += "<span> <span class='value'>"+key+"</span> <span class='param'>"+ronin.modules[key].constructor.name+" ";
}
return s;
}
}

View File

@@ -1,111 +0,0 @@
function Commander(element,element_input)
{
this.element = element;
this.element_input = element_input;
this.hint = new Hint();
this.storage = [];
this.storage_index = 0;
this.always_show = false;
this.queue = [];
this.query = function(input_str)
{
if(input_str.indexOf(";") > 0){
this.queue = input_str.split(";");
}
else{
this.queue = [];
this.queue.push(input_str)
}
this.run();
this.hide();
}
this.run = function()
{
if(!commander.queue[0]){ console.log("Finished queue"); return; }
active(commander.queue[0].trim());
commander.queue.shift();
setTimeout(function(){ commander.run(); }, 100);
}
function active(content)
{
console.info(content);
var key = content[0];
var cmd = new Command(content.substring(1).trim().split(" "));
if(ronin.modules[key]){
ronin.modules[key].active(cmd);
}
ronin.history.add(content);
}
this.passive = function(content)
{
var key = content[0];
var cmd = new Command(content.substring(1).trim().split(" "));
ronin.module = null;
if(ronin.modules[key]){
ronin.modules[key].passive(cmd);
ronin.module = ronin.modules[key];
ronin.cursor.set_mode(ronin.module);
}
else{
ronin.cursor.set_mode(ronin.brush);
}
this.hint.update();
}
this.cmd = function()
{
var content = this.element_input.value.trim();
var key = content[0];
var cmd = new Command(content.substring(1).trim().split(" "));
return cmd;
}
//
this.show = function()
{
this.element.setAttribute('class','visible');
this.element_input.focus();
this.element_input.value = "";
}
this.always = function() {
this.always_show = !this.always_show;
}
this.hide = function()
{
if (!this.always_show) {
this.element.setAttribute('class','hidden');
}
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];
}
}

View File

@@ -37,8 +37,9 @@ ronin.terminal.query("@ layer=Main");
ronin.terminal.query("- 0,0");
ronin.terminal.query("- 1,1");
ronin.terminal.query("- 2,2");
ronin.terminal.query("- #ff00ff");
ronin.terminal.query("- #ff0000");
ronin.terminal.query("~ Ready.");
ronin.terminal.input_element.focus();
ronin.terminal.update_hint();
ronin.surface.update_widget();

View File

@@ -38,8 +38,8 @@ function Keyboard()
case 27: this.key_escape(); break;
case 219: ronin.brush.size_up(); break;
case 221: ronin.brush.size_down(); break;
case 38: ronin.surface.layer_up(); break;
case 40: ronin.surface.layer_down(); break;
case 38: this.key_arrow_up(); break;
case 40: this.key_arrow_down(); break;
case 8: this.key_delete(); break;
}
@@ -64,18 +64,22 @@ function Keyboard()
this.key_arrow_up = function()
{
if(ronin.module){ ronin.module.key_arrow_up(); }
}
this.key_arrow_down = function()
{
if(ronin.module){ ronin.module.key_arrow_down(); }
}
this.key_arrow_left = function()
{
if(ronin.module){ ronin.module.key_arrow_left(); }
}
this.key_arrow_right = function()
{
if(ronin.module){ ronin.module.key_arrow_right(); }
}
this.key_colon = function()

View File

@@ -6,12 +6,10 @@ function Ronin()
this.surface = new Surface("@");
this.fileload = new FileLoad("/");
this.filesave = new FileSave("$");
this.history = new History("^");
this.overlay = new Overlay("|");
this.brush = new Brush("-");
this.eye = new Eye("*");
this.render = new Render("%");
this.stroke = new Stroke("_");
this.vector = new Vector("+");
this.help = new Help("?");
this.typo = new Typographe("&");
@@ -21,13 +19,11 @@ function Ronin()
this.modules[this.surface.rune] = this.surface;
this.modules[this.fileload.rune] = this.fileload;
this.modules[this.filesave.rune] = this.filesave;
this.modules[this.history.rune] = this.history;
this.modules[this.overlay.rune] = this.overlay;
this.modules[this.render.rune] = this.render;
this.modules[this.brush.rune] = this.brush;
this.modules[this.eye.rune] = this.eye;
this.modules[this.typo.rune] = this.typo;
this.modules[this.stroke.rune] = this.stroke;
this.modules[this.vector.rune] = this.vector;
this.modules[this.help.rune] = this.help;
this.modules[this.terminal.rune] = this.terminal;