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

📄 gridtext.c

📁 基于rtos开发的浏览器!
💻 C
📖 第 1 页 / 共 5 页
字号:
	char,		ch){    HTLine * line;    HTStyle * style;    int indent;    /*     *  Make sure we don't crash on NULLs.     */    if (!text)	return;    if (text->halted > 1) {	/*	 *  We should stop outputting more text, because low memory was	 *  detected.  - kw	 */	if (text->halted == 2) {	    /*	     *  But if we haven't done so yet, first append a warning.	     *  We should still have a few bytes left for that :).	     *  We temporarily reset test->halted to 0 for this, since	     *  this function will get called recursively. - kw	     */	    text->halted = 0;	    text->kanji_buf = '\0';	    HText_appendText(text, " *** MEMORY EXHAUSTED ***");	}	text->halted = 3;	return;    }    /*     *  Make sure we don't hang on escape sequences.     */    if (ch == '\033' && HTCJK == NOCJK)			/* decimal 27 */	return;#ifndef USE_SLANG    /*     *  Block 8-bit chars not allowed by the current display character     *  set if they are below what LYlowest_eightbit indicates.     *  Slang used its own replacements, so for USE_SLANG blocking here     *  is not necessary to protect terminals from those characters.     *  They should have been filtered out or translated by an earlier     *  processing stage anyway. - kw     */    if ((unsigned char)ch >= 128 && HTCJK == NOCJK &&	!text->T.transp && !text->T.output_utf8 &&	(unsigned char)ch < LYlowest_eightbit[current_char_set])	return;#endif /* USE_SLANG */    if ((unsigned char)ch == 155 && HTCJK == NOCJK) {	/* octal 233 */	if (!HTPassHighCtrlRaw &&	    !text->T.transp && !text->T.output_utf8 &&	    (155 < LYlowest_eightbit[current_char_set]) &&	    strncmp(LYchar_set_names[current_char_set],		    "DosLatin1 (cp850)", 17) &&	    strncmp(LYchar_set_names[current_char_set],		    "DosLatinUS (cp437)", 18) &&	    strncmp(LYchar_set_names[current_char_set],		    "Macintosh (8 bit)", 17) &&	    strncmp(LYchar_set_names[current_char_set],		    "NeXT character set", 18)) {	    return;	}    }    line = text->last_line;    style = text->style;    indent = text->in_line_1 ? (int)style->indent1st : (int)style->leftIndent;    if (HTCJK != NOCJK) {	switch(text->state) {	    case S_text:		if (ch == '\033') {		    /*		    **  Setting up for CJK escape sequence handling (based on		    **  Takuya ASADA's (asada@three-a.co.jp) CJK Lynx). - FM		    */		    text->state = S_esc;		    text->kanji_buf = '\0';		    return;		}		break;		case S_esc:		/*		 *  Expecting '$'or '(' following CJK ESC.		 */		if (ch == '$') {		    text->state = S_dollar;		    return;		} else if (ch == '(') {		    text->state = S_paren;		    return;		} else {		    text->state = S_text;		}		case S_dollar:		/*		 *  Expecting '@', 'B', 'A' or '(' after CJK "ESC$".		 */		if (ch == '@' || ch == 'B' || ch=='A') {		    text->state = S_nonascii_text;		    return;		} else if (ch == '(') {		    text->state = S_dollar_paren;		    return;		} else {		    text->state = S_text;		}		break;		case S_dollar_paren:		/*		 * Expecting 'C' after CJK "ESC$(".		 */		if (ch == 'C') {		    text->state = S_nonascii_text;		    return;		} else {		    text->state = S_text;		}		break;		case S_paren:		/*		 *  Expecting 'B', 'J', 'T' or 'I' after CJK "ESC(".		 */		if (ch == 'B' || ch == 'J' || ch == 'T')  {		    /*		     *  Can split here. - FM		     */		    text->permissible_split = (int)text->last_line->size;		    text->state = S_text;		    return;		} else if (ch == 'I')  {		    text->state = S_jisx0201_text;		    /*		     *  Can split here. - FM		     */		    text->permissible_split = (int)text->last_line->size;		    return;		} else {		    text->state = S_text;		}		break;		case S_nonascii_text:		/*		 *  Expecting CJK ESC after non-ASCII text.		 */		if (ch == '\033') {		    text->state = S_esc;		    text->kanji_buf = '\0';		    return;		} else {		    ch |= 0200;		}		break;		/*		 *  JIS X0201 Kana in JIS support. - by ASATAKU		 */		case S_jisx0201_text:		if (ch == '\033') {		    text->state = S_esc;		    text->kanji_buf = '\0';		    return;		} else {		    text->kanji_buf = '\x8E';		    ch |= 0200;		}		break;	}	if (!text->kanji_buf) {	    if ((ch & 0200) != 0) {		/*		 *  JIS X0201 Kana in SJIS support. - by ASATAKU		 */	        if ((text->kcode == SJIS) &&		    ((unsigned char)ch >= 0xA1) &&		    ((unsigned char)ch <= 0xDF)) {		    unsigned char c = (unsigned char)ch;		    unsigned char kb = (unsigned char)text->kanji_buf;		    JISx0201TO0208_SJIS(c,					(unsigned char *)&kb,					(unsigned char *)&c);		    ch = (char)c;		    text->kanji_buf = (char)kb;	        } else {		    text->kanji_buf = ch;		    /*		     *  Can split here. - FM		     */		    text->permissible_split = (int)text->last_line->size;		    return;	        }	    }	} else {	    goto check_IgnoreExcess;	}    } else if (ch == '\033') {	return;    }    if (IsSpecialAttrChar(ch)) {#ifndef USE_COLOR_STYLE	if (ch == LY_UNDERLINE_START_CHAR) {	    line->data[line->size++] = LY_UNDERLINE_START_CHAR;	    line->data[line->size] = '\0';	    underline_on = ON;	    if (!(dump_output_immediately && use_underscore))		ctrl_chars_on_this_line++;	    return;	} else if (ch == LY_UNDERLINE_END_CHAR) {	    line->data[line->size++] = LY_UNDERLINE_END_CHAR;	    line->data[line->size] = '\0';	    underline_on = OFF;	    if (!(dump_output_immediately && use_underscore))		ctrl_chars_on_this_line++;	    return;	} else if (ch == LY_BOLD_START_CHAR) {	    line->data[line->size++] = LY_BOLD_START_CHAR;	    line->data[line->size] = '\0';	    bold_on = ON;	    ctrl_chars_on_this_line++;	    return;	} else if (ch == LY_BOLD_END_CHAR) {	    line->data[line->size++] = LY_BOLD_END_CHAR;	    line->data[line->size] = '\0';	    bold_on = OFF;	    ctrl_chars_on_this_line++;	    return;	} else if (ch == LY_SOFT_HYPHEN) {	    int i;	    /*	     *  Ignore the soft hyphen if it is the first character	     *  on the line, or if it is preceded by a space or	     *  hyphen. - FM	     */	    if (line->size < 1 || text->permissible_split >= (int)line->size)		return;	    for (i = (text->permissible_split + 1); line->data[i]; i++) {		if (!IsSpecialAttrChar((unsigned char)line->data[i]) &&		    !isspace((unsigned char)line->data[i]) &&		    (unsigned char)line->data[i] != '-' &&		    (unsigned char)line->data[i] != HT_NON_BREAK_SPACE &&		    (unsigned char)line->data[i] != HT_EM_SPACE) {		    break;		}	    }	    if (line->data[i] == '\0') {		return;	    }	}#else	return;#endif    }    if (IS_UTF_EXTRA(ch)) {	line->data[line->size++] = ch;	line->data[line->size] = '\0';	ctrl_chars_on_this_line++;	return;    }    /*     *  New Line.     */    if (ch == '\n') {	    new_line(text);	    text->in_line_1 = YES;	/* First line of new paragraph */	    /*	     *  There are some pages written in	     *  different kanji codes. - TA & kw	     */	    if (HTCJK == JAPANESE)		text->kcode = NOKANJI;	    return;    }    /*     *  Convert EM_SPACE to a space here so that it doesn't get collapsed.     */    if (ch == HT_EM_SPACE)	ch = ' ';    /*     *  I'm going to cheat here in a BIG way.  Since I know that all     *  \r's will be trapped by HTML_put_character I'm going to use     *  \r to mean go down a line but don't start a new paragraph.     *  i.e. use the second line indenting.     */    if (ch == '\r') {	new_line(text);	text->in_line_1 = NO;	/*	 *  There are some pages written in	 *  different kanji codes. - TA & kw	 */	if (HTCJK == JAPANESE)	    text->kcode = NOKANJI;	return;    }    /*     *  Tabs.     */    if (ch == '\t') {	CONST HTTabStop * Tab;	int target;	/* Where to tab to */	int here;	if (line->size > 0 && line->data[line->size-1] == LY_SOFT_HYPHEN) {	    /*	     *  A tab shouldn't follow a soft hyphen, so	     *  if one does, we'll dump the soft hyphen. - FM	     */	    line->data[--line->size] = '\0';	    ctrl_chars_on_this_line--;	}	here = (((int)line->size + (int)line->offset) + indent)		- ctrl_chars_on_this_line; /* Consider special chars GAB */	if (style->tabs) {	/* Use tab table */	    for (Tab = style->tabs;		Tab->position <= here;		Tab++)		if (!Tab->position) {		    new_line(text);		    return;		}	    target = Tab->position;	} else if (text->in_line_1) {	/* Use 2nd indent */	    if (here >= (int)style->leftIndent) {	        new_line(text); /* wrap */		return;	    } else {	        target = (int)style->leftIndent;	    }	} else {		/* Default tabs align with left indent mod 8 */#ifdef DEFAULT_TABS_8	    target = (((int)line->offset + (int)line->size + 8) & (-8))			+ (int)style->leftIndent;#else	    new_line(text);	    return;#endif	}	if (target > (LYcols-1) - (int)style->rightIndent &&	    HTOutputFormat != WWW_SOURCE) {	    new_line(text);	    return;	} else {	    /*	     *  Can split here. - FM	     */	    text->permissible_split = (int)line->size;	    if (line->size == 0) {	        line->offset = line->offset + target - here;	    } else {	        for (; here<target; here++) {		    /* Put character into line */		    line->data[line->size++] = ' ';		    line->data[line->size] = '\0';	        }	    }	    return;	}	/*NOTREACHED*/    } /* if tab */    if (ch == ' ') {	/*	 *  Can split here. - FM	 */	text->permissible_split = (int)text->last_line->size;	/*	 *  There are some pages written in	 *  different kanji codes. - TA	 */	if (HTCJK == JAPANESE)	    text->kcode = NOKANJI;    }    /*     *  Check if we should ignore characters at the wrap point.     */check_IgnoreExcess:    if (text->IgnoreExcess &&	((indent + (int)line->offset + (int)line->size) +	(int)style->rightIndent - ctrl_chars_on_this_line) >= (LYcols-1))	return;    /*     *  Check for end of line.     */    if (((indent + (int)line->offset + (int)line->size) +	 (int)style->rightIndent - ctrl_chars_on_this_line +	 ((line->size > 0) &&	  (int)(line->data[line->size-1] ==				LY_SOFT_HYPHEN ?					     1 : 0))) >= (LYcols - 1)) {	if (style->wordWrap && HTOutputFormat != WWW_SOURCE) {	    split_line(text, text->permissible_split);	    if (ch == ' ') return;	/* Ignore space causing split */	}  else if (HTOutputFormat == WWW_SOURCE) {		 /*		  *  For source output we don't want to wrap this stuff		  *  unless absolutely necessary. - LJM		  *  !		  *  If we don't wrap here we might get a segmentation fault.		  *  but let's see what happens		  */		if ((int)line->size >= (int)(MAX_LINE-1))		   new_line(text);  /* try not to linewrap */	} else {		/*		 *  For normal stuff like pre let's go ahead and		 *  wrap so the user can see all of the text.		 */		new_line(text);	}    } else if ((int)line->size >= (int)(MAX_LINE-1)) {	/*	 *  Never overrun memory if LYcols is set to a large value - KW	 */	new_line(text);    }    /*     *  Insert normal characters.     */    if (ch == HT_NON_BREAK_SPACE) {	ch = ' ';    }    if (ch & 0x80)	text->have_8bit_chars = YES;    {	HTFont font = style->font;	unsigned char hi, lo, tmp[2];	line = text->last_line; /* May have changed */	if (HTCJK != NOCJK && text->kanji_buf) {	    hi = (unsigned char)text->kanji_buf, lo = (unsigned char)ch;	    if (HTCJK == JAPANESE && text->kcode == NOKANJI) {		if (IS_SJIS(hi, lo, text->in_sjis) && IS_EUC(hi, lo)) {		    text->kcode = NOKANJI;		} else if (IS_SJIS(hi, lo, text->in_sjis)) {		    text->kcode = SJIS;		} else if (IS_EUC(hi, lo)) {		    text->kcode = EUC;		}	    }	    if (HTCJK == JAPANESE &&		(kanji_code == EUC) && (text->kcode == SJIS)) {		SJIS_TO_EUC1(hi, lo, tmp);		line->data[line->size++] = tmp[0];		line->data[line->size++] = tmp[1];	    } else if (HTCJK == JAPANESE &&		       (kanji_code == EUC) && (text->kcode == EUC)) {		JISx0201TO0208_EUC(hi, lo, &hi, &lo);		line->data[line->size++] = hi;		line->data[line->size++] = lo;	    } else if (HTCJK == JAPANESE &&		       (kanji_code == SJIS) && (text->kcode == EUC)) {		EUC_TO_SJIS1(hi, lo, tmp);		line->data[line->size++] = tmp[0];		line->data[line->size++] = tmp[1];	    } else {		line->data[line->size++] = hi;		line->data[line->size++] = lo;	    }	    text->kanji_buf = 0;	} else if (HTCJK != NOCJK) {	    line->data[line->size++] = (kanji_code != NOKANJI) ?							    ch :					  (font & HT_CAPITALS) ?						   TOUPPER(ch) : ch;	} else {	    line->data[line->size++] =	/* Put character into line */		font & HT_CAPITALS ? TOUPPER(ch) : ch;	}	line->data[line->size] = '\0';	if (font & HT_DOUBLE)		/* Do again if doubled */	    HText_appendCharacter(text, HT_NON_BREAK_SPACE);	    /* NOT a permissible split */	if (ch == LY_SOFT_HYPHEN) {	    ctrl_char

⌨️ 快捷键说明

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