]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
expand(1) the source to get rid of tab/space mixed indents
authorprockai <prockai>
Wed, 23 Feb 2005 07:54:22 +0000 (07:54 +0000)
committerprockai <prockai>
Wed, 23 Feb 2005 07:54:22 +0000 (07:54 +0000)
27 files changed:
button.c
buttonbar.c
checkbox.c
checkboxtree.c
dialogboxes.c
dialogboxes.h
eawidth.c
entry.c
form.c
grid.c
label.c
listbox.c
newt.c
newt.h
newt_pr.h
scale.c
scrollbar.c
showchars.c
showkey.c
snackmodule.c
test.c
testgrid.c
testtree.c
textbox.c
whiptail.c
whiptcl.c
windows.c

index 467efdb3534e76565dd399f72f72ba94e0163fec..1ce8fea6989818705a9c8576ecac143eb113288b 100644 (file)
--- a/button.c
+++ b/button.c
@@ -16,7 +16,7 @@ static void buttonDrawText(newtComponent co, int active, int pushed);
 static void buttonDraw(newtComponent c);
 static void buttonDestroy(newtComponent co);
 static struct eventResult buttonEvent(newtComponent c,
-                                     struct event ev);
+                                      struct event ev);
 static void buttonPlace(newtComponent co, int newLeft, int newTop);
 
 static struct componentOps buttonOps = {
@@ -38,11 +38,11 @@ static newtComponent createButton(int left, int row, const char * text, int comp
 
     co = malloc(sizeof(*co));
     if (co == NULL) 
-       return NULL;
+        return NULL;
     bu = malloc(sizeof(struct button));
     if (bu == NULL)  {
-       free (co);
-       return NULL;
+        free (co);
+        return NULL;
     }
     co->data = bu;
 
@@ -51,11 +51,11 @@ static newtComponent createButton(int left, int row, const char * text, int comp
     co->ops = &buttonOps;
 
     if (bu->compact) {
-       co->height = 1;
-       co->width = width + 3;
+        co->height = 1;
+        co->width = width + 3;
     } else {
-       co->height = 4;
-       co->width = width + 5;
+        co->height = 4;
+        co->width = width + 5;
     }
 
     co->top = row;
@@ -104,27 +104,27 @@ static void buttonDrawIt(newtComponent co, int active, int pushed) {
     SLsmg_set_color(NEWT_COLORSET_BUTTON);
 
     if (bu->compact) {
-       if (active)
-           SLsmg_set_color(NEWT_COLORSET_COMPACTBUTTON);
-       else
-           SLsmg_set_color(NEWT_COLORSET_BUTTON);
-       newtGotorc(co->top+ pushed, co->left + 1 + pushed);
-       SLsmg_write_char('<');
-       SLsmg_write_string(bu->text);
-       SLsmg_write_char('>');
+        if (active)
+            SLsmg_set_color(NEWT_COLORSET_COMPACTBUTTON);
+        else
+            SLsmg_set_color(NEWT_COLORSET_BUTTON);
+        newtGotorc(co->top+ pushed, co->left + 1 + pushed);
+        SLsmg_write_char('<');
+        SLsmg_write_string(bu->text);
+        SLsmg_write_char('>');
     } else {
-       if (pushed) {
-           SLsmg_set_color(NEWT_COLORSET_BUTTON);
-           newtDrawBox(co->left + 1, co->top + 1, co->width - 1, 3, 0);
-
-           SLsmg_set_color(NEWT_COLORSET_WINDOW);
-           newtClearBox(co->left, co->top, co->width, 1);
-           newtClearBox(co->left, co->top, 1, co->height);
-       } else {
-           newtDrawBox(co->left, co->top, co->width - 1, 3, 1);
-       }
-
-       buttonDrawText(co, active, pushed);
+        if (pushed) {
+            SLsmg_set_color(NEWT_COLORSET_BUTTON);
+            newtDrawBox(co->left + 1, co->top + 1, co->width - 1, 3, 0);
+
+            SLsmg_set_color(NEWT_COLORSET_WINDOW);
+            newtClearBox(co->left, co->top, co->width, 1);
+            newtClearBox(co->left, co->top, 1, co->height);
+        } else {
+            newtDrawBox(co->left, co->top, co->width - 1, 3, 1);
+        }
+
+        buttonDrawText(co, active, pushed);
     }
 }
 
@@ -134,9 +134,9 @@ static void buttonDrawText(newtComponent co, int active, int pushed) {
     if (pushed) pushed = 1;
 
     if (active)
-       SLsmg_set_color(NEWT_COLORSET_ACTBUTTON);
+        SLsmg_set_color(NEWT_COLORSET_ACTBUTTON);
     else
-       SLsmg_set_color(NEWT_COLORSET_BUTTON);
+        SLsmg_set_color(NEWT_COLORSET_BUTTON);
 
     newtGotorc(co->top + 1 + pushed, co->left + 1 + pushed);
     SLsmg_write_char(' ');
@@ -145,58 +145,58 @@ static void buttonDrawText(newtComponent co, int active, int pushed) {
 }
 
 static struct eventResult buttonEvent(newtComponent co,
-                                     struct event ev) {
+                                      struct event ev) {
     struct eventResult er;
     struct button * bu = co->data;
 
     if (ev.when == EV_NORMAL) {
-       switch (ev.event) {
-         case EV_FOCUS:
-           buttonDrawIt(co, 1, 0);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case EV_UNFOCUS:
-           buttonDrawIt(co, 0, 0);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case EV_KEYPRESS:
-           if (ev.u.key == ' ' || ev.u.key == '\r') {
-               if (!bu->compact) {
-                   /* look pushed */
-                   buttonDrawIt(co, 1, 1);
-                   newtRefresh();
-                   newtDelay(150000);
-                   buttonDrawIt(co, 1, 0);
-                   newtRefresh();
-                   newtDelay(150000);
-               }
-
-               er.result = ER_EXITFORM;
-           } else
-               er.result = ER_IGNORED;
-           break;
-         case EV_MOUSE:
-             if (ev.u.mouse.type == MOUSE_BUTTON_DOWN &&
-                 co->top <= ev.u.mouse.y &&
-                 co->top + co->height - !bu->compact > ev.u.mouse.y &&
-                 co->left <= ev.u.mouse.x &&
-                 co->left + co->width - !bu->compact > ev.u.mouse.x) {
-                 if (!bu->compact) {
-                     buttonDrawIt(co, 1, 1);
-                     newtRefresh();
-                     newtDelay(150000);
-                     buttonDrawIt(co, 1, 0);
-                     newtRefresh();
-                     newtDelay(150000);
-                 }
-                 er.result = ER_EXITFORM;
-             }
-           break;
-       }
+        switch (ev.event) {
+          case EV_FOCUS:
+            buttonDrawIt(co, 1, 0);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case EV_UNFOCUS:
+            buttonDrawIt(co, 0, 0);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case EV_KEYPRESS:
+            if (ev.u.key == ' ' || ev.u.key == '\r') {
+                if (!bu->compact) {
+                    /* look pushed */
+                    buttonDrawIt(co, 1, 1);
+                    newtRefresh();
+                    newtDelay(150000);
+                    buttonDrawIt(co, 1, 0);
+                    newtRefresh();
+                    newtDelay(150000);
+                }
+
+                er.result = ER_EXITFORM;
+            } else
+                er.result = ER_IGNORED;
+            break;
+          case EV_MOUSE:
+              if (ev.u.mouse.type == MOUSE_BUTTON_DOWN &&
+                  co->top <= ev.u.mouse.y &&
+                  co->top + co->height - !bu->compact > ev.u.mouse.y &&
+                  co->left <= ev.u.mouse.x &&
+                  co->left + co->width - !bu->compact > ev.u.mouse.x) {
+                  if (!bu->compact) {
+                      buttonDrawIt(co, 1, 1);
+                      newtRefresh();
+                      newtDelay(150000);
+                      buttonDrawIt(co, 1, 0);
+                      newtRefresh();
+                      newtDelay(150000);
+                  }
+                  er.result = ER_EXITFORM;
+              }
+            break;
+        }
     } else
-       er.result = ER_IGNORED;
+        er.result = ER_IGNORED;
 
     return er;
 }
index 45473c9d2724eb96c58945e31c17d69ffcb661cb..9d3a9e207d855f0b2f03afdd34ffd4019d1857ea 100644 (file)
@@ -6,27 +6,27 @@
 newtGrid newtButtonBarv(char * button1, newtComponent * b1comp, va_list args) {
     newtGrid grid;
     struct buttonInfo {
-       char * name;
-       newtComponent * compPtr;
+        char * name;
+        newtComponent * compPtr;
     } buttons[50];
     int num;
     int i;
 
     buttons[0].name = button1, buttons[0].compPtr = b1comp, num = 1;
     while (1) {
-       buttons[num].name = va_arg(args, char *);
-       if (!buttons[num].name) break;
-       buttons[num].compPtr = va_arg(args, newtComponent *);
-       num++;
+        buttons[num].name = va_arg(args, char *);
+        if (!buttons[num].name) break;
+        buttons[num].compPtr = va_arg(args, newtComponent *);
+        num++;
     }
 
     grid = newtCreateGrid(num, 1);
 
     for (i = 0; i < num; i++) {
-       *buttons[i].compPtr = newtButton(-1, -1, buttons[i].name);
-       newtGridSetField(grid, i, 0, NEWT_GRID_COMPONENT, 
-                        *buttons[i].compPtr,
-                        num ? 1 : 0, 0, 0, 0, 0, 0);
+        *buttons[i].compPtr = newtButton(-1, -1, buttons[i].name);
+        newtGridSetField(grid, i, 0, NEWT_GRID_COMPONENT, 
+                         *buttons[i].compPtr,
+                         num ? 1 : 0, 0, 0, 0, 0, 0);
     }
 
     return grid;
index c753374bb701a02fd4d5360913aff0a74b031f34..64f8193dc68ba43594adbf4fe586094c4226ea9e 100644 (file)
@@ -35,16 +35,16 @@ static struct componentOps cbOps = {
 } ;
 
 newtComponent newtRadiobutton(int left, int top, const char * text, int isDefault,
-                             newtComponent prevButton) {
+                              newtComponent prevButton) {
     newtComponent co;
     newtComponent curr;
     struct checkbox * rb;
     char initialValue;
 
     if (isDefault)
-       initialValue = '*';
+        initialValue = '*';
     else
-       initialValue = ' ';
+        initialValue = ' ';
 
     co = newtCheckbox(left, top, text, initialValue, " *", NULL);
     rb = co->data;
@@ -53,8 +53,8 @@ newtComponent newtRadiobutton(int left, int top, const char * text, int isDefaul
     rb->prevButton = prevButton;
 
     for (curr = co; curr; curr = rb->prevButton) {
-       rb = curr->data;
-       rb->lastButton = co;
+        rb = curr->data;
+        rb->lastButton = co;
     }
 
     return co;
@@ -67,10 +67,10 @@ newtComponent newtRadioGetCurrent(newtComponent setMember) {
     rb = setMember->data;
 
     while (rb && rb->value != '*') {
-       setMember = rb->prevButton;
-       if (!setMember)
-         return NULL;
-       rb = setMember->data;
+        setMember = rb->prevButton;
+        if (!setMember)
+          return NULL;
+        rb = setMember->data;
     }
 
     return setMember;
@@ -94,7 +94,7 @@ void newtCheckboxSetValue(newtComponent co, char value) {
  * FIXME: Check all calls.
  */
 newtComponent newtCheckbox(int left, int top, const char * text, char defValue,
-                          const char * seq, char * result) {
+                           const char * seq, char * result) {
     newtComponent co;
     struct checkbox * cb;
 
@@ -102,18 +102,18 @@ newtComponent newtCheckbox(int left, int top, const char * text, char defValue,
 
     co = malloc(sizeof(*co));
     if (co == NULL)
-       return NULL;
+        return NULL;
     cb = malloc(sizeof(struct checkbox));
     if (cb == NULL) {
-       free(co);
-       return NULL;
+        free(co);
+        return NULL;
     }
     co->data = cb;
     cb->flags = 0;
     if (result)
-       cb->result = result;
+        cb->result = result;
     else
-       cb->result = &cb->value;
+        cb->result = &cb->value;
 
     cb->text = strdup(text);
     cb->seq = strdup(seq);
@@ -142,9 +142,9 @@ void newtCheckboxSetFlags(newtComponent co, int flags, enum newtFlagsSense sense
     cb->flags = newtSetFlags(cb->flags, flags, sense);
 
     if (!(cb->flags & NEWT_FLAG_DISABLED))
-       co->takesFocus = 1;
+        co->takesFocus = 1;
     else
-       co->takesFocus = 0;
+        co->takesFocus = 0;
 
     newtGetrc(&row, &col);
     cbDraw(co);
@@ -157,11 +157,11 @@ static void cbDraw(newtComponent c) {
     if (c->top == -1 || !c->isMapped) return;
 
     if (cb->flags & NEWT_FLAG_DISABLED) {
-       cb->inactive = NEWT_COLORSET_DISENTRY;
-       cb->active = NEWT_COLORSET_DISENTRY;
+        cb->inactive = NEWT_COLORSET_DISENTRY;
+        cb->active = NEWT_COLORSET_DISENTRY;
     } else {
-       cb->inactive = COLORSET_CHECKBOX;
-       cb->active = COLORSET_ACTCHECKBOX;
+        cb->inactive = COLORSET_CHECKBOX;
+        cb->active = COLORSET_ACTCHECKBOX;
     }
 
     SLsmg_set_color(cb->inactive);
@@ -170,21 +170,21 @@ static void cbDraw(newtComponent c) {
 
     switch (cb->type) {
       case RADIO:
-       SLsmg_write_string("( ) ");
-       break;
+        SLsmg_write_string("( ) ");
+        break;
 
       case CHECK:
-       SLsmg_write_string("[ ] ");
-       break;
+        SLsmg_write_string("[ ] ");
+        break;
 
       default:
-       break;
+        break;
     }
 
     SLsmg_write_string(cb->text);
 
     if (cb->hasFocus)
-       SLsmg_set_color(cb->active);
+        SLsmg_set_color(cb->active);
 
     newtGotorc(c->top, c->left + 1);
     SLsmg_write_char(*cb->result);
@@ -205,73 +205,73 @@ struct eventResult cbEvent(newtComponent co, struct event ev) {
     const char * cur;
 
     if (ev.when == EV_NORMAL) {
-       switch (ev.event) {
-         case EV_FOCUS:
-           cb->hasFocus = 1;
-           cbDraw(co);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case EV_UNFOCUS:
-           cb->hasFocus = 0;
-           cbDraw(co);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case EV_KEYPRESS:
-           if (ev.u.key == ' ') {
-               if (cb->type == RADIO) {
-                   makeActive(co);
-               } else if (cb->type == CHECK) {
-                   cur = strchr(cb->seq, *cb->result);
-                   if (!cur)
-                       *cb->result = *cb->seq;
-                   else {
-                       cur++;
-                       if (! *cur)
-                           *cb->result = *cb->seq;
-                       else
-                           *cb->result = *cur;
-                   }
-                   cbDraw(co);
-                   er.result = ER_SWALLOWED;
-
-                   if (co->callback)
-                       co->callback(co, co->callbackData);
-               } else {
-                   er.result = ER_IGNORED;
-               }
-           } else if(ev.u.key == NEWT_KEY_ENTER) {
-               er.result = ER_IGNORED;
-           } else {
-               er.result = ER_IGNORED;
-           }
-           break;
-         case EV_MOUSE:
-           if (ev.u.mouse.type == MOUSE_BUTTON_DOWN) {
-               if (cb->type == RADIO) {
-                   makeActive(co);
-               } else if (cb->type == CHECK) {
-                   cur = strchr(cb->seq, *cb->result);
-                   if (!cur)
-                       *cb->result = *cb->seq;
-                   else {
-                       cur++;
-                       if (! *cur)
-                           *cb->result = *cb->seq;
-                       else
-                           *cb->result = *cur;
-                   }
-                   cbDraw(co);
-                   er.result = ER_SWALLOWED;
-
-                   if (co->callback)
-                       co->callback(co, co->callbackData);
-               }
-           }
-       }
+        switch (ev.event) {
+          case EV_FOCUS:
+            cb->hasFocus = 1;
+            cbDraw(co);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case EV_UNFOCUS:
+            cb->hasFocus = 0;
+            cbDraw(co);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case EV_KEYPRESS:
+            if (ev.u.key == ' ') {
+                if (cb->type == RADIO) {
+                    makeActive(co);
+                } else if (cb->type == CHECK) {
+                    cur = strchr(cb->seq, *cb->result);
+                    if (!cur)
+                        *cb->result = *cb->seq;
+                    else {
+                        cur++;
+                        if (! *cur)
+                            *cb->result = *cb->seq;
+                        else
+                            *cb->result = *cur;
+                    }
+                    cbDraw(co);
+                    er.result = ER_SWALLOWED;
+
+                    if (co->callback)
+                        co->callback(co, co->callbackData);
+                } else {
+                    er.result = ER_IGNORED;
+                }
+            } else if(ev.u.key == NEWT_KEY_ENTER) {
+                er.result = ER_IGNORED;
+            } else {
+                er.result = ER_IGNORED;
+            }
+            break;
+          case EV_MOUSE:
+            if (ev.u.mouse.type == MOUSE_BUTTON_DOWN) {
+                if (cb->type == RADIO) {
+                    makeActive(co);
+                } else if (cb->type == CHECK) {
+                    cur = strchr(cb->seq, *cb->result);
+                    if (!cur)
+                        *cb->result = *cb->seq;
+                    else {
+                        cur++;
+                        if (! *cur)
+                            *cb->result = *cb->seq;
+                        else
+                            *cb->result = *cur;
+                    }
+                    cbDraw(co);
+                    er.result = ER_SWALLOWED;
+
+                    if (co->callback)
+                        co->callback(co, co->callbackData);
+                }
+            }
+        }
     } else
-       er.result = ER_IGNORED;
+        er.result = ER_IGNORED;
 
     return er;
 }
@@ -285,16 +285,16 @@ static void makeActive(newtComponent co) {
     curr = cb->lastButton;
     rb = curr->data;
     while (curr && rb->value == rb->seq[0]) {
-       curr = rb->prevButton;
-       if (curr) rb = curr->data;
+        curr = rb->prevButton;
+        if (curr) rb = curr->data;
     }
     if (curr) {
-       rb->value = rb->seq[0];
-       cbDraw(curr);
+        rb->value = rb->seq[0];
+        cbDraw(curr);
     }
     cb->value = cb->seq[1];
     cbDraw(co);
 
     if (co->callback)
-       co->callback(co, co->callbackData);
+        co->callback(co, co->callbackData);
 }
index 815cc52e66c75f094d155ad76b76631824a47463..f4e70c0edc8010198387162567e622898c4ec210 100644 (file)
@@ -40,7 +40,7 @@ static void doBuildFlatList(struct CheckboxTree * ct, struct items * item);
 enum countWhat { COUNT_EXPOSED=0, COUNT_SELECTED=1 };
 static int countItems(struct items * item, enum countWhat justExposed);
 static inline void updateWidth(newtComponent co, struct CheckboxTree * ct,
-                               int maxField);
+                                int maxField);
 
 static struct componentOps ctOps = {
     ctDraw,
@@ -51,12 +51,12 @@ static struct componentOps ctOps = {
 } ;
 
 static inline void updateWidth(newtComponent co, struct CheckboxTree * ct,
-                               int maxField) {
+                                int maxField) {
     ct->curWidth = maxField;
     co->width = ct->curWidth + ct->sbAdjust;
 
     if (ct->sb)
-       ct->sb->left = co->left + co->width - 1;
+        ct->sb->left = co->left + co->width - 1;
 }
 
 static int countItems(struct items * item, enum countWhat what) {
@@ -64,10 +64,10 @@ static int countItems(struct items * item, enum countWhat what) {
 
     while (item) {
         if ((!item->branch && item->selected == what) || (what == COUNT_EXPOSED))
-           count++;
-       if (item->branch || (what == COUNT_EXPOSED && item->selected))
-           count += countItems(item->branch, what);
-       item = item->next;
+            count++;
+        if (item->branch || (what == COUNT_EXPOSED && item->selected))
+            count += countItems(item->branch, what);
+        item = item->next;
     }
 
     return count;
@@ -75,9 +75,9 @@ static int countItems(struct items * item, enum countWhat what) {
 
 static void doBuildFlatList(struct CheckboxTree * ct, struct items * item) {
     while (item) {
-       ct->flatList[ct->flatCount++] = item;
-       if (item->branch && item->selected) doBuildFlatList(ct, item->branch);
-       item = item->next;
+        ct->flatList[ct->flatCount++] = item;
+        if (item->branch && item->selected) doBuildFlatList(ct, item->branch);
+        item = item->next;
     }
 }
 
@@ -96,8 +96,8 @@ static void buildFlatList(newtComponent co) {
 }
 
 int newtCheckboxTreeAddItem(newtComponent co, 
-                           const char * text, const void * data,
-                           int flags, int index, ...) {
+                            const char * text, const void * data,
+                            int flags, int index, ...) {
     va_list argList;
     int numIndexes;
     int * indexes;
@@ -107,8 +107,8 @@ int newtCheckboxTreeAddItem(newtComponent co,
     numIndexes = 0;
     i = index;
     while (i != NEWT_ARG_LAST) {
-       numIndexes++;
-       i = va_arg(argList, int);
+        numIndexes++;
+        i = va_arg(argList, int);
     }
 
     va_end(argList);
@@ -119,8 +119,8 @@ int newtCheckboxTreeAddItem(newtComponent co,
     i = index;
     va_start(argList, index);
     while (i != NEWT_ARG_LAST) {
-       indexes[numIndexes++] = i;
-       i = va_arg(argList, int);
+        indexes[numIndexes++] = i;
+        i = va_arg(argList, int);
     }
     va_end(argList);
 
@@ -130,23 +130,23 @@ int newtCheckboxTreeAddItem(newtComponent co,
 }
 
 static int doFindItemPath(struct items * items, void * data, int * path, 
-                         int * len) {
+                          int * len) {
     int where = 0;
 
     while (items) {
-       if (items->data == data) {
-           if (path) path[items->depth] = where;
-           if (len) *len = items->depth + 1;
-           return 1;
-       }
-
-       if (items->branch && doFindItemPath(items->branch, data, path, len)) {
-           if (path) path[items->depth] = where;
-           return 1;
-       }
-
-       items = items->next;
-       where++;
+        if (items->data == data) {
+            if (path) path[items->depth] = where;
+            if (len) *len = items->depth + 1;
+            return 1;
+        }
+
+        if (items->branch && doFindItemPath(items->branch, data, path, len)) {
+            if (path) path[items->depth] = where;
+            return 1;
+        }
+
+        items = items->next;
+        where++;
     }
 
     return 0;
@@ -167,8 +167,8 @@ int * newtCheckboxTreeFindItem(newtComponent co, void * data) {
 }
 
 int newtCheckboxTreeAddArray(newtComponent co, 
-                           const char * text, const void * data,
-                           int flags, int * indexes) {
+                            const char * text, const void * data,
+                            int flags, int * indexes) {
     struct items * curList, * newNode, * item = NULL;
     struct items ** listPtr = NULL;
     int i, index, numIndexes, width;
@@ -178,67 +178,67 @@ int newtCheckboxTreeAddArray(newtComponent co,
     while (indexes[numIndexes] != NEWT_ARG_LAST) numIndexes++;
 
     if (!ct->itemlist) {
-       if (numIndexes > 1) return -1;
+        if (numIndexes > 1) return -1;
 
-       ct->itemlist = malloc(sizeof(*ct->itemlist)); // FIXME: Error check?
-       item = ct->itemlist;
-       item->prev = NULL;
-       item->next = NULL;
+        ct->itemlist = malloc(sizeof(*ct->itemlist)); // FIXME: Error check?
+        item = ct->itemlist;
+        item->prev = NULL;
+        item->next = NULL;
     } else {
-       curList = ct->itemlist;
-       listPtr = &ct->itemlist;
-
-       i = 0;
-       index = indexes[i];
-       while (i < numIndexes) {
-           item = curList;
-
-           if (index == NEWT_ARG_APPEND) {
-               item = NULL;
-           } else {
-               while (index && item) 
-                   item = item->next, index--;
-           }
-
-           i++;
-           if (i < numIndexes) {
-               curList = item->branch;
-               listPtr = &item->branch;
-               if (!curList && (i + 1 != numIndexes)) return -1;
-
-               index = indexes[i];
-           }
-       }
-
-       if (!curList) {                         /* create a new branch */
-           item = malloc(sizeof(*curList->prev));
-           item->next = item->prev = NULL;
-           *listPtr = item;
-       } else if (!item) {                     /* append to end */
-           item = curList;
-           while (item->next) item = item->next;
-           item->next = malloc(sizeof(*curList->prev)); // FIXME Error check
-           item->next->prev = item;
-           item = item->next;
-           item->next = NULL;
-       } else { 
-           newNode = malloc(sizeof(*newNode)); // FIXME Error check ? 
-           newNode->prev = item->prev;
-           newNode->next = item;
-
-           if (item->prev) item->prev->next = newNode;
-           item->prev = newNode;
-           item = newNode;
-           if (!item->prev) *listPtr = item;
-       }
+        curList = ct->itemlist;
+        listPtr = &ct->itemlist;
+
+        i = 0;
+        index = indexes[i];
+        while (i < numIndexes) {
+            item = curList;
+
+            if (index == NEWT_ARG_APPEND) {
+                item = NULL;
+            } else {
+                while (index && item) 
+                    item = item->next, index--;
+            }
+
+            i++;
+            if (i < numIndexes) {
+                curList = item->branch;
+                listPtr = &item->branch;
+                if (!curList && (i + 1 != numIndexes)) return -1;
+
+                index = indexes[i];
+            }
+        }
+
+        if (!curList) {                         /* create a new branch */
+            item = malloc(sizeof(*curList->prev));
+            item->next = item->prev = NULL;
+            *listPtr = item;
+        } else if (!item) {                     /* append to end */
+            item = curList;
+            while (item->next) item = item->next;
+            item->next = malloc(sizeof(*curList->prev)); // FIXME Error check
+            item->next->prev = item;
+            item = item->next;
+            item->next = NULL;
+        } else { 
+            newNode = malloc(sizeof(*newNode)); // FIXME Error check ? 
+            newNode->prev = item->prev;
+            newNode->next = item;
+
+            if (item->prev) item->prev->next = newNode;
+            item->prev = newNode;
+            item = newNode;
+            if (!item->prev) *listPtr = item;
+        }
     }
-       
+        
     item->text = strdup(text);
     item->data = data;
     if (flags & NEWT_FLAG_SELECTED) {
-       item->selected = 1;
+        item->selected = 1;
     } else {
-       item->selected = 0;
+        item->selected = 0;
     }
     item->flags = flags;
     item->branch = NULL;
@@ -248,7 +248,7 @@ int newtCheckboxTreeAddArray(newtComponent co,
     width = wstrlen(text, -1);
 
     if ((ct->userHasSetWidth == 0) && ((width + i + ct->sbAdjust) > co->width)) {
-       updateWidth(co, ct, width + i);
+        updateWidth(co, ct, width + i);
     }
 
     return 0;
@@ -258,13 +258,13 @@ static struct items * findItem(struct items * items, const void * data) {
     struct items * i;
 
     while (items) {
-       if (items->data == data) return items;
-       if (items->branch) {
-           i = findItem(items->branch, data);
-           if (i) return i;
-       }
+        if (items->data == data) return items;
+        if (items->branch) {
+            i = findItem(items->branch, data);
+            if (i) return i;
+        }
 
-       items = items->next;
+        items = items->next;
     }
 
     return NULL;
@@ -272,11 +272,11 @@ static struct items * findItem(struct items * items, const void * data) {
 
 static void listSelected(struct items * items, int * num, const void ** list, int seqindex) {
     while (items) {
-           if ((seqindex ? items->selected==seqindex : items->selected) && !items->branch)
-           list[(*num)++] = (void *) items->data;
-       if (items->branch)
-           listSelected(items->branch, num, list, seqindex);
-       items = items->next;
+            if ((seqindex ? items->selected==seqindex : items->selected) && !items->branch)
+            list[(*num)++] = (void *) items->data;
+        if (items->branch)
+            listSelected(items->branch, num, list, seqindex);
+        items = items->next;
     }
 }
 
@@ -304,11 +304,11 @@ const void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems,
     if(!co || !numitems) return NULL;
 
     ct = co->data;
-       
+        
     if (seqnum) {
-           while( ct->seq[seqindex] && ( ct->seq[seqindex] != seqnum )) seqindex++;
+            while( ct->seq[seqindex] && ( ct->seq[seqindex] != seqnum )) seqindex++;
     } else {
-           seqindex = 0;
+            seqindex = 0;
     }
 
     *numitems = countItems(ct->itemlist, (seqindex ? seqindex : COUNT_SELECTED));
@@ -322,7 +322,7 @@ const void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems,
 }
 
 newtComponent newtCheckboxTree(int left, int top, int height, int flags) {
-       return newtCheckboxTreeMulti(left, top, height, NULL, flags);
+        return newtCheckboxTreeMulti(left, top, height, NULL, flags);
 }
 
 newtComponent newtCheckboxTreeMulti(int left, int top, int height, char *seq, int flags) {
@@ -348,16 +348,16 @@ newtComponent newtCheckboxTreeMulti(int left, int top, int height, char *seq, in
     ct->flags = flags;
 
     if (seq)
-       ct->seq = strdup(seq);
+        ct->seq = strdup(seq);
     else
-       ct->seq = strdup(" *");
+        ct->seq = strdup(" *");
     if (flags & NEWT_FLAG_SCROLL) {
-       ct->sb = newtVerticalScrollbar(left, top, height,
-                                      COLORSET_LISTBOX, COLORSET_ACTLISTBOX);
-       ct->sbAdjust = 2;
+        ct->sb = newtVerticalScrollbar(left, top, height,
+                                       COLORSET_LISTBOX, COLORSET_ACTLISTBOX);
+        ct->sbAdjust = 2;
     } else {
-       ct->sb = NULL;
-       ct->sbAdjust = 0;
+        ct->sb = NULL;
+        ct->sbAdjust = 0;
     }
     
     return co;
@@ -368,7 +368,7 @@ static void ctMapped(newtComponent co, int isMapped) {
 
     co->isMapped = isMapped;
     if (ct->sb)
-       ct->sb->ops->mapped(ct->sb, isMapped);
+        ct->sb->ops->mapped(ct->sb, isMapped);
 }
 
 static void ctPlace(newtComponent co, int newLeft, int newTop) {
@@ -378,7 +378,7 @@ static void ctPlace(newtComponent co, int newLeft, int newTop) {
     co->left = newLeft;
 
     if (ct->sb)
-       ct->sb->ops->place(ct->sb, co->left + co->width - 1, co->top);
+        ct->sb->ops->place(ct->sb, co->left + co->width - 1, co->top);
 }
 
 int ctSetItem(newtComponent co, struct items *item, enum newtFlagsSense sense)
@@ -388,41 +388,41 @@ int ctSetItem(newtComponent co, struct items *item, enum newtFlagsSense sense)
     struct items * firstItem;
     
     if (!item)
-       return 1;
+        return 1;
     
     switch(sense) {
-       case NEWT_FLAGS_RESET:
-           item->selected = 0;
-           break;
-       case NEWT_FLAGS_SET:
-           item->selected = 1;
-           break;
-       case NEWT_FLAGS_TOGGLE:
-           if (item->branch)
-             item->selected = !item->selected;
-           else if (!(ct->flags & NEWT_CHECKBOXTREE_UNSELECTABLE)) {
-                   item->selected++;
-                   if (item->selected==strlen(ct->seq))
-                     item->selected = 0;
-           }
-           break;
+        case NEWT_FLAGS_RESET:
+            item->selected = 0;
+            break;
+        case NEWT_FLAGS_SET:
+            item->selected = 1;
+            break;
+        case NEWT_FLAGS_TOGGLE:
+            if (item->branch)
+              item->selected = !item->selected;
+            else if (!(ct->flags & NEWT_CHECKBOXTREE_UNSELECTABLE)) {
+                    item->selected++;
+                    if (item->selected==strlen(ct->seq))
+                      item->selected = 0;
+            }
+            break;
     }
 
     if (item->branch) {
-       currItem = *ct->currItem;
-       firstItem = *ct->firstItem;
+        currItem = *ct->currItem;
+        firstItem = *ct->firstItem;
 
-       buildFlatList(co);
+        buildFlatList(co);
 
-       ct->currItem = ct->flatList;
-       while (*ct->currItem != currItem) ct->currItem++;
+        ct->currItem = ct->flatList;
+        while (*ct->currItem != currItem) ct->currItem++;
 
-       ct->firstItem = ct->flatList;
-       if (ct->flatCount > co->height) {
-               struct items ** last = ct->flatList + ct->flatCount - co->height;
-               while (*ct->firstItem != firstItem && ct->firstItem != last)
-                   ct->firstItem++;
-       }
+        ct->firstItem = ct->flatList;
+        if (ct->flatCount > co->height) {
+                struct items ** last = ct->flatList + ct->flatCount - co->height;
+                while (*ct->firstItem != firstItem && ct->firstItem != last)
+                    ct->firstItem++;
+        }
     }
 
     return 0;
@@ -431,10 +431,10 @@ int ctSetItem(newtComponent co, struct items *item, enum newtFlagsSense sense)
 static void ctSetItems(struct items *item, int selected)
 {
     for (; item; item = item->next) {
-       if (!item->branch)
-           item->selected = selected;
-       else
-           ctSetItems(item->branch, selected);
+        if (!item->branch)
+            item->selected = selected;
+        else
+            ctSetItems(item->branch, selected);
     }
 }
 
@@ -448,8 +448,8 @@ static void ctDraw(newtComponent co) {
     if (!co->isMapped) return ;
 
     if (!ct->firstItem) {
-       buildFlatList(co);
-       ct->firstItem = ct->currItem = ct->flatList;
+        buildFlatList(co);
+        ct->firstItem = ct->currItem = ct->flatList;
     }
 
     item = ct->firstItem;
@@ -459,60 +459,60 @@ static void ctDraw(newtComponent co) {
     newtTrashScreen();
     
     while (*item && i < co->height) {
-       newtGotorc(co->top + i, co->left);
-       if (*item == *ct->currItem) {
-           SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
-           currRow = co->top + i;
-       } else
-           SLsmg_set_color(NEWT_COLORSET_LISTBOX);
-
-       for (j = 0; j < (*item)->depth; j++)
-           SLsmg_write_string("   ");
-
-       if ((*item)->branch) {
-           if ((*item)->selected) 
-               SLsmg_write_string("<-> ");
-           else
-               SLsmg_write_string("<+> ");
-       } else {
-           if (ct->flags & NEWT_CHECKBOXTREE_HIDE_BOX) {
-               if ((*item)->selected)
-                   SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
-               SLsmg_write_string("    ");
-           } else {
-               char tmp[5];
-               snprintf(tmp,5,"[%c] ",ct->seq[(*item)->selected]);
-               SLsmg_write_string(tmp);
-           }
-       }
-
-       SLsmg_write_nstring((*item)->text, co->width - 4 - 
-                                          (3 * (*item)->depth));
-
-       SLsmg_set_color(NEWT_COLORSET_LISTBOX);
-
-       item++;
-       i++;
+        newtGotorc(co->top + i, co->left);
+        if (*item == *ct->currItem) {
+            SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
+            currRow = co->top + i;
+        } else
+            SLsmg_set_color(NEWT_COLORSET_LISTBOX);
+
+        for (j = 0; j < (*item)->depth; j++)
+            SLsmg_write_string("   ");
+
+        if ((*item)->branch) {
+            if ((*item)->selected) 
+                SLsmg_write_string("<-> ");
+            else
+                SLsmg_write_string("<+> ");
+        } else {
+            if (ct->flags & NEWT_CHECKBOXTREE_HIDE_BOX) {
+                if ((*item)->selected)
+                    SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
+                SLsmg_write_string("    ");
+            } else {
+                char tmp[5];
+                snprintf(tmp,5,"[%c] ",ct->seq[(*item)->selected]);
+                SLsmg_write_string(tmp);
+            }
+        }
+
+        SLsmg_write_nstring((*item)->text, co->width - 4 - 
+                                           (3 * (*item)->depth));
+
+        SLsmg_set_color(NEWT_COLORSET_LISTBOX);
+
+        item++;
+        i++;
     }
 
     /* There could be empty lines left (i.e. if the user closes an expanded
        list which is the last thing in the tree, and whose elements are
        displayed at the bottom of the screen */
     if (i < co->height) {
-       spaces = alloca(co->width);
-       memset(spaces, ' ', co->width);
-       SLsmg_set_color(NEWT_COLORSET_LISTBOX);
+        spaces = alloca(co->width);
+        memset(spaces, ' ', co->width);
+        SLsmg_set_color(NEWT_COLORSET_LISTBOX);
     }
     while (i < co->height) {
-       newtGotorc(co->top + i, co->left);
-       SLsmg_write_nstring(spaces, co->width);
-       i++;
+        newtGotorc(co->top + i, co->left);
+        SLsmg_write_nstring(spaces, co->width);
+        i++;
     }
     
     if(ct->sb) {
-       newtScrollbarSet(ct->sb, ct->currItem - ct->flatList, 
-                        ct->flatCount - 1);
-       ct->sb->ops->draw(ct->sb);
+        newtScrollbarSet(ct->sb, ct->currItem - ct->flatList, 
+                         ct->flatCount - 1);
+        ct->sb->ops->draw(ct->sb);
     }
 
     newtGotorc(currRow, co->left + 1);
@@ -525,10 +525,10 @@ static void ctDestroy(newtComponent co) {
     nextitem = item = ct->itemlist;
 
     while (item != NULL) {
-       nextitem = item->next;
-       free(item->text);
-       free(item);
-       item = nextitem;
+        nextitem = item->next;
+        free(item->text);
+        free(item);
+        item = nextitem;
     }
 
     free(ct->seq);
@@ -545,143 +545,143 @@ struct eventResult ctEvent(newtComponent co, struct event ev) {
     er.result = ER_IGNORED;
 
     if(ev.when == EV_EARLY || ev.when == EV_LATE) {
-       return er;
+        return er;
     }
 
     switch(ev.event) {
     case EV_KEYPRESS:
-       key = ev.u.key;
-       if (key == (char) key && key != ' ') {
-           for (selnum = 0; ct->seq[selnum]; selnum++)
-           if (key == ct->seq[selnum])
-               break;
-           if (!ct->seq[selnum])
-               switch (key) {
-               case '-': selnum = 0; break;
-               case '+':
-               case '*': selnum = 1; break;
-               }
-           if (ct->seq[selnum])
-               key = '*';
-       }
-       switch(key) {
-       case ' ':
-       case NEWT_KEY_ENTER:
-           ctSetItem(co, *ct->currItem, NEWT_FLAGS_TOGGLE);
-           er.result = ER_SWALLOWED;
-           if (!(*ct->currItem)->branch || (*ct->currItem)->selected)
-               key = NEWT_KEY_DOWN;
-           else
-               key = '*';
-           break;
-       case '*':
-           if ((*ct->currItem)->branch) {
-               ctSetItems((*ct->currItem)->branch, selnum);
-               if (!(*ct->currItem)->selected)
-                   key = NEWT_KEY_DOWN;
-           } else {
-               (*ct->currItem)->selected = selnum;
-               key = NEWT_KEY_DOWN;
-           }
-           er.result = ER_SWALLOWED;
-           break;
-       }
-       switch (key) {
-       case '*':
-           ctDraw(co);
-           if(co->callback) co->callback(co, co->callbackData);
-           return er;
-       case NEWT_KEY_HOME:
-           ct->currItem = ct->flatList;
-           ct->firstItem = ct->flatList;
-           ctDraw(co);
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           return er;
-       case NEWT_KEY_END:
-           ct->currItem = ct->flatList + ct->flatCount - 1;
-           if (ct->flatCount <= co->height)
-               ct->firstItem = ct->flatList;
-           else
-               ct->firstItem = ct->flatList + ct->flatCount - co->height;
-           ctDraw(co);
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           return er;
-       case NEWT_KEY_DOWN:
-           if (ev.u.key != NEWT_KEY_DOWN) {
-               if(co->callback) co->callback(co, co->callbackData);
-               if (strlen(ct->seq) != 2) {
-                   ctDraw(co);
-                   return er;
-               }
-           }
-           if ((ct->currItem - ct->flatList + 1) < ct->flatCount) {
-               ct->currItem++;
-
-               if (ct->currItem - ct->firstItem >= co->height) 
-                   ct->firstItem++;
-
-               ctDraw(co);
-           } else if (ev.u.key != NEWT_KEY_DOWN)
-               ctDraw(co);
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           return er;
-       case NEWT_KEY_UP:
-           if (ct->currItem != ct->flatList) {
-               ct->currItem--;
-
-               if (ct->currItem < ct->firstItem)
-                   ct->firstItem = ct->currItem;
-                   
-               ctDraw(co);
-           }
-           er.result = ER_SWALLOWED;
-           if(co->callback) co->callback(co, co->callbackData);
-           return er;
-       case NEWT_KEY_PGUP:
-           if (ct->firstItem - co->height < ct->flatList) {
-               ct->firstItem = ct->currItem = ct->flatList;
-           } else {
-               ct->currItem -= co->height;
-               ct->firstItem -= co->height;
-           }
-
-           ctDraw(co);
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           return er;
-       case NEWT_KEY_PGDN:
-           listEnd = ct->flatList + ct->flatCount - 1;
-           lastItem = ct->firstItem + co->height - 1;
-
-           if (lastItem + co->height > listEnd) {
-               ct->firstItem = listEnd - co->height + 1;
-               ct->currItem = listEnd;
-           } else {
-               ct->currItem += co->height;
-               ct->firstItem += co->height;
-           }
-
-           ctDraw(co);
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           return er;
-       }
-       break;
+        key = ev.u.key;
+        if (key == (char) key && key != ' ') {
+            for (selnum = 0; ct->seq[selnum]; selnum++)
+            if (key == ct->seq[selnum])
+                break;
+            if (!ct->seq[selnum])
+                switch (key) {
+                case '-': selnum = 0; break;
+                case '+':
+                case '*': selnum = 1; break;
+                }
+            if (ct->seq[selnum])
+                key = '*';
+        }
+        switch(key) {
+        case ' ':
+        case NEWT_KEY_ENTER:
+            ctSetItem(co, *ct->currItem, NEWT_FLAGS_TOGGLE);
+            er.result = ER_SWALLOWED;
+            if (!(*ct->currItem)->branch || (*ct->currItem)->selected)
+                key = NEWT_KEY_DOWN;
+            else
+                key = '*';
+            break;
+        case '*':
+            if ((*ct->currItem)->branch) {
+                ctSetItems((*ct->currItem)->branch, selnum);
+                if (!(*ct->currItem)->selected)
+                    key = NEWT_KEY_DOWN;
+            } else {
+                (*ct->currItem)->selected = selnum;
+                key = NEWT_KEY_DOWN;
+            }
+            er.result = ER_SWALLOWED;
+            break;
+        }
+        switch (key) {
+        case '*':
+            ctDraw(co);
+            if(co->callback) co->callback(co, co->callbackData);
+            return er;
+        case NEWT_KEY_HOME:
+            ct->currItem = ct->flatList;
+            ct->firstItem = ct->flatList;
+            ctDraw(co);
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            return er;
+        case NEWT_KEY_END:
+            ct->currItem = ct->flatList + ct->flatCount - 1;
+            if (ct->flatCount <= co->height)
+                ct->firstItem = ct->flatList;
+            else
+                ct->firstItem = ct->flatList + ct->flatCount - co->height;
+            ctDraw(co);
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            return er;
+        case NEWT_KEY_DOWN:
+            if (ev.u.key != NEWT_KEY_DOWN) {
+                if(co->callback) co->callback(co, co->callbackData);
+                if (strlen(ct->seq) != 2) {
+                    ctDraw(co);
+                    return er;
+                }
+            }
+            if ((ct->currItem - ct->flatList + 1) < ct->flatCount) {
+                ct->currItem++;
+
+                if (ct->currItem - ct->firstItem >= co->height) 
+                    ct->firstItem++;
+
+                ctDraw(co);
+            } else if (ev.u.key != NEWT_KEY_DOWN)
+                ctDraw(co);
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            return er;
+        case NEWT_KEY_UP:
+            if (ct->currItem != ct->flatList) {
+                ct->currItem--;
+
+                if (ct->currItem < ct->firstItem)
+                    ct->firstItem = ct->currItem;
+                    
+                ctDraw(co);
+            }
+            er.result = ER_SWALLOWED;
+            if(co->callback) co->callback(co, co->callbackData);
+            return er;
+        case NEWT_KEY_PGUP:
+            if (ct->firstItem - co->height < ct->flatList) {
+                ct->firstItem = ct->currItem = ct->flatList;
+            } else {
+                ct->currItem -= co->height;
+                ct->firstItem -= co->height;
+            }
+
+            ctDraw(co);
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            return er;
+        case NEWT_KEY_PGDN:
+            listEnd = ct->flatList + ct->flatCount - 1;
+            lastItem = ct->firstItem + co->height - 1;
+
+            if (lastItem + co->height > listEnd) {
+                ct->firstItem = listEnd - co->height + 1;
+                ct->currItem = listEnd;
+            } else {
+                ct->currItem += co->height;
+                ct->firstItem += co->height;
+            }
+
+            ctDraw(co);
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            return er;
+        }
+        break;
 
     case EV_FOCUS:
-       ctDraw(co);
-       er.result = ER_SWALLOWED;
-       break;
-       
+        ctDraw(co);
+        er.result = ER_SWALLOWED;
+        break;
+        
     case EV_UNFOCUS:
-       ctDraw(co);
-       er.result = ER_SWALLOWED;
-       break;
+        ctDraw(co);
+        er.result = ER_SWALLOWED;
+        break;
     default:
-       break;
+        break;
     }
 
     return er;
@@ -712,7 +712,7 @@ void newtCheckboxTreeSetEntry(newtComponent co, const void * data, const char *
 
     width = wstrlen(text, -1);
     if ((ct->userHasSetWidth == 0) && ((width + i + ct->sbAdjust) > co->width)) {
-       updateWidth(co, ct, width + i);
+        updateWidth(co, ct, width + i);
     }
 
     ctDraw(co);
@@ -728,9 +728,9 @@ char newtCheckboxTreeGetEntryValue(newtComponent co, const void * data)
     item = findItem(ct->itemlist, data);
     if (!item) return -1;
     if (item->branch)
-       return item->selected ? NEWT_CHECKBOXTREE_EXPANDED : NEWT_CHECKBOXTREE_COLLAPSED;
+        return item->selected ? NEWT_CHECKBOXTREE_EXPANDED : NEWT_CHECKBOXTREE_COLLAPSED;
     else
-       return ct->seq[item->selected];
+        return ct->seq[item->selected];
 }
 
 void newtCheckboxTreeSetEntryValue(newtComponent co, const void * data, char value)
@@ -745,8 +745,8 @@ void newtCheckboxTreeSetEntryValue(newtComponent co, const void * data, char val
     if (!item || item->branch) return;
 
     for(i = 0; ct->seq[i]; i++)
-       if (value == ct->seq[i])
-           break;
+        if (value == ct->seq[i])
+            break;
 
     if (!ct->seq[i]) return;
     item->selected = i;
@@ -766,15 +766,15 @@ void newtCheckboxTreeSetCurrent(newtComponent co, void * data) {
 
     /* traverse the path and turn on all of the branches to this point */
     for (i = 0, treeTop = ct->itemlist; path[i + 1] != NEWT_ARG_LAST; i++) {
-       for (j = 0, item = treeTop; j < path[i]; j++)
-           item = item->next;
+        for (j = 0, item = treeTop; j < path[i]; j++)
+            item = item->next;
 
-       item->selected = 1;
-       treeTop = item->branch;
+        item->selected = 1;
+        treeTop = item->branch;
     }
 
     buildFlatList(co);
-       
+        
     item = findItem(ct->itemlist, data);
 
     i = 0;
@@ -784,10 +784,10 @@ void newtCheckboxTreeSetCurrent(newtComponent co, void * data) {
     j = i - (co->height / 2);
 
     if ((j + co->height) > ct->flatCount) 
-       j = ct->flatCount - co->height;
+        j = ct->flatCount - co->height;
     
     if (j < 0)
-       j = 0;
+        j = 0;
 
     ct->firstItem = ct->flatList + j;
     ct->currItem = ct->flatList + i;
index d2b220968fb81c2768f30b606c5ea26d9d2558b5..c9d3643e41620c78da0fc408a73dd0f7835bf086 100644 (file)
 /* globals -- ick */
 static int buttonHeight = 1;
 static newtComponent (*makeButton)(int left, int right, const char * text) = 
-               newtCompactButton;
+                newtCompactButton;
 
 static void addButtons(int height, int width, newtComponent form, 
-                      newtComponent * okay, newtComponent * cancel, 
-                      int flags) {
+                       newtComponent * okay, newtComponent * cancel, 
+                       int flags) {
     if (flags & FLAG_NOCANCEL) {
-       *okay = makeButton((width - 8) / 2, height - buttonHeight - 1, "Ok");
-       *cancel = NULL;
-       newtFormAddComponent(form, *okay);
+        *okay = makeButton((width - 8) / 2, height - buttonHeight - 1, "Ok");
+        *cancel = NULL;
+        newtFormAddComponent(form, *okay);
     } else {
-       *okay = makeButton((width - 18) / 3, height - buttonHeight - 1, "Ok");
-       *cancel = makeButton(((width - 18) / 3) * 2 + 9, 
-                               height - buttonHeight - 1, "Cancel");
-       newtFormAddComponents(form, *okay, *cancel, NULL);
+        *okay = makeButton((width - 18) / 3, height - buttonHeight - 1, "Ok");
+        *cancel = makeButton(((width - 18) / 3) * 2 + 9, 
+                                height - buttonHeight - 1, "Cancel");
+        newtFormAddComponents(form, *okay, *cancel, NULL);
     }
 }
 
 static newtComponent textbox(int maxHeight, int width, const char * text,
-                       int flags, int * height) {
+                        int flags, int * height) {
     newtComponent tb;
     int sFlag = (flags & FLAG_SCROLL_TEXT) ? NEWT_FLAG_SCROLL : 0;
     int i;
@@ -45,11 +45,11 @@ static newtComponent textbox(int maxHeight, int width, const char * text,
     dst = buf = alloca(strlen(text) + 1);
     src = text; 
     while (*src) {
-       if (*src == '\\' && *(src + 1) == 'n') {
-           src += 2;
-           *dst++ = '\n';
-       } else
-           *dst++ = *src++;
+        if (*src == '\\' && *(src + 1) == 'n') {
+            src += 2;
+            *dst++ = '\n';
+        } else
+            *dst++ = *src++;
     }
     *dst++ = '\0';
 
@@ -58,8 +58,8 @@ static newtComponent textbox(int maxHeight, int width, const char * text,
 
     i = newtTextboxGetNumLines(tb);
     if (i < maxHeight) {
-       newtTextboxSetHeight(tb, i);
-       maxHeight = i;
+        newtTextboxSetHeight(tb, i);
+        maxHeight = i;
     }
 
     *height = maxHeight;
@@ -68,7 +68,7 @@ static newtComponent textbox(int maxHeight, int width, const char * text,
 }
 
 int gauge(const char * text, int height, int width, poptContext optCon, int fd, 
-               int flags) {
+                int flags) {
     newtComponent form, scale, tb;
     int top;
     const char * arg;
@@ -98,41 +98,41 @@ int gauge(const char * text, int height, int width, poptContext optCon, int fd,
     newtRefresh();
 
     while (fgets(buf, sizeof(buf) - 1, f)) {
-       buf[strlen(buf) - 1] = '\0';
-
-       if (!strcmp(buf, "XXX")) {
-           fgets(buf3, sizeof(buf3) - 1, f);
-           buf3[strlen(buf3) - 1] = '\0';
-           arg = buf3;
-
-           i = 0;
-           while (fgets(buf + i, sizeof(buf) - 1 - i, f)) {
-               buf[strlen(buf) - 1] = '\0';
-               if (!strcmp(buf + i, "XXX")) {
-                   *(buf + i) = '\0';
-                   break;
-               }
-               i = strlen(buf);
-           }
-
-           newtTextboxSetText(tb, buf);
-       } else {
-           arg = buf;
-       }
-
-       val = strtoul(buf, &end, 10);
-       if (!*end) {
-           newtScaleSet(scale, val);
-           newtDrawForm(form);
-           newtRefresh();
-       }
+        buf[strlen(buf) - 1] = '\0';
+
+        if (!strcmp(buf, "XXX")) {
+            fgets(buf3, sizeof(buf3) - 1, f);
+            buf3[strlen(buf3) - 1] = '\0';
+            arg = buf3;
+
+            i = 0;
+            while (fgets(buf + i, sizeof(buf) - 1 - i, f)) {
+                buf[strlen(buf) - 1] = '\0';
+                if (!strcmp(buf + i, "XXX")) {
+                    *(buf + i) = '\0';
+                    break;
+                }
+                i = strlen(buf);
+            }
+
+            newtTextboxSetText(tb, buf);
+        } else {
+            arg = buf;
+        }
+
+        val = strtoul(buf, &end, 10);
+        if (!*end) {
+            newtScaleSet(scale, val);
+            newtDrawForm(form);
+            newtRefresh();
+        }
     }
 
     return DLG_OKAY;
 }
 
 int inputBox(const char * text, int height, int width, poptContext optCon, 
-               int flags, const char ** result) {
+                int flags, const char ** result) {
     newtComponent form, entry, okay, cancel, answer, tb;
     const char * val;
     int rc = DLG_OKAY;
@@ -140,11 +140,11 @@ int inputBox(const char * text, int height, int width, poptContext optCon,
 
     val = poptGetArg(optCon);
     tb = textbox(height - 3 - buttonHeight, width - 2,
-                       text, flags, &top);
+                        text, flags, &top);
 
     form = newtForm(NULL, NULL, 0);
     entry = newtEntry(1, top + 1, val, width - 2, &val, 
-                       NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
+                        NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
 
     newtFormAddComponents(form, tb, entry, NULL);
 
@@ -152,7 +152,7 @@ int inputBox(const char * text, int height, int width, poptContext optCon,
 
     answer = newtRunForm(form);
     if (answer == cancel)
-       rc = DLG_CANCEL;
+        rc = DLG_CANCEL;
 
     *result = val;
 
@@ -160,7 +160,7 @@ int inputBox(const char * text, int height, int width, poptContext optCon,
 }
 
 int listBox(const char * text, int height, int width, poptContext optCon,
-               int flags, const char ** result) {
+                int flags, const char ** result) {
     newtComponent form, okay, tb, answer, listBox;
     newtComponent cancel = NULL;
     const char * arg;
@@ -175,8 +175,8 @@ int listBox(const char * text, int height, int width, poptContext optCon,
     int maxTextWidth = 0;
     int scrollFlag;
     struct {
-       const char * text;
-       const char * tag;
+        const char * text;
+        const char * tag;
     } * itemInfo = malloc(allocedItems * sizeof(*itemInfo));
 
     if (itemInfo == NULL) return DLG_ERROR;
@@ -185,56 +185,56 @@ int listBox(const char * text, int height, int width, poptContext optCon,
     if (*end) return DLG_ERROR;
 
     while ((arg = poptGetArg(optCon))) {
-       if (allocedItems == numItems) {
-           allocedItems += 5;
-           itemInfo = realloc(itemInfo, sizeof(*itemInfo) * allocedItems);
-           if (itemInfo == NULL) return DLG_ERROR;
-       }
-
-       itemInfo[numItems].tag = arg;
-       if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
-
-       if (!(flags & FLAG_NOITEM)) {
-           itemInfo[numItems].text = arg;
-       } else
-           itemInfo[numItems].text = "";
-
-       if (wstrlen(itemInfo[numItems].text,-1) > (unsigned int)maxTextWidth)
-           maxTextWidth = wstrlen(itemInfo[numItems].text,-1);
-       if (wstrlen(itemInfo[numItems].tag,-1) > (unsigned int)maxTagWidth)
-           maxTagWidth = wstrlen(itemInfo[numItems].tag,-1);
-
-       numItems++;
+        if (allocedItems == numItems) {
+            allocedItems += 5;
+            itemInfo = realloc(itemInfo, sizeof(*itemInfo) * allocedItems);
+            if (itemInfo == NULL) return DLG_ERROR;
+        }
+
+        itemInfo[numItems].tag = arg;
+        if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
+
+        if (!(flags & FLAG_NOITEM)) {
+            itemInfo[numItems].text = arg;
+        } else
+            itemInfo[numItems].text = "";
+
+        if (wstrlen(itemInfo[numItems].text,-1) > (unsigned int)maxTextWidth)
+            maxTextWidth = wstrlen(itemInfo[numItems].text,-1);
+        if (wstrlen(itemInfo[numItems].tag,-1) > (unsigned int)maxTagWidth)
+            maxTagWidth = wstrlen(itemInfo[numItems].tag,-1);
+
+        numItems++;
     }
     if (numItems == 0)
-       return DLG_ERROR;
+        return DLG_ERROR;
 
     if (flags & FLAG_NOTAGS) {
-           maxTagWidth = 0;
+            maxTagWidth = 0;
     }
 
     form = newtForm(NULL, NULL, 0);
 
     tb = textbox(height - 4 - buttonHeight - listHeight, width - 2,
-                       text, flags, &top);
+                        text, flags, &top);
 
     if (listHeight >= numItems) {
-       scrollFlag = 0;
-       i = 0;
+        scrollFlag = 0;
+        i = 0;
     } else {
-       scrollFlag = NEWT_FLAG_SCROLL;
-       i = 2;
+        scrollFlag = NEWT_FLAG_SCROLL;
+        i = 2;
     }
 
     listBox = newtListbox(3 + ((width - 10 - maxTagWidth - maxTextWidth - i) 
-                                       / 2),
-                         top + 1, listHeight, 
-                           NEWT_FLAG_RETURNEXIT | scrollFlag);
+                                        / 2),
+                          top + 1, listHeight, 
+                            NEWT_FLAG_RETURNEXIT | scrollFlag);
 
     snprintf(format, MAXFORMAT, "%%-%ds  %%s", maxTagWidth);
     for (i = 0; i < numItems; i++) {
-       snprintf(buf, MAXBUF, format, itemInfo[i].tag, itemInfo[i].text);
-       newtListboxAddEntry(listBox, buf, (void *) i);
+        snprintf(buf, MAXBUF, format, itemInfo[i].tag, itemInfo[i].text);
+        newtListboxAddEntry(listBox, buf, (void *) i);
     }
 
     newtFormAddComponents(form, tb, listBox, NULL);
@@ -243,7 +243,7 @@ int listBox(const char * text, int height, int width, poptContext optCon,
 
     answer = newtRunForm(form);
     if (answer == cancel)
-       rc = DLG_CANCEL;
+        rc = DLG_CANCEL;
 
     i = (int) newtListboxGetCurrent(listBox);
     *result = itemInfo[i].tag;
@@ -252,7 +252,7 @@ int listBox(const char * text, int height, int width, poptContext optCon,
 }
 
 int checkList(const char * text, int height, int width, poptContext optCon,
-               int useRadio, int flags, const char *** selections) {
+                int useRadio, int flags, const char *** selections) {
     newtComponent form, okay, tb, subform, answer;
     newtComponent sb = NULL, cancel = NULL;
     const char * arg;
@@ -267,9 +267,9 @@ int checkList(const char * text, int height, int width, poptContext optCon,
     int maxWidth = 0;
     int top;
     struct {
-       const char * text;
-       const char * tag;
-       newtComponent comp;
+        const char * text;
+        const char * tag;
+        newtComponent comp;
     } * cbInfo = malloc(allocedBoxes * sizeof(*cbInfo));
     char * cbStates = malloc(allocedBoxes * sizeof(cbStates));
 
@@ -279,63 +279,63 @@ int checkList(const char * text, int height, int width, poptContext optCon,
     if (*end) return DLG_ERROR;
 
     while ((arg = poptGetArg(optCon))) {
-       if (allocedBoxes == numBoxes) {
-           allocedBoxes += 5;
-           cbInfo = realloc(cbInfo, sizeof(*cbInfo) * allocedBoxes);
-           cbStates = realloc(cbStates, sizeof(*cbStates) * allocedBoxes);
-           if ((cbInfo == NULL) || (cbStates == NULL)) return DLG_ERROR;
-       }
-
-       cbInfo[numBoxes].tag = arg;
-       if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
-
-       if (!(flags & FLAG_NOITEM)) {
-           cbInfo[numBoxes].text = arg;
-           if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
-       } else
-           cbInfo[numBoxes].text = "";
-
-       if (!strcmp(arg, "1") || !strcasecmp(arg, "on") || 
-               !strcasecmp(arg, "yes"))
-           cbStates[numBoxes] = '*';
-       else
-           cbStates[numBoxes] = ' ';
-
-       if (wstrlen(cbInfo[numBoxes].tag,-1) > (unsigned int)maxWidth)
-           maxWidth = wstrlen(cbInfo[numBoxes].tag,-1);
-
-       numBoxes++;
+        if (allocedBoxes == numBoxes) {
+            allocedBoxes += 5;
+            cbInfo = realloc(cbInfo, sizeof(*cbInfo) * allocedBoxes);
+            cbStates = realloc(cbStates, sizeof(*cbStates) * allocedBoxes);
+            if ((cbInfo == NULL) || (cbStates == NULL)) return DLG_ERROR;
+        }
+
+        cbInfo[numBoxes].tag = arg;
+        if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
+
+        if (!(flags & FLAG_NOITEM)) {
+            cbInfo[numBoxes].text = arg;
+            if (!(arg = poptGetArg(optCon))) return DLG_ERROR;
+        } else
+            cbInfo[numBoxes].text = "";
+
+        if (!strcmp(arg, "1") || !strcasecmp(arg, "on") || 
+                !strcasecmp(arg, "yes"))
+            cbStates[numBoxes] = '*';
+        else
+            cbStates[numBoxes] = ' ';
+
+        if (wstrlen(cbInfo[numBoxes].tag,-1) > (unsigned int)maxWidth)
+            maxWidth = wstrlen(cbInfo[numBoxes].tag,-1);
+
+        numBoxes++;
     }
 
-       
+        
     form = newtForm(NULL, NULL, 0);
 
     tb = textbox(height - 3 - buttonHeight - listHeight, width - 2,
-                       text, flags, &top);
+                        text, flags, &top);
 
     if (listHeight < numBoxes) { 
-       sb = newtVerticalScrollbar(width - 4, 
-                                  top + 1,
-                                  listHeight, NEWT_COLORSET_CHECKBOX,
-                                  NEWT_COLORSET_ACTCHECKBOX);
-       newtFormAddComponent(form, sb);
+        sb = newtVerticalScrollbar(width - 4, 
+                                   top + 1,
+                                   listHeight, NEWT_COLORSET_CHECKBOX,
+                                   NEWT_COLORSET_ACTCHECKBOX);
+        newtFormAddComponent(form, sb);
     }
     subform = newtForm(sb, NULL, 0);
     newtFormSetBackground(subform, NEWT_COLORSET_CHECKBOX);
 
     snprintf(format, MAXFORMAT, "%%-%ds  %%s", maxWidth);
     for (i = 0; i < numBoxes; i++) {
-       snprintf(buf, MAXBUF, format, cbInfo[i].tag, cbInfo[i].text);
+        snprintf(buf, MAXBUF, format, cbInfo[i].tag, cbInfo[i].text);
 
-       if (useRadio)
-           cbInfo[i].comp = newtRadiobutton(4, top + 1 + i, buf,
-                                       cbStates[i] != ' ', 
-                                       i ? cbInfo[i - 1].comp : NULL);
-       else
-           cbInfo[i].comp = newtCheckbox(4, top + 1 + i, buf,
-                             cbStates[i], NULL, cbStates + i);
+        if (useRadio)
+            cbInfo[i].comp = newtRadiobutton(4, top + 1 + i, buf,
+                                        cbStates[i] != ' ', 
+                                        i ? cbInfo[i - 1].comp : NULL);
+        else
+            cbInfo[i].comp = newtCheckbox(4, top + 1 + i, buf,
+                              cbStates[i], NULL, cbStates + i);
 
-       newtFormAddComponent(subform, cbInfo[i].comp);
+        newtFormAddComponent(subform, cbInfo[i].comp);
     }
 
     newtFormSetHeight(subform, listHeight);
@@ -347,34 +347,34 @@ int checkList(const char * text, int height, int width, poptContext optCon,
 
     answer = newtRunForm(form);
     if (answer == cancel)
-       rc = DLG_CANCEL;
+        rc = DLG_CANCEL;
 
     if (useRadio) {
-       answer = newtRadioGetCurrent(cbInfo[0].comp);
-       for (i = 0; i < numBoxes; i++) 
-           if (cbInfo[i].comp == answer) {
-               *selections = malloc(sizeof(char *) * 2);
-               if (*selections == NULL) return DLG_ERROR;
-               (*selections)[0] = cbInfo[i].tag;
-               (*selections)[1] = NULL;
-               break;
-           }
+        answer = newtRadioGetCurrent(cbInfo[0].comp);
+        for (i = 0; i < numBoxes; i++) 
+            if (cbInfo[i].comp == answer) {
+                *selections = malloc(sizeof(char *) * 2);
+                if (*selections == NULL) return DLG_ERROR;
+                (*selections)[0] = cbInfo[i].tag;
+                (*selections)[1] = NULL;
+                break;
+            }
     } else {
-       numSelected = 0;
-       for (i = 0; i < numBoxes; i++) {
-           if (cbStates[i] != ' ') numSelected++;
-       }
+        numSelected = 0;
+        for (i = 0; i < numBoxes; i++) {
+            if (cbStates[i] != ' ') numSelected++;
+        }
 
-       *selections = malloc(sizeof(char *) * (numSelected + 1));
-       if (*selections == NULL) return DLG_ERROR;
+        *selections = malloc(sizeof(char *) * (numSelected + 1));
+        if (*selections == NULL) return DLG_ERROR;
 
-       numSelected = 0;
-       for (i = 0; i < numBoxes; i++) {
-           if (cbStates[i] != ' ') 
-               (*selections)[numSelected++] = cbInfo[i].tag;
-       }
+        numSelected = 0;
+        for (i = 0; i < numBoxes; i++) {
+            if (cbStates[i] != ' ') 
+                (*selections)[numSelected++] = cbInfo[i].tag;
+        }
 
-       (*selections)[numSelected] = NULL;
+        (*selections)[numSelected] = NULL;
     }
 
     return rc;
@@ -388,41 +388,41 @@ int messageBox(const char * text, int height, int width, int type, int flags) {
     form = newtForm(NULL, NULL, 0);
 
     tb = newtTextbox(1, 1, width - 2, height - 3 - buttonHeight, 
-                       NEWT_FLAG_WRAP | tFlag);
+                        NEWT_FLAG_WRAP | tFlag);
     newtTextboxSetText(tb, text);
 
     newtFormAddComponent(form, tb);
 
     switch ( type ) {
     case MSGBOX_INFO:
-       break;
+        break;
     case MSGBOX_MSG:
-       yes = makeButton((width - 8) / 2, height - 1 - buttonHeight, "Ok");
-       newtFormAddComponent(form, yes);
-       break;
+        yes = makeButton((width - 8) / 2, height - 1 - buttonHeight, "Ok");
+        newtFormAddComponent(form, yes);
+        break;
     default:
-       yes = makeButton((width - 16) / 3, height - 1 - buttonHeight, "Yes");
-       no = makeButton(((width - 16) / 3) * 2 + 9, height - 1 - buttonHeight, 
-                       "No");
-       newtFormAddComponents(form, yes, no, NULL);
+        yes = makeButton((width - 16) / 3, height - 1 - buttonHeight, "Yes");
+        no = makeButton(((width - 16) / 3) * 2 + 9, height - 1 - buttonHeight, 
+                        "No");
+        newtFormAddComponents(form, yes, no, NULL);
 
-       if (flags & FLAG_DEFAULT_NO)
-           newtFormSetCurrent(form, no);
+        if (flags & FLAG_DEFAULT_NO)
+            newtFormSetCurrent(form, no);
     }
 
     if ( type != MSGBOX_INFO ) {
-       newtRunForm(form);
+        newtRunForm(form);
 
-       answer = newtFormGetCurrent(form);
+        answer = newtFormGetCurrent(form);
 
-       if (answer == no)
-           return DLG_CANCEL;
+        if (answer == no)
+            return DLG_CANCEL;
     }
     else {
-       newtDrawForm(form);
-       newtRefresh();
+        newtDrawForm(form);
+        newtRefresh();
     }
-       
+        
 
 
     return DLG_OKAY;
@@ -430,10 +430,10 @@ int messageBox(const char * text, int height, int width, int type, int flags) {
 
 void useFullButtons(int state) {
     if (state) {
-       buttonHeight = 3;
-       makeButton = newtButton;
+        buttonHeight = 3;
+        makeButton = newtButton;
    } else {
-       buttonHeight = 1;
-       makeButton = newtCompactButton;
+        buttonHeight = 1;
+        makeButton = newtCompactButton;
    }
 }
index 27f072c301d25e7099ca435f4cf4b29060e0e292..d480bf527e7739bbcab5d7d640fe8e2552312f63 100644 (file)
@@ -7,25 +7,25 @@
 #define MSGBOX_YESNO 1
 #define MSGBOX_INFO 2
 
-#define FLAG_NOITEM            (1 << 0)
-#define FLAG_NOCANCEL          (1 << 1)
-#define FLAG_SCROLL_TEXT       (1 << 2)
-#define FLAG_DEFAULT_NO        (1 << 3)
-#define FLAG_NOTAGS            (1 << 5)
+#define FLAG_NOITEM             (1 << 0)
+#define FLAG_NOCANCEL           (1 << 1)
+#define FLAG_SCROLL_TEXT        (1 << 2)
+#define FLAG_DEFAULT_NO         (1 << 3)
+#define FLAG_NOTAGS             (1 << 5)
 
-#define DLG_ERROR              -1
-#define DLG_OKAY               0
-#define DLG_CANCEL             1
+#define DLG_ERROR               -1
+#define DLG_OKAY                0
+#define DLG_CANCEL              1
 
 int messageBox(const char * text, int height, int width, int type, int flags);
 int checkList(const char * text, int height, int width, poptContext optCon,
-               int useRadio, int flags, const char *** selections);
+                int useRadio, int flags, const char *** selections);
 int listBox(const char * text, int height, int width, poptContext optCon,
-               int flags, const char ** result);
+                int flags, const char ** result);
 int inputBox(const char * text, int height, int width, poptContext optCon, 
-               int flags, const char ** result);
+                int flags, const char ** result);
 int gauge(const char * text, int height, int width, poptContext optCon, int fd, 
-               int flags);
+                int flags);
 void useFullButtons(int state);
 
 #endif
index 7001e96c86815b1fb5baa51b126796c328083af2..d142419ae98cef6af775851bfec9c3cac1b21671 100644 (file)
--- a/eawidth.c
+++ b/eawidth.c
@@ -23,128 +23,128 @@ typedef struct {
 
 static const eaw_db_type eaw_db[] = {
   { 0x0020,0x007E,narrow },
-  { 0x00A1,0x00A1,ambiguous }, /*INVERTED EXCLAMATION MARK*/
+  { 0x00A1,0x00A1,ambiguous },  /*INVERTED EXCLAMATION MARK*/
   { 0x00A2,0x00A3,narrow },
-  { 0x00A4,0x00A4,ambiguous }, /*CURRENCY SIGN*/
+  { 0x00A4,0x00A4,ambiguous },  /*CURRENCY SIGN*/
   { 0x00A5,0x00A6,narrow },
   { 0x00A7,0x00A8,ambiguous },
-  { 0x00AA,0x00AA,ambiguous }, /*FEMININE ORDINAL INDICATOR*/
-  { 0x00AC,0x00AC,narrow },    /*NOT SIGN*/
-  { 0x00AD,0x00AD,ambiguous }, /*SOFT HYPHEN*/
-  { 0x00AF,0x00AF,narrow },    /*MACRON*/
+  { 0x00AA,0x00AA,ambiguous },  /*FEMININE ORDINAL INDICATOR*/
+  { 0x00AC,0x00AC,narrow },     /*NOT SIGN*/
+  { 0x00AD,0x00AD,ambiguous },  /*SOFT HYPHEN*/
+  { 0x00AF,0x00AF,narrow },     /*MACRON*/
   { 0x00B0,0x00B4,ambiguous },
   { 0x00B6,0x00BA,ambiguous },
   { 0x00BC,0x00BF,ambiguous },
-  { 0x00C6,0x00C6,ambiguous }, /*LATIN CAPITAL LETTER AE*/
-  { 0x00D0,0x00D0,ambiguous }, /*LATIN CAPITAL LETTER ETH*/
+  { 0x00C6,0x00C6,ambiguous },  /*LATIN CAPITAL LETTER AE*/
+  { 0x00D0,0x00D0,ambiguous },  /*LATIN CAPITAL LETTER ETH*/
   { 0x00D7,0x00D8,ambiguous },
   { 0x00DE,0x00E1,ambiguous },
-  { 0x00E6,0x00E6,ambiguous }, /*LATIN SMALL LETTER AE*/
+  { 0x00E6,0x00E6,ambiguous },  /*LATIN SMALL LETTER AE*/
   { 0x00E8,0x00EA,ambiguous },
   { 0x00EC,0x00ED,ambiguous },
-  { 0x00F0,0x00F0,ambiguous }, /*LATIN SMALL LETTER ETH*/
+  { 0x00F0,0x00F0,ambiguous },  /*LATIN SMALL LETTER ETH*/
   { 0x00F2,0x00F3,ambiguous },
   { 0x00F7,0x00FA,ambiguous },
-  { 0x00FC,0x00FC,ambiguous }, /*LATIN SMALL LETTER U WITH DIAERESIS*/
-  { 0x00FE,0x00FE,ambiguous }, /*LATIN SMALL LETTER THORN*/
-  { 0x0101,0x0101,ambiguous }, /*LATIN SMALL LETTER A WITH MACRON*/
-  { 0x0111,0x0111,ambiguous }, /*LATIN SMALL LETTER D WITH STROKE*/
-  { 0x0113,0x0113,ambiguous }, /*LATIN SMALL LETTER E WITH MACRON*/
-  { 0x011B,0x011B,ambiguous }, /*LATIN SMALL LETTER E WITH CARON*/
+  { 0x00FC,0x00FC,ambiguous },  /*LATIN SMALL LETTER U WITH DIAERESIS*/
+  { 0x00FE,0x00FE,ambiguous },  /*LATIN SMALL LETTER THORN*/
+  { 0x0101,0x0101,ambiguous },  /*LATIN SMALL LETTER A WITH MACRON*/
+  { 0x0111,0x0111,ambiguous },  /*LATIN SMALL LETTER D WITH STROKE*/
+  { 0x0113,0x0113,ambiguous },  /*LATIN SMALL LETTER E WITH MACRON*/
+  { 0x011B,0x011B,ambiguous },  /*LATIN SMALL LETTER E WITH CARON*/
   { 0x0126,0x0127,ambiguous },
-  { 0x012B,0x012B,ambiguous }, /*LATIN SMALL LETTER I WITH MACRON*/
+  { 0x012B,0x012B,ambiguous },  /*LATIN SMALL LETTER I WITH MACRON*/
   { 0x0131,0x0133,ambiguous },
-  { 0x0138,0x0138,ambiguous }, /*LATIN SMALL LETTER KRA*/
+  { 0x0138,0x0138,ambiguous },  /*LATIN SMALL LETTER KRA*/
   { 0x013F,0x0142,ambiguous },
-  { 0x0144,0x0144,ambiguous }, /*LATIN SMALL LETTER N WITH ACUTE*/
+  { 0x0144,0x0144,ambiguous },  /*LATIN SMALL LETTER N WITH ACUTE*/
   { 0x0148,0x014A,ambiguous },
-  { 0x014D,0x014D,ambiguous }, /*LATIN SMALL LETTER O WITH MACRON*/
+  { 0x014D,0x014D,ambiguous },  /*LATIN SMALL LETTER O WITH MACRON*/
   { 0x0152,0x0153,ambiguous },
   { 0x0166,0x0167,ambiguous },
-  { 0x016B,0x016B,ambiguous }, /*LATIN SMALL LETTER U WITH MACRON*/
-  { 0x01CE,0x01CE,ambiguous }, /*LATIN SMALL LETTER A WITH CARON*/
-  { 0x01D0,0x01D0,ambiguous }, /*LATIN SMALL LETTER I WITH CARON*/
-  { 0x01D2,0x01D2,ambiguous }, /*LATIN SMALL LETTER O WITH CARON*/
-  { 0x01D4,0x01D4,ambiguous }, /*LATIN SMALL LETTER U WITH CARON*/
-  { 0x01D6,0x01D6,ambiguous }, /*LATIN SMALL LETTER U W/DIAERESIS+MACRON*/
-  { 0x01D8,0x01D8,ambiguous }, /*LATIN SMALL LETTER U W/DIAERESIS+ACUTE*/
-  { 0x01DA,0x01DA,ambiguous }, /*LATIN SMALL LETTER U W/DIAERESIS+CARON*/
-  { 0x01DC,0x01DC,ambiguous }, /*LATIN SMALL LETTER U W/DIAERESIS+GRAVE*/
-  { 0x0251,0x0251,ambiguous }, /*LATIN SMALL LETTER ALPHA*/
-  { 0x0261,0x0261,ambiguous }, /*LATIN SMALL LETTER SCRIPT G*/
-  { 0x02C7,0x02C7,ambiguous }, /*CARON*/
+  { 0x016B,0x016B,ambiguous },  /*LATIN SMALL LETTER U WITH MACRON*/
+  { 0x01CE,0x01CE,ambiguous },  /*LATIN SMALL LETTER A WITH CARON*/
+  { 0x01D0,0x01D0,ambiguous },  /*LATIN SMALL LETTER I WITH CARON*/
+  { 0x01D2,0x01D2,ambiguous },  /*LATIN SMALL LETTER O WITH CARON*/
+  { 0x01D4,0x01D4,ambiguous },  /*LATIN SMALL LETTER U WITH CARON*/
+  { 0x01D6,0x01D6,ambiguous },  /*LATIN SMALL LETTER U W/DIAERESIS+MACRON*/
+  { 0x01D8,0x01D8,ambiguous },  /*LATIN SMALL LETTER U W/DIAERESIS+ACUTE*/
+  { 0x01DA,0x01DA,ambiguous },  /*LATIN SMALL LETTER U W/DIAERESIS+CARON*/
+  { 0x01DC,0x01DC,ambiguous },  /*LATIN SMALL LETTER U W/DIAERESIS+GRAVE*/
+  { 0x0251,0x0251,ambiguous },  /*LATIN SMALL LETTER ALPHA*/
+  { 0x0261,0x0261,ambiguous },  /*LATIN SMALL LETTER SCRIPT G*/
+  { 0x02C7,0x02C7,ambiguous },  /*CARON*/
   { 0x02C9,0x02CB,ambiguous },
-  { 0x02CD,0x02CD,ambiguous }, /*MODIFIER LETTER LOW MACRON*/
-  { 0x02D0,0x02D0,ambiguous }, /*MODIFIER LETTER TRIANGULAR COLON*/
+  { 0x02CD,0x02CD,ambiguous },  /*MODIFIER LETTER LOW MACRON*/
+  { 0x02D0,0x02D0,ambiguous },  /*MODIFIER LETTER TRIANGULAR COLON*/
   { 0x02D8,0x02DB,ambiguous },
-  { 0x02DD,0x02DD,ambiguous }, /*DOUBLE ACUTE ACCENT*/
+  { 0x02DD,0x02DD,ambiguous },  /*DOUBLE ACUTE ACCENT*/
   { 0x0300,0x0362,ambiguous },
   { 0x0391,0x03A9,ambiguous },
   { 0x03B1,0x03C1,ambiguous },
   { 0x03C3,0x03C9,ambiguous },
-  { 0x0401,0x0401,ambiguous }, /*CYRILLIC CAPITAL LETTER IO*/
+  { 0x0401,0x0401,ambiguous },  /*CYRILLIC CAPITAL LETTER IO*/
   { 0x0410,0x044F,ambiguous },
-  { 0x0451,0x0451,ambiguous }, /*CYRILLIC SMALL LETTER IO*/
+  { 0x0451,0x0451,ambiguous },  /*CYRILLIC SMALL LETTER IO*/
   { 0x1100,0x115F,wide },
-  { 0x2010,0x2010,ambiguous }, /*HYPHEN*/
+  { 0x2010,0x2010,ambiguous },  /*HYPHEN*/
   { 0x2013,0x2016,ambiguous },
   { 0x2018,0x2019,ambiguous },
   { 0x201C,0x201D,ambiguous },
   { 0x2020,0x2021,ambiguous },
   { 0x2025,0x2027,ambiguous },
-  { 0x2030,0x2030,ambiguous }, /*PER MILLE SIGN*/
+  { 0x2030,0x2030,ambiguous },  /*PER MILLE SIGN*/
   { 0x2032,0x2033,ambiguous },
-  { 0x2035,0x2035,ambiguous }, /*REVERSED PRIME*/
-  { 0x203B,0x203B,ambiguous }, /*REFERENCE MARK*/
-  { 0x2074,0x2074,ambiguous }, /*SUPERSCRIPT FOUR*/
-  { 0x207F,0x207F,ambiguous }, /*SUPERSCRIPT LATIN SMALL LETTER N*/
+  { 0x2035,0x2035,ambiguous },  /*REVERSED PRIME*/
+  { 0x203B,0x203B,ambiguous },  /*REFERENCE MARK*/
+  { 0x2074,0x2074,ambiguous },  /*SUPERSCRIPT FOUR*/
+  { 0x207F,0x207F,ambiguous },  /*SUPERSCRIPT LATIN SMALL LETTER N*/
   { 0x2081,0x2084,ambiguous },
-  { 0x20A9,0x20A9,half_width },        /*WON SIGN*/
-  { 0x20AC,0x20AC,ambiguous }, /*EURO SIGN*/
-  { 0x2103,0x2103,ambiguous }, /*DEGREE CELSIUS*/
-  { 0x2105,0x2105,ambiguous }, /*CARE OF*/
-  { 0x2109,0x2109,ambiguous }, /*DEGREE FAHRENHEIT*/
-  { 0x2113,0x2113,ambiguous }, /*SCRIPT SMALL L*/
+  { 0x20A9,0x20A9,half_width }, /*WON SIGN*/
+  { 0x20AC,0x20AC,ambiguous },  /*EURO SIGN*/
+  { 0x2103,0x2103,ambiguous },  /*DEGREE CELSIUS*/
+  { 0x2105,0x2105,ambiguous },  /*CARE OF*/
+  { 0x2109,0x2109,ambiguous },  /*DEGREE FAHRENHEIT*/
+  { 0x2113,0x2113,ambiguous },  /*SCRIPT SMALL L*/
   { 0x2121,0x2122,ambiguous },
-  { 0x2126,0x2126,ambiguous }, /*OHM SIGN*/
-  { 0x212B,0x212B,ambiguous }, /*ANGSTROM SIGN*/
+  { 0x2126,0x2126,ambiguous },  /*OHM SIGN*/
+  { 0x212B,0x212B,ambiguous },  /*ANGSTROM SIGN*/
   { 0x2154,0x2155,ambiguous },
-  { 0x215B,0x215B,ambiguous }, /*VULGAR FRACTION ONE EIGHTH*/
-  { 0x215E,0x215E,ambiguous }, /*VULGAR FRACTION SEVEN EIGHTHS*/
+  { 0x215B,0x215B,ambiguous },  /*VULGAR FRACTION ONE EIGHTH*/
+  { 0x215E,0x215E,ambiguous },  /*VULGAR FRACTION SEVEN EIGHTHS*/
   { 0x2160,0x216B,ambiguous },
   { 0x2170,0x2179,ambiguous },
   { 0x2190,0x2199,ambiguous },
-  { 0x21D2,0x21D2,ambiguous }, /*RIGHTWARDS DOUBLE ARROW*/
-  { 0x21D4,0x21D4,ambiguous }, /*LEFT RIGHT DOUBLE ARROW*/
-  { 0x2200,0x2200,ambiguous }, /*FOR ALL*/
+  { 0x21D2,0x21D2,ambiguous },  /*RIGHTWARDS DOUBLE ARROW*/
+  { 0x21D4,0x21D4,ambiguous },  /*LEFT RIGHT DOUBLE ARROW*/
+  { 0x2200,0x2200,ambiguous },  /*FOR ALL*/
   { 0x2202,0x2203,ambiguous },
   { 0x2207,0x2208,ambiguous },
-  { 0x220B,0x220B,ambiguous }, /*CONTAINS AS MEMBER*/
-  { 0x220F,0x220F,ambiguous }, /*N-ARY PRODUCT*/
-  { 0x2211,0x2211,ambiguous }, /*N-ARY SUMMATION*/
-  { 0x2215,0x2215,ambiguous }, /*DIVISION SLASH*/
-  { 0x221A,0x221A,ambiguous }, /*SQUARE ROOT*/
+  { 0x220B,0x220B,ambiguous },  /*CONTAINS AS MEMBER*/
+  { 0x220F,0x220F,ambiguous },  /*N-ARY PRODUCT*/
+  { 0x2211,0x2211,ambiguous },  /*N-ARY SUMMATION*/
+  { 0x2215,0x2215,ambiguous },  /*DIVISION SLASH*/
+  { 0x221A,0x221A,ambiguous },  /*SQUARE ROOT*/
   { 0x221D,0x2220,ambiguous },
-  { 0x2223,0x2223,ambiguous }, /*DIVIDES*/
-  { 0x2225,0x2225,ambiguous }, /*PARALLEL TO*/
+  { 0x2223,0x2223,ambiguous },  /*DIVIDES*/
+  { 0x2225,0x2225,ambiguous },  /*PARALLEL TO*/
   { 0x2227,0x222C,ambiguous },
-  { 0x222E,0x222E,ambiguous }, /*CONTOUR INTEGRAL*/
+  { 0x222E,0x222E,ambiguous },  /*CONTOUR INTEGRAL*/
   { 0x2234,0x2237,ambiguous },
   { 0x223C,0x223D,ambiguous },
-  { 0x2248,0x2248,ambiguous }, /*ALMOST EQUAL TO*/
-  { 0x224C,0x224C,ambiguous }, /*ALL EQUAL TO*/
-  { 0x2252,0x2252,ambiguous }, /*APPROXIMATELY EQUAL TO OR THE IMAGE OF*/
+  { 0x2248,0x2248,ambiguous },  /*ALMOST EQUAL TO*/
+  { 0x224C,0x224C,ambiguous },  /*ALL EQUAL TO*/
+  { 0x2252,0x2252,ambiguous },  /*APPROXIMATELY EQUAL TO OR THE IMAGE OF*/
   { 0x2260,0x2261,ambiguous },
   { 0x2264,0x2267,ambiguous },
   { 0x226A,0x226B,ambiguous },
   { 0x226E,0x226F,ambiguous },
   { 0x2282,0x2283,ambiguous },
   { 0x2286,0x2287,ambiguous },
-  { 0x2295,0x2295,ambiguous }, /*CIRCLED PLUS*/
-  { 0x2299,0x2299,ambiguous }, /*CIRCLED DOT OPERATOR*/
-  { 0x22A5,0x22A5,ambiguous }, /*UP TACK*/
-  { 0x22BF,0x22BF,ambiguous }, /*RIGHT TRIANGLE*/
-  { 0x2312,0x2312,ambiguous }, /*ARC*/
+  { 0x2295,0x2295,ambiguous },  /*CIRCLED PLUS*/
+  { 0x2299,0x2299,ambiguous },  /*CIRCLED DOT OPERATOR*/
+  { 0x22A5,0x22A5,ambiguous },  /*UP TACK*/
+  { 0x22BF,0x22BF,ambiguous },  /*RIGHT TRIANGLE*/
+  { 0x2312,0x2312,ambiguous },  /*ARC*/
   { 0x2460,0x24BF,ambiguous },
   { 0x24D0,0x24E9,ambiguous },
   { 0x2500,0x254B,ambiguous },
@@ -157,22 +157,22 @@ static const eaw_db_type eaw_db[] = {
   { 0x25BC,0x25BD,ambiguous },
   { 0x25C0,0x25C1,ambiguous },
   { 0x25C6,0x25C8,ambiguous },
-  { 0x25CB,0x25CB,ambiguous }, /*WHITE CIRCLE*/
+  { 0x25CB,0x25CB,ambiguous },  /*WHITE CIRCLE*/
   { 0x25CE,0x25D1,ambiguous },
   { 0x25E2,0x25E5,ambiguous },
-  { 0x25EF,0x25EF,ambiguous }, /*LARGE CIRCLE*/
+  { 0x25EF,0x25EF,ambiguous },  /*LARGE CIRCLE*/
   { 0x2605,0x2606,ambiguous },
-  { 0x2609,0x2609,ambiguous }, /*SUN*/
+  { 0x2609,0x2609,ambiguous },  /*SUN*/
   { 0x260E,0x260F,ambiguous },
-  { 0x261C,0x261C,ambiguous }, /*WHITE LEFT POINTING INDEX*/
-  { 0x261E,0x261E,ambiguous }, /*WHITE RIGHT POINTING INDEX*/
-  { 0x2640,0x2640,ambiguous }, /*FEMALE SIGN*/
-  { 0x2642,0x2642,ambiguous }, /*MALE SIGN*/
+  { 0x261C,0x261C,ambiguous },  /*WHITE LEFT POINTING INDEX*/
+  { 0x261E,0x261E,ambiguous },  /*WHITE RIGHT POINTING INDEX*/
+  { 0x2640,0x2640,ambiguous },  /*FEMALE SIGN*/
+  { 0x2642,0x2642,ambiguous },  /*MALE SIGN*/
   { 0x2660,0x2661,ambiguous },
   { 0x2663,0x2665,ambiguous },
   { 0x2667,0x266A,ambiguous },
   { 0x266C,0x266D,ambiguous },
-  { 0x266F,0x266F,ambiguous }, /*MUSIC SHARP SIGN*/
+  { 0x266F,0x266F,ambiguous },  /*MUSIC SHARP SIGN*/
   { 0x2E80,0x3009,wide },
   { 0x300A,0x300B,ambiguous },
   { 0x300C,0x3019,wide },
@@ -239,81 +239,81 @@ get_east_asia_type (wchar_t unicode) {
 int
 east_asia_mblen (const char *locale_name, const char *s, size_t n, int x)
 {
-       wchar_t *wcs, *p;
-       int width = 0;
+        wchar_t *wcs, *p;
+        int width = 0;
 
-       if (NULL == s) s = "";
+        if (NULL == s) s = "";
 
-       /*
-        *  Getting the locale name via setlocale() is expensive, so we prefer
-        *  to have it passed to us.
-        */
-       if (NULL == locale_name) {
-               locale_name = setlocale(LC_CTYPE, NULL);
-               if (NULL == locale_name) return INT_MAX;
-       }
+        /*
+         *  Getting the locale name via setlocale() is expensive, so we prefer
+         *  to have it passed to us.
+         */
+        if (NULL == locale_name) {
+                locale_name = setlocale(LC_CTYPE, NULL);
+                if (NULL == locale_name) return INT_MAX;
+        }
 
-       wcs = (wchar_t *) calloc(n, sizeof(wchar_t));
-       if (NULL == wcs) return INT_MAX;
+        wcs = (wchar_t *) calloc(n, sizeof(wchar_t));
+        if (NULL == wcs) return INT_MAX;
 
 #if defined __GLIBC__ && !__GLIBC_PREREQ(2,2)
 #warning wide character support is broken. Glibc 2.2 or better needed.
 #endif
 
-       if ((size_t) -1 == mbstowcs(wcs, s, n)) return INT_MAX;
-
-       switch (get_east_asia_type(*wcs)) {
-               case neutral:
-
-                       /*
-                        *  Put characters that print nothing here.
-                        *
-                        *  XXX: Yes, I know there are a lot more than this in ISO-10646, but
-                        *  this function is intended to calculate the width of strings for
-                        *  fixed width terminals displaying legacy CJK character sets.
-                        *  State-of-the-art Unicode handling terminals probably won't need
-                        *  this function anyway.
-                        */
-                       if (0x0000 == *wcs) break; /* NULL */
-                       if (0x0007 == *wcs) break; /* BELL */
-                       
-                       /*  FIXME: there will probably be ASCII chars after the escape
-                        *  code, which will be counted as part of the width even though they
-                        *  aren't displayed.
-                        */
-                       if (0x001B == *wcs) break; /* ESC */
-                       if (0xFEFF == *wcs) break; /* ZWNBSP aka BOM (magic, signature) */
-                       
-                       /*
-                        *  Special characters go here
-                        */
-                       if (0x0008 == *wcs) { /* BACKSPACE */
-                               width = -1;
-                               break;
-                       }
-                       if (0x0009 == *wcs) { /* TAB */
-                               if (tab_width < 0) width = x % abs(tab_width);
-                               else width = tab_width;
-                               break;
-                       }
-                       
-                       /*FALLTHRU*/
-               case narrow:
-               case half_width:
-                       width = 1;
-                       break;
-               case wide:
-               case full_width:
-                       width = 2;
-                       break;
-               case ambiguous:
-                       width = is_cjk_locale(locale_name) ? 2 : 1;
-                       break;
-               default:
-                       width = INT_MAX;
+        if ((size_t) -1 == mbstowcs(wcs, s, n)) return INT_MAX;
+
+        switch (get_east_asia_type(*wcs)) {
+                case neutral:
+
+                        /*
+                         *  Put characters that print nothing here.
+                         *
+                         *  XXX: Yes, I know there are a lot more than this in ISO-10646, but
+                         *  this function is intended to calculate the width of strings for
+                         *  fixed width terminals displaying legacy CJK character sets.
+                         *  State-of-the-art Unicode handling terminals probably won't need
+                         *  this function anyway.
+                         */
+                        if (0x0000 == *wcs) break; /* NULL */
+                        if (0x0007 == *wcs) break; /* BELL */
+                        
+                        /*  FIXME: there will probably be ASCII chars after the escape
+                         *  code, which will be counted as part of the width even though they
+                         *  aren't displayed.
+                         */
+                        if (0x001B == *wcs) break; /* ESC */
+                        if (0xFEFF == *wcs) break; /* ZWNBSP aka BOM (magic, signature) */
+                        
+                        /*
+                         *  Special characters go here
+                         */
+                        if (0x0008 == *wcs) { /* BACKSPACE */
+                                width = -1;
+                                break;
+                        }
+                        if (0x0009 == *wcs) { /* TAB */
+                                if (tab_width < 0) width = x % abs(tab_width);
+                                else width = tab_width;
+                                break;
+                        }
+                        
+                        /*FALLTHRU*/
+                case narrow:
+                case half_width:
+                        width = 1;
+                        break;
+                case wide:
+                case full_width:
+                        width = 2;
+                        break;
+                case ambiguous:
+                        width = is_cjk_locale(locale_name) ? 2 : 1;
+                        break;
+                default:
+                        width = INT_MAX;
     }
-       free(wcs);
-       return width;
+        free(wcs);
+        return width;
 }
 
 int
diff --git a/entry.c b/entry.c
index 2b289549b749759be5efb8dc5c9664bfeecc66bc..8281b1b371450dec3a24650a43b1c4114c025c83 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -17,9 +17,9 @@ struct entry {
     char * buf;
     const char ** resultPtr;
     int bufAlloced;
-    int bufUsed;               /* amount of the buffer that's been used */
-    int cursorPosition;        /* cursor *in the string* on on screen */
-    int firstChar;             /* first character position being shown */
+    int bufUsed;                /* amount of the buffer that's been used */
+    int cursorPosition;         /* cursor *in the string* on on screen */
+    int firstChar;              /* first character position being shown */
     newtEntryFilter filter;
     void * filterData;
 };
@@ -27,7 +27,7 @@ struct entry {
 static void entryDraw(newtComponent co);
 static void entryDestroy(newtComponent co);
 static struct eventResult entryEvent(newtComponent co,
-                                    struct event ev);
+                                     struct event ev);
 
 static struct eventResult entryHandleKey(newtComponent co, int key);
 
@@ -43,25 +43,25 @@ void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd) {
     struct entry * en = co->data;
 
     if ((strlen(value) + 1) > (unsigned int)en->bufAlloced) {
-       free(en->buf);
-       en->bufAlloced = strlen(value) + 1;
-       en->buf = malloc(en->bufAlloced);
-       if (en->resultPtr) *en->resultPtr = en->buf;
+        free(en->buf);
+        en->bufAlloced = strlen(value) + 1;
+        en->buf = malloc(en->bufAlloced);
+        if (en->resultPtr) *en->resultPtr = en->buf;
     }
-    memset(en->buf, 0, en->bufAlloced);                /* clear the buffer */
+    memset(en->buf, 0, en->bufAlloced);         /* clear the buffer */
     strcpy(en->buf, value);
     en->bufUsed = strlen(value);
     en->firstChar = 0;
     if (cursorAtEnd)
-       en->cursorPosition = en->bufUsed;
+        en->cursorPosition = en->bufUsed;
     else
-       en->cursorPosition = 0;
+        en->cursorPosition = 0;
 
     entryDraw(co);
 } ;
 
 newtComponent newtEntry(int left, int top, const char * initialValue, int width,
-                       const char ** resultPtr, int flags) {
+                        const char ** resultPtr, int flags) {
     newtComponent co;
     struct entry * en;
 
@@ -86,12 +86,12 @@ newtComponent newtEntry(int left, int top, const char * initialValue, int width,
     en->filter = NULL;
 
     if (!(en->flags & NEWT_FLAG_DISABLED))
-       co->takesFocus = 1;
+        co->takesFocus = 1;
     else
-       co->takesFocus = 0;
+        co->takesFocus = 0;
 
     if (initialValue && wstrlen(initialValue,-1) > (unsigned int)width) {
-       en->bufAlloced = wstrlen(initialValue,-1) + 1;
+        en->bufAlloced = wstrlen(initialValue,-1) + 1;
     }
     en->buf = malloc(en->bufAlloced);
     en->resultPtr = resultPtr;
@@ -99,13 +99,13 @@ newtComponent newtEntry(int left, int top, const char * initialValue, int width,
 
     memset(en->buf, 0, en->bufAlloced);
     if (initialValue) {
-       strcpy(en->buf, initialValue);
-       en->bufUsed = strlen(initialValue);
-       en->cursorPosition = en->bufUsed;
+        strcpy(en->buf, initialValue);
+        en->bufUsed = strlen(initialValue);
+        en->cursorPosition = en->bufUsed;
     } else {
-       *en->buf = '\0';
-       en->bufUsed = 0;
-       en->cursorPosition = 0;
+        *en->buf = '\0';
+        en->bufUsed = 0;
+        en->cursorPosition = 0;
     }
 
     return co;
@@ -120,58 +120,58 @@ static void entryDraw(newtComponent co) {
     if (!co->isMapped) return;
 
     if (en->flags & NEWT_FLAG_DISABLED)
-       SLsmg_set_color(NEWT_COLORSET_DISENTRY);
+        SLsmg_set_color(NEWT_COLORSET_DISENTRY);
     else
-       SLsmg_set_color(NEWT_COLORSET_ENTRY);
+        SLsmg_set_color(NEWT_COLORSET_ENTRY);
 
     if (en->flags & NEWT_FLAG_HIDDEN) {
-       newtGotorc(co->top, co->left);
-       for (i = 0; i < co->width; i++)
-           SLsmg_write_char('_');
-       newtGotorc(co->top, co->left);
+        newtGotorc(co->top, co->left);
+        for (i = 0; i < co->width; i++)
+            SLsmg_write_char('_');
+        newtGotorc(co->top, co->left);
 
-       return;
+        return;
     }
 
     newtGotorc(co->top, co->left);
 
     if (en->cursorPosition < en->firstChar) {
-       /* scroll to the left */
-       en->firstChar = en->cursorPosition;
+        /* scroll to the left */
+        en->firstChar = en->cursorPosition;
     } else if ((en->firstChar + co->width) <= en->cursorPosition) {
-       /* scroll to the right */
-       en->firstChar = en->cursorPosition - co->width + 1;
+        /* scroll to the right */
+        en->firstChar = en->cursorPosition - co->width + 1;
     }
 
     chptr = en->buf + en->firstChar;
 
     if (en->flags & NEWT_FLAG_PASSWORD) {
-       char *tmpptr, *p;
+        char *tmpptr, *p;
 
-       tmpptr = alloca(strlen(chptr)+2);
-       strcpy(tmpptr, chptr);
-       for (p = tmpptr; *p; p++)
-           *p = '*';
-       chptr = tmpptr;
-    }                  
+        tmpptr = alloca(strlen(chptr)+2);
+        strcpy(tmpptr, chptr);
+        for (p = tmpptr; *p; p++)
+            *p = '*';
+        chptr = tmpptr;
+    }                   
 
     len = wstrlen(chptr, -1);
 
     if (len <= co->width) {
-       i = len;
-       SLsmg_write_string(chptr);
-       while (i < co->width) {
-           SLsmg_write_char('_');
-           i++;
-       }
+        i = len;
+        SLsmg_write_string(chptr);
+        while (i < co->width) {
+            SLsmg_write_char('_');
+            i++;
+        }
     } else {
-       SLsmg_write_nstring(chptr, co->width);
+        SLsmg_write_nstring(chptr, co->width);
     }
 
     if (en->flags & NEWT_FLAG_HIDDEN)
-       newtGotorc(co->top, co->left);
+        newtGotorc(co->top, co->left);
     else
-       newtGotorc(co->top, co->left + (en->cursorPosition - en->firstChar));
+        newtGotorc(co->top, co->left + (en->cursorPosition - en->firstChar));
 }
 
 void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense) {
@@ -181,9 +181,9 @@ void newtEntrySetFlags(newtComponent co, int flags, enum newtFlagsSense sense) {
     en->flags = newtSetFlags(en->flags, flags, sense);
 
     if (!(en->flags & NEWT_FLAG_DISABLED))
-       co->takesFocus = 1;
+        co->takesFocus = 1;
     else
-       co->takesFocus = 0;
+        co->takesFocus = 0;
 
     newtGetrc(&row, &col);
     entryDraw(co);
@@ -199,55 +199,55 @@ static void entryDestroy(newtComponent co) {
 }
 
 static struct eventResult entryEvent(newtComponent co,
-                                    struct event ev) {
+                                     struct event ev) {
     struct entry * en = co->data;
     struct eventResult er;
     int ch;
 
     if (ev.when == EV_NORMAL) {
-       switch (ev.event) {
-       case EV_FOCUS:
-           newtCursorOn();
-           if (en->flags & NEWT_FLAG_HIDDEN)
-               newtGotorc(co->top, co->left);
-           else
-               newtGotorc(co->top, co->left +
-                          (en->cursorPosition - en->firstChar));
-           er.result = ER_SWALLOWED;
-           break;
-
-       case EV_UNFOCUS:
-           newtCursorOff();
-           newtGotorc(0, 0);
-           er.result = ER_SWALLOWED;
-           if (co->callback)
-               co->callback(co, co->callbackData);
-           break;
-
-       case EV_KEYPRESS:
-           ch = ev.u.key;
-           if (en->filter)
-               ch = en->filter(co, en->filterData, ch, en->cursorPosition);
-           if (ch) er = entryHandleKey(co, ch);
-           break;
-
-       case EV_MOUSE:
-           if ((ev.u.mouse.type == MOUSE_BUTTON_DOWN) &&
-               (en->flags ^ NEWT_FLAG_HIDDEN)) {
-               if (strlen(en->buf) >= ev.u.mouse.x - co->left) {
-                   en->cursorPosition = ev.u.mouse.x - co->left;
-                   newtGotorc(co->top,
-                              co->left +(en->cursorPosition - en->firstChar));
-               } else {
-                   en->cursorPosition = strlen(en->buf);
-                   newtGotorc(co->top,
-                              co->left +(en->cursorPosition - en->firstChar));
-               }
-           }
-           break;
-       }
+        switch (ev.event) {
+        case EV_FOCUS:
+            newtCursorOn();
+            if (en->flags & NEWT_FLAG_HIDDEN)
+                newtGotorc(co->top, co->left);
+            else
+                newtGotorc(co->top, co->left +
+                           (en->cursorPosition - en->firstChar));
+            er.result = ER_SWALLOWED;
+            break;
+
+        case EV_UNFOCUS:
+            newtCursorOff();
+            newtGotorc(0, 0);
+            er.result = ER_SWALLOWED;
+            if (co->callback)
+                co->callback(co, co->callbackData);
+            break;
+
+        case EV_KEYPRESS:
+            ch = ev.u.key;
+            if (en->filter)
+                ch = en->filter(co, en->filterData, ch, en->cursorPosition);
+            if (ch) er = entryHandleKey(co, ch);
+            break;
+
+        case EV_MOUSE:
+            if ((ev.u.mouse.type == MOUSE_BUTTON_DOWN) &&
+                (en->flags ^ NEWT_FLAG_HIDDEN)) {
+                if (strlen(en->buf) >= ev.u.mouse.x - co->left) {
+                    en->cursorPosition = ev.u.mouse.x - co->left;
+                    newtGotorc(co->top,
+                               co->left +(en->cursorPosition - en->firstChar));
+                } else {
+                    en->cursorPosition = strlen(en->buf);
+                    newtGotorc(co->top,
+                               co->left +(en->cursorPosition - en->firstChar));
+                }
+            }
+            break;
+        }
     } else
-       er.result = ER_IGNORED;
+        er.result = ER_IGNORED;
 
     return er;
 }
@@ -259,109 +259,109 @@ static struct eventResult entryHandleKey(newtComponent co, int key) {
 
     er.result = ER_SWALLOWED;
     switch (key) {
-      case '\r':                               /* Return */
-       if (en->flags & NEWT_FLAG_RETURNEXIT) {
-           er.result = ER_EXITFORM;
-       } else {
-           er.result = ER_NEXTCOMP;
-       }
-       break;
-
-      case '\001':                             /* ^A */
+      case '\r':                                /* Return */
+        if (en->flags & NEWT_FLAG_RETURNEXIT) {
+            er.result = ER_EXITFORM;
+        } else {
+            er.result = ER_NEXTCOMP;
+        }
+        break;
+
+      case '\001':                              /* ^A */
       case NEWT_KEY_HOME:
-       en->cursorPosition = 0;
-       break;
+        en->cursorPosition = 0;
+        break;
 
-      case '\005':                             /* ^E */
+      case '\005':                              /* ^E */
       case NEWT_KEY_END:
-       en->cursorPosition = en->bufUsed;
-       break;
+        en->cursorPosition = en->bufUsed;
+        break;
 
-      case '\013':                             /* ^K */
-       en->bufUsed = en->cursorPosition;
-       memset(en->buf + en->bufUsed, 0, en->bufAlloced - en->bufUsed);
-       break;
+      case '\013':                              /* ^K */
+        en->bufUsed = en->cursorPosition;
+        memset(en->buf + en->bufUsed, 0, en->bufAlloced - en->bufUsed);
+        break;
 
-      case '\002':                             /* ^B */
+      case '\002':                              /* ^B */
       case NEWT_KEY_LEFT:
-       if (en->cursorPosition)
-           en->cursorPosition--;
-       break;
+        if (en->cursorPosition)
+            en->cursorPosition--;
+        break;
 
       case '\004':
       case NEWT_KEY_DELETE:
-       chptr = en->buf + en->cursorPosition;
-       if (*chptr) {
-           chptr++;
-           while (*chptr) {
-               *(chptr - 1) = *chptr;
-               chptr++;
-           }
-           *(chptr - 1) = '\0';
-           en->bufUsed--;
-       }
-       break;
+        chptr = en->buf + en->cursorPosition;
+        if (*chptr) {
+            chptr++;
+            while (*chptr) {
+                *(chptr - 1) = *chptr;
+                chptr++;
+            }
+            *(chptr - 1) = '\0';
+            en->bufUsed--;
+        }
+        break;
 
       case NEWT_KEY_BKSPC:
-       if (en->cursorPosition) {
-           /* if this isn't true, there's nothing to erase */
-           chptr = en->buf + en->cursorPosition;
-           en->bufUsed--;
-           en->cursorPosition--;
-           while (*chptr) {
-               *(chptr - 1) = *chptr;
-               chptr++;
-           }
-           *(chptr - 1) = '\0';
-       }
-       break;
-
-      case '\006':                             /* ^B */
+        if (en->cursorPosition) {
+            /* if this isn't true, there's nothing to erase */
+            chptr = en->buf + en->cursorPosition;
+            en->bufUsed--;
+            en->cursorPosition--;
+            while (*chptr) {
+                *(chptr - 1) = *chptr;
+                chptr++;
+            }
+            *(chptr - 1) = '\0';
+        }
+        break;
+
+      case '\006':                              /* ^B */
       case NEWT_KEY_RIGHT:
-       if (en->cursorPosition < en->bufUsed)
-           en->cursorPosition++;
-       break;
+        if (en->cursorPosition < en->bufUsed)
+            en->cursorPosition++;
+        break;
 
       default:
-       if ((key >= 0x20 && key <= 0x7e) || (key >= 0xa0 && key <= 0xff)) {
-           if (!(en->flags & NEWT_FLAG_SCROLL) && en->bufUsed >= co->width) {
-               SLtt_beep();
-               break;
-           }
-
-           if ((en->bufUsed + 1) == en->bufAlloced) {
-               en->bufAlloced += 20;
-               en->buf = realloc(en->buf, en->bufAlloced);
-               if (en->resultPtr) *en->resultPtr = en->buf;
-               memset(en->buf + en->bufUsed + 1, 0, 20);
-           }
-
-           if (en->cursorPosition == en->bufUsed) {
-               en->bufUsed++;
-           } else {
-               /* insert the new character */
-
-               /* chptr is the last character in the string */
-               chptr = (en->buf + en->bufUsed) - 1;
-               if ((en->bufUsed + 1) == en->bufAlloced) {
-                   /* this string fills the buffer, so clip it */
-                   chptr--;
-               } else
-                   en->bufUsed++;
-
-               insPoint = en->buf + en->cursorPosition;
-
-               while (chptr >= insPoint) {
-                   *(chptr + 1) = *chptr;
-                   chptr--;
-               }
-
-           }
-
-           en->buf[en->cursorPosition++] = key;
-       } else {
-           er.result = ER_IGNORED;
-       }
+        if ((key >= 0x20 && key <= 0x7e) || (key >= 0xa0 && key <= 0xff)) {
+            if (!(en->flags & NEWT_FLAG_SCROLL) && en->bufUsed >= co->width) {
+                SLtt_beep();
+                break;
+            }
+
+            if ((en->bufUsed + 1) == en->bufAlloced) {
+                en->bufAlloced += 20;
+                en->buf = realloc(en->buf, en->bufAlloced);
+                if (en->resultPtr) *en->resultPtr = en->buf;
+                memset(en->buf + en->bufUsed + 1, 0, 20);
+            }
+
+            if (en->cursorPosition == en->bufUsed) {
+                en->bufUsed++;
+            } else {
+                /* insert the new character */
+
+                /* chptr is the last character in the string */
+                chptr = (en->buf + en->bufUsed) - 1;
+                if ((en->bufUsed + 1) == en->bufAlloced) {
+                    /* this string fills the buffer, so clip it */
+                    chptr--;
+                } else
+                    en->bufUsed++;
+
+                insPoint = en->buf + en->cursorPosition;
+
+                while (chptr >= insPoint) {
+                    *(chptr + 1) = *chptr;
+                    chptr--;
+                }
+
+            }
+
+            en->buf[en->cursorPosition++] = key;
+        } else {
+            er.result = ER_IGNORED;
+        }
     }
 
     entryDraw(co);
diff --git a/form.c b/form.c
index 534ca29c17e4e7a18b7b65f8dab5319e6b73e709..d12a3581c0f7df2cc5dcb7e643a55f8d91edd948 100644 (file)
--- a/form.c
+++ b/form.c
@@ -372,8 +372,8 @@ static int Gpm_GetEvent(Gpm_Event *event)
 *****************************************************************************/
 
 struct element {
-    int top, left;             /* Actual, not virtual. These are translated */
-    newtComponent co;          /* into actual through vertOffset */
+    int top, left;              /* Actual, not virtual. These are translated */
+    newtComponent co;           /* into actual through vertOffset */
 };
 
 struct fdInfo {
@@ -428,7 +428,7 @@ static inline int componentFits(newtComponent co, int compNum) {
 
     if ((co->top + form->vertOffset) > el->top) return 0;
     if ((co->top + form->vertOffset + co->height) <
-           (el->top + el->co->height)) return 0;
+            (el->top + el->co->height)) return 0;
 
     return 1;
 }
@@ -446,7 +446,7 @@ newtComponent newtForm(newtComponent vertBar, void * help, int flags) {
     co->left = -1;
     co->isMapped = 0;
 
-    co->takesFocus = 0;                        /* we may have 0 components */
+    co->takesFocus = 0;                 /* we may have 0 components */
     co->ops = &formOps;
 
     form->help = help;
@@ -469,13 +469,13 @@ newtComponent newtForm(newtComponent vertBar, void * help, int flags) {
     form->timer = 0;
     form->lastTimeout.tv_sec = form->lastTimeout.tv_usec = 0;
     if (!(form->flags & NEWT_FLAG_NOF12)) {
-       newtFormAddHotKey(co, NEWT_KEY_F12);
+        newtFormAddHotKey(co, NEWT_KEY_F12);
     }
 
     if (vertBar)
-       form->vertBar = vertBar;
+        form->vertBar = vertBar;
     else
-       form->vertBar = NULL;
+        form->vertBar = NULL;
 
     form->helpTag = help;
     form->helpCb = helpCallback;
@@ -495,17 +495,17 @@ void newtFormSetCurrent(newtComponent co, newtComponent subco) {
     int i, new;
 
     for (i = 0; i < form->numComps; i++) {
-        if (form->elements[i].co == subco) break;
+         if (form->elements[i].co == subco) break;
     }
 
     if (form->elements[i].co != subco) return;
     new = i;
 
     if (co->isMapped && !componentFits(co, new)) {
-       gotoComponent(form, -1);
-       form->vertOffset = form->elements[new].top - co->top - 1;
-       if (form->vertOffset > (form->numRows - co->height))
-           form->vertOffset = form->numRows - co->height;
+        gotoComponent(form, -1);
+        form->vertOffset = form->elements[new].top - co->top - 1;
+        if (form->vertOffset > (form->numRows - co->height))
+            form->vertOffset = form->numRows - co->height;
     }
 
     gotoComponent(form, new);
@@ -536,9 +536,9 @@ void newtFormAddComponent(newtComponent co, newtComponent newco) {
     co->takesFocus = 1;
 
     if (form->numCompsAlloced == form->numComps) {
-       form->numCompsAlloced += 5;
-       form->elements = realloc(form->elements,
-                           sizeof(*(form->elements)) * form->numCompsAlloced);
+        form->numCompsAlloced += 5;
+        form->elements = realloc(form->elements,
+                            sizeof(*(form->elements)) * form->numCompsAlloced);
     }
 
     /* we grab real values for these a bit later */
@@ -547,7 +547,7 @@ void newtFormAddComponent(newtComponent co, newtComponent newco) {
     form->elements[form->numComps].co = newco;
 
     if (newco->takesFocus && form->currComp == -1)
-       form->currComp = form->numComps;
+        form->currComp = form->numComps;
 
     form->numComps++;
 }
@@ -559,7 +559,7 @@ void newtFormAddComponents(newtComponent co, ...) {
     va_start(ap, co);
 
     while ((subco = va_arg(ap, newtComponent)))
-       newtFormAddComponent(co, subco);
+        newtFormAddComponent(co, subco);
 
     va_end(ap);
 }
@@ -578,10 +578,10 @@ static void formPlace(newtComponent co, int left, int top) {
     co->left = left;
 
     for (i = 0, el = form->elements; i < form->numComps; i++, el++) {
-       el->co->top += vertDelta;
-       el->top += vertDelta;
-       el->co->left += horizDelta;
-       el->left += horizDelta;
+        el->co->top += vertDelta;
+        el->top += vertDelta;
+        el->co->left += horizDelta;
+        el->left += horizDelta;
     }
 }
 
@@ -596,25 +596,25 @@ void newtDrawForm(newtComponent co) {
     newtClearBox(co->left, co->top, co->width, co->height);
 
     for (i = 0, el = form->elements; i < form->numComps; i++, el++) {
-       /* the scrollbar *always* fits somewhere */
-       if (el->co == form->vertBar) {
-           el->co->ops->mapped(el->co, 1);
-           el->co->ops->draw(el->co);
-       } else {
-           /* only draw it if it'll fit on the screen vertically */
-           if (componentFits(co, i)) {
-               el->co->top = el->top - form->vertOffset;
-               el->co->ops->mapped(el->co, 1);
-               el->co->ops->draw(el->co);
-           } else {
-               el->co->ops->mapped(el->co, 0);
-           }
-       }
+        /* the scrollbar *always* fits somewhere */
+        if (el->co == form->vertBar) {
+            el->co->ops->mapped(el->co, 1);
+            el->co->ops->draw(el->co);
+        } else {
+            /* only draw it if it'll fit on the screen vertically */
+            if (componentFits(co, i)) {
+                el->co->top = el->top - form->vertOffset;
+                el->co->ops->mapped(el->co, 1);
+                el->co->ops->draw(el->co);
+            } else {
+                el->co->ops->mapped(el->co, 0);
+            }
+        }
     }
 
     if (form->vertBar)
-       newtScrollbarSet(form->vertBar, form->vertOffset,
-                        form->numRows - co->height);
+        newtScrollbarSet(form->vertBar, form->vertOffset,
+                         form->numRows - co->height);
 }
 
 static struct eventResult formEvent(newtComponent co, struct event ev) {
@@ -633,153 +633,153 @@ static struct eventResult formEvent(newtComponent co, struct event ev) {
 
     switch (ev.when) {
       case EV_EARLY:
-         if (ev.event == EV_KEYPRESS) {
-           if (ev.u.key == NEWT_KEY_TAB) {
-               er.result = ER_SWALLOWED;
-               dir = 1;
-               wrap = 1;
-           } else if (ev.u.key == NEWT_KEY_UNTAB) {
-               er.result = ER_SWALLOWED;
-               dir = -1;
-               wrap = 1;
-           }
-       }
-
-       if (form->numComps) {
-           i = form->currComp;
-           num = 0;
-           while (er.result == ER_IGNORED && num != form->numComps ) {
-               er = form->elements[i].co->ops->event(form->elements[i].co, ev);
-
-               num++;
-               i++;
-               if (i == form->numComps) i = 0;
-           }
-       }
-
-       break;
+          if (ev.event == EV_KEYPRESS) {
+            if (ev.u.key == NEWT_KEY_TAB) {
+                er.result = ER_SWALLOWED;
+                dir = 1;
+                wrap = 1;
+            } else if (ev.u.key == NEWT_KEY_UNTAB) {
+                er.result = ER_SWALLOWED;
+                dir = -1;
+                wrap = 1;
+            }
+        }
+
+        if (form->numComps) {
+            i = form->currComp;
+            num = 0;
+            while (er.result == ER_IGNORED && num != form->numComps ) {
+                er = form->elements[i].co->ops->event(form->elements[i].co, ev);
+
+                num++;
+                i++;
+                if (i == form->numComps) i = 0;
+            }
+        }
+
+        break;
 
       case EV_NORMAL:
-         if (ev.event == EV_MOUSE) {
-             found = 0;
-             for (i = 0, el = form->elements; i < form->numComps; i++, el++) {
-                 if ((el->co->top <= ev.u.mouse.y) &&
-                     (el->co->top + el->co->height > ev.u.mouse.y) &&
-                     (el->co->left <= ev.u.mouse.x) &&
-                     (el->co->left + el->co->width > ev.u.mouse.x)) {
-                     found = 1;
-                     if (el->co->takesFocus) {
-                         gotoComponent(form, i);
-                         subco = form->elements[form->currComp].co;
-                     }
-                 }
-                 /* If we did not find a co to send this event to, we
-                    should just swallow the event here. */
-             }
-             if (!found) {
-                 er.result = ER_SWALLOWED;
-
-                 return er;
-             }
-         }
-       er = subco->ops->event(subco, ev);
-       switch (er.result) {
-         case ER_NEXTCOMP:
-           er.result = ER_SWALLOWED;
-           dir = 1;
-           break;
-
-         case ER_EXITFORM:
-           form->exitComp = subco;
-           break;
-
-         default:
-           break;
-       }
-       break;
+          if (ev.event == EV_MOUSE) {
+              found = 0;
+              for (i = 0, el = form->elements; i < form->numComps; i++, el++) {
+                  if ((el->co->top <= ev.u.mouse.y) &&
+                      (el->co->top + el->co->height > ev.u.mouse.y) &&
+                      (el->co->left <= ev.u.mouse.x) &&
+                      (el->co->left + el->co->width > ev.u.mouse.x)) {
+                      found = 1;
+                      if (el->co->takesFocus) {
+                          gotoComponent(form, i);
+                          subco = form->elements[form->currComp].co;
+                      }
+                  }
+                  /* If we did not find a co to send this event to, we
+                     should just swallow the event here. */
+              }
+              if (!found) {
+                  er.result = ER_SWALLOWED;
+
+                  return er;
+              }
+          }
+        er = subco->ops->event(subco, ev);
+        switch (er.result) {
+          case ER_NEXTCOMP:
+            er.result = ER_SWALLOWED;
+            dir = 1;
+            break;
+
+          case ER_EXITFORM:
+            form->exitComp = subco;
+            break;
+
+          default:
+            break;
+        }
+        break;
 
       case EV_LATE:
-       er = subco->ops->event(subco, ev);
-
-       if (er.result == ER_IGNORED) {
-           switch (ev.u.key) {
-             case NEWT_KEY_UP:
-             case NEWT_KEY_LEFT:
-             case NEWT_KEY_BKSPC:
-               er.result = ER_SWALLOWED;
-               dir = -1;
-               break;
-
-             case NEWT_KEY_DOWN:
-             case NEWT_KEY_RIGHT:
-               er.result = ER_SWALLOWED;
-               dir = 1;
-               break;
-
-            case NEWT_KEY_PGUP:
-               er.result = ER_SWALLOWED;
-               dir = -1;
-               page = 1;
-               break;
-
-            case NEWT_KEY_PGDN:
-               er.result = ER_SWALLOWED;
-               dir = 1;
-               page = 1;
-               break;
-           }
-       }
+        er = subco->ops->event(subco, ev);
+
+        if (er.result == ER_IGNORED) {
+            switch (ev.u.key) {
+              case NEWT_KEY_UP:
+              case NEWT_KEY_LEFT:
+              case NEWT_KEY_BKSPC:
+                er.result = ER_SWALLOWED;
+                dir = -1;
+                break;
+
+              case NEWT_KEY_DOWN:
+              case NEWT_KEY_RIGHT:
+                er.result = ER_SWALLOWED;
+                dir = 1;
+                break;
+
+             case NEWT_KEY_PGUP:
+                er.result = ER_SWALLOWED;
+                dir = -1;
+                page = 1;
+                break;
+
+             case NEWT_KEY_PGDN:
+                er.result = ER_SWALLOWED;
+                dir = 1;
+                page = 1;
+                break;
+            }
+        }
     }
 
     if (dir) {
-       new = form->currComp;
-
-       if (page) {
-           new += dir * co->height;
-           if (new < 0)
-               new = 0;
-           else if (new >= form->numComps)
-               new = (form->numComps - 1);
-
-           while (!form->elements[new].co->takesFocus)
-               new = new - dir;
-       } else {
-           do {
-               new += dir;
-
-               if (wrap) {
-                   if (new < 0)
-                       new = form->numComps - 1;
-                   else if (new >= form->numComps)
-                       new = 0;
-               } else if (new < 0 || new >= form->numComps)
-                   return er;
-           } while (!form->elements[new].co->takesFocus);
-       }
-
-       /* make sure this component is visible */
-       if (!componentFits(co, new)) {
-           gotoComponent(form, -1);
-
-           if (dir < 0) {
-               /* make the new component the first one */
-               form->vertOffset = form->elements[new].top - co->top;
-           } else {
-               /* make the new component the last one */
-               form->vertOffset = (form->elements[new].top +
-                                       form->elements[new].co->height) -
-                                   (co->top + co->height);
-           }
-
-           if (form->vertOffset < 0) form->vertOffset = 0;
-           if (form->vertOffset > (form->numRows - co->height))
-               form->vertOffset = form->numRows - co->height;
-
-           newtDrawForm(co);
-       }
-
-       gotoComponent(form, new);
-       er.result = ER_SWALLOWED;
+        new = form->currComp;
+
+        if (page) {
+            new += dir * co->height;
+            if (new < 0)
+                new = 0;
+            else if (new >= form->numComps)
+                new = (form->numComps - 1);
+
+            while (!form->elements[new].co->takesFocus)
+                new = new - dir;
+        } else {
+            do {
+                new += dir;
+
+                if (wrap) {
+                    if (new < 0)
+                        new = form->numComps - 1;
+                    else if (new >= form->numComps)
+                        new = 0;
+                } else if (new < 0 || new >= form->numComps)
+                    return er;
+            } while (!form->elements[new].co->takesFocus);
+        }
+
+        /* make sure this component is visible */
+        if (!componentFits(co, new)) {
+            gotoComponent(form, -1);
+
+            if (dir < 0) {
+                /* make the new component the first one */
+                form->vertOffset = form->elements[new].top - co->top;
+            } else {
+                /* make the new component the last one */
+                form->vertOffset = (form->elements[new].top +
+                                        form->elements[new].co->height) -
+                                    (co->top + co->height);
+            }
+
+            if (form->vertOffset < 0) form->vertOffset = 0;
+            if (form->vertOffset > (form->numRows - co->height))
+                form->vertOffset = form->numRows - co->height;
+
+            newtDrawForm(co);
+        }
+
+        gotoComponent(form, new);
+        er.result = ER_SWALLOWED;
     }
 
     return er;
@@ -793,13 +793,13 @@ void newtFormDestroy(newtComponent co) {
 
     /* first, destroy all of the components */
     for (i = 0; i < form->numComps; i++) {
-       subco = form->elements[i].co;
-       if (subco->ops->destroy) {
-           subco->ops->destroy(subco);
-       } else {
-           if (subco->data) free(subco->data);
-           free(subco);
-       }
+        subco = form->elements[i].co;
+        if (subco->ops->destroy) {
+            subco->ops->destroy(subco);
+        } else {
+            if (subco->data) free(subco->data);
+            free(subco);
+        }
     }
 
     if (form->hotKeys) free(form->hotKeys);
@@ -814,12 +814,12 @@ newtComponent newtRunForm(newtComponent co) {
 
     newtFormRun(co, &es);
     if (es.reason == NEWT_EXIT_HOTKEY) {
-       if (es.u.key == NEWT_KEY_F12) {
-           es.reason = NEWT_EXIT_COMPONENT;
-           es.u.co = co;
-       } else {
-           return NULL;
-       }
+        if (es.u.key == NEWT_KEY_F12) {
+            es.reason = NEWT_EXIT_COMPONENT;
+            es.u.co = co;
+        } else {
+            return NULL;
+        }
     }
 
     return es.u.co;
@@ -850,36 +850,36 @@ void newtFormSetSize(newtComponent co) {
     co->top = form->elements[0].co->top;
     co->left = form->elements[0].co->left;
     for (i = 0, el = form->elements; i < form->numComps; i++, el++) {
-       if (el->co->ops == &formOps)
-           newtFormSetSize(el->co);
-
-       el->left = el->co->left;
-       el->top = el->co->top;
-
-       if (co->left > el->co->left) {
-           delta = co->left - el->co->left;
-           co->left -= delta;
-           co->width += delta;
-       }
-
-       if (co->top > el->co->top) {
-           delta = co->top - el->co->top;
-           co->top -= delta;
-           if (!form->fixedHeight)
-               co->height += delta;
-       }
-
-       if ((co->left + co->width) < (el->co->left + el->co->width))
-           co->width = (el->co->left + el->co->width) - co->left;
-
-       if (!form->fixedHeight) {
-           if ((co->top + co->height) < (el->co->top + el->co->height))
-               co->height = (el->co->top + el->co->height) - co->top;
-       }
-
-       if ((el->co->top + el->co->height - co->top) > form->numRows) {
-           form->numRows = el->co->top + el->co->height - co->top;
-       }
+        if (el->co->ops == &formOps)
+            newtFormSetSize(el->co);
+
+        el->left = el->co->left;
+        el->top = el->co->top;
+
+        if (co->left > el->co->left) {
+            delta = co->left - el->co->left;
+            co->left -= delta;
+            co->width += delta;
+        }
+
+        if (co->top > el->co->top) {
+            delta = co->top - el->co->top;
+            co->top -= delta;
+            if (!form->fixedHeight)
+                co->height += delta;
+        }
+
+        if ((co->left + co->width) < (el->co->left + el->co->width))
+            co->width = (el->co->left + el->co->width) - co->left;
+
+        if (!form->fixedHeight) {
+            if ((co->top + co->height) < (el->co->top + el->co->height))
+                co->height = (el->co->top + el->co->height) - co->top;
+        }
+
+        if ((el->co->top + el->co->height - co->top) > form->numRows) {
+            form->numRows = el->co->top + el->co->height - co->top;
+        }
     }
 }
 
@@ -910,155 +910,155 @@ void newtFormRun(newtComponent co, struct newtExitStruct * es) {
     newtDrawForm(co);
 
     if (form->currComp == -1) {
-       gotoComponent(form, 0);
+        gotoComponent(form, 0);
     } else
-       gotoComponent(form, form->currComp);
+        gotoComponent(form, form->currComp);
 
     while (!done) {
-       newtRefresh();
+        newtRefresh();
 
-       FD_ZERO(&readSet);
-       FD_ZERO(&writeSet);
-       FD_ZERO(&exceptSet);
-       FD_SET(0, &readSet);
+        FD_ZERO(&readSet);
+        FD_ZERO(&writeSet);
+        FD_ZERO(&exceptSet);
+        FD_SET(0, &readSet);
 #ifdef USE_GPM
-       if (gpm_fd > 0) {
-           FD_SET(gpm_fd, &readSet);
-       }
-       max = form->maxFd > gpm_fd ? form->maxFd : gpm_fd;
+        if (gpm_fd > 0) {
+            FD_SET(gpm_fd, &readSet);
+        }
+        max = form->maxFd > gpm_fd ? form->maxFd : gpm_fd;
 #else
-       max = form->maxFd;
+        max = form->maxFd;
 #endif
 
-       for (i = 0; i < form->numFds; i++) {
-           if (form->fds[i].flags & NEWT_FD_READ)
-               FD_SET(form->fds[i].fd, &readSet);
-           if (form->fds[i].flags & NEWT_FD_WRITE)
-               FD_SET(form->fds[i].fd, &writeSet);
-           if (form->fds[i].flags & NEWT_FD_EXCEPT)
-               FD_SET(form->fds[i].fd, &exceptSet);
-       }
-
-       if (form->timer) {
-           /* Calculate when we next need to return with a timeout. Do
-              this inside the loop in case a callback resets the timer. */
-           if (!form->lastTimeout.tv_sec && !form->lastTimeout.tv_usec)
-               gettimeofday(&form->lastTimeout, NULL);
-
-           nextTimeout.tv_sec = form->lastTimeout.tv_sec + 
-                   (form->timer / 1000);
-           nextTimeout.tv_usec = form->lastTimeout.tv_usec + 
-                                   (form->timer % 1000) * 1000;
-
-           gettimeofday(&now, 0);
-
-           if (now.tv_sec > nextTimeout.tv_sec) {
-               timeout.tv_sec = timeout.tv_usec = 0;
-           } else if (now.tv_sec == nextTimeout.tv_sec) {
-               timeout.tv_sec = 0;
-               if (now.tv_usec > nextTimeout.tv_usec)
-                   timeout.tv_usec = 0;
-               else
-                   timeout.tv_usec = nextTimeout.tv_usec - now.tv_usec;
-           } else if (now.tv_sec < nextTimeout.tv_sec) {
-               timeout.tv_sec = nextTimeout.tv_sec - now.tv_sec;
-               if (now.tv_usec > nextTimeout.tv_usec)
-                   timeout.tv_sec--,
-                   timeout.tv_usec = nextTimeout.tv_usec + 1000000 -
-                                       now.tv_usec;
-               else 
-                   timeout.tv_usec = nextTimeout.tv_usec - now.tv_usec;
-           }
-       } else {
-           timeout.tv_sec = timeout.tv_usec = 0;
-       }
-
-       i = select(max + 1, &readSet, &writeSet, &exceptSet, 
-                       form->timer ? &timeout : NULL);
-       if (i < 0) continue;    /* ?? What should we do here? */
-
-       if (i == 0) {
-           done = 1;
-           es->reason = NEWT_EXIT_TIMER;
-           gettimeofday(&form->lastTimeout, NULL);
-       } else
+        for (i = 0; i < form->numFds; i++) {
+            if (form->fds[i].flags & NEWT_FD_READ)
+                FD_SET(form->fds[i].fd, &readSet);
+            if (form->fds[i].flags & NEWT_FD_WRITE)
+                FD_SET(form->fds[i].fd, &writeSet);
+            if (form->fds[i].flags & NEWT_FD_EXCEPT)
+                FD_SET(form->fds[i].fd, &exceptSet);
+        }
+
+        if (form->timer) {
+            /* Calculate when we next need to return with a timeout. Do
+               this inside the loop in case a callback resets the timer. */
+            if (!form->lastTimeout.tv_sec && !form->lastTimeout.tv_usec)
+                gettimeofday(&form->lastTimeout, NULL);
+
+            nextTimeout.tv_sec = form->lastTimeout.tv_sec + 
+                    (form->timer / 1000);
+            nextTimeout.tv_usec = form->lastTimeout.tv_usec + 
+                                    (form->timer % 1000) * 1000;
+
+            gettimeofday(&now, 0);
+
+            if (now.tv_sec > nextTimeout.tv_sec) {
+                timeout.tv_sec = timeout.tv_usec = 0;
+            } else if (now.tv_sec == nextTimeout.tv_sec) {
+                timeout.tv_sec = 0;
+                if (now.tv_usec > nextTimeout.tv_usec)
+                    timeout.tv_usec = 0;
+                else
+                    timeout.tv_usec = nextTimeout.tv_usec - now.tv_usec;
+            } else if (now.tv_sec < nextTimeout.tv_sec) {
+                timeout.tv_sec = nextTimeout.tv_sec - now.tv_sec;
+                if (now.tv_usec > nextTimeout.tv_usec)
+                    timeout.tv_sec--,
+                    timeout.tv_usec = nextTimeout.tv_usec + 1000000 -
+                                        now.tv_usec;
+                else 
+                    timeout.tv_usec = nextTimeout.tv_usec - now.tv_usec;
+            }
+        } else {
+            timeout.tv_sec = timeout.tv_usec = 0;
+        }
+
+        i = select(max + 1, &readSet, &writeSet, &exceptSet, 
+                        form->timer ? &timeout : NULL);
+        if (i < 0) continue;    /* ?? What should we do here? */
+
+        if (i == 0) {
+            done = 1;
+            es->reason = NEWT_EXIT_TIMER;
+            gettimeofday(&form->lastTimeout, NULL);
+        } else
 #ifdef USE_GPM
-       if (gpm_fd > 0 && FD_ISSET(gpm_fd, &readSet)) {
-           Gpm_GetEvent(&event);
+        if (gpm_fd > 0 && FD_ISSET(gpm_fd, &readSet)) {
+            Gpm_GetEvent(&event);
 
-           if (event.type & GPM_DOWN) {
-               /* Transform coordinates to current window */
-               newtGetWindowPos(&x, &y);
+            if (event.type & GPM_DOWN) {
+                /* Transform coordinates to current window */
+                newtGetWindowPos(&x, &y);
 
-               ev.event = EV_MOUSE;
-               ev.u.mouse.type = MOUSE_BUTTON_DOWN;
-               ev.u.mouse.x = event.x - x - 1;
-               ev.u.mouse.y = event.y - y - 1;
+                ev.event = EV_MOUSE;
+                ev.u.mouse.type = MOUSE_BUTTON_DOWN;
+                ev.u.mouse.x = event.x - x - 1;
+                ev.u.mouse.y = event.y - y - 1;
 
-               /* Send the form the event */
-               er = sendEvent(co, ev);
+                /* Send the form the event */
+                er = sendEvent(co, ev);
 
-               if (er.result == ER_EXITFORM) {
-                   done = 1;
-                   es->reason = NEWT_EXIT_COMPONENT;
-                   es->u.co = form->exitComp;
-               }
+                if (er.result == ER_EXITFORM) {
+                    done = 1;
+                    es->reason = NEWT_EXIT_COMPONENT;
+                    es->u.co = form->exitComp;
+                }
 
-           }
-       } else
+            }
+        } else
 #endif
-       {
-           if (FD_ISSET(0, &readSet)) {
-
-               key = newtGetKey();
-
-               if (key == NEWT_KEY_RESIZE) {
-                   newtResizeScreen(1);
-                   continue;
-               }
-
-               for (i = 0; i < form->numHotKeys; i++) {
-                   if (form->hotKeys[i] == key) {
-                       es->reason = NEWT_EXIT_HOTKEY;
-                       es->u.key = key;
-                       done = 1;
-                       break;
-                   }
-               }
-
-               if (key == NEWT_KEY_F1 && form->helpTag && form->helpCb)
-                   form->helpCb(co, form->helpTag);
-
-               if (!done) {
-                   ev.event = EV_KEYPRESS;
-                   ev.u.key = key;
-
-                   er = sendEvent(co, ev);
-
-                   if (er.result == ER_EXITFORM) {
-                       done = 1;
-                       es->reason = NEWT_EXIT_COMPONENT;
-                       es->u.co = form->exitComp;
-                   }
-               }
-           } else {
-               for (i = 0; i < form->numFds; i++) {
-                   if (((form->fds[i].flags & NEWT_FD_READ)
-                       && FD_ISSET(form->fds[i].fd, &readSet))
-                       || ((form->fds[i].flags & NEWT_FD_WRITE)
-                       && FD_ISSET(form->fds[i].fd, &writeSet))
-                       || ((form->fds[i].flags & NEWT_FD_EXCEPT)
-                       && FD_ISSET(form->fds[i].fd, &exceptSet))) break;
-               }
-               if(i < form->numFds)
-                   es->u.watch = form->fds[i].fd;
-               else
-                   es->u.watch = -1;
-
-               es->reason = NEWT_EXIT_FDREADY;
-               done = 1;
-           }
-       }
+        {
+            if (FD_ISSET(0, &readSet)) {
+
+                key = newtGetKey();
+
+                if (key == NEWT_KEY_RESIZE) {
+                    newtResizeScreen(1);
+                    continue;
+                }
+
+                for (i = 0; i < form->numHotKeys; i++) {
+                    if (form->hotKeys[i] == key) {
+                        es->reason = NEWT_EXIT_HOTKEY;
+                        es->u.key = key;
+                        done = 1;
+                        break;
+                    }
+                }
+
+                if (key == NEWT_KEY_F1 && form->helpTag && form->helpCb)
+                    form->helpCb(co, form->helpTag);
+
+                if (!done) {
+                    ev.event = EV_KEYPRESS;
+                    ev.u.key = key;
+
+                    er = sendEvent(co, ev);
+
+                    if (er.result == ER_EXITFORM) {
+                        done = 1;
+                        es->reason = NEWT_EXIT_COMPONENT;
+                        es->u.co = form->exitComp;
+                    }
+                }
+            } else {
+                for (i = 0; i < form->numFds; i++) {
+                    if (((form->fds[i].flags & NEWT_FD_READ)
+                        && FD_ISSET(form->fds[i].fd, &readSet))
+                        || ((form->fds[i].flags & NEWT_FD_WRITE)
+                        && FD_ISSET(form->fds[i].fd, &writeSet))
+                        || ((form->fds[i].flags & NEWT_FD_EXCEPT)
+                        && FD_ISSET(form->fds[i].fd, &exceptSet))) break;
+                }
+                if(i < form->numFds)
+                    es->u.watch = form->fds[i].fd;
+                else
+                    es->u.watch = -1;
+
+                es->reason = NEWT_EXIT_FDREADY;
+                done = 1;
+            }
+        }
     }
     newtRefresh();
 #ifdef USE_GPM
@@ -1073,13 +1073,13 @@ static struct eventResult sendEvent(newtComponent co, struct event ev) {
     er = co->ops->event(co, ev);
 
     if (er.result == ER_IGNORED) {
-       ev.when = EV_NORMAL;
-       er = co->ops->event(co, ev);
+        ev.when = EV_NORMAL;
+        er = co->ops->event(co, ev);
     }
 
     if (er.result == ER_IGNORED) {
-       ev.when = EV_LATE;
-       er = co->ops->event(co, ev);
+        ev.when = EV_LATE;
+        er = co->ops->event(co, ev);
     }
 
     return er;
@@ -1089,16 +1089,16 @@ static void gotoComponent(struct form * form, int newComp) {
     struct event ev;
 
     if (form->currComp != -1) {
-       ev.event = EV_UNFOCUS;
-       sendEvent(form->elements[form->currComp].co, ev);
+        ev.event = EV_UNFOCUS;
+        sendEvent(form->elements[form->currComp].co, ev);
     }
 
     form->currComp = newComp;
 
     if (form->currComp != -1) {
-       ev.event = EV_FOCUS;
-       ev.when = EV_NORMAL;
-       sendEvent(form->elements[form->currComp].co, ev);
+        ev.event = EV_FOCUS;
+        ev.when = EV_NORMAL;
+        sendEvent(form->elements[form->currComp].co, ev);
     }
 }
 
@@ -1123,7 +1123,7 @@ void newtFormWatchFd(newtComponent co, int fd, int fdFlags) {
 
     for (i = 0; i < form->numFds; i++)
       if (form->fds[i].fd == fd)
-       break;
+        break;
 
     if(i >= form->numFds)
       form->fds = realloc(form->fds, (++form->numFds) * sizeof(*form->fds));
diff --git a/grid.c b/grid.c
index bedd02a5267cce15a71c5a3e7ec4c8f874da1ad8..0dde33618b7918b60507af0915eaaedd2cf87786 100644 (file)
--- a/grid.c
+++ b/grid.c
@@ -12,8 +12,8 @@
 struct gridField {
     enum newtGridElement type;
     union {
-       newtGrid grid;
-       newtComponent co;
+        newtGrid grid;
+        newtComponent co;
     } u;
     int padLeft, padTop, padRight, padBottom;
     int anchor;
@@ -22,7 +22,7 @@ struct gridField {
 
 struct grid_s {
     int rows, cols;
-    int width, height;         /* totals, -1 means unknown */
+    int width, height;          /* totals, -1 means unknown */
     struct gridField ** fields;
 };
 
@@ -38,8 +38,8 @@ newtGrid newtCreateGrid(int cols, int rows) {
 
     grid->fields = malloc(sizeof(*grid->fields) * cols);
     while (cols--) {
-       grid->fields[cols] = malloc(sizeof(**(grid->fields)) * rows);
-       memset(grid->fields[cols], 0, sizeof(**(grid->fields)) * rows);
+        grid->fields[cols] = malloc(sizeof(**(grid->fields)) * rows);
+        memset(grid->fields[cols], 0, sizeof(**(grid->fields)) * rows);
     }
 
     grid->width = grid->height = -1;
@@ -48,13 +48,13 @@ newtGrid newtCreateGrid(int cols, int rows) {
 }
 
 void newtGridSetField(newtGrid grid, int col, int row, 
-                     enum newtGridElement type, void * val, int padLeft,
-                     int padTop, int padRight, int padBottom, int anchor,
-                     int flags) {
+                      enum newtGridElement type, void * val, int padLeft,
+                      int padTop, int padRight, int padBottom, int anchor,
+                      int flags) {
     struct gridField * field = &grid->fields[col][row];
 
     if (field->type == NEWT_GRID_SUBGRID) 
-       newtGridFree(field->u.grid, 1);
+        newtGridFree(field->u.grid, 1);
 
     field->type = type;
     field->u.co = (void *) val;
@@ -75,11 +75,11 @@ static void distSpace(int extra, int items, int * list) {
     all = extra / items;
     some = extra % items;
     for (i = 0; i < items; i++) {
-       list[i] += all;
-       if (some) {
-           list[i]++;
-           some--;
-       }
+        list[i] += all;
+        if (some) {
+            list[i]++;
+            some--;
+        }
     }
 }
 
@@ -99,57 +99,57 @@ static void shuffleGrid(newtGrid grid, int left, int top, int set) {
 
     minWidth = 0;
     for (row = 0; row < grid->rows; row++) {
-       i = 0;
-       for (col = 0; col < grid->cols; col++) {
-           field = &grid->fields[col][row];
-           if (field->type == NEWT_GRID_SUBGRID) {
-               /* we'll have to redo this later */
-               if (field->u.grid->width == -1) 
-                   shuffleGrid(field->u.grid, left, top, 0);
-               j = field->u.grid->width;
-           } else if (field->type == NEWT_GRID_COMPONENT) {
-               if (field->u.co->ops == formOps)
-                   newtFormSetSize(field->u.co);
-               j = field->u.co->width;
-           } else 
-               j = 0;
-
-           j += field->padLeft + field->padRight;
-
-           if (j > widths[col]) widths[col] = j;
-           i += widths[col];
-       }
-
-       if (i > minWidth) minWidth = i;
+        i = 0;
+        for (col = 0; col < grid->cols; col++) {
+            field = &grid->fields[col][row];
+            if (field->type == NEWT_GRID_SUBGRID) {
+                /* we'll have to redo this later */
+                if (field->u.grid->width == -1) 
+                    shuffleGrid(field->u.grid, left, top, 0);
+                j = field->u.grid->width;
+            } else if (field->type == NEWT_GRID_COMPONENT) {
+                if (field->u.co->ops == formOps)
+                    newtFormSetSize(field->u.co);
+                j = field->u.co->width;
+            } else 
+                j = 0;
+
+            j += field->padLeft + field->padRight;
+
+            if (j > widths[col]) widths[col] = j;
+            i += widths[col];
+        }
+
+        if (i > minWidth) minWidth = i;
     }
 
     minHeight = 0;
     for (col = 0; col < grid->cols; col++) {
-       i = 0;
-       for (row = 0; row < grid->rows; row++) {
-           field = &grid->fields[col][row];
-           if (field->type == NEWT_GRID_SUBGRID) {
-               /* we'll have to redo this later */
-               if (field->u.grid->height == -1) 
-                   shuffleGrid(field->u.grid, 0, 0, 0);
-               j = field->u.grid->height;
-           } else if (field->type == NEWT_GRID_COMPONENT){
-               j = field->u.co->height;
-           } else 
-               j = 0;
-
-           j += field->padTop + field->padBottom;
-
-           if (j > heights[row]) heights[row] = j;
-           i += heights[row];
-       }
-
-       if (i > minHeight) minHeight = i;
+        i = 0;
+        for (row = 0; row < grid->rows; row++) {
+            field = &grid->fields[col][row];
+            if (field->type == NEWT_GRID_SUBGRID) {
+                /* we'll have to redo this later */
+                if (field->u.grid->height == -1) 
+                    shuffleGrid(field->u.grid, 0, 0, 0);
+                j = field->u.grid->height;
+            } else if (field->type == NEWT_GRID_COMPONENT){
+                j = field->u.co->height;
+            } else 
+                j = 0;
+
+            j += field->padTop + field->padBottom;
+
+            if (j > heights[row]) heights[row] = j;
+            i += heights[row];
+        }
+
+        if (i > minHeight) minHeight = i;
     }
 
     /* this catches the -1 case */
-    if (grid->width < minWidth) grid->width = minWidth;                /* ack! */
-    if (grid->height < minHeight) grid->height = minHeight;    /* ditto! */
+    if (grid->width < minWidth) grid->width = minWidth;         /* ack! */
+    if (grid->height < minHeight) grid->height = minHeight;     /* ditto! */
 
     if (!set) return;
 
@@ -158,57 +158,57 @@ static void shuffleGrid(newtGrid grid, int left, int top, int set) {
 
     thisTop = top;
     for (row = 0; row < grid->rows; row++) {
-       i = 0;
-       thisLeft = left;
-       for (col = 0; col < grid->cols; col++) {
-           field = &grid->fields[col][row];
-
-           if (field->type == NEWT_GRID_EMPTY) continue;
-
-           x = thisLeft + field->padLeft;
-           remx = widths[col] - field->padLeft - field->padRight;
-           y = thisTop + field->padTop;
-           remy = heights[row] - field->padTop - field->padBottom;
-
-           if (field->type == NEWT_GRID_SUBGRID) {
-               remx -= field->u.grid->width;
-               remy -= field->u.grid->height;
-           } else if (field->type == NEWT_GRID_COMPONENT) {
-               remx -= field->u.co->width;
-               remy -= field->u.co->height;
-           }
-
-           if (!(field->flags & NEWT_GRID_FLAG_GROWX)) {
-               if (field->anchor & NEWT_ANCHOR_RIGHT)
-                   x += remx;
-               else if (!(field->anchor & NEWT_ANCHOR_LEFT))
-                   x += (remx / 2);
-           }
-        
-           if (!(field->flags & NEWT_GRID_FLAG_GROWY)) {
-               if (field->anchor & NEWT_ANCHOR_BOTTOM)
-                   y += remx;
-               else if (!(field->anchor & NEWT_ANCHOR_TOP))
-                   y += (remy / 2);
-           }
-
-           if (field->type == NEWT_GRID_SUBGRID) {
-               if (field->flags & NEWT_GRID_FLAG_GROWX)
-                   field->u.grid->width = widths[col] - field->padLeft 
-                                               - field->padRight;
-               if (field->flags & NEWT_GRID_FLAG_GROWY)
-                   field->u.grid->height = heights[col] - field->padTop
-                                               - field->padBottom;
-
-               shuffleGrid(field->u.grid, x, y, 1);
-           } else if (field->type == NEWT_GRID_COMPONENT) {
-               field->u.co->ops->place(field->u.co, x, y);
-           }
-
-           thisLeft += widths[col];
-       }
-
-       thisTop += heights[row];
+        i = 0;
+        thisLeft = left;
+        for (col = 0; col < grid->cols; col++) {
+            field = &grid->fields[col][row];
+
+            if (field->type == NEWT_GRID_EMPTY) continue;
+
+            x = thisLeft + field->padLeft;
+            remx = widths[col] - field->padLeft - field->padRight;
+            y = thisTop + field->padTop;
+            remy = heights[row] - field->padTop - field->padBottom;
+
+            if (field->type == NEWT_GRID_SUBGRID) {
+                remx -= field->u.grid->width;
+                remy -= field->u.grid->height;
+            } else if (field->type == NEWT_GRID_COMPONENT) {
+                remx -= field->u.co->width;
+                remy -= field->u.co->height;
+            }
+
+            if (!(field->flags & NEWT_GRID_FLAG_GROWX)) {
+                if (field->anchor & NEWT_ANCHOR_RIGHT)
+                    x += remx;
+                else if (!(field->anchor & NEWT_ANCHOR_LEFT))
+                    x += (remx / 2);
+            }
+         
+            if (!(field->flags & NEWT_GRID_FLAG_GROWY)) {
+                if (field->anchor & NEWT_ANCHOR_BOTTOM)
+                    y += remx;
+                else if (!(field->anchor & NEWT_ANCHOR_TOP))
+                    y += (remy / 2);
+            }
+
+            if (field->type == NEWT_GRID_SUBGRID) {
+                if (field->flags & NEWT_GRID_FLAG_GROWX)
+                    field->u.grid->width = widths[col] - field->padLeft 
+                                                - field->padRight;
+                if (field->flags & NEWT_GRID_FLAG_GROWY)
+                    field->u.grid->height = heights[col] - field->padTop
+                                                - field->padBottom;
+
+                shuffleGrid(field->u.grid, x, y, 1);
+            } else if (field->type == NEWT_GRID_COMPONENT) {
+                field->u.co->ops->place(field->u.co, x, y);
+            }
+
+            thisLeft += widths[col];
+        }
+
+        thisTop += heights[row];
     }
 }
 
@@ -220,14 +220,14 @@ void newtGridFree(newtGrid grid, int recurse) {
     int row, col;
 
     for (col = 0; col < grid->cols; col++) {
-       if (recurse) {
-           for (row = 0; row < grid->rows; row++) {
-               if (grid->fields[col][row].type == NEWT_GRID_SUBGRID)
-                   newtGridFree(grid->fields[col][row].u.grid, 1);
-           }
-       }
-
-       free(grid->fields[col]);
+        if (recurse) {
+            for (row = 0; row < grid->rows; row++) {
+                if (grid->fields[col][row].type == NEWT_GRID_SUBGRID)
+                    newtGridFree(grid->fields[col][row].u.grid, 1);
+            }
+        }
+
+        free(grid->fields[col]);
     }
 
     free(grid->fields);
@@ -236,8 +236,8 @@ void newtGridFree(newtGrid grid, int recurse) {
 
 void newtGridGetSize(newtGrid grid, int * width, int * height) {
     if (grid->width == -1 || grid->height == -1) {
-       grid->width = grid->height = -1;
-       shuffleGrid(grid, 0, 0, 1);
+        grid->width = grid->height = -1;
+        shuffleGrid(grid, 0, 0, 1);
     }
 
     *width = grid->width;
@@ -250,8 +250,8 @@ void newtGridWrappedWindow(newtGrid grid, char * title) {
     newtGridGetSize(grid, &width, &height);
     w = wstrlen(title,-1);
     if (width < w + 2) {
-       offset = ((w + 2) - width) / 2; 
-       width = w + 2;
+        offset = ((w + 2) - width) / 2; 
+        width = w + 2;
     }
     newtCenteredWindow(width + 2, height + 2, title);
     newtGridPlace(grid, 1 + offset, 1);
@@ -266,46 +266,46 @@ void newtGridWrappedWindowAt(newtGrid grid, char * title, int left, int top) {
 }
 
 void newtGridAddComponentsToForm(newtGrid grid, newtComponent form, 
-                                int recurse) {
+                                 int recurse) {
     int row, col;
 
     for (col = 0; col < grid->cols; col++) {
-       for (row = 0; row < grid->rows; row++) {
-           if (grid->fields[col][row].type == NEWT_GRID_SUBGRID && recurse)
-               newtGridAddComponentsToForm(grid->fields[col][row].u.grid,
-                                           form, 1);
-           else if (grid->fields[col][row].type == NEWT_GRID_COMPONENT)
-               newtFormAddComponent(form, grid->fields[col][row].u.co);
-       }
+        for (row = 0; row < grid->rows; row++) {
+            if (grid->fields[col][row].type == NEWT_GRID_SUBGRID && recurse)
+                newtGridAddComponentsToForm(grid->fields[col][row].u.grid,
+                                            form, 1);
+            else if (grid->fields[col][row].type == NEWT_GRID_COMPONENT)
+                newtFormAddComponent(form, grid->fields[col][row].u.co);
+        }
     }
 }
 
 /* this handles up to 50 items */
 static newtGrid stackem(int isVert, enum newtGridElement type1, void * what1,
-                       va_list args, int close) {
+                        va_list args, int close) {
     struct item {
-       enum newtGridElement type;
-       void * what;
+        enum newtGridElement type;
+        void * what;
     } items[50];
     int i, num;
     newtGrid grid;
     
     items[0].type = type1, items[0].what = what1, num = 1;
     while (1) {
-       items[num].type = va_arg(args, enum newtGridElement);
-       if (items[num].type == NEWT_GRID_EMPTY) break;
+        items[num].type = va_arg(args, enum newtGridElement);
+        if (items[num].type == NEWT_GRID_EMPTY) break;
 
-       items[num].what = va_arg(args, void *);
-       num++;
+        items[num].what = va_arg(args, void *);
+        num++;
     }
 
     grid = newtCreateGrid(isVert ? 1 : num, isVert ? num : 1);
 
     for (i = 0; i < num; i++) {
-       newtGridSetField(grid, isVert ? 0 : i, isVert ? i : 0, 
-                        items[i].type, items[i].what,
-                        close ? 0 : (i ? (isVert ? 0 : 1) : 0),
-                        close ? 0 : (i ? (isVert ? 1 : 0) : 0), 0, 0, 0, 0);
+        newtGridSetField(grid, isVert ? 0 : i, isVert ? i : 0, 
+                         items[i].type, items[i].what,
+                         close ? 0 : (i ? (isVert ? 0 : 1) : 0),
+                         close ? 0 : (i ? (isVert ? 1 : 0) : 0), 0, 0, 0, 0);
     }
 
     return grid;
@@ -364,31 +364,31 @@ newtGrid newtGridHStacked(enum newtGridElement type1, void * what1, ...) {
 }
 
 newtGrid newtGridBasicWindow(newtComponent text, newtGrid middle,
-                            newtGrid buttons) {
+                             newtGrid buttons) {
     newtGrid grid;
 
     grid = newtCreateGrid(1, 3);
     newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text,
-                    0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
+                     0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
     newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, middle,
-                    0, 1, 0, 0, 0, 0);
+                     0, 1, 0, 0, 0, 0);
     newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttons,
-                    0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
+                     0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
 
     return grid;
 }
 
 newtGrid newtGridSimpleWindow(newtComponent text, newtComponent middle,
-                            newtGrid buttons) {
+                             newtGrid buttons) {
     newtGrid grid;
 
     grid = newtCreateGrid(1, 3);
     newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, text,
-                    0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
+                     0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
     newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, middle,
-                    0, 1, 0, 0, 0, 0);
+                     0, 1, 0, 0, 0, 0);
     newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttons,
-                    0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
+                     0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
 
     return grid;
 }
diff --git a/label.c b/label.c
index ad8665b82068cea9a6b3f76478f3ae6de31b0c7e..d4f508d4aaae2181d751d9649ab80608cfd59f63 100644 (file)
--- a/label.c
+++ b/label.c
@@ -50,12 +50,12 @@ void newtLabelSetText(newtComponent co, const char * text) {
     co->width = wstrlen(text,-1);
     newLength = strlen(text);
     if (newLength <= la->length) {
-       memset(la->text, ' ', la->length);
-       memcpy(la->text, text, newLength);
+        memset(la->text, ' ', la->length);
+        memcpy(la->text, text, newLength);
     } else {
-       free(la->text);
-       la->text = strdup(text);
-       la->length = newLength;
+        free(la->text);
+        la->text = strdup(text);
+        la->length = newLength;
     }
 
     labelDraw(co);
index a8957373107725e76453b192e1090158dcbe4e1b..a2e7b4c910dc96a7611dd8618443e3c7959ff436 100644 (file)
--- a/listbox.c
+++ b/listbox.c
@@ -24,21 +24,21 @@ struct items {
 /* Holds all the relevant information for this listbox */
 struct listbox {
     newtComponent sb;   /* Scrollbar on right side of listbox */
-    int curWidth;      /* size of text w/o scrollbar or border*/
-    int curHeight;     /* size of text w/o border */
+    int curWidth;       /* size of text w/o scrollbar or border*/
+    int curHeight;      /* size of text w/o border */
     int sbAdjust;
     int bdxAdjust, bdyAdjust;
     int numItems, numSelected;
     int userHasSetWidth;
     int currItem, startShowItem; /* startShowItem is the first item displayed
-                                  on the screen */
+                                   on the screen */
     int isActive; /* If we handle key events all the time, it seems
-                    to do things even when they are supposed to be for
-                    another button/whatever */
+                     to do things even when they are supposed to be for
+                     another button/whatever */
     struct items *boxItems;
     int grow;
     int flags; /* flags for this listbox, right now just
-                 NEWT_FLAG_RETURNEXIT */
+                  NEWT_FLAG_RETURNEXIT */
 };
 
 static void listboxDraw(newtComponent co);
@@ -47,7 +47,7 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev);
 static void newtListboxRealSetCurrent(newtComponent co);
 static void listboxPlace(newtComponent co, int newLeft, int newTop);
 static inline void updateWidth(newtComponent co, struct listbox * li,
-                               int maxField);
+                                int maxField);
 static void listboxMapped(newtComponent co, int isMapped);
 
 static struct componentOps listboxOps = {
@@ -63,7 +63,7 @@ static void listboxMapped(newtComponent co, int isMapped) {
 
     co->isMapped = isMapped;
     if (li->sb)
-       li->sb->ops->mapped(li->sb, isMapped);
+        li->sb->ops->mapped(li->sb, isMapped);
 }
 
 static void listboxPlace(newtComponent co, int newLeft, int newTop) {
@@ -73,8 +73,8 @@ static void listboxPlace(newtComponent co, int newLeft, int newTop) {
     co->left = newLeft;
 
     if (li->sb)
-       li->sb->ops->place(li->sb, co->left + co->width - li->bdxAdjust - 1,
-                          co->top);
+        li->sb->ops->place(li->sb, co->left + co->width - li->bdxAdjust - 1,
+                           co->top);
 }
 
 newtComponent newtListbox(int left, int top, int height, int flags) {
@@ -82,11 +82,11 @@ newtComponent newtListbox(int left, int top, int height, int flags) {
     struct listbox * li;
 
     if (!(co = malloc(sizeof(*co))))
-       return NULL;
+        return NULL;
 
     if (!(li = malloc(sizeof(struct listbox)))) {
-       free(co);
-       return NULL;
+        free(co);
+        return NULL;
     }
 
     li->boxItems = NULL;
@@ -100,29 +100,29 @@ newtComponent newtListbox(int left, int top, int height, int flags) {
     li->bdxAdjust = 0;
     li->bdyAdjust = 0;
     li->flags = flags & (NEWT_FLAG_RETURNEXIT | NEWT_FLAG_BORDER |
-                        NEWT_FLAG_MULTIPLE | NEWT_FLAG_SHOWCURSOR);
+                         NEWT_FLAG_MULTIPLE | NEWT_FLAG_SHOWCURSOR);
 
     if (li->flags & NEWT_FLAG_BORDER) {
-       li->bdxAdjust = 2;
-       li->bdyAdjust = 1;
+        li->bdxAdjust = 2;
+        li->bdyAdjust = 1;
     }
 
     co->height = height;
     li->curHeight = co->height - (2 * li->bdyAdjust);
 
     if (height) {
-       li->grow = 0;
-       if (flags & NEWT_FLAG_SCROLL) {
-           sb = newtVerticalScrollbar(left, top + li->bdyAdjust,
-                                       li->curHeight,
-                                       COLORSET_LISTBOX, COLORSET_ACTLISTBOX);
-           li->sbAdjust = 3;
-       } else {
-           sb = NULL;
-       }
+        li->grow = 0;
+        if (flags & NEWT_FLAG_SCROLL) {
+            sb = newtVerticalScrollbar(left, top + li->bdyAdjust,
+                                        li->curHeight,
+                                        COLORSET_LISTBOX, COLORSET_ACTLISTBOX);
+            li->sbAdjust = 3;
+        } else {
+            sb = NULL;
+        }
     } else {
-       li->grow = 1;
-       sb = NULL;
+        li->grow = 1;
+        sb = NULL;
     }
 
     li->sb = sb;
@@ -140,12 +140,12 @@ newtComponent newtListbox(int left, int top, int height, int flags) {
 }
 
 static inline void updateWidth(newtComponent co, struct listbox * li,
-                               int maxField) {
+                                int maxField) {
     li->curWidth = maxField;
     co->width = li->curWidth + li->sbAdjust + 2 * li->bdxAdjust;
 
     if (li->sb)
-       li->sb->left = co->left + co->width - li->bdxAdjust - 1;
+        li->sb->left = co->left + co->width - li->bdxAdjust - 1;
 }
 
 void newtListboxSetCurrentByKey(newtComponent co, void * key) {
@@ -155,10 +155,10 @@ void newtListboxSetCurrentByKey(newtComponent co, void * key) {
 
     item = li->boxItems, i = 0;
     while (item && item->data != key)
-       item = item->next, i++;
+        item = item->next, i++;
 
     if (item)
-       newtListboxSetCurrent(co, i);
+        newtListboxSetCurrent(co, i);
 }
 
 void newtListboxSetCurrent(newtComponent co, int num)
@@ -166,20 +166,20 @@ void newtListboxSetCurrent(newtComponent co, int num)
     struct listbox * li = co->data;
 
     if (num >= li->numItems)
-       li->currItem = li->numItems - 1;
+        li->currItem = li->numItems - 1;
     else if (num < 0)
-       li->currItem = 0;
+        li->currItem = 0;
     else
-       li->currItem = num;
+        li->currItem = num;
 
     if (li->currItem < li->startShowItem)
-       li->startShowItem = li->currItem;
+        li->startShowItem = li->currItem;
     else if (li->currItem - li->startShowItem > li->curHeight - 1)
-       li->startShowItem = li->currItem - li->curHeight + 1;
+        li->startShowItem = li->currItem - li->curHeight + 1;
     if (li->startShowItem + li->curHeight > li->numItems)
-       li->startShowItem = li->numItems - li->curHeight;
+        li->startShowItem = li->numItems - li->curHeight;
     if(li->startShowItem < 0)
-       li->startShowItem = 0;
+        li->startShowItem = 0;
 
     newtListboxRealSetCurrent(co);
 }
@@ -189,7 +189,7 @@ static void newtListboxRealSetCurrent(newtComponent co)
     struct listbox * li = co->data;
 
     if(li->sb)
-       newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
+        newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
     listboxDraw(co);
     if(co->callback) co->callback(co, co->callbackData);
 }
@@ -210,16 +210,16 @@ void * newtListboxGetCurrent(newtComponent co) {
     struct items *item;
 
     for(i = 0, item = li->boxItems; item != NULL && i < li->currItem;
-       i++, item = item->next);
+        i++, item = item->next);
 
     if (item)
-       return (void *)item->data;
+        return (void *)item->data;
     else
-       return NULL;
+        return NULL;
 }
 
 void newtListboxSelectItem(newtComponent co, const void * key,
-       enum newtFlagsSense sense)
+        enum newtFlagsSense sense)
 {
     struct listbox * li = co->data;
     int i;
@@ -227,24 +227,24 @@ void newtListboxSelectItem(newtComponent co, const void * key,
 
     item = li->boxItems, i = 0;
     while (item && item->data != key)
-       item = item->next, i++;
+        item = item->next, i++;
 
     if (!item) return;
 
     if (item->isSelected)
-       li->numSelected--;
+        li->numSelected--;
 
     switch(sense) {
-       case NEWT_FLAGS_RESET:
-               item->isSelected = 0; break;
-       case NEWT_FLAGS_SET:
-               item->isSelected = 1; break;
-       case NEWT_FLAGS_TOGGLE:
-               item->isSelected = !item->isSelected;
+        case NEWT_FLAGS_RESET:
+                item->isSelected = 0; break;
+        case NEWT_FLAGS_SET:
+                item->isSelected = 1; break;
+        case NEWT_FLAGS_TOGGLE:
+                item->isSelected = !item->isSelected;
     }
 
     if (item->isSelected)
-       li->numSelected++;
+        li->numSelected++;
 
     listboxDraw(co);
 }
@@ -255,8 +255,8 @@ void newtListboxClearSelection(newtComponent co)
     struct listbox * li = co->data;
 
     for(item = li->boxItems; item != NULL;
-       item = item->next)
-       item->isSelected = 0;
+        item = item->next)
+        item->isSelected = 0;
     li->numSelected = 0;
     listboxDraw(co);
 }
@@ -276,9 +276,9 @@ void ** newtListboxGetSelection(newtComponent co, int *numitems)
 
     retval = malloc(li->numSelected * sizeof(void *));
     for(i = 0, item = li->boxItems; item != NULL;
-       item = item->next)
-       if(item->isSelected)
-           retval[i++] = (void *)item->data;
+        item = item->next)
+        if(item->isSelected)
+            retval[i++] = (void *)item->data;
     *numitems = li->numSelected;
     return retval;
 }
@@ -289,20 +289,20 @@ void newtListboxSetEntry(newtComponent co, int num, const char * text) {
     struct items *item;
 
     for(i = 0, item = li->boxItems; item != NULL && i < num;
-       i++, item = item->next);
+        i++, item = item->next);
 
     if(!item)
-       return;
+        return;
     else {
-       free(item->text);
-       item->text = strdup(text);
+        free(item->text);
+        item->text = strdup(text);
     }
     if (li->userHasSetWidth == 0 && wstrlen(text,-1) > li->curWidth) {
-       updateWidth(co, li, wstrlen(text,-1));
+        updateWidth(co, li, wstrlen(text,-1));
     }
 
     if (num >= li->startShowItem && num <= li->startShowItem + co->height)
-       listboxDraw(co);
+        listboxDraw(co);
 }
 
 void newtListboxSetData(newtComponent co, int num, void * data) {
@@ -311,72 +311,72 @@ void newtListboxSetData(newtComponent co, int num, void * data) {
     struct items *item;
 
     for(i = 0, item = li->boxItems; item != NULL && i < num;
-       i++, item = item->next);
+        i++, item = item->next);
 
     item->data = data;
 }
 
 int newtListboxAppendEntry(newtComponent co, const char * text,
-                       const void * data) {
+                        const void * data) {
     struct listbox * li = co->data;
     struct items *item;
 
     if(li->boxItems) {
-       for (item = li->boxItems; item->next != NULL; item = item->next);
+        for (item = li->boxItems; item->next != NULL; item = item->next);
 
-       item = item->next = malloc(sizeof(struct items));
+        item = item->next = malloc(sizeof(struct items));
     } else {
-       item = li->boxItems = malloc(sizeof(struct items));
+        item = li->boxItems = malloc(sizeof(struct items));
     }
 
     if (!li->userHasSetWidth && text && (wstrlen(text,-1) > li->curWidth))
-       updateWidth(co, li, wstrlen(text,-1));
+        updateWidth(co, li, wstrlen(text,-1));
 
     item->text = strdup(text); item->data = data; item->next = NULL;
     item->isSelected = 0;
 
     if (li->grow)
-       co->height++, li->curHeight++;
+        co->height++, li->curHeight++;
     li->numItems++;
 
     return 0;
 }
 
 int newtListboxInsertEntry(newtComponent co, const char * text,
-                          const void * data, void * key) {
+                           const void * data, void * key) {
     struct listbox * li = co->data;
     struct items *item, *t;
 
     if (li->boxItems) {
-       if (key) {
-           item = li->boxItems;
-           while (item && item->data != key) item = item->next;
-
-           if (!item) return 1;
-
-           t = item->next;
-           item = item->next = malloc(sizeof(struct items));
-           item->next = t;
-       } else {
-           t = li->boxItems;
-           item = li->boxItems = malloc(sizeof(struct items));
-           item->next = t;
-       }
+        if (key) {
+            item = li->boxItems;
+            while (item && item->data != key) item = item->next;
+
+            if (!item) return 1;
+
+            t = item->next;
+            item = item->next = malloc(sizeof(struct items));
+            item->next = t;
+        } else {
+            t = li->boxItems;
+            item = li->boxItems = malloc(sizeof(struct items));
+            item->next = t;
+        }
     } else if (key) {
-       return 1;
+        return 1;
     } else {
-       item = li->boxItems = malloc(sizeof(struct items));
-       item->next = NULL;
+        item = li->boxItems = malloc(sizeof(struct items));
+        item->next = NULL;
     }
 
     if (!li->userHasSetWidth && text && (wstrlen(text,-1) > li->curWidth))
-       updateWidth(co, li, wstrlen(text,-1));
+        updateWidth(co, li, wstrlen(text,-1));
 
     item->text = strdup(text?text:"(null)"); item->data = data;
     item->isSelected = 0;
 
     if (li->sb)
-       li->sb->left = co->left + co->width - li->bdxAdjust - 1;
+        li->sb->left = co->left + co->width - li->bdxAdjust - 1;
     li->numItems++;
 
     listboxDraw(co);
@@ -391,40 +391,40 @@ int newtListboxDeleteEntry(newtComponent co, void * key) {
     int num;
 
     if (li->boxItems == NULL || li->numItems <= 0)
-       return 0;
+        return 0;
 
     num = 0;
 
     item2 = NULL, item = li->boxItems;
     while (item && item->data != key) {
-       item2 = item;
-       item = item->next;
-       num++;
+        item2 = item;
+        item = item->next;
+        num++;
     }
 
     if (!item)
-       return -1;
+        return -1;
 
     if (item2)
-       item2->next = item->next;
+        item2->next = item->next;
     else
-       li->boxItems = item->next;
+        li->boxItems = item->next;
 
     free(item->text);
     free(item);
     li->numItems--;
 
     if (!li->userHasSetWidth) {
-       widest = 0;
-       for (item = li->boxItems; item != NULL; item = item->next)
-           if ((t = wstrlen(item->text,-1)) > widest) widest = t;
+        widest = 0;
+        for (item = li->boxItems; item != NULL; item = item->next)
+            if ((t = wstrlen(item->text,-1)) > widest) widest = t;
     }
 
     if (li->currItem >= num)
-       li->currItem--;
+        li->currItem--;
 
     if (!li->userHasSetWidth) {
-       updateWidth(co, li, widest);
+        updateWidth(co, li, widest);
     }
 
     listboxDraw(co);
@@ -437,16 +437,16 @@ void newtListboxClear(newtComponent co)
     struct listbox * li;
     struct items *anitem, *nextitem;
     if(co == NULL || (li = co->data) == NULL)
-       return;
+        return;
     for(anitem = li->boxItems; anitem != NULL; anitem = nextitem) {
-       nextitem = anitem->next;
-       free(anitem->text);
-       free(anitem);
+        nextitem = anitem->next;
+        free(anitem->text);
+        free(anitem);
     }
     li->numItems = li->numSelected = li->currItem = li->startShowItem = 0;
     li->boxItems = NULL;
     if (!li->userHasSetWidth)
-       updateWidth(co, li, 5);
+        updateWidth(co, li, 5);
 }
 
 int newtListboxItemCount(newtComponent co)
@@ -463,24 +463,24 @@ void newtListboxGetEntry(newtComponent co, int num, char **text, void **data) {
     struct items *item;
 
     if (!li->boxItems || num >= li->numItems) {
-       if(text)
-           *text = NULL;
-       if(data)
-           *data = NULL;
-       return;
+        if(text)
+            *text = NULL;
+        if(data)
+            *data = NULL;
+        return;
     }
 
     i = 0;
     item = li->boxItems;
     while (item && i < num) {
-       i++, item = item->next;
+        i++, item = item->next;
     }
 
     if (item) {
-       if (text)
-           *text = item->text;
-       if (data)
-           *data = (void *)item->data;
+        if (text)
+            *text = item->text;
+        if (data)
+            *data = (void *)item->data;
     }
 }
 
@@ -496,7 +496,7 @@ static void listboxDraw(newtComponent co)
     
     if(li->flags & NEWT_FLAG_BORDER) {
       if(li->isActive)
-         SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
+          SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
       else
           SLsmg_set_color(NEWT_COLORSET_LISTBOX);
 
@@ -504,30 +504,30 @@ static void listboxDraw(newtComponent co)
     }
 
     if(li->sb)
-       li->sb->ops->draw(li->sb);
+        li->sb->ops->draw(li->sb);
 
     SLsmg_set_color(NEWT_COLORSET_LISTBOX);
 
     for(i = 0, item = li->boxItems; item != NULL && i < li->startShowItem;
-       i++, item = item->next);
+        i++, item = item->next);
 
     j = i;
 
     for (i = 0; item != NULL && i < li->curHeight; i++, item = item->next) {
-       if (!item->text) continue;
+        if (!item->text) continue;
 
-       newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust);
-       if(j + i == li->currItem) {
-           if(item->isSelected)
-               SLsmg_set_color(NEWT_COLORSET_ACTSELLISTBOX);
-           else
-               SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
-       } else if(item->isSelected)
-           SLsmg_set_color(NEWT_COLORSET_SELLISTBOX);
-       else
-           SLsmg_set_color(NEWT_COLORSET_LISTBOX);
+        newtGotorc(co->top + i + li->bdyAdjust, co->left + li->bdxAdjust);
+        if(j + i == li->currItem) {
+            if(item->isSelected)
+                SLsmg_set_color(NEWT_COLORSET_ACTSELLISTBOX);
+            else
+                SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX);
+        } else if(item->isSelected)
+            SLsmg_set_color(NEWT_COLORSET_SELLISTBOX);
+        else
+            SLsmg_set_color(NEWT_COLORSET_LISTBOX);
 
-       SLsmg_write_nstring(item->text, li->curWidth);
+        SLsmg_write_nstring(item->text, li->curWidth);
 
     }
     newtGotorc(co->top + (li->currItem - li->startShowItem) + li->bdyAdjust,
@@ -543,203 +543,203 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) {
     er.result = ER_IGNORED;
 
     if(ev.when == EV_EARLY || ev.when == EV_LATE) {
-       return er;
+        return er;
     }
 
     switch(ev.event) {
       case EV_KEYPRESS:
-       if (!li->isActive) break;
-
-       switch(ev.u.key) {
-         case ' ':
-           if(!(li->flags & NEWT_FLAG_MULTIPLE)) break;
-           newtListboxSelectItem(co, newtListboxGetCurrent(co),
-                                 NEWT_FLAGS_TOGGLE);
-           er.result = ER_SWALLOWED;
-           /* We don't break here, because it is cool to be able to
-              hold space to select a bunch of items in a list at once */
-
-         case NEWT_KEY_DOWN:
-           if(li->numItems <= 0) break;
-           if(li->currItem < li->numItems - 1) {
-               li->currItem++;
-               if(li->currItem > (li->startShowItem + li->curHeight - 1)) {
-                   li->startShowItem = li->currItem - li->curHeight + 1;
-                   if(li->startShowItem + li->curHeight > li->numItems)
-                       li->startShowItem = li->numItems - li->curHeight;
-               }
-               if(li->sb)
-                   newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
-               listboxDraw(co);
-           }
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case NEWT_KEY_ENTER:
-           if(li->numItems <= 0) break;
-           if(li->flags & NEWT_FLAG_RETURNEXIT)
-               er.result = ER_EXITFORM;
-           break;
-
-         case NEWT_KEY_UP:
-           if(li->numItems <= 0) break;
-           if(li->currItem > 0) {
-               li->currItem--;
-               if(li->currItem < li->startShowItem)
-                   li->startShowItem = li->currItem;
-               if(li->sb)
-                   newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
-               listboxDraw(co);
-           }
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case NEWT_KEY_PGUP:
-           if(li->numItems <= 0) break;
-           li->startShowItem -= li->curHeight - 1;
-           if(li->startShowItem < 0)
-               li->startShowItem = 0;
-           li->currItem -= li->curHeight - 1;
-           if(li->currItem < 0)
-               li->currItem = 0;
-           newtListboxRealSetCurrent(co);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case NEWT_KEY_PGDN:
-           if(li->numItems <= 0) break;
-           li->startShowItem += li->curHeight;
-           if(li->startShowItem > (li->numItems - li->curHeight)) {
-               li->startShowItem = li->numItems - li->curHeight;
-           }
-           li->currItem += li->curHeight;
-           if(li->currItem >= li->numItems) {
-               li->currItem = li->numItems - 1;
-           }
-           newtListboxRealSetCurrent(co);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case NEWT_KEY_HOME:
-           if(li->numItems <= 0) break;
-           newtListboxSetCurrent(co, 0);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case NEWT_KEY_END:
-           if(li->numItems <= 0) break;
-           li->startShowItem = li->numItems - li->curHeight;
-           if(li->startShowItem < 0)
-               li->startShowItem = 0;
-           li->currItem = li->numItems - 1;
-           newtListboxRealSetCurrent(co);
-           er.result = ER_SWALLOWED;
-           break;
-         default:
-             if (li->numItems <= 0) break;
+        if (!li->isActive) break;
+
+        switch(ev.u.key) {
+          case ' ':
+            if(!(li->flags & NEWT_FLAG_MULTIPLE)) break;
+            newtListboxSelectItem(co, newtListboxGetCurrent(co),
+                                  NEWT_FLAGS_TOGGLE);
+            er.result = ER_SWALLOWED;
+            /* We don't break here, because it is cool to be able to
+               hold space to select a bunch of items in a list at once */
+
+          case NEWT_KEY_DOWN:
+            if(li->numItems <= 0) break;
+            if(li->currItem < li->numItems - 1) {
+                li->currItem++;
+                if(li->currItem > (li->startShowItem + li->curHeight - 1)) {
+                    li->startShowItem = li->currItem - li->curHeight + 1;
+                    if(li->startShowItem + li->curHeight > li->numItems)
+                        li->startShowItem = li->numItems - li->curHeight;
+                }
+                if(li->sb)
+                    newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
+                listboxDraw(co);
+            }
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case NEWT_KEY_ENTER:
+            if(li->numItems <= 0) break;
+            if(li->flags & NEWT_FLAG_RETURNEXIT)
+                er.result = ER_EXITFORM;
+            break;
+
+          case NEWT_KEY_UP:
+            if(li->numItems <= 0) break;
+            if(li->currItem > 0) {
+                li->currItem--;
+                if(li->currItem < li->startShowItem)
+                    li->startShowItem = li->currItem;
+                if(li->sb)
+                    newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
+                listboxDraw(co);
+            }
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case NEWT_KEY_PGUP:
+            if(li->numItems <= 0) break;
+            li->startShowItem -= li->curHeight - 1;
+            if(li->startShowItem < 0)
+                li->startShowItem = 0;
+            li->currItem -= li->curHeight - 1;
+            if(li->currItem < 0)
+                li->currItem = 0;
+            newtListboxRealSetCurrent(co);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case NEWT_KEY_PGDN:
+            if(li->numItems <= 0) break;
+            li->startShowItem += li->curHeight;
+            if(li->startShowItem > (li->numItems - li->curHeight)) {
+                li->startShowItem = li->numItems - li->curHeight;
+            }
+            li->currItem += li->curHeight;
+            if(li->currItem >= li->numItems) {
+                li->currItem = li->numItems - 1;
+            }
+            newtListboxRealSetCurrent(co);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case NEWT_KEY_HOME:
+            if(li->numItems <= 0) break;
+            newtListboxSetCurrent(co, 0);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case NEWT_KEY_END:
+            if(li->numItems <= 0) break;
+            li->startShowItem = li->numItems - li->curHeight;
+            if(li->startShowItem < 0)
+                li->startShowItem = 0;
+            li->currItem = li->numItems - 1;
+            newtListboxRealSetCurrent(co);
+            er.result = ER_SWALLOWED;
+            break;
+          default:
+              if (li->numItems <= 0) break;
               if (ev.u.key < NEWT_KEY_EXTRA_BASE && isalpha(ev.u.key)) {
-                 for(i = 0, item = li->boxItems; item != NULL &&
-                         i < li->currItem; i++, item = item->next);
-
-                 if (item && item->text && (toupper(*item->text) == toupper(ev.u.key))) {
-                     item = item->next;
-                     i++;
-                 } else { 
-                     item = li->boxItems;
-                     i = 0;
-                 }
-                 while (item && item->text &&
-                        toupper(*item->text) != toupper(ev.u.key)) {
-                     item = item->next;
-                     i++;
-                 }
-                 if (item) {
-                     li->currItem = i;
-                     if(li->currItem < li->startShowItem ||
-                        li->currItem > li->startShowItem)
-                         li->startShowItem =
-                             li->currItem > li->numItems - li->curHeight ?
-                             li->startShowItem = li->numItems - li->curHeight :
-                             li->currItem;
-                     if(li->sb)
-                         newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
-                     newtListboxRealSetCurrent(co);
-                     er.result = ER_SWALLOWED;
-                 }
-             }
-       }
-       break;
+                  for(i = 0, item = li->boxItems; item != NULL &&
+                          i < li->currItem; i++, item = item->next);
+
+                  if (item && item->text && (toupper(*item->text) == toupper(ev.u.key))) {
+                      item = item->next;
+                      i++;
+                  } else { 
+                      item = li->boxItems;
+                      i = 0;
+                  }
+                  while (item && item->text &&
+                         toupper(*item->text) != toupper(ev.u.key)) {
+                      item = item->next;
+                      i++;
+                  }
+                  if (item) {
+                      li->currItem = i;
+                      if(li->currItem < li->startShowItem ||
+                         li->currItem > li->startShowItem)
+                          li->startShowItem =
+                              li->currItem > li->numItems - li->curHeight ?
+                              li->startShowItem = li->numItems - li->curHeight :
+                              li->currItem;
+                      if(li->sb)
+                          newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
+                      newtListboxRealSetCurrent(co);
+                      er.result = ER_SWALLOWED;
+                  }
+              }
+        }
+        break;
 
       case EV_FOCUS:
-       li->isActive = 1;
-       listboxDraw(co);
-       if(li->flags & NEWT_FLAG_SHOWCURSOR)
-         newtCursorOn();
-       er.result = ER_SWALLOWED;
-       break;
+        li->isActive = 1;
+        listboxDraw(co);
+        if(li->flags & NEWT_FLAG_SHOWCURSOR)
+          newtCursorOn();
+        er.result = ER_SWALLOWED;
+        break;
 
       case EV_UNFOCUS:
-       li->isActive = 0;
-       listboxDraw(co);
-       if(li->flags & NEWT_FLAG_SHOWCURSOR)
-         newtCursorOff();
-       er.result = ER_SWALLOWED;
-       break;
+        li->isActive = 0;
+        listboxDraw(co);
+        if(li->flags & NEWT_FLAG_SHOWCURSOR)
+          newtCursorOff();
+        er.result = ER_SWALLOWED;
+        break;
 
       case EV_MOUSE:
-         /* if this mouse click was within the listbox, make the current
-            item the item clicked on. */
-       /* Up scroll arrow */
-       if (li->sb &&
-           ev.u.mouse.x == co->left + co->width - li->bdxAdjust - 1 &&
-           ev.u.mouse.y == co->top + li->bdyAdjust) {
-           if(li->numItems <= 0) break;
-           if(li->currItem > 0) {
-               li->currItem--;
-               if(li->currItem < li->startShowItem)
-                   li->startShowItem = li->currItem;
-               if(li->sb)
-                   newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
-               listboxDraw(co);
-           }
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           break;
-       }
-       /* Down scroll arrow */
-       if (li->sb &&
-           ev.u.mouse.x == co->left + co->width - li->bdxAdjust - 1 &&
-           ev.u.mouse.y == co->top + co->height - li->bdyAdjust - 1) {
-           if(li->numItems <= 0) break;
-           if(li->currItem < li->numItems - 1) {
-               li->currItem++;
-               if(li->currItem > (li->startShowItem + li->curHeight - 1)) {
-                   li->startShowItem = li->currItem - li->curHeight + 1;
-                   if(li->startShowItem + li->curHeight > li->numItems)
-                       li->startShowItem = li->numItems - li->curHeight;
-               }
-               if(li->sb)
-                   newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
-               listboxDraw(co);
-           }
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           break;
-       }
-       if ((ev.u.mouse.y >= co->top + li->bdyAdjust) &&
-           (ev.u.mouse.y <= co->top + co->height - (li->bdyAdjust * 2)) &&
-           (ev.u.mouse.x >= co->left + li->bdxAdjust) &&
-           (ev.u.mouse.x <= co->left + co->width + (li->bdxAdjust * 2))) {
-           li->currItem = li->startShowItem +
-               (ev.u.mouse.y - li->bdyAdjust - co->top);
-           newtListboxRealSetCurrent(co);
-           listboxDraw(co);
-           if(co->callback) co->callback(co, co->callbackData);
-           er.result = ER_SWALLOWED;
-           break;
-       }
+          /* if this mouse click was within the listbox, make the current
+             item the item clicked on. */
+        /* Up scroll arrow */
+        if (li->sb &&
+            ev.u.mouse.x == co->left + co->width - li->bdxAdjust - 1 &&
+            ev.u.mouse.y == co->top + li->bdyAdjust) {
+            if(li->numItems <= 0) break;
+            if(li->currItem > 0) {
+                li->currItem--;
+                if(li->currItem < li->startShowItem)
+                    li->startShowItem = li->currItem;
+                if(li->sb)
+                    newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
+                listboxDraw(co);
+            }
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            break;
+        }
+        /* Down scroll arrow */
+        if (li->sb &&
+            ev.u.mouse.x == co->left + co->width - li->bdxAdjust - 1 &&
+            ev.u.mouse.y == co->top + co->height - li->bdyAdjust - 1) {
+            if(li->numItems <= 0) break;
+            if(li->currItem < li->numItems - 1) {
+                li->currItem++;
+                if(li->currItem > (li->startShowItem + li->curHeight - 1)) {
+                    li->startShowItem = li->currItem - li->curHeight + 1;
+                    if(li->startShowItem + li->curHeight > li->numItems)
+                        li->startShowItem = li->numItems - li->curHeight;
+                }
+                if(li->sb)
+                    newtScrollbarSet(li->sb, li->currItem + 1, li->numItems);
+                listboxDraw(co);
+            }
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            break;
+        }
+        if ((ev.u.mouse.y >= co->top + li->bdyAdjust) &&
+            (ev.u.mouse.y <= co->top + co->height - (li->bdyAdjust * 2)) &&
+            (ev.u.mouse.x >= co->left + li->bdxAdjust) &&
+            (ev.u.mouse.x <= co->left + co->width + (li->bdxAdjust * 2))) {
+            li->currItem = li->startShowItem +
+                (ev.u.mouse.y - li->bdyAdjust - co->top);
+            newtListboxRealSetCurrent(co);
+            listboxDraw(co);
+            if(co->callback) co->callback(co, co->callbackData);
+            er.result = ER_SWALLOWED;
+            break;
+        }
     }
 
     return er;
@@ -752,10 +752,10 @@ static void listboxDestroy(newtComponent co) {
     nextitem = item = li->boxItems;
 
     while (item != NULL) {
-       nextitem = item->next;
-       free(item->text);
-       free(item);
-       item = nextitem;
+        nextitem = item->next;
+        free(item->text);
+        free(item);
+        item = nextitem;
     }
 
     if (li->sb) li->sb->ops->destroy(li->sb);
diff --git a/newt.c b/newt.c
index 4cc22d0507eca8084136aacbe7f3213e4af45f11..ed7c9c94a3da388365d30ab46416bcb3bc59f55b 100644 (file)
--- a/newt.c
+++ b/newt.c
@@ -46,81 +46,81 @@ static const char * defaultHelpLine =
 ;
 
 const struct newtColors newtDefaultColorPalette = {
-       "white", "blue",                        /* root fg, bg */
-       "black", "lightgray",                   /* border fg, bg */
-       "black", "lightgray",                   /* window fg, bg */
-       "white", "black",                       /* shadow fg, bg */
-       "red", "lightgray",                     /* title fg, bg */
-       "lightgray", "red",                     /* button fg, bg */
-       "red", "lightgray",                     /* active button fg, bg */
-       "yellow", "blue",                       /* checkbox fg, bg */
-       "blue", "brown",                        /* active checkbox fg, bg */
-       "yellow", "blue",                       /* entry box fg, bg */
-       "blue", "lightgray",                    /* label fg, bg */
-       "black", "lightgray",                   /* listbox fg, bg */
-       "yellow", "blue",                       /* active listbox fg, bg */
-       "black", "lightgray",                   /* textbox fg, bg */
-       "lightgray", "black",                   /* active textbox fg, bg */
-       "white", "blue",                        /* help line */
-       "yellow", "blue",                       /* root text */
-       "blue",                                 /* scale full */
-       "red",                                  /* scale empty */
-       "blue", "lightgray",                    /* disabled entry fg, bg */
-       "white", "blue",                        /* compact button fg, bg */
-       "yellow", "red",                        /* active & sel listbox */
-       "black", "brown"                        /* selected listbox */
+        "white", "blue",                        /* root fg, bg */
+        "black", "lightgray",                   /* border fg, bg */
+        "black", "lightgray",                   /* window fg, bg */
+        "white", "black",                       /* shadow fg, bg */
+        "red", "lightgray",                     /* title fg, bg */
+        "lightgray", "red",                     /* button fg, bg */
+        "red", "lightgray",                     /* active button fg, bg */
+        "yellow", "blue",                       /* checkbox fg, bg */
+        "blue", "brown",                        /* active checkbox fg, bg */
+        "yellow", "blue",                       /* entry box fg, bg */
+        "blue", "lightgray",                    /* label fg, bg */
+        "black", "lightgray",                   /* listbox fg, bg */
+        "yellow", "blue",                       /* active listbox fg, bg */
+        "black", "lightgray",                   /* textbox fg, bg */
+        "lightgray", "black",                   /* active textbox fg, bg */
+        "white", "blue",                        /* help line */
+        "yellow", "blue",                       /* root text */
+        "blue",                                 /* scale full */
+        "red",                                  /* scale empty */
+        "blue", "lightgray",                    /* disabled entry fg, bg */
+        "white", "blue",                        /* compact button fg, bg */
+        "yellow", "red",                        /* active & sel listbox */
+        "black", "brown"                        /* selected listbox */
 };
 
 static const struct keymap keymap[] = {
-       { "\033OA",             NEWT_KEY_UP,            "kh" },
-       { "\033[A",             NEWT_KEY_UP,            "ku" },
-       { "\033OB",             NEWT_KEY_DOWN,          "kd" },
-       { "\033[B",             NEWT_KEY_DOWN,          "kd" },
-       { "\033[C",             NEWT_KEY_RIGHT,         "kr" },
-       { "\033OC",             NEWT_KEY_RIGHT,         "kr" },
-       { "\033[D",             NEWT_KEY_LEFT,          "kl" },
-       { "\033OD",             NEWT_KEY_LEFT,          "kl" },
-       { "\033[H",             NEWT_KEY_HOME,          "kh" },
-       { "\033[1~",            NEWT_KEY_HOME,          "kh" },
-       { "\033Ow",             NEWT_KEY_END,           "kH" },
-       { "\033[4~",            NEWT_KEY_END,           "kH" },
-
-       { "\033[3~",            NEWT_KEY_DELETE,        "kl" },
-       { "\033[2~",            NEWT_KEY_INSERT,        NULL },
-
-       { "\033\t",             NEWT_KEY_UNTAB,         NULL },
-
-       { "\033[5~",            NEWT_KEY_PGUP,          NULL },
-       { "\033[6~",            NEWT_KEY_PGDN,          NULL },
-       { "\033V",              NEWT_KEY_PGUP,          "kH" },
-       { "\033v",              NEWT_KEY_PGUP,          "kH" },
-
-       { "\033[[A",            NEWT_KEY_F1,            NULL },
-       { "\033[[B",            NEWT_KEY_F2,            NULL },
-       { "\033[[C",            NEWT_KEY_F3,            NULL },
-       { "\033[[D",            NEWT_KEY_F4,            NULL },
-       { "\033[[E",            NEWT_KEY_F5,            NULL },
-
-       { "\033OP",             NEWT_KEY_F1,            NULL },
-       { "\033OQ",             NEWT_KEY_F2,            NULL },
-       { "\033OR",             NEWT_KEY_F3,            NULL },
-       { "\033OS",             NEWT_KEY_F4,            NULL },
-
-       { "\033[11~",           NEWT_KEY_F1,            NULL },
-       { "\033[12~",           NEWT_KEY_F2,            NULL },
-       { "\033[13~",           NEWT_KEY_F3,            NULL },
-       { "\033[14~",           NEWT_KEY_F4,            NULL },
-       { "\033[15~",           NEWT_KEY_F5,            NULL },
-       { "\033[17~",           NEWT_KEY_F6,            NULL },
-       { "\033[18~",           NEWT_KEY_F7,            NULL },
-       { "\033[19~",           NEWT_KEY_F8,            NULL },
-       { "\033[20~",           NEWT_KEY_F9,            NULL },
-       { "\033[21~",           NEWT_KEY_F10,           NULL },
-       { "\033[23~",           NEWT_KEY_F11,           NULL },
-       { "\033[24~",           NEWT_KEY_F12,           NULL },
-       { "\033",               NEWT_KEY_ESCAPE,        NULL },
-
-       { 0 },  /* LEAVE this one */
+        { "\033OA",             NEWT_KEY_UP,            "kh" },
+        { "\033[A",             NEWT_KEY_UP,            "ku" },
+        { "\033OB",             NEWT_KEY_DOWN,          "kd" },
+        { "\033[B",             NEWT_KEY_DOWN,          "kd" },
+        { "\033[C",             NEWT_KEY_RIGHT,         "kr" },
+        { "\033OC",             NEWT_KEY_RIGHT,         "kr" },
+        { "\033[D",             NEWT_KEY_LEFT,          "kl" },
+        { "\033OD",             NEWT_KEY_LEFT,          "kl" },
+        { "\033[H",             NEWT_KEY_HOME,          "kh" },
+        { "\033[1~",            NEWT_KEY_HOME,          "kh" },
+        { "\033Ow",             NEWT_KEY_END,           "kH" },
+        { "\033[4~",            NEWT_KEY_END,           "kH" },
+
+        { "\033[3~",            NEWT_KEY_DELETE,        "kl" },
+        { "\033[2~",            NEWT_KEY_INSERT,        NULL },
+
+        { "\033\t",             NEWT_KEY_UNTAB,         NULL },
+
+        { "\033[5~",            NEWT_KEY_PGUP,          NULL },
+        { "\033[6~",            NEWT_KEY_PGDN,          NULL },
+        { "\033V",              NEWT_KEY_PGUP,          "kH" },
+        { "\033v",              NEWT_KEY_PGUP,          "kH" },
+
+        { "\033[[A",            NEWT_KEY_F1,            NULL },
+        { "\033[[B",            NEWT_KEY_F2,            NULL },
+        { "\033[[C",            NEWT_KEY_F3,            NULL },
+        { "\033[[D",            NEWT_KEY_F4,            NULL },
+        { "\033[[E",            NEWT_KEY_F5,            NULL },
+
+        { "\033OP",             NEWT_KEY_F1,            NULL },
+        { "\033OQ",             NEWT_KEY_F2,            NULL },
+        { "\033OR",             NEWT_KEY_F3,            NULL },
+        { "\033OS",             NEWT_KEY_F4,            NULL },
+
+        { "\033[11~",           NEWT_KEY_F1,            NULL },
+        { "\033[12~",           NEWT_KEY_F2,            NULL },
+        { "\033[13~",           NEWT_KEY_F3,            NULL },
+        { "\033[14~",           NEWT_KEY_F4,            NULL },
+        { "\033[15~",           NEWT_KEY_F5,            NULL },
+        { "\033[17~",           NEWT_KEY_F6,            NULL },
+        { "\033[18~",           NEWT_KEY_F7,            NULL },
+        { "\033[19~",           NEWT_KEY_F8,            NULL },
+        { "\033[20~",           NEWT_KEY_F9,            NULL },
+        { "\033[21~",           NEWT_KEY_F10,           NULL },
+        { "\033[23~",           NEWT_KEY_F11,           NULL },
+        { "\033[24~",           NEWT_KEY_F12,           NULL },
+        { "\033",               NEWT_KEY_ESCAPE,        NULL },
+
+        { 0 },  /* LEAVE this one */
 };
 static char keyPrefix = '\033';
 
@@ -146,27 +146,27 @@ static int getkeyInterruptHook(void) {
 }
 
 int wstrlen(const char *str, int len) {
-       mbstate_t ps;
-       wchar_t tmp;
-       int nchars = 0;
-       
-       if (!str) return 0;
-       if (!len) return 0;
-       if (len < 0) len = strlen(str);
-       memset(&ps,0,sizeof(mbstate_t));
-       while (len > 0) {
-               int x,y;
-               
-               x = mbrtowc(&tmp,str,len,&ps);
-               if (x >0) {
-                       str += x;
-                       len -= x;
-                       y = wcwidth(tmp);
-                       if (y>0)
-                         nchars+=y;
-               } else break;
-       }
-       return nchars;
+        mbstate_t ps;
+        wchar_t tmp;
+        int nchars = 0;
+        
+        if (!str) return 0;
+        if (!len) return 0;
+        if (len < 0) len = strlen(str);
+        memset(&ps,0,sizeof(mbstate_t));
+        while (len > 0) {
+                int x,y;
+                
+                x = mbrtowc(&tmp,str,len,&ps);
+                if (x >0) {
+                        str += x;
+                        len -= x;
+                        y = wcwidth(tmp);
+                        if (y>0)
+                          nchars+=y;
+                } else break;
+        }
+        return nchars;
 }
 
 static int getkey() {
@@ -182,7 +182,7 @@ static int getkey() {
 
 void newtFlushInput(void) {
     while (SLang_input_pending(0)) {
-       getkey();
+        getkey();
     }
 }
 
@@ -245,7 +245,7 @@ int newtInit(void) {
             if ((lang = getenv("LANG")) == NULL)
                 lang = "";
     if (strstr (lang, ".euc") != NULL)
-       trashScreen = 1;
+        trashScreen = 1;
 
     (void) strlen(ident);
 
@@ -254,15 +254,15 @@ int newtInit(void) {
 
     MonoValue = getenv(MonoEnv);
     if ( MonoValue == NULL ) {
-       SLtt_Use_Ansi_Colors = 1;
+        SLtt_Use_Ansi_Colors = 1;
     } else {
-       SLtt_Use_Ansi_Colors = 0;
+        SLtt_Use_Ansi_Colors = 0;
     }
 
     if ((ret = SLsmg_init_smg()) < 0)
-       return ret;
+        return ret;
     if ((ret = SLang_init_tty(0, 0, 0)) < 0)
-       return ret;
+        return ret;
 
     newtSetColors(newtDefaultColorPalette);
     newtCursorOff();
@@ -324,40 +324,40 @@ void newtSetColors(struct newtColors colors) {
     SLtt_set_color(NEWT_COLORSET_TITLE, "", colors.titleFg, colors.titleBg);
     SLtt_set_color(NEWT_COLORSET_BUTTON, "", colors.buttonFg, colors.buttonBg);
     SLtt_set_color(NEWT_COLORSET_ACTBUTTON, "", colors.actButtonFg,
-                       colors.actButtonBg);
+                        colors.actButtonBg);
     SLtt_set_color(NEWT_COLORSET_CHECKBOX, "", colors.checkboxFg,
-                       colors.checkboxBg);
+                        colors.checkboxBg);
     SLtt_set_color(NEWT_COLORSET_ACTCHECKBOX, "", colors.actCheckboxFg,
-                       colors.actCheckboxBg);
+                        colors.actCheckboxBg);
     SLtt_set_color(NEWT_COLORSET_ENTRY, "", colors.entryFg, colors.entryBg);
     SLtt_set_color(NEWT_COLORSET_LABEL, "", colors.labelFg, colors.labelBg);
     SLtt_set_color(NEWT_COLORSET_LISTBOX, "", colors.listboxFg,
-                       colors.listboxBg);
+                        colors.listboxBg);
     SLtt_set_color(NEWT_COLORSET_ACTLISTBOX, "", colors.actListboxFg,
-                       colors.actListboxBg);
+                        colors.actListboxBg);
     SLtt_set_color(NEWT_COLORSET_TEXTBOX, "", colors.textboxFg,
-                       colors.textboxBg);
+                        colors.textboxBg);
     SLtt_set_color(NEWT_COLORSET_ACTTEXTBOX, "", colors.actTextboxFg,
-                       colors.actTextboxBg);
+                        colors.actTextboxBg);
     SLtt_set_color(NEWT_COLORSET_HELPLINE, "", colors.helpLineFg,
-                       colors.helpLineBg);
+                        colors.helpLineBg);
     SLtt_set_color(NEWT_COLORSET_ROOTTEXT, "", colors.rootTextFg,
-                       colors.rootTextBg);
+                        colors.rootTextBg);
 
     SLtt_set_color(NEWT_COLORSET_EMPTYSCALE, "", "white",
-                       colors.emptyScale);
+                        colors.emptyScale);
     SLtt_set_color(NEWT_COLORSET_FULLSCALE, "", "white",
-                       colors.fullScale);
+                        colors.fullScale);
     SLtt_set_color(NEWT_COLORSET_DISENTRY, "", colors.disabledEntryFg,
-                       colors.disabledEntryBg);
+                        colors.disabledEntryBg);
 
     SLtt_set_color(NEWT_COLORSET_COMPACTBUTTON, "", colors.compactButtonFg,
-                       colors.compactButtonBg);
+                        colors.compactButtonBg);
 
     SLtt_set_color(NEWT_COLORSET_ACTSELLISTBOX, "", colors.actSelListboxFg,
-                  colors.actSelListboxBg);
+                   colors.actSelListboxBg);
     SLtt_set_color(NEWT_COLORSET_SELLISTBOX, "", colors.selListboxFg,
-                  colors.selListboxBg);
+                   colors.selListboxBg);
 }
 
 int newtGetKey(void) {
@@ -366,76 +366,76 @@ int newtGetKey(void) {
     const struct keymap * curr;
 
     do {
-       key = getkey();
-       if (key == SLANG_GETKEY_ERROR) {
-           /* Either garbage was read, or stdin disappeared
-            * (the parent terminal was proably closed)
-            * if the latter, die.
-            */
-           if (feof(stdin))
-                   exit(1);
-           if (needResize) {
+        key = getkey();
+        if (key == SLANG_GETKEY_ERROR) {
+            /* Either garbage was read, or stdin disappeared
+             * (the parent terminal was proably closed)
+             * if the latter, die.
+             */
+            if (feof(stdin))
+                    exit(1);
+            if (needResize) {
                 needResize = 0;
-               return NEWT_KEY_RESIZE;
+                return NEWT_KEY_RESIZE;
             }
 
-           /* ignore other signals */
-           continue;
-       }
+            /* ignore other signals */
+            continue;
+        }
 
-       if (key == NEWT_KEY_SUSPEND && suspendCallback)
-           suspendCallback(suspendCallbackData);
+        if (key == NEWT_KEY_SUSPEND && suspendCallback)
+            suspendCallback(suspendCallbackData);
     } while (key == NEWT_KEY_SUSPEND);
 
     switch (key) {
       case 'v' | 0x80:
       case 'V' | 0x80:
-       return NEWT_KEY_PGUP;
+        return NEWT_KEY_PGUP;
 
       case 22:
-       return NEWT_KEY_PGDN;
+        return NEWT_KEY_PGDN;
 
-       return NEWT_KEY_BKSPC;
+        return NEWT_KEY_BKSPC;
       case 0x7f:
-       return NEWT_KEY_BKSPC;
+        return NEWT_KEY_BKSPC;
 
       case 0x08:
-       return NEWT_KEY_BKSPC;
+        return NEWT_KEY_BKSPC;
 
       default:
-       if (key != keyPrefix) return key;
+        if (key != keyPrefix) return key;
     }
 
     memset(buf, 0, sizeof(buf));
 
     *chptr++ = key;
     while (SLang_input_pending(5)) {
-       key = getkey();
-       if (key == keyPrefix) {
-           /* he hit unknown keys too many times -- start over */
-           memset(buf, 0, sizeof(buf));
-           chptr = buf;
-       }
-
-       *chptr++ = key;
-
-       /* this search should use bsearch(), but when we only look through
-          a list of 20 (or so) keymappings, it's probably faster just to
-          do a inline linear search */
-
-       for (curr = keymap; curr->code; curr++) {
-           if (curr->str) {
-               if (!strcmp(curr->str, buf))
-                   return curr->code;
-           }
-       }
+        key = getkey();
+        if (key == keyPrefix) {
+            /* he hit unknown keys too many times -- start over */
+            memset(buf, 0, sizeof(buf));
+            chptr = buf;
+        }
+
+        *chptr++ = key;
+
+        /* this search should use bsearch(), but when we only look through
+           a list of 20 (or so) keymappings, it's probably faster just to
+           do a inline linear search */
+
+        for (curr = keymap; curr->code; curr++) {
+            if (curr->str) {
+                if (!strcmp(curr->str, buf))
+                    return curr->code;
+            }
+        }
     }
 
     for (curr = keymap; curr->code; curr++) {
-       if (curr->str) {
-           if (!strcmp(curr->str, buf))
-               return curr->code;
-       }
+        if (curr->str) {
+            if (!strcmp(curr->str, buf))
+                return curr->code;
+        }
     }
 
     /* Looks like we were a bit overzealous in reading characters. Return
@@ -444,7 +444,7 @@ int newtGetKey(void) {
 
     chptr--;
     while (chptr > buf)
-       SLang_ungetkey(*chptr--);
+        SLang_ungetkey(*chptr--);
 
     return *chptr;
 }
@@ -464,7 +464,7 @@ void newtWaitForKey(void) {
  */
 void newtClearKeyBuffer(void) {
     while (SLang_input_pending(1)) {
-       getkey();
+        getkey();
     }
 }
 
@@ -478,7 +478,7 @@ void newtClearKeyBuffer(void) {
  * @return zero on success (currently no errors reported)
  */
 int newtOpenWindow(unsigned left, unsigned top, unsigned width, unsigned height,
-                         const char * title) {
+                          const char * title) {
     int j, row, col;
     int n;
     int i;
@@ -486,9 +486,9 @@ int newtOpenWindow(unsigned left, unsigned top, unsigned width, unsigned height,
     newtFlushInput();
 
     if (!currentWindow) {
-       currentWindow = windowStack;
+        currentWindow = windowStack;
     } else {
-       currentWindow++;
+        currentWindow++;
     }
 
     currentWindow->left = left;
@@ -503,19 +503,19 @@ int newtOpenWindow(unsigned left, unsigned top, unsigned width, unsigned height,
     col = left - 1;
     /* clip to the current screen bounds - msw */
     if (row < 0)
-       row = 0;
+        row = 0;
     if (col < 0)
-       col = 0;
+        col = 0;
     if (left + width > SLtt_Screen_Cols)
-       width = SLtt_Screen_Cols - left;
+        width = SLtt_Screen_Cols - left;
     if (top + height > SLtt_Screen_Rows)
-       height = SLtt_Screen_Rows - top;
+        height = SLtt_Screen_Rows - top;
     n = 0;
     for (j = 0; j < height + 3; j++, row++) {
-       SLsmg_gotorc(row, col);
-       SLsmg_read_raw(currentWindow->buffer + n,
-                      currentWindow->width + 3);
-       n += currentWindow->width + 3;
+        SLsmg_gotorc(row, col);
+        SLsmg_read_raw(currentWindow->buffer + n,
+                       currentWindow->width + 3);
+        n += currentWindow->width + 3;
     }
 
     newtTrashScreen();
@@ -524,20 +524,20 @@ int newtOpenWindow(unsigned left, unsigned top, unsigned width, unsigned height,
     SLsmg_draw_box(top - 1, left - 1, height + 2, width + 2);
 
     if (currentWindow->title) {
-       i = wstrlen(currentWindow->title,-1) + 4;
-       i = ((width - i) / 2) + left;
-       SLsmg_gotorc(top - 1, i);
-       SLsmg_set_char_set(1);
-       SLsmg_write_char(SLSMG_RTEE_CHAR);
-       SLsmg_set_char_set(0);
-       SLsmg_write_char(' ');
-       SLsmg_set_color(NEWT_COLORSET_TITLE);
-       SLsmg_write_string((char *)currentWindow->title);
-       SLsmg_set_color(NEWT_COLORSET_BORDER);
-       SLsmg_write_char(' ');
-       SLsmg_set_char_set(1);
-       SLsmg_write_char(SLSMG_LTEE_CHAR);
-       SLsmg_set_char_set(0);
+        i = wstrlen(currentWindow->title,-1) + 4;
+        i = ((width - i) / 2) + left;
+        SLsmg_gotorc(top - 1, i);
+        SLsmg_set_char_set(1);
+        SLsmg_write_char(SLSMG_RTEE_CHAR);
+        SLsmg_set_char_set(0);
+        SLsmg_write_char(' ');
+        SLsmg_set_color(NEWT_COLORSET_TITLE);
+        SLsmg_write_string((char *)currentWindow->title);
+        SLsmg_set_color(NEWT_COLORSET_BORDER);
+        SLsmg_write_char(' ');
+        SLsmg_set_char_set(1);
+        SLsmg_write_char(SLSMG_LTEE_CHAR);
+        SLsmg_set_char_set(0);
     }
 
     SLsmg_set_color(NEWT_COLORSET_WINDOW);
@@ -548,8 +548,8 @@ int newtOpenWindow(unsigned left, unsigned top, unsigned width, unsigned height,
     SLsmg_fill_region(top, left + width + 1, height + 1, 1, ' ');
 
     for (i = top; i < (top + height + 1); i++) {
-       SLsmg_gotorc(i, left + width + 1);
-       SLsmg_write_string(" ");
+        SLsmg_gotorc(i, left + width + 1);
+        SLsmg_write_string(" ");
     }
 
     return 0;
@@ -589,23 +589,23 @@ void newtPopWindow(void) {
     row = currentWindow->top - 1;
     col = currentWindow->left - 1;
     if (row < 0)
-       row = 0;
+        row = 0;
     if (col < 0)
-       col = 0;
+        col = 0;
     for (j = 0; j < currentWindow->height + 3; j++, row++) {
-       SLsmg_gotorc(row, col);
-       SLsmg_write_raw(currentWindow->buffer + n,
-                       currentWindow->width + 3);
-       n += currentWindow->width + 3;
+        SLsmg_gotorc(row, col);
+        SLsmg_write_raw(currentWindow->buffer + n,
+                        currentWindow->width + 3);
+        n += currentWindow->width + 3;
     }
 
     free(currentWindow->buffer);
     free(currentWindow->title);
 
     if (currentWindow == windowStack)
-       currentWindow = NULL;
+        currentWindow = NULL;
     else
-       currentWindow--;
+        currentWindow--;
 
     SLsmg_set_char_set(0);
 
@@ -616,10 +616,10 @@ void newtPopWindow(void) {
 
 void newtGetWindowPos(int * x, int * y) {
     if (currentWindow) {
-       *x = currentWindow->left;
-       *y = currentWindow->top;
+        *x = currentWindow->left;
+        *y = currentWindow->top;
     } else
-       *x = *y = 0;
+        *x = *y = 0;
 }
 
 void newtGetrc(int * row, int * col) {
@@ -629,8 +629,8 @@ void newtGetrc(int * row, int * col) {
 
 void newtGotorc(int newRow, int newCol) {
     if (currentWindow) {
-       newRow += currentWindow->top;
-       newCol += currentWindow->left;
+        newRow += currentWindow->top;
+        newCol += currentWindow->left;
     }
 
     cursorRow = newRow;
@@ -640,23 +640,23 @@ void newtGotorc(int newRow, int newCol) {
 
 void newtDrawBox(int left, int top, int width, int height, int shadow) {
     if (currentWindow) {
-       top += currentWindow->top;
-       left += currentWindow->left;
+        top += currentWindow->top;
+        left += currentWindow->left;
     }
 
     SLsmg_draw_box(top, left, height, width);
 
     if (shadow) {
-       SLsmg_set_color(NEWT_COLORSET_SHADOW);
-       SLsmg_fill_region(top + height, left + 1, 1, width - 1, ' ');
-       SLsmg_fill_region(top + 1, left + width, height, 1, ' ');
+        SLsmg_set_color(NEWT_COLORSET_SHADOW);
+        SLsmg_fill_region(top + height, left + 1, 1, width - 1, ' ');
+        SLsmg_fill_region(top + 1, left + width, height, 1, ' ');
     }
 }
 
 void newtClearBox(int left, int top, int width, int height) {
     if (currentWindow) {
-       top += currentWindow->top;
-       left += currentWindow->left;
+        top += currentWindow->top;
+        left += currentWindow->left;
     }
 
     SLsmg_fill_region(top, left, height, width, ' ');
@@ -670,8 +670,8 @@ static void initKeymap(void) {
     struct keymap * curr;
 
     for (curr = keymap; curr->code; curr++) {
-       if (!curr->str)
-           curr->str = SLtt_tgetstr(curr->tc);
+        if (!curr->str)
+            curr->str = SLtt_tgetstr(curr->tc);
     }
 
     /* Newt's keymap handling is a bit broken. It assumes that any extended
@@ -679,7 +679,7 @@ static void initKeymap(void) {
        will probably need to fix this, or just yell at me and I'll be so
        ashamed of myself for doing it this way I'll fix it */
 
-    keyPrefix = 0x1b;          /* ESC */
+    keyPrefix = 0x1b;           /* ESC */
 }
 #endif
 
@@ -700,7 +700,7 @@ void newtDelay(unsigned usecs) {
 }
 
 struct eventResult newtDefaultEventHandler(newtComponent c,
-                                          struct event ev) {
+                                           struct event ev) {
     struct eventResult er;
 
     er.result = ER_IGNORED;
@@ -713,22 +713,22 @@ void newtRedrawHelpLine(void) {
     SLsmg_set_color(NEWT_COLORSET_HELPLINE);
 
     if (currentHelpline) {
-       /* buffer size needs to be wide enough to hold all the multibyte
-          currentHelpline + all the single byte ' ' to fill the line */
-       int wlen = wstrlen(*currentHelpline, -1);
-       int len;
-
-       if (wlen > SLtt_Screen_Cols)
-           wlen = SLtt_Screen_Cols;
-       len = strlen(*currentHelpline) + (SLtt_Screen_Cols - wlen);
-       buf = alloca(len + 1);
-       memset(buf, ' ', len);
-       memcpy(buf, *currentHelpline, strlen(*currentHelpline));
-       buf[len] = '\0';
+        /* buffer size needs to be wide enough to hold all the multibyte
+           currentHelpline + all the single byte ' ' to fill the line */
+        int wlen = wstrlen(*currentHelpline, -1);
+        int len;
+
+        if (wlen > SLtt_Screen_Cols)
+            wlen = SLtt_Screen_Cols;
+        len = strlen(*currentHelpline) + (SLtt_Screen_Cols - wlen);
+        buf = alloca(len + 1);
+        memset(buf, ' ', len);
+        memcpy(buf, *currentHelpline, strlen(*currentHelpline));
+        buf[len] = '\0';
     } else {
-       buf = alloca(SLtt_Screen_Cols + 1);
-       memset(buf, ' ', SLtt_Screen_Cols);
-       buf[SLtt_Screen_Cols] = '\0';
+        buf = alloca(SLtt_Screen_Cols + 1);
+        memset(buf, ' ', SLtt_Screen_Cols);
+        buf[SLtt_Screen_Cols] = '\0';
     }
     SLsmg_gotorc(SLtt_Screen_Rows - 1, 0);
     SLsmg_write_string(buf);
@@ -736,13 +736,13 @@ void newtRedrawHelpLine(void) {
 
 void newtPushHelpLine(const char * text) {
     if (!text)
-       text = defaultHelpLine;
+        text = defaultHelpLine;
 
     if (currentHelpline)
-       (*(++currentHelpline)) = strdup(text);
+        (*(++currentHelpline)) = strdup(text);
     else {
-       currentHelpline = helplineStack;
-       *currentHelpline = strdup(text);
+        currentHelpline = helplineStack;
+        *currentHelpline = strdup(text);
     }
 
     newtRedrawHelpLine();
@@ -753,9 +753,9 @@ void newtPopHelpLine(void) {
 
     free(*currentHelpline);
     if (currentHelpline == helplineStack)
-       currentHelpline = NULL;
+        currentHelpline = NULL;
     else
-       currentHelpline--;
+        currentHelpline--;
 
     newtRedrawHelpLine();
 }
@@ -764,11 +764,11 @@ void newtDrawRootText(int col, int row, const char * text) {
     SLsmg_set_color(NEWT_COLORSET_ROOTTEXT);
 
     if (col < 0) {
-       col = SLtt_Screen_Cols + col;
+        col = SLtt_Screen_Cols + col;
     }
 
     if (row < 0) {
-       row = SLtt_Screen_Rows + row;
+        row = SLtt_Screen_Rows + row;
     }
 
     SLsmg_gotorc(row, col);
@@ -778,16 +778,16 @@ void newtDrawRootText(int col, int row, const char * text) {
 int newtSetFlags(int oldFlags, int newFlags, enum newtFlagsSense sense) {
     switch (sense) {
       case NEWT_FLAGS_SET:
-       return oldFlags | newFlags;
+        return oldFlags | newFlags;
 
       case NEWT_FLAGS_RESET:
-       return oldFlags & (~newFlags);
+        return oldFlags & (~newFlags);
 
       case NEWT_FLAGS_TOGGLE:
-       return oldFlags ^ newFlags;
+        return oldFlags ^ newFlags;
 
       default:
-       return oldFlags;
+        return oldFlags;
     }
 }
 
@@ -822,6 +822,6 @@ void newtCursorOn(void) {
 
 void newtTrashScreen(void) {
     if (trashScreen)
-       SLsmg_touch_lines (0, SLtt_Screen_Rows - 1);
+        SLsmg_touch_lines (0, SLtt_Screen_Rows - 1);
 }
      
diff --git a/newt.h b/newt.h
index b179da105f556307c03f0030c3f387f28e9a2937..9ae596dbab27e366b26245774cc838c0037ac5f8 100644 (file)
--- a/newt.h
+++ b/newt.h
@@ -7,32 +7,32 @@ extern "C" {
 
 #include <stdarg.h>
 
-#define NEWT_COLORSET_ROOT             2
-#define NEWT_COLORSET_BORDER           3
-#define NEWT_COLORSET_WINDOW           4
-#define NEWT_COLORSET_SHADOW           5
-#define NEWT_COLORSET_TITLE            6
-#define NEWT_COLORSET_BUTTON           7
-#define NEWT_COLORSET_ACTBUTTON                8
-#define NEWT_COLORSET_CHECKBOX         9
-#define NEWT_COLORSET_ACTCHECKBOX      10
-#define NEWT_COLORSET_ENTRY            11
-#define NEWT_COLORSET_LABEL            12
-#define NEWT_COLORSET_LISTBOX          13
-#define NEWT_COLORSET_ACTLISTBOX       14
-#define NEWT_COLORSET_TEXTBOX          15
-#define NEWT_COLORSET_ACTTEXTBOX       16
-#define NEWT_COLORSET_HELPLINE         17
-#define NEWT_COLORSET_ROOTTEXT         18
-#define NEWT_COLORSET_EMPTYSCALE       19
-#define NEWT_COLORSET_FULLSCALE                20
-#define NEWT_COLORSET_DISENTRY         21
-#define NEWT_COLORSET_COMPACTBUTTON    22
-#define NEWT_COLORSET_ACTSELLISTBOX    23
-#define NEWT_COLORSET_SELLISTBOX       24
-
-#define NEWT_ARG_LAST                  -100000
-#define NEWT_ARG_APPEND                        -1
+#define NEWT_COLORSET_ROOT              2
+#define NEWT_COLORSET_BORDER            3
+#define NEWT_COLORSET_WINDOW            4
+#define NEWT_COLORSET_SHADOW            5
+#define NEWT_COLORSET_TITLE             6
+#define NEWT_COLORSET_BUTTON            7
+#define NEWT_COLORSET_ACTBUTTON         8
+#define NEWT_COLORSET_CHECKBOX          9
+#define NEWT_COLORSET_ACTCHECKBOX       10
+#define NEWT_COLORSET_ENTRY             11
+#define NEWT_COLORSET_LABEL             12
+#define NEWT_COLORSET_LISTBOX           13
+#define NEWT_COLORSET_ACTLISTBOX        14
+#define NEWT_COLORSET_TEXTBOX           15
+#define NEWT_COLORSET_ACTTEXTBOX        16
+#define NEWT_COLORSET_HELPLINE          17
+#define NEWT_COLORSET_ROOTTEXT          18
+#define NEWT_COLORSET_EMPTYSCALE        19
+#define NEWT_COLORSET_FULLSCALE         20
+#define NEWT_COLORSET_DISENTRY          21
+#define NEWT_COLORSET_COMPACTBUTTON     22
+#define NEWT_COLORSET_ACTSELLISTBOX     23
+#define NEWT_COLORSET_SELLISTBOX        24
+
+#define NEWT_ARG_LAST                   -100000
+#define NEWT_ARG_APPEND                 -1
 
 struct newtColors {
     char * rootFg, * rootBg;
@@ -61,43 +61,43 @@ struct newtColors {
 
 enum newtFlagsSense { NEWT_FLAGS_SET, NEWT_FLAGS_RESET, NEWT_FLAGS_TOGGLE };
 
-#define NEWT_FLAG_RETURNEXIT   (1 << 0)
-#define NEWT_FLAG_HIDDEN       (1 << 1)
-#define NEWT_FLAG_SCROLL       (1 << 2)
-#define NEWT_FLAG_DISABLED     (1 << 3)
-/* OBSOLETE #define NEWT_FLAG_NOSCROLL         (1 << 4)        for listboxes */
-#define NEWT_FLAG_BORDER       (1 << 5)
-#define NEWT_FLAG_WRAP         (1 << 6)
-#define NEWT_FLAG_NOF12                (1 << 7)
+#define NEWT_FLAG_RETURNEXIT    (1 << 0)
+#define NEWT_FLAG_HIDDEN        (1 << 1)
+#define NEWT_FLAG_SCROLL        (1 << 2)
+#define NEWT_FLAG_DISABLED      (1 << 3)
+/* OBSOLETE #define NEWT_FLAG_NOSCROLL  (1 << 4)        for listboxes */
+#define NEWT_FLAG_BORDER        (1 << 5)
+#define NEWT_FLAG_WRAP          (1 << 6)
+#define NEWT_FLAG_NOF12         (1 << 7)
 #define NEWT_FLAG_MULTIPLE      (1 << 8)
-#define NEWT_FLAG_SELECTED     (1 << 9)
-#define NEWT_FLAG_CHECKBOX     (1 << 10)
+#define NEWT_FLAG_SELECTED      (1 << 9)
+#define NEWT_FLAG_CHECKBOX      (1 << 10)
 #define NEWT_FLAG_PASSWORD      (1 << 11)  /* draw '*'  of chars in entrybox */
 #define NEWT_FLAG_SHOWCURSOR    (1 << 12) /* Only applies to listbox for now */
-#define NEWT_FD_READ           (1 << 0)
-#define NEWT_FD_WRITE          (1 << 1)
-#define NEWT_FD_EXCEPT         (1 << 2)
+#define NEWT_FD_READ            (1 << 0)
+#define NEWT_FD_WRITE           (1 << 1)
+#define NEWT_FD_EXCEPT          (1 << 2)
 
-#define NEWT_CHECKBOXTREE_UNSELECTABLE (1 << 12)
-#define NEWT_CHECKBOXTREE_HIDE_BOX     (1 << 13)
+#define NEWT_CHECKBOXTREE_UNSELECTABLE  (1 << 12)
+#define NEWT_CHECKBOXTREE_HIDE_BOX      (1 << 13)
 
-#define NEWT_CHECKBOXTREE_COLLAPSED    '\0'
-#define NEWT_CHECKBOXTREE_EXPANDED     '\1'
-#define NEWT_CHECKBOXTREE_UNSELECTED   ' '
-#define NEWT_CHECKBOXTREE_SELECTED     '*'
+#define NEWT_CHECKBOXTREE_COLLAPSED     '\0'
+#define NEWT_CHECKBOXTREE_EXPANDED      '\1'
+#define NEWT_CHECKBOXTREE_UNSELECTED    ' '
+#define NEWT_CHECKBOXTREE_SELECTED      '*'
 
 /* Backwards compatibility */
 #define NEWT_LISTBOX_RETURNEXIT NEWT_FLAG_RETURNEXIT
-#define NEWT_ENTRY_SCROLL      NEWT_FLAG_SCROLL
-#define NEWT_ENTRY_HIDDEN      NEWT_FLAG_HIDDEN
-#define NEWT_ENTRY_RETURNEXIT  NEWT_FLAG_RETURNEXIT
-#define NEWT_ENTRY_DISABLED    NEWT_FLAG_DISABLED
+#define NEWT_ENTRY_SCROLL       NEWT_FLAG_SCROLL
+#define NEWT_ENTRY_HIDDEN       NEWT_FLAG_HIDDEN
+#define NEWT_ENTRY_RETURNEXIT   NEWT_FLAG_RETURNEXIT
+#define NEWT_ENTRY_DISABLED     NEWT_FLAG_DISABLED
 
-#define NEWT_TEXTBOX_WRAP      NEWT_FLAG_WRAP
-#define NEWT_TEXTBOX_SCROLL    NEWT_FLAG_SCROLL
-#define NEWT_FORM_NOF12                NEWT_FLAG_NOF12
+#define NEWT_TEXTBOX_WRAP       NEWT_FLAG_WRAP
+#define NEWT_TEXTBOX_SCROLL     NEWT_FLAG_SCROLL
+#define NEWT_FORM_NOF12         NEWT_FLAG_NOF12
 
-#define newtListboxAddEntry    newtListboxAppendEntry
+#define newtListboxAddEntry     newtListboxAppendEntry
 
 
 typedef struct newtComponent_struct * newtComponent;
@@ -116,8 +116,8 @@ void newtClearKeyBuffer(void);
 void newtDelay(unsigned int usecs);
 /* top, left are *not* counting the border */
 int newtOpenWindow(unsigned int left,unsigned int top, 
-                  unsigned int width,unsigned  int height, 
-                 const char * title);
+                   unsigned int width,unsigned  int height, 
+                  const char * title);
 int newtCenteredWindow(unsigned int width,unsigned int height, const char * title);
 void newtPopWindow(void);
 void newtSetColors(struct newtColors colors);
@@ -139,17 +139,17 @@ void newtCursorOn(void);
 newtComponent newtCompactButton(int left, int top, const char * text);
 newtComponent newtButton(int left, int top, const char * text);
 newtComponent newtCheckbox(int left, int top, const char * text, char defValue,
-                          const char * seq, char * result);
+                           const char * seq, char * result);
 char newtCheckboxGetValue(newtComponent co);
 void newtCheckboxSetValue(newtComponent co, char value);
 void newtCheckboxSetFlags(newtComponent co, int flags, enum newtFlagsSense sense);
 
     
 newtComponent newtRadiobutton(int left, int top, const char * text, int isDefault,
-                             newtComponent prevButton);
+                              newtComponent prevButton);
 newtComponent newtRadioGetCurrent(newtComponent setMember);
 newtComponent newtListitem(int left, int top, const char * text, int isDefault,
-                             newtComponent prevItem, const void * data, int flags);
+                              newtComponent prevItem, const void * data, int flags);
 void newtListitemSet(newtComponent co, const char * text);
 void * newtListitemGetData(newtComponent co);
 void newtGetScreenSize(int * cols, int * rows);
@@ -157,7 +157,7 @@ void newtGetScreenSize(int * cols, int * rows);
 newtComponent newtLabel(int left, int top, const char * text);
 void newtLabelSetText(newtComponent co, const char * text);
 newtComponent newtVerticalScrollbar(int left, int top, int height,
-                                   int normalColorset, int thumbColorset);
+                                    int normalColorset, int thumbColorset);
 void newtScrollbarSet(newtComponent co, int where, int total);
 
 newtComponent newtListbox(int left, int top, int height, int flags);
@@ -168,7 +168,7 @@ void newtListboxSetEntry(newtComponent co, int num, const char * text);
 void newtListboxSetWidth(newtComponent co, int width);
 void newtListboxSetData(newtComponent co, int num, void * data);
 int newtListboxAppendEntry(newtComponent co, const char * text, 
-                          const void * data);
+                           const void * data);
 /* Send the key to insert after, or NULL to insert at the top */
 int newtListboxInsertEntry(newtComponent co, const char * text, const void * data, void * key);
 int newtListboxDeleteEntry(newtComponent co, void * data);
@@ -178,7 +178,7 @@ void newtListboxGetEntry(newtComponent co, int num, char **text, void **data);
 void **newtListboxGetSelection(newtComponent co, int *numitems);
 void newtListboxClearSelection(newtComponent co);
 void newtListboxSelectItem(newtComponent co, const void * key,
-       enum newtFlagsSense sense);
+        enum newtFlagsSense sense);
 /* Returns number of items currently in listbox. */
 int newtListboxItemCount(newtComponent co);
 
@@ -190,35 +190,35 @@ void newtCheckboxTreeSetCurrent(newtComponent co, void * item);
 const void ** newtCheckboxTreeGetMultiSelection(newtComponent co, int *numitems, char seqnum);
 /* last item is NEWT_ARG_LAST for all of these */
 int newtCheckboxTreeAddItem(newtComponent co, 
-                           const char * text, const void * data,
-                           int flags, int index, ...);
+                            const char * text, const void * data,
+                            int flags, int index, ...);
 int newtCheckboxTreeAddArray(newtComponent co, 
-                            const char * text, const void * data,
-                            int flags, int * indexes);
+                             const char * text, const void * data,
+                             int flags, int * indexes);
 int * newtCheckboxTreeFindItem(newtComponent co, void * data);
 void newtCheckboxTreeSetEntry(newtComponent co, const void * data,
-                             const char * text);
+                              const char * text);
 void newtCheckboxTreeSetWidth(newtComponent co, int width);
 char newtCheckboxTreeGetEntryValue(newtComponent co, const void * data);
 void newtCheckboxTreeSetEntryValue(newtComponent co, const void * data,
-                                  char value);
+                                   char value);
  
 newtComponent newtTextboxReflowed(int left, int top, char * text, int width,
-                                 int flexDown, int flexUp, int flags);
+                                  int flexDown, int flexUp, int flags);
 newtComponent newtTextbox(int left, int top, int width, int height, int flags);
 void newtTextboxSetText(newtComponent co, const char * text);
 void newtTextboxSetHeight(newtComponent co, int height);
 int newtTextboxGetNumLines(newtComponent co);
 char * newtReflowText(char * text, int width, int flexDown, int flexUp,
-                     int * actualWidth, int * actualHeight);
+                      int * actualWidth, int * actualHeight);
 
 struct newtExitStruct {
     enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT, NEWT_EXIT_FDREADY,
-          NEWT_EXIT_TIMER } reason;
+           NEWT_EXIT_TIMER } reason;
     union {
-       int watch;
-       int key;
-       newtComponent co;
+        int watch;
+        int key;
+        newtComponent co;
     } u;
 } ;
 
@@ -233,15 +233,15 @@ void newtFormAddComponent(newtComponent form, newtComponent co);
 void newtFormAddComponents(newtComponent form, ...);
 void newtFormSetHeight(newtComponent co, int height);
 void newtFormSetWidth(newtComponent co, int width);
-newtComponent newtRunForm(newtComponent form);         /* obsolete */
+newtComponent newtRunForm(newtComponent form);          /* obsolete */
 void newtFormRun(newtComponent co, struct newtExitStruct * es);
 void newtDrawForm(newtComponent form);
 void newtFormAddHotKey(newtComponent co, int key);
 
 typedef int (*newtEntryFilter)(newtComponent entry, void * data, int ch,
-                              int cursor);
+                               int cursor);
 newtComponent newtEntry(int left, int top, const char * initialValue, int width,
-                       const char ** resultPtr, int flags);
+                        const char ** resultPtr, int flags);
 void newtEntrySet(newtComponent co, const char * value, int cursorAtEnd);
 void newtEntrySetFilter(newtComponent co, newtEntryFilter filter, void * data);
 char * newtEntryGetValue(newtComponent co);
@@ -255,57 +255,57 @@ void newtComponentTakesFocus(newtComponent co, int val);
 
 /* this also destroys all of the components (including other forms) on the 
    form */
-void newtFormDestroy(newtComponent form);      
+void newtFormDestroy(newtComponent form);       
 
 /* Key codes */
 
-#define NEWT_KEY_TAB                   '\t'
-#define NEWT_KEY_ENTER                 '\r'
-#define NEWT_KEY_SUSPEND               '\032'                  /* ctrl - z*/
-#define NEWT_KEY_ESCAPE                        '\e'
-#define NEWT_KEY_RETURN                        NEWT_KEY_ENTER
-
-#define NEWT_KEY_EXTRA_BASE            0x8000
-#define NEWT_KEY_UP                    NEWT_KEY_EXTRA_BASE + 1
-#define NEWT_KEY_DOWN                  NEWT_KEY_EXTRA_BASE + 2
-#define NEWT_KEY_LEFT                  NEWT_KEY_EXTRA_BASE + 4
-#define NEWT_KEY_RIGHT                 NEWT_KEY_EXTRA_BASE + 5
-#define NEWT_KEY_BKSPC                 NEWT_KEY_EXTRA_BASE + 6
-#define NEWT_KEY_DELETE                        NEWT_KEY_EXTRA_BASE + 7
-#define NEWT_KEY_HOME                  NEWT_KEY_EXTRA_BASE + 8
-#define NEWT_KEY_END                   NEWT_KEY_EXTRA_BASE + 9
-#define NEWT_KEY_UNTAB                 NEWT_KEY_EXTRA_BASE + 10
-#define NEWT_KEY_PGUP                  NEWT_KEY_EXTRA_BASE + 11
-#define NEWT_KEY_PGDN                  NEWT_KEY_EXTRA_BASE + 12
-#define NEWT_KEY_INSERT                        NEWT_KEY_EXTRA_BASE + 13
-
-#define NEWT_KEY_F1                    NEWT_KEY_EXTRA_BASE + 101
-#define NEWT_KEY_F2                    NEWT_KEY_EXTRA_BASE + 102
-#define NEWT_KEY_F3                    NEWT_KEY_EXTRA_BASE + 103
-#define NEWT_KEY_F4                    NEWT_KEY_EXTRA_BASE + 104
-#define NEWT_KEY_F5                    NEWT_KEY_EXTRA_BASE + 105
-#define NEWT_KEY_F6                    NEWT_KEY_EXTRA_BASE + 106
-#define NEWT_KEY_F7                    NEWT_KEY_EXTRA_BASE + 107
-#define NEWT_KEY_F8                    NEWT_KEY_EXTRA_BASE + 108
-#define NEWT_KEY_F9                    NEWT_KEY_EXTRA_BASE + 109
-#define NEWT_KEY_F10                   NEWT_KEY_EXTRA_BASE + 110
-#define NEWT_KEY_F11                   NEWT_KEY_EXTRA_BASE + 111
-#define NEWT_KEY_F12                   NEWT_KEY_EXTRA_BASE + 112
+#define NEWT_KEY_TAB                    '\t'
+#define NEWT_KEY_ENTER                  '\r'
+#define NEWT_KEY_SUSPEND                '\032'                  /* ctrl - z*/
+#define NEWT_KEY_ESCAPE                 '\e'
+#define NEWT_KEY_RETURN                 NEWT_KEY_ENTER
+
+#define NEWT_KEY_EXTRA_BASE             0x8000
+#define NEWT_KEY_UP                     NEWT_KEY_EXTRA_BASE + 1
+#define NEWT_KEY_DOWN                   NEWT_KEY_EXTRA_BASE + 2
+#define NEWT_KEY_LEFT                   NEWT_KEY_EXTRA_BASE + 4
+#define NEWT_KEY_RIGHT                  NEWT_KEY_EXTRA_BASE + 5
+#define NEWT_KEY_BKSPC                  NEWT_KEY_EXTRA_BASE + 6
+#define NEWT_KEY_DELETE                 NEWT_KEY_EXTRA_BASE + 7
+#define NEWT_KEY_HOME                   NEWT_KEY_EXTRA_BASE + 8
+#define NEWT_KEY_END                    NEWT_KEY_EXTRA_BASE + 9
+#define NEWT_KEY_UNTAB                  NEWT_KEY_EXTRA_BASE + 10
+#define NEWT_KEY_PGUP                   NEWT_KEY_EXTRA_BASE + 11
+#define NEWT_KEY_PGDN                   NEWT_KEY_EXTRA_BASE + 12
+#define NEWT_KEY_INSERT                 NEWT_KEY_EXTRA_BASE + 13
+
+#define NEWT_KEY_F1                     NEWT_KEY_EXTRA_BASE + 101
+#define NEWT_KEY_F2                     NEWT_KEY_EXTRA_BASE + 102
+#define NEWT_KEY_F3                     NEWT_KEY_EXTRA_BASE + 103
+#define NEWT_KEY_F4                     NEWT_KEY_EXTRA_BASE + 104
+#define NEWT_KEY_F5                     NEWT_KEY_EXTRA_BASE + 105
+#define NEWT_KEY_F6                     NEWT_KEY_EXTRA_BASE + 106
+#define NEWT_KEY_F7                     NEWT_KEY_EXTRA_BASE + 107
+#define NEWT_KEY_F8                     NEWT_KEY_EXTRA_BASE + 108
+#define NEWT_KEY_F9                     NEWT_KEY_EXTRA_BASE + 109
+#define NEWT_KEY_F10                    NEWT_KEY_EXTRA_BASE + 110
+#define NEWT_KEY_F11                    NEWT_KEY_EXTRA_BASE + 111
+#define NEWT_KEY_F12                    NEWT_KEY_EXTRA_BASE + 112
 
 /* not really a key, but newtGetKey returns it */
-#define NEWT_KEY_RESIZE                        NEWT_KEY_EXTRA_BASE + 113
+#define NEWT_KEY_RESIZE                 NEWT_KEY_EXTRA_BASE + 113
 
-#define NEWT_ANCHOR_LEFT               (1 << 0)
-#define NEWT_ANCHOR_RIGHT              (1 << 1)
-#define NEWT_ANCHOR_TOP                        (1 << 2)
-#define NEWT_ANCHOR_BOTTOM             (1 << 3)
+#define NEWT_ANCHOR_LEFT                (1 << 0)
+#define NEWT_ANCHOR_RIGHT               (1 << 1)
+#define NEWT_ANCHOR_TOP                 (1 << 2)
+#define NEWT_ANCHOR_BOTTOM              (1 << 3)
 
-#define NEWT_GRID_FLAG_GROWX           (1 << 0)
-#define NEWT_GRID_FLAG_GROWY           (1 << 1)
+#define NEWT_GRID_FLAG_GROWX            (1 << 0)
+#define NEWT_GRID_FLAG_GROWY            (1 << 1)
 
 typedef struct grid_s * newtGrid;
 enum newtGridElement { NEWT_GRID_EMPTY = 0,
-                      NEWT_GRID_COMPONENT, NEWT_GRID_SUBGRID };
+                       NEWT_GRID_COMPONENT, NEWT_GRID_SUBGRID };
 
 newtGrid newtCreateGrid(int cols, int rows);
 /* TYPE, what, TYPE, what, ..., NULL */
@@ -314,13 +314,13 @@ newtGrid newtGridVCloseStacked(enum newtGridElement type, void * what, ...);
 newtGrid newtGridHStacked(enum newtGridElement type1, void * what1, ...);
 newtGrid newtGridHCloseStacked(enum newtGridElement type1, void * what1, ...);
 newtGrid newtGridBasicWindow(newtComponent text, newtGrid middle,
-                            newtGrid buttons);
+                             newtGrid buttons);
 newtGrid newtGridSimpleWindow(newtComponent text, newtComponent middle,
-                            newtGrid buttons);
+                             newtGrid buttons);
 void newtGridSetField(newtGrid grid, int col, int row, 
-                     enum newtGridElement type, void * val, int padLeft,
-                     int padTop, int padRight, int padBottom, int anchor,
-                     int flags);
+                      enum newtGridElement type, void * val, int padLeft,
+                      int padTop, int padRight, int padBottom, int anchor,
+                      int flags);
 void newtGridPlace(newtGrid grid, int left, int top);
 #define newtGridDestroy newtGridFree
 void newtGridFree(newtGrid grid, int recurse);
@@ -328,7 +328,7 @@ void newtGridGetSize(newtGrid grid, int * width, int * height);
 void newtGridWrappedWindow(newtGrid grid, char * title);
 void newtGridWrappedWindowAt(newtGrid grid, char * title, int left, int top);
 void newtGridAddComponentsToForm(newtGrid grid, newtComponent form, 
-                                int recurse);
+                                 int recurse);
 
 /* convienve */
 newtGrid newtButtonBarv(char * button1, newtComponent * b1comp, va_list args);
@@ -337,35 +337,35 @@ newtGrid newtButtonBar(char * button1, newtComponent * b1comp, ...);
 /* automatically centered and shrink wrapped */
 void newtWinMessage(char * title, char * buttonText, char * text, ...);
 void newtWinMessagev(char * title, char * buttonText, char * text, 
-                    va_list argv);
+                     va_list argv);
 
 /* having separate calls for these two seems silly, but having two separate
    variable length-arg lists seems like a bad idea as well */
 
 /* Returns 0 if F12 was pressed, 1 for button1, 2 for button2 */
 int newtWinChoice(char * title, char * button1, char * button2, 
-                  char * text, ...);
+                   char * text, ...);
 /* Returns 0 if F12 was pressed, 1 for button1, 2 for button2, 
    3 for button3 */
 int newtWinTernary(char * title, char * button1, char * button2, 
-                  char * button3, char * message, ...);
+                   char * button3, char * message, ...);
 
 /* Returns the button number pressed, 0 on F12 */
 int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown, 
-               int flexUp, int maxListHeight, char ** items, int * listItem,
-               char * button1, ...);
+                int flexUp, int maxListHeight, char ** items, int * listItem,
+                char * button1, ...);
 
 struct newtWinEntry {
     char * text;
-    const char ** value;               /* may be initialized to set default */
+    const char ** value;                /* may be initialized to set default */
     int flags;
 };
 
 /* Returns the button number pressed, 0 on F12. The final values are
    dynamically allocated, and need to be freed. */
 int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown, 
-                  int flexUp, int dataWidth, 
-                  struct newtWinEntry * items, char * button1, ...);
+                   int flexUp, int dataWidth, 
+                   struct newtWinEntry * items, char * button1, ...);
 
 #ifdef __cplusplus
 } /* End of extern "C" { */
index 911898cfb38fc0fc7f6c7fe65cfc0df0fe43ad61..2bd2f18c5825dda4d3b2921ac15dc49f0f697d4b 100644 (file)
--- a/newt_pr.h
+++ b/newt_pr.h
@@ -1,21 +1,21 @@
 #ifndef H_NEWT_PR
 #define H_NEWT_PR
 
-#define COLORSET_ROOT          NEWT_COLORSET_ROOT
-#define COLORSET_BORDER        NEWT_COLORSET_BORDER
-#define COLORSET_WINDOW                NEWT_COLORSET_WINDOW
-#define COLORSET_SHADOW                NEWT_COLORSET_SHADOW
-#define COLORSET_TITLE         NEWT_COLORSET_TITLE
-#define COLORSET_BUTTON                NEWT_COLORSET_BUTTON
-#define COLORSET_ACTBUTTON     NEWT_COLORSET_ACTBUTTON
-#define COLORSET_CHECKBOX      NEWT_COLORSET_CHECKBOX
-#define COLORSET_ACTCHECKBOX   NEWT_COLORSET_ACTCHECKBOX
-#define COLORSET_ENTRY         NEWT_COLORSET_ENTRY
-#define COLORSET_LABEL         NEWT_COLORSET_LABEL
-#define COLORSET_LISTBOX       NEWT_COLORSET_LISTBOX
-#define COLORSET_ACTLISTBOX    NEWT_COLORSET_ACTLISTBOX
-#define COLORSET_TEXTBOX       NEWT_COLORSET_TEXTBOX
-#define COLORSET_ACTTEXTBOX    NEWT_COLORSET_ACTTEXTBOX
+#define COLORSET_ROOT           NEWT_COLORSET_ROOT
+#define COLORSET_BORDER         NEWT_COLORSET_BORDER
+#define COLORSET_WINDOW         NEWT_COLORSET_WINDOW
+#define COLORSET_SHADOW         NEWT_COLORSET_SHADOW
+#define COLORSET_TITLE          NEWT_COLORSET_TITLE
+#define COLORSET_BUTTON         NEWT_COLORSET_BUTTON
+#define COLORSET_ACTBUTTON      NEWT_COLORSET_ACTBUTTON
+#define COLORSET_CHECKBOX       NEWT_COLORSET_CHECKBOX
+#define COLORSET_ACTCHECKBOX    NEWT_COLORSET_ACTCHECKBOX
+#define COLORSET_ENTRY          NEWT_COLORSET_ENTRY
+#define COLORSET_LABEL          NEWT_COLORSET_LABEL
+#define COLORSET_LISTBOX        NEWT_COLORSET_LISTBOX
+#define COLORSET_ACTLISTBOX     NEWT_COLORSET_ACTLISTBOX
+#define COLORSET_TEXTBOX        NEWT_COLORSET_TEXTBOX
+#define COLORSET_ACTTEXTBOX     NEWT_COLORSET_ACTTEXTBOX
 
 int newtSetFlags(int oldFlags, int newFlags, enum newtFlagsSense sense);
 
@@ -44,11 +44,11 @@ struct newtComponent_struct {
 } ;
 
 enum eventResultTypes { ER_IGNORED, ER_SWALLOWED, ER_EXITFORM, ER_SETFOCUS,
-                       ER_NEXTCOMP };
+                        ER_NEXTCOMP };
 struct eventResult {
     enum eventResultTypes result;
     union {
-       newtComponent focus;
+        newtComponent focus;
     } u;
 };
 
@@ -59,11 +59,11 @@ struct event {
     enum eventTypes event;
     enum eventSequence when;
     union {
-       int key;
-       struct {
-           enum { MOUSE_MOTION, MOUSE_BUTTON_DOWN, MOUSE_BUTTON_UP } type;
-           int x, y;
-       } mouse;
+        int key;
+        struct {
+            enum { MOUSE_MOTION, MOUSE_BUTTON_DOWN, MOUSE_BUTTON_UP } type;
+            int x, y;
+        } mouse;
     } u;
 } ;
 
@@ -78,7 +78,7 @@ struct componentOps {
 void newtDefaultPlaceHandler(newtComponent c, int newLeft, int newTop);
 void newtDefaultMappedHandler(newtComponent c, int isMapped);
 struct eventResult newtDefaultEventHandler(newtComponent c,
-                                          struct event ev);
+                                           struct event ev);
 
 int wstrlen(const char *str, int len);
 
diff --git a/scale.c b/scale.c
index f898916b339327b8b18c1931dfd2441bd2833b7e..43ab44852e70af531066cc3f5c101db7ea1e1306 100644 (file)
--- a/scale.c
+++ b/scale.c
@@ -52,11 +52,11 @@ void newtScaleSet(newtComponent co, unsigned long long amount) {
     newPercentage = (amount * 100) / sc->fullValue;
 
     if (newPercentage > 100)
-       newPercentage = 100;
+        newPercentage = 100;
     
     if (newPercentage != sc->percentage) {
-       sc->percentage = newPercentage;
-       scaleDraw(co);
+        sc->percentage = newPercentage;
+        scaleDraw(co);
     }
 }
 
index 1a737a40900456267a2dcccbf837b8bfef58e5cb..ca9f595e6ad9a22e3e728b9853bcf8cefec8a90c 100644 (file)
@@ -28,18 +28,18 @@ void newtScrollbarSet(newtComponent co, int where, int total) {
     int new;
 
     if (sb->arrows)
-       new = (where * (co->height - 3)) / (total ? total : 1) + 1;
+        new = (where * (co->height - 3)) / (total ? total : 1) + 1;
     else
-       new = (where * (co->height - 1)) / (total ? total : 1);
+        new = (where * (co->height - 1)) / (total ? total : 1);
     if (new != sb->curr) {
-       sbDrawThumb(co, 0);
-       sb->curr = new;
-       sbDrawThumb(co, 1);
+        sbDrawThumb(co, 0);
+        sb->curr = new;
+        sbDrawThumb(co, 1);
     }
 }
 
 newtComponent newtVerticalScrollbar(int left, int top, int height,
-                                   int normalColorset, int thumbColorset) {
+                                    int normalColorset, int thumbColorset) {
     newtComponent co;
     struct scrollbar * sb;
 
@@ -48,11 +48,11 @@ newtComponent newtVerticalScrollbar(int left, int top, int height,
     co->data = sb;
 
     if (!strcmp(getenv("TERM"), "linux") && height >= 2) {
-       sb->arrows = 1;
-       sb->curr = 1;
+        sb->arrows = 1;
+        sb->curr = 1;
     } else {
-       sb->arrows = 0;
-       sb->curr = 0;
+        sb->arrows = 0;
+        sb->curr = 0;
     }
     sb->cs = normalColorset;
     sb->csThumb = thumbColorset;
@@ -78,19 +78,19 @@ static void sbDraw(newtComponent co) {
 
     SLsmg_set_char_set(1);
     if (sb->arrows) {
-       newtGotorc(co->top, co->left);
-       SLsmg_write_char(SLSMG_UARROW_CHAR);
-       for (i = 1; i < co->height - 1; i++) {
-           newtGotorc(i + co->top, co->left);
-           SLsmg_write_char(SLSMG_CKBRD_CHAR);
-       }
-       newtGotorc(co->top + co->height - 1, co->left);
-       SLsmg_write_char(SLSMG_DARROW_CHAR);
+        newtGotorc(co->top, co->left);
+        SLsmg_write_char(SLSMG_UARROW_CHAR);
+        for (i = 1; i < co->height - 1; i++) {
+            newtGotorc(i + co->top, co->left);
+            SLsmg_write_char(SLSMG_CKBRD_CHAR);
+        }
+        newtGotorc(co->top + co->height - 1, co->left);
+        SLsmg_write_char(SLSMG_DARROW_CHAR);
     } else {
-       for (i = 0; i < co->height; i++) {
-           newtGotorc(i + co->top, co->left);
-           SLsmg_write_char(SLSMG_CKBRD_CHAR);
-       }
+        for (i = 0; i < co->height; i++) {
+            newtGotorc(i + co->top, co->left);
+            SLsmg_write_char(SLSMG_CKBRD_CHAR);
+        }
     }
 
     SLsmg_set_char_set(0);
@@ -108,9 +108,9 @@ static void sbDrawThumb(newtComponent co, int isOn) {
     SLsmg_set_char_set(1);
 
     /*if (isOn)
-       SLsmg_set_color(sb->csThumb);
+        SLsmg_set_color(sb->csThumb);
     else*/
-       SLsmg_set_color(sb->cs);
+        SLsmg_set_color(sb->cs);
 
     SLsmg_write_char(ch);
     SLsmg_set_char_set(0);
index eb999eda851ef007b27242fbbb2098b2859b8c94..1225e733fb909883db4b52d8210940e565728050 100644 (file)
@@ -7,12 +7,12 @@ void printall(int offset) {
     SLsmg_gotorc(0, offset);
     SLsmg_write_string("  0 1 2 3 4 5 6 7 8 9 A B C D E F");
     for (i = 0; i < 16; i++) {
-       SLsmg_gotorc(i + 1, offset);
-       SLsmg_printf("%x", i);
-       for (j = 0; j < 16; j++) {
-           SLsmg_gotorc(i + 1, (j + 1) * 2 + offset);
-           SLsmg_write_char(n++);
-       }
+        SLsmg_gotorc(i + 1, offset);
+        SLsmg_printf("%x", i);
+        for (j = 0; j < 16; j++) {
+            SLsmg_gotorc(i + 1, (j + 1) * 2 + offset);
+            SLsmg_write_char(n++);
+        }
     }
 }
 
index 14baf6c3c2ad548f61825594e07ea11b9c4bc278..7770a0c2b8d4e0f41bc7ec8127a25c03308e7237 100644 (file)
--- a/showkey.c
+++ b/showkey.c
@@ -10,13 +10,13 @@ int main(void) {
 
     buf = SLtt_tgetstr("ku");
     if (!buf) {
-       printf("termcap entry not found for kl\n\r");
+        printf("termcap entry not found for kl\n\r");
     } else {
-       printf("termcap entry found for kl: %s", buf);
-       while (*buf) {
-           printf("0x%02x ", *buf++);
-       }
-       printf("\n\r");
+        printf("termcap entry found for kl: %s", buf);
+        while (*buf) {
+            printf("0x%02x ", *buf++);
+        }
+        printf("\n\r");
     }
 
     printf("\n\r");
@@ -30,8 +30,8 @@ int main(void) {
     printf("You pressed: ");
 
     while (SLang_input_pending(1)) {
-       i = SLang_getkey();
-       printf("0x%02x ", i);
+        i = SLang_getkey();
+        printf("0x%02x ", i);
     }
 
     printf("\n\r");
index f992e44692a893d8556cd3da3cc32479cadaf652..d961cb2095bb6dde61a3dcda9be5fd356d522061 100644 (file)
@@ -123,15 +123,15 @@ static PyTypeObject snackGridType = {
         "snackgrid",                    /* tp_name */
         sizeof(snackGrid),              /* tp_size */
         0,                              /* tp_itemsize */
-        emptyDestructor,                       /* tp_dealloc */
+        emptyDestructor,                        /* tp_dealloc */
         0,                              /* tp_print */
-        gridGetAttr,                   /* tp_getattr */
+        gridGetAttr,                    /* tp_getattr */
         0,                              /* tp_setattr */
         0,                              /* tp_compare */
         0,                              /* tp_repr */
         0,                              /* tp_as_number */
         0,                              /* tp_as_sequence */
-        0,                             /* tp_as_mapping */
+        0,                              /* tp_as_mapping */
 };
 
 struct snackForm_s {
@@ -165,15 +165,15 @@ static PyTypeObject snackFormType = {
         "snackform",                    /* tp_name */
         sizeof(snackForm),              /* tp_size */
         0,                              /* tp_itemsize */
-        emptyDestructor,               /* tp_dealloc */
+        emptyDestructor,                /* tp_dealloc */
         0,                              /* tp_print */
-        formGetAttr,                   /* tp_getattr */
+        formGetAttr,                    /* tp_getattr */
         0,                              /* tp_setattr */
         0,                              /* tp_compare */
         0,                              /* tp_repr */
         0,                              /* tp_as_number */
         0,                              /* tp_as_sequence */
-        0,                             /* tp_as_mapping */
+        0,                              /* tp_as_mapping */
 };
 
 struct snackWidget_s {
@@ -250,15 +250,15 @@ static PyTypeObject snackWidgetType = {
         "snackwidget",                  /* tp_name */
         sizeof(snackWidget),            /* tp_size */
         0,                              /* tp_itemsize */
-        widgetDestructor,                      /* tp_dealloc */
+        widgetDestructor,               /* tp_dealloc */
         0,                              /* tp_print */
-        widgetGetAttr,                 /* tp_getattr */
+        widgetGetAttr,                  /* tp_getattr */
         0,                              /* tp_setattr */
         0,                              /* tp_compare */
         0,                              /* tp_repr */
         0,                              /* tp_as_number */
         0,                              /* tp_as_sequence */
-        0,                             /* tp_as_mapping */
+        0,                              /* tp_as_mapping */
 };
 
 static snackWidget * snackWidgetNew (void) {
@@ -325,7 +325,7 @@ static PyObject * screenSize(PyObject * s, PyObject * args) {
     int width, height;
 
     if (!PyArg_ParseTuple(args, ""))
-       return NULL;
+        return NULL;
 
     newtGetScreenSize(&width, &height);
 
@@ -348,15 +348,15 @@ static void suspendCallbackMarshall(void * data) {
     PyObject * args, * result;
 
     if (scs->data) {
-       args = Py_BuildValue("(O)", scs->data);
-       result = PyEval_CallObject(scs->cb, args);
-       Py_DECREF (args);
+        args = Py_BuildValue("(O)", scs->data);
+        result = PyEval_CallObject(scs->cb, args);
+        Py_DECREF (args);
     } else
-       result = PyEval_CallObject(scs->cb, NULL);
+        result = PyEval_CallObject(scs->cb, NULL);
     
     if (!result) {
-       PyErr_Print();
-       PyErr_Clear();
+        PyErr_Print();
+        PyErr_Clear();
     }
 
     Py_XDECREF(result);
@@ -369,15 +369,15 @@ static void callbackMarshall(newtComponent co, void * data) {
     PyObject * args, * result;
 
     if (scs->data) {
-       args = Py_BuildValue("(O)", scs->data);
-       result = PyEval_CallObject(scs->cb, args);
-       Py_DECREF (args);
+        args = Py_BuildValue("(O)", scs->data);
+        result = PyEval_CallObject(scs->cb, args);
+        Py_DECREF (args);
     } else
-       result = PyEval_CallObject(scs->cb, NULL);
+        result = PyEval_CallObject(scs->cb, NULL);
 
     if (!result) {
-       PyErr_Print();
-       PyErr_Clear();
+        PyErr_Print();
+        PyErr_Clear();
     }
     
     Py_XDECREF(result);
@@ -387,7 +387,7 @@ static void callbackMarshall(newtComponent co, void * data) {
 
 static PyObject * setSuspendCallback(PyObject * s, PyObject * args) {
     if (!PyArg_ParseTuple(args, "O|O", &suspend.cb, &suspend.data))
-       return NULL;
+        return NULL;
 
     Py_INCREF (suspend.cb);
     Py_XINCREF (suspend.data);    
@@ -400,10 +400,10 @@ static PyObject * setSuspendCallback(PyObject * s, PyObject * args) {
 
 static PyObject * setHelpCallback(PyObject * s, PyObject * args) {
     if (!PyArg_ParseTuple(args, "O", &helpCallback.cb))
-       return NULL;
+        return NULL;
 
     /*if (helpCallback.cb) {
-       Py_DECREF (helpCallback.cb);
+        Py_DECREF (helpCallback.cb);
     }*/
 
     Py_INCREF (helpCallback.cb);
@@ -419,7 +419,7 @@ static PyObject * drawRootText(PyObject * s, PyObject * args) {
     char * text;
 
     if (!PyArg_ParseTuple(args, "iis", &left, &top, &text))
-       return NULL;
+        return NULL;
 
     newtDrawRootText(left, top, text);
 
@@ -451,12 +451,12 @@ static PyObject * pushHelpLine(PyObject * s, PyObject * args) {
     char * text;
 
     if (!PyArg_ParseTuple(args, "s", &text))
-       return NULL;
+        return NULL;
 
     if (!strcmp(text, "*default*"))
-       newtPushHelpLine(NULL);
+        newtPushHelpLine(NULL);
     else
-       newtPushHelpLine(text);
+        newtPushHelpLine(text);
 
     Py_INCREF(Py_None);
     return Py_None;
@@ -469,7 +469,7 @@ static PyObject * reflowText(PyObject * s, PyObject * args) {
     PyObject * tuple;
 
     if (!PyArg_ParseTuple(args, "si|ii", &text, &width, &minus, &plus))
-       return NULL;
+        return NULL;
 
     new = newtReflowText(text, width, minus, plus, &realWidth, &realHeight);
 
@@ -484,7 +484,7 @@ static PyObject * centeredWindow(PyObject * s, PyObject * args) {
     char * title;
 
     if (!PyArg_ParseTuple(args, "iis", &width, &height, &title))
-       return NULL;
+        return NULL;
 
     newtCenteredWindow(width, height, title);
 
@@ -498,13 +498,13 @@ static PyObject * gridWrappedWindow(PyObject * s, PyObject * args) {
     int x = -1, y = -1;
 
     if (!PyArg_ParseTuple(args, "O!s|ii", &snackGridType, &grid, &title, 
-                         &x, &y))
-       return NULL;
+                          &x, &y))
+        return NULL;
 
     if (y == -1)
-       newtGridWrappedWindow(grid->grid, title);
+        newtGridWrappedWindow(grid->grid, title);
     else
-       newtGridWrappedWindowAt(grid->grid, title, x, y);
+        newtGridWrappedWindowAt(grid->grid, title, x, y);
 
     Py_INCREF(Py_None);
     return Py_None;
@@ -515,7 +515,7 @@ static PyObject * openWindow(PyObject * s, PyObject * args) {
     char * title;
 
     if (!PyArg_ParseTuple(args, "iiiis", &left, &top, &width, &height, &title))
-       return NULL;
+        return NULL;
 
     newtOpenWindow(left, top, width, height, title);
 
@@ -534,7 +534,7 @@ static PyObject * messageWindow(PyObject * s, PyObject * args) {
     char * okbutton = "Ok";
 
     if (!PyArg_ParseTuple(args, "ss|s", &title, &text, &okbutton)) 
-       return NULL;
+        return NULL;
 
     newtWinMessage(title, okbutton, text);
 
@@ -549,8 +549,8 @@ static PyObject * choiceWindow(PyObject * s, PyObject * args) {
     int rc;
 
     if (!PyArg_ParseTuple(args, "ss|ss", &title, &text, &okbutton, 
-                         &cancelbutton)) 
-       return NULL;
+                          &cancelbutton)) 
+        return NULL;
 
     rc = newtWinChoice(title, okbutton, cancelbutton, text);
 
@@ -562,8 +562,8 @@ static PyObject * ternaryWindow(PyObject * s, PyObject * args) {
     int rc;
 
     if (!PyArg_ParseTuple(args, "sssss", &title, &text, &button1, &button2, 
-                         &button3)) 
-       return NULL;
+                          &button3)) 
+        return NULL;
 
     rc = newtWinTernary(title, button1, button2, button3, text);
 
@@ -634,14 +634,14 @@ static snackWidget * listboxWidget(PyObject * s, PyObject * args) {
     int doScroll = 0, returnExit = 0, showCursor = 0 ;
 
     if (!PyArg_ParseTuple(args, "i|iii", &height, &doScroll, &returnExit, &showCursor))
-       return NULL;
+        return NULL;
 
     widget = snackWidgetNew ();
     widget->co = newtListbox(-1, -1, height,
-                            (doScroll ? NEWT_FLAG_SCROLL : 0) |
-                            (returnExit ? NEWT_FLAG_RETURNEXIT : 0) |
-                            (showCursor ? NEWT_FLAG_SHOWCURSOR : 0)
-                            );
+                             (doScroll ? NEWT_FLAG_SCROLL : 0) |
+                             (returnExit ? NEWT_FLAG_RETURNEXIT : 0) |
+                             (showCursor ? NEWT_FLAG_SHOWCURSOR : 0)
+                             );
     widget->anint = 1;
     
     return widget;
@@ -655,12 +655,12 @@ static snackWidget * textWidget(PyObject * s, PyObject * args) {
     snackWidget * widget;
     
     if (!PyArg_ParseTuple(args, "iis|ii", &width, &height, &text, &scrollBar, &wrap))
-       return NULL;
+        return NULL;
 
     widget = snackWidgetNew ();
     widget->co = newtTextbox(-1, -1, width, height,
-                               (scrollBar ? NEWT_FLAG_SCROLL : 0) |
-                               (wrap ? NEWT_FLAG_WRAP : 0));
+                                (scrollBar ? NEWT_FLAG_SCROLL : 0) |
+                                (wrap ? NEWT_FLAG_WRAP : 0));
     newtTextboxSetText(widget->co, text);
     
     return widget;
@@ -672,14 +672,14 @@ static snackWidget * radioButtonWidget(PyObject * s, PyObject * args) {
     int isOn;
 
     if (!PyArg_ParseTuple(args, "sOi", &text, &group, &isOn)) 
-               return NULL;
+                return NULL;
 
     widget = snackWidgetNew ();
 
     if ((PyObject *) group == Py_None)
-       widget->co = newtRadiobutton(-1, -1, text, isOn, NULL);
+        widget->co = newtRadiobutton(-1, -1, text, isOn, NULL);
     else
-       widget->co = newtRadiobutton(-1, -1, text, isOn, group->co);
+        widget->co = newtRadiobutton(-1, -1, text, isOn, group->co);
 
     return widget;
 }
@@ -693,7 +693,7 @@ static snackWidget * checkboxWidget(PyObject * s, PyObject * args) {
 
     widget = snackWidgetNew ();
     widget->co = newtCheckbox(-1, -1, text, isOn ? '*' : ' ', NULL, 
-                               &widget->achar);
+                                &widget->achar);
 
     return widget;
 }
@@ -727,15 +727,15 @@ static snackWidget * entryWidget(PyObject * s, PyObject * args) {
     int isHidden, isScrolled, returnExit, isPassword;
 
     if (!PyArg_ParseTuple(args, "isiiii", &width, &initial,
-                         &isHidden, &isPassword, &isScrolled, &returnExit)) return NULL;
+                          &isHidden, &isPassword, &isScrolled, &returnExit)) return NULL;
 
     widget = snackWidgetNew ();
     widget->co = newtEntry(-1, -1, initial, width,
                            (const char **) &widget->apointer, 
-                          (isHidden ? NEWT_FLAG_HIDDEN : 0) |
-                          (isPassword ? NEWT_FLAG_PASSWORD : 0) |
-                          (returnExit ? NEWT_FLAG_RETURNEXIT : 0) |
-                          (isScrolled ? NEWT_FLAG_SCROLL : 0));
+                           (isHidden ? NEWT_FLAG_HIDDEN : 0) |
+                           (isPassword ? NEWT_FLAG_PASSWORD : 0) |
+                           (returnExit ? NEWT_FLAG_RETURNEXIT : 0) |
+                           (isScrolled ? NEWT_FLAG_SCROLL : 0));
 
     return widget;
 }
@@ -747,7 +747,7 @@ static snackForm * formCreate(PyObject * s, PyObject * args) {
     if (!PyArg_ParseTuple(args, "|O", &help)) return NULL;
 
     if (help == Py_None)
-       help = NULL;
+        help = NULL;
 
     form = PyObject_NEW(snackForm, &snackFormType);
     form->fo = newtForm(NULL, help, 0);
@@ -790,19 +790,19 @@ static PyObject * gridSetField(snackGrid * grid, PyObject * args) {
     int anchorFlags = 0, growFlags = 0;
 
     if (!PyArg_ParseTuple(args, "iiO|(iiii)ii", &x, &y, 
-                               &w, &pLeft, &pTop, &pRight, &pBottom,
-                               &anchorFlags, &growFlags)) 
-       return NULL;
+                                &w, &pLeft, &pTop, &pRight, &pBottom,
+                                &anchorFlags, &growFlags)) 
+        return NULL;
 
     if (w->ob_type == &snackWidgetType) {
-       newtGridSetField(grid->grid, x, y, NEWT_GRID_COMPONENT,
-                        w->co, pLeft, pTop, pRight, pBottom, anchorFlags, 
-                        growFlags);
+        newtGridSetField(grid->grid, x, y, NEWT_GRID_COMPONENT,
+                         w->co, pLeft, pTop, pRight, pBottom, anchorFlags, 
+                         growFlags);
     } else {
-       g = (snackGrid *) w;
-       newtGridSetField(grid->grid, x, y, NEWT_GRID_SUBGRID,
-                        g->grid, pLeft, pTop, pRight, pBottom, anchorFlags, 
-                        growFlags);
+        g = (snackGrid *) w;
+        newtGridSetField(grid->grid, x, y, NEWT_GRID_SUBGRID,
+                         g->grid, pLeft, pTop, pRight, pBottom, anchorFlags, 
+                         growFlags);
     }
 
     Py_INCREF(Py_None);
@@ -825,14 +825,14 @@ static PyObject * formAdd(snackForm * s, PyObject * args) {
     int size = PyTuple_Size(args), i;
     
     if (!size) {
-       /* this is a hack, I should give an error directly */
-       if (!PyArg_ParseTuple(args, "O!", &snackWidgetType, &w)) 
-           return NULL;
+        /* this is a hack, I should give an error directly */
+        if (!PyArg_ParseTuple(args, "O!", &snackWidgetType, &w)) 
+            return NULL;
     }
 
     for (i = 0; i < size; i++) {
-       w = (snackWidget *) PyTuple_GET_ITEM(args, i);
-       newtFormAddComponent(s->fo, w->co);
+        w = (snackWidget *) PyTuple_GET_ITEM(args, i);
+        newtFormAddComponent(s->fo, w->co);
     }
 
     Py_INCREF(Py_None);
@@ -845,20 +845,20 @@ static PyObject * formRun(snackForm * s, PyObject * args) {
     newtFormRun(s->fo, &result);
 
     if (result.reason == NEWT_EXIT_HOTKEY)
-       return Py_BuildValue("(si)", "hotkey", result.u.key);
+        return Py_BuildValue("(si)", "hotkey", result.u.key);
     else if (result.reason == NEWT_EXIT_TIMER)
-       return Py_BuildValue("(si)", "timer", 0);
+        return Py_BuildValue("(si)", "timer", 0);
     else if (result.reason == NEWT_EXIT_FDREADY)
-       return Py_BuildValue("(si)", "fdready", result.u.watch);
+        return Py_BuildValue("(si)", "fdready", result.u.watch);
     else
-       return Py_BuildValue("(si)", "widget", result.u.co);
+        return Py_BuildValue("(si)", "widget", result.u.co);
 }
 
 static PyObject * formHotKey(snackForm * s, PyObject * args) {
     int key;
 
     if (!PyArg_ParseTuple(args, "i", &key))
-       return NULL;
+        return NULL;
 
     newtFormAddHotKey(s->fo, key);
 
@@ -870,7 +870,7 @@ static PyObject * formSetTimer(snackForm * form, PyObject * args) {
     int millisecs;
 
     if (!PyArg_ParseTuple(args, "i", &millisecs))
-       return NULL;
+        return NULL;
 
     newtFormSetTimer(form->fo, millisecs);
 
@@ -882,7 +882,7 @@ static PyObject * formWatchFD(snackForm * form, PyObject * args) {
     int fd, fdflags;
 
     if (!PyArg_ParseTuple(args, "ii", &fd, &fdflags))
-       return NULL;
+        return NULL;
 
     newtFormWatchFd(form->fo, fd, fdflags);
 
@@ -894,7 +894,7 @@ static PyObject * formSetCurrent(snackForm * form, PyObject * args) {
     snackWidget * w;
 
     if (!PyArg_ParseTuple(args, "O", &w))
-       return NULL;
+        return NULL;
 
     newtFormSetCurrent(form->fo, w->co);
 
@@ -906,13 +906,13 @@ static PyObject * widgetGetAttr(PyObject * s, char * name) {
     snackWidget * w = (snackWidget *) s;
 
     if (!strcmp(name, "key")) {
-       return Py_BuildValue("i", w->co);
+        return Py_BuildValue("i", w->co);
     } else if (!strcmp(name, "entryValue")) {
-       return Py_BuildValue("s", w->apointer);
+        return Py_BuildValue("s", w->apointer);
     } else if (!strcmp(name, "checkboxValue")) {
-       return Py_BuildValue("i", w->achar == ' ' ? 0 : 1);
+        return Py_BuildValue("i", w->achar == ' ' ? 0 : 1);
     } else if (!strcmp(name, "radioValue")) {
-       return Py_BuildValue("i", newtRadioGetCurrent(w->co));
+        return Py_BuildValue("i", newtRadioGetCurrent(w->co));
     }
 
     return Py_FindMethod(widgetMethods, s, name);
@@ -932,7 +932,7 @@ static PyObject * widgetAddCallback(snackWidget * s, PyObject * args) {
     s->scs.data = NULL;
     
     if (!PyArg_ParseTuple(args, "O|O", &s->scs.cb, &s->scs.data))
-       return NULL;
+        return NULL;
 
     Py_INCREF (s->scs.cb);
     Py_XINCREF (s->scs.data);
@@ -947,7 +947,7 @@ static PyObject * widgetEntrySetValue(snackWidget * s, PyObject * args) {
     char * val;
 
     if (!PyArg_ParseTuple(args, "s", &val))
-       return NULL;
+        return NULL;
 
     newtEntrySet(s->co, val, 1);
 
@@ -971,7 +971,7 @@ static PyObject * widgetListboxAdd(snackWidget * s, PyObject * args) {
     char * text;
     
     if (!PyArg_ParseTuple(args, "s", &text))
-       return NULL;
+        return NULL;
 
     newtListboxAddEntry(s->co, text, I2P(s->anint));
 
@@ -983,7 +983,7 @@ static PyObject * widgetListboxIns(snackWidget * s, PyObject * args) {
     int key;
     
     if (!PyArg_ParseTuple(args, "si", &text, &key))
-       return NULL;
+        return NULL;
 
     newtListboxInsertEntry(s->co, text, I2P(s->anint), I2P(key));
 
@@ -994,7 +994,7 @@ static PyObject * widgetListboxDel(snackWidget * s, PyObject * args) {
     int key;
     
     if (!PyArg_ParseTuple(args, "i", &key))
-       return NULL;
+        return NULL;
 
     newtListboxDeleteEntry(s->co, I2P(key));
 
@@ -1004,7 +1004,7 @@ static PyObject * widgetListboxDel(snackWidget * s, PyObject * args) {
 
 static PyObject * widgetListboxGet(snackWidget * s, PyObject * args) {
     if (!PyArg_ParseTuple(args, ""))
-       return NULL;
+        return NULL;
 
     return PyInt_FromLong((long) newtListboxGetCurrent(s->co));
 }
@@ -1013,7 +1013,7 @@ static PyObject * widgetListboxSet(snackWidget * s, PyObject * args) {
     int index;
     
     if (!PyArg_ParseTuple(args, "i", &index))
-       return NULL;
+        return NULL;
 
     newtListboxSetCurrentByKey(s->co, I2P(index));
 
@@ -1025,7 +1025,7 @@ static PyObject * widgetListboxSetW(snackWidget * s, PyObject * args) {
     int width;
 
     if (!PyArg_ParseTuple(args, "i", &width))
-       return NULL;
+        return NULL;
 
     newtListboxSetWidth(s->co, width);
 
@@ -1056,12 +1056,12 @@ static snackWidget * checkboxTreeWidget(PyObject * s, PyObject * args, PyObject
     const char *kw[] = {"height", "scrollbar", "hide_checkbox", "unselectable", NULL};
     
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|iii", (char **) kw,
-               &height, &scrollBar, &hide_checkbox, &unselectable))
-       return NULL;
+                &height, &scrollBar, &hide_checkbox, &unselectable))
+        return NULL;
 
     flags = (scrollBar ? NEWT_FLAG_SCROLL : 0) |
-       (hide_checkbox ? NEWT_CHECKBOXTREE_HIDE_BOX : 0) |    
-       (unselectable ? NEWT_CHECKBOXTREE_UNSELECTABLE : 0);
+        (hide_checkbox ? NEWT_CHECKBOXTREE_HIDE_BOX : 0) |    
+        (unselectable ? NEWT_CHECKBOXTREE_UNSELECTABLE : 0);
 
     widget = snackWidgetNew ();
     widget->co = newtCheckboxTree(-1, -1, height, flags);
@@ -1080,25 +1080,25 @@ static PyObject * widgetCheckboxTreeAddItem(snackWidget * s, PyObject * args) {
     int i;
 
     if (!PyArg_ParseTuple(args, "sOi", &text, &pathList, &selected))
-       return NULL;
+        return NULL;
 
     len = PyTuple_Size(pathList);
     path = alloca(sizeof(*path) * (len + 1));
     for (i = 0; i < len; i++) {
         o = PyTuple_GetItem(pathList, i);
-       path[i] = PyInt_AsLong(o);
+        path[i] = PyInt_AsLong(o);
     }
     path[len] = NEWT_ARG_LAST;
 
     newtCheckboxTreeAddArray(s->co, text, I2P(s->anint),
-                            selected ? NEWT_FLAG_SELECTED : 0, path);
+                             selected ? NEWT_FLAG_SELECTED : 0, path);
 
     return PyInt_FromLong(s->anint++);
 }
 
 static PyObject * widgetCheckboxTreeGetCur(snackWidget * s, PyObject * args) {
     if (!PyArg_ParseTuple(args, ""))
-       return NULL;
+        return NULL;
 
     return PyInt_FromLong((long)newtCheckboxTreeGetCurrent(s->co));
 }
@@ -1119,7 +1119,7 @@ static PyObject * widgetCheckboxTreeSetWidth(snackWidget * s, PyObject * args) {
     int width;
 
     if (!PyArg_ParseTuple(args, "i", &width))
-       return NULL;
+        return NULL;
 
     newtCheckboxTreeSetWidth(s->co, width);
 
@@ -1145,8 +1145,8 @@ static PyObject * widgetCheckboxTreeSetEntryValue(snackWidget * s, PyObject * ar
     if (!PyArg_ParseTuple(args, "i|i", &data, &isOn)) return NULL;
 
     newtCheckboxTreeSetEntryValue(s->co, I2P(data),
-                                 isOn ? NEWT_CHECKBOXTREE_SELECTED :
-                                        NEWT_CHECKBOXTREE_UNSELECTED);
+                                  isOn ? NEWT_CHECKBOXTREE_SELECTED :
+                                         NEWT_CHECKBOXTREE_UNSELECTED);
 
     Py_INCREF(Py_None);
     return Py_None;
@@ -1166,40 +1166,40 @@ static PyObject * widgetCheckboxTreeGetEntryValue(snackWidget * s, PyObject * ar
 
     switch (selection) {
     case NEWT_CHECKBOXTREE_EXPANDED:
-       isOn = 1;
+        isOn = 1;
     case NEWT_CHECKBOXTREE_COLLAPSED:
-       isBranch = 1;
-       break;
+        isBranch = 1;
+        break;
     case NEWT_CHECKBOXTREE_UNSELECTED:
-       break;
+        break;
     default:
-       isOn = 1;
-       break;
+        isOn = 1;
+        break;
     }    
     return Py_BuildValue("(ii)", isBranch, isOn);
 }
 
 static PyObject * widgetCheckboxTreeGetSel(snackWidget * s,
-                                             PyObject * args) {
+                                              PyObject * args) {
     void ** selection;
     int numselected;
     int i;
     PyObject * sel;
 
     if (!PyArg_ParseTuple(args, ""))
-       return NULL;
+        return NULL;
 
     selection = (void **) newtCheckboxTreeGetSelection(s->co, &numselected);
 
     sel = PyList_New(0);
     
     if (!selection) {
-       return sel;
+        return sel;
     }
 
     sel = PyList_New(0);
     for (i = 0; i < numselected; i++) {
-       PyList_Append(sel, PyInt_FromLong((long) selection[i]));
+        PyList_Append(sel, PyInt_FromLong((long) selection[i]));
     }
     free(selection);
 
@@ -1226,7 +1226,7 @@ void init_snack(void) {
     PyDict_SetItemString(d, "ANCHOR_TOP", PyInt_FromLong(NEWT_ANCHOR_TOP));
     PyDict_SetItemString(d, "ANCHOR_RIGHT", PyInt_FromLong(NEWT_ANCHOR_RIGHT));
     PyDict_SetItemString(d, "ANCHOR_BOTTOM", 
-                        PyInt_FromLong(NEWT_ANCHOR_BOTTOM));
+                         PyInt_FromLong(NEWT_ANCHOR_BOTTOM));
     PyDict_SetItemString(d, "GRID_GROWX", PyInt_FromLong(NEWT_GRID_FLAG_GROWX));
     PyDict_SetItemString(d, "GRID_GROWY", PyInt_FromLong(NEWT_GRID_FLAG_GROWY));
 
diff --git a/test.c b/test.c
index c1b9aa8d16045a5f8ff63b131fe54c991cdcb1e0..4c2074db54a9a91eaabdf6940a2f81c667048236 100644 (file)
--- a/test.c
+++ b/test.c
@@ -14,9 +14,9 @@ void disableCallback(newtComponent co, void * data) {
     struct callbackInfo * cbi = data;
 
     if (*cbi->state == ' ') {
-       newtEntrySetFlags(cbi->en, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET);
+        newtEntrySetFlags(cbi->en, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET);
     } else {
-       newtEntrySetFlags(cbi->en, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
+        newtEntrySetFlags(cbi->en, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
     }
 
     newtRefresh();
@@ -73,9 +73,9 @@ int main(void) {
     newtFormSetBackground(rsf, NEWT_COLORSET_CHECKBOX);
 
     for (i = 0; i < 10; i++) {
-       sprintf(buf, "Check %d", i);
-       cs[i] = newtCheckbox(3, 10 + i, buf, ' ', NULL, &results[i]);
-       newtFormAddComponent(chklist, cs[i]);
+        sprintf(buf, "Check %d", i);
+        cs[i] = newtCheckbox(3, 10 + i, buf, ' ', NULL, &results[i]);
+        newtFormAddComponent(chklist, cs[i]);
     }
 
     l1 = newtLabel(3, 6, "Scale:");
@@ -98,7 +98,7 @@ int main(void) {
     newtFormAddComponents(f, rsf, scale, NULL);
 
     lb = newtListbox(45, 1, 6, NEWT_FLAG_MULTIPLE | NEWT_FLAG_BORDER |
-                               NEWT_FLAG_SCROLL | NEWT_FLAG_SHOWCURSOR);
+                                NEWT_FLAG_SCROLL | NEWT_FLAG_SHOWCURSOR);
     newtListboxAppendEntry(lb, "First", (void *) 1);
     newtListboxAppendEntry(lb, "Second", (void *) 2);
     newtListboxAppendEntry(lb, "Third", (void *) 3);
@@ -124,18 +124,18 @@ int main(void) {
     newtFormSetTimer(f, 200);
 
     do {
-       newtFormRun(f, &es);
-
-       if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == b2) {
-           newtScaleSet(scale, atoi(scaleVal));
-           newtRefresh();
-           answer = NULL;
-       } else if (es.reason == NEWT_EXIT_TIMER) {
-           spinState++;
-           if (!*spinState) spinState = spinner;
-           sprintf(buf, "Spinner: %c", *spinState);
-           newtLabelSetText(timeLabel, buf);
-       }
+        newtFormRun(f, &es);
+
+        if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == b2) {
+            newtScaleSet(scale, atoi(scaleVal));
+            newtRefresh();
+            answer = NULL;
+        } else if (es.reason == NEWT_EXIT_TIMER) {
+            spinState++;
+            if (!*spinState) spinState = spinner;
+            sprintf(buf, "Spinner: %c", *spinState);
+            newtLabelSetText(timeLabel, buf);
+        }
     } while (es.reason != NEWT_EXIT_COMPONENT || es.u.co == b2);
 
     scaleVal = strdup(scaleVal);
@@ -156,8 +156,8 @@ int main(void) {
 
     printf("\nSelected listbox items (%d):\n", numsel);
     if(selectedList) {
-       for(i = 0; i < numsel; i++)
-           printf("#%d\n", (int) selectedList[i]);
+        for(i = 0; i < numsel; i++)
+            printf("#%d\n", (int) selectedList[i]);
     }
 
     return 0;
index 0d3aa85f9278219d4f9fc7c6b0f918d8b49238f6..f2b7c581786f528028b974843d79dbb962eeebb4 100644 (file)
@@ -14,11 +14,11 @@ int main(void) {
     char * menuContents[] = { "One", "Two", "Three", "Four", "Five", NULL };
     const char * entries[10];
     struct newtWinEntry autoEntries[] = {
-       { "An entry", entries + 0, 0 },
-       { "Another entry", entries + 1, 0 },
-       { "Third entry", entries + 2, 0 },
-       { "Fourth entry", entries + 3, 0 },
-       { NULL, NULL, 0 } };
+        { "An entry", entries + 0, 0 },
+        { "Another entry", entries + 1, 0 },
+        { "Third entry", entries + 2, 0 },
+        { "Fourth entry", entries + 3, 0 },
+        { NULL, NULL, 0 } };
 
     memset(entries, 0, sizeof(entries));
 
@@ -34,7 +34,7 @@ int main(void) {
 
     grid = newtCreateGrid(2, 2);
     newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, b1, 0, 0, 0, 0, 
-                       NEWT_ANCHOR_RIGHT, 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);
@@ -46,17 +46,17 @@ int main(void) {
     newtGridFree(grid, 1);
 
     answer = newtRunForm(f);
-       
+        
     newtFormDestroy(f);
     newtPopWindow();
 
     flowedText = newtReflowText("This is a quite a bit of text. It is 40 "
-                               "columns long, so some wrapping should be "
-                               "done. Did you know that the quick, brown "
-                               "fox jumped over the lazy dog?\n\n"
-                               "In other news, it's pretty important that we "
-                               "can properly force a line break.",
-                               40, 5, 5, &textWidth, &textHeight);
+                                "columns long, so some wrapping should be "
+                                "done. Did you know that the quick, brown "
+                                "fox jumped over the lazy dog?\n\n"
+                                "In other news, it's pretty important that we "
+                                "can properly force a line break.",
+                                40, 5, 5, &textWidth, &textHeight);
     t = newtTextbox(-1, -1, textWidth, textHeight, NEWT_FLAG_WRAP);
     newtTextboxSetText(t, flowedText);
     free(flowedText);
@@ -73,7 +73,7 @@ int main(void) {
 
     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);
+                        NEWT_GRID_FLAG_GROWX);
     newtGridWrappedWindow(grid, "another example");
     newtGridDestroy(grid, 1);
 
@@ -89,14 +89,14 @@ int main(void) {
 
     textWidth = 0;
     rc = newtWinMenu("Test Menu", "This is a sample invovation of the "
-                    "newtWinMenu() call. It may or may not have a scrollbar, "
-                    "depending on the need for one.", 50, 5, 5, 3, 
-                    menuContents, &textWidth, "Ok", "Cancel", NULL);
+                     "newtWinMenu() call. It may or may not have a scrollbar, "
+                     "depending on the need for one.", 50, 5, 5, 3, 
+                     menuContents, &textWidth, "Ok", "Cancel", NULL);
 
     rc = newtWinEntries("Text newtWinEntries()", "This is a sample invovation of "
-                    "newtWinEntries() call. It lets you get a lot of input "
-                    "quite easily.", 50, 5, 5, 20, autoEntries, "Ok", 
-                    "Cancel", NULL);
+                     "newtWinEntries() call. It lets you get a lot of input "
+                     "quite easily.", 50, 5, 5, 20, autoEntries, "Ok", 
+                     "Cancel", NULL);
 
     newtFinished();
 
index 62494b8b98ea369b6c53daf54c29ab97c298cc85..28d41c4953e2d7967ffb3e8df17bcf1088ba89d8 100644 (file)
@@ -20,73 +20,73 @@ int main(void) {
 
     checktree = newtCheckboxTreeMulti(-1, -1, 10, " ab", NEWT_FLAG_SCROLL);
     newtCheckboxTreeAddItem(checktree, "Numbers", (void *) 2, 0,
-                           NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Really really long thing",
-                          (void *) 3, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                           (void *) 3, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "number 5", (void *) 5, 
-                           NEWT_FLAG_SELECTED, 
-                           NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_FLAG_SELECTED, 
+                            NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "number 6", (void *) 6, 0, 
-                           NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "number 7", (void *) 7, 
-                           NEWT_FLAG_SELECTED, 
-                           NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_FLAG_SELECTED, 
+                            NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "number 8", (void *) 8, 0, 
-                           NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "number 9", (void *) 9, 0, 
-                           NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "number 10", (void *) 10,
-                           NEWT_FLAG_SELECTED,
-                           NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_FLAG_SELECTED,
+                            NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "number 11", (void *) 11, 0, 
-                           NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Donuts", (void *) 12,
-                           NEWT_FLAG_SELECTED,
-                           NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_FLAG_SELECTED,
+                            NEWT_ARG_APPEND, NEWT_ARG_LAST);
 
     newtCheckboxTreeAddItem(checktree, "Bavarian Cream", (void *) 301,
-                           NEWT_FLAG_SELECTED,
-                           9, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_FLAG_SELECTED,
+                            9, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Honey dipped", (void *) 302,
-                           NEWT_FLAG_SELECTED,
-                           9, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_FLAG_SELECTED,
+                            9, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Jelly", (void *) 303,
-                           NEWT_FLAG_SELECTED,
-                           9, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            NEWT_FLAG_SELECTED,
+                            9, NEWT_ARG_APPEND, NEWT_ARG_LAST);
 
     newtCheckboxTreeAddItem(checktree, "Colors", (void *) 1, 0,
-                           0, NEWT_ARG_LAST);
+                            0, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Red", (void *) 100, 0,
-                           0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "White", (void *) 101, 0,
-                           0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Blue", (void *) 102, 0,
-                           0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
 
     newtCheckboxTreeAddItem(checktree, "number 4", (void *) 4, 0,
-                           3, NEWT_ARG_LAST);
+                            3, NEWT_ARG_LAST);
 
     newtCheckboxTreeAddItem(checktree, "Single digit", (void *) 200, 0,
-                           1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "One", (void *) 201, 0,
-                           1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Two", (void *) 202, 0,
-                           1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Three", (void *) 203, 0,
-                           1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Four", (void *) 204, 0,
-                           1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, 0, NEWT_ARG_APPEND, NEWT_ARG_LAST);
 
     newtCheckboxTreeAddItem(checktree, "Double digit", (void *) 300, 0,
-                           1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Ten", (void *) 210, 0,
-                           1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Eleven", (void *) 211, 0,
-                           1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Twelve", (void *) 212, 0,
-                           1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
     newtCheckboxTreeAddItem(checktree, "Thirteen", (void *) 213, 0,
-                           1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
+                            1, 1, NEWT_ARG_APPEND, NEWT_ARG_LAST);
 
     newtCheckboxTreeSetCurrent(checktree, (void *) 12);
 
@@ -94,9 +94,9 @@ int main(void) {
     
     grid = newtCreateGrid(1, 2);
     newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, checktree, 0, 0, 0, 1, 
-                    NEWT_ANCHOR_RIGHT, 0);
+                     NEWT_ANCHOR_RIGHT, 0);
     newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, button, 0, 0, 0, 0, 
-                    0, 0);
+                     0, 0);
 
     newtGridWrappedWindow(grid, "Checkbox Tree Test");
     newtGridFree(grid, 1);
@@ -111,26 +111,26 @@ int main(void) {
     result = newtCheckboxTreeGetSelection(checktree, &numselected);
     ptr = result;
     if (!result || !numselected)
-       printf("none selected\n");
+        printf("none selected\n");
     else
-       printf("Current selection (all) (%d):\n", numselected);
+        printf("Current selection (all) (%d):\n", numselected);
     for (i = 0; i < numselected; i++) {
-       j = (int) *ptr++;
-       printf("%d\n", j);
+        j = (int) *ptr++;
+        printf("%d\n", j);
     }
     result = newtCheckboxTreeGetMultiSelection(checktree, &numselected, 'b');
     ptr = result;
     if (!result || !numselected)
-       printf("none selected\n");
+        printf("none selected\n");
     else
-       printf("Current selection (b) (%d):\n",numselected);
+        printf("Current selection (b) (%d):\n",numselected);
     for (i = 0; i < numselected; i++) {
-       j = (int) *ptr++;
-       printf("%d\n", j);
+        j = (int) *ptr++;
+        printf("%d\n", j);
     }
-       
+        
     if (result)
-       free(result);
+        free(result);
 
     list = newtCheckboxTreeFindItem(checktree, (void *) 213);
     printf("path:");
index 68742cfef46c3720853f41ef76d467de2c44633c..abb5c921e1bad7cb7a897aff2e733d0c4c93119f 100644 (file)
--- a/textbox.c
+++ b/textbox.c
@@ -24,9 +24,9 @@ static char * expandTabs(const char * text);
 static void textboxDraw(newtComponent co);
 static void addLine(newtComponent co, const char * s, int len);
 static void doReflow(const char * text, char ** resultPtr, int width, 
-                    int * badness, int * heightPtr);
+                     int * badness, int * heightPtr);
 static struct eventResult textboxEvent(newtComponent c,
-                                     struct event ev);
+                                      struct event ev);
 static void textboxDestroy(newtComponent co);
 static void textboxPlace(newtComponent co, int newLeft, int newTop);
 static void textboxMapped(newtComponent co, int isMapped);
@@ -44,7 +44,7 @@ static void textboxMapped(newtComponent co, int isMapped) {
 
     co->isMapped = isMapped;
     if (tb->sb)
-       tb->sb->ops->mapped(tb->sb, isMapped);
+        tb->sb->ops->mapped(tb->sb, isMapped);
 }
 
 static void textboxPlace(newtComponent co, int newLeft, int newTop) {
@@ -54,7 +54,7 @@ static void textboxPlace(newtComponent co, int newLeft, int newTop) {
     co->left = newLeft;
 
     if (tb->sb)
-       tb->sb->ops->place(tb->sb, co->left + co->width - 1, co->top);
+        tb->sb->ops->place(tb->sb, co->left + co->width - 1, co->top);
 }
 
 void newtTextboxSetHeight(newtComponent co, int height) {
@@ -68,13 +68,13 @@ int newtTextboxGetNumLines(newtComponent co) {
 }
 
 newtComponent newtTextboxReflowed(int left, int top, char * text, int width,
-                                 int flexDown, int flexUp, int flags) {
+                                  int flexDown, int flexUp, int flags) {
     newtComponent co;
     char * reflowedText;
     int actWidth, actHeight;
 
     reflowedText = newtReflowText(text, width, flexDown, flexUp,
-                                 &actWidth, &actHeight);
+                                  &actWidth, &actHeight);
     
     co = newtTextbox(left, top, actWidth, actHeight, NEWT_FLAG_WRAP);
     newtTextboxSetText(co, reflowedText);
@@ -110,11 +110,11 @@ newtComponent newtTextbox(int left, int top, int width, int height, int flags) {
     tb->blankline[width] = '\0';
 
     if (flags & NEWT_FLAG_SCROLL) {
-       co->width += 2;
-       tb->sb = newtVerticalScrollbar(co->left + co->width - 1, co->top, 
-                          co->height, COLORSET_TEXTBOX, COLORSET_TEXTBOX);
+        co->width += 2;
+        tb->sb = newtVerticalScrollbar(co->left + co->width - 1, co->top, 
+                           co->height, COLORSET_TEXTBOX, COLORSET_TEXTBOX);
     } else {
-       tb->sb = NULL;
+        tb->sb = NULL;
     }
 
     return co;
@@ -130,24 +130,24 @@ static char * expandTabs(const char * text) {
 
     buf = malloc(bufAlloced + 1);
     for (src = text, dest = buf; *src; src++) {
-       if ((bufUsed + 10) > bufAlloced) {
-           bufAlloced += strlen(text) / 2;
-           buf = realloc(buf, bufAlloced + 1);
-           dest = buf + bufUsed;
-       }
-       if (*src == '\t') {
-           i = 8 - (linePos & 8);
-           memset(dest, ' ', i);
-           dest += i, bufUsed += i, linePos += i;
-       } else {
-           if (*src == '\n')
-               linePos = 0;
-           else
-               linePos++;
-
-           *dest++ = *src;
-           bufUsed++;
-       }
+        if ((bufUsed + 10) > bufAlloced) {
+            bufAlloced += strlen(text) / 2;
+            buf = realloc(buf, bufAlloced + 1);
+            dest = buf + bufUsed;
+        }
+        if (*src == '\t') {
+            i = 8 - (linePos & 8);
+            memset(dest, ' ', i);
+            dest += i, bufUsed += i, linePos += i;
+        } else {
+            if (*src == '\n')
+                linePos = 0;
+            else
+                linePos++;
+
+            *dest++ = *src;
+            bufUsed++;
+        }
     }
 
     *dest = '\0';
@@ -155,7 +155,7 @@ static char * expandTabs(const char * text) {
 }
 
 static void doReflow(const char * text, char ** resultPtr, int width, 
-                    int * badness, int * heightPtr) {
+                     int * badness, int * heightPtr) {
     char * result = NULL;
     const char * chptr, * end;
     int i;
@@ -165,77 +165,77 @@ static void doReflow(const char * text, char ** resultPtr, int width,
     mbstate_t ps;
 
     if (resultPtr) {
-       /* XXX I think this will work */
-       result = malloc(strlen(text) + (strlen(text) / width) + 2);
-       *result = '\0';
+        /* XXX I think this will work */
+        result = malloc(strlen(text) + (strlen(text) / width) + 2);
+        *result = '\0';
     }
-       
+        
     memset(&ps,0,sizeof(mbstate_t));
     while (*text) {
-       end = strchr(text, '\n');
-       if (!end)
-           end = text + strlen(text);
-
-       while (*text && text <= end) {
-           int len;
-               
-           len = wstrlen(text, end - text);
-           if (len < width) {
-               if (result) {
-                   strncat(result, text, end - text);
-                   strcat(result, "\n");
-                   height++;
-               }
-
-               if (len < (width / 2)) {
-#ifdef DEBUG_WRAP                  
-               fprintf(stderr,"adding %d\n",((width / 2) - (len)) / 2);
-#endif                                 
-                   howbad += ((width / 2) - (len)) / 2;
-               }
-               text = end;
-               if (*text) text++;
-           } else {
-               const char *spcptr = NULL;
-               int spc =0,w2, x;
-
-               chptr = text;
-               w2 = 0;
-               for (i = 0; i < width - 1;) {
-                       if ((x=mbrtowc(&tmp,chptr,end-chptr,&ps))<=0)
-                               break;
-                       if (spc && !iswspace(tmp))
-                               spc = 0;
-                       else if (!spc && iswspace(tmp)) {
-                               spc = 1;
-                               spcptr = chptr;
-                               w2 = i;
-                       }
-                       chptr += x;
-                       x = wcwidth(tmp);
-                       if (x>0)
-                           i+=x;
-               }
-               howbad += width - w2 + 1;
-#ifdef DEBUG_WRAP                  
-               fprintf(stderr,"adding %d\n",width - w2 + 1, chptr);
-#endif                                 
-               if (spcptr) chptr = spcptr;
-               if (result) {
-                   strncat(result, text, chptr - text );
-                   strcat(result, "\n");
-                   height++;
-               }
-
-               text = chptr;
-               while (1) {
-                       if ((x=mbrtowc(&tmp,text,end-text,NULL))<=0)
-                               break;
-                       if (!iswspace(tmp)) break;
-                       text += x;
-               }
-           }
-       }
+        end = strchr(text, '\n');
+        if (!end)
+            end = text + strlen(text);
+
+        while (*text && text <= end) {
+            int len;
+                
+            len = wstrlen(text, end - text);
+            if (len < width) {
+                if (result) {
+                    strncat(result, text, end - text);
+                    strcat(result, "\n");
+                    height++;
+                }
+
+                if (len < (width / 2)) {
+#ifdef DEBUG_WRAP                   
+                fprintf(stderr,"adding %d\n",((width / 2) - (len)) / 2);
+#endif                                  
+                    howbad += ((width / 2) - (len)) / 2;
+                }
+                text = end;
+                if (*text) text++;
+            } else {
+                const char *spcptr = NULL;
+                int spc =0,w2, x;
+
+                chptr = text;
+                w2 = 0;
+                for (i = 0; i < width - 1;) {
+                        if ((x=mbrtowc(&tmp,chptr,end-chptr,&ps))<=0)
+                                break;
+                        if (spc && !iswspace(tmp))
+                                spc = 0;
+                        else if (!spc && iswspace(tmp)) {
+                                spc = 1;
+                                spcptr = chptr;
+                                w2 = i;
+                        }
+                        chptr += x;
+                        x = wcwidth(tmp);
+                        if (x>0)
+                            i+=x;
+                }
+                howbad += width - w2 + 1;
+#ifdef DEBUG_WRAP                   
+                fprintf(stderr,"adding %d\n",width - w2 + 1, chptr);
+#endif                                  
+                if (spcptr) chptr = spcptr;
+                if (result) {
+                    strncat(result, text, chptr - text );
+                    strcat(result, "\n");
+                    height++;
+                }
+
+                text = chptr;
+                while (1) {
+                        if ((x=mbrtowc(&tmp,text,end-text,NULL))<=0)
+                                break;
+                        if (!iswspace(tmp)) break;
+                        text += x;
+                }
+            }
+        }
     }
 
     if (badness) *badness = howbad;
@@ -247,7 +247,7 @@ static void doReflow(const char * text, char ** resultPtr, int width,
 }
 
 char * newtReflowText(char * text, int width, int flexDown, int flexUp,
-                     int * actualWidth, int * actualHeight) {
+                      int * actualWidth, int * actualHeight) {
     int min, max;
     int i;
     char * result;
@@ -257,22 +257,22 @@ char * newtReflowText(char * text, int width, int flexDown, int flexUp,
     expandedText = expandTabs(text);
 
     if (flexDown || flexUp) {
-       min = width - flexDown;
-       max = width + flexUp;
+        min = width - flexDown;
+        max = width + flexUp;
 
-       minbad = -1;
-       minbadwidth = width;
+        minbad = -1;
+        minbadwidth = width;
 
-       for (i = min; i <= max; i++) {
-           doReflow(expandedText, NULL, i, &howbad, NULL);
+        for (i = min; i <= max; i++) {
+            doReflow(expandedText, NULL, i, &howbad, NULL);
 
-           if (minbad == -1 || howbad < minbad) {
-               minbad = howbad;
-               minbadwidth = i;
-           }
-       }
+            if (minbad == -1 || howbad < minbad) {
+                minbad = howbad;
+                minbadwidth = i;
+            }
+        }
 
-       width = minbadwidth;
+        width = minbadwidth;
     }
 
     doReflow(expandedText, &result, width, NULL, actualHeight);
@@ -288,20 +288,20 @@ void newtTextboxSetText(newtComponent co, const char * text) {
     int badness, height;
 
     if (tb->lines) {
-       free(tb->lines);
-       tb->linesAlloced = tb->numLines = 0;
+        free(tb->lines);
+        tb->linesAlloced = tb->numLines = 0;
     }
 
     expanded = expandTabs(text);
 
     if (tb->doWrap) {
-       doReflow(expanded, &reflowed, tb->textWidth, &badness, &height);
-       free(expanded);
-       expanded = reflowed;
+        doReflow(expanded, &reflowed, tb->textWidth, &badness, &height);
+        free(expanded);
+        expanded = reflowed;
     }
 
     for (start = expanded; *start; start++)
-       if (*start == '\n') tb->linesAlloced++;
+        if (*start == '\n') tb->linesAlloced++;
 
     /* This ++ leaves room for an ending line w/o a \n */
     tb->linesAlloced++;
@@ -309,12 +309,12 @@ void newtTextboxSetText(newtComponent co, const char * text) {
 
     start = expanded;
     while ((end = strchr(start, '\n'))) {
-       addLine(co, start, end - start);
-       start = end + 1;
+        addLine(co, start, end - start);
+        start = end + 1;
     }
 
     if (*start)
-       addLine(co, start, strlen(start));
+        addLine(co, start, strlen(start));
 
     free(expanded);
     
@@ -326,7 +326,7 @@ static void addLine(newtComponent co, const char * s, int len) {
     struct textbox * tb = co->data;
 
     while (wstrlen(s,len) > tb->textWidth) {
-           len--;
+            len--;
     }
     tb->lines[tb->numLines] = malloc(len + 1);
     memcpy(tb->lines[tb->numLines], s, len);
@@ -339,77 +339,77 @@ static void textboxDraw(newtComponent c) {
     int size;
 
     if (tb->sb) {
-       size = tb->numLines - c->height;
-       newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0);
-       tb->sb->ops->draw(tb->sb);
+        size = tb->numLines - c->height;
+        newtScrollbarSet(tb->sb, tb->topLine, size ? size : 0);
+        tb->sb->ops->draw(tb->sb);
     }
 
     SLsmg_set_color(NEWT_COLORSET_TEXTBOX);
 
     for (i = 0; (i + tb->topLine) < tb->numLines && i < c->height; i++) {
-       newtGotorc(c->top + i, c->left);
-       SLsmg_write_string(tb->blankline);
-       newtGotorc(c->top + i, c->left);
-       SLsmg_write_string(tb->lines[i + tb->topLine]);
+        newtGotorc(c->top + i, c->left);
+        SLsmg_write_string(tb->blankline);
+        newtGotorc(c->top + i, c->left);
+        SLsmg_write_string(tb->lines[i + tb->topLine]);
     }
 }
 
 static struct eventResult textboxEvent(newtComponent co, 
-                                     struct event ev) {
+                                      struct event ev) {
     struct textbox * tb = co->data;
     struct eventResult er;
 
     er.result = ER_IGNORED;
 
     if (ev.when == EV_EARLY && ev.event == EV_KEYPRESS && tb->sb) {
-       newtTrashScreen();
-       switch (ev.u.key) {
-         case NEWT_KEY_UP:
-           if (tb->topLine) tb->topLine--;
-           textboxDraw(co);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case NEWT_KEY_DOWN:
-           if (tb->topLine < (tb->numLines - co->height)) tb->topLine++;
-           textboxDraw(co);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case NEWT_KEY_PGDN:
-           tb->topLine += co->height;
-           if (tb->topLine > (tb->numLines - co->height)) {
-               tb->topLine = tb->numLines - co->height;
-               if (tb->topLine < 0) tb->topLine = 0;
-           }
-           textboxDraw(co);
-           er.result = ER_SWALLOWED;
-           break;
-
-         case NEWT_KEY_PGUP:
-           tb->topLine -= co->height;
-           if (tb->topLine < 0) tb->topLine = 0;
-           textboxDraw(co);
-           er.result = ER_SWALLOWED;
-           break;
-       }
+        newtTrashScreen();
+        switch (ev.u.key) {
+          case NEWT_KEY_UP:
+            if (tb->topLine) tb->topLine--;
+            textboxDraw(co);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case NEWT_KEY_DOWN:
+            if (tb->topLine < (tb->numLines - co->height)) tb->topLine++;
+            textboxDraw(co);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case NEWT_KEY_PGDN:
+            tb->topLine += co->height;
+            if (tb->topLine > (tb->numLines - co->height)) {
+                tb->topLine = tb->numLines - co->height;
+                if (tb->topLine < 0) tb->topLine = 0;
+            }
+            textboxDraw(co);
+            er.result = ER_SWALLOWED;
+            break;
+
+          case NEWT_KEY_PGUP:
+            tb->topLine -= co->height;
+            if (tb->topLine < 0) tb->topLine = 0;
+            textboxDraw(co);
+            er.result = ER_SWALLOWED;
+            break;
+        }
     }
     if (ev.when == EV_EARLY && ev.event == EV_MOUSE && tb->sb) {
-       /* Top scroll arrow */
-       if (ev.u.mouse.x == co->width && ev.u.mouse.y == co->top) {
-           if (tb->topLine) tb->topLine--;
-           textboxDraw(co);
-           
-           er.result = ER_SWALLOWED;
-       }
-       /* Bottom scroll arrow */
-       if (ev.u.mouse.x == co->width &&
-           ev.u.mouse.y == co->top + co->height - 1) {
-           if (tb->topLine < (tb->numLines - co->height)) tb->topLine++;
-           textboxDraw(co);
-           
-           er.result = ER_SWALLOWED;
-       }
+        /* Top scroll arrow */
+        if (ev.u.mouse.x == co->width && ev.u.mouse.y == co->top) {
+            if (tb->topLine) tb->topLine--;
+            textboxDraw(co);
+            
+            er.result = ER_SWALLOWED;
+        }
+        /* Bottom scroll arrow */
+        if (ev.u.mouse.x == co->width &&
+            ev.u.mouse.y == co->top + co->height - 1) {
+            if (tb->topLine < (tb->numLines - co->height)) tb->topLine++;
+            textboxDraw(co);
+            
+            er.result = ER_SWALLOWED;
+        }
     }
     return er;
 }
@@ -419,7 +419,7 @@ static void textboxDestroy(newtComponent co) {
     struct textbox * tb = co->data;
 
     for (i = 0; i < tb->numLines; i++) 
-       free(tb->lines[i]);
+        free(tb->lines[i]);
     free(tb->lines);
     free(tb->blankline);
     free(tb);
index 6b9a4fb8f3c9ccd465d8a541bdd98279075b2df3..be5fd41e43e835b68b95fea7cc6af405759f4812 100644 (file)
 #include "newt.h"
 
 enum mode { MODE_NONE, MODE_INFOBOX, MODE_MSGBOX, MODE_YESNO, MODE_CHECKLIST,
-           MODE_INPUTBOX, MODE_RADIOLIST, MODE_MENU, MODE_GAUGE,
+            MODE_INPUTBOX, MODE_RADIOLIST, MODE_MENU, MODE_GAUGE,
             MODE_TEXTBOX };
 
-#define OPT_MSGBOX             1000
-#define OPT_CHECKLIST          1001
-#define OPT_YESNO              1002
-#define OPT_INPUTBOX           1003
-#define OPT_FULLBUTTONS        1004
-#define OPT_MENU               1005
-#define OPT_RADIOLIST          1006
-#define OPT_GAUGE              1007
-#define OPT_INFOBOX            1008
-#define OPT_TEXTBOX            1009
+#define OPT_MSGBOX              1000
+#define OPT_CHECKLIST           1001
+#define OPT_YESNO               1002
+#define OPT_INPUTBOX            1003
+#define OPT_FULLBUTTONS         1004
+#define OPT_MENU                1005
+#define OPT_RADIOLIST           1006
+#define OPT_GAUGE               1007
+#define OPT_INFOBOX             1008
+#define OPT_TEXTBOX             1009
 
 static void usage(void) {
     newtFinished(); 
@@ -82,89 +82,89 @@ int main(int argc, const char ** argv) {
     char * title = NULL;
     char * backtitle = NULL;
     struct poptOption optionsTable[] = {
-           { "backtitle", '\0', POPT_ARG_STRING, &backtitle, 0 },
-           { "checklist", '\0', 0, 0, OPT_CHECKLIST },
-           { "clear", '\0', 0, &clear, 0 },
-           { "defaultno", '\0', 0, &defaultNo, 0 },
-           { "inputbox", '\0', 0, 0, OPT_INPUTBOX },
-           { "fb", '\0', 0, 0, OPT_FULLBUTTONS },
-           { "fullbuttons", '\0', 0, 0, OPT_FULLBUTTONS },
-           { "gauge", '\0', 0, 0, OPT_GAUGE },
-           { "infobox", '\0', 0, 0, OPT_INFOBOX },
-           { "menu", '\0', 0, 0, OPT_MENU },
-           { "msgbox", '\0', 0, 0, OPT_MSGBOX },
-           { "nocancel", '\0', 0, &noCancel, 0 },
-           { "noitem", '\0', 0, &noItem, 0 },
-           { "notags", '\0', 0, &noTags, 0 },
-           { "radiolist", '\0', 0, 0, OPT_RADIOLIST },
-           { "scrolltext", '\0', 0, &scrollText, 0 },
-           { "separate-output", '\0', 0, &separateOutput, 0 },
-           { "title", '\0', POPT_ARG_STRING, &title, 0 },
-           { "yesno", '\0', 0, 0, OPT_YESNO },
-           { "textbox", '\0', 0, 0, OPT_TEXTBOX },
-           { 0, 0, 0, 0, 0 } 
+            { "backtitle", '\0', POPT_ARG_STRING, &backtitle, 0 },
+            { "checklist", '\0', 0, 0, OPT_CHECKLIST },
+            { "clear", '\0', 0, &clear, 0 },
+            { "defaultno", '\0', 0, &defaultNo, 0 },
+            { "inputbox", '\0', 0, 0, OPT_INPUTBOX },
+            { "fb", '\0', 0, 0, OPT_FULLBUTTONS },
+            { "fullbuttons", '\0', 0, 0, OPT_FULLBUTTONS },
+            { "gauge", '\0', 0, 0, OPT_GAUGE },
+            { "infobox", '\0', 0, 0, OPT_INFOBOX },
+            { "menu", '\0', 0, 0, OPT_MENU },
+            { "msgbox", '\0', 0, 0, OPT_MSGBOX },
+            { "nocancel", '\0', 0, &noCancel, 0 },
+            { "noitem", '\0', 0, &noItem, 0 },
+            { "notags", '\0', 0, &noTags, 0 },
+            { "radiolist", '\0', 0, 0, OPT_RADIOLIST },
+            { "scrolltext", '\0', 0, &scrollText, 0 },
+            { "separate-output", '\0', 0, &separateOutput, 0 },
+            { "title", '\0', POPT_ARG_STRING, &title, 0 },
+            { "yesno", '\0', 0, 0, OPT_YESNO },
+            { "textbox", '\0', 0, 0, OPT_TEXTBOX },
+            { 0, 0, 0, 0, 0 } 
     };
     
     optCon = poptGetContext("whiptail", argc, argv, optionsTable, 0);
 
     while ((arg = poptGetNextOpt(optCon)) > 0) {
-       optArg = poptGetOptArg(optCon);
-
-       switch (arg) {
-         case OPT_INFOBOX:
-           if (mode != MODE_NONE) usage();
-           mode = MODE_INFOBOX;
-           break;
-
-         case OPT_MENU:
-           if (mode != MODE_NONE) usage();
-           mode = MODE_MENU;
-           break;
-
-         case OPT_MSGBOX:
-           if (mode != MODE_NONE) usage();
-           mode = MODE_MSGBOX;
-           break;
+        optArg = poptGetOptArg(optCon);
+
+        switch (arg) {
+          case OPT_INFOBOX:
+            if (mode != MODE_NONE) usage();
+            mode = MODE_INFOBOX;
+            break;
+
+          case OPT_MENU:
+            if (mode != MODE_NONE) usage();
+            mode = MODE_MENU;
+            break;
+
+          case OPT_MSGBOX:
+            if (mode != MODE_NONE) usage();
+            mode = MODE_MSGBOX;
+            break;
           case OPT_TEXTBOX:
             if (mode != MODE_NONE) usage();
             mode = MODE_TEXTBOX;
             break;
-         case OPT_RADIOLIST:
-           if (mode != MODE_NONE) usage();
-           mode = MODE_RADIOLIST;
-           break;
-
-         case OPT_CHECKLIST:
-           if (mode != MODE_NONE) usage();
-           mode = MODE_CHECKLIST;
-           break;
-
-         case OPT_FULLBUTTONS:
-           useFullButtons(1);
-           break;
-
-         case OPT_YESNO:
-           if (mode != MODE_NONE) usage();
-           mode = MODE_YESNO;
-           break;
-
-         case OPT_GAUGE:
-           if (mode != MODE_NONE) usage();
-           mode = MODE_GAUGE;
-           break;
-
-         case OPT_INPUTBOX:
-           if (mode != MODE_NONE) usage();
-           mode = MODE_INPUTBOX;
-           break;
-       }
+          case OPT_RADIOLIST:
+            if (mode != MODE_NONE) usage();
+            mode = MODE_RADIOLIST;
+            break;
+
+          case OPT_CHECKLIST:
+            if (mode != MODE_NONE) usage();
+            mode = MODE_CHECKLIST;
+            break;
+
+          case OPT_FULLBUTTONS:
+            useFullButtons(1);
+            break;
+
+          case OPT_YESNO:
+            if (mode != MODE_NONE) usage();
+            mode = MODE_YESNO;
+            break;
+
+          case OPT_GAUGE:
+            if (mode != MODE_NONE) usage();
+            mode = MODE_GAUGE;
+            break;
+
+          case OPT_INPUTBOX:
+            if (mode != MODE_NONE) usage();
+            mode = MODE_INPUTBOX;
+            break;
+        }
     }
     
     if (arg < -1) {
-       fprintf(stderr, "%s: %s\n", 
-               poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 
-               poptStrerror(arg));
-       exit(1);
+        fprintf(stderr, "%s: %s\n", 
+                poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 
+                poptStrerror(arg));
+        exit(1);
     }
 
     output = fdopen (outputfd, "w");
@@ -188,9 +188,9 @@ int main(int argc, const char ** argv) {
     if (*end) usage();
 
     if (mode == MODE_GAUGE) {
-       fd = dup(0);
-       close(0);
-       if (open("/dev/tty", O_RDWR) != 0) perror("open /dev/tty");
+        fd = dup(0);
+        close(0);
+        if (open("/dev/tty", O_RDWR) != 0) perror("open /dev/tty");
     }
 
     newtInit();
@@ -200,7 +200,7 @@ int main(int argc, const char ** argv) {
     newtOpenWindow((80 - width) / 2, (24 - height) / 2, width, height, title);
 
     if (backtitle)
-       newtDrawRootText(0, 0, backtitle);
+        newtDrawRootText(0, 0, backtitle);
 
     if (noCancel) flags |= FLAG_NOCANCEL;
     if (noItem) flags |= FLAG_NOITEM;
@@ -211,65 +211,65 @@ int main(int argc, const char ** argv) {
     switch (mode) {
       case MODE_MSGBOX:
       case MODE_TEXTBOX:
-       rc = messageBox(text, height, width, MSGBOX_MSG, flags);
-       break;
+        rc = messageBox(text, height, width, MSGBOX_MSG, flags);
+        break;
 
       case MODE_INFOBOX:
-       rc = messageBox(text, height, width, MSGBOX_INFO, flags);
-       break;
+        rc = messageBox(text, height, width, MSGBOX_INFO, flags);
+        break;
 
       case MODE_YESNO:
-       rc = messageBox(text, height, width, MSGBOX_YESNO, flags);
-       break;
+        rc = messageBox(text, height, width, MSGBOX_YESNO, flags);
+        break;
 
       case MODE_INPUTBOX:
-       rc = inputBox(text, height, width, optCon, flags, &result);
+        rc = inputBox(text, height, width, optCon, flags, &result);
         if (rc == DLG_OKAY) fprintf(output, "%s", result);
-       break;
+        break;
 
       case MODE_MENU:
-       rc = listBox(text, height, width, optCon, flags, &result);
-       if (rc == DLG_OKAY) fprintf(output, "%s", result);
-       break;
+        rc = listBox(text, height, width, optCon, flags, &result);
+        if (rc == DLG_OKAY) fprintf(output, "%s", result);
+        break;
 
       case MODE_RADIOLIST:
-       rc = checkList(text, height, width, optCon, 1, flags, &selections);
+        rc = checkList(text, height, width, optCon, 1, flags, &selections);
         if (rc == DLG_OKAY) {
             fprintf(output, "%s", selections[0]);
-           free(selections);
-       }
-       break;
+            free(selections);
+        }
+        break;
 
       case MODE_CHECKLIST:
-       rc = checkList(text, height, width, optCon, 0, flags, &selections);
-
-       if (!rc) {
-           for (next = selections; *next; next++) {
-               if (!separateOutput) {
-                   if (needSpace) putc(' ', output);
-                   fprintf(output, "\"%s\"", *next);
-                   needSpace = 1;
-               } else {
-                   fprintf(output, "%s\n", *next);
-               }
-           }
-
-           free(selections);
-       }
-       break;
+        rc = checkList(text, height, width, optCon, 0, flags, &selections);
+
+        if (!rc) {
+            for (next = selections; *next; next++) {
+                if (!separateOutput) {
+                    if (needSpace) putc(' ', output);
+                    fprintf(output, "\"%s\"", *next);
+                    needSpace = 1;
+                } else {
+                    fprintf(output, "%s\n", *next);
+                }
+            }
+
+            free(selections);
+        }
+        break;
 
       case MODE_GAUGE:
-       rc = gauge(text, height, width, optCon, fd, flags);
-       break;
+        rc = gauge(text, height, width, optCon, fd, flags);
+        break;
 
       default:
-       usage();
+        usage();
     }
 
     if (rc == -1) usage();
 
     if (clear)
-       newtPopWindow();
+        newtPopWindow();
     newtFinished();
 
     return rc;
index 6e496f84c785803dadff8570c2834de3cef13b3d..a5fd027dec4793e134cca701c09f9cc8cc5416e0 100644 (file)
--- a/whiptcl.c
+++ b/whiptcl.c
@@ -7,21 +7,21 @@
 #include "tcl.h"
 
 enum mode { MODE_NONE, MODE_MSGBOX, MODE_YESNO, MODE_CHECKLIST, MODE_INPUTBOX,
-           MODE_RADIOLIST, MODE_MENU };
+            MODE_RADIOLIST, MODE_MENU };
 
-#define OPT_MSGBOX             1000
-#define OPT_CHECKLIST          1001
-#define OPT_YESNO              1002
-#define OPT_INPUTBOX           1003
-#define OPT_MENU               1005
-#define OPT_RADIOLIST          1006
+#define OPT_MSGBOX              1000
+#define OPT_CHECKLIST           1001
+#define OPT_YESNO               1002
+#define OPT_INPUTBOX            1003
+#define OPT_MENU                1005
+#define OPT_RADIOLIST           1006
 
 static char * setBacktext(ClientData data, Tcl_Interp * interp, 
-                         char * name1, char * name2, int flags);
+                          char * name1, char * name2, int flags);
 static char * setHelptext(ClientData data, Tcl_Interp * interp,
-                         char * name1, char * name2, int flags);
+                          char * name1, char * name2, int flags);
 static char * setFullButtons(ClientData data, Tcl_Interp * interp, 
-                            char * name1, char * name2, int flags);
+                             char * name1, char * name2, int flags);
 
 static int wtFinish(ClientData clientData, Tcl_Interp * interp, int argc,
                   char ** argv) {
@@ -38,13 +38,13 @@ static int wtInit(ClientData clientData, Tcl_Interp * interp, int argc,
     newtPushHelpLine("");
 
     Tcl_TraceVar(interp, "whiptcl_backtext", 
-                TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, setBacktext, NULL);
+                 TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, setBacktext, NULL);
     Tcl_TraceVar(interp, "whiptcl_helpline", 
-                TCL_TRACE_WRITES | TCL_TRACE_UNSETS | TCL_GLOBAL_ONLY, 
-                setHelptext, NULL);
+                 TCL_TRACE_WRITES | TCL_TRACE_UNSETS | TCL_GLOBAL_ONLY, 
+                 setHelptext, NULL);
     Tcl_TraceVar(interp, "whiptcl_fullbuttons", 
-                TCL_TRACE_WRITES | TCL_TRACE_UNSETS | TCL_GLOBAL_ONLY, 
-                setFullButtons, NULL);
+                 TCL_TRACE_WRITES | TCL_TRACE_UNSETS | TCL_GLOBAL_ONLY, 
+                 setFullButtons, NULL);
 
     Tcl_SetVar(interp, "whiptcl_helpline", "", TCL_GLOBAL_ONLY);
     Tcl_SetVar(interp, "whiptcl_fullbuttons", "1", TCL_GLOBAL_ONLY);
@@ -73,100 +73,100 @@ static int wtCmd(ClientData clientData, Tcl_Interp * interp, int argc,
     const char ** selections, ** next;
     char * title = NULL;
     struct poptOption optionsTable[] = {
-           { "checklist", '\0', 0, 0, OPT_CHECKLIST },
-           { "defaultno", '\0', 0, &defaultNo, 0 },
-           { "inputbox", '\0', 0, 0, OPT_INPUTBOX },
-           { "menu", '\0', 0, 0, OPT_MENU },
-           { "msgbox", '\0', 0, 0, OPT_MSGBOX },
-           { "nocancel", '\0', 0, &noCancel, 0 },
-           { "noitem", '\0', 0, &noItem, 0 },
-           { "radiolist", '\0', 0, 0, OPT_RADIOLIST },
-           { "scrolltext", '\0', 0, &scrollText, 0 },
-           { "title", '\0', POPT_ARG_STRING, &title, 0 },
-           { "yesno", '\0', 0, 0, OPT_YESNO },
-           { 0, 0, 0, 0, 0 } 
+            { "checklist", '\0', 0, 0, OPT_CHECKLIST },
+            { "defaultno", '\0', 0, &defaultNo, 0 },
+            { "inputbox", '\0', 0, 0, OPT_INPUTBOX },
+            { "menu", '\0', 0, 0, OPT_MENU },
+            { "msgbox", '\0', 0, 0, OPT_MSGBOX },
+            { "nocancel", '\0', 0, &noCancel, 0 },
+            { "noitem", '\0', 0, &noItem, 0 },
+            { "radiolist", '\0', 0, 0, OPT_RADIOLIST },
+            { "scrolltext", '\0', 0, &scrollText, 0 },
+            { "title", '\0', POPT_ARG_STRING, &title, 0 },
+            { "yesno", '\0', 0, 0, OPT_YESNO },
+            { 0, 0, 0, 0, 0 } 
     };
     
     optCon = poptGetContext("whiptcl", argc, argv, optionsTable, 0);
 
     while ((arg = poptGetNextOpt(optCon)) > 0) {
-       optArg = poptGetOptArg(optCon);
-
-       switch (arg) {
-         case OPT_MENU:
-           if (mode != MODE_NONE) rc = -1;
-           mode = MODE_MENU;
-           break;
-
-         case OPT_MSGBOX:
-           if (mode != MODE_NONE) rc = -1;
-           mode = MODE_MSGBOX;
-           break;
-
-         case OPT_RADIOLIST:
-           if (mode != MODE_NONE) rc = -1;
-           mode = MODE_RADIOLIST;
-           break;
-
-         case OPT_CHECKLIST:
-           if (mode != MODE_NONE) rc = -1;
-           mode = MODE_CHECKLIST;
-           break;
-
-         case OPT_YESNO:
-           if (mode != MODE_NONE) rc = -1;
-           mode = MODE_YESNO;
-           break;
-
-         case OPT_INPUTBOX:
-           if (mode != MODE_NONE) rc = -1;
-           mode = MODE_INPUTBOX;
-           break;
-       }
+        optArg = poptGetOptArg(optCon);
+
+        switch (arg) {
+          case OPT_MENU:
+            if (mode != MODE_NONE) rc = -1;
+            mode = MODE_MENU;
+            break;
+
+          case OPT_MSGBOX:
+            if (mode != MODE_NONE) rc = -1;
+            mode = MODE_MSGBOX;
+            break;
+
+          case OPT_RADIOLIST:
+            if (mode != MODE_NONE) rc = -1;
+            mode = MODE_RADIOLIST;
+            break;
+
+          case OPT_CHECKLIST:
+            if (mode != MODE_NONE) rc = -1;
+            mode = MODE_CHECKLIST;
+            break;
+
+          case OPT_YESNO:
+            if (mode != MODE_NONE) rc = -1;
+            mode = MODE_YESNO;
+            break;
+
+          case OPT_INPUTBOX:
+            if (mode != MODE_NONE) rc = -1;
+            mode = MODE_INPUTBOX;
+            break;
+        }
     }
     
     if (arg < -1) {
-       /* this could buffer oveflow, bug we're not setuid so I don't care */
-       interp->result = malloc(200);
-       interp->freeProc = TCL_DYNAMIC;
-       sprintf(interp->result, "%s: %s\n", 
-               poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 
-               poptStrerror(arg));
-
-       return TCL_ERROR;
+        /* this could buffer oveflow, bug we're not setuid so I don't care */
+        interp->result = malloc(200);
+        interp->freeProc = TCL_DYNAMIC;
+        sprintf(interp->result, "%s: %s\n", 
+                poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 
+                poptStrerror(arg));
+
+        return TCL_ERROR;
     }
 
     if (mode == MODE_NONE) {
-       interp->result = "no dialog mode was specified";
-       return TCL_ERROR;
+        interp->result = "no dialog mode was specified";
+        return TCL_ERROR;
     } else if (rc) {
-       interp->result = "multiple modes were specified";
-       return TCL_ERROR;
+        interp->result = "multiple modes were specified";
+        return TCL_ERROR;
     }
 
     if (!(text = poptGetArg(optCon))) {
-       interp->result = "missing text parameter";
-       return TCL_ERROR;
+        interp->result = "missing text parameter";
+        return TCL_ERROR;
     }
 
     if (!(nextArg = poptGetArg(optCon))) {
-       interp->result = "height missing";
-       return TCL_ERROR;
+        interp->result = "height missing";
+        return TCL_ERROR;
     }
     height = strtoul(nextArg, &end, 10);
     if (*end) {
-       interp->result = "height is not a number";
-       return TCL_ERROR;
+        interp->result = "height is not a number";
+        return TCL_ERROR;
     }
 
     if (!(nextArg = poptGetArg(optCon))) {
-       interp->result = "width missing";
-       return TCL_ERROR;
+        interp->result = "width missing";
+        return TCL_ERROR;
     }
     width = strtoul(nextArg, &end, 10);
     if (*end) {
-       interp->result = "width is not a number";
-       return TCL_ERROR;
+        interp->result = "width is not a number";
+        return TCL_ERROR;
     }
 
     width -= 2;
@@ -180,91 +180,91 @@ static int wtCmd(ClientData clientData, Tcl_Interp * interp, int argc,
 
     switch (mode) {
       case MODE_MSGBOX:
-       rc = messageBox(text, height, width, MSGBOX_MSG, flags);
-       break;
+        rc = messageBox(text, height, width, MSGBOX_MSG, flags);
+        break;
 
       case MODE_YESNO:
-       rc = messageBox(text, height, width, MSGBOX_YESNO, flags);
-       if (rc == DLG_OKAY)
-           interp->result = "yes";
-       else 
-           interp->result = "no";
-       if (rc == DLG_ERROR) rc = 0;
-       break;
+        rc = messageBox(text, height, width, MSGBOX_YESNO, flags);
+        if (rc == DLG_OKAY)
+            interp->result = "yes";
+        else 
+            interp->result = "no";
+        if (rc == DLG_ERROR) rc = 0;
+        break;
 
       case MODE_INPUTBOX:
-       rc = inputBox(text, height, width, optCon, flags, &result);
-       if (!rc) {
-           interp->result = strdup(result);
-           interp->freeProc = TCL_DYNAMIC;
-       }
-       break;
+        rc = inputBox(text, height, width, optCon, flags, &result);
+        if (!rc) {
+            interp->result = strdup(result);
+            interp->freeProc = TCL_DYNAMIC;
+        }
+        break;
 
       case MODE_MENU:
-       rc = listBox(text, height, width, optCon, flags, &result);
-       if (!rc) {
-           interp->result = strdup(result);
-           interp->freeProc = TCL_DYNAMIC;
-       }
-       break;
+        rc = listBox(text, height, width, optCon, flags, &result);
+        if (!rc) {
+            interp->result = strdup(result);
+            interp->freeProc = TCL_DYNAMIC;
+        }
+        break;
 
       case MODE_RADIOLIST:
-       rc = checkList(text, height, width, optCon, 1, flags, &selections);
-       if (!rc) {
-           interp->result = strdup(selections[0]);
-           interp->freeProc = TCL_DYNAMIC;
-       }
-       break;
+        rc = checkList(text, height, width, optCon, 1, flags, &selections);
+        if (!rc) {
+            interp->result = strdup(selections[0]);
+            interp->freeProc = TCL_DYNAMIC;
+        }
+        break;
 
       case MODE_CHECKLIST:
-       rc = checkList(text, height, width, optCon, 0, flags, &selections);
+        rc = checkList(text, height, width, optCon, 0, flags, &selections);
 
-       if (!rc) {
-           for (next = selections; *next; next++) 
-               Tcl_AppendElement(interp, *next);
+        if (!rc) {
+            for (next = selections; *next; next++) 
+                Tcl_AppendElement(interp, *next);
 
-           free(selections);
-       }
-       break;
+            free(selections);
+        }
+        break;
 
       case MODE_NONE:
-       /* this can't happen */
+        /* this can't happen */
         break;
     }
 
     newtPopWindow();
 
     if (rc == DLG_ERROR) {
-       interp->result = "bad paramter for whiptcl dialog box";
-       return TCL_ERROR;
+        interp->result = "bad paramter for whiptcl dialog box";
+        return TCL_ERROR;
     } 
 
     Tcl_SetVar(interp, "whiptcl_canceled", (rc == DLG_CANCEL) ? "1" : "0",
-               0);
+                0);
 
     return TCL_OK;
 }
 
 static char * setBacktext(ClientData data, Tcl_Interp * interp, 
-                         char * name1, char * name2, int flags) {
+                          char * name1, char * name2, int flags) {
     static char blankLine[81] = "                                        "
                          "                                        ";
 
     newtDrawRootText(0, 0, blankLine);
     newtDrawRootText(0, 0, Tcl_GetVar(interp, "whiptcl_backtext",
-                                     TCL_GLOBAL_ONLY));
+                                      TCL_GLOBAL_ONLY));
 
     return NULL;
 }
 
 static char * setHelptext(ClientData data, Tcl_Interp * interp, 
-                         char * name1, char * name2, int flags) {
+                          char * name1, char * name2, int flags) {
     char * text = Tcl_GetVar(interp, "whiptcl_helpline", TCL_GLOBAL_ONLY);
 
     if (!text)
-       text = "";
+        text = "";
     else if (!strlen(text))
-       text = NULL;
+        text = NULL;
 
     newtPopHelpLine();
     newtPushHelpLine(text);
@@ -273,14 +273,14 @@ static char * setHelptext(ClientData data, Tcl_Interp * interp,
 }
 
 static char * setFullButtons(ClientData data, Tcl_Interp * interp, 
-                            char * name1, char * name2, int flags) {
+                             char * name1, char * name2, int flags) {
     char * val = Tcl_GetVar(interp, "whiptcl_fullbuttons", TCL_GLOBAL_ONLY);
     int rc;
     int state;
     
     if ((rc = Tcl_ExprBoolean(interp, val, &state))) {
-       Tcl_FreeResult(interp);
-       return "whiptcl_fullbuttons may only contain a boolean value";
+        Tcl_FreeResult(interp);
+        return "whiptcl_fullbuttons may only contain a boolean value";
     }
 
     useFullButtons(state);
index 9f9b8b349ab256c37f8cb9015476c6950f87f2fe..806f17b476f7d66cc5aa8437e901aac211933f48 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -8,7 +8,7 @@
 #include "newt.h"
 
 static void * newtvwindow(char * title, char * button1, char * button2, 
-                      char * button3, char * message, va_list args) {
+                       char * button3, char * message, va_list args) {
     newtComponent b1, b2 = NULL, b3 = NULL, t, f, answer;
     char * buf = NULL;
     int size = 0;
@@ -19,52 +19,52 @@ static void * newtvwindow(char * title, char * button1, char * button2,
     newtGrid grid, buttonGrid;
 
     do {
-       size += 1000;
-       if (buf) free(buf);
-       buf = malloc(size);
-       i = vsnprintf(buf, size, message, args);
+        size += 1000;
+        if (buf) free(buf);
+        buf = malloc(size);
+        i = vsnprintf(buf, size, message, args);
     } while (i >= size || i == -1);
 
     flowedText = newtReflowText(buf, 35, 5, 5, &width, &height);
     if (height > 6) {
-       free(flowedText);
-       flowedText = newtReflowText(buf, 60, 5, 5, &width, &height);
+        free(flowedText);
+        flowedText = newtReflowText(buf, 60, 5, 5, &width, &height);
     }
     free(buf);
 
     if (height > 12) {
-       height = 12;
-       scroll = NEWT_FLAG_SCROLL;
+        height = 12;
+        scroll = NEWT_FLAG_SCROLL;
     }
     t = newtTextbox(-1, -1, width, height, NEWT_TEXTBOX_WRAP | scroll);
     newtTextboxSetText(t, flowedText);
     free(flowedText);
 
     if (button3) {
-       buttonGrid = newtButtonBar(button1, &b1, button2, &b2, 
-                                  button3, &b3, NULL);
+        buttonGrid = newtButtonBar(button1, &b1, button2, &b2, 
+                                   button3, &b3, NULL);
     } else if (button2) {
-       buttonGrid = newtButtonBar(button1, &b1, button2, &b2, NULL);
+        buttonGrid = newtButtonBar(button1, &b1, button2, &b2, NULL);
     } else {
-       buttonGrid = newtButtonBar(button1, &b1, NULL);
+        buttonGrid = newtButtonBar(button1, &b1, NULL);
     }
 
     newtGridSetField(buttonGrid, 0, 0, NEWT_GRID_COMPONENT, b1, 
-                    0, 0, button2 ? 1 : 0, 0, 0, 0);
+                     0, 0, button2 ? 1 : 0, 0, 0, 0);
 
     grid = newtCreateGrid(1, 2);
     newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, t, 0, 0, 0, 0, 0, 0);
     newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, buttonGrid, 
-                    0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
+                     0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
     newtGridWrappedWindow(grid, title);
 
     f = newtForm(NULL, NULL, 0);
     newtFormAddComponents(f, t, b1, NULL);
 
     if (button2)
-       newtFormAddComponent(f, b2);
+        newtFormAddComponent(f, b2);
     if (button3)
-       newtFormAddComponent(f, b3);
+        newtFormAddComponent(f, b3);
 
     answer = newtRunForm(f);
     newtGridFree(grid, 1);
@@ -73,17 +73,17 @@ static void * newtvwindow(char * title, char * button1, char * button2,
     newtPopWindow();
 
     if (answer == f)
-       return NULL;
+        return NULL;
     else if (answer == b1)
-       return button1;
+        return button1;
     else if (answer == b2)
-       return button2;
+        return button2;
 
     return button3;
 }
 
 int newtWinChoice(char * title, char * button1, char * button2, 
-                  char * message, ...) {
+                   char * message, ...) {
     va_list args;
     void * rc;
 
@@ -92,9 +92,9 @@ int newtWinChoice(char * title, char * button1, char * button2,
     va_end(args);
 
     if (rc == button1)
-       return 1;
+        return 1;
     else if (rc == button2)
-       return 2;
+        return 2;
 
     return 0;
 }
@@ -108,12 +108,12 @@ void newtWinMessage(char * title, char * buttonText, char * text, ...) {
 }
 
 void newtWinMessagev(char * title, char * buttonText, char * text, 
-                    va_list argv) {
+                     va_list argv) {
     newtvwindow(title, buttonText, NULL, NULL, text, argv);
 }
 
 int newtWinTernary(char * title, char * button1, char * button2, 
-                  char * button3, char * message, ...) {
+                   char * button3, char * message, ...) {
     va_list args;
     void * rc;
 
@@ -122,18 +122,18 @@ int newtWinTernary(char * title, char * button1, char * button2,
     va_end(args);
 
     if (rc == button1)
-       return 1;
+        return 1;
     else if (rc == button2)
-       return 2;
+        return 2;
     else if (rc == button3)
-       return 3;
+        return 3;
 
     return 0;
 }
 
 int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown, 
-               int flexUp, int maxListHeight, char ** items, int * listItem,
-               char * button1, ...) {
+                int flexUp, int maxListHeight, char ** items, int * listItem,
+                char * button1, ...) {
     newtComponent textbox, listbox, result, form;
     va_list args;
     newtComponent *buttons = NULL;
@@ -144,16 +144,16 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown,
     char * buttonName;
 
     textbox = newtTextboxReflowed(-1, -1, text, suggestedWidth, flexDown,
-                                 flexUp, 0);
+                                  flexUp, 0);
 
     for (i = 0; items[i]; i++) ;
     if (i < maxListHeight) maxListHeight = i;
     needScroll = i > maxListHeight;
 
     listbox = newtListbox(-1, -1, maxListHeight, 
-                 (needScroll ? NEWT_FLAG_SCROLL : 0) | NEWT_FLAG_RETURNEXIT);
+                  (needScroll ? NEWT_FLAG_SCROLL : 0) | NEWT_FLAG_RETURNEXIT);
     for (i = 0; items[i]; i++) {
-       newtListboxAddEntry(listbox, items[i], (void *) i);
+        newtListboxAddEntry(listbox, items[i], (void *) i);
     }
 
     newtListboxSetCurrent(listbox, *listItem);
@@ -171,9 +171,9 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown,
 
     buttonBar = newtCreateGrid(numButtons, 1);
     for (i = 0; i < numButtons; i++) {
-       newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT, 
-                        buttons[i],
-                        i ? 1 : 0, 0, 0, 0, 0, 0);
+        newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT, 
+                         buttons[i],
+                         i ? 1 : 0, 0, 0, 0, 0, 0);
     }
 
     grid = newtGridSimpleWindow(textbox, listbox, buttonBar);
@@ -189,9 +189,9 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown,
 
     for (rc = 0; result != buttons[rc] && rc < numButtons; rc++);
     if (rc == numButtons) 
-       rc = 0; /* F12 or return-on-exit (which are the same for us) */
+        rc = 0; /* F12 or return-on-exit (which are the same for us) */
     else 
-       rc++;
+        rc++;
 
     newtFormDestroy(form);
     newtPopWindow();
@@ -200,8 +200,8 @@ int newtWinMenu(char * title, char * text, int suggestedWidth, int flexDown,
 }
 
 int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown, 
-                  int flexUp, int dataWidth, 
-                  struct newtWinEntry * items, char * button1, ...) {
+                   int flexUp, int dataWidth, 
+                   struct newtWinEntry * items, char * button1, ...) {
     newtComponent *buttons, result, form, textw;
     newtGrid grid, buttonBar, subgrid;
     int numItems;
@@ -211,7 +211,7 @@ int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown,
     va_list args;
 
     textw = newtTextboxReflowed(-1, -1, text, suggestedWidth, flexDown,
-                               flexUp, 0);
+                                flexUp, 0);
 
     for (numItems = 0; items[numItems].text; numItems++); 
 
@@ -229,31 +229,31 @@ int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown,
 
     buttonBar = newtCreateGrid(numButtons, 1);
     for (i = 0; i < numButtons; i++) {
-       newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT, 
-                        buttons[i],
-                        i ? 1 : 0, 0, 0, 0, 0, 0);
+        newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT, 
+                         buttons[i],
+                         i ? 1 : 0, 0, 0, 0, 0, 0);
     }
 
     subgrid = newtCreateGrid(2, numItems);
     for (i = 0; i < numItems; i++) {
-       newtGridSetField(subgrid, 0, i, NEWT_GRID_COMPONENT,
-                        newtLabel(-1, -1, items[i].text),
-                        0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
-       newtGridSetField(subgrid, 1, i, NEWT_GRID_COMPONENT,
-                        newtEntry(-1, -1, items[i].value ? 
-                                   *items[i].value : NULL, dataWidth,
-                                   items[i].value, items[i].flags),
-                        1, 0, 0, 0, 0, 0);
+        newtGridSetField(subgrid, 0, i, NEWT_GRID_COMPONENT,
+                         newtLabel(-1, -1, items[i].text),
+                         0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
+        newtGridSetField(subgrid, 1, i, NEWT_GRID_COMPONENT,
+                         newtEntry(-1, -1, items[i].value ? 
+                                    *items[i].value : NULL, dataWidth,
+                                    items[i].value, items[i].flags),
+                         1, 0, 0, 0, 0, 0);
     }
 
     grid = newtCreateGrid(1, 3);
     form = newtForm(NULL, 0, 0);
     newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, textw, 
-                    0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
+                     0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0);
     newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid, 
-                    0, 1, 0, 0, 0, 0);
+                     0, 1, 0, 0, 0, 0);
     newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttonBar, 
-                    0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
+                     0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX);
     newtGridAddComponentsToForm(grid, form, 1);
     newtGridWrappedWindow(grid, title);
     newtGridFree(grid, 1);
@@ -261,13 +261,13 @@ int newtWinEntries(char * title, char * text, int suggestedWidth, int flexDown,
     result = newtRunForm(form);
 
     for (rc = 0; rc < numItems; rc++)
-       *items[rc].value = strdup(*items[rc].value);
+        *items[rc].value = strdup(*items[rc].value);
 
     for (rc = 0; result != buttons[rc] && rc < numButtons; rc++);
     if (rc == numButtons) 
-       rc = 0; /* F12 */
+        rc = 0; /* F12 */
     else 
-       rc++;
+        rc++;
 
     newtFormDestroy(form);
     newtPopWindow();