⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lyforms.c

📁 基于rtos开发的浏览器!
💻 C
📖 第 1 页 / 共 3 页
字号:
				    window_offset = 0;			    }			    if (disabled) {				_statusline(FORM_LINK_OPTION_LIST_UNM_MSG);			    } else {				_statusline(FORM_LINK_OPTION_LIST_MESSAGE);			    }			    goto redraw;			}			/*			 *  Not in range. - FM			 */			_statusline(BAD_OPTION_NUM_ENTERED);			sleep(MessageSecs);		    }		}		/*		 *  Restore the popup statusline. - FM		 */		if (disabled) {		    _statusline(FORM_LINK_OPTION_LIST_UNM_MSG);		} else {		    _statusline(FORM_LINK_OPTION_LIST_MESSAGE);		}		break;	    case LYK_PREV_LINK:	    case LYK_UP_LINK:		if (cur_selection > 0)		    cur_selection--;		/*		 *  Scroll the window up if necessary.		 */		if ((cur_selection - window_offset) < 0) {		    window_offset--;		    goto redraw;		}		break;	    case LYK_NEXT_LINK:	    case LYK_DOWN_LINK:		if (cur_selection < num_options)		    cur_selection++;		/*		 *  Scroll the window down if necessary		 */		if ((cur_selection - window_offset) >= length) {		    window_offset++;		    goto redraw;		}		break;	    case LYK_NEXT_PAGE:		/*		 *  Okay, are we on the last page of the list?		 *  If not then,		 */		if (window_offset != (num_options - length + 1)) {		    /*		     *  Modify the current selection to not be a		     *  coordinate in the list, but a coordinate		     *  on the item selected in the window.		     */		    cur_selection -= window_offset;		    /*		     *  Page down the proper length for the list.		     *  If simply to far, back up.		     */		    window_offset += length;		    if (window_offset > (num_options - length)) {			window_offset = (num_options - length + 1);		    }		    /*		     *  Readjust the current selection to be a		     *  list coordinate rather than window.		     *  Redraw this thing.		     */		    cur_selection += window_offset;		    goto redraw;		}		else if (cur_selection < num_options) {		    /*		     *  Already on last page of the list so just		     *  redraw it with the last item selected.		     */		    cur_selection = num_options;		}		break;	    case LYK_PREV_PAGE:		/*		 *  Are we on the first page of the list?		 *  If not then,		 */		if (window_offset != 0) {		    /*		     *  Modify the current selection to not be a		     *  list coordinate, but a window coordinate.		     */		    cur_selection -= 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 selection.		     */		    cur_selection += window_offset;		    goto redraw;		} else if (cur_selection > 0) {		    /*		     *  Already on the first page so just		     *  back up to the first item.		     */		    cur_selection = 0;		}		break;	    case LYK_HOME:		cur_selection = 0;		if (window_offset > 0) {		    window_offset = 0;		    goto redraw;		}		break;	    case LYK_END:		cur_selection = num_options;		if (window_offset != (num_options - length + 1)) {		    window_offset = (num_options - length + 1);		    goto redraw;		}		break;	    case LYK_DOWN_TWO:		cur_selection += 2;		if (cur_selection > num_options)		    cur_selection = num_options;		/*		 *  Scroll the window down if necessary.		 */		if ((cur_selection - window_offset) >= length) {		    window_offset += 2;		    if (window_offset > (num_options - length + 1))			window_offset = (num_options - length + 1);		    goto redraw;		}		break;	    case LYK_UP_TWO:		cur_selection -= 2;		if (cur_selection < 0)		    cur_selection = 0;		/*		 *  Scroll the window up if necessary.		 */		if ((cur_selection - window_offset) < 0) {		    window_offset -= 2;		    if (window_offset < 0)			window_offset = 0;		    goto redraw;		}		break;	    case LYK_DOWN_HALF:		cur_selection += (length/2);		if (cur_selection > num_options)		    cur_selection = num_options;		/*		 *  Scroll the window down if necessary.		 */		if ((cur_selection - window_offset) >= length) {		    window_offset += (length/2);		    if (window_offset > (num_options - length + 1))			window_offset = (num_options - length + 1);		    goto redraw;		}		break;	    case LYK_UP_HALF:		cur_selection -= (length/2);		if (cur_selection < 0)		    cur_selection = 0;		/*		 *  Scroll the window up if necessary.		 */		if ((cur_selection - 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			 */			_statusline(CANCELLED);			sleep(InfoSecs);			goto restore_popup_statusline;		    }		}check_recall:		if (*prev_target == '\0' &&		    !(recall && (ch == UPARROW || ch == DNARROW))) {		    /*		     *  No entry.  Simply break.   - FM		     */		    _statusline(CANCELLED);		    sleep(InfoSecs);		    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			     */			    _statusline(CANCELLED);			    sleep(InfoSecs);			    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			     */			    _statusline(CANCELLED);			    sleep(InfoSecs);			    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 option. - FM		 */		for (j = 1, tmp_ptr = opt_ptr->next;		     tmp_ptr != NULL; tmp_ptr = tmp_ptr->next, j++) {		    if (case_sensitive) {			if (strstr(tmp_ptr->name, prev_target_buffer) != NULL)			    break;		    } else {			if (LYstrstr(tmp_ptr->name, prev_target_buffer) != NULL)			    break;		    }		}		if (tmp_ptr != NULL) {		    /*		     *  We have a hit, so make that option the current. - FM		     */		    cur_selection += j;		    /*		     *  Scroll the window down if necessary.		     */		    if ((cur_selection - window_offset) >= length) {			window_offset += j;			if (window_offset > (num_options - length + 1))			    window_offset = (num_options - length + 1);			ReDraw = TRUE;		    }		    goto restore_popup_statusline;		}		/*		 *  If we started at the beginning, it can't be present. - FM		 */		if (cur_selection == 0) {		    _user_message(STRING_NOT_FOUND, prev_target_buffer);		    sleep(MessageSecs);		    goto restore_popup_statusline;		}		/*		 *  Search from the beginning to the current option. - FM		 */		for (j = 0, tmp_ptr = list;		     j < cur_selection; tmp_ptr = tmp_ptr->next, j++) {		    if (case_sensitive) {			if (strstr(tmp_ptr->name, prev_target_buffer) != NULL)			    break;		    } else {			if (LYstrstr(tmp_ptr->name, prev_target_buffer) != NULL)			    break;		    }		}		if (j < cur_selection) {		    /*		     *  We have a hit, so make that option the current. - FM		     */		    j = (cur_selection - j);		    cur_selection -= j;		    /*		     *  Scroll the window up if necessary.		     */		    if ((cur_selection - 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 options either. - FM		 */		_user_message(STRING_NOT_FOUND, prev_target_buffer);		sleep(MessageSecs);restore_popup_statusline:		/*		 *  Restore the popup statusline and		 *  reset the search variables. - FM		 */		if (disabled)		    _statusline(FORM_LINK_OPTION_LIST_UNM_MSG);		else		    _statusline(FORM_LINK_OPTION_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_selection = orig_selection;		cmd = LYK_ACTIVATE; /* to exit */		break;	}    }#ifndef USE_SLANG    delwin(form_window);#ifdef NCURSES    LYsubwindow(0);#endif#endif /* !USE_SLANG */    return(disabled ? orig_selection : cur_selection);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -