[pve-devel] [PATCH pve-client 2/2] Add remote handling

Dietmar Maurer dietmar at proxmox.com
Wed May 30 12:55:45 CEST 2018


#!/usr/bin/perl

use strict;
use warnings;

require 'sys/ioctl.ph';
die "no TIOCGWINSZ" unless defined &TIOCGWINSZ;

# ( row, col, x, y )
sub get_terminal_size {
    my $h = shift || *STDIN;
    die "not a termianl" if ! -t $h;

    my $winsize = '';
    if (!ioctl($h, &TIOCGWINSZ, $winsize)) {
	die sprintf "$0: ioctl TIOCGWINSZ (%08x: $!)\n", &TIOCGWINSZ;
    }
    
    my ($row, $col, $xpixel, $ypixel) = unpack('S4', $winsize);
    print "(row,col) = ($row,$col)";
    return ($row, $col, $xpixel, $ypixel);
}

get_terminal_size();

not sure what's the best way to switch to 'raw'mode?

> On May 30, 2018 at 12:47 PM René Jochum <r.jochum at proxmox.com> wrote:
> 
> 
> Signed-off-by: René Jochum <r.jochum at proxmox.com>
> ---
>  PVE/APIClient/Commands/remote.pm | 118 ++++++++++++++++++++++----
>  PVE/APIClient/Config.pm          | 174
> ++++++++++++++++++++++++++++++++-------
>  PVE/APIClient/Helpers.pm         |   9 ++
>  3 files changed, 254 insertions(+), 47 deletions(-)
> 
> diff --git a/PVE/APIClient/Commands/remote.pm
> b/PVE/APIClient/Commands/remote.pm
> index a6eb512..51106a6 100644
> --- a/PVE/APIClient/Commands/remote.pm
> +++ b/PVE/APIClient/Commands/remote.pm
> @@ -8,32 +8,72 @@ use PVE::APIClient::Config;
>  
>  use PVE::CLIHandler;
>  
> -use base qw(PVE::CLIHandler);
> -
> -my $remote_name_regex = qr(\w+);
> +use PVE::APIClient::Helpers ();
> +use Term::ReadLine;



More information about the pve-devel mailing list