summaryrefslogtreecommitdiff
blob: 050907cea435c7cf25bc0b26a353e5ab3b5b7cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
store visible lines to buffer before clearing the screen when pressing ctrl-l

patch by rlblaster
https://bbs.archlinux.org/viewtopic.php?id=129302

--- a/src/command.C
+++ b/src/command.C
@@ -2932,6 +2932,17 @@
 
       case CSI_CUP:		/* 8.3.21: (1,1) CURSOR POSITION */
       case CSI_HVP:		/* 8.3.64: (1,1) CHARACTER AND LINE POSITION */
+        if (nargs == 1 && current_screen == 0)
+          {
+            // This is usually followed with clear screen so add some extra
+            // lines to avoid deleting the lines already on screen. If we are
+            // already at the top, add an extra screen height of lines.
+            int extra_lines = nrow-1;
+            if (screen.cur.row == 0)
+              extra_lines += nrow;
+            for (int i = 0; i < extra_lines; ++i)
+              scr_add_lines (L"\r\n", 2);
+          }
         scr_gotorc (arg[0] - 1, nargs < 2 ? 0 : (arg[1] - 1), 0);
         break;