Ejemplo n.º 1
0
/* Display a help file in a filebox */
int
systemDisplayHelp(char *file)
{
    char *fname = NULL;
    char buf[FILENAME_MAX];
    int ret = 0;
    WINDOW *w = savescr();
    
		printf("zzz");
    fname = systemHelpFile(file, buf);
    if (!fname) {
	snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file);
	use_helpfile(NULL);
	use_helpline(NULL);
	dialog_mesgbox("Sorry!", buf, -1, -1);
	ret = 1;
    }
    else {
	use_helpfile(NULL);
	use_helpline(NULL);
	dialog_textbox(file, fname, LINES, COLS);
    }
    restorescr(w);
    return ret;
}
Ejemplo n.º 2
0
int
main(int argc, char **argv)
{
	int retval;
	unsigned char *tresult;
	char comstr[BUFSIZ];

	init_dialog();
	do {
		use_helpline("Press OK for listing directory");
		retval = dialog_tree(names, 
			sizeof(names)/sizeof(unsigned char *) - 1,
			 '/',
			"tree dialog box example",
			"Typical find -x / -type d output", 
			-1, -1, 15,
                        	    &tresult);
		
		if (retval)
			break;
		
		use_helpline(NULL);
		(void)snprintf(comstr, sizeof(comstr), 
			"ls -CF %s", tresult);

		retval = dialog_prgbox(
			comstr, 
			comstr, 20, 60, TRUE, TRUE);

		dialog_clear();
  		
		retval = dialog_tree(names1, 
			sizeof(names1)/sizeof(unsigned char *),
			 ':',
			"tree dialog box example",
			"Other tree", 
			-1, -1, 5,
                        	    &tresult);
		if (!retval)
		{
	  		dialog_clear();
  		}
	} while (!retval);

	dialog_update();
	
	dialog_clear();
	
	end_dialog();
  	
	exit(retval);
}
Ejemplo n.º 3
0
/* Put up a message in an input box and return the value */
char *
msgGetInput(char *buf, const char *fmt, ...)
{
    va_list args;
    char *errstr;
    static char input_buffer[256];
    int rval;
    WINDOW *w = savescr();

    errstr = (char *)alloca(FILENAME_MAX);
    va_start(args, fmt);
    vsnprintf(errstr, FILENAME_MAX, fmt, args);
    va_end(args);
    use_helpline(NULL);
    use_helpfile(NULL);
    if (buf)
	SAFE_STRCPY(input_buffer, buf);
    else
	input_buffer[0] = '\0';
    if (OnVTY) {
	ioctl(0, VT_ACTIVATE, 1);	/* Switch back */
	msgInfo(NULL);
    }
    rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
    restorescr(w);
    if (!rval)
	return input_buffer;
    else
	return NULL;
}
Ejemplo n.º 4
0
int
main(int argc, char **argv)
{
	int retval;
	unsigned char *tresult;

	init_dialog();
	use_helpfile("ftree2.test");
	use_helpline("Press Arrows, Tab, Enter or F1");
	retval = dialog_ftree("ftree2.test", '\t',
		"ftree dialog box example",
		"xterm widget tree from preprocess editres(1) dump", 
		-1, -1, 15,
                            &tresult);

	dialog_update();
	
	dialog_clear();
	
	end_dialog();

	if (!retval)
	{
 		puts(tresult);
  		free(tresult);
  	}
  	
	exit(retval);
}
Ejemplo n.º 5
0
int
dmenuSystemCommandBox(dialogMenuItem *tmp)
{
    WINDOW *w = savescr();
    
    use_helpfile(NULL);
    use_helpline("Select OK to dismiss this dialog");
    dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1);
    restorescr(w);
    return DITEM_SUCCESS;
}
Ejemplo n.º 6
0
/* Traverse over an internal menu */
Boolean
dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons)
{
    int n, rval = 0;
    dialogMenuItem *items;

    items = menu->items;
    if (buttons)
	items += 2;
    /* Count up all the items */
    for (n = 0; items[n].title; n++);

    while (1) {
	char buf[FILENAME_MAX];
	WINDOW *w = savescr();

	/* Any helpful hints, put 'em up! */
	use_helpline(menu->helpline);
	use_helpfile(systemHelpFile(menu->helpfile, buf));
	dialog_clear_norefresh();
	/* Pop up that dialog! */
	if (menu->type & DMENU_NORMAL_TYPE)
	    rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt,
		-1, -1, menu_height(menu, n), -n, items,
		(char *)(uintptr_t)buttons, choice, scroll);

	else if (menu->type & DMENU_RADIO_TYPE)
	    rval = dialog_radiolist((u_char *)menu->title,
		(u_char *)menu->prompt, -1, -1, menu_height(menu, n), -n,
		items, (char *)(uintptr_t)buttons);

	else if (menu->type & DMENU_CHECKLIST_TYPE)
	    rval = dialog_checklist((u_char *)menu->title,
		(u_char *)menu->prompt, -1, -1, menu_height(menu, n), -n,
		items, (char *)(uintptr_t)buttons);
	else
	    msgFatal("Menu: `%s' is of an unknown type\n", menu->title);
	if (exited) {
	    exited = FALSE;
	    restorescr(w);
	    return TRUE;
	}
	else if (rval) {
	    restorescr(w);
	    return FALSE;
	}
	else if (menu->type & DMENU_SELECTION_RETURNS) {
	    restorescr(w);
	    return TRUE;
	}
    }
}
Ejemplo n.º 7
0
static void
handle_intr(int sig)
{
    WINDOW *save = savescr();

    use_helpline(NULL);
    use_helpfile(NULL);
    if (OnVTY) {
        ioctl(0, VT_ACTIVATE, 1);       /* Switch back */
        msgInfo(NULL);
    }
    (void)dialog_menu("Installation interrupt",
		     "Do you want to abort the installation?",
		     -1, -1, 2, -2, intrmenu, NULL, NULL, NULL);
    restorescr(save);
}
Ejemplo n.º 8
0
/* Put up a message in a popup information box */
void
msgNotify(const char *fmt, ...)
{
    va_list args;
    char *errstr;

    errstr = (char *)alloca(FILENAME_MAX);
    va_start(args, fmt);
    vsnprintf(errstr, FILENAME_MAX, fmt, args);
    va_end(args);
    use_helpline(NULL);
    use_helpfile(NULL);
    if (isDebug())
	msgDebug("Notify: %s\n", errstr);
    dialog_msgbox(NULL, errstr, -1, -1, 0);
}
Ejemplo n.º 9
0
/* Tell the user there's some output to go look at */
void
msgWeHaveOutput(const char *fmt, ...)
{
    va_list args;
    char *errstr;
    WINDOW *w = savescr();
    
    errstr = (char *)alloca(FILENAME_MAX);
    va_start(args, fmt);
    vsnprintf(errstr, FILENAME_MAX, fmt, args);
    va_end(args);
    use_helpline(NULL);
    use_helpfile(NULL);
    msgDebug("Notify: %s\n", errstr);
    dialog_clear_norefresh();
    sleep(2);
    dialog_msgbox(NULL, errstr, -1, -1, 0);
    restorescr(w);
}
Ejemplo n.º 10
0
/* Put up a message in a popup confirmation box */
void
msgConfirm(const char *fmt, ...)
{
    va_list args;
    char *errstr;
    WINDOW *w = savescr();

    errstr = (char *)alloca(FILENAME_MAX);
    va_start(args, fmt);
    vsnprintf(errstr, FILENAME_MAX, fmt, args);
    va_end(args);
    use_helpline(NULL);
    use_helpfile(NULL);
    if (OnVTY) {
	ioctl(0, VT_ACTIVATE, 1);
	msgInfo(NULL);
    }
    dialog_notify(errstr);
    restorescr(w);
}
Ejemplo n.º 11
0
/* Put up a message in a popup no/yes box and return 0 for YES, 1 for NO */
int
msgNoYes(const char *fmt, ...)
{
    va_list args;
    char *errstr;
    int ret;
    WINDOW *w = savescr();
    
    errstr = (char *)alloca(FILENAME_MAX);
    va_start(args, fmt);
    vsnprintf(errstr, FILENAME_MAX, fmt, args);
    va_end(args);
    use_helpline(NULL);
    use_helpfile(NULL);
    if (OnVTY) {
	ioctl(0, VT_ACTIVATE, 1);	/* Switch back */
	msgInfo(NULL);
    }
    if (variable_get(VAR_NONINTERACTIVE))
	return 1;	/* If non-interactive, return NO all the time */
    ret = dialog_noyes("User Confirmation Requested", errstr, -1, -1);
    restorescr(w);
    return ret;
}
Ejemplo n.º 12
0
void
main(int argc, char **argv)
{
    void *chain;
    int st;
    char check1 = 0, check2 = 1;
    char name[20];
    char password[20];
    char message[80];
    LIA foo;

    static char msg[] = "This is some text\n"
			"That can be found\n"
			"In a text object\n"
			"At the bottom of the sea\n";

    static ListItem menu[] = {
	/* menuitems need hotkeys */
	{ "A", "Choice A" },
	{ "B", "Choice B" },
	{ "C", "Choice C" },
	{ "D", "Choice D" },
	{ "E", "Choice E" },
	{ "F", "Choice F" },
	{ "G", "Choice G" },
	{ "H", "Choice H" },
    };
    #define NR_MENU	(sizeof menu / sizeof menu[0])

    static ListItem list[] = {
	{ "A", "Choice A", 0, 1 },
	{ "B", "Choice B", 0, 0 },
	{ "C", "Choice C", 0, 0 },
    } ;
    #define NR_LIST	(sizeof list / sizeof list[0])

    strcpy(name, "Fernando Poo");
    name[0] = 0xff;
    strcpy(password, "Sekret");
    strcpy(message, "A MESSAGE");

    setHelpRoot(".");

    chain = ObjChain(newOKButton(1,"OK", 0, 0),
		     newCheck(0,0,"A CHECK ITEM GOES PLONK",0,&check1,0,"demo.html"));
    chain = ObjChain(chain, newCancelButton(2,"CANCEL", 0, "demo.html"));
    chain = ObjChain(chain, newCheck(0,2,0,"Check | your hat?",&check2,0,"demo.html"));
    chain = ObjChain(chain, newString(4,3,10, sizeof name, name,
				      "Name", "Your name", 0, "demo.html"));
    chain = ObjChain(chain, newPWString(0,7,10, sizeof password, password,
				      0, "Your password", 0, "demo.html"));
    chain = ObjChain(chain, newString(0,10,10, sizeof message, message,
				      "String Title", 0, 0, "demo.html"));

    chain = ObjChain(chain, newMenu(30,0,-1,-1,
				    NR_MENU,menu,"A MENU","",
				    MENU_SELECTION, menucallback,"demo.html"));
    chain = ObjChain(chain, list_ying = newList(40,0,-1,-1,
				    NR_LIST,list,"A LIST","",
				    CHECK_SELECTED,0,"demo.html"));
    chain = ObjChain(chain, list_yang = newRadioList(54,0,-1,-1,
					 NR_LIST,list,"SAME LIST","",
					 HIGHLIGHT_SELECTED,0,"demo.html"));

    chain = ObjChain(chain, newText(40,7,20,3,strlen(msg),"Text",0,msg,0,"demo.html"));

    init_dialog();
    if (argc > 1) {
	switch (atoi(argv[1])) {
	default:
		use_helpline("[TAB] to move, [ESC] to exit");
		st = MENU(chain, 0, 0, "title",
		   "SCIENTIFIC PROGRESS\nGOES BONK", FANCY_MENU|ALIGN_RIGHT);
		if (st == MENU_ERROR)
		    perror("MENU");
		break;

	case 1:
		use_helpline("This is an error message");
		Error("Nothing in particular");
		break;

	case 2:
		use_helpline("Counting down");
		errno = 0;
		MENU(0,-1,-1 ,0, " ONE ", 0);
		usleep(400000);
		use_helpline("tick");
		MENU(0,-1,-1, 0, " TWO ", 0);
		usleep(400000);
		use_helpline("tick");
		MENU(0,-1,-1, 0, "THREE", 0);
		usleep(400000);
		break;
	case 4:
		foo = newLIA(0,0);
		addToLIA(foo, "1", "first", 0);
		addToLIA(foo, "2", "second", 0);
		addToLIA(foo, "3", "third", 0);
		addToLIA(foo, "4", "forth", 0);
		addToLIA(foo, "5", "fifth", 0);

		chain = newListWidget(0,0,18,3,foo,"title", 0,0,0,0);
		chain = ObjChain(chain, newCancelButton(0, "Done", 0, 0));

		st = MENU(chain, -1, -1, "list widget", 0, 0);
		if (st == MENU_ERROR)
		    perror("MENU");
		break;
	}
    }
    else {
	use_helpline("[TAB] or the mouse to navigate, [ESC] to exit");
	st = MENU(chain, -1, -1, "title",
		    "SCIENTIFIC PROGRESS\nGOES BONK", ALIGN_RIGHT);
	if (st == MENU_ERROR)
	    perror("MENU");
    }
    end_dialog();
    adump();
}
Ejemplo n.º 13
0
int
index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll)
{
    struct ListPtrs lists;
    size_t maxname;
    int n, rval;
    int curr, max;
    PkgNodePtr kp;
    dialogMenuItem *nitems;
    Boolean hasPackages;
    WINDOW *w;
    
    lists.root = root;
    lists.top = top;
    lists.plist = plist;

    hasPackages = FALSE;
    nitems = NULL;
    n = maxname = 0;

    /* Figure out if this menu is full of "leaves" or "branches" */
    for (kp = top->kids; kp && kp->name; kp = kp->next) {
	size_t len;

	++n;
	if (kp->type == PACKAGE && plist) {
	    hasPackages = TRUE;
	    if ((len = strlen(kp->name)) > maxname)
		maxname = len;
	}
    }
    if (!n && plist) {
	msgConfirm("The %s menu is empty.", top->name);
	return DITEM_LEAVE_MENU;
    }

    w = savescr();
    while (1) {
	n = 0;
	curr = max = 0;
	use_helpline(NULL);
	use_helpfile(NULL);
	kp = top->kids;
	if (!hasPackages && plist) {
	    nitems = item_add(nitems, "OK", NULL, NULL, NULL, NULL, NULL, NULL, &curr, &max);
	    nitems = item_add(nitems, "Install", NULL, NULL, NULL, NULL, NULL, NULL, &curr, &max);
	}
	while (kp && kp->name) {
	    char buf[256];
	    IndexEntryPtr ie = kp->data;

	    /* Brutally adjust description to fit in menu */
	    if (kp->type == PACKAGE)
		snprintf(buf, sizeof buf, "[%s]", ie->path ? ie->path : "External vendor");
	    else
		SAFE_STRCPY(buf, kp->desc);
	    if (strlen(buf) > (_MAX_DESC - maxname))
		buf[_MAX_DESC - maxname] = '\0';
	    nitems = item_add(nitems, kp->name, buf, pkg_checked, 
			      pkg_fire, pkg_selected, kp, &lists, 
			      &curr, &max);
	    ++n;
	    kp = kp->next;
	}
	/* NULL delimiter so item_free() knows when to stop later */
	nitems = item_add(nitems, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
			  &curr, &max);

recycle:
	dialog_clear_norefresh();
	if (hasPackages)
	    rval = dialog_checklist(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems, NULL);
	else
	    rval = dialog_menu(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems + (plist ? 2 : 0), (char *)plist, pos, scroll);
	if (rval == -1 && plist) {
	    static char *cp;
	    PkgNodePtr menu;

	    /* Search */
	    if ((cp = msgGetInput(cp, "Search by package name.  Please enter search string:")) != NULL) {
		PkgNodePtr p = index_search(top, cp, &menu);

		if (p) {
		    int pos, scroll;

		    /* These need to be set to point at the found item, actually.  Hmmm! */
		    pos = scroll = 0;
		    index_menu(root, menu, plist, &pos, &scroll);
		}
		else
		    msgConfirm("Search string: %s yielded no hits.", cp);
	    }
	    goto recycle;
	}
	items_free(nitems, &curr, &max);
	restorescr(w);
	return rval ? DITEM_FAILURE : DITEM_SUCCESS;
    }
}