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

📄 gridtext.c

📁 基于rtos开发的浏览器!
💻 C
📖 第 1 页 / 共 5 页
字号:
     *  Check the kcode setting if the anchor has a charset element. - FM     */    if (anchor->charset)	HText_setKcode(self, anchor->charset,		       HTAnchor_getUCInfoStage(anchor, UCT_STAGE_HTEXT));    /*     *	Memory leak fixed.     *  05-29-94 Lynx 2-3-1 Garrett Arch Blythe     *	Check to see if our underline and star_string need initialization     *		if the underline is not filled with dots.     */    if (underscore_string[0] != '.') {	/*	 *  Create an array of dots for the UNDERSCORES macro. - FM	 */	memset(underscore_string, '.', (MAX_LINE-1));	underscore_string[(MAX_LINE-1)] = '\0';	underscore_string[MAX_LINE] = '\0';	/*	 *  Create an array of underscores for the STARS macro. - FM	 */	memset(star_string, '_', (MAX_LINE-1));	star_string[(MAX_LINE-1)] = '\0';	star_string[MAX_LINE] = '\0';    }    underline_on = FALSE; /* reset */    bold_on = FALSE;    return self;}/*                      Creation Method 2**                      ---------------****      Stream is assumed open and left open.*/PUBLIC HText *  HText_new2 ARGS2(	HTParentAnchor *,	anchor,	HTStream *,		stream){    HText * this = HText_new(anchor);    if (stream) {	this->target = stream;	this->targetClass = *stream->isa;	/* copy action procedures */    }    return this;}/*	Free Entire Text**	----------------*/PUBLIC void HText_free ARGS1(	HText *,	self){    if (!self)	return;    HTAnchor_setDocument(self->node_anchor, (HyperDoc *)0);    while (YES) {	/* Free off line array */	HTLine * l = self->last_line;	if (l) {	    l->next->prev = l->prev;	    l->prev->next = l->next;	/* Unlink l */	    self->last_line = l->prev;	    if (l != self->last_line) {	        FREE(l);	    } else {	        free(l);	    }	}	if (l == self->last_line) {	/* empty */	    l = NULL;	    break;	}    };    while (self->first_anchor) {		/* Free off anchor array */	TextAnchor * l = self->first_anchor;	self->first_anchor = l->next;	if (l->link_type == INPUT_ANCHOR && l->input_field) {	    /*	     *  Free form fields.	     */	    if (l->input_field->type == F_OPTION_LIST_TYPE &&		l->input_field->select_list != NULL) {		/*		 *  Free off option lists if present.		 *  It should always be present for F_OPTION_LIST_TYPE		 *  unless we had invalid markup which prevented		 *  HText_setLastOptionValue from finishing its job		 *  and left the input field in an insane state. - kw		 */		OptionType *optptr = l->input_field->select_list;		OptionType *tmp;		while (optptr) {		    tmp = optptr;		    optptr = tmp->next;		    FREE(tmp->name);		    FREE(tmp->cp_submit_value);		    FREE(tmp);		}		l->input_field->select_list = NULL;		/*		 *  Don't free the value field on option		 *  lists since it points to a option value		 *  same for orig value.		 */		l->input_field->value = NULL;		l->input_field->orig_value = NULL;		l->input_field->cp_submit_value = NULL;		l->input_field->orig_submit_value = NULL;	    } else {		FREE(l->input_field->value);		FREE(l->input_field->orig_value);		FREE(l->input_field->cp_submit_value);		FREE(l->input_field->orig_submit_value);	    }	    FREE(l->input_field->name);	    FREE(l->input_field->submit_action);	    FREE(l->input_field->submit_enctype);	    FREE(l->input_field->submit_title);	    FREE(l->input_field->accept_cs);	    FREE(l->input_field);	}	FREE(l->hightext);	FREE(l->hightext2);	FREE(l);    }    FormList_delete(self->forms);    /*     *  Free the tabs list. - FM     */    if (self->tabs) {	HTTabID * Tab = NULL;	HTList * cur = self->tabs;	while (NULL != (Tab = (HTTabID *)HTList_nextObject(cur))) {	    FREE(Tab->name);	    FREE(Tab);	}	HTList_delete(self->tabs);	self->tabs = NULL;    }    /*     *  Free the hidden links list. - FM     */    if (self->hidden_links) {	char * href = NULL;	HTList * cur = self->hidden_links;	while (NULL != (href = (char *)HTList_nextObject(cur)))	    FREE(href);	HTList_delete(self->hidden_links);	self->hidden_links = NULL;    }    /*     *  Invoke HTAnchor_delete() to free the node_anchor     *  if it is not a destination of other links. - FM     */    if (self->node_anchor) {	HTAnchor_resetUCInfoStage(self->node_anchor, -1, UCT_STAGE_STRUCTURED,				  UCT_SETBY_NONE);	HTAnchor_resetUCInfoStage(self->node_anchor, -1, UCT_STAGE_HTEXT,				  UCT_SETBY_NONE);	if (HTAnchor_delete(self->node_anchor))	    /*	     *  Make sure HTMainAnchor won't point	     *  to an invalid structure. - KW	     */	    HTMainAnchor = NULL;    }    FREE(self);}/*		Display Methods**		---------------*//*	Output a line**	-------------*/PRIVATE int display_line ARGS2(	HTLine *,	line,	HText *,	text){    register int i, j;    char buffer[7];    char *data;    size_t utf_extra = 0;#ifdef USE_COLOR_STYLE    int current_style = 0;#endif    char LastDisplayChar = ' ';    /*     *  Set up the multibyte character buffer,     *  and clear the line to which we will be     *  writing.     */    buffer[0] = buffer[1] = buffer[2] = '\0';    clrtoeol();    /*     *  Add offset, making sure that we do not     *  go over the COLS limit on the display.     */    j = (int)line->offset;    if (j > (int)LYcols - 1)	j = (int)LYcols - 1;#ifdef USE_SLANG    SLsmg_forward (j);    i = j;#else#ifdef USE_COLOR_STYLE    if (line->size == 0)	i = j;    else#endif    for (i = 0; i < j; i++)	addch (' ');#endif /* USE_SLANG */    /*     *  Add the data, making sure that we do not     *  go over the COLS limit on the display.     */    data = line->data;    i++;    while ((i < LYcols) && ((buffer[0] = *data) != '\0')) {	data++;#if defined(USE_COLOR_STYLE) || defined(SLSC)#define CStyle line->styles[current_style]	while (current_style < line->numstyles &&	       i >= CStyle.horizpos + line->offset + 1)	{		(void) LynxChangeStyle (CStyle.style,CStyle.direction,CStyle.previous);		current_style++;	}#endif	switch (buffer[0]) {#ifndef USE_COLOR_STYLE	    case LY_UNDERLINE_START_CHAR:	        if (dump_output_immediately && use_underscore) {		    addch('_');		    i++;		} else {		    start_underline();		}		break;	    case LY_UNDERLINE_END_CHAR:	        if (dump_output_immediately && use_underscore) {		    addch('_');		    i++;		} else {		    stop_underline();		}		break;	    case LY_BOLD_START_CHAR:		start_bold();		break;	    case LY_BOLD_END_CHAR:		stop_bold ();		break;#endif	    case LY_SOFT_HYPHEN:	        if (*data != '\0' ||		    isspace((unsigned char)LastDisplayChar) ||		    LastDisplayChar == '-') {		    /*		     *  Ignore the soft hyphen if it is not the last		     *  character in the line.  Also ignore it if it		     *  first character following the margin, or if it		     *  is preceded by a white character (we loaded 'M'		     *  into LastDisplayChar if it was a multibyte		     *  character) or hyphen, though it should have		     *  been excluded by HText_appendCharacter() or by		     *  split_line() in those cases. - FM		     */		    break;		} else {		    /*		     *  Make it a hard hyphen and fall through. - FM		     */		    buffer[0] = '-';		    i++;		}	    default:		i++;		if (text->T.output_utf8 && !isascii(buffer[0])) {		    if ((*buffer & 0xe0) == 0xc0) {			utf_extra = 1;		    } else if ((*buffer & 0xf0) == 0xe0) {			utf_extra = 2;		    } else if ((*buffer & 0xf8) == 0xf0) {			utf_extra = 3;		    } else if ((*buffer & 0xfc) == 0xf8) {			utf_extra = 4;		    } else if ((*buffer & 0xfe) == 0xfc) {			utf_extra = 5;		    } else {			 /*			  *  Garbage.			  */			utf_extra = 0;		    }		    if (strlen(data) < utf_extra) {			/*			 *  Shouldn't happen.			 */			utf_extra = 0;		    }		    LastDisplayChar = 'M';		}		if (utf_extra) {		    strncpy(&buffer[1], data, utf_extra);		    buffer[utf_extra+1] = '\0';		    addstr(buffer);		    buffer[1] = '\0';		    data += utf_extra;		    utf_extra = 0;		} else if (HTCJK != NOCJK && !isascii(buffer[0])) {		    /*		     *  For CJK strings, by Masanobu Kimura.		     */		    buffer[1] = *data;		    data++;		    addstr(buffer);		    buffer[1] = '\0';		    /*		     *  For now, load 'M' into LastDisplayChar,		     *  but we should check whether it's white		     *  and if so, use ' '.  I don't know if		     *  there actually are white CJK characters,		     *  and we're loading ' ' for multibyte		     *  spacing characters in this code set,		     *  but this will become an issue when		     *  the development code set's multibyte		     *  character handling is used. - FM		     */		    LastDisplayChar = 'M';		} else {		    addstr(buffer);		    LastDisplayChar = buffer[0];		}	} /* end of switch */    } /* end of while */    /*     *  Add the return.     */    addch('\n');#ifndef USE_COLOR_STYLE    stop_underline();    stop_bold();#else    while (current_style < line->numstyles)    {	(void) LynxChangeStyle (CStyle.style, CStyle.direction, CStyle.previous);	current_style++;    }#undef CStyle#endif    return(0);}/*	Output the title line**	---------------------*/PRIVATE void display_title ARGS1(	HText *,	text){    char *title = NULL;    char percent[20];    char *cp = NULL;    unsigned char *tmp = NULL;    int i = 0, j = 0;    /*     *  Make sure we have a text structure. - FM     */    if (!text)	return;    lynx_start_title_color ();#ifdef USE_COLOR_STYLE/* turn the TITLE style on */    LynxChangeStyle(s_title, ABS_ON, 0);#endif /* USE_COLOR_STYLE */    /*     *  Load the title field. - FM     */    StrAllocCopy(title,		 (HTAnchor_title(text->node_anchor) ?		  HTAnchor_title(text->node_anchor) : ""));    /*     *  There shouldn't be any \n in the title field,     *  but if there is, lets kill it now.  Also trim     *  any trailing spaces. - FM     */    if ((cp = strchr(title,'\n')) != NULL)	*cp = '\0';    i = (*title ? (strlen(title) - 1) : 0);    while ((i >= 0) && title[i] == ' ')	title[i--] = '\0';    /*     *  Generate the page indicator (percent) string.     */    if ((text->Lines + 1) > (display_lines)) {	/*	 *  In a small attempt to correct the number of pages counted....	 *    GAB 07-14-94	 *	 *  In a bigger attempt (hope it holds up 8-)....	 *    FM 02-08-95	 */	int total_pages =		(((text->Lines + 1) + (display_lines - 1))/(display_lines));	int start_of_last_page =		((text->Lines + 1) < display_lines) ? 0 :		((text->Lines + 1) - display_lines);	sprintf(percent, " (p%d of %d)",		((text->top_of_screen >= start_of_last_page) ?						 total_pages :	            ((text->top_of_screen + display_lines)/(display_lines))),		total_pages);    } else {	percent[0] = '\0';	/* Null string */    }    /*     *  Generate and display the title string, with page indicator     *  if appropriate, preceded by the toolbar token if appropriate,     *  and truncated if necessary. - FM & KW     */    if (HTCJK != NOCJK) {	if (*title &&	    (tmp = (unsigned char *)calloc(1, (strlen(title) + 1)))) {	    if (kanji_code == EUC) {	        TO_EUC((unsigned char *)title, tmp);	    } else if (kanji_code == SJIS) {	        TO_SJIS((unsigned char *)title, tmp);	    } else {	        for (i = 0, j = 0; title[i]; i++) {		    if (title[i] != '\033') {		        tmp[j++] = title[i];		    }		}		tmp[j] = '\0';	    }	    StrAllocCopy(title, (CONST char *)tmp);	    FREE(tmp);	}    }    move(0, 0);    clrtoeol();    if (text->top_of_screen > 0 && HText_hasToolbar(text)) {	addch('#');    }    i = (LYcols - 1) - strlen(percent) - strlen(title);    if (i > 0) {	move(0, i);    } else {	/*	 *  Note that this truncation is not taking into	 *  account the possibility that multibyte	 *  characters might be present. - FM	 */	title[((LYcols - 2) - strlen(percent))] = '\0';	move(0, 1);    }    addstr(title);    if (percent[0] != '\0')	addstr(percent);    addch('\n');    FREE(title);#ifdef USE_COLOR_STYLE

⌨️ 快捷键说明

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