mirror of
https://github.com/duncs/clusterssh.git
synced 2025-04-21 09:09:06 +00:00
added support for specifying the desired number of columns or rows
This commit is contained in:
parent
2b9b8990b7
commit
cd355f965d
4 changed files with 58 additions and 18 deletions
|
@ -950,24 +950,43 @@ sub retile_hosts {
|
|||
$self->config->{internal_screen_width} = $xdisplay->{width_in_pixels};
|
||||
|
||||
# Now, work out how many columns of terminals we can fit on screen
|
||||
$self->config->{internal_columns} = int(
|
||||
( $self->config->{internal_screen_width}
|
||||
- $self->config->{screen_reserve_left}
|
||||
- $self->config->{screen_reserve_right}
|
||||
) / (
|
||||
$self->config->{internal_terminal_width}
|
||||
+ $self->config->{terminal_reserve_left}
|
||||
+ $self->config->{terminal_reserve_right}
|
||||
)
|
||||
);
|
||||
|
||||
# Work out the number of rows we need to use to fit everything on screen
|
||||
$self->config->{internal_rows} = int(
|
||||
( $self->config->{internal_total}
|
||||
/ $self->config->{internal_columns}
|
||||
) + 0.999
|
||||
);
|
||||
if ( $self->config->{rows} != -1 || $self->config->{cols} != -1 ) {
|
||||
if ( $self->config->{rows} != -1 ) {
|
||||
$self->config->{internal_rows} = $self->config->{rows};
|
||||
$self->config->{internal_columns} = int(
|
||||
( $self->config->{internal_total}
|
||||
/ $self->config->{internal_rows}
|
||||
) + 0.999
|
||||
);
|
||||
}
|
||||
else {
|
||||
$self->config->{internal_columns} = $self->config->{cols};
|
||||
$self->config->{internal_rows} = int(
|
||||
( $self->config->{internal_total}
|
||||
/ $self->config->{internal_columns}
|
||||
) + 0.999
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$self->config->{internal_columns} = int(
|
||||
( $self->config->{internal_screen_width}
|
||||
- $self->config->{screen_reserve_left}
|
||||
- $self->config->{screen_reserve_right}
|
||||
) / (
|
||||
$self->config->{internal_terminal_width}
|
||||
+ $self->config->{terminal_reserve_left}
|
||||
+ $self->config->{terminal_reserve_right}
|
||||
)
|
||||
);
|
||||
|
||||
# Work out the number of rows we need to use to fit everything on screen
|
||||
$self->config->{internal_rows} = int(
|
||||
( $self->config->{internal_total}
|
||||
/ $self->config->{internal_columns}
|
||||
) + 0.999
|
||||
);
|
||||
}
|
||||
$self->debug( 2, "Screen Columns: ", $self->config->{internal_columns} );
|
||||
$self->debug( 2, "Screen Rows: ", $self->config->{internal_rows} );
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ my %default_config = (
|
|||
|
||||
# don't set username here as takes precendence over ssh config
|
||||
user => '',
|
||||
rows => -1,
|
||||
cols => -1,
|
||||
);
|
||||
|
||||
sub new {
|
||||
|
|
|
@ -240,7 +240,16 @@ sub add_common_options {
|
|||
help =>
|
||||
$self->loc('Do not output extra text when using some options'),
|
||||
);
|
||||
|
||||
$self->add_option(
|
||||
spec => 'cols|x=i',
|
||||
arg_desc => 'cols',
|
||||
help => $self->loc('Number of columns'),
|
||||
);
|
||||
$self->add_option(
|
||||
spec => 'rows|y=i',
|
||||
arg_desc => 'rows',
|
||||
help => $self->loc('Number of rows'),
|
||||
);
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -380,6 +389,12 @@ sub getopts {
|
|||
= !$self->parent->config->{window_tiling} || 0;
|
||||
}
|
||||
|
||||
if ( $self->rows ) {
|
||||
$self->parent->config->{rows} = $self->rows;
|
||||
}
|
||||
if ( $self->cols ) {
|
||||
$self->parent->config->{cols} = $self->cols;
|
||||
}
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,8 @@ Readonly::Hash my %default_config => {
|
|||
# other bits inheritted from App::ClusterSSH::Base
|
||||
lang => 'en',
|
||||
user => '',
|
||||
rows => -1,
|
||||
cols => -1,
|
||||
};
|
||||
my %expected = %default_config;
|
||||
is_deeply( $config, \%expected, 'default config is correct' );
|
||||
|
@ -538,6 +540,7 @@ my $expected = qq{# Configuration dump produced by "cssh -d"
|
|||
auto_close=5
|
||||
auto_quit=yes
|
||||
auto_wm_decoration_offsets=no
|
||||
cols=-1
|
||||
console=console
|
||||
console_args=
|
||||
console_position=
|
||||
|
@ -568,6 +571,7 @@ max_host_menu_items=30
|
|||
menu_host_autotearoff=0
|
||||
menu_send_autotearoff=0
|
||||
mouse_paste=Button-2
|
||||
rows=-1
|
||||
rsh=rsh
|
||||
rsh_args=
|
||||
screen_reserve_bottom=60
|
||||
|
|
Loading…
Add table
Reference in a new issue