changeset 17240:11459d1ff17c

Use termcap "erase to end of line" character code instead of using spaces to end of screen.
author ods15
date Sun, 25 Dec 2005 18:26:35 +0000
parents b654001ae89a
children 3ab613cdf96a
files mplayer.c osdep/getch2.c osdep/getch2.h
diffstat 3 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mplayer.c	Sun Dec 25 17:38:19 2005 +0000
+++ b/mplayer.c	Sun Dec 25 18:26:35 2005 +0000
@@ -962,9 +962,8 @@
     saddf(line, &pos, width, "%4.2fx ", playback_speed);
 
   // end
-  memset(&line[pos], ' ', width - pos);
-  line[width] = 0;
-  mp_msg(MSGT_AVSYNC, MSGL_STATUS, "%s\r", line);
+  line[pos] = 0;
+  mp_msg(MSGT_AVSYNC, MSGL_STATUS, "%s%s\r", line, erase_to_end_of_line);
   free(line);
 }
 
--- a/osdep/getch2.c	Sun Dec 25 17:38:19 2005 +0000
+++ b/osdep/getch2.c	Sun Dec 25 18:26:35 2005 +0000
@@ -40,6 +40,7 @@
 
 int screen_width=80;
 int screen_height=24;
+char * erase_to_end_of_line = "\033[J";
 
 typedef struct {
   int len;
@@ -78,6 +79,7 @@
 static int success=0;
 
 int load_termcap(char *termtype){
+  char * p;
   if(!termtype) termtype=getenv("TERM");
   if(!termtype) termtype="unknown";
   success=tgetent(term_buffer, termtype);
@@ -88,6 +90,7 @@
   screen_height=tgetnum("li");
   if(screen_width<1 || screen_width>255) screen_width=80;
   if(screen_height<1 || screen_height>255) screen_height=24;
+  if ((p = tgetstr("cd",&term_p))) erase_to_end_of_line=p;
 
   termcap_add("kP",KEY_PGUP);
   termcap_add("kN",KEY_PGDWN);
--- a/osdep/getch2.h	Sun Dec 25 17:38:19 2005 +0000
+++ b/osdep/getch2.h	Sun Dec 25 18:26:35 2005 +0000
@@ -5,6 +5,9 @@
 extern int screen_width;
 extern int screen_height;
 
+/* Termcap code to erase to end of line */
+extern char * erase_to_end_of_line;
+
 /* Get screen-size using IOCTL call. */
 extern void get_screen_size();