From d6d63b9431b6d84c1322369caeb443a7491ae555 Mon Sep 17 00:00:00 2001 From: BlackLight Date: Fri, 24 Dec 2010 22:43:25 +0100 Subject: [PATCH] Implementing 'clear' command --- blash.json | 1 + commands/clear.json | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 commands/clear.json 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; + }, +} +