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

📄 lyutils.c

📁 基于rtos开发的浏览器!
💻 C
📖 第 1 页 / 共 5 页
字号:
				move(hLine, (offset + 1));			    } else {				addstr(tmp);			    }			    tmp[1] = '\0';			    written += (utf_extra + 1);			    utf_extra = 0;			} else if (HTCJK != NOCJK && !isascii(tmp[0])) {			    /*			     *	For CJK strings, by Masanobu Kimura.			     */			    tmp[1] = data[++itmp];			    /*			     *	Make sure we don't restore emphasis to			     *	the last character of hightext2 if we			     *	are making the link current. - FM			     */			    if (flag == ON && data[(itmp + 1)] == '\0') {				LYstopTargetEmphasis();				TargetEmphasisON = FALSE;			    } else {				addstr(tmp);			    }			    tmp[1] = '\0';			    written += 2;			} else {			    /*			     *	Make sure we don't restore emphasis to			     *	the last character of hightext2 if we			     *	are making the link current. - FM			     */			    if (flag == ON && data[(itmp + 1)] == '\0') {				LYstopTargetEmphasis();				TargetEmphasisON = FALSE;			    } else {				addstr(tmp);			    }			    written++;			}		    }		    /*		     *	Turn off the emphasis if we haven't already,		     *	and then we're done. - FM		     */		    if (TargetEmphasisON) {			LYstopTargetEmphasis();		    }		    goto highlight_search_done;		} else {		    Data = cp;		    Offset = (offset + HitOffset);		    data = buffer;		    offset = hoffset;		    goto highlight_hit_within_hightext2;		}	    }	    goto highlight_search_done;	}highlight_search_done:	FREE(theData);	if (!LYShowCursor)	    /*	     *	Get cursor out of the way.	     */	    move((LYlines - 1), (LYcols - 1));	else#endif /* FANCY CURSES || USE_SLANG */	    /*	     *	Never hide the cursor if there's no FANCY CURSES or SLANG.	     */	    move(links[cur].ly,		 ((links[cur].lx > 0) ? (links[cur].lx - 1) : 0));	if (flag)	    refresh();    }    return;}/* *  free_and_clear will free a pointer if it *  is non-zero and then set it to zero. */PUBLIC void free_and_clear ARGS1(	char **,	pointer){    if (*pointer) {	free(*pointer);	*pointer = 0;    }    return;}/* *  Collapse (REMOVE) all spaces in the string. */PUBLIC void collapse_spaces ARGS1(	char *, 	string){    int i=0;    int j=0;    if (!string)	return;    for (; string[i] != '\0'; i++)	if (!isspace((unsigned char)string[i]))	    string[j++] = string[i];    string[j] = '\0';  /* terminate */    return;}/* *  Convert single or serial newlines to single spaces throughout a string *  (ignore newlines if the preceding character is a space) and convert *  tabs to single spaces.  Don't ignore any explicit tabs or spaces if *  the condense argument is FALSE, otherwise, condense any serial spaces *  or tabs to one space. - FM */PUBLIC void convert_to_spaces ARGS2(	char *, 	string,	BOOL,		condense){    char *s = string;    char *ns = string;    BOOL last_is_space = FALSE;    if (!string)	return;    while (*s) {	switch (*s) {	    case ' ':	    case '\t':		if (!(condense && last_is_space))		    *(ns++) = ' ';		last_is_space = TRUE;		break;	    case '\r':	    case '\n':		if (!last_is_space) {		    *(ns++) = ' ';		    last_is_space = TRUE;		}		break;	    default:		*(ns++) = *s;		last_is_space = FALSE;		break;	}	s++;    }    *ns = '\0';    return;}/* *  Strip trailing slashes from directory paths. */PUBLIC char * strip_trailing_slash ARGS1(	char *, 	dirname){    int i;    i = strlen(dirname) - 1;    while (i >= 0 && dirname[i] == '/')	dirname[i--] = '\0';    return(dirname);}/* *  Display (or hide) the status line. */BOOLEAN mustshow = FALSE;PUBLIC void statusline ARGS1(	CONST char *,	text){    char buffer[256];    unsigned char *temp = NULL;    int max_length, len, i, j;    unsigned char k;    if (text == NULL)	return;    /*     *	Don't print statusline messages if dumping to stdout.     */    if (dump_output_immediately)	return;    /*     *	Don't print statusline message if turned off.     */    if (mustshow != TRUE) {	if (no_statusline == TRUE) {	    return;	}    }    mustshow = FALSE;    /*     *	Deal with any CJK escape sequences and Kanji if we have a CJK     *	character set selected, otherwise, strip any escapes.  Also,     *	make sure text is not longer than the statusline window. - FM     */    max_length = ((LYcols - 2) < 256) ? (LYcols - 2) : 255;    if ((text[0] != '\0') &&	(LYHaveCJKCharacterSet)) {	/*	 *  Translate or filter any escape sequences. - FM	 */	if ((temp = (unsigned char *)calloc(1, strlen(text) + 1)) == NULL)	    outofmem(__FILE__, "statusline");	if (kanji_code == EUC) {	    TO_EUC((unsigned char *)text, temp);	} else if (kanji_code == SJIS) {	    TO_SJIS((unsigned char *)text, temp);	} else {	    for (i = 0, j = 0; text[i]; i++) {		if (text[i] != '\033') {		    temp[j++] = text[i];		}	    }	    temp[j] = '\0';	}	/*	 *  Deal with any newlines or tabs in the string. - FM	 */	convert_to_spaces((char *)temp, FALSE);	/*	 *  Handle the Kanji, making sure the text is not	 *  longer than the statusline window. - FM	 */	for (i = 0, j = 0, len = 0, k = '\0';	     temp[i] != '\0' && len < max_length; i++) {	    if (k != '\0') {		buffer[j++] = k;		buffer[j++] = temp[i];		k = '\0';		len += 2;	    } else if ((temp[i] & 0200) != 0) {		k = temp[i];	    } else {		buffer[j++] = temp[i];		len++;	    }	}	buffer[j] = '\0';	FREE(temp);    } else {	/*	 *  Strip any escapes, and shorten text if necessary.  Note	 *  that we don't deal with the possibility of UTF-8 characters	 *  in the string.  This is unlikely, but if strings with such	 *  characters are used in LYMessages_en.h, a compilation	 *  symbol of HAVE_UTF8_STATUSLINES could be added there, and	 *  code added here for determining the displayed string length,	 *  as we do above for CJK. - FM	 */	for (i = 0, len = 0; text[i] != '\0' && len < max_length; i++) {	    if (text[i] != '\033') {		buffer[len++] = text[i];	    }	}	buffer[len] = '\0';	/*	 *  Deal with any newlines or tabs in the string. - FM	 */	convert_to_spaces(buffer, FALSE);    }    /*     *	Move to the desired statusline window and     *	output the text highlighted. - FM     */    if (LYStatusLine >= 0) {	if (LYStatusLine < LYlines-1) {	    move(LYStatusLine, 0);	} else {	    move(LYlines-1, 0);	}    } else if (user_mode == NOVICE_MODE) {	move(LYlines-3, 0);    } else {	move(LYlines-1, 0);    }    clrtoeol();    if (text != NULL && text[0] != '\0') {#ifdef HAVE_UTF8_STATUSLINES	if (LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8) {	    refresh();	}#endif /* HAVE_UTF8_STATUSLINES */#ifndef USE_COLOR_STYLE	lynx_start_status_color ();	addstr (buffer);	lynx_stop_status_color ();#else	/* draw the status bar in the STATUS style */	{		int a=(strncmp(buffer, "Alert", 5) || !hashStyles[s_alert].name ? s_status : s_alert);		LynxChangeStyle (a, ABS_ON, 1);		addstr(buffer);		wbkgdset(stdscr,			 ((lynx_has_color && LYShowColor >= SHOW_COLOR_ON)			  ? hashStyles[a].color			  :A_NORMAL) | ' ');		clrtoeol();		if (s_normal != NOSTYLE)		    wbkgdset(stdscr, hashStyles[s_normal].color | ' ');		else		    wbkgdset(stdscr,			     ((lynx_has_color && LYShowColor >= SHOW_COLOR_ON)			      ? displayStyles[DSTYLE_NORMAL].color			      : A_NORMAL) | ' ');		LynxChangeStyle (a, ABS_OFF, 0);	}#endif    }    refresh();    return;}static char *novice_lines[] = {#ifndef NOVICE_LINE_TWO_A#define NOVICE_LINE_TWO_A	NOVICE_LINE_TWO#define NOVICE_LINE_TWO_B	""#define NOVICE_LINE_TWO_C	""#endif /* !NOVICE_LINE_TWO_A */  NOVICE_LINE_TWO_A,  NOVICE_LINE_TWO_B,  NOVICE_LINE_TWO_C,  ""};static int lineno = 0;PUBLIC void toggle_novice_line NOARGS{	lineno++;	if (*novice_lines[lineno] == '\0')		lineno = 0;	return;}PUBLIC void noviceline ARGS1(	int,		more_flag GCC_UNUSED){    if (dump_output_immediately)	return;    move(LYlines-2,0);    /* stop_reverse(); */    clrtoeol();    addstr(NOVICE_LINE_ONE);    clrtoeol();#if defined(DIRED_SUPPORT ) && defined(OK_OVERRIDE)    if (lynx_edit_mode && !no_dired_support)       addstr(DIRED_NOVICELINE);    else#endif /* DIRED_SUPPORT && OK_OVERRIDE */    if (LYUseNoviceLineTwo)	addstr(NOVICE_LINE_TWO);    else	addstr(novice_lines[lineno]);#ifdef NOTDEFINED    if (is_www_index && more_flag) {	addstr("This is a searchable index.  Use ");	addstr(key_for_func(LYK_INDEX_SEARCH));	addstr(" to search:");	stop_reverse();	addstr("                ");	start_reverse();	addstr("space for more");    } else if (is_www_index) {	addstr("This is a searchable index.  Use ");	addstr(key_for_func(LYK_INDEX_SEARCH));	addstr(" to search:");    } else {	addstr("Type a command or ? for help:");	if (more_flag) {	    stop_reverse();	    addstr("                       ");	    start_reverse();	    addstr("Press space for next page");	}    }#endif /* NOTDEFINED */    refresh();    return;}PRIVATE int fake_zap = 0;PUBLIC void LYFakeZap ARGS1(    BOOL,	set){    if (set && fake_zap < 1) {	if (TRACE) {	    fprintf(stderr, "\r *** Set simulated 'Z'");	    if (fake_zap)		fprintf(stderr, ", %d pending", fake_zap);	    fprintf(stderr, " ***\n");	}	fake_zap++;    } else if (!set && fake_zap) {	if (TRACE) {	    fprintf(stderr, "\r *** Unset simulated 'Z'");	    fprintf(stderr, ", %d pending", fake_zap);	    fprintf(stderr, " ***\n");	}	fake_zap = 0;    }}PUBLIC int HTCheckForInterrupt NOARGS{#ifndef VMS /* UNIX stuff: */    int c;#ifndef USE_SLANG    struct timeval socket_timeout;    int ret = 0;    fd_set readfds;#endif /* !USE_SLANG */    if (fake_zap > 0) {	fake_zap--;	if (TRACE) {	    fprintf(stderr, "\r *** Got simulated 'Z' ***\n");	    fflush(stderr);	    if (!LYTraceLogFP)		sleep(AlertSecs);	}	return((int)TRUE);    }    /** Curses or slang setup was not invoked **/    if (dump_output_immediately)	return((int)FALSE);#ifdef USE_SLANG    /** No keystroke was entered	Note that this isn't taking possible SOCKSification	and the socks_flag into account, and may fail on the	slang library's select() when SOCKSified. - FM **/    if (0 == SLang_input_pending(0))	return(FALSE);#else /* Unix curses: */    socket_timeout.tv_sec = 0;    socket_timeout.tv_usec = 100;    FD_ZERO(&readfds);    FD_SET(0, &readfds);#ifdef SOCKS    if (socks_flag)	ret = Rselect(FD_SETSIZE, (void *)&readfds, NULL, NULL,		      &socket_timeout);    else#endif /* SOCKS */	ret = select(FD_SETSIZE, (void *)&readfds, NULL, NULL,		     &socket_timeout);    /** Suspended? **/    if ((ret == -1) && (errno == EINTR))	 return((int)FALSE);    /** No keystroke was entered? **/    if (!FD_ISSET(0,&readfds))	 return((int)FALSE);#endif /* USE_SLANG */    /** Keyboard 'Z' or 'z', or Control-G or Control-C **/#if defined (DOSPATH) && defined (NCURSES)    nodelay(stdscr,TRUE);#endif /* DOSPATH */    c = LYgetch();#if defined (DOSPATH) && defined (NCURSES)    nodelay(stdscr,FALSE);#endif /* DOSPATH */    if (TOUPPER(c) == 'Z' || c == 7 || c == 3)	return((int)TRUE);    /** Other keystrokes **/    return((int)FALSE);#else /* VMS: */    int c;    extern BOOLEAN HadVMSInterrupt;    extern int typeahead();    if (fake_zap > 0) {	fake_zap--;	if (TRACE) {	    fprintf(stderr, "\r *** Got simulated 'Z' ***\n");	    fflush(stderr);	    if (!LYTraceLogFP)		sleep(AlertSecs);	}	return((int)TRUE);    }    /** Curses or slang setup was not invoked **/    if (dump_output_immediately)	  return((int)FALSE);    /** Control-C or Control-Y and a 'N'o reply to exit query **/    if (HadVMSInterrupt) {	HadVMSInterrupt = FALSE;	return((int)TRUE);    }    /** Keyboard 'Z' or 'z', or Control-G or Control-C **/    c = typeahead();    if (TOUPPER(c) == 'Z' || c == 7 || c == 3)	return((int)TRUE);    /** Other or no keystrokes **/    return((int)FALSE);#endif /* !VMS */}

⌨️ 快捷键说明

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