[pve-devel] applied: [PATCH manager] qemu/Monitor: save the last 20 commands
Wolfgang Bumiller
w.bumiller at proxmox.com
Mon Jan 29 15:11:03 CET 2018
applied, despite the lack of tab completion ;-)
On Fri, Jan 26, 2018 at 03:25:26PM +0100, Dominik Csapak wrote:
> and make them available with the up/down arrow key
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> www/manager6/qemu/Monitor.js | 45 ++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 37 insertions(+), 8 deletions(-)
>
> diff --git a/www/manager6/qemu/Monitor.js b/www/manager6/qemu/Monitor.js
> index 686950ad..4cfd1537 100644
> --- a/www/manager6/qemu/Monitor.js
> +++ b/www/manager6/qemu/Monitor.js
> @@ -18,6 +18,8 @@ Ext.define('PVE.qemu.Monitor', {
> throw "no VM ID specified";
> }
>
> + var history = [];
> + var histNum = -1;
> var lines = [];
>
> var textbox = Ext.createWidget('panel', {
> @@ -56,6 +58,14 @@ Ext.define('PVE.qemu.Monitor', {
>
> var executeCmd = function(cmd) {
> addLine("# " + Ext.htmlEncode(cmd));
> + if (cmd) {
> + history.unshift(cmd);
> + if (history.length > 20) {
> + history.splice(20);
> + }
> + }
> + histNum = -1;
> +
> refresh();
> Proxmox.Utils.API2Request({
> params: { command: cmd },
> @@ -96,14 +106,33 @@ Ext.define('PVE.qemu.Monitor', {
> refresh();
> },
> specialkey: function(f, e) {
> - if (e.getKey() === e.ENTER) {
> - var cmd = f.getValue();
> - f.setValue('');
> - executeCmd(cmd);
> - } else if (e.getKey() === e.PAGE_UP) {
> - textbox.scrollBy(0, -0.9*textbox.getHeight(), false);
> - } else if (e.getKey() === e.PAGE_DOWN) {
> - textbox.scrollBy(0, 0.9*textbox.getHeight(), false);
> + var key = e.getKey();
> + switch (key) {
> + case e.ENTER:
> + var cmd = f.getValue();
> + f.setValue('');
> + executeCmd(cmd);
> + break;
> + case e.PAGE_UP:
> + textbox.scrollBy(0, -0.9*textbox.getHeight(), false);
> + break;
> + case e.PAGE_DOWN:
> + textbox.scrollBy(0, 0.9*textbox.getHeight(), false);
> + break;
> + case e.UP:
> + if (histNum + 1 < history.length) {
> + f.setValue(history[++histNum]);
> + }
> + e.preventDefault();
> + break;
> + case e.DOWN:
> + if (histNum > 0) {
> + f.setValue(history[--histNum]);
> + }
> + e.preventDefault();
> + break;
> + default:
> + break;
> }
> }
> }
> --
> 2.11.0
More information about the pve-devel
mailing list