Layout in the main configuration
This commit is contained in:
parent
ab468beb64
commit
6cd023a0fe
1 changed files with 35 additions and 28 deletions
43
spp.pl
43
spp.pl
|
@ -8,28 +8,31 @@ use utf8;
|
||||||
use open ':std', ':encoding(UTF-8)';
|
use open ':std', ':encoding(UTF-8)';
|
||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
our @LEFT = (
|
our %CONFIG = (
|
||||||
|
# LAYOUT
|
||||||
|
# - Section generators for the left side of the top bar
|
||||||
|
layout_left => [
|
||||||
'datetime' ,
|
'datetime' ,
|
||||||
'userhost' ,
|
'userhost' ,
|
||||||
#'load' ,
|
#'load' ,
|
||||||
#'prevcmd' ,
|
#'prevcmd' ,
|
||||||
);
|
] ,
|
||||||
our $MIDDLE = 'cwd';
|
# - Section generator for the central part of the top bar (undef if unused)
|
||||||
our @RIGHT = (
|
layout_middle => 'cwd' ,
|
||||||
|
# - Section generators for the right side of the top bar
|
||||||
|
layout_right => [
|
||||||
#'datetime' ,
|
#'datetime' ,
|
||||||
#'userhost' ,
|
#'userhost' ,
|
||||||
'load' ,
|
'load' ,
|
||||||
#'prevcmd' ,
|
#'prevcmd' ,
|
||||||
);
|
] ,
|
||||||
our @INPUT = (
|
# - Section generators for the input bar
|
||||||
|
layout_input => [
|
||||||
#'datetime' ,
|
#'datetime' ,
|
||||||
#'userhost' ,
|
#'userhost' ,
|
||||||
#'load' ,
|
#'load' ,
|
||||||
'prevcmd' ,
|
'prevcmd' ,
|
||||||
);
|
] ,
|
||||||
|
|
||||||
our %CONFIG = (
|
|
||||||
# LAYOUT
|
|
||||||
# - Always generate input line ?
|
# - Always generate input line ?
|
||||||
layout_input_always => 0 ,
|
layout_input_always => 0 ,
|
||||||
|
|
||||||
|
@ -335,14 +338,17 @@ sub render
|
||||||
|
|
||||||
sub gen_top_line
|
sub gen_top_line
|
||||||
{
|
{
|
||||||
return "" unless ( @LEFT || @RIGHT || defined( $MIDDLE ) );
|
my @left = @{ $CONFIG{layout_left} };
|
||||||
|
my @right = @{ $CONFIG{layout_right} };
|
||||||
|
my $midGen = $CONFIG{layout_middle};
|
||||||
|
return "" unless ( @left || @right || defined( $midGen ) );
|
||||||
|
|
||||||
# Generate content
|
# Generate content
|
||||||
my ( @left , @lm , @middle , @mr , @right ) = ( );
|
my ( @lm , @middle , @mr ) = ( );
|
||||||
my $mc = $THEME{bg_middle};
|
my $mc = $THEME{bg_middle};
|
||||||
@left = gen_prompt_sections( @LEFT );
|
@left = gen_prompt_sections( @left );
|
||||||
if ( defined $MIDDLE ) {
|
if ( defined $midGen ) {
|
||||||
@middle = ( gen_prompt_section( $MIDDLE ) );
|
@middle = ( gen_prompt_section( $midGen ) );
|
||||||
if ( @middle ) {
|
if ( @middle ) {
|
||||||
@lm = gen_transition( $THEME{middle_prefix} , $mc , $mc );
|
@lm = gen_transition( $THEME{middle_prefix} , $mc , $mc );
|
||||||
@mr = gen_transition( $THEME{middle_suffix} , $mc , $mc );
|
@mr = gen_transition( $THEME{middle_suffix} , $mc , $mc );
|
||||||
|
@ -351,7 +357,7 @@ sub gen_top_line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@right = gen_prompt_sections( reverse @RIGHT );
|
@right = gen_prompt_sections( reverse @right );
|
||||||
|
|
||||||
# Adapt to width
|
# Adapt to width
|
||||||
my $len = get_length( ( @lm , @middle , @mr ) );
|
my $len = get_length( ( @lm , @middle , @mr ) );
|
||||||
|
@ -375,9 +381,10 @@ sub gen_top_line
|
||||||
|
|
||||||
sub gen_input_line
|
sub gen_input_line
|
||||||
{
|
{
|
||||||
return "" unless @INPUT || $CONFIG{layout_input_always};
|
my @input = @{ $CONFIG{layout_input} };
|
||||||
|
return "" unless @input || $CONFIG{layout_input_always};
|
||||||
my $len = 0;
|
my $len = 0;
|
||||||
my @input = adapt_to_width( \$len , 'input' , gen_prompt_sections( @INPUT ) );
|
@input = adapt_to_width( \$len , 'input' , gen_prompt_sections( @input ) );
|
||||||
push @input , {content=>['']} unless @input;
|
push @input , {content=>['']} unless @input;
|
||||||
return ( $len ,
|
return ( $len ,
|
||||||
render( 'input' , add_transitions( 'input' , 0 , 0 , @input ) )
|
render( 'input' , add_transitions( 'input' , 0 , 0 , @input ) )
|
||||||
|
|
Loading…
Reference in a new issue