PUBLIC int popup_choice ARGS6(
PUBLIC int popup_choice ARGS7(
PUBLIC int popup_choice ARGS6(	int,		cur_choice,	int,		line,	int,		column,	char **,	choices,	int,		i_length,	int,		disabled){    int ly = line;    int lx = (column >= 0 ? column : (COL_OPTION_VALUES - 1));    int c = 0, cmd = 0, i = 0, j = 0;    int orig_choice = cur_choice;#ifndef USE_SLANG    WINDOW * form_window;#endif /* !USE_SLANG */    int num_choices = 0, top, bottom, length = -1;    unsigned width = 0;    char ** Cptr = choices;    int window_offset = 0;    int DisplayLines = (LYlines - 2);    char Cnum[64];    int Lnum;    int npages;    static char prev_target[512];		/* Search string buffer */    static char prev_target_buffer[512];	/* Next search buffer */    static BOOL first = TRUE;    char *cp;    int ch = 0, recall;    int QueryTotal;    int QueryNum;    BOOLEAN FirstRecall = TRUE;    BOOLEAN ReDraw = FALSE;    int number;    char buffer[512];    /*     * Initialize the search string buffer. - FM     */    if (first) {	*prev_target_buffer = '\0';	first = FALSE;    }    *prev_target = '\0';    QueryTotal = (search_queries ? HTList_count(search_queries) : 0);    recall = ((QueryTotal >= 1) ? RECALL : NORECALL);    QueryNum = QueryTotal;    /*     *	Count the number of choices to be displayed, where     *	num_choices ranges from 0 to n, and set width to the     *	longest choice string length.  Also set Lnum to the     *	length for the highest choice number, then decrement     *	num_choices so as to be zero-based.  The window width     *	will be based on the sum of width and Lnum. - FM     */    for (num_choices = 0; Cptr[num_choices] != NULL; num_choices++) {	if (strlen(Cptr[num_choices]) > width) {	    width = strlen(Cptr[num_choices]);	}    }    sprintf(Cnum, "%d: ", num_choices);    Lnum = strlen(Cnum);    num_choices--;    /*     *	Let's assume for the sake of sanity that ly is the number     *	 corresponding to the line the option is on.     *	Let's also assume that cur_choice is the number of the     *	 choice that should be initially selected, with 0 being     *	 the first choice.     *	So what we have, is the top equal to the current screen line     *	 subtracting the cur_choice + 1 (the one must be for the top     *	 line we will draw in a box).  If the top goes under 0, then     *	 consider it 0.     */    top = ly - (cur_choice + 1);    if (top < 0)	top = 0;    /*     *	Check and see if we need to put the i_length parameter up to     *	the number of real choices.     */    if (i_length < 1) {	i_length = num_choices;    } else {	/*	 *  Otherwise, it is really one number too high.	 */	i_length--;    }    /*     *	The bottom is the value of the top plus the number of choices     *	to view plus 3 (one for the top line, one for the bottom line,     *	and one to offset the 0 counted in the num_choices).     */    bottom = top + i_length + 3;    /*     *	Hmm...	If the bottom goes beyond the number of lines available,     */    if (bottom > DisplayLines) {	/*	 *  Position the window at the top if we have more	 *  choices than will fit in the window.	 */	if ((i_length + 3) > DisplayLines) {	    top = 0;	    bottom = (top + (i_length + 3));	    if (bottom > DisplayLines)		bottom = (DisplayLines + 1);	} else {	    /*	     *	Try to position the window so that the selected choice will	     *	  appear where the choice box currently is positioned.	     *	It could end up too high, at this point, but we'll move it	     *	  down latter, if that has happened.	     */	    top = (DisplayLines + 1) - (i_length + 3);	    bottom = (DisplayLines + 1);	}    }    /*     *	This is really fun, when the length is 4, it means 0 to 4, or 5.     */    length = (bottom - top) - 2;    /*     *	Move the window down if it's too high.     */    if (bottom < ly + 2) {	bottom = ly + 2;	if (bottom > DisplayLines + 1)	    bottom = DisplayLines + 1;	top = bottom - length - 2;    }    /*     *	Set up the overall window, including the boxing characters ('*'),     *	if it all fits.  Otherwise, set up the widest window possible. - FM     */#ifdef USE_SLANG    SLsmg_fill_region(top, lx - 1, bottom - top, (Lnum + width + 4), ' ');#else    if (!(form_window = newwin(bottom - top, (Lnum + width + 4),			       top, (lx - 1))) &&	!(form_window = newwin(bottom - top, 0, top, 0))) {	HTAlert(POPUP_FAILED);	return(orig_choice);    }    scrollok(form_window, TRUE);#ifdef PDCURSES    keypad(form_window, TRUE);#endif /* PDCURSES */#ifdef NCURSES    LYsubwindow(form_window);#endif#if defined(HAVE_GETBKGD) /* not defined in ncurses 1.8.7 */    wbkgd(form_window, getbkgd(stdscr));    wbkgdset(form_window, getbkgd(stdscr));#endif#endif /* USE_SLANG */    /*     *	Clear the command line and write     *	the popup statusline. - FM     */    move((LYlines - 2), 0);    clrtoeol();    if (disabled) {	_statusline(CHOICE_LIST_UNM_MSG);    } else {	_statusline(CHOICE_LIST_MESSAGE);    }    /*     *	Set up the window_offset for choices.     *	 cur_choice ranges from 0...n     *	 length ranges from 0...m     */    if (cur_choice >= length) {	window_offset = cur_choice - length + 1;    }    /*     *	Compute the number of popup window pages. - FM     */    npages = ((num_choices + 1) > length) ?		(((num_choices + 1) + (length - 1))/(length))					  : 1;/* *  OH!  I LOVE GOTOs! hack hack hack */redraw:    Cptr = choices;    /*     *	Display the boxed choices.     */    for (i = 0; i <= num_choices; i++) {	if (i >= window_offset && i - window_offset < length) {	    sprintf(Cnum, "%s%d: ",			   ((num_choices > 8 && i < 9) ?						   " " : ""),			   (i + 1));#ifdef USE_SLANG	    SLsmg_gotorc(top + ((i + 1) - window_offset), (lx - 1 + 2));	    addstr(Cnum);	    SLsmg_write_nstring(Cptr[i], width);#else	    wmove(form_window, ((i + 1) - window_offset), 2);	    wclrtoeol(form_window);	    waddstr(form_window, Cnum);	    waddstr(form_window, Cptr[i]);#endif /* USE_SLANG */	}    }#ifdef USE_SLANG    SLsmg_draw_box(top, (lx - 1), (bottom - top), (Lnum + width + 4));#else#ifdef VMS    VMSbox(form_window, (bottom - top), (Lnum + width + 4));#else    LYbox(form_window, FALSE);#endif /* VMS */    wrefresh(form_window);#endif /* USE_SLANG */    Cptr = NULL;    /*     *	Loop on user input.     */    while (cmd != LYK_ACTIVATE) {	/*	 *  Unreverse cur choice.	 */	if (Cptr != NULL) {	    sprintf(Cnum, "%s%d: ",			  ((num_choices > 8 && i < 9) ?						  " " : ""),			  (i + 1));#ifdef USE_SLANG	    SLsmg_gotorc((top + ((i + 1) - window_offset)), (lx - 1 + 2));	    addstr(Cnum);	    SLsmg_write_nstring(Cptr[i], width);#else	    wmove(form_window, ((i + 1) - window_offset), 2);	    waddstr(form_window, Cnum);	    waddstr(form_window, Cptr[i]);#endif /* USE_SLANG */	}	Cptr = choices;	i = cur_choice;	sprintf(Cnum, "%s%d: ",		      ((num_choices > 8 && i < 9) ?					      " " : ""),		      (i + 1));#ifdef USE_SLANG	SLsmg_gotorc((top + ((i + 1) - window_offset)), (lx - 1 + 2));	addstr(Cnum);	SLsmg_set_color(2);	SLsmg_write_nstring(Cptr[i], width);	SLsmg_set_color(0);	/*	 *  If LYShowCursor is ON, move the cursor to the left	 *  of the current choice, so that blind users, who are	 *  most likely to have LYShowCursor ON, will have it's	 *  string spoken or passed to the braille interface as	 *  each choice is made current.  Otherwise, move it to	 *  the bottom, right column of the screen, to "hide"	 *  the cursor as for the main document, and let sighted	 *  users rely on the current choice's highlighting or	 *  color without the distraction of a blinking cursor	 *  in the window. - FM	 */	if (LYShowCursor)	    SLsmg_gotorc((top + ((i + 1) - window_offset)), (lx - 1 + 1));	else	    SLsmg_gotorc((LYlines - 1), (LYcols - 1));	SLsmg_refresh();#else	wmove(form_window, ((i + 1) - window_offset), 2);	waddstr(form_window, Cnum);	wstart_reverse(form_window);	waddstr(form_window, Cptr[i]);	wstop_reverse(form_window);	/*	 *  If LYShowCursor is ON, move the cursor to the left	 *  of the current choice, so that blind users, who are	 *  most likely to have LYShowCursor ON, will have it's	 *  string spoken or passed to the braille interface as	 *  each choice is made current.  Otherwise, leave it to	 *  the right of the current choice, since we can't move	 *  it out of the window, and let sighted users rely on	 *  the highlighting of the current choice without the	 *  distraction of a blinking cursor preceding it. - FM	 */	if (LYShowCursor)	    wmove(form_window, ((i + 1) - window_offset), 1);	wrefresh(form_window);#endif /* USE_SLANG  */	term_options = FALSE;	c = LYgetch_for(FOR_CHOICE);	if (term_options || c == 3 || c == 7) {	    cmd = LYK_QUIT;#ifndef USE_SLANG	} else if (c == MOUSE_KEY) {	    if ((cmd = fancy_mouse(form_window, i + 1 + window_offset, &cur_choice)) < 0)		goto redraw;	    if  (cmd == LYK_ACTIVATE)		break;#endif	} else {	    cmd = keymap[c+1];	}#ifdef VMS	if (HadVMSInterrupt) {	    HadVMSInterrupt = FALSE;	    cmd = LYK_QUIT;	}#endif /* VMS */	switch(cmd) {	    case LYK_F_LINK_NUM:		c = '\0';	    case LYK_1:	    case LYK_2:	    case LYK_3:	    case LYK_4:	    case LYK_5:	    case LYK_6:	    case LYK_7:	    case LYK_8:	    case LYK_9:		/*		 *  Get a number from the user, possibly with		 *  a 'g' or 'p' suffix (which will be loaded		 *  into c). - FM & LE		 */		number = get_popup_choice_number((int *)&c);		/*		 *  Check for a 'p' suffix. - FM		 */		if (c == 'p') {		    /*		     *	Treat 1 or less as the first page. - FM		     */		    if (number <= 1) {			if (window_offset == 0) {			    HTUserMsg(ALREADY_AT_CHOICE_BEGIN);			    if (disabled) {				_statusline(CHOICE_LIST_UNM_MSG);			    } else {				_statusline(CHOICE_LIST_MESSAGE);			    }			    break;			}			window_offset = 0;			cur_choice = 0;			if (disabled) {			    _statusline(CHOICE_LIST_UNM_MSG);			} else {			    _statusline(CHOICE_LIST_MESSAGE);			}			goto redraw;		    }		    /*		     *	Treat a number equal to or greater than the		     *	number of pages as the last page. - FM		     */		    if (number >= npages) {			if (window_offset >= ((num_choices - length) + 1)) {			    HTUserMsg(ALREADY_AT_CHOICE_END);			    if (disabled) {				_statusline(CHOICE_LIST_UNM_MSG);			    } else {				_statusline(CHOICE_LIST_MESSAGE);			    }			    break;			}			window_offset = ((npages - 1) * length);			if (window_offset > (num_choices - length)) {			    window_offset = (num_choices - length + 1);			}			if (cur_choice < window_offset)			    cur_choice = window_offset;			if (disabled) {			    _statusline(CHOICE_LIST_UNM_MSG);			} else {			    _statusline(CHOICE_LIST_MESSAGE);			}			goto redraw;		    }		    /*		     *	We want an intermediate page. - FM		     */		    if (((number - 1) * length) == window_offset) {			sprintf(buffer, ALREADY_AT_CHOICE_PAGE, number);			HTUserMsg(buffer);			if (disabled) {			    _statusline(CHOICE_LIST_UNM_MSG);			} else {			    _statusline(CHOICE_LIST_MESSAGE);			}			break;		    }		    cur_choice = window_offset = ((number - 1) * length);		    if (disabled) {			_statusline(CHOICE_LIST_UNM_MSG);		    } else {			_statusline(CHOICE_LIST_MESSAGE);		    }		    goto redraw;		}		/*		 *  Check for a positive number, which signifies		 *  that a choice should be sought. - FM		 */		if (number > 0) {		    /*		     *	Decrement the number so as to correspond		     *	with our cur_choice values. - FM		     */		    number--;		    /*		     *	If the number is in range and had no legal		     *	suffix, select the indicated choice. - FM		     */		    if (number <= num_choices && c == '\0') {			cur_choice = number;			cmd = LYK_ACTIVATE;			break;		    }		    /*		     *	Verify that we had a 'g' suffix,		     *	and act on the number. - FM		     */		    if (c == 'g') {			if (cur_choice == number) {			    /*			     *	The choice already is current. - FM			     */			    sprintf(buffer,				    CHOICE_ALREADY_CURRENT, (number + 1));			    HTUserMsg(buffer);			    if (disabled) {				_statusline(CHOICE_LIST_UNM_MSG);			    } else {				_statusline(CHOICE_LIST_MESSAGE);			    }			    break;			}			if (number <= num_choices) {			    /*			     *	The number is in range and had a 'g'			     *	suffix, so make it the current choice,			     *	scrolling if needed. - FM			     */			    j = (number - cur_choice);			    cur_choice = number;			    if ((j > 0) &&				(cur_choice - window_offset) >= length) {				window_offset += j;				if (window_offset > (num_choices - length + 1))				    window_offset = (num_choices - length + 1);			    } else if ((cur_choice - window_offset) < 0) {				window_offset -= abs(j);				if (window_offset < 0)				    window_offset = 0;			    }			    if (disabled) {				_statusline(CHOICE_LIST_UNM_MSG);			    } else {				_statusline(CHOICE_LIST_MESSAGE);			    }			    goto redraw;			}			/*			 *  Not in range. - FM			 */			HTUserMsg(BAD_CHOICE_NUM_ENTERED);		    }		}		/*		 *  Restore the popup statusline. - FM		 */		if (disabled) {		    _statusline(CHOICE_LIST_UNM_MSG);		} else {		    _statusline(CHOICE_LIST_MESSAGE);		}		break;	    case LYK_PREV_LINK:	    case LYK_UP_LINK:		if (cur_choice > 0)		    cur_choice--;		/*		 *  Scroll the window up if necessary.		 */		if ((cur_choice - window_offset) < 0) {		    window_offset--;		    goto redraw;		}		break;	    case LYK_NEXT_LINK:	    case LYK_DOWN_LINK:		if (cur_choice < num_choices)		    cur_choice++;		/*		 *  Scroll the window down if necessary		 */		if ((cur_choice - window_offset) >= length) {		    window_offset++;		    goto redraw;		}		break;	    case LYK_NEXT_PAGE:		/*		 *  Okay, are we on the last page of the choices list?		 *  If not then,		 */		if (window_offset != (num_choices - length + 1)) {		    /*		     *	Modify the current choice to not be a		     *	coordinate in the list, but a coordinate		     *	on the item selected in the window.		     */		    cur_choice -= window_offset;		    /*		     *	Page down the proper length for the list.		     *	If simply to far, back up.		     */		    window_offset += length;		    if (window_offset > (num_choices - length)) {			window_offset = (num_choices - length + 1);		    }		    /*		     *	Readjust the current choice to be a choice		     *	list coordinate rather than window.		     *	Redraw this thing.		     */		    cur_choice += window_offset;		    goto redraw;		}		else if (cur_choice < num_choices) {		    /*		     *	Already on last page of the choice list so		     *	just redraw it with the last item selected.		     */		    cur_choice = num_choices;		}		break;	    case LYK_PREV_PAGE:		/*		 *  Are we on the first page of the choice list?		 *  If not then,		 */		if (window_offset != 0) {		    /*		     *	Modify the current choice to not be a choice		     *	list coordinate, but a window coordinate.		     */		    cur_choice -= window_offset;		    /*		     *	Page up the proper length.		     *	If too far, back up.		     */		    window_offset -= length;		    if (window_offset < 0) {			window_offset = 0;		    }		    /*		     *	Readjust the current choice.		     */		    cur_choice += window_offset;		    goto redraw;		} else if (cur_choice > 0) {		    /*		     *	Already on the first page so just		     *	back up to the first item.		     */		    cur_choice = 0;		}		break;	    case LYK_HOME:		cur_choice = 0;		if (window_offset > 0) {		    window_offset = 0;		    goto redraw;		}		break;	    case LYK_END:		cur_choice = num_choices;		if (window_offset != (num_choices - length + 1)) {		    window_offset = (num_choices - length + 1);		    goto redraw;		}		break;	    case LYK_DOWN_TWO:		cur_choice += 2;		if (cur_choice > num_choices)		    cur_choice = num_choices;		/*		 *  Scroll the window down if necessary.		 */		if ((cur_choice - window_offset) >= length) {		    window_offset += 2;		    if (window_offset > (num_choices - length + 1))			window_offset = (num_choices - length + 1);		    goto redraw;		}		break;	    case LYK_UP_TWO:		cur_choice -= 2;		if (cur_choice < 0)		    cur_choice = 0;		/*		 *  Scroll the window up if necessary.		 */		if ((cur_choice - window_offset) < 0) {		    window_offset -= 2;		    if (window_offset < 0)			window_offset = 0;		    goto redraw;		}		break;	    case LYK_DOWN_HALF:		cur_choice += (length/2);		if (cur_choice > num_choices)		    cur_choice = num_choices;		/*		 *  Scroll the window down if necessary.		 */		if ((cur_choice - window_offset) >= length) {		    window_offset += (length/2);		    if (window_offset > (num_choices - length + 1))			window_offset = (num_choices - length + 1);		    goto redraw;		}		break;	    case LYK_UP_HALF:		cur_choice -= (length/2);		if (cur_choice < 0)		    cur_choice = 0;		/*		 *  Scroll the window up if necessary.		 */		if ((cur_choice - window_offset) < 0) {		    window_offset -= (length/2);		    if (window_offset < 0)			window_offset = 0;		    goto redraw;		}		break;	    case LYK_REFRESH:		lynx_force_repaint();		refresh();		break;	    case LYK_NEXT:		if (recall && *prev_target_buffer == '\0') {		    /*		     *	We got a 'n'ext command with no prior query		     *	specified within the popup window.  See if		     *	one was entered when the popup was retracted,		     *	and if so, assume that's what's wanted.  Note		     *	that it will become the default within popups,		     *	unless another is entered within a popup.  If		     *	the within popup default is to be changed at		     *	that point, use WHEREIS ('/') and enter it,		     *	or the up- or down-arrow keys to seek any of		     *	the previously entered queries, regardless of		     *	whether they were entered within or outside		     *	of a popup window. - FM		     */		    if ((cp = (char *)HTList_objectAt(search_queries,						      0)) != NULL) {			strcpy(prev_target_buffer, cp);			QueryNum = 0;			FirstRecall = FALSE;		    }		}		strcpy(prev_target, prev_target_buffer);	    case LYK_WHEREIS:		if (*prev_target == '\0' ) {		    _statusline(ENTER_WHEREIS_QUERY);		    if ((ch = LYgetstr(prev_target, VISIBLE,				       sizeof(prev_target_buffer),				       recall)) < 0) {			/*			 *  User cancelled the search via ^G. - FM			 */			HTInfoMsg(CANCELLED);			goto restore_popup_statusline;		    }		}check_recall:		if (*prev_target == '\0' &&		    !(recall && (ch == UPARROW || ch == DNARROW))) {		    /*		     *	No entry.  Simply break.   - FM		     */		    HTInfoMsg(CANCELLED);		    goto restore_popup_statusline;		}		if (recall && ch == UPARROW) {		    if (FirstRecall) {			/*			 *  Use the current string or			 *  last query in the list. - FM			 */			FirstRecall = FALSE;			if (*prev_target_buffer) {			    for (QueryNum = (QueryTotal - 1);				 QueryNum > 0; QueryNum--) {				if ((cp = (char *)HTList_objectAt(							search_queries,							QueryNum)) != NULL &&				    !strcmp(prev_target_buffer, cp)) {				    break;				}			    }			} else {			    QueryNum = 0;			}		    } else {			/*			 *  Go back to the previous query in the list. - FM			 */			QueryNum++;		    }		    if (QueryNum >= QueryTotal)			/*			 *  Roll around to the last query in the list. - FM			 */			QueryNum = 0;		    if ((cp = (char *)HTList_objectAt(search_queries,						      QueryNum)) != NULL) {			strcpy(prev_target, cp);			if (*prev_target_buffer &&			    !strcmp(prev_target_buffer, prev_target)) {			    _statusline(EDIT_CURRENT_QUERY);			} else if ((*prev_target_buffer && QueryTotal == 2) ||				   (!(*prev_target_buffer) &&				      QueryTotal == 1)) {			    _statusline(EDIT_THE_PREV_QUERY);			} else {			    _statusline(EDIT_A_PREV_QUERY);			}			if ((ch = LYgetstr(prev_target, VISIBLE,				sizeof(prev_target_buffer), recall)) < 0) {			    /*			     *	User cancelled the search via ^G. - FM			     */			    HTInfoMsg(CANCELLED);			    goto restore_popup_statusline;			}			goto check_recall;		    }		} else if (recall && ch == DNARROW) {		    if (FirstRecall) {		    /*		     *	Use the current string or		     *	first query in the list. - FM		     */		    FirstRecall = FALSE;		    if (*prev_target_buffer) {			for (QueryNum = 0;			     QueryNum < (QueryTotal - 1); QueryNum++) {			    if ((cp = (char *)HTList_objectAt(							search_queries,							QueryNum)) != NULL &&				!strcmp(prev_target_buffer, cp)) {				    break;			    }			}		    } else {			QueryNum = (QueryTotal - 1);		    }		} else {		    /*		     *	Advance to the next query in the list. - FM		     */		    QueryNum--;		}		if (QueryNum < 0)		    /*		     *	Roll around to the first query in the list. - FM		     */		    QueryNum = (QueryTotal - 1);		    if ((cp = (char *)HTList_objectAt(search_queries,						      QueryNum)) != NULL) {			strcpy(prev_target, cp);			if (*prev_target_buffer &&			    !strcmp(prev_target_buffer, prev_target)) {			    _statusline(EDIT_CURRENT_QUERY);			} else if ((*prev_target_buffer &&				    QueryTotal == 2) ||				   (!(*prev_target_buffer) &&				    QueryTotal == 1)) {			    _statusline(EDIT_THE_PREV_QUERY);			} else {			    _statusline(EDIT_A_PREV_QUERY);			}			if ((ch = LYgetstr(prev_target, VISIBLE,					   sizeof(prev_target_buffer),					   recall)) < 0) {			    /*			     * User cancelled the search via ^G. - FM			     */			    HTInfoMsg(CANCELLED);			    goto restore_popup_statusline;			}			goto check_recall;		    }		}		/*		 *  Replace the search string buffer with the new target. - FM		 */		strcpy(prev_target_buffer, prev_target);		HTAddSearchQuery(prev_target_buffer);		/*		 *  Start search at the next choice. - FM		 */		for (j = 1; Cptr[i+j] != NULL; j++) {		    sprintf(buffer, "%s%d: %s",				    ((num_choices > 8 && (j + i) < 9) ?								  " " : ""),				    (i + j + 1),				    Cptr[i+j]);		    if (case_sensitive) {			if (strstr(buffer, prev_target_buffer) != NULL)			    break;		    } else {			if (LYstrstr(buffer, prev_target_buffer) != NULL)			    break;		    }		}		if (Cptr[i+j] != NULL) {		    /*		     *	We have a hit, so make that choice the current. - FM		     */		    cur_choice += j;		    /*		     *	Scroll the window down if necessary.		     */		    if ((cur_choice - window_offset) >= length) {			window_offset += j;			if (window_offset > (num_choices - length + 1))			    window_offset = (num_choices - length + 1);			ReDraw = TRUE;		    }		    goto restore_popup_statusline;		}		/*		 *  If we started at the beginning, it can't be present. - FM		 */		if (cur_choice == 0) {		    HTUserMsg2(STRING_NOT_FOUND, prev_target_buffer);		    goto restore_popup_statusline;		}		/*		 *  Search from the beginning to the current choice. - FM		 */		for (j = 0; j < cur_choice; j++) {		    sprintf(buffer, "%s%d: %s",				    ((num_choices > 8 && j < 9) ?							    " " : ""),				    (j + 1),				    Cptr[j]);		    if (case_sensitive) {			if (strstr(buffer, prev_target_buffer) != NULL)			    break;		    } else {			if (LYstrstr(buffer, prev_target_buffer) != NULL)			    break;		    }		}		if (j < cur_choice) {		    /*		     *	We have a hit, so make that choice the current. - FM		     */		    j = (cur_choice - j);		    cur_choice -= j;		    /*		     *	Scroll the window up if necessary.		     */		    if ((cur_choice - window_offset) < 0) {			window_offset -= j;			if (window_offset < 0)			    window_offset = 0;			ReDraw = TRUE;		    }		    goto restore_popup_statusline;		}		/*		 *  Didn't find it in the preceding choices either. - FM		 */		HTUserMsg2(STRING_NOT_FOUND, prev_target_buffer);restore_popup_statusline:		/*		 *  Restore the popup statusline and		 *  reset the search variables. - FM		 */		if (disabled)		    _statusline(CHOICE_LIST_UNM_MSG);		else		    _statusline(CHOICE_LIST_MESSAGE);		*prev_target = '\0';		QueryTotal = (search_queries ? HTList_count(search_queries)					     : 0);		recall = ((QueryTotal >= 1) ? RECALL : NORECALL);		QueryNum = QueryTotal;		if (ReDraw == TRUE) {		    ReDraw = FALSE;		    goto redraw;		}		break;	    case LYK_QUIT:	    case LYK_ABORT:	    case LYK_PREV_DOC:		cur_choice = orig_choice;		term_options = TRUE;		HTUserMsg(CANCELLED);		cmd = LYK_ACTIVATE; /* to exit */		break;	}    }#ifndef USE_SLANG    delwin(form_window);#ifdef NCURSES    LYsubwindow(0);#endif#endif /* !USE_SLANG */    if (disabled || term_options) {	_statusline("");	return(orig_choice);    } else {	_statusline(VALUE_ACCEPTED);	return(cur_choice);    }}