repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: bd545c8a7945c5d7b5289af43fc8d3480ab2b779:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit bd545c8a7945c5d7b5289af43fc8d3480ab2b779
Author: Emanuele Giaquinta 
Date:   Wed Nov 2 15:11:51 2011 +0000

    Unify selection fixup in scr_scroll_text.

    Fixes selection update when scrolling up and the selection is outside
    the scrolling region. Before this change urxvt would wrongly scroll the
    selection in this case.

diff --git a/src/screen.C b/src/screen.C
index 8fe3dbf96fcc5587e18b45449e24ab270be2b421..
index ..c825b275d5ccbdd8d5422b61a255e976d70a422f 100644
--- a/src/screen.C
+++ b/src/screen.C
@@ -683,16 +683,6 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW
             scr_blank_screen_mem (l, rstyle);
         }

-      // move and/or clear selection, if any
-      if (selection.op && current_screen == selection.screen)
-        {
-          selection.beg.row  -= count;
-          selection.end.row  -= count;
-          selection.mark.row -= count;
-
-          selection_check (0);
-        }
-
       // finally move the view window, if desired
       if (option (Opt_scrollWithBuffer)
           && view_start != 0
@@ -704,29 +694,6 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW
     }
   else
     {
-      if (selection.op && current_screen == selection.screen)
-        {
-          if ((selection.beg.row < row1 && selection.end.row > row1)
-              || (selection.beg.row < row2 && selection.end.row > row2)
-              || (selection.beg.row - count < row1 && selection.beg.row >= row1)
-              || (selection.beg.row - count > row2 && selection.beg.row <= row2)
-              || (selection.end.row - count < row1 && selection.end.row >= row1)
-              || (selection.end.row - count > row2 && selection.end.row <= row2))
-            {
-              CLEAR_ALL_SELECTION ();
-              selection.op = SELECTION_CLEAR;
-            }
-          else if (selection.end.row >= row1 && selection.end.row <= row2)
-            {
-              /* move selected region too */
-              selection.beg.row  -= count;
-              selection.end.row  -= count;
-              selection.mark.row -= count;
-
-              selection_check (0);
-            }
-        }
-
       // use a simple and robust scrolling algorithm, this
       // part of scr_scroll_text is not time-critical.

@@ -763,6 +730,27 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW
       }
     }

+  // move and/or clear selection, if any
+  if (selection.op && current_screen == selection.screen)
+    {
+      if ((selection.beg.row < row1 && selection.end.row > row1)
+          || (selection.beg.row < row2 && selection.end.row > row2)
+          || (selection.beg.row - count < row1 && selection.beg.row >= row1)
+          || (selection.beg.row - count > row2 && selection.beg.row <= row2)
+          || (selection.end.row - count < row1 && selection.end.row >= row1)
+          || (selection.end.row - count > row2 && selection.end.row <= row2))
+        CLEAR_ALL_SELECTION ();
+      else if (selection.end.row >= row1 && selection.end.row <= row2)
+        {
+          /* move selected region too */
+          selection.beg.row  -= count;
+          selection.end.row  -= count;
+          selection.mark.row -= count;
+
+          selection_check (0);
+        }
+    }
+
   return count;
 }

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