From 57a08b52db8fac9b87225687720a19af12996974 Mon Sep 17 00:00:00 2001 From: Dai Sato Date: Wed, 23 May 2007 13:07:44 +0000 Subject: [w3m-dev 04236] expand display_ins_del to select a type of fontify. --- file.c | 209 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 181 insertions(+), 28 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index ca920bd..87ed309 100644 --- a/file.c +++ b/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.252 2007/05/23 12:26:56 inu Exp $ */ +/* $Id: file.c,v 1.253 2007/05/23 13:07:44 inu Exp $ */ #include "fm.h" #include #include "myctype.h" @@ -2444,6 +2444,8 @@ set_breakpoint(struct readbuffer *obuf, int tag_length) obuf->bp.in_bold = obuf->in_bold; obuf->bp.in_italic = obuf->in_italic; obuf->bp.in_under = obuf->in_under; + obuf->bp.in_strike = obuf->in_strike; + obuf->bp.in_ins = obuf->in_ins; obuf->bp.nobr_level = obuf->nobr_level; obuf->bp.prev_ctype = obuf->prev_ctype; obuf->bp.init_flag = 0; @@ -2459,6 +2461,8 @@ back_to_breakpoint(struct readbuffer *obuf) obuf->in_bold = obuf->bp.in_bold; obuf->in_italic = obuf->bp.in_italic; obuf->in_under = obuf->bp.in_under; + obuf->in_strike = obuf->bp.in_strike; + obuf->in_ins = obuf->bp.in_ins; obuf->prev_ctype = obuf->bp.prev_ctype; obuf->pos = obuf->bp.pos; obuf->top_margin = obuf->bp.top_margin; @@ -2481,6 +2485,7 @@ append_tags(struct readbuffer *obuf) case HTML_B: case HTML_U: case HTML_I: + case HTML_S: push_link(obuf->tag_stack[i]->cmd, obuf->line->length, obuf->pos); break; } @@ -2695,7 +2700,8 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, FILE *f = h_env->f; Str line = obuf->line, pass = NULL; char *hidden_anchor = NULL, *hidden_img = NULL, *hidden_bold = NULL, - *hidden_under = NULL, *hidden_italic = NULL, *hidden = NULL; + *hidden_under = NULL, *hidden_italic = NULL, *hidden_strike = NULL, + *hidden_ins = NULL, *hidden = NULL; #ifdef DEBUG if (w3m_debug) { @@ -2745,6 +2751,18 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, hidden = hidden_under; } } + if (obuf->in_strike) { + if ((hidden_strike = has_hidden_link(obuf, HTML_S)) != NULL) { + if (!hidden || hidden_strike < hidden) + hidden = hidden_strike; + } + } + if (obuf->in_ins) { + if ((hidden_ins = has_hidden_link(obuf, HTML_INS)) != NULL) { + if (!hidden || hidden_ins < hidden) + hidden = hidden_ins; + } + } if (hidden) { pass = Strnew_charp(hidden); Strshrink(line, line->ptr + line->length - hidden); @@ -2772,6 +2790,10 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, Strcat_charp(line, ""); if (obuf->in_under && !hidden_under) Strcat_charp(line, ""); + if (obuf->in_strike && !hidden_strike) + Strcat_charp(line, ""); + if (obuf->in_ins && !hidden_ins) + Strcat_charp(line, ""); if (obuf->top_margin > 0) { int i; @@ -2978,6 +3000,10 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent, push_tag(obuf, "", HTML_I); if (!hidden_under && obuf->in_under) push_tag(obuf, "", HTML_U); + if (!hidden_strike && obuf->in_strike) + push_tag(obuf, "", HTML_S); + if (!hidden_ins && obuf->in_ins) + push_tag(obuf, "", HTML_INS); } void @@ -3092,6 +3118,10 @@ save_fonteffect(struct html_feed_environ *h_env, struct readbuffer *obuf) push_tag(obuf, "", HTML_N_I); if (obuf->in_under) push_tag(obuf, "", HTML_N_U); + if (obuf->in_strike) + push_tag(obuf, "", HTML_N_S); + if (obuf->in_ins) + push_tag(obuf, "", HTML_N_INS); bzero(obuf->fontstat, FONTSTAT_SIZE); } @@ -3109,6 +3139,10 @@ restore_fonteffect(struct html_feed_environ *h_env, struct readbuffer *obuf) push_tag(obuf, "", HTML_I); if (obuf->in_under) push_tag(obuf, "", HTML_U); + if (obuf->in_strike) + push_tag(obuf, "", HTML_S); + if (obuf->in_ins) + push_tag(obuf, "", HTML_INS); } static Str @@ -4985,36 +5019,114 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) case HTML_AREA: return 0; case HTML_DEL: - if (displayInsDel) - HTMLlineproc1("[DEL:", h_env); - else + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: obuf->flag |= RB_DEL; + break; + case DISPLAY_INS_DEL_NORMAL: + HTMLlineproc1("[DEL:", h_env); + break; + case DISPLAY_INS_DEL_FONTIFY: + obuf->in_strike++; + if (obuf->in_strike == 1) { + push_tag(obuf, "", HTML_S); + } + break; + } return 1; case HTML_N_DEL: - if (displayInsDel) - HTMLlineproc1(":DEL]", h_env); - else + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: obuf->flag &= ~RB_DEL; + break; + case DISPLAY_INS_DEL_NORMAL: + HTMLlineproc1(":DEL]", h_env); + case DISPLAY_INS_DEL_FONTIFY: + if (obuf->in_strike == 0) + return 1; + if (obuf->in_strike == 1 && close_effect0(obuf, HTML_S)) + obuf->in_strike = 0; + if (obuf->in_strike > 0) { + obuf->in_strike--; + if (obuf->in_strike == 0) { + push_tag(obuf, "", HTML_N_S); + } + } + break; + } return 1; case HTML_S: - if (displayInsDel) - HTMLlineproc1("[S:", h_env); - else + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: obuf->flag |= RB_S; + break; + case DISPLAY_INS_DEL_NORMAL: + HTMLlineproc1("[S:", h_env); + break; + case DISPLAY_INS_DEL_FONTIFY: + obuf->in_strike++; + if (obuf->in_strike == 1) { + push_tag(obuf, "", HTML_S); + } + break; + } return 1; case HTML_N_S: - if (displayInsDel) - HTMLlineproc1(":S]", h_env); - else + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: obuf->flag &= ~RB_S; + break; + case DISPLAY_INS_DEL_NORMAL: + HTMLlineproc1(":S]", h_env); + break; + case DISPLAY_INS_DEL_FONTIFY: + if (obuf->in_strike == 0) + return 1; + if (obuf->in_strike == 1 && close_effect0(obuf, HTML_S)) + obuf->in_strike = 0; + if (obuf->in_strike > 0) { + obuf->in_strike--; + if (obuf->in_strike == 0) { + push_tag(obuf, "", HTML_N_S); + } + } + } return 1; case HTML_INS: - if (displayInsDel) + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: + break; + case DISPLAY_INS_DEL_NORMAL: HTMLlineproc1("[INS:", h_env); + break; + case DISPLAY_INS_DEL_FONTIFY: + obuf->in_ins++; + if (obuf->in_ins == 1) { + push_tag(obuf, "", HTML_INS); + } + break; + } return 1; case HTML_N_INS: - if (displayInsDel) + switch (displayInsDel) { + case DISPLAY_INS_DEL_SIMPLE: + break; + case DISPLAY_INS_DEL_NORMAL: HTMLlineproc1(":INS]", h_env); + break; + case DISPLAY_INS_DEL_FONTIFY: + if (obuf->in_ins == 0) + return 1; + if (obuf->in_ins == 1 && close_effect0(obuf, HTML_INS)) + obuf->in_ins = 0; + if (obuf->in_ins > 0) { + obuf->in_ins--; + if (obuf->in_ins == 0) { + push_tag(obuf, "", HTML_N_INS); + } + } + break; + } return 1; case HTML_SUP: if (!(obuf->flag & (RB_DEL | RB_S))) @@ -5109,6 +5221,25 @@ textlist_feed() return NULL; } +ex_efct(int ex) +{ + int effect = 0; + + if (! ex) + return 0; + + if (ex & PE_EX_ITALIC) + effect |= PE_EX_ITALIC_E; + + if (ex & PE_EX_INSERT) + effect |= PE_EX_INSERT_E; + + if (ex & PE_EX_STRIKE) + effect |= PE_EX_STRIKE_E; + + return effect; +} + static void HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) { @@ -5189,7 +5320,7 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) while (str < endp) { PSIZE; mode = get_mctype(str); - if ((effect | ex_effect) & PC_SYMBOL && *str != '<') { + if ((effect | ex_efct(ex_effect)) & PC_SYMBOL && *str != '<') { #ifdef USE_M17N char **buf = set_symbol(symbol_width0); int len; @@ -5197,16 +5328,16 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) p = buf[(int)symbol]; len = get_mclen(p); mode = get_mctype(p); - PPUSH(mode | effect | ex_effect, *(p++)); + PPUSH(mode | effect | ex_efct(ex_effect), *(p++)); if (--len) { mode = (mode & ~PC_WCHAR1) | PC_WCHAR2; while (len--) { PSIZE; - PPUSH(mode | effect | ex_effect, *(p++)); + PPUSH(mode | effect | ex_efct(ex_effect), *(p++)); } } #else - PPUSH(PC_ASCII | effect | ex_effect, SYMBOL_BASE + symbol); + PPUSH(PC_ASCII | effect | ex_efct(ex_effect), SYMBOL_BASE + symbol); #endif str += symbol_width; } @@ -5215,12 +5346,12 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) #else else if (mode == PC_CTRL || IS_INTSPACE(*str)) { #endif - PPUSH(PC_ASCII | effect | ex_effect, ' '); + PPUSH(PC_ASCII | effect | ex_efct(ex_effect), ' '); str++; } #ifdef USE_M17N else if (mode & PC_UNKNOWN) { - PPUSH(PC_ASCII | effect | ex_effect, ' '); + PPUSH(PC_ASCII | effect | ex_efct(ex_effect), ' '); str += get_mclen(str); } #endif @@ -5228,13 +5359,13 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) #ifdef USE_M17N int len = get_mclen(str); #endif - PPUSH(mode | effect | ex_effect, *(str++)); + PPUSH(mode | effect | ex_efct(ex_effect), *(str++)); #ifdef USE_M17N if (--len) { mode = (mode & ~PC_WCHAR1) | PC_WCHAR2; while (len--) { PSIZE; - PPUSH(mode | effect | ex_effect, *(str++)); + PPUSH(mode | effect | ex_efct(ex_effect), *(str++)); } } #endif @@ -5252,12 +5383,12 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) #else if (mode == PC_CTRL || IS_INTSPACE(*str)) { #endif - PPUSH(PC_ASCII | effect | ex_effect, ' '); + PPUSH(PC_ASCII | effect | ex_efct(ex_effect), ' '); p++; } #ifdef USE_M17N else if (mode & PC_UNKNOWN) { - PPUSH(PC_ASCII | effect | ex_effect, ' '); + PPUSH(PC_ASCII | effect | ex_efct(ex_effect), ' '); p += get_mclen(p); } #endif @@ -5265,13 +5396,13 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) #ifdef USE_M17N int len = get_mclen(p); #endif - PPUSH(mode | effect | ex_effect, *(p++)); + PPUSH(mode | effect | ex_efct(ex_effect), *(p++)); #ifdef USE_M17N if (--len) { mode = (mode & ~PC_WCHAR1) | PC_WCHAR2; while (len--) { PSIZE; - PPUSH(mode | effect | ex_effect, *(p++)); + PPUSH(mode | effect | ex_efct(ex_effect), *(p++)); } } #endif @@ -5296,12 +5427,24 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) case HTML_N_I: ex_effect &= ~PE_EX_ITALIC; break; + case HTML_INS: + ex_effect |= PE_EX_INSERT; + break; + case HTML_N_INS: + ex_effect &= ~PE_EX_INSERT; + break; case HTML_U: effect |= PE_UNDER; break; case HTML_N_U: effect &= ~PE_UNDER; break; + case HTML_S: + ex_effect |= PE_EX_STRIKE; + break; + case HTML_N_S: + ex_effect &= ~PE_EX_STRIKE; + break; case HTML_A: if (renderFrameSet && parsedtag_get_value(tag, ATTR_FRAMENAME, &p)) { @@ -6554,6 +6697,8 @@ init_henv(struct html_feed_environ *h_env, struct readbuffer *obuf, obuf->in_bold = 0; obuf->in_italic = 0; obuf->in_under = 0; + obuf->in_strike = 0; + obuf->in_ins = 0; obuf->prev_ctype = PC_ASCII; obuf->tag_sp = 0; obuf->fontstat_sp = 0; @@ -6596,6 +6741,14 @@ completeHTMLstream(struct html_feed_environ *h_env, struct readbuffer *obuf) push_tag(obuf, "", HTML_N_U); obuf->in_under = 0; } + if (obuf->in_strike) { + push_tag(obuf, "", HTML_N_S); + obuf->in_strike = 0; + } + if (obuf->in_ins) { + push_tag(obuf, "", HTML_N_INS); + obuf->in_ins = 0; + } if (obuf->flag & RB_INTXTA) HTMLlineproc1("", h_env); /* for unbalanced select tag */ -- cgit v1.2.3