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

📄 html.c

📁 飞漫公司的minigui的1.6.8收费增值版本的demon等示例程序
💻 C
📖 第 1 页 / 共 5 页
字号:
{#ifdef USE_TABLES    DwWidget *table;    DwStyle style_attrs, *tstyle, *old_style;    const char *attrbuf;    int border = 0, cellspacing = 1, cellpadding = 2, bgcolor;#endif    Html_push_tag(html, tag, tagsize);    a_Dw_page_add_parbreak(DW_PAGE (html->dw), 0,                          html->stack[(html)->stack_top].style);#ifdef USE_TABLES    if ((attrbuf = Html_get_attr(html, tag, tagsize, "border")))        border = isdigit(attrbuf[0]) ? strtol (attrbuf, NULL, 10) : 1;    if ((attrbuf = Html_get_attr(html, tag, tagsize, "cellspacing")))        cellspacing = strtol (attrbuf, NULL, 10);    if ((attrbuf = Html_get_attr(html, tag, tagsize, "cellpadding")))        cellpadding = strtol (attrbuf, NULL, 10);    /* The style for the table */    style_attrs = *html->stack[html->stack_top].style;    /* When dillo was started with the --debug-rendering option, there     * is always a border around the table. */    if (dillo_dbg_rendering)        a_Dw_style_box_set_val (&style_attrs.border_width, MIN (border, 1));    else        a_Dw_style_box_set_val (&style_attrs.border_width, border);    a_Dw_style_box_set_border_color (&style_attrs,        a_Dw_style_shaded_color_new            (html->stack[html->stack_top].current_bg_color, html->bw->main_window));    a_Dw_style_box_set_border_style (&style_attrs, DW_STYLE_BORDER_OUTSET);    style_attrs.border_spacing = cellspacing;    if ((attrbuf = Html_get_attr(html, tag, tagsize, "width")))        style_attrs.width = Html_parse_length (html, attrbuf);    if ((attrbuf = Html_get_attr(html, tag, tagsize, "align"))) {        if (strcasecmp (attrbuf, "left") == 0)            style_attrs.text_align = DW_STYLE_TEXT_ALIGN_LEFT;        else if (strcasecmp (attrbuf, "right") == 0)            style_attrs.text_align = DW_STYLE_TEXT_ALIGN_RIGHT;        else if (strcasecmp (attrbuf, "center") == 0)            style_attrs.text_align = DW_STYLE_TEXT_ALIGN_CENTER;    }    if (!prefs.force_my_colors &&            (attrbuf = Html_get_attr(html, tag, tagsize, "bgcolor"))) {        bgcolor = Html_color_parse(html, attrbuf, -1);        if (bgcolor != -1) {            if (bgcolor == 0xffffff && !prefs.allow_white_bg)                bgcolor = prefs.bg_color;            html->stack[html->stack_top].current_bg_color = bgcolor;            style_attrs.background_color =                a_Dw_style_color_new (bgcolor, html->bw->main_window);        }    }    tstyle = a_Dw_style_new (&style_attrs, html->bw->main_window);    /* The style for the cells */    style_attrs = *html->stack[html->stack_top].style;    /* When dillo was started with the --debug-rendering option, there        * is always a border around the cells. */    if (dillo_dbg_rendering)        a_Dw_style_box_set_val (&style_attrs.border_width, 1);    else        a_Dw_style_box_set_val (&style_attrs.border_width, border ? 1 : 0);    a_Dw_style_box_set_val (&style_attrs.padding, cellpadding);    a_Dw_style_box_set_border_color (&style_attrs, tstyle->border_color.top);    a_Dw_style_box_set_border_style (&style_attrs, DW_STYLE_BORDER_INSET);    old_style = html->stack[html->stack_top].table_cell_style;    html->stack[html->stack_top].table_cell_style =        a_Dw_style_new (&style_attrs, html->bw->main_window);    if (old_style)        a_Dw_style_unref (old_style);    table = a_Dw_table_new ();    a_Dw_page_add_widget (DW_PAGE (html->dw), table, tstyle);    a_Dw_style_unref (tstyle);    html->stack[html->stack_top].table_mode = DILLO_HTML_TABLE_MODE_TOP;    html->stack[html->stack_top].cell_text_align_set = FALSE;    html->stack[html->stack_top].table = table;#endif}/* * used by <TD> and <TH> */static void Html_tag_open_table_cell(DilloHtml *html, char *tag, int tagsize,                                     DwStyleTextAlignType text_align){#ifdef USE_TABLES    DwWidget *col_page;    int colspan = 1, rowspan = 1;    const char *attrbuf;    DwStyle style_attrs, *style, *old_style;    guint32 bgcolor;    gboolean new_style;    switch (html->stack[html->stack_top].table_mode) {    case DILLO_HTML_TABLE_MODE_NONE:        MSG_HTML("<td> or <th> outside <table>\n");        return;    case DILLO_HTML_TABLE_MODE_TOP:        MSG_HTML("<td> or <th> outside <tr>\n");        /* a_Dw_table_add_cell takes care that dillo does not crash. */        /* continues */    case DILLO_HTML_TABLE_MODE_TR:    case DILLO_HTML_TABLE_MODE_TD:        /* todo: check errors? */        if ((attrbuf = Html_get_attr(html, tag, tagsize, "colspan")))            colspan = strtol (attrbuf, NULL, 10);        if ((attrbuf = Html_get_attr(html, tag, tagsize, "rowspan")))            rowspan = strtol (attrbuf, NULL, 10);        /* text style */        old_style = html->stack[html->stack_top].style;        style_attrs = *old_style;        if (!html->stack[html->stack_top].cell_text_align_set)            style_attrs.text_align = text_align;        if (Html_get_attr(html, tag, tagsize, "nowrap"))            style_attrs.white_space = DW_STYLE_WHITE_SPACE_NOWRAP;        else            style_attrs.white_space = DW_STYLE_WHITE_SPACE_NORMAL;        html->stack[html->stack_top].style =            a_Dw_style_new (&style_attrs, html->bw->main_window);        a_Dw_style_unref (old_style);        Html_tag_set_align_attr (html, tag, tagsize);        /* cell style */        style_attrs = *html->stack[html->stack_top].table_cell_style;        new_style = FALSE;        if ((attrbuf = Html_get_attr(html, tag, tagsize, "width"))) {            style_attrs.width = Html_parse_length (html, attrbuf);            new_style = TRUE;        }        if (Html_tag_set_valign_attr (html, tag, tagsize, &style_attrs))            new_style = TRUE;        if (!prefs.force_my_colors &&                (attrbuf = Html_get_attr(html, tag, tagsize, "bgcolor"))) {            bgcolor = Html_color_parse(html, attrbuf, -1);            if (bgcolor != -1) {                if (bgcolor == 0xffffff && !prefs.allow_white_bg)                    bgcolor = prefs.bg_color;                new_style = TRUE;                style_attrs.background_color =                    a_Dw_style_color_new (bgcolor, html->bw->main_window);                html->stack[html->stack_top].current_bg_color = bgcolor;            }        }        if (html->stack[html->stack_top].style->text_align                == DW_STYLE_TEXT_ALIGN_STRING)            col_page = a_Dw_table_cell_new (a_Dw_table_get_cell_ref                            (DW_TABLE (html->stack[html->stack_top].table)));        else            col_page = a_Dw_page_new ();        if (new_style) {            style = a_Dw_style_new (&style_attrs, html->bw->main_window);            a_Dw_widget_set_style (col_page, style);            a_Dw_style_unref (style);        }        else            a_Dw_widget_set_style (col_page,                                    html->stack[html->stack_top].table_cell_style);        a_Dw_table_add_cell (DW_TABLE (html->stack[html->stack_top].table),                        col_page, colspan, rowspan);        html->stack[html->stack_top].page = html->dw = col_page;        /* Handle it when the user clicks on a link */        Html_connect_signals(html, G_OBJECT(col_page));        break;    default:        /* compiler happiness */        break;    }    html->stack[html->stack_top].table_mode = DILLO_HTML_TABLE_MODE_TD;#endif}/* * <TD> */static void Html_tag_open_td(DilloHtml *html, char *tag, int tagsize){    Html_cleanup_tag(html, "td>");    Html_cleanup_tag(html, "th>");    Html_push_tag(html, tag, tagsize);    Html_tag_open_table_cell (html, tag, tagsize, DW_STYLE_TEXT_ALIGN_LEFT);}/* * <TH> */static void Html_tag_open_th(DilloHtml *html, char *tag, int tagsize){    Html_cleanup_tag(html, "td>");    Html_cleanup_tag(html, "th>");    Html_push_tag(html, tag, tagsize);    Html_set_top_font(html, NULL, 0, 1, 1);    Html_tag_open_table_cell (html, tag, tagsize, DW_STYLE_TEXT_ALIGN_CENTER);}/* * <TR> */static void Html_tag_open_tr(DilloHtml *html, char *tag, int tagsize){    const char *attrbuf;    DwStyle style_attrs, *style, *old_style;    guint32 bgcolor;    Html_cleanup_tag(html, "td>");    Html_cleanup_tag(html, "th>");    Html_cleanup_tag(html, "tr>");    Html_push_tag(html, tag, tagsize);#ifdef USE_TABLES    switch (html->stack[html->stack_top].table_mode) {    case DILLO_HTML_TABLE_MODE_NONE:        _MSG("Invalid HTML syntax: <tr> outside <table>\n");        return;    case DILLO_HTML_TABLE_MODE_TOP:    case DILLO_HTML_TABLE_MODE_TR:    case DILLO_HTML_TABLE_MODE_TD:        style = NULL;        if (!prefs.force_my_colors &&                (attrbuf = Html_get_attr(html, tag, tagsize, "bgcolor"))) {            bgcolor = Html_color_parse(html, attrbuf, -1);            if (bgcolor != -1) {                if (bgcolor == 0xffffff && !prefs.allow_white_bg)                    bgcolor = prefs.bg_color;                style_attrs = *html->stack[html->stack_top].style;                style_attrs.background_color =                    a_Dw_style_color_new (bgcolor, html->bw->main_window);                style =                    a_Dw_style_new (&style_attrs, html->bw->main_window);                html->stack[html->stack_top].current_bg_color = bgcolor;            }        }        //printf ("style: %p\n", style);        a_Dw_table_add_row (DW_TABLE (html->stack[html->stack_top].table), style);        if (style)            a_Dw_style_unref (style);        if (Html_get_attr (html, tag, tagsize, "align")) {            html->stack[html->stack_top].cell_text_align_set = TRUE;            Html_tag_set_align_attr (html, tag, tagsize);        }        style_attrs = *html->stack[html->stack_top].table_cell_style;        if (Html_tag_set_valign_attr (html, tag, tagsize, &style_attrs)) {            old_style = html->stack[html->stack_top].table_cell_style;            html->stack[html->stack_top].table_cell_style =                a_Dw_style_new (&style_attrs, html->bw->main_window);            a_Dw_style_unref (old_style);        }        break;    default:        break;    }    html->stack[html->stack_top].table_mode = DILLO_HTML_TABLE_MODE_TR;#else    a_Dw_page_add_parbreak (DW_PAGE (html->dw), 0,                          html->stack[(html)->stack_top].style);#endif}/* * <FRAME>, <IFRAME> * todo: This is just a temporary fix while real frame support *       isn't finished. Imitates lynx/w3m's frames. */static void Html_tag_open_frame (DilloHtml *html, char *tag, int tagsize){    const char *attrbuf;    char *src;    DilloUrl *url;    DwPage *page;    DwStyle style_attrs, *link_style;    DwWidget *bullet;#if 0    char *buf;    int buf_size;#endif    page = DW_PAGE(html->dw);    if (!(attrbuf = Html_get_attr(html, tag, tagsize, "src")) )        return;    if (!(url = Html_url_new(html, attrbuf, NULL, 0, 0, 0, 0)))        return;    src = g_strdup(attrbuf);    style_attrs = *(html->stack[html->stack_top].style);    if (a_Url_does_visited (url))  /* visited frame */        style_attrs.color = a_Dw_style_color_new                (html->linkblock->visited_color, html->bw->main_window);    else                                /* unvisited frame */        style_attrs.color = a_Dw_style_color_new                (html->linkblock->link_color, html->bw->main_window);    style_attrs.text_decoration |= DW_STYLE_TEXT_DECORATION_UNDERLINE;    style_attrs.x_link = Html_set_new_link(html, &url);    link_style = a_Dw_style_new (&style_attrs, html->bw->main_window);    a_Dw_page_add_parbreak(page, 5, html->stack[(html)->stack_top].style);    /* The bullet will be assigned the current list style, which should     * be "disc" by default, but may in very weird pages be different.     * Anyway, there should be no harm. */    bullet = a_Dw_bullet_new();    a_Dw_page_add_widget(page, bullet, html->stack[html->stack_top].style);    a_Dw_page_add_space(page, html->stack[html->stack_top].style);    if (tolower(tag[1]) == 'i') {        /* IFRAME usually comes with very long advertising/spying URLS,         * to not break rendering we will force name="IFRAME" */        a_Dw_page_add_text(page, g_strdup("IFRAME"), link_style);    }    else {        /* FRAME:         * If 'name' tag is present use it, if not use 'src' value */        if ( !(attrbuf = Html_get_attr(html, tag, tagsize, "name")) ) {            a_Dw_page_add_text(page, g_strdup(src), link_style);        }        else {            a_Dw_page_add_text(page, g_strdup(attrbuf), link_style);        }   }    a_Dw_page_add_parbreak(page, 5, html->stack[(html)->stack_top].style);    a_Dw_style_unref (link_style);    g_free (src);}/* * <FRAMESET> * todo: This is just a temporary fix while real frame support *       isn't finished. Imitates lynx/w3m's frames. */static void Html_tag_open_frameset (DilloHtml *html, char *tag, int tagsize){    Html_par_push_tag (html, tag, tagsize);    a_Dw_page_add_text(DW_PAGE(html->dw), g_strdup("--FRAME--"),                      html->stack[html->stack_top].style);    Html_add_indented(html, 40, 0, 5);}/* * <H1> | <H2> | <H3> | <H4> | <H5> | <H6> */static void Html_tag_open_h(DilloHtml *html, char *tag, int tagsize){    Html_par_push_tag(html, tag, tagsize);    /* todo: combining these two would be slightly faster */    Html_set_top_font(html, prefs.vw_fontname,                        Html_level_to_fontsize(FontSizesNum - (tag[2] - '0')),                        1, 3);    Html_tag_set_align_attr (html, tag, tagsize);    /* First finalize unclosed H tags (we test if already named anyway) */#if 0    a_Menu_pagemarks_set_text(html->bw, html->Stash->str);    a_Menu_pagemarks_add(html->bw, DW_PAGE (html->dw),                        html->stack[html->stack_top].style, (tag[2] - '0'));#endif    Html_stash_init(html);    htm

⌨️ 快捷键说明

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