Time to go back to my old plan

This commit is contained in:
Devine Lu Linvega 2017-05-18 21:19:49 -10:00
parent d9677f0fea
commit 3b07675845
6 changed files with 31 additions and 106 deletions

View File

@ -8,23 +8,22 @@ body { margin:0px; padding:0px; overflow:hidden; font-family:"input_mono_medium"
#overlay { position:absolute; z-index:1000;}
#frame { cursor:none;}
#terminal { position: fixed;top: 0px;left: 0px;background: #000;width: 40vw;height: 100vh;overflow: hidden;}
#terminal { position: fixed;bottom: 0px;left: 0px;background: #000;width: 100vw;height: 30px;overflow: hidden;}
#terminal logs { display: none;position: absolute;bottom:20px;width:100vw;color:white}
#terminal logs log { display: block; font-size:10px; line-height:25px; padding:0px 5px; color:#666;}
#terminal logs log .rune { color:white; }
#terminal logs log.error .rune { color:red; }
#terminal logs log.input { color:white; }
#terminal logs log.image img { height:85px;width:auto;border-radius: 3px }
#terminal menu { display: inline-block;position: absolute;bottom: 0px;right: 0px;padding: 0px 5px;font-size: 10px;line-height: 20px;color:white }
#terminal.locked input { color:red; }
#terminal status { display: block;position: absolute;bottom: 0px;left: 0px;padding: 5px 15px 5px 31px;font-size: 12px;line-height: 20px;color: white;width:calc(40vw - 45px) }
#terminal status { display: block;position: absolute;bottom: 0px;right: 0px;padding: 5px 15px 5px 31px;font-size: 12px;line-height: 20px;color: white;width:calc(40vw - 45px) }
#terminal status .details { float:right; color:#555; }
#terminal.hide { height:25px; }
#terminal.mini { height:120px; }
#terminal.full { height:100vh; }
#terminal #widget { position: absolute;top: 0px;left: 0px;line-height: 30px;font-size: 12px;z-index: 9000;color: white;width: calc(40vw - 15px);height: 100px;padding-left:30px }
#terminal #widget { position: absolute;top: 0px;right: 0px;line-height: 30px;font-size: 12px;z-index: 9000;color: white;width: calc(40vw - 15px);height: 100px;padding-left:30px }
#terminal #widget span { display:inline-block; line-height:15px; padding:0px 5px; vertical-align: top; min-width:100px;}
#terminal #widget span name { display: block; border-bottom: 1px solid #333; line-height:25px; margin-bottom:5px;}
#terminal #widget li { display:block; }
@ -41,6 +40,5 @@ body { margin:0px; padding:0px; overflow:hidden; font-family:"input_mono_medium"
#terminal hint line .input .setting { background: #444; }
#terminal hint line .input .comment { background: #222;width:100%;display: inline-block }
#terminal textarea { display: block;position: fixed;top: 100px;width: calc(40vw - 16px);height: calc(100vh - 130px);padding: 0px 15px;line-height: 20px;font-size: 12px;background: none;color: #ccc;border-left:1px solid #333;margin-left:15px}
#terminal textarea:hover { border-left:1px solid #555; }
#terminal textarea { z-index:900; }
#terminal input { line-height: 30px; width:400px; background:none; color:pink; font-size:12px; }

View File

@ -35,5 +35,6 @@ starting_canvas.height = parseInt(starting_canvas.height/40) * 40;
var target_file = window.location.hash ? window.location.hash : "default";
target_file = target_file.substr(1,target_file.length-1);
ronin.terminal.load(window.location.hash ? target_file+".rin" : "default.rin");
// ronin.terminal.load(window.location.hash ? target_file+".rin" : "default.rin");
ronin.widget.update();
ronin.terminal.input.focus();

View File

@ -13,7 +13,6 @@ function Keyboard()
}
ronin.cursor.update(event);
ronin.widget.update();
ronin.terminal.timer = 0;
ronin.terminal.update();
}
@ -22,7 +21,7 @@ function Keyboard()
this.shift_held = false;
this.alt_held = false;
switch (event.key) {
switch (event.key || event.which) {
case "Enter": this.key_enter(); break;
case "ArrowUp": this.key_arrow_up(); break;
case "ArrowDown": this.key_arrow_down(); break;
@ -30,10 +29,6 @@ function Keyboard()
case "ArrowRight": this.key_arrow_right(); break;
case ":": this.key_colon(); break;
case "Escape": this.key_escape(); break;
}
switch(event.which)
{
case 13: this.key_enter(); break;
case 186: if(event.shiftKey){this.key_colon();} break;
case 27: this.key_escape(); break;
@ -55,6 +50,7 @@ function Keyboard()
this.key_enter = function()
{
ronin.terminal.run();
}
this.key_space = function()

View File

@ -221,7 +221,7 @@ function Cursor(rune)
this.mode.mouse_held = false;
this.mode.mouse_from = null;
this.mode = ronin.brush;
ronin.terminal.textarea.focus();
ronin.terminal.input.focus();
}
this.widget = function()

View File

@ -3,10 +3,9 @@ function Terminal(rune)
Module.call(this,">");
this.element = document.createElement("div");
this.textarea = document.createElement("textarea");
this.input = document.createElement("input");
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 = [];
@ -18,56 +17,27 @@ function Terminal(rune)
// Module
this.install = function(cmd)
{
this.element.appendChild(this.textarea);
this.element.appendChild(this.input);
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.status_element.innerHTML = "Ready.";
this.textarea.value = ""
this.input.value = ""
this.hint_element.innerHTML = "";
this.validation_timer();
this.timer = 20;
}
this.timer = 0;
this.history = "";
this.validation_timer = function()
{
this.timer += 1;
setTimeout(function(){ ronin.terminal.validation_timer(); }, 100);
this.validate();
}
this.has_changed = function()
{
return ronin.terminal.history != ronin.terminal.textarea.value ? true : false;
}
this.validate = function()
{
if(this.timer < 10){ return; }
if(ronin.terminal.has_changed() == true){
ronin.terminal.run();
}
this.history = this.textarea.value;
this.timer = 0;
}
this.run = function()
{
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>\n";
}
this.run_line(this.input.value);
// this.hint_element.innerHTML = "";
// var queue = ronin.terminal.input.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>\n";
// }
}
this.run_line = function(id,line)
this.run_line = function(line)
{
var content = line;
@ -93,7 +63,7 @@ function Terminal(rune)
ronin.cursor.set_mode(ronin[module_name]);
if(ronin[module_name] && ronin[module_name][method_name]){
return ronin[module_name][method_name](parameters,id == 1 ? true : false);
return ronin[module_name][method_name](parameters);
}
else if(ronin[module_name] && ronin[module_name].settings[setting_name]){
return ronin[module_name].update_setting(setting_name,parameters);
@ -116,58 +86,13 @@ function Terminal(rune)
return 0, "Unknown";
}
this.syntax_highlight = function(line)
{
var line = line;
// Comment
if(line[0] == "~"){ line = "<span class='comment'>"+line+"</span>"; }
// Method
if(line.indexOf(".") > 0){
var module = line.split(".")[0];
var method = line.split(".")[1].split(" ")[0];
line = line.replace(module,"<span class='module'>"+module+"</span>");
line = line.replace(method,"<span class='method'>"+method+"</span>");
}
// Setting
if(line.indexOf(":") > 0){
var module = line.split(":")[0];
var setting = line.split(":")[1].split(" ")[0];
line = line.replace(module,"<span class='module'>"+module+"</span>");
line = line.replace(setting,"<span class='setting'>"+setting+"</span>");
}
return line;
}
this.update_active_line = function(new_line)
{
var lines = this.textarea.value.split("\n");
var lines = this.input.value.split("\n");
lines[lines.length-1] = new_line;
this.textarea.value = lines.join("\n");
this.timer = 10;
}
this.update = function()
{
if(ronin.terminal.has_changed() == true){
this.status_element.innerHTML = "Changes Pending.";
}
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.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></line><br />";
}
this.input.value = lines.join("\n");
}
this.log = function(log)
@ -175,6 +100,11 @@ function Terminal(rune)
}
this.update = function()
{
}
this.filename = "default.rin";
this.load = function readTextFile(name)
@ -190,7 +120,7 @@ function Terminal(rune)
if(rawFile.status === 200 || rawFile.status == 0)
{
var allText = rawFile.responseText;
ronin.terminal.textarea.value = allText;
ronin.terminal.input.value = allText;
}
}
}
@ -200,7 +130,7 @@ function Terminal(rune)
this.cmd = function()
{
var lines = ronin.terminal.textarea.value.split("\n");
var lines = ronin.terminal.input.value.split("\n");
var last = lines[lines.length-1];
return new Command(last.split(" "));
}

View File

@ -52,7 +52,7 @@ function Type(rune)
var str = ronin.terminal.cmd().text() ? ronin.terminal.cmd().text() : "Placeholder";
var line = "type.write "+position.render()+" \""+str+"\"";
ronin.terminal.update_active_line(line);
ronin.terminal.textarea.value += "\n";
ronin.terminal.input.value += "\n";
ronin.cursor.release();
}