Improve redrawing of screen

This commit is contained in:
Michael Krayer 2025-04-08 14:15:05 +02:00
parent 748020b2fa
commit 82ffbac28b
1 changed files with 11 additions and 7 deletions

View File

@ -40,7 +40,7 @@ restore_term(void)
tcsetattr(0, TCSADRAIN, &orig_term); tcsetattr(0, TCSADRAIN, &orig_term);
/* Make cursor visible. Assumes VT100. */ /* Make cursor visible. Assumes VT100. */
printf("\033[?25h"); printf("\033[?25h\033[?1049l");
fflush(stdout); fflush(stdout);
} }
@ -214,7 +214,9 @@ attach_main(int noerror)
tcsetattr(0, TCSADRAIN, &cur_term); tcsetattr(0, TCSADRAIN, &cur_term);
/* Clear the screen. This assumes VT100. */ /* Clear the screen. This assumes VT100. */
write(1, "\33[H\33[J", 6); printf("\033[?1049h\033[H");
fflush(stdout);
/* write(1, "\33[H\33[J", 6); */
/* Tell the master that we want to attach. */ /* Tell the master that we want to attach. */
memset(&pkt, 0, sizeof(struct packet)); memset(&pkt, 0, sizeof(struct packet));
@ -238,7 +240,8 @@ attach_main(int noerror)
n = select(s + 1, &readfds, NULL, NULL, NULL); n = select(s + 1, &readfds, NULL, NULL, NULL);
if (n < 0 && errno != EINTR && errno != EAGAIN) if (n < 0 && errno != EINTR && errno != EAGAIN)
{ {
printf(EOS "\r\n[select failed]\r\n"); restore_term();
printf(EOS "[select failed]\r\n");
exit(1); exit(1);
} }
@ -249,13 +252,14 @@ attach_main(int noerror)
if (len == 0) if (len == 0)
{ {
printf(EOS "\r\n[EOF - dtach terminating]" restore_term();
"\r\n"); printf(EOS "[EOF - dtach terminating]\r\n");
exit(0); exit(0);
} }
else if (len < 0) else if (len < 0)
{ {
printf(EOS "\r\n[read returned an error]\r\n"); restore_term();
printf(EOS "[read returned an error]\r\n");
exit(1); exit(1);
} }
/* Send the data to the terminal. */ /* Send the data to the terminal. */