On 1/26/18 3:25 PM, Dominik Csapak wrote:
> and make them available with the up/down arrow key
> 

Looks good.

Reviewed-by: Thomas Lamprecht <t.lampre...@proxmox.com>
Tested-by: Thomas Lamprecht <t.lampre...@proxmox.com>

Up next: tab auto completion? ;)

> Signed-off-by: Dominik Csapak <d.csa...@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;
>                           }
>                       }
>                   }
> 


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to