repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 6b297581cb6649bcaa1139f24b1f7804da05ea60:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 6b297581cb6649bcaa1139f24b1f7804da05ea60
Author: Marc Lehmann 
Date:   Sun Jan 8 01:16:10 2006 +0000

    *** empty log message ***

diff --git a/src/perl/option-popup b/src/perl/option-popup
index 45e3301591b5a6e353d603610015a726468f47c7..
index ..5ac602663613612d3a6890de37b68a1a36d5b27c 100644
--- a/src/perl/option-popup
+++ b/src/perl/option-popup
@@ -12,6 +12,9 @@ sub on_button_press {
    if ($event->{button} == 3 && $event->{state} & urxvt::ControlMask) {
       my $popup = $self->popup ($event);

+      $popup->add_title ("Options");
+      $popup->add_separator;
+
       my %unsafe = map +($_ => 1),
          qw(borderLess console iconic loginShell reverseVideo
             scrollBar scrollBar_floating scrollBar_right
diff --git a/src/perl/urxvt-popup b/src/perl/urxvt-popup
index ed343f98e9da0a9f35088f19abc0510bc8c5ce6b..
index ..b1f3cbdfb818756c5014b64bcbfa0554f384bc96 100644
--- a/src/perl/urxvt-popup
+++ b/src/perl/urxvt-popup
@@ -10,13 +10,13 @@ sub refresh {

    my $row = 1;
    for my $item (@{ $self->{data}{item} }) {
-      my $rend = "\x1b[30;47m";
+      my $rend = "normal";

       if ($row == $self->{hover}) {
-         $rend = $self->{press} ? "\x1b[m" : "\x1b[30;46m";
+         $rend = $self->{press} ? "active" : "hover";
       }

-      $cmd .= "$rend\x1b[K";
+      $cmd .= "$item->{rend}{$rend}\x1b[K";
       $cmd .= $self->locale_encode ($item->{render}->($item));
       $cmd .= "\015\012";

diff --git a/src/urxvt.pm b/src/urxvt.pm
index 58e1d1166e5eed66bb3e49823f85ff28cb141224..
index ..f11ee1df5b08c150313bed8a3be1a15463fc1cc4 100644
--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -1027,15 +1027,42 @@ package urxvt::popup;
 sub add_item {
    my ($self, $item) = @_;

+   $item->{rend}{normal} = "\x1b[0;30;47m" unless exists $item->{rend}{normal};
+   $item->{rend}{hover}  = "\x1b[0;30;46m" unless exists $item->{rend}{hover};
+   $item->{rend}{active} = "\x1b[m"        unless exists $item->{rend}{active};
+
+   $item->{render} ||= sub { $_[0]{text} };
+
    push @{ $self->{item} }, $item;
 }

+sub add_separator {
+   my ($self, $sep) = @_;
+
+   $sep ||= "═";
+
+   $self->add_item ({
+      rend => { normal => "\x1b[0;30;47m", hover => "\x1b[0;30;47m", active => "\x1b[0;30;47m" },
+      text => "",
+      render => sub { $sep x $urxvt::TERM->ncol },
+      activate => sub { },
+   });
+}
+
+sub add_title {
+   my ($self, $title) = @_;
+
+   $self->add_item ({
+      rend => { normal => "\x1b[38;5;11;44m", hover => "\x1b[38;5;11;44m", active => "\x1b[38;5;11;44m" },
+      text => $title,
+      activate => sub { },
+   });
+}
+
 sub add_button {
    my ($self, $text, $cb) = @_;

-   $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb,
-      render => sub { $_[0]{text} },
-   });
+   $self->add_item ({ type => "button", text => "[ $text ]", activate => $cb});
 }

 sub add_toggle {

-----END OF PAGE-----