[Scummvm-cvs-logs] CVS: scummvm/gui console.cpp,1.8,1.9

Max Horn fingolfin at users.sourceforge.net
Sat Dec 14 14:19:01 CET 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv28576

Modified Files:
	console.cpp 
Log Message:
retrieve the input and (for now) print it back to the console

Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/console.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- console.cpp	14 Dec 2002 22:10:37 -0000	1.8
+++ console.cpp	14 Dec 2002 22:18:00 -0000	1.9
@@ -123,18 +123,29 @@
 
 void ConsoleDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers)
 {
+	int i;
+	
 	switch (keycode) {
 		case '\n':	// enter/return
-		case '\r':
+		case '\r': {
 			if (_caretVisible)
 				drawCaret(true);
-		
+			
 			nextLine();
+
+			int len = _promptEndPos - _promptStartPos;
+			char str[len + 1];
+			for (i = 0; i < len; i++)
+				str[i] = _buffer[(_promptStartPos + i) % kBufferSize];
+			str[len] = 0;
+			printf("You entered '%s'\n", str);
+
 			print(PROMPT);
 			_promptStartPos = _promptEndPos = _currentPos;
 			
 			draw();
 			break;
+			}
 		case 27:	// escape
 			close();
 			break;
@@ -144,7 +155,7 @@
 		
 			if (_currentPos > _promptStartPos) {
 				_currentPos--;
-				for (int i = _currentPos; i < _promptEndPos; i++)
+				for (i = _currentPos; i < _promptEndPos; i++)
 					_buffer[i % kBufferSize] = _buffer[(i+1) % kBufferSize];
 				_buffer[_promptEndPos % kBufferSize] = ' ';
 				_promptEndPos--;
@@ -191,7 +202,7 @@
 			} else if (modifiers == OSystem::KBD_CTRL) {
 				specialKeys(keycode);
 			} else if (isprint((char)ascii)) {
-				for (int i = _promptEndPos-1; i >= _currentPos; i--)
+				for (i = _promptEndPos-1; i >= _currentPos; i--)
 					_buffer[(i+1) % kBufferSize] = _buffer[i % kBufferSize];
 				_promptEndPos++;
 				putchar((char)ascii);





More information about the Scummvm-git-logs mailing list