Autocompelte
This commit is contained in:
parent
56d5dfc976
commit
43ea3bd386
@ -20,6 +20,8 @@ body { margin:0px; padding:0px; overflow:hidden; font-family:"input_mono_medium"
|
||||
#terminal #widget { text-align: right; bottom:30px}
|
||||
#terminal #widget .mouse { color:white; }
|
||||
|
||||
span.autocomplete { background:white; color:black; }
|
||||
|
||||
span.module { display: inline-block; color:#999; }
|
||||
span.method { display: inline-block; color:#999; }
|
||||
span.method .name { color:#fff; }
|
||||
|
@ -14,6 +14,16 @@ function Keyboard()
|
||||
if(event.altKey == true){
|
||||
this.alt_held = true;
|
||||
}
|
||||
|
||||
// Autocomplete with tab
|
||||
if(event.keyCode === 9){
|
||||
var ac = ronin.terminal.find_autocomplete();
|
||||
if(ac){
|
||||
event.preventDefault();
|
||||
ronin.terminal.input.value += ac;
|
||||
}
|
||||
}
|
||||
|
||||
ronin.cursor.update(event);
|
||||
ronin.widget.update();
|
||||
ronin.terminal.update();
|
||||
@ -24,6 +34,8 @@ function Keyboard()
|
||||
this.shift_held = false;
|
||||
this.alt_held = false;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
switch (event.key || event.keyCode || event.which) {
|
||||
case "Enter": this.key_enter(); break;
|
||||
case "ArrowUp": this.key_arrow_up(); break;
|
||||
@ -44,6 +56,8 @@ function Keyboard()
|
||||
case 8: this.key_delete(); break;
|
||||
}
|
||||
|
||||
console.log(event)
|
||||
|
||||
// Passive
|
||||
ronin.widget.update();
|
||||
ronin.terminal.update();
|
||||
|
@ -54,11 +54,13 @@ function Terminal(rune)
|
||||
var command = this.cmd();
|
||||
var module = command.module();
|
||||
var method = command.method();
|
||||
var autocomplete = this.find_autocomplete(command,module,method);
|
||||
|
||||
if(method && preview){
|
||||
method.preview(command);
|
||||
}
|
||||
this.hint_element.innerHTML = "<span class='input'>"+this.input.value+"</span>"+(this.input.value ? " > " : "")+(module ? module.hint(method) : ronin.hint(method));
|
||||
|
||||
this.hint_element.innerHTML = "<span class='input'>"+this.input.value+"</span>"+(autocomplete ? '<span class="autocomplete">'+autocomplete+'</span>' : '')+(this.input.value ? " > " : "")+(module ? module.hint(method) : ronin.hint(method));
|
||||
ronin.cursor.update();
|
||||
}
|
||||
|
||||
@ -92,6 +94,31 @@ function Terminal(rune)
|
||||
|
||||
return "Loading "+cmd.values();
|
||||
}
|
||||
|
||||
this.find_autocomplete = function()
|
||||
{
|
||||
html = ""
|
||||
|
||||
var entry = this.input.value;
|
||||
var module = this.cmd().module();
|
||||
var method = entry.indexOf(".") > -1 ? entry.split(".")[1] : null;
|
||||
|
||||
if(entry.length == 0){ return null; }
|
||||
|
||||
if(module && method){
|
||||
for(id in module.methods){
|
||||
if(method == module.methods[id].name){ break; }
|
||||
if(method == module.methods[id].name.substr(0,method.length)){ return module.methods[id].name.replace(method,""); }
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(id in ronin.modules){
|
||||
if(entry == ronin.modules[id].name){ break; }
|
||||
if(entry == ronin.modules[id].name.substr(0,entry.length)){ return ronin.modules[id].name.replace(entry,""); }
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Log
|
||||
|
Loading…
x
Reference in New Issue
Block a user