… | |
… | |
675 | @TERM_EXT = (); |
675 | @TERM_EXT = (); |
676 | $TERM->register_package ($_) for @pkg; |
676 | $TERM->register_package ($_) for @pkg; |
677 | } |
677 | } |
678 | |
678 | |
679 | for ( |
679 | for ( |
680 | @{ delete $TERM->{perl_ext_3} }, |
|
|
681 | grep $_, map { split /,/, $TERM->resource ("perl_ext_$_") } 1, 2 |
680 | grep $_, map { split /,/, $TERM->resource ("perl_ext_$_") } 1, 2 |
682 | ) { |
681 | ) { |
683 | if ($_ eq "default") { |
682 | if ($_ eq "default") { |
684 | $ext_arg{$_} ||= [] for qw(selection option-popup selection-popup searchable-scrollback readline); |
683 | |
|
|
684 | $ext_arg{$_} = [] |
|
|
685 | for |
|
|
686 | qw(selection option-popup selection-popup readline), |
|
|
687 | map $_->[0], values %{ $TERM->{meta}{binding} }, |
|
|
688 | @{ delete $TERM->{perl_ext_3} }; |
|
|
689 | |
|
|
690 | for ($TERM->_keysym_resources) { |
|
|
691 | next if /^(?:string|command|builtin|builtin-string|perl)/; |
|
|
692 | next unless /^([A-Za-z0-9_\-]+):/; |
|
|
693 | |
|
|
694 | my $ext = $1; |
|
|
695 | $ext =~ y/-/_/; |
|
|
696 | |
|
|
697 | $ext_arg{$ext} = []; |
|
|
698 | } |
|
|
699 | |
685 | } elsif (/^-(.*)$/) { |
700 | } elsif (/^-(.*)$/) { |
686 | delete $ext_arg{$1}; |
701 | delete $ext_arg{$1}; |
|
|
702 | |
687 | } elsif (/^([^<]+)<(.*)>$/) { |
703 | } elsif (/^([^<]+)<(.*)>$/) { |
688 | push @{ $ext_arg{$1} }, $2; |
704 | push @{ $ext_arg{$1} }, $2; |
|
|
705 | |
689 | } else { |
706 | } else { |
690 | $ext_arg{$_} ||= []; |
707 | $ext_arg{$_} ||= []; |
|
|
708 | } |
|
|
709 | } |
|
|
710 | |
|
|
711 | # now register default key bindings |
|
|
712 | for my $ext (sort keys %ext_arg) { |
|
|
713 | while (my ($k, $v) = each %{ $TERM->{meta}{ext}{$ext}{binding} }) { |
|
|
714 | $TERM->bind_action ($k, "$v->[0]:$v->[1]"); |
691 | } |
715 | } |
692 | } |
716 | } |
693 | |
717 | |
694 | for my $ext (sort keys %ext_arg) { |
718 | for my $ext (sort keys %ext_arg) { |
695 | my @files = grep -f $_, map "$_/$ext", @dirs; |
719 | my @files = grep -f $_, map "$_/$ext", @dirs; |
… | |
… | |
1079 | |
1103 | |
1080 | return if exists $self->{meta}; |
1104 | return if exists $self->{meta}; |
1081 | |
1105 | |
1082 | my @libdirs = perl_libdirs $self; |
1106 | my @libdirs = perl_libdirs $self; |
1083 | |
1107 | |
1084 | return if $self->{meta_libdirs} eq join "\x00", @libdirs; |
1108 | # return if $self->{meta_libdirs} eq join "\x00", @libdirs;#d# |
1085 | |
1109 | |
1086 | my %meta; |
|
|
1087 | |
|
|
1088 | $self->{meta_libdirs} = join "\x00", @libdirs; |
1110 | # $self->{meta_libdirs} = join "\x00", @libdirs;#d# |
1089 | $self->{meta} = \%meta; |
1111 | $self->{meta} = \my %meta; |
1090 | |
|
|
1091 | my %ext; |
|
|
1092 | |
1112 | |
1093 | # first gather extensions |
1113 | # first gather extensions |
1094 | for my $dir (reverse @libdirs) { |
1114 | for my $dir (reverse @libdirs) { |
1095 | opendir my $fh, $dir |
1115 | opendir my $fh, $dir |
1096 | or next; |
1116 | or next; |
… | |
… | |
1110 | } else { |
1130 | } else { |
1111 | $ext{resource}{$pattern} = [$ext, $type, $desc]; |
1131 | $ext{resource}{$pattern} = [$ext, $type, $desc]; |
1112 | } |
1132 | } |
1113 | } elsif (/^#:META:BINDING:(.*)/) { |
1133 | } elsif (/^#:META:BINDING:(.*)/) { |
1114 | my ($keysym, $action) = split /:/, $1; |
1134 | my ($keysym, $action) = split /:/, $1; |
1115 | $ext{binding}{$keysym} = $action; |
1135 | $ext{binding}{$keysym} = [$ext, $action]; |
1116 | } elsif (/^\s*(?:#|$)/) { |
1136 | } elsif (/^\s*(?:#|$)/) { |
1117 | # skip other comments and empty lines |
1137 | # skip other comments and empty lines |
1118 | } else { |
1138 | } else { |
1119 | last; # stop parsing on first non-empty non-comment line |
1139 | last; # stop parsing on first non-empty non-comment line |
1120 | } |
1140 | } |
1121 | } |
1141 | } |
1122 | |
1142 | |
1123 | $meta{$ext} = \%ext; |
1143 | $meta{ext}{$ext} = \%ext; |
1124 | } |
1144 | } |
1125 | } |
1145 | } |
1126 | |
1146 | |
1127 | # and now merge resources and bindings |
1147 | # and now merge resources and bindings |
1128 | while (my ($k, $v) = each %ext) { |
1148 | while (my ($k, $v) = each %{ $meta{ext} }) { |
1129 | #TODO: should check for extensions overriding each other |
1149 | #TODO: should check for extensions overriding each other |
1130 | %{ $meta{resource} } = (%{ $meta{resource} }, %{ $v->{resource} }); |
1150 | %{ $meta{resource} } = (%{ $meta{resource} }, %{ $v->{resource} }); |
1131 | %{ $meta{binding} } = (%{ $meta{binding} }, %{ $v->{binding} }); |
1151 | %{ $meta{binding} } = (%{ $meta{binding} }, %{ $v->{binding} }); |
1132 | } |
1152 | } |
1133 | } |
1153 | } |