Bläddra i källkod

started on ANSI sequence processing

tags/v0.9.3
Dan Lynch 18 år sedan
förälder
incheckning
f9887c3f0f
1 ändrade filer med 22 tillägg och 1 borttagningar
  1. 22
    1
      src/tests/curses_scr.c

+ 22
- 1
src/tests/curses_scr.c Visa fil

@@ -2,6 +2,7 @@
2 2
 #include <termios.h>
3 3
 #include <stddef.h>
4 4
 #include <stdio.h>
5
+#include <string.h>
5 6
 
6 7
 #define ESC 27
7 8
 #define MODE 3
@@ -46,7 +47,27 @@ void _putc( struct _curses_screen *scr __unused, chtype c ) {
46 47
 }
47 48
 
48 49
 int _getc( struct _curses_screen *scr __unused ) {
49
-	return getchar();
50
+	int c;
51
+	char buffer[16];
52
+	char *ptr;
53
+	c = getchar();
54
+	if ( c == '\n' )
55
+		return KEY_ENTER;
56
+	/*
57
+	  WE NEED TO PROCESS ANSI SEQUENCES TO PASS BACK KEY_* VALUES
58
+	if ( c == ESC ) {
59
+		ptr = buffer;
60
+		while ( scr->peek( scr ) == TRUE ) {
61
+			*(ptr++) = getchar();
62
+		}
63
+
64
+		// ANSI sequences
65
+		if ( strcmp ( buffer, "[D" ) == 0 )
66
+			return KEY_LEFT;
67
+	}
68
+	*/
69
+
70
+	return c;
50 71
 }
51 72
 
52 73
 bool _peek( struct _curses_screen *scr __unused ) {

Laddar…
Avbryt
Spara