Skip to content

Instantly share code, notes, and snippets.

Created April 30, 2012 15:03
Show Gist options
  • Save anonymous/2559054 to your computer and use it in GitHub Desktop.
Save anonymous/2559054 to your computer and use it in GitHub Desktop.
urxvt: updated clear.patch
diff -r 4399ffb6a87c -r 48f53e1cf599 src/command.C
--- a/src/command.C Sat Jan 21 13:57:22 2012 +0100
+++ b/src/command.C Mon Apr 30 16:22:25 2012 +0200
@@ -2869,6 +2869,10 @@
return;
}
+ /* remember the current row on position change, in case there's a clear screen
+ * right after, so that we can add "preserve" the buffer (e.g. on ^L) */
+ static int old_row = -1, was_moved = 0;
+
switch (ch)
{
/*
@@ -2932,6 +2936,12 @@
case CSI_CUP: /* 8.3.21: (1,1) CURSOR POSITION */
case CSI_HVP: /* 8.3.64: (1,1) CHARACTER AND LINE POSITION */
+ /* if moving to row 1, remember current row in case a clear screen comes next */
+ if (nargs == 1 && arg[0] == 1 && current_screen == 0)
+ {
+ was_moved = 1;
+ old_row = screen.cur.row;
+ }
scr_gotorc (arg[0] - 1, nargs < 2 ? 0 : (arg[1] - 1), 0);
break;
@@ -2943,6 +2953,16 @@
break;
case CSI_ED: /* 8.3.40: (0) ERASE IN PAGE */
+ if (was_moved)
+ {
+ /* this is most likely a ^L, so we'll go back to where we where before
+ * the position change, add a screen of empty lines, then move back
+ * on top. that way the (scrolling) buffer will be preserved */
+ scr_gotorc (old_row, 0, 0);
+ for (int i = nrow - 1; i > 0; --i)
+ scr_add_lines (L"\r\n", 2);
+ scr_gotorc (0, 0, 0);
+ }
scr_erase_screen (arg[0]);
break;
@@ -3086,6 +3106,16 @@
default:
break;
}
+ if (was_moved > 0)
+ {
+ if (was_moved > 1)
+ {
+ was_moved = 0;
+ old_row = -1;
+ }
+ else
+ ++was_moved;
+ }
}
/*}}} */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment