package Psh
::Builtins
::Theme
;
Displays a list of available themes.
If your themes look strange try C<option encoding=iso8859-1> - this
will switch to an alternative usage of graphical characters.
Psh
::Util
::print_error
("Error parsing themefile $file.\n");
Psh
::Util
::print_error
("Do not understand: $line\n") if $line;
Psh
::Util
::print_error
("Please install Archive::Tar to handle .bt files!\n");
my $tar= Archive
::Tar
->new();
@lines= split /\n/, $tar->get_content('theme');
Psh
::Util
::print_error
("Could not find theme '$file'.\n");
if ($lines[0]=~/^\#\!.*psh/) { # psh-script
Psh
::process_variable
(join("\n",@lines));
} else { # try to parse it as a simple bashish theme
foreach my $line (@lines) {
next if substr($line,0,1) eq '#';
if ($line=~/^\s*needmod\s+themecompat\s*$/) {
} elsif ($line=~/^\s*PS(\d)\s*\=\s*(.*)$/) {
my ($num,$text)= ($1,$2);
$ps[$num]= Psh
::Parser
::unquote
($text);
return _parse_error
($file);
} elsif ($line=~/^\s*PROMPT\s*\=\s*(.*)$/) {
$ps[1]= Psh
::Parser
::unquote
($1);
} elsif ($line=~/^\s*TITLE\s*\=\s*(.*)$/) {
$title= Psh
::Parser
::unquote
($1);
} elsif ($line=~/^\s*X\w+\=/ or
$line=~/^\s*needmod\s+/ or
$line=~/^\s*THEME_.*\=/ or
$line=~/^\s*SUPERPROMPT/ or
return _parse_error
($file,$line);
for (my $i=1; $i<=4; $i++) {
next unless defined $ps[$i];
$ps[$i]=~s/\$n/\\n/g; $ps[$i]=~s/\$t/\\t/g;
$ps[$i]=~s/\$w/\\w/g; $ps[$i]=~s/\$W/\\W/g;
$ps[$i]=~s/\$u/\\u/g; $ps[$i]=~s/\$c/\\!/g;
$ps[$i]=~s/\$b/\\\$/g; $ps[$i]=~s/\$s/\\s/g;
$ps[$i]=~s/\$h/\\h/g; $ps[$i]=~s/\$i/\\#/g;
$ps[$i]=~s/\$d/\\d/g; $ps[$i]=~s/\$x/%/g;
$ps[$i]=~s/\$e/\!/g; $ps[$i]=~s/\$m/\$/g;
Psh
::Options
::set_option
('window_title',$title) if defined $title;
for (my $i=1; $i<=4; $i++) {
next unless defined $ps[$i];
Psh
::Options
::set_option
("ps$i",$ps[$i]);
Psh
::Options
::del_option
('ps3') unless defined $ps[3];
Psh
::Options
::del_option
('ps4') unless defined $ps[4];
Psh
::Options
::del_option
('promp_command');
my @dirs= (Psh
::OS
::catdir
(Psh
::OS
::rootdir
(),'usr','share',
Psh
::OS
::catdir
(Psh
::OS
::rootdir
(),'usr','local','share',
Psh
::OS
::catdir
(Psh
::OS
::get_home_dir
(),'.psh','share','themes'),
Psh
::OS
::catdir
(Psh
::OS
::rootdir
(),'psh','themes'));
foreach my $dir (@dirs) {
my @tmp= Psh
::OS
::glob('*',$dir,1);
foreach my $file (@tmp) {
my $full= Psh
::OS
::catfile
($dir,$file);
next if !-r
$full or -d _
;
Psh
::Util
::print_list
(@result);
if ($line=~/$Psh::OS::FILE_SEPARATOR/) { # abs path specified
my $tmp= Psh
::Util
::abs_path
($line);
return _set_theme
($tmp) if $tmp;
foreach my $dir (@dirs) {
my $file= Psh
::OS
::catfile
($dir,$line);
return _set_theme
("$file.bt");
return _set_theme
($file);
Psh
::Util
::print_error
("Could not find theme '$line'.\n");
return $color_table{$name};