]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
kanji wrap patch
authormsw <msw>
Wed, 20 Oct 1999 20:33:38 +0000 (20:33 +0000)
committermsw <msw>
Wed, 20 Oct 1999 20:33:38 +0000 (20:33 +0000)
newt.spec
textbox.c
windows.c

index 73a9967f57706a81ddc1ddaf64cab728f7217e50..b2dc71909f2b354e14ec8832928e1fc3dd0944c3 100644 (file)
--- a/newt.spec
+++ b/newt.spec
@@ -2,7 +2,7 @@ Summary: A development library for text mode user interfaces.
 Name: newt
 %define version 0.50
 Version: %{version}
-Release: 13
+Release: 14
 Copyright: LGPL
 Group: System Environment/Libraries
 Source: ftp://ftp.redhat.com/pub/redhat/code/newt/newt-%{version}.tar.gz
@@ -55,6 +55,9 @@ rm -rf $RPM_BUILD_ROOT
 %postun -p /sbin/ldconfig
 
 %changelog
+* Wed Oct 20 1999 Matt Wilson <msw@redhat.com>
+- added patch to correctly wrap euc kanji
+
 * Wed Sep 01 1999 Erik Troan <ewt@redhat.com>
 - added suspend/resume to snack
 
index 331cb8f039390be9761b48087e96c5d4c9a9d1fc..2578738d71df187133a87ed1c9cb6ba53d49ef6c 100644 (file)
--- a/textbox.c
+++ b/textbox.c
@@ -147,12 +147,16 @@ static char * expandTabs(const char * text) {
     return buf;
 }
 
+#define iseuckanji(c)   (0xa1 <= (unsigned char)(c&0xff) && (unsigned char)(c&0xff) <= 0xfe)
+
 static void doReflow(const char * text, char ** resultPtr, int width, 
                     int * badness, int * heightPtr) {
     char * result = NULL;
     const char * chptr, * end;
+    int i;
     int howbad = 0;
     int height = 0;
+    int kanji = 0;
 
     if (resultPtr) {
        /* XXX I think this will work */
@@ -161,6 +165,7 @@ static void doReflow(const char * text, char ** resultPtr, int width,
     }
     
     while (*text) {
+        kanji = 0;
        end = strchr(text, '\n');
        if (!end)
            end = text + strlen(text);
@@ -178,10 +183,23 @@ static void doReflow(const char * text, char ** resultPtr, int width,
                text = end;
                if (*text) text++;
            } else {
-               chptr = text + width - 1;
-               while (chptr > text && !isspace(*chptr)) chptr--;
-               while (chptr > text && isspace(*chptr)) chptr--;
-               chptr++;
+               chptr = text;
+               kanji = 0;
+               for ( i = 0; i < width - 1; i++ ) {
+                   if ( !iseuckanji(*chptr)) {
+                       kanji = 0;
+                   } else if ( kanji == 1 ) {
+                       kanji = 2; 
+                   } else {
+                       kanji = 1;
+                   }
+                   chptr++;
+               }
+               if (kanji == 0) {
+                   while (chptr > text && !isspace(*chptr)) chptr--;
+                   while (chptr > text && isspace(*chptr)) chptr--;
+                   chptr++;
+               }
                
                if (chptr-text == 1 && !isspace(*chptr))
                  chptr = text + width - 1;
@@ -189,12 +207,18 @@ static void doReflow(const char * text, char ** resultPtr, int width,
                if (chptr > text)
                    howbad += width - (chptr - text) + 1;
                if (result) {
-                   strncat(result, text, chptr - text);
+                 if (kanji == 1) {
+                   strncat(result, text, chptr - text + 1 );
+                   chptr++;
+                   kanji = 0;
+                 } else {
+                   strncat(result, text, chptr - text );
+                 }
                    strcat(result, "\n");
                    height++;
                }
 
-               if (isspace(*chptr))
+               if (isspace(*chptr))
                    text = chptr + 1;
                else
                  text = chptr;
index 4629fe610204df76434570556d3634db309c6588..1c62fafa92f9270d0f8e2525357e8659486845a2 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -104,6 +104,7 @@ void newtWinMessage(char * title, char * buttonText, char * text, ...) {
 
     va_start(args, text);
     newtvwindow(title, buttonText, NULL, NULL, text, args);
+    newtResizeScreen(1);
     va_end(args);
 }