repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: c2538b892f48fdd196738bba14221615628d57b4:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit c2538b892f48fdd196738bba14221615628d57b4
Author: Marc Lehmann 
Date:   Sun Jan 15 05:14:12 2006 +0000

    *** empty log message ***

diff --git a/Changes b/Changes
index 3f7cb5868ebd5cb61ea3dfde59f0eb696cf734c3..
index ..a130e04ac9b2066f72eb04d637aa866328bb0c06 100644
--- a/Changes
+++ b/Changes
@@ -12,11 +12,18 @@ WISH: just for fun, do shade and tint with XRender.
 WISH: support tex fonts

 9.0
-TODO: scroll lines into scrollback when tscroll==0, regardless of bscrol
+	- use the scrollback buffer even when the scroll region doesn't
+          span the whole screen, as long as it starts at row 0.
+	- selection popup now shows selection in dec/hex/oct.
+        - perl/selection: matching on unicode characters in the selection
+          code was O(n²), which equals infinity in some degenerate cases
+          :-> Matching is now done on UTF-8, which makes it almost instant.
+        - perl/selection, perl/selection-autotransform: regexes are now
+          being interpreted in the locale urxvt was started.
+        - applied many patches by Emanuele Giaquinta that clean the code up
+          and fix more bugs in the utmp logging code.
 	- add tsl/fsl and related capabilities to the terminfo description,
           to set the window title.
-	- selection popup now shows selection in dec/hex/oct.
-        - fix some bugs in the utmp logging code.

 7.0  Fri Jan 13 14:02:18 CET 2006
 	- added sections for DISTRIBUTION MAINTAINERS and about
diff --git a/src/logging.C b/src/logging.C
index 36a9501f72183728a10eadf8d89776fcf1083fa1..
index ..5363d57d2ad0b7a4ed08797d64ffa0d163eb5922 100644
--- a/src/logging.C
+++ b/src/logging.C
@@ -46,11 +46,11 @@
 #ifdef UTMP_SUPPORT

 #if HAVE_STRUCT_UTMP
-int              rxvt_write_bsd_utmp              (int utmp_pos, struct utmp *wu);
-void             rxvt_update_wtmp                 (const char *fname, const struct utmp *putmp);
+static int              rxvt_write_bsd_utmp              (int utmp_pos, struct utmp *wu);
+static void             rxvt_update_wtmp                 (const char *fname, const struct utmp *putmp);
 #endif

-void             rxvt_update_lastlog              (const char *fname, const char *pty, const char *host);
+static void             rxvt_update_lastlog              (const char *fname, const char *pty, const char *host);

 /*
  * BSD style utmp entry
@@ -73,15 +73,13 @@ rxvt_term::makeutent (const char *pty, const char *hostname)
 #ifdef HAVE_STRUCT_UTMPX
   struct utmpx *utx = &this->utx;
 #endif
-#ifdef HAVE_UTMP_PID
   int i;
-#endif
   struct passwd *pwent = getpwuid (getuid ());

   if (!strncmp (pty, "/dev/", 5))
     pty += 5;		/* skip /dev/ prefix */

-#ifdef HAVE_UTMP_PID
+#if defined(HAVE_UTMP_PID) || defined(HAVE_STRUCT_UTMPX)
   if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3))
     strncpy (ut_id, pty + 3, sizeof (ut_id));
   else if (sscanf (pty, "pts/%d", &i) == 1)
@@ -169,7 +167,6 @@ rxvt_term::makeutent (const char *pty, const char *hostname)
 #if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)

   {
-    int             i;
 # ifdef HAVE_TTYSLOT
     i = ttyslot ();
     if (rxvt_write_bsd_utmp (i, ut))
@@ -330,8 +327,8 @@ rxvt_term::cleanutent ()
 /*
  * Write a BSD style utmp entry
  */
-#ifdef HAVE_UTMP_H
-int
+#if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)
+static int
 rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu)
 {
   int             fd;
@@ -351,7 +348,7 @@ rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu)
  * Update a BSD style wtmp entry
  */
 #if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) && defined(HAVE_STRUCT_UTMP)
-void
+static void
 rxvt_update_wtmp (const char *fname, const struct utmp *putmp)
 {
   int             fd, gotlock, retry;
@@ -392,7 +389,7 @@ rxvt_update_wtmp (const char *fname, const struct utmp *putmp)

 /* ------------------------------------------------------------------------- */
 #ifdef LASTLOG_SUPPORT
-void
+static void
 rxvt_update_lastlog (const char *fname, const char *pty, const char *host)
 {
 # ifdef HAVE_STRUCT_LASTLOGX
diff --git a/src/perl/selection b/src/perl/selection
index d5fdd8b254b8f855ad4ec8e15c9396d7c631b50b..
index ..ca71f9c3cf7375cde30915e0be63b688395a719e 100644
--- a/src/perl/selection
+++ b/src/perl/selection
@@ -14,6 +14,7 @@ sub on_init {

    for (my $idx = 0; defined (my $res = $self->x_resource ("selection.pattern-$idx")); $idx++) {
       no re 'eval'; # just to be sure
+      $res = utf8::encode $self->locale_decode ($res);
       push @{ $self->{patterns} }, qr/$res/;
    }

@@ -67,6 +68,12 @@ sub on_sel_extend {

    my @matches;

+   # not doing matches in unicode mode helps speed
+   # enourmously here. working in utf-8 should be
+   # equivalent due to the magic of utf-8 encoding.
+   utf8::encode $text;
+   study $text; # _really_ helps, too :)
+
    for my $regex (@mark_patterns, @{ $self->{patterns} }) {
       while ($text =~ /$regex/g) {
          if ($-[1] <= $markofs and $markofs <= $+[1]) {
diff --git a/src/perl/selection-autotransform b/src/perl/selection-autotransform
index 48e3c02c7e9c6e6ff572c3bc356b9c7df32a1964..
index ..22d5bbb68528c7967a86932e80eccfe51f9ff204 100644
--- a/src/perl/selection-autotransform
+++ b/src/perl/selection-autotransform
@@ -20,6 +20,7 @@ sub on_init {
    }

    for (my $idx = 0; defined (my $res = urxvt::untaint $self->x_resource ("selection-autotransform.$idx")); $idx++) {
+      $res = $self->locale_decode ($res);
       my $transform = eval "sub { $res }";

       if ($transform) {
diff --git a/src/screen.C b/src/screen.C
index 56c2dfb2b90b576a0858313ea6d41708bd560399..
index ..77d3575974fad8c522d02ded21048e2bd1bb3979 100644
--- a/src/screen.C
+++ b/src/screen.C
@@ -615,15 +615,48 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count)

   if (count > 0
       && row1 == 0
-      && row2 == nrow - 1
       && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll)))
     {
       nsaved = min (nsaved + count, saveLines);

       HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END));

+      // scroll everything up 'count' lines
       term_start = (term_start + count) % total_rows;

+      {
+        // severe bottommost scrolled line
+        line_t &l = ROW(row2 - count);
+        l.touch ();
+        l.is_longer (0);
+      }
+
+      // erase newly scorlled-in lines
+      for (int i = count; i; --i )
+        {
+          // basically this is a slightly optimized scr_blank_screen_mem
+          // it is worth the effort on slower machines
+          line_t &l = ROW(nrow - i);
+
+          scr_blank_line (l, 0, l.l, rstyle);
+
+          l.l = 0;
+          l.f = 0;
+        }
+
+      // now copy lines below the scroll region bottom to the
+      // bottom of the screen again, so they look as if they
+      // hadn't moved.
+      for (int i = nrow; --i > row2; )
+        {
+          line_t &l1 = ROW(i - count);
+          line_t &l2 = ROW(i);
+
+          ::swap (l1, l2);
+          l2.touch ();
+        }
+      
+      // move and/or clear selection, if any
       if (selection.op && current_screen == selection.screen)
         {
           selection.beg.row  -= count;
@@ -639,18 +672,7 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count)
             }
         }

-      for (int i = count; i--; )
-        {
-          // basically thi is a slightly optimized scr_blank_screen_mem
-          // it is worth the effort on slower machines
-          line_t &l = ROW(row2 - i);
-
-          scr_blank_line (l, 0, l.l, rstyle);
-
-          l.l = 0;
-          l.f = 0;
-        }
-      
+      // finally move the view window, if desired
       if (OPTION (Opt_scrollWithBuffer)
           && view_start != 0
           && view_start != saveLines)

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