Exemple #1
0
void HTMLView::HandleHTMLTag( char* tag ) {

	char* p;
	bool off = false;
	bool handled = false;

	// Trim all the whitespace off the left side of the tag
	p = tag;
	while( *p == ' ' )
		++p;
		
	// return if there is nothing left
	if( !(*p) )
		return;

	// is this an end tag?
	if( *p == '/' ) {
		off = true;

		// make sure there is something after the slash
		if( !(*(++p)) )
			return;		
	}
		
	// starts with 'b' (body, bold, or line break)
	if( (*p == 'B') || (*p == 'b') ) {
		
		// if it is just a b (for bold)
		if( !(*(p+1)) || *(p+1) == ' ' ) {
			SetFontAttribute( B_BOLD_FACE, !off );
			handled = true;
		}

		// if it is a body tag		
		else if( FirstWordMatch( p, "body" ) )
			handled = true;
			
		// if it is a line break		
		else if( FirstWordMatch( p, "br" ) ) {
			InsertHTMLText( "\n" );
			handled = true;
		}
	}
		
	// starts with 'i' (probably italic)
	else if( (*p == 'I') || (*p == 'i') ) {
		if( !(*(p+1)) || *(p+1) == ' ' ) {
			SetFontAttribute( B_ITALIC_FACE, !off );
			handled = true;
		}
	}
	
	// starts with 'f' (probably <FONT> )
	else if( (*p == 'F') || (*p == 'f') ) {
		if( FirstWordMatch( p, "font" ) ) {
			if( !off && showFontColorSizes )
				DoFontTagAttributes( p );
			else {
				if( !fontStack.IsEmpty() ) {
					fontInfo savedInfo;
					fontStack.Pop( savedInfo );
					SetFontColor( savedInfo.color );
					SetFontSize( savedInfo.size );
				} else
					ResetFontToBase();
			}			
			handled = true;
		}
	}
	
	// starts with 'a' (probably <a href="..."> )
	else if( (*p == 'A') || (*p == 'a') ) {
		if( FirstWordMatch( p, "a" ) ) {
			if( !off )
				DoLinkAttributes( p );
			else {
				// Insert the URL (kind of cheap, but it works for now)
				InsertHTMLText( " [" );
				InsertHTMLText( URL );
				InsertHTMLText( "]" );
				URL[0] = '\0';
				urlOn = false;
			}
			handled = true;
		}
	}	
	
	// starts with 'h' (probably <HTML> )
	else if( (*p == 'H') || (*p == 'h') ) {
		if( FirstWordMatch( p, "html" ) )
			handled = true;
	}
	
	// starts with 'u' (underline)
	else if( (*p == 'U') || (*p == 'u') ) {
		if( !(*(p+1)) || *(p+1) == ' ' )
			handled = true;
	}
	
	// starts with 's' (<sub> or <sup> )
	else if( (*p == 'S') || (*p == 's') ) {
		if( FirstWordMatch(p,"sub") || FirstWordMatch(p,"sup") )
			handled = true;
	}	
	
	// if it wasn't handled, it was probably some silly user
	//   saying stuff like <this>, so print it out raw
	if( !handled ) {
		InsertHTMLText( "<" );
		InsertHTMLText( tag );
		InsertHTMLText( ">" );
	}
}
Exemple #2
0
static int ReadICValue (Xi18n i18n_core,
                        CARD16 icvalue_id,
                        int value_length,
                        void *p,
                        XICAttribute *value_ret,
                        CARD16 *number_ret,
                        int need_swap,
                        void **value_buf)
{
    XICAttr *ic_attr = i18n_core->address.xic_attr;
    int i;

    *number_ret = (CARD16) 0;

    for (i = 0;  i < i18n_core->address.ic_attr_num;  i++, ic_attr++)
    {
        if (ic_attr->attribute_id == icvalue_id)
            break;
        /*endif*/
    }
    /*endfor*/
    switch (ic_attr->type)
    {
    case XimType_NEST:
        {
            int total_length = 0;
            CARD16 attribute_ID;
            INT16 attribute_length;
            unsigned char *p1 = (unsigned char *) p;
            CARD16 ic_len = 0;
            CARD16 number;
            FrameMgr fm;
            extern XimFrameRec attr_head_fr[];

            while (total_length < value_length)
            {
                fm = FrameMgrInit (attr_head_fr, (char *) p1, need_swap);
                /* get data */
                FrameMgrGetToken (fm, attribute_ID);
                FrameMgrGetToken (fm, attribute_length);
                FrameMgrFree (fm);
                p1 += sizeof (CARD16)*2;
                ReadICValue (i18n_core,
                             attribute_ID,
                             attribute_length,
                             p1,
                             (value_ret + ic_len),
                             &number,
                             need_swap,
                             value_buf);
                ic_len++;
                *number_ret += number;
                p1 += attribute_length;
                p1 += IMPAD (attribute_length);
                total_length += (CARD16) sizeof(CARD16)*2
                                + (INT16) attribute_length
                                + IMPAD (attribute_length);
            }
	    /*endwhile*/
            return ic_len;
        }

    case XimType_CARD8:
    case XimType_CARD16:
    case XimType_CARD32:
    case XimType_Window:
        SetCardAttribute (value_ret, p, ic_attr, value_length, need_swap, value_buf);
        *number_ret = (CARD16) 1;
        return *number_ret;

    case XimType_XFontSet:
        SetFontAttribute (value_ret, p, ic_attr, value_length, need_swap, value_buf);
        *number_ret = (CARD16) 1;
        return *number_ret;

    case XimType_XRectangle:
        SetRectAttribute (value_ret, p, ic_attr, value_length, need_swap, value_buf);
        *number_ret = (CARD16) 1;
        return *number_ret;

    case XimType_XPoint:
        SetPointAttribute(value_ret, p, ic_attr, value_length, need_swap, value_buf);
        *number_ret = (CARD16) 1;
        return *number_ret;

#if 0
    case XimType_XIMHotKeyTriggers:
        SetHotKeyAttribute (value_ret, p, ic_attr, value_length, need_swap, value_buf);
	*number_ret = (CARD16) 1;
	return *number_ret;
#endif
    }
    /*endswitch*/
    return 0;
}