xyb3rt / urxvt-perls

Perl extensions for the rxvt-unicode terminal emulator
GNU General Public License v2.0
754 stars 110 forks source link

Contrib #76

Closed faqz closed 7 years ago

faqz commented 7 years ago

Second attempt to contribute to your project Bert.

Three extensions are contributed:

pinky-urxvt - Status line based on tabbed and tabbedex. The sole purpose of this extension is to make it easy for you to keep track of things that you are interested to monitor while hacking your way something in the terminal.

urxvt-man2pdf - Convert man page while reading it to pdf. No need to quit reading or open another terminal instance/tab.

urxvt-pasta - Same description as https://github.com/muennich/urxvt-perls/pull/73

ebiza commented 7 years ago

pinky-urxvt.diff

--- 
+++ 
@@ -28,11 +28,12 @@

 sub refresh {
   my ($self) = @_;
+
   my $ncol = $self->ncol;
   my $text = " " x $ncol;
   my $rend = [($self->{rs_pinky}) x $ncol];

-  my $statusLine = $self->{pinky_tab}[0];
+  my $statusLine = $self->{pinky_line}[0];
   my $txt = $statusLine->{name} || "";
   my $len = length $txt;

@@ -46,7 +47,7 @@
 }

-sub new_pinky_tab {
+sub new_pinky_status_line {
   my ($self, @argv) = @_;

   push @urxvt::TERM_INIT, sub {
@@ -73,28 +74,9 @@

   push @urxvt::TERM_EXT, urxvt::ext::pinky::pinky_status::;

-  my @argv_list = ( @{$self->{argv}} , @argv );
-  my $term = new urxvt::term
-    $self->env, $urxvt::RXVTNAME,
-    -embed => $self->parent,
-   @argv_list;
-
-  return $term;
-}
-
-
-sub configure {
-  my ($self) = @_;
-  my $x = 0;
-  my $statusLine = $self->{cur};
+  new urxvt::term $self->env, $urxvt::RXVTNAME,
+    -embed => $self->parent, ();

-  for (; $x < 2; $x++) {
-    $statusLine->XMoveResizeWindow (
-      $statusLine->parent,
-      0, $self->{tabheight} + $x,
-      $self->width, $self->height - $self->{tabheight}
-    );
-  }
   return;
 }

@@ -115,24 +97,17 @@
 }

-sub make_current {
+sub make_pinky_window {
   my ($self, $statusLine) = @_;
-  my $cur = $self->{cur};
-
-  if ($cur) {
-    if ($cur->mapped) {
-      $cur->XUnmapWindow ($cur->parent);
-    }
-    $cur->focus_out;
-  }

   $self->{cur} = $statusLine;
-  $self->configure;

-  $statusLine->focus_out;
-  if ($self->focus) {
-    $statusLine->focus_in;
-  }
+  $self->{cur}->XMoveResizeWindow (
+    $self->{cur}->parent,
+    0, $self->{lineheight},
+    $self->width,
+    $self->height - $self->{lineheight}
+  );

   $statusLine->XMapWindow ($statusLine->parent);
   $self->refresh;
@@ -148,14 +123,6 @@
 }

-sub on_focus_out {
-  my ($self, $event) = @_;
-
-  $self->{cur}->focus_out;
-  return;
-}
-
-
 sub on_tt_write {
   my ($self, $octets) = @_;

@@ -191,17 +158,10 @@
 sub on_start {
   my ($self) = @_;

-  $self->{maxtabheight} = $self->int_bwidth + $self->fheight + $self->lineSpace;
-  $self->{tabheight} = $self->{maxtabheight};
+  $self->{lineheight} = $self->int_bwidth + $self->fheight + $self->lineSpace;
   $self->cmd_parse ("\033[?25l");

-  my @argv = $self->argv;
-  do {
-    shift @argv;
-  } while @argv && $argv[0] ne "-e";
-  $self->{argv} = \@argv;
-
-  $self->new_pinky_tab;
+  $self->new_pinky_status_line;
   return;
 }

@@ -209,7 +169,7 @@
 sub on_wm_delete_window {
   my ($self) = @_;

-  $_->destroy for @{$self->{pinky_tab}};
+  $_->destroy for @{$self->{pinky_line}};
   return 1;
 }

@@ -217,8 +177,8 @@
 sub pinky_status_start {
   my ($self, $statusLine) = @_;

-  push @{ $self->{pinky_tab} }, $statusLine;
-  $self->make_current ($statusLine);
+  push @{$self->{pinky_line}}, $statusLine;
+  $self->make_pinky_window ($statusLine);
   return;
 }

@@ -240,7 +200,6 @@
   if ($1 eq "update_line") {
     my ($name) = split /;/, $osc , 1;
     $statusLine->{name} = $name;
-    $self->configure;
     $self->refresh;
   }
   return 1;
ghost commented 7 years ago

urxvt-perls fork with those extensions included can be found at - https://github.com/uz2/urxvt-perls/tree/master/contrib

xyb3rt commented 7 years ago

I do not consider my urxvt-perls repo to be a central resource for rxvt-unicode extensions. The rxvt-unicode project itself seems to be the right place if you want to contribute them somewhere official.