Implementing 'clear' command

This commit is contained in:
BlackLight 2010-12-24 22:43:25 +01:00
parent 5e1a804f44
commit d6d63b9431
2 changed files with 40 additions and 0 deletions

View file

@ -188,6 +188,7 @@
"commands" : [ "commands" : [
"cat", "cat",
"cd", "cd",
"clear",
"eval", "eval",
"find", "find",
"ls", "ls",

39
commands/clear.json Normal file
View file

@ -0,0 +1,39 @@
{
"name" : "clear",
"info" : {
"syntax" : "clear",
"brief" : "Clear the terminal screen",
},
"action" : function ( arg )
{
var out = '';
var text = ( shell.json.promptText ) ? shell.json.promptText : "[%n@%m %W] $ ";
text = shell.unescapePrompt ( text, shell.json.promptSequences );
shell.window.removeChild ( shell.prompt );
shell.window.removeChild ( shell.cmdOut );
shell.window.innerHTML = '';
shell.prompt = document.createElement ( 'input' );
shell.prompt.setAttribute ( 'name', 'blashPrompt' );
shell.prompt.setAttribute ( 'type', 'text' );
shell.prompt.setAttribute ( 'class', 'promptInput' );
shell.prompt.setAttribute ( 'autocomplete', 'off' );
shell.prompt.setAttribute ( 'onkeydown', 'shell.getKey ( event )' );
shell.prompt.setAttribute ( 'onkeyup', 'this.focus()' );
shell.prompt.setAttribute ( 'onblur', 'return false' );
shell.cmdOut = document.createElement ( 'div' );
shell.cmdOut.setAttribute ( 'id', 'blashCmdOut' );
shell.cmdOut.setAttribute ( 'class', 'blashCmdOut' );
shell.window.appendChild ( shell.prompt );
shell.window.appendChild ( shell.cmdOut );
shell.prompt.focus();
return out;
},
}