… | |
… | |
1025 | package urxvt::popup; |
1025 | package urxvt::popup; |
1026 | |
1026 | |
1027 | sub add_item { |
1027 | sub add_item { |
1028 | my ($self, $item) = @_; |
1028 | my ($self, $item) = @_; |
1029 | |
1029 | |
|
|
1030 | $item->{rend}{normal} = "\x1b[0;30;47m" unless exists $item->{rend}{normal}; |
|
|
1031 | $item->{rend}{hover} = "\x1b[0;30;46m" unless exists $item->{rend}{hover}; |
|
|
1032 | $item->{rend}{active} = "\x1b[m" unless exists $item->{rend}{active}; |
|
|
1033 | |
|
|
1034 | $item->{render} ||= sub { $_[0]{text} }; |
|
|
1035 | |
1030 | push @{ $self->{item} }, $item; |
1036 | push @{ $self->{item} }, $item; |
|
|
1037 | } |
|
|
1038 | |
|
|
1039 | sub add_separator { |
|
|
1040 | my ($self, $sep) = @_; |
|
|
1041 | |
|
|
1042 | $sep ||= "═"; |
|
|
1043 | |
|
|
1044 | $self->add_item ({ |
|
|
1045 | rend => { normal => "\x1b[0;30;47m", hover => "\x1b[0;30;47m", active => "\x1b[0;30;47m" }, |
|
|
1046 | text => "", |
|
|
1047 | render => sub { $sep x $urxvt::TERM->ncol }, |
|
|
1048 | activate => sub { }, |
|
|
1049 | }); |
|
|
1050 | } |
|
|
1051 | |
|
|
1052 | sub add_title { |
|
|
1053 | my ($self, $title) = @_; |
|
|
1054 | |
|
|
1055 | $self->add_item ({ |
|
|
1056 | rend => { normal => "\x1b[38;5;11;44m", hover => "\x1b[38;5;11;44m", active => "\x1b[38;5;11;44m" }, |
|
|
1057 | text => $title, |
|
|
1058 | activate => sub { }, |
|
|
1059 | }); |
1031 | } |
1060 | } |
1032 | |
1061 | |
1033 | sub add_button { |
1062 | sub add_button { |
1034 | my ($self, $text, $cb) = @_; |
1063 | my ($self, $text, $cb) = @_; |
1035 | |
1064 | |
1036 | $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb, |
1065 | $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb}); |
1037 | render => sub { $_[0]{text} }, |
|
|
1038 | }); |
|
|
1039 | } |
1066 | } |
1040 | |
1067 | |
1041 | sub add_toggle { |
1068 | sub add_toggle { |
1042 | my ($self, $text, $cb, $value) = @_; |
1069 | my ($self, $text, $cb, $value) = @_; |
1043 | |
1070 | |