shared: $(LIBNEWTSH)
$(LIBNEWTSH): shareddir $(SHAREDOBJS)
- gcc -shared -o $(LIBNEWTSH) -Wl,-soname,$(LIBNEWTSONAME) $(SHAREDOBJS)
+ gcc -shared -o $(LIBNEWTSH) -Wl,-soname,$(LIBNEWTSONAME) $(SHAREDOBJS) $(LIBS)
$(SHAREDDIR)/%.o : %.c
$(CC) $(SHCFLAGS) -c $(CFLAGS) -o $@ $<
install: $(LIBNEWT)
+ [ -d $(bindir) ] || install -m 755 -d $(bindir)
[ -d $(libdir) ] || install -m 755 -d $(libdir)
[ -d $(includedir) ] || install -m 755 -d $(includedir)
install -m 644 newt.h $(includedir)
en->bufUsed = 0;
en->bufAlloced = width + 1;
- if (!(en->flags & NEWT_ENTRY_DISABLED))
+ if (!(en->flags & NEWT_FLAG_DISABLED))
co->takesFocus = 1;
else
co->takesFocus = 0;
if (co->top == -1) return;
- if (en->flags & NEWT_ENTRY_DISABLED)
+ if (en->flags & NEWT_FLAG_DISABLED)
SLsmg_set_color(NEWT_COLORSET_DISENTRY);
else
SLsmg_set_color(NEWT_COLORSET_ENTRY);
- if (en->flags & NEWT_ENTRY_HIDDEN) {
+ if (en->flags & NEWT_FLAG_HIDDEN) {
newtGotorc(co->top, co->left);
for (i = 0; i < co->width; i++)
SLsmg_write_char('_');
SLsmg_write_nstring(chptr, co->width);
}
- if (en->flags & NEWT_ENTRY_HIDDEN)
+ if (en->flags & NEWT_FLAG_HIDDEN)
newtGotorc(co->top, co->left);
else
newtGotorc(co->top, co->left + (en->cursorPosition - en->firstChar));
en->flags = newtSetFlags(en->flags, flags, sense);
- if (!(en->flags & NEWT_ENTRY_DISABLED))
+ if (!(en->flags & NEWT_FLAG_DISABLED))
co->takesFocus = 1;
else
co->takesFocus = 0;
switch (ev.event) {
case EV_FOCUS:
/*SLtt_set_cursor_visibility(0);*/
- if (en->flags & NEWT_ENTRY_HIDDEN)
+ if (en->flags & NEWT_FLAG_HIDDEN)
newtGotorc(co->top, co->left);
else
newtGotorc(co->top, co->left +
er.result = ER_SWALLOWED;
switch (key) {
case '\r': /* Return */
- if (en->flags & NEWT_ENTRY_RETURNEXIT) {
+ if (en->flags & NEWT_FLAG_RETURNEXIT) {
er.result = ER_EXITFORM;
} else {
er.result = ER_NEXTCOMP;
default:
if ((key >= 0x20 && key <= 0x7e) || (key >= 0xa0 && key <= 0xff)) {
- if (!(en->flags & NEWT_ENTRY_SCROLL) && en->bufUsed == co->width) {
+ if (!(en->flags & NEWT_FLAG_SCROLL) && en->bufUsed == co->width) {
SLtt_beep();
break;
}
form->background = COLORSET_WINDOW;
form->hotKeys = malloc(sizeof(int));
form->numHotKeys = 0;
- if (!(form->flags & NEWT_FORM_NOF12)) {
+ if (!(form->flags & NEWT_FLAG_NOF12)) {
newtFormAddHotKey(co, NEWT_KEY_F12);
}
Copyright Elliot Lee 1996 */
#include <slang/slang.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct items *boxItems;
int grow;
int flags; /* flags for this listbox, right now just
- NEWT_LISTBOX_RETURNEXIT */
+ NEWT_FLAG_RETURNEXIT */
};
static void listboxDraw(newtComponent co);
li->currItem = 0;
li->isActive = 0;
li->startShowItem = 0;
- li->flags = flags & (NEWT_LISTBOX_RETURNEXIT|NEWT_FLAG_DOBORDER);
+ li->flags = flags & (NEWT_FLAG_RETURNEXIT|NEWT_FLAG_DOBORDER);
if (height) {
li->grow = 0;
if(num > li->numItems)
num = li->numItems;
- if (!li->boxItems)
- return -1;
+ if (li->boxItems == NULL || li->numItems <= 0)
+ return 0;
if (num <= 1) {
item = li->boxItems;
/* Fix things up for the width-finding loop near the bottom */
item2 = li->boxItems;
- widest = strlen(item2->key);
+ widest = strlen(item2?item2->key:"");
} else {
for(i = 0, item = li->boxItems; item != NULL && i < num - 1;
i++, item = item->next) {
li->numItems--;
if(li->currItem >= num)
li->currItem--;
- for (item = item2->next; item != NULL; item = item->next)
+ for (item = item2?item2->next:item2; item != NULL; item = item->next)
if((t = strlen(item->key)) > widest) widest = t;
/* Adjust the listbox width */
switch(ev.u.key) {
case NEWT_KEY_ENTER:
- if(li-> flags & NEWT_LISTBOX_RETURNEXIT)
+ if(li-> flags & NEWT_FLAG_RETURNEXIT)
er.result = ER_EXITFORM;
break;
#define NEWT_FLAG_DISABLED (1 << 3)
#define NEWT_FLAG_NOSCROLL (1 << 4) /* for listboxes */
#define NEWT_FLAG_DOBORDER (1 << 5)
+#define NEWT_FLAG_WRAP (1 << 6)
+#define NEWT_FLAG_NOF12 (1 << 7)
/* Backwards compatibility */
#define NEWT_LISTBOX_RETURNEXIT NEWT_FLAG_RETURNEXIT
#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
+
typedef struct newtComponent_struct * newtComponent;
extern struct newtColors newtDefaultColorPalette;
int newtListboxDeleteEntry(newtComponent co, int num);
void newtListboxGetEntry(newtComponent co, int num, char **text, void **data);
-#define NEWT_TEXTBOX_WRAP (1 << 0)
-#define NEWT_TEXTBOX_SCROLL (1 << 1)
-
newtComponent newtTextbox(int left, int top, int with, int height, int flags);
void newtTextboxSetText(newtComponent co, const char * text);
void newtTextboxSetHeight(newtComponent co, int height);
int newtTextboxGetNumLines(newtComponent co);
-#define NEWT_FORM_NOF12 (1 << 0)
-
struct newtExitStruct {
enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT } reason;
union {
%changelog
+* Tue May 28 1997 Elliot Lee <sopwith@redhat.com> 0.8-2
+- Touchups on Makefile
+- Cleaned up NEWT_FLAGS_*
+
* Tue Mar 18 1997 Erik Troan <ewt@redhat.com>
- Cleaned up listbox
struct callbackInfo * cbi = data;
if (*cbi->state == ' ') {
- newtEntrySetFlags(cbi->en, NEWT_ENTRY_DISABLED, NEWT_FLAGS_RESET);
+ newtEntrySetFlags(cbi->en, NEWT_FLAG_DISABLED, NEWT_FLAGS_RESET);
} else {
- newtEntrySetFlags(cbi->en, NEWT_ENTRY_DISABLED, NEWT_FLAGS_SET);
+ newtEntrySetFlags(cbi->en, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET);
}
newtRefresh();
l2 = newtLabel(3, 7, "Scrolls:");
l3 = newtLabel(3, 8, "Hidden:");
e1 = newtEntry(12, 6, "", 20, &scaleVal, 0);
- e2 = newtEntry(12, 7, "Default", 20, &enr2, NEWT_ENTRY_SCROLL);
- e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_ENTRY_HIDDEN);
+ e2 = newtEntry(12, 7, "Default", 20, &enr2, NEWT_FLAG_SCROLL);
+ e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_FLAG_HIDDEN);
cbis[0].state = &results[0];
cbis[0].en = e1;
newtListboxAddEntry(lb, "Ninth", NULL);
newtListboxAddEntry(lb, "Tenth", NULL);
- t = newtTextbox(45, 10, 17, 5, NEWT_TEXTBOX_WRAP);
+ t = newtTextbox(45, 10, 17, 5, NEWT_FLAG_WRAP);
newtTextboxSetText(t, "This is some text does it look okay?\nThis should be alone.\nThis shouldn't be printed");
newtFormAddComponents(f, lb, t, NULL);
co->left = left;
co->takesFocus = 0;
- tb->doWrap = flags & NEWT_TEXTBOX_WRAP;
+ tb->doWrap = flags & NEWT_FLAG_WRAP;
tb->numLines = 0;
tb->linesAlloced = 0;
tb->lines = NULL;
tb->topLine = 0;
- if (flags & NEWT_TEXTBOX_SCROLL) {
+ if (flags & NEWT_FLAG_SCROLL) {
co->width = width - 2;
tb->sb = newtVerticalScrollbar(co->left + co->width + 1, co->top,
co->height, COLORSET_TEXTBOX, COLORSET_TEXTBOX);
newtComponent textbox(int maxHeight, int width, char * text, int flags,
int * height) {
newtComponent tb;
- int sFlag = (flags & FLAG_SCROLL_TEXT) ? NEWT_TEXTBOX_SCROLL : 0;
+ int sFlag = (flags & FLAG_SCROLL_TEXT) ? NEWT_FLAG_SCROLL : 0;
int i;
char * buf, * src, * dst;
}
*dst++ = '\0';
- tb = newtTextbox(1, 0, width, maxHeight, NEWT_TEXTBOX_WRAP | sFlag);
+ tb = newtTextbox(1, 0, width, maxHeight, NEWT_FLAG_WRAP | sFlag);
newtTextboxSetText(tb, buf);
i = newtTextboxGetNumLines(tb);
int messageBox(char * text, int height, int width, int type, int flags) {
newtComponent form, yes, tb, answer;
newtComponent no = NULL;
- int tFlag = (flags & FLAG_SCROLL_TEXT) ? NEWT_TEXTBOX_SCROLL : 0;
+ int tFlag = (flags & FLAG_SCROLL_TEXT) ? NEWT_FLAG_SCROLL : 0;
form = newtForm(NULL, NULL, 0);
tb = newtTextbox(1, 1, width - 2, height - 3 - buttonHeight,
- NEWT_TEXTBOX_WRAP | tFlag);
+ NEWT_FLAG_WRAP | tFlag);
newtTextboxSetText(tb, text);
newtFormAddComponent(form, tb);