From: msw Date: Tue, 23 Jan 2001 06:27:38 +0000 (+0000) Subject: revert for now X-Git-Tag: r0-50-19~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6323124211d8872bf70d7d453e2e8001ec74d7c1;p=thirdparty%2Fnewt.git revert for now --- diff --git a/CHANGES b/CHANGES index 28f43d4..c14da3d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,3 @@ -0.50.20 - - changes to support Asian languages properly - -0.50.19-2 - - don't build newt-python2 sub package - 1.59 -> 0.50.10 - added support for help - added cusor on/off stuff diff --git a/Makefile.in b/Makefile.in index 4cdef5a..f61c31c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -12,9 +12,8 @@ VERSION = @VERSION@ CVSTAG = r$(subst .,-,$(VERSION)) SONAME = @SONAME@ -PROGS = test test-j whiptail whiptcl.so testgrid testgrid-j testtree testtree-j +PROGS = test whiptail whiptcl.so testgrid testtree TESTOBJS = test.o -TESTJOBJS = test-j.o NDIALOGOBJS = whiptail.o dialogboxes.o WHIPTCLOBJS = whiptcl.o dialogboxes.o LIBNEWT = libnewt.a @@ -22,7 +21,7 @@ LIBNEWTSH = libnewt.so.$(VERSION) LIBNEWTSONAME = libnewt.so.$(SONAME) LIBOBJS = newt.o button.o form.o checkbox.o entry.o label.o listbox.o \ scrollbar.o textbox.o scale.o grid.o windows.o buttonbar.o \ - checkboxtree.o eawidth.o + checkboxtree.o SHCFLAGS = -fPIC @@ -36,7 +35,7 @@ pythonbindir = $(prefix)/lib/python1.5/lib-dynload #-------------------------------------- -SOURCES = $(subst .o,.c,$(TESTOBJS) $(TESTJOBJS) $(NDIALOGOBJS) $(LIBOBJS)) +SOURCES = $(subst .o,.c,$(TESTOBJS) $(NDIALOGOBJS) $(LIBOBJS)) SHAREDDIR = shared SHAREDOBJS = $(patsubst %,$(SHAREDDIR)/%, $(LIBOBJS)) @@ -52,21 +51,12 @@ all: $(TARGET) _snackmodule.so test: $(TESTOBJS) $(LIBNEWT) gcc -g -o test $(TESTOBJS) $(LIBNEWT) $(LIBS) -static -test-j: $(TESTJOBJS) $(LIBNEWT) - gcc -g -o test-j $(TESTJOBJS) $(LIBNEWT) $(LIBS) -static - testgrid: testgrid.o $(LIBNEWT) gcc -g -o testgrid testgrid.o $(LIBNEWT) $(LIBS) -testgrid-j: testgrid-j.o $(LIBNEWT) - gcc -g -o testgrid-j testgrid-j.o $(LIBNEWT) $(LIBS) - testtree: testtree.o $(LIBNEWT) gcc -g -o testtree testtree.o $(LIBNEWT) $(LIBS) -testtree-j: testtree-j.o $(LIBNEWT) - gcc -g -o testtree-j testtree-j.o $(LIBNEWT) $(LIBS) - _snackmodule.so: snackmodule.o $(LIBNEWTSH) gcc --shared $(SHCFLAGS) -o _snackmodule.so snackmodule.o -L . $(LIBNEWTSH) diff --git a/button.c b/button.c index 079de9b..1ff360d 100644 --- a/button.c +++ b/button.c @@ -4,7 +4,6 @@ #include "newt.h" #include "newt_pr.h" -#include "eawidth.h" struct button { char * text; @@ -31,7 +30,6 @@ static struct componentOps buttonOps = { static newtComponent createButton(int left, int row, const char * text, int compact) { newtComponent co; struct button * bu; - int width = get_east_asia_str_width (NULL, text, 0); co = malloc(sizeof(*co)); bu = malloc(sizeof(struct button)); @@ -43,17 +41,16 @@ static newtComponent createButton(int left, int row, const char * text, int comp if (bu->compact) { co->height = 1; - co->width = width + 3; + co->width = strlen(text) + 3; } else { co->height = 4; - co->width = width + 5; + co->width = strlen(text) + 5; } co->top = row; co->left = left; co->takesFocus = 1; co->isMapped = 0; - co->isLabel = 0; newtGotorc(co->top, co->left); diff --git a/checkbox.c b/checkbox.c index 7278788..eee514c 100644 --- a/checkbox.c +++ b/checkbox.c @@ -4,7 +4,6 @@ #include "newt.h" #include "newt_pr.h" -#include "eawidth.h" enum type { CHECK, RADIO }; @@ -118,11 +117,10 @@ newtComponent newtCheckbox(int left, int top, const char * text, char defValue, co->callback = NULL; co->height = 1; - co->width = get_east_asia_str_width (NULL, text, 0) + 4; + co->width = strlen(text) + 4; co->top = top; co->left = left; co->takesFocus = 1; - co->isLabel = 0; return co; } diff --git a/checkboxtree.c b/checkboxtree.c index 32ee62e..d9cdaca 100644 --- a/checkboxtree.c +++ b/checkboxtree.c @@ -4,7 +4,6 @@ #include "newt.h" #include "newt_pr.h" -#include "eawidth.h" struct items { char * text; @@ -159,7 +158,7 @@ int newtCheckboxTreeAddArray(newtComponent co, int flags, int * indexes) { struct items * curList, * newNode, * item; struct items ** listPtr = NULL; - int i, index, numIndexes, width; + int i, index, numIndexes; struct CheckboxTree * ct = co->data; numIndexes = 0; @@ -233,10 +232,9 @@ int newtCheckboxTreeAddArray(newtComponent co, item->depth = numIndexes - 1; i = 4 + (3 * item->depth); - width = get_east_asia_str_width (NULL, text, 0); - if ((width + i + ct->pad) > co->width) { - co->width = width + i + ct->pad; + if ((strlen(text) + i + ct->pad) > co->width) { + co->width = strlen(text) + i + ct->pad; } return 0; @@ -316,7 +314,6 @@ newtComponent newtCheckboxTreeMulti(int left, int top, int height, char *seq, in co->height = height; co->width = 0; co->isMapped = 0; - co->isLabel = 0; ct->itemlist = NULL; ct->firstItem = NULL; ct->currItem = NULL; @@ -660,7 +657,7 @@ void newtCheckboxTreeSetEntry(newtComponent co, const void * data, const char * { struct CheckboxTree * ct; struct items * item; - int i, width; + int i; if (!co) return; ct = co->data; @@ -671,10 +668,9 @@ void newtCheckboxTreeSetEntry(newtComponent co, const void * data, const char * item->text = strdup(text); i = 4 + (3 * item->depth); - width = get_east_asia_str_width (NULL, text, 0); - if ((width + i + ct->pad) > co->width) { - co->width = width + i + ct->pad; + if ((strlen(text) + i + ct->pad) > co->width) { + co->width = strlen(text) + i + ct->pad; } ctDraw(co); diff --git a/configure.in b/configure.in index b4c1b4a..b470291 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(newt_pr.h) AC_CONFIG_HEADER(config.h) -VERSION=0.50.20 +VERSION=0.50.19 SONAME=0.50 AC_SUBST(VERSION) AC_SUBST(SONAME) diff --git a/dialogboxes.c b/dialogboxes.c index 5847f26..4144009 100644 --- a/dialogboxes.c +++ b/dialogboxes.c @@ -9,7 +9,6 @@ #include "dialogboxes.h" #include "newt.h" #include "popt.h" -#include "eawidth.h" /* globals -- ick */ static int buttonHeight = 1; @@ -171,7 +170,6 @@ int listBox(const char * text, int height, int width, poptContext optCon, int maxTagWidth = 0; int maxTextWidth = 0; int scrollFlag; - int w; struct { const char * text; const char * tag; @@ -195,10 +193,10 @@ int listBox(const char * text, int height, int width, poptContext optCon, } else itemInfo[numItems].text = ""; - if ((w = get_east_asia_str_width (NULL, itemInfo[numItems].text, 0)) > (unsigned int)maxTextWidth) - maxTextWidth = w; - if ((w = get_east_asia_str_width (NULL, itemInfo[numItems].tag, 0)) > (unsigned int)maxTagWidth) - maxTagWidth = w; + if (strlen(itemInfo[numItems].text) > (unsigned int)maxTextWidth) + maxTextWidth = strlen(itemInfo[numItems].text); + if (strlen(itemInfo[numItems].tag) > (unsigned int)maxTagWidth) + maxTagWidth = strlen(itemInfo[numItems].tag); numItems++; } @@ -256,7 +254,6 @@ int checkList(const char * text, int height, int width, poptContext optCon, char buf[80], format[20]; int maxWidth = 0; int top; - int w; struct { const char * text; const char * tag; @@ -290,8 +287,8 @@ int checkList(const char * text, int height, int width, poptContext optCon, else cbStates[numBoxes] = ' '; - if ((w = get_east_asia_str_width (NULL, cbInfo[numBoxes].tag, 0)) > (unsigned int)maxWidth) - maxWidth = w; + if (strlen(cbInfo[numBoxes].tag) > (unsigned int)maxWidth) + maxWidth = strlen(cbInfo[numBoxes].tag); numBoxes++; } diff --git a/eawidth.c b/eawidth.c index d9a0540..7001e96 100644 --- a/eawidth.c +++ b/eawidth.c @@ -404,9 +404,13 @@ get_east_asia_str_n_width (const char *locale_name, const char *s, size_t n, int int get_east_asia_str_width (const char *locale_name, const char *s, int x) { size_t n; + int rc; n = strlen(s) + 1; - return get_east_asia_str_n_width (locale_name, s, n, x); + rc = get_east_asia_str_n_width (locale_name, s, n, x); + if (rc == INT_MAX) + return strlen (s); + return rc; } #if TEST_GET_EAST_ASIA_STR_WIDTH diff --git a/eawidth.h b/eawidth.h deleted file mode 100644 index 668e35a..0000000 --- a/eawidth.h +++ /dev/null @@ -1,37 +0,0 @@ -#include - -typedef enum { - ambiguous, neutral, narrow, half_width, wide, full_width -} east_asia_type; - -/** - * get_east_asia_type returns the character classification of a given - * Unicode character according to Unicode Technical - * Report 11. - * - * @param unicode the Unicode/ISO-10646 character to get the type of - * @return the classification of the character, according to - * UAX#11 data. - */ -east_asia_type get_east_asia_type(wchar_t unicode); - -/** - * get_east_asia_width measures the amount of space a multibyte string - * takes an a traditional fixed width terminal such - * as xterm in character cells. - * - * @param locale_name used to determine the if character width should - * be interpreted as CJK or Asian in the case of - * Greek and Cyrillic characters. If NULL, it will - * use setlocale() to determine the LC_CTYPE setting. - * @param s the multibyte string to measure the width of. - * @param x the current cursor position, used to handle the - * calculation of tab widths. 0 is the first column. - * @return the number of fixed width character cells the string - * takes up. If the string is an illegal multibyte - * string, or a memory error or other occurs, INT_MAX - * is returned and errno is set. - */ -int get_east_asia_str_width(const char *locale_name, const char *s, int x); -int get_east_asia_str_n_width (const char *locale_name, const char *s, size_t n, int x); -int east_asia_mblen (const char *locale_name, const char *s, size_t n, int x); diff --git a/entry.c b/entry.c index b597879..154edba 100644 --- a/entry.c +++ b/entry.c @@ -5,7 +5,6 @@ #include "newt.h" #include "newt_pr.h" -#include "eawidth.h" struct entry { int flags; @@ -59,7 +58,6 @@ newtComponent newtEntry(int left, int top, const char * initialValue, int width, char ** resultPtr, int flags) { newtComponent co; struct entry * en; - int w; co = malloc(sizeof(*co)); en = malloc(sizeof(struct entry)); @@ -71,7 +69,6 @@ newtComponent newtEntry(int left, int top, const char * initialValue, int width, co->width = width; co->isMapped = 0; co->callback = NULL; - co->isLabel = 0; co->ops = &entryOps; @@ -87,8 +84,8 @@ newtComponent newtEntry(int left, int top, const char * initialValue, int width, else co->takesFocus = 0; - if (initialValue && (w = get_east_asia_str_width (NULL, initialValue, 0)) > (unsigned int)width) { - en->bufAlloced = w + 1; + if (initialValue && strlen(initialValue) > (unsigned int)width) { + en->bufAlloced = strlen(initialValue) + 1; } en->buf = malloc(en->bufAlloced); en->resultPtr = resultPtr; diff --git a/form.c b/form.c index 3140213..825fd46 100644 --- a/form.c +++ b/form.c @@ -5,7 +5,6 @@ #include #include #include -#include #ifdef USE_GPM #include @@ -24,12 +23,6 @@ #include "newt.h" #include "newt_pr.h" -#include "eawidth.h" - -struct label { - char *text; - int length; -}; #ifdef USE_GPM /*....................................... The connection data structure */ @@ -449,7 +442,6 @@ newtComponent newtForm(newtComponent vertBar, void * help, int flags) { co->top = -1; co->left = -1; co->isMapped = 0; - co->isLabel = 0; co->takesFocus = 0; /* we may have 0 components */ co->ops = &formOps; @@ -536,8 +528,6 @@ void newtFormSetWidth(newtComponent co, int width) { void newtFormAddComponent(newtComponent co, newtComponent newco) { struct form * form = co->data; - int i, j, k, l, xmap, ymap, x, y; - char *map, *s = NULL; co->takesFocus = 1; @@ -556,76 +546,6 @@ void newtFormAddComponent(newtComponent co, newtComponent newco) { form->currComp = form->numComps; form->numComps++; - - /* check multibyte char broken */ - /* create text map */ - xmap = 0; - ymap = 0; - for ( i = 0; i < form->numComps; i++ ) { - if ((form->elements[i].co->top + form->elements[i].co->height) > ymap ) - ymap = form->elements[i].co->top + form->elements[i].co->height; - if ((form->elements[i].co->left + form->elements[i].co->width) > xmap ) - xmap = form->elements[i].co->left + form->elements[i].co->width; - } - map = (char *)calloc ((xmap+1) * (ymap+1), sizeof (char)); - -#define MAP(x,y) *(map + ((x)*ymap + (y))) - - /* create non-label components map */ - for ( i = 0; i < form->numComps; i++ ) { - if ( form->elements[i].co->isLabel == 0 && form->elements[i].co->left >= 0 && form->elements[i].co->top >= 0 ) { - for ( x = 0; x < form->elements[i].co->width; x++ ) { - for ( y = 0; y < form->elements[i].co->height; y++ ) - MAP (form->elements[i].co->left+x, form->elements[i].co->top+y) = 1; - } - } - } - - /* check label overlap */ - for ( i = 0; i < form->numComps; i++ ) { - if ( form->elements[i].co->isLabel != 0 ) { - y = form->elements[i].co->top; - l = form->elements[i].co->left; - if ( y >= 0 && l >= 0 ) { - for ( j = 0; j < form->elements[i].co->width; j++ ) { - if ( MAP (j+l, y) != 0 ) { - if ( MAP (j+l, y) != 1 ) { - /* if label is here, move label */ - while ( MAP (form->elements[i].co->left, y) != 0 ) - form->elements[i].co->left++; - } else { - /* if label is overlapping, cut label */ - if ((j+l) == form->elements[i].co->left ) { - free (((struct label *)form->elements[i].co->data)->text); - ((struct label *)form->elements[i].co->data)->text = malloc (1); - ((struct label *)form->elements[i].co->data)->text[0] = 0; - ((struct label *)form->elements[i].co->data)->length = 0; - form->elements[i].co->width = 0; - } else { - x = 0; - while (x < j) { - s = &((struct label *)form->elements[i].co->data)->text[x]; - k = east_asia_mblen (NULL, s, strlen (s), 0); - if ( k <= 0 ) break; - else { - if ((x+k) < j ) x += k; - else break; - } - } - s = ((struct label *)form->elements[i].co->data)->text; - ((struct label *)form->elements[i].co->data)->text = realloc(s, x+1); - ((struct label *)form->elements[i].co->data)->text[x] = 0; - ((struct label *)form->elements[i].co->data)->length = strlen (s); - form->elements[i].co->width = get_east_asia_str_width (NULL, s, 0); - } - } - } else - MAP (j+l, y) = 2; - } - } - } - } - free (map); } void newtFormAddComponents(newtComponent co, ...) { @@ -882,7 +802,6 @@ void newtFormDestroy(newtComponent co) { free(form->elements); free(form); free(co); - newtResizeScreen(1); } newtComponent newtRunForm(newtComponent co) { diff --git a/grid.c b/grid.c index 391dd07..4330113 100644 --- a/grid.c +++ b/grid.c @@ -4,7 +4,6 @@ #include "newt.h" #include "newt_pr.h" -#include "eawidth.h" struct gridField { enum newtGridElement type; @@ -242,13 +241,12 @@ void newtGridGetSize(newtGrid grid, int * width, int * height) { } void newtGridWrappedWindow(newtGrid grid, char * title) { - int width, height, offset = 0, w; + int width, height, offset = 0; newtGridGetSize(grid, &width, &height); - w = get_east_asia_str_width (NULL, title, 0); - if (width < (w + 2)) { - offset = ((w + 2) - width) / 2; - width = w + 2; + if (width < strlen(title) + 2) { + offset = ((strlen(title) + 2) - width) / 2; + width = strlen(title) + 2; } newtCenteredWindow(width + 2, height + 2, title); newtGridPlace(grid, 1 + offset, 1); diff --git a/label.c b/label.c index 1c4ecfd..f1a9ceb 100644 --- a/label.c +++ b/label.c @@ -4,7 +4,6 @@ #include "newt.h" #include "newt_pr.h" -#include "eawidth.h" struct label { char * text; @@ -33,11 +32,10 @@ newtComponent newtLabel(int left, int top, const char * text) { co->ops = &labelOps; co->height = 1; - co->width = get_east_asia_str_width (NULL, text, 0); + co->width = strlen(text); co->top = top; co->left = left; co->takesFocus = 0; - co->isLabel = 1; la->length = strlen(text); la->text = strdup(text); @@ -49,7 +47,7 @@ void newtLabelSetText(newtComponent co, const char * text) { int newLength; struct label * la = co->data; - newLength = get_east_asia_str_width (NULL, text, 0); + newLength = strlen(text); if (newLength <= la->length) { memset(la->text, ' ', la->length); memcpy(la->text, text, newLength); diff --git a/listbox.c b/listbox.c index 4f951b6..ef276ae 100644 --- a/listbox.c +++ b/listbox.c @@ -11,7 +11,7 @@ #include "newt.h" #include "newt_pr.h" -#include "eawidth.h" + /* Linked list of items in the listbox */ struct items { @@ -133,7 +133,6 @@ newtComponent newtListbox(int left, int top, int height, int flags) { co->ops = &listboxOps; co->takesFocus = 1; co->callback = NULL; - co->isLabel = 0; updateWidth(co, li, 5); @@ -286,7 +285,7 @@ void ** newtListboxGetSelection(newtComponent co, int *numitems) void newtListboxSetEntry(newtComponent co, int num, const char * text) { struct listbox * li = co->data; - int i, w; + int i; struct items *item; for(i = 0, item = li->boxItems; item != NULL && i < num; @@ -298,9 +297,8 @@ void newtListboxSetEntry(newtComponent co, int num, const char * text) { free(item->text); item->text = strdup(text); } - w = get_east_asia_str_width (NULL, text, 0); - if (li->userHasSetWidth == 0 && w > li->curWidth) { - updateWidth(co, li, w); + if (li->userHasSetWidth == 0 && strlen(text) > li->curWidth) { + updateWidth(co, li, strlen(text)); } if (num >= li->startShowItem && num <= li->startShowItem + co->height) @@ -322,7 +320,6 @@ int newtListboxAppendEntry(newtComponent co, const char * text, const void * data) { struct listbox * li = co->data; struct items *item; - int w; if(li->boxItems) { for (item = li->boxItems; item->next != NULL; item = item->next); @@ -332,9 +329,8 @@ int newtListboxAppendEntry(newtComponent co, const char * text, item = li->boxItems = malloc(sizeof(struct items)); } - w = get_east_asia_str_width (NULL, text, 0); - if (!li->userHasSetWidth && text && (w > li->curWidth)) - updateWidth(co, li, w); + if (!li->userHasSetWidth && text && (strlen(text) > li->curWidth)) + updateWidth(co, li, strlen(text)); item->text = strdup(text); item->data = data; item->next = NULL; item->isSelected = 0; @@ -350,7 +346,6 @@ int newtListboxInsertEntry(newtComponent co, const char * text, const void * data, void * key) { struct listbox * li = co->data; struct items *item, *t; - int w; if (li->boxItems) { if (key) { @@ -374,9 +369,8 @@ int newtListboxInsertEntry(newtComponent co, const char * text, item->next = NULL; } - w = get_east_asia_str_width (NULL, text, 0); - if (!li->userHasSetWidth && text && (w > li->curWidth)) - updateWidth(co, li, w); + if (!li->userHasSetWidth && text && (strlen(text) > li->curWidth)) + updateWidth(co, li, strlen(text)); item->text = strdup(text?text:"(null)"); item->data = data; item->isSelected = 0; @@ -423,7 +417,7 @@ int newtListboxDeleteEntry(newtComponent co, void * key) { if (!li->userHasSetWidth) { widest = 0; for (item = li->boxItems; item != NULL; item = item->next) - if ((t = get_east_asia_str_width (NULL, item->text, 0)) > widest) widest = t; + if ((t = strlen(item->text)) > widest) widest = t; } if (li->currItem >= num) diff --git a/newt.c b/newt.c index 1bef1c8..f919c33 100644 --- a/newt.c +++ b/newt.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "newt.h" #include "newt_pr.h" @@ -169,6 +168,7 @@ void newtCls(void) { newtRefresh(); } +#if defined(THIS_DOESNT_WORK) void newtResizeScreen(int redraw) { newtPushHelpLine(""); @@ -185,13 +185,11 @@ void newtResizeScreen(int redraw) { if (redraw) SLsmg_refresh(); } +#endif int newtInit(void) { char * MonoValue, * MonoEnv = "NEWT_MONO"; - /* initialize locale */ - setlocale (LC_ALL, ""); - /* use the version variable just to be sure it gets included */ strlen(version); diff --git a/newt.spec b/newt.spec index 1515318..656b7c2 100644 --- a/newt.spec +++ b/newt.spec @@ -1,12 +1,12 @@ Summary: A development library for text mode user interfaces. Name: newt -%define version 0.50.20 +%define version 0.50.19 Version: %{version} Release: 1 Copyright: LGPL Group: System Environment/Libraries Source: ftp://ftp.redhat.com/pub/redhat/code/newt/newt-%{version}.tar.gz -BuildRequires: python,perl +BuildRequires: python,python2,perl Requires: slang Provides: snack BuildRoot: %{_tmppath}/%{name}-%{version}-%{root} @@ -63,11 +63,11 @@ python -c 'from compileall import *; compile_dir("'$RPM_BUILD_ROOT'/usr/lib/pyth # cheat... build python2 stuff here make clean -#perl -pi -e "s/python1.5/python2.0/g" * +perl -pi -e "s/python1.5/python2.0/g" * ./configure make instroot=$RPM_BUILD_ROOT install make instroot=$RPM_BUILD_ROOT install-sh -#python -c 'from compileall import *; compile_dir("'$RPM_BUILD_ROOT'/usr/lib/python2.0",10,"/usr/lib/python2.0")' +python -c 'from compileall import *; compile_dir("'$RPM_BUILD_ROOT'/usr/lib/python2.0",10,"/usr/lib/python2.0")' %clean @@ -97,14 +97,11 @@ rm -rf $RPM_BUILD_ROOT /usr/lib/libnewt.a /usr/lib/libnewt.so -#%files python2 -#%defattr (-,root,root) -#/usr/lib/python2.0 +%files python2 +%defattr (-,root,root) +/usr/lib/python2.0 %changelog -* Mon Jan 22 2001 Than Ngo -- don't build newt-python2 sub package. - * Fri Dec 15 2000 Trond Eivind Glomsrød - use %%{_tmppath} - add python2 subpackage, with such support diff --git a/newt_pr.h b/newt_pr.h index 77f1458..76f5e2f 100644 --- a/newt_pr.h +++ b/newt_pr.h @@ -33,7 +33,6 @@ struct newtComponent_struct { int top, left; int takesFocus; int isMapped; - int isLabel; struct componentOps * ops; diff --git a/scale.c b/scale.c index 826a0f8..11c72cc 100644 --- a/scale.c +++ b/scale.c @@ -35,7 +35,6 @@ newtComponent newtScale(int left, int top, int width, long long fullValue) { co->top = top; co->left = left; co->takesFocus = 0; - co->isLabel = 0; sc->fullValue = fullValue; sc->charsSet = 0; diff --git a/scrollbar.c b/scrollbar.c index 7e3b8cb..cb4bc27 100644 --- a/scrollbar.c +++ b/scrollbar.c @@ -64,7 +64,6 @@ newtComponent newtVerticalScrollbar(int left, int top, int height, co->height = height; co->width = 1; co->takesFocus = 0; - co->isLabel = 0; return co; } diff --git a/test-j.c b/test-j.c deleted file mode 100644 index 0810182..0000000 --- a/test-j.c +++ /dev/null @@ -1,146 +0,0 @@ -#include -#include -#include -#include - -#include "newt.h" - -struct callbackInfo { - newtComponent en; - char * state; -}; - -void disableCallback(newtComponent co, void * data) { - struct callbackInfo * cbi = data; - - if (*cbi->state == ' ') { - newtEntrySetFlags(cbi->en, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET); - } else { - newtEntrySetFlags(cbi->en, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); - } - - newtRefresh(); -} - -void suspend(void * d) { - newtSuspend(); - raise(SIGTSTP); - newtResume(); -} - -int main(void) { - newtComponent b1, b2, r1, r2, r3, e2, e3, l1, l2, l3, scale; - newtComponent lb, t, rsf, answer; - newtComponent cs[10]; - newtComponent f, chklist, e1; - struct callbackInfo cbis[3]; - char results[10]; - char * enr2, * enr3, * scaleVal; - void ** selectedList; - int i, numsel; - char buf[20]; - - newtInit(); - newtCls(); - - newtSetSuspendCallback(suspend, NULL); - - newtDrawRootText(0, 0, "Newt ¥Æ¥¹¥È¥×¥í¥°¥é¥à"); - newtPushHelpLine(NULL); - newtDrawRootText(-50, 0, "¥ë¡¼¥È¥Æ¥­¥¹¥È"); - - newtOpenWindow(2, 2, 30, 10, "£±ÈÖÌܤΥ¦¥£¥ó¥É¥¦"); - newtOpenWindow(10, 5, 65, 16, "¥¦¥£¥ó¥É¥¦£²"); - - f = newtForm(NULL, NULL, 0); - chklist = newtForm(NULL, NULL, 0); - - b1 = newtButton(3, 1, "½ªÎ»"); - b2 = newtButton(18, 1, "¹¹¿·"); - r1 = newtRadiobutton(20, 10, "ÁªÂò»è£±", 0, NULL); - r2 = newtRadiobutton(20, 11, "ÁªÂò»è£²", 1, r1); - r3 = newtRadiobutton(20, 12, "ÁªÂò»è£³", 0, r2); - rsf = newtForm(NULL, NULL, 0); - newtFormAddComponents(rsf, r1, r2, r3, NULL); - newtFormSetBackground(rsf, NEWT_COLORSET_CHECKBOX); - - for (i = 0; i < 10; i++) { - sprintf(buf, "¥Á¥§¥Ã¥¯ %d", i); - cs[i] = newtCheckbox(3, 10 + i, buf, ' ', NULL, &results[i]); - newtFormAddComponent(chklist, cs[i]); - } - - l1 = newtLabel(3, 6, "¥¹¥±¡¼¥ë:"); - l2 = newtLabel(3, 7, "¥¹¥¯¥í¡¼¥ë:"); - l3 = newtLabel(3, 8, "¥Ò¥É¥¥¥ó:"); - e1 = newtEntry(12, 6, "", 20, &scaleVal, 0); - e2 = newtEntry(12, 7, "ɸ½à", 20, &enr2, NEWT_FLAG_SCROLL); - e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_FLAG_HIDDEN); - - cbis[0].state = &results[0]; - cbis[0].en = e1; - newtComponentAddCallback(cs[0], disableCallback, &cbis[0]); - - scale = newtScale(3, 14, 32, 100); - - newtFormSetHeight(chklist, 3); - - newtFormAddComponents(f, b1, b2, l1, l2, l3, e1, e2, e3, chklist, NULL); - newtFormAddComponents(f, rsf, scale, NULL); - - lb = newtListbox(45, 1, 6, NEWT_FLAG_MULTIPLE | NEWT_FLAG_BORDER | - NEWT_FLAG_SCROLL); - newtListboxAppendEntry(lb, "£±ÈÖÌÜ", (void *) 1); - newtListboxAppendEntry(lb, "£²ÈÖÌÜ", (void *) 2); - newtListboxAppendEntry(lb, "£³ÈÖÌÜ", (void *) 3); - newtListboxAppendEntry(lb, "£´ÈÖÌÜ", (void *) 4); - newtListboxAppendEntry(lb, "£¶ÈÖÌÜ", (void *) 6); - newtListboxAppendEntry(lb, "£·ÈÖÌÜ", (void *) 7); - newtListboxAppendEntry(lb, "£¸ÈÖÌÜ", (void *) 8); - newtListboxAppendEntry(lb, "£¹ÈÖÌÜ", (void *) 9); - newtListboxAppendEntry(lb, "£±£°ÈÖÌÜ", (void *) 10); - - newtListboxInsertEntry(lb, "£µÈÖÌÜ", (void *) 5, (void *) 4); - newtListboxInsertEntry(lb, "£±£±ÈÖÌÜ", (void *) 11, (void *) 10); - newtListboxDeleteEntry(lb, (void *) 11); - - t = newtTextbox(45, 10, 17, 5, NEWT_FLAG_WRAP); - newtTextboxSetText(t, "¤³¤ì¤Ï¥Æ¥­¥¹¥È¤Î¥µ¥ó¥×¥ë¤Ç¤¹¡£\nÀµ¾ï¤Ëɽ¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¤«¡©\n¤³¤ì¤ÏñÆÈ¹Ô¤Ç¤¹¡£\n¤³¤ì¤Ïɽ¼¨¤µ¤ì¤Æ¤Ï¤¤¤±¤Þ¤»¤ó"); - - newtFormAddComponents(f, lb, t, NULL); - newtRefresh(); - - do { - answer = newtRunForm(f); - - if (answer == b2) { - newtScaleSet(scale, atoi(scaleVal)); - newtRefresh(); - answer = NULL; - } - } while (!answer); - - scaleVal = strdup(scaleVal); - enr2 = strdup(enr2); - enr3 = strdup(enr3); - - selectedList = newtListboxGetSelection(lb, &numsel); - - newtFormDestroy(f); - - newtPopWindow(); - newtPopWindow(); - newtFinished(); - - printf("got string 1: %s\n", scaleVal); - printf("got string 2: %s\n", enr2); - printf("got string 3: %s\n", enr3); - - if(selectedList) { - printf("\nSelected listbox items:\n"); - for(i = 0; i < numsel; i++) - puts(selectedList[i]); - } - - return 0; -} diff --git a/testgrid-j.c b/testgrid-j.c deleted file mode 100644 index 2fda940..0000000 --- a/testgrid-j.c +++ /dev/null @@ -1,106 +0,0 @@ -#include -#include -#include -#include - -#include "newt.h" - -int main(void) { - newtComponent b1, b2, b3, b4; - newtComponent answer, f, t; - newtGrid grid, subgrid; - char * flowedText; - int textWidth, textHeight, rc; - char * menuContents[] = { "°ì", "Æó", "»°", "»Í", "¸Þ", NULL }; - char * entries[10]; - struct newtWinEntry autoEntries[] = { - { "¥¨¥ó¥È¥ê", entries + 0, 0 }, - { "Ê̤Υ¨¥ó¥È¥ê", entries + 1, 0 }, - { "»°ÈÖÌܤΥ¨¥ó¥È¥ê", entries + 2, 0 }, - { "»ÍÈÖÌܤΥ¨¥ó¥È¥ê", entries + 3, 0 }, - { NULL, NULL, 0 } }; - - memset(entries, 0, sizeof(entries)); - - newtInit(); - newtCls(); - - b1 = newtCheckbox(-1, -1, "¥Æ¥¹¥È¤Î¤¿¤á¤Î¤«¤Ê¤êŤ¤¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹", ' ', NULL, NULL); - b2 = newtButton(-1, -1, "Ê̤Υܥ¿¥ó"); - b3 = newtButton(-1, -1, "¤·¤«¤·¡¢¤·¤«¤·"); - b4 = newtButton(-1, -1, "¤·¤«¤·²¿¤À¤í¤¦¡©"); - - f = newtForm(NULL, NULL, 0); - - grid = newtCreateGrid(2, 2); - newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, b1, 0, 0, 0, 0, - NEWT_ANCHOR_RIGHT, 0); - newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0); - newtGridSetField(grid, 1, 0, NEWT_GRID_COMPONENT, b3, 0, 0, 0, 0, 0, 0); - newtGridSetField(grid, 1, 1, NEWT_GRID_COMPONENT, b4, 0, 0, 0, 0, 0, 0); - - - newtFormAddComponents(f, b1, b2, b3, b4, NULL); - - newtGridWrappedWindow(grid, "°ìÈÖÌܤΥ¦¥£¥ó¥É¥¦"); - newtGridFree(grid, 1); - - answer = newtRunForm(f); - - newtFormDestroy(f); - newtPopWindow(); - - flowedText = newtReflowText("¤³¤ì¤Ï¤«¤Ê¤ê¥Æ¥­¥¹¥È¤é¤·¤¤¤â¤Î¤Ç¤¹¡£40¥«¥é¥à" - "¤ÎŤµ¤Ç¡¢¥é¥Ã¥Ô¥ó¥°¤¬¹Ô¤ï¤ì¤Þ¤¹¡£" - "ÁÇÁᤤ¡¢Ãã¿§¤Î¸Ñ¤¬¤Î¤í¤Þ¤Ê¸¤¤òÈô¤Ó" - "±Û¤¨¤¿¤Î¤òÃΤäƤ뤫¤¤?\n\n" - "¾¤Ë¤ªÃΤ餻¤¹¤ë¤³¤È¤È¤·¤Æ¡¢Å¬Åö¤Ë²þ¹Ô¤ò¤¹¤ë" - "¤³¤È¤¬½ÅÍפǤ¹¡£", - 40, 5, 5, &textWidth, &textHeight); - t = newtTextbox(-1, -1, textWidth, textHeight, NEWT_FLAG_WRAP); - newtTextboxSetText(t, flowedText); - free(flowedText); - - - b1 = newtButton(-1, -1, "λ²ò"); - b2 = newtButton(-1, -1, "¥­¥ã¥ó¥»¥ë"); - - grid = newtCreateGrid(1, 2); - subgrid = newtCreateGrid(2, 1); - - newtGridSetField(subgrid, 0, 0, NEWT_GRID_COMPONENT, b1, 0, 0, 0, 0, 0, 0); - newtGridSetField(subgrid, 1, 0, NEWT_GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0); - - newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, t, 0, 0, 0, 1, 0, 0); - newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid, 0, 0, 0, 0, 0, - NEWT_GRID_FLAG_GROWX); - newtGridWrappedWindow(grid, "Ê̤ÎÎã"); - newtGridDestroy(grid, 1); - - f = newtForm(NULL, NULL, 0); - newtFormAddComponents(f, b1, t, b2, NULL); - answer = newtRunForm(f); - - newtPopWindow(); - newtFormDestroy(f); - - newtWinMessage("¥·¥ó¥×¥ë", "λ²ò", "¤³¤ì¤Ï¥·¥ó¥×¥ë¤Ê¥á¥Ã¥»¡¼¥¸¥¦¥£¥ó¥É¥¦¤Ç¤¹"); - newtWinChoice("¥·¥ó¥×¥ë", "λ²ò", "¥­¥ã¥ó¥»¥ë", "¤³¤ì¤Ï¥·¥ó¥×¥ë¤ÊÁªÂò¥¦¥£¥ó¥É¥¦¤Ç¤¹"); - - textWidth = 0; - rc = newtWinMenu("¥Æ¥¹¥È¥á¥Ë¥å¡¼", "¤³¤ì¤Ï newtWinMenu() ¥³¡¼¥ë¤Î¥µ¥ó¥×¥ë" - "¤Ç¤¹¡£ ¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤ÏɬÍפ˱þ¤¸¤Æ¤Ä¤¤¤¿¤ê¡¢ " - "¤Ä¤«¤Ê¤«¤Ã¤¿¤ê¤·¤Þ¤¹¡£", 50, 5, 5, 3, - menuContents, &textWidth, "λ²ò", "¥­¥ã¥ó¥»¥ë", NULL); - - rc = newtWinEntries("¥Æ¥­¥¹¥È newtWinEntries()", "¤³¤ì¤Ï newtWinEntries()" - "¥³¡¼¥ë¤Î¥µ¥ó¥×¥ë¤Ç¤¹¡£¤¿¤¤¤Ø¤ó´Êñ¤Ë¤¿¤¯¤µ¤ó¤ÎÆþÎϤò" - "°·¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£", 50, 5, 5, 20, autoEntries, "λ²ò", - "¥­¥ã¥ó¥»¥ë", NULL); - - newtFinished(); - - printf("rc = 0x%x item = %d\n", rc, textWidth); - - return 0; -} diff --git a/testtree-j.c b/testtree-j.c deleted file mode 100644 index d871c2a..0000000 --- a/testtree-j.c +++ /dev/null @@ -1,132 +0,0 @@ -#include -#include -#include -#include - -#include "newt.h" - -int main(void) { - newtGrid grid; - newtComponent checktree; - newtComponent button; - newtComponent form; - newtComponent answer; - void ** result, **ptr; - int numselected, i, j; - int * list; - - newtInit(); - newtCls(); - - checktree = newtCheckboxTreeMulti(-1, -1, 10, " ab", NEWT_FLAG_SCROLL); - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼", (void *) 2, 0, - NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "ËÜÅö¤ËËÜÅö¤ËŤ¤¥â¥Î", - (void *) 3, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼£µ", (void *) 5, - NEWT_FLAG_SELECTED, - NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼£¶", (void *) 6, 0, - NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼£·", (void *) 7, - NEWT_FLAG_SELECTED, - NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼£¸", (void *) 8, 0, - NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼£¹", (void *) 9, 0, - NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼£±£°", (void *) 10, - NEWT_FLAG_SELECTED, - NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼£±£±", (void *) 11, 0, - NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼£±£²", (void *) 12, - NEWT_FLAG_SELECTED, - NEWT_ARG_APPEND, NEWT_ARG_LAST); - - newtCheckboxTreeAddItem(checktree, "¥«¥é¡¼", (void *) 1, 0, - 0, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "ÀÖ¿§", (void *) 100, 0, - 0, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "Çò¿§", (void *) 101, 0, - 0, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "ÀÄ¿§", (void *) 102, 0, - 0, NEWT_ARG_APPEND, NEWT_ARG_LAST); - - newtCheckboxTreeAddItem(checktree, "¥Ê¥ó¥Ð¡¼£´", (void *) 4, 0, - 3, NEWT_ARG_LAST); - - newtCheckboxTreeAddItem(checktree, "°ì·å¤Î¿ô»ú", (void *) 200, 0, - 1, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "°ì", (void *) 201, 0, - 1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "Æó", (void *) 202, 0, - 1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "»°", (void *) 203, 0, - 1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "»Í", (void *) 204, 0, - 1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST); - - newtCheckboxTreeAddItem(checktree, "Æó·å¤Î¿ô»ú", (void *) 300, 0, - 1, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "½½", (void *) 210, 0, - 1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "½½°ì", (void *) 211, 0, - 1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "½½Æó", (void *) 212, 0, - 1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST); - newtCheckboxTreeAddItem(checktree, "½½»°", (void *) 213, 0, - 1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST); - - button = newtButton(-1, -1, "½ªÎ»"); - - grid = newtCreateGrid(1, 2); - newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, checktree, 0, 0, 0, 1, - NEWT_ANCHOR_RIGHT, 0); - newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, button, 0, 0, 0, 0, - 0, 0); - - newtGridWrappedWindow(grid, "¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¥Ä¥ê¡¼¥Æ¥¹¥È"); - newtGridFree(grid, 1); - - form = newtForm(NULL, NULL, 0); - newtFormAddComponents(form, checktree, button, NULL); - - answer = newtRunForm(form); - - newtFinished(); - - result = newtCheckboxTreeGetSelection(checktree, &numselected); - ptr = result; - if (!result || !numselected) - printf("none selected\n"); - else - printf("Current selection (all) (%d):\n", numselected); - for (i = 0; i < numselected; i++) { - j = (int) *ptr++; - printf("%d\n", j); - } - result = newtCheckboxTreeGetMultiSelection(checktree, &numselected, 'b'); - ptr = result; - if (!result || !numselected) - printf("none selected\n"); - else - printf("Current selection (b) (%d):\n",numselected); - for (i = 0; i < numselected; i++) { - j = (int) *ptr++; - printf("%d\n", j); - } - - if (result) - free(result); - - list = newtCheckboxTreeFindItem(checktree, (void *) 213); - printf("path:"); - for (i = 0; list && list[i] != NEWT_ARG_LAST; i++) - printf(" %d", list[i]); - printf("\n"); - - newtFormDestroy(form); - - return 0; -} diff --git a/textbox.c b/textbox.c index 708e9f6..2578738 100644 --- a/textbox.c +++ b/textbox.c @@ -2,11 +2,9 @@ #include #include #include -#include #include "newt.h" #include "newt_pr.h" -#include "eawidth.h" struct textbox { char ** lines; @@ -96,7 +94,6 @@ newtComponent newtTextbox(int left, int top, int width, int height, int flags) { co->left = left; co->takesFocus = 0; co->width = width; - co->isLabel = 0; tb->doWrap = flags & NEWT_FLAG_WRAP; tb->numLines = 0; @@ -160,88 +157,76 @@ static void doReflow(const char * text, char ** resultPtr, int width, int howbad = 0; int height = 0; int kanji = 0; - int w, w2; - w = get_east_asia_str_width (NULL, text, 0); if (resultPtr) { - /* XXX I think this will work */ - result = malloc(w * 2 + 2); - *result = '\0'; + /* XXX I think this will work */ + result = malloc(strlen(text) + (strlen(text) / width) + 2); + *result = '\0'; } while (*text) { kanji = 0; - end = strchr(text, '\n'); - if (!end) - end = text + strlen(text); - - while (*text && text <= end) { - char *ptr; - - ptr = (char *)malloc (sizeof (char)*((end-text)+1)); - strncpy (ptr, text, end - text); - *(ptr + (end-text)) = 0; - w2 = get_east_asia_str_width (NULL, ptr, 0); - free (ptr); - if (w2 < width) { - if (result) { - strncat(result, text, end - text); - strcat(result, "\n"); - } - height++; - - if (w2 < (width / 2)) - howbad += ((width / 2) - w2) / 2; - text = end; - if (*text) text++; - } else { - int is_space = 0, into_kanji = 0; - char *spcptr = NULL; - - chptr = text; - i = 0; - while ( i < (width - 1)) { - kanji = east_asia_mblen (NULL, chptr, end - chptr, 0); - if ( kanji == INT_MAX || kanji <= 0 ) kanji = 1; - else { - if ( kanji == 1 ) { - if ( is_space == 0 ) { - if (isspace(*chptr)) { - is_space = 1; - } - else if ( into_kanji == 1 ) { - if (!spcptr) spcptr = chptr; - is_space = 1; - } - } else { - if (!spcptr) spcptr = chptr; - else if (isspace(*chptr)) { - spcptr = NULL; - is_space = 1; - } - } - } else { - into_kanji = 1; - is_space = 0; - spcptr = NULL; - } - if ((i+kanji) < (width - 1)) i += kanji; - else break; - } - chptr = chptr + kanji; - } - if ( is_space != 0 && spcptr-text > 1 ) chptr = spcptr; - howbad += width - (chptr - text) + 1; - if ( result ) { - strncat (result, text, chptr - text); - strcat (result, "\n"); - } - height++; - text = chptr; - while (east_asia_mblen (NULL, text, end - text, 0) == 1 && isspace(*text)) text++; - } + end = strchr(text, '\n'); + if (!end) + end = text + strlen(text); + + while (*text && text <= end) { + if (end - text < width) { + if (result) { + strncat(result, text, end - text); + strcat(result, "\n"); + height++; } + + if (end - text < (width / 2)) + howbad += ((width / 2) - (end - text)) / 2; + text = end; + if (*text) text++; + } else { + 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; + + if (chptr > text) + howbad += width - (chptr - text) + 1; + if (result) { + 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)) + text = chptr + 1; + else + text = chptr; + while (isspace(*text)) text++; + } } + } + if (badness) *badness = howbad; if (resultPtr) *resultPtr = result; if (heightPtr) *heightPtr = height; diff --git a/windows.c b/windows.c index 86a8af0..4629fe6 100644 --- a/windows.c +++ b/windows.c @@ -71,7 +71,6 @@ static void * newtvwindow(char * title, char * button1, char * button2, newtFormDestroy(f); newtPopWindow(); - newtResizeScreen(1); if (answer == f) return NULL; @@ -90,7 +89,6 @@ int newtWinChoice(char * title, char * button1, char * button2, va_start(args, message); rc = newtvwindow(title, button1, button2, NULL, message, args); - newtResizeScreen(1); va_end(args); if (rc == button1) @@ -112,7 +110,6 @@ void newtWinMessage(char * title, char * buttonText, char * text, ...) { void newtWinMessagev(char * title, char * buttonText, char * text, va_list argv) { newtvwindow(title, buttonText, NULL, NULL, text, argv); - newtResizeScreen(1); } int newtWinTernary(char * title, char * button1, char * button2, @@ -122,7 +119,6 @@ int newtWinTernary(char * title, char * button1, char * button2, va_start(args, message); rc = newtvwindow(title, button1, button2, button3, message, args); - newtResizeScreen(1); va_end(args); if (rc == button1) @@ -171,7 +167,6 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown, buttonName = va_arg(args, char *); } - newtResizeScreen(1); va_end(button1); buttonBar = newtCreateGrid(numButtons, 1); @@ -201,8 +196,6 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown, newtFormDestroy(form); newtPopWindow(); - newtResizeScreen(1); - return rc; } @@ -278,6 +271,5 @@ int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown, newtFormDestroy(form); newtPopWindow(); - newtResizeScreen(1); return rc; }