Implementing 'clear' command
This commit is contained in:
parent
5e1a804f44
commit
d6d63b9431
2 changed files with 40 additions and 0 deletions
|
@ -188,6 +188,7 @@
|
|||
"commands" : [
|
||||
"cat",
|
||||
"cd",
|
||||
"clear",
|
||||
"eval",
|
||||
"find",
|
||||
"ls",
|
||||
|
|
39
commands/clear.json
Normal file
39
commands/clear.json
Normal 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;
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in a new issue