d74b327
diff --git a/display.c b/display.c
8edf2cb
index b11b18b..180f19c 100644
d74b327
--- a/display.c
d74b327
+++ b/display.c
8edf2cb
@@ -3818,4 +3818,10 @@ char **cmdv;
3f891b1
 
3f891b1
 #endif /* BLANKER_PRG */
3f891b1
 
3f891b1
+void
3f891b1
+ClearScrollbackBuffer()
3f891b1
+{
3f891b1
+  if (D_CE3)
3f891b1
+    AddCStr(D_CE3);
3f891b1
+}
3f891b1
 
d74b327
diff --git a/extern.h b/extern.h
8edf2cb
index 7966008..e1ec242 100644
d74b327
--- a/extern.h
d74b327
+++ b/extern.h
3f891b1
@@ -316,6 +316,7 @@ extern int   color256to88 __P((int));
3f891b1
 extern void  ResetIdle __P((void));
3f891b1
 extern void  KillBlanker __P((void));
3f891b1
 extern void  DisplaySleep1000 __P((int, int));
3f891b1
+extern void  ClearScrollbackBuffer __P((void));
3f891b1
 
3f891b1
 /* resize.c */
3f891b1
 extern int   ChangeWindowSize __P((struct win *, int, int, int));
d74b327
diff --git a/screen.c b/screen.c
8edf2cb
index 64650e9..c68d949 100644
d74b327
--- a/screen.c
d74b327
+++ b/screen.c
8edf2cb
@@ -1958,6 +1958,7 @@ void Detach(int mode)
8edf2cb
 
3f891b1
     case D_LOCK:
3f891b1
       ClearAll();
3f891b1
+      ClearScrollbackBuffer();
3f891b1
       sign = SIG_LOCK;
3f891b1
       /* tell attacher to lock terminal with a lockprg. */
3f891b1
       break;
d74b327
diff --git a/term.c b/term.c
8edf2cb
index c92d85a..a6e9200 100644
d74b327
--- a/term.c
d74b327
+++ b/term.c
3f891b1
@@ -83,6 +83,7 @@ struct term term[T_N] =
3f891b1
   { "CD", T_STR  },
3f891b1
   { "ce", T_STR  },
3f891b1
   { "cb", T_STR  },
3f891b1
+  { "E3", T_STR  },
3f891b1
 
3f891b1
 /* initialise */
3f891b1
   { "is", T_STR  },