[MPlayer-dev-eng] [PATCH] erase to end of line termcap try 2
Oded Shimon
ods15 at ods15.dyndns.org
Tue Dec 27 21:36:18 CET 2005
On Tue, Dec 27, 2005 at 10:34:32PM +0200, Oded Shimon wrote:
> hope this fix will please everyone, asking on ml first.
> code now defaults to exactly old behavior, unless there is a termcap code
> that can tell it otherwise. meaning, on windows you'll get the old
> behavior.
>
> - ods15
-------------- next part --------------
Index: osdep/getch2-win.c
===================================================================
RCS file: /cvsroot/mplayer/main/osdep/getch2-win.c,v
retrieving revision 1.9
diff -u -r1.9 getch2-win.c
--- osdep/getch2-win.c 27 Dec 2005 10:42:02 -0000 1.9
+++ osdep/getch2-win.c 27 Dec 2005 20:31:59 -0000
@@ -22,7 +22,7 @@
int screen_width=80;
int screen_height=24;
-char * erase_to_end_of_line = " \r";
+char * erase_to_end_of_line = NULL;
void get_screen_size(){
}
Index: osdep/getch2.c
===================================================================
RCS file: /cvsroot/mplayer/main/osdep/getch2.c,v
retrieving revision 1.21
diff -u -r1.21 getch2.c
--- osdep/getch2.c 25 Dec 2005 18:26:35 -0000 1.21
+++ osdep/getch2.c 27 Dec 2005 20:31:59 -0000
@@ -40,7 +40,7 @@
int screen_width=80;
int screen_height=24;
-char * erase_to_end_of_line = "\033[J";
+char * erase_to_end_of_line = NULL;
typedef struct {
int len;
@@ -79,7 +79,6 @@
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);
@@ -90,7 +89,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;
+ erase_to_end_of_line= tgetstr("cd",&term_p);
termcap_add("kP",KEY_PGUP);
termcap_add("kN",KEY_PGDWN);
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.897
diff -u -r1.897 mplayer.c
--- mplayer.c 27 Dec 2005 10:42:02 -0000 1.897
+++ mplayer.c 27 Dec 2005 20:32:03 -0000
@@ -962,8 +962,14 @@
saddf(line, &pos, width, "%4.2fx ", playback_speed);
// end
- line[pos] = 0;
- mp_msg(MSGT_AVSYNC, MSGL_STATUS, "%s%s\r", erase_to_end_of_line, line);
+ if (erase_to_end_of_line) {
+ line[pos] = 0;
+ mp_msg(MSGT_AVSYNC, MSGL_STATUS, "%s%s\r", line, erase_to_end_of_line);
+ } else {
+ memset(&line[pos], ' ', width - pos);
+ line[width] = 0;
+ mp_msg(MSGT_AVSYNC, MSGL_STATUS, "%s\r", line);
+ }
free(line);
}
More information about the MPlayer-dev-eng
mailing list