[Cbe-oss-dev] [PATCH 1/2] spu-tools: Fix handling of escape sequences on spu-top

Andre Detsch adetsch at br.ibm.com
Sat Apr 12 01:09:14 EST 2008


Fix handling of escape sequences on spu-top.

Signed-off-by: Andre Detsch <adetsch at br.ibm.com>

Index: libspe2/tools/spu-tools/src/spu-top.c
===================================================================
--- libspe2.orig/tools/spu-tools/src/spu-top.c
+++ libspe2/tools/spu-tools/src/spu-top.c
@@ -364,6 +364,7 @@ int main(int argc, char **argv)
 	struct proc** procs;
 	struct ctx** ctxs;
 	struct timeval last_time, current_time;
+	char* term;
 
 	/* Parse options */
 	static struct option long_options[] = {
@@ -392,6 +393,21 @@ int main(int argc, char **argv)
 	/* Init ncurses library */
 	init_ncurses();
 	halfdelay(refresh_delay);
+	keypad(stdscr, true);
+	term = getenv("TERM");
+	if (!strcmp(term, "xterm") || !strcmp(term, "xterm-color") || !strcmp(term, "vt220")) {
+		define_key("\033[H", KEY_HOME);
+		define_key("\033[F", KEY_END);
+		define_key("\033OP", KEY_F(1));
+		define_key("\033OQ", KEY_F(2));
+		define_key("\033OR", KEY_F(3));
+		define_key("\033OS", KEY_F(4));
+		define_key("\033[11~", KEY_F(1));
+		define_key("\033[12~", KEY_F(2));
+		define_key("\033[13~", KEY_F(3));
+		define_key("\033[14~", KEY_F(4));
+		define_key("\033[17;2~", KEY_F(18));
+	}
 
 	/* Handle signals */
 	atexit(quit);



More information about the cbe-oss-dev mailing list