diff src/text/gftp-text.c @ 675:84d38c525f46

2005-1-24 Brian Masney <masneyb@gftp.org> * src/text/gftp-text.c (gftp_text_ask_question, gftp_text_write_string) - convert the string from UTF8 to the users' current locale before it is displayed * src/text/gftp-text.c src/text/gftp-text.h - fixed signed/unsigned mismatch when calculating the window size * src/gtk/transfer.c (update_file_status) - expanded the maximum length of the dlstr variable
author masneyb
date Tue, 25 Jan 2005 01:11:00 +0000
parents 81b957b00691
children ff091f8e387f
line wrap: on
line diff
--- a/src/text/gftp-text.c	Mon Jan 24 00:56:58 2005 +0000
+++ b/src/text/gftp-text.c	Tue Jan 25 01:11:00 2005 +0000
@@ -20,11 +20,11 @@
 #include "gftp-text.h"
 static const char cvsid[] = "$Id$";
 
-int
+unsigned int
 gftp_text_get_win_size (void)
 {
   struct winsize size;
-  int ret;
+  unsigned int ret;
 
   if (ioctl (0, TIOCGWINSZ, (char *) &size) < 0)
     ret = 80;
@@ -36,14 +36,19 @@
 
 
 static void
-gftp_text_write_string (char *string)
+gftp_text_write_string (gftp_request * request, char *string)
 {
-  char *stpos, *endpos, savechar;
-  int sw;
+  gchar *stpos, *endpos, *locale_str, savechar;
+  unsigned int sw;
 
   sw = gftp_text_get_win_size ();
 
-  stpos = string;
+  locale_str = gftp_string_from_utf8 (request, string);
+  if (locale_str == NULL)
+    stpos = string;
+  else
+    stpos = locale_str;
+
   do
     {
       if ((endpos = strchr (stpos, '\n')) == NULL)
@@ -77,6 +82,9 @@
       sw = sw;
     }
   while (stpos != endpos);
+
+  if (locale_str != NULL)
+    g_free (locale_str);
 }
 
 
@@ -134,7 +142,7 @@
   if (level == gftp_logging_misc_nolog)
     printf ("%s", outstr);
   else
-    gftp_text_write_string (outstr);
+    gftp_text_write_string (request, outstr);
   
   printf ("%s", GFTPUI_COMMON_COLOR_DEFAULT);
 
@@ -147,6 +155,7 @@
 gftp_text_ask_question (const char *question, int echo, char *buf, size_t size)
 {
   struct termios term, oldterm;
+  gchar *locale_question;
   sigset_t sig, sigsave;
   char *pos, *termname;
   int singlechar;
@@ -176,7 +185,16 @@
   else
     infd = stdin;
 
-  printf ("%s%s%s ", GFTPUI_COMMON_COLOR_BLUE, question, GFTPUI_COMMON_COLOR_DEFAULT);
+  locale_question = g_locale_from_utf8 (question, -1, NULL, NULL, NULL);
+  if (locale_question != NULL)
+    {
+      printf ("%s%s%s ", GFTPUI_COMMON_COLOR_BLUE, locale_question,
+              GFTPUI_COMMON_COLOR_DEFAULT);
+      g_free (locale_question);
+    }
+  else
+    printf ("%s%s%s ", GFTPUI_COMMON_COLOR_BLUE, question,
+            GFTPUI_COMMON_COLOR_DEFAULT);
 
   if (size == 1)
     {