[Tux4kids-commits] r627 - tuxtype/trunk/src

sreyas-guest at alioth.debian.org sreyas-guest at alioth.debian.org
Thu Aug 14 12:57:18 UTC 2008


Author: sreyas-guest
Date: 2008-08-14 12:57:11 +0000 (Thu, 14 Aug 2008)
New Revision: 627

Modified:
   tuxtype/trunk/src/alphabet.c
   tuxtype/trunk/src/practice.c
Log:


Modified: tuxtype/trunk/src/alphabet.c
===================================================================
--- tuxtype/trunk/src/alphabet.c	2008-08-14 12:19:14 UTC (rev 626)
+++ tuxtype/trunk/src/alphabet.c	2008-08-14 12:57:11 UTC (rev 627)
@@ -1114,28 +1114,27 @@
 
 /******************To be used for savekeyboard*************/
 /***Converts wchar_t string to char string*****************/
-int ConvertToUTF8(wchar_t* UTF32_word, char* word)
+int ConvertToUTF8(wchar_t* wide_word, char* UTF8_word)
 {
   int i = 0;
   ConversionResult result;
   UTF8 temp_UTF8[FNLEN];
   UTF32 temp_UTF32[FNLEN];
 
-  const UTF8* UTF8_Start = temp_UTF8;
-  const UTF8* UTF8_End = &temp_UTF8[FNLEN-1];
-  UTF32* UTF32_Start = temp_UTF32;
-  UTF32* UTF32_End = &temp_UTF32[FNLEN-1];
+  UTF8* UTF8_Start = temp_UTF8;
+  UTF8* UTF8_End = &temp_UTF8[FNLEN-1];
+  const UTF32* UTF32_Start = temp_UTF32;
+  const UTF32* UTF32_End = &temp_UTF32[FNLEN-1];
 
-  strncpy(temp_UTF32, UTF32_word, FNLEN);
+  wcsncpy(temp_UTF32, wide_word, FNLEN);
 
-  ConvertUTF32toUTF8(&UTF32_Start, UTF32_End,
-                     &UTF8_Start, UTF8_End, 0);
+  ConvertUTF32toUTF8(&UTF32_Start, UTF32_End, &UTF8_Start, UTF8_End, 0);
 
-  word[0] = '\0';
+  UTF8_word[0] = 0;
 
-  while ((i < FNLEN) && (temp_UTF8[i] != '\0'))
+  while ((i < FNLEN) && (temp_UTF8[i] != 0))
   {
-    word[i] = temp_UTF8[i];
+    UTF8_word[i] = temp_UTF8[i];
     i++; 
   }
 
@@ -1146,12 +1145,13 @@
   }
   else  //need terminating null:
   {
-    word[i] = '\0';
+	for(i;i<FNLEN;i++)
+	    UTF8_word[i] = 0;
   }
 
-  DEBUGCODE {fprintf(stderr, "word = %s\n", word);}
+  DEBUGCODE {fprintf(stderr, "UTF8_word = %s\n", UTF8_word);}
 
-  return strlen(word);
+  return strlen(UTF8_word);
 }
 
 /******************************************************************/
@@ -1615,15 +1615,16 @@
 void savekeyboard(void)
 {
 	unsigned char fn[FNLEN];
+	FILE *fp;
+	int i;
+	wchar_t tmp[2];
+	char buf[FNLEN];
+	tmp[1]=0;
 	if(!settings.use_english)
 		sprintf(fn , "%s/keyboard.lst", settings.theme_data_path);
 	else
 		sprintf(fn , "%s/keyboard.lst", settings.default_data_path);
-	FILE *fp;
-	int i;
-	wchar_t tmp[2];
-	char buf[10];
-	tmp[1]='\0';
+
 	fp=fopen(fn,"w");
 	if (fp == NULL)
 	{

Modified: tuxtype/trunk/src/practice.c
===================================================================
--- tuxtype/trunk/src/practice.c	2008-08-14 12:19:14 UTC (rev 626)
+++ tuxtype/trunk/src/practice.c	2008-08-14 12:57:11 UTC (rev 627)
@@ -75,7 +75,7 @@
       total = 0,
       state = 0;
   int key[100] = {0};
-  SDL_Rect dst, dst2, dst3, dst4, dst5;
+  SDL_Rect dst, dst2, dst3, dst4;
   char keytime[20],
        totaltime[20];
   SDL_Surface* srfc = NULL;
@@ -115,21 +115,16 @@
   dst2.w = srfc->w;
   dst2.h = srfc->h;
 
-  dst3.x = 50;
+  dst3.x = 0;
   dst3.y = 400;
-  dst3.w = 160;
-  dst3.h = 50;
+  dst3.w = screen->w;
+  dst3.h = bg->h-dst3.y;
 
   dst4.x = 480;
   dst4.y = 400;
   dst4.w = 240;
   dst4.h = 50;
 
-  dst5.x = 480;
-  dst5.y = 400;
-  dst5.w = 240;
-  dst5.h = 50;
-
   dst.x = 40;
 
   start = SDL_GetTicks();
@@ -377,6 +372,8 @@
 				else
 					tmp='\'';
 				break;
+			case SDLK_SPACE:tmp=' ';
+				break;
 			case SDLK_a:tmp='a';
 				break;
 			case SDLK_b:tmp='b';
@@ -440,7 +437,7 @@
             dst2.x = 40;
             dst4.x = 480;
             SDL_BlitSurface(bg, &dst3, screen, &dst2);
-            SDL_BlitSurface(bg, &dst5, screen, &dst4);
+            //SDL_BlitSurface(bg, &dst5, screen, &dst4);
             SDL_Flip(screen);
 
             srfc = GetWhiteGlyph(event.key.keysym.unicode);




More information about the Tux4kids-commits mailing list