From 4730a2056edacc3be62dfe81e69bdfdedcca4071 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 9 Jul 2014 05:20:38 -0400 Subject: [PATCH] feature(console) add clear with Ctrl + l --- HELP.md | 1 + lib/client/console.js | 33 +++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/HELP.md b/HELP.md index 66cf41d7..81287746 100644 --- a/HELP.md +++ b/HELP.md @@ -155,6 +155,7 @@ Console | `~` | open | `Ctrl + p` | paste path of current directory | `Ctrl + z` | cancel current prompt +| `Ctrl + l` | clear | `Esc` | close Config diff --git a/lib/client/console.js b/lib/client/console.js index 6512702b..0b5a7fee 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -45,6 +45,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; } this.show = show; + this.clear = clear; // Handle a command. function handler(command) { @@ -66,16 +67,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; jqconsole = $(Element).jqconsole('', '> '); - jqconsole.RegisterShortcut('Z', function() { - jqconsole.SetPromptText(''); - }); - - jqconsole.RegisterShortcut('P', function() { - var command = jqconsole.GetPromptText(); - - command += DOM.getCurrentDirPath(); - jqconsole.SetPromptText(command); - }); + addShortCuts(jqconsole); } CloudCmd.View.show(Element, { @@ -131,6 +123,27 @@ var CloudCmd, Util, DOM, CloudFunc, $; } } + function addShortCuts(jqconsole) { + jqconsole.RegisterShortcut('Z', function() { + jqconsole.SetPromptText(''); + }); + + jqconsole.RegisterShortcut('L', clear); + + jqconsole.RegisterShortcut('P', function() { + var command = jqconsole.GetPromptText(); + + command += DOM.getCurrentDirPath(); + jqconsole.SetPromptText(command); + }); + } + + function clear() { + jqconsole.Reset(); + addShortCuts(jqconsole); + jqconsole.Prompt(true, handler); + } + function load(callback) { var dir = CloudCmd.LIBDIRCLIENT + 'console/', jsPath = dir + 'lib/',