diff --git a/blash.json b/blash.json index 9fede53..327eb11 100644 --- a/blash.json +++ b/blash.json @@ -188,6 +188,7 @@ "commands" : [ "cat", "cd", + "clear", "eval", "find", "ls", diff --git a/commands/clear.json b/commands/clear.json new file mode 100644 index 0000000..c049011 --- /dev/null +++ b/commands/clear.json @@ -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; + }, +} +