[MPlayer-dev-eng] [PATCH] erase to end of line for status line
Oded Shimon
ods15 at ods15.dyndns.org
Sat Dec 24 20:54:06 CET 2005
Patch to make MPlayer use termcap code "cd", which means "clear to end of
line" instead of using a ton of spaces to erase the rest of the status
line.
pro: make mp_msg color more usable, less hackish in general
con: make redirecting output to file a bit worse, but this was never all
that good to begin with.
Could someone with a windows box report how this patch behaves with windows
terminal?
BTW, -term-osd-esc should upgrade to using same termcap method.
- ods15
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.894
diff -u -r1.894 mplayer.c
--- mplayer.c 7 Dec 2005 05:12:07 -0000 1.894
+++ mplayer.c 24 Dec 2005 19:35:16 -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);
}
Index: osdep/getch2.c
===================================================================
RCS file: /cvsroot/mplayer/main/osdep/getch2.c,v
retrieving revision 1.20
diff -u -r1.20 getch2.c
--- osdep/getch2.c 14 Nov 2005 00:28:03 -0000 1.20
+++ osdep/getch2.c 24 Dec 2005 19:35:17 -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);
Index: osdep/getch2.h
===================================================================
RCS file: /cvsroot/mplayer/main/osdep/getch2.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 getch2.h
--- osdep/getch2.h 24 Feb 2001 20:30:12 -0000 1.1.1.1
+++ osdep/getch2.h 24 Dec 2005 19:35:17 -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();
More information about the MPlayer-dev-eng
mailing list