diff options
| author | Simon Tatham <anakin@pobox.com> | 1999-10-22 13:24:30 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 1999-10-22 13:24:30 +0000 |
| commit | 8022a13d69f8f24c54df96b140bd9eb84b23a5f1 (patch) | |
| tree | 5fe79100c90e3ce0c846f10653cccb40fa1f322a /bk_text.c | |
| parent | 3ea5db22e2af7b4446528de78b4c51bc3cd0559b (diff) | |
| download | halibut-8022a13d69f8f24c54df96b140bd9eb84b23a5f1.zip halibut-8022a13d69f8f24c54df96b140bd9eb84b23a5f1.tar.gz halibut-8022a13d69f8f24c54df96b140bd9eb84b23a5f1.tar.bz2 halibut-8022a13d69f8f24c54df96b140bd9eb84b23a5f1.tar.xz | |
Introduce word types for attributed spaces, so backends can distinguish
between emphasis _like_ _this_ and _like this_
[originally from svn r245]
Diffstat (limited to 'bk_text.c')
| -rw-r--r-- | bk_text.c | 42 |
1 files changed, 36 insertions, 6 deletions
@@ -262,23 +262,42 @@ static void text_rdaddwc(rdstringc *rs, word *text, word *end) { case word_Emph: case word_Code: case word_WeakCode: - if (text->type == word_Emph) + if (text->type == word_Emph && + (text->aux == attr_First || text->aux == attr_Only)) rdaddc(rs, '_'); /* FIXME: configurability */ - else if (text->type == word_Code) + else if (text->type == word_Code && + (text->aux == attr_First || text->aux == attr_Only)) rdaddc(rs, '`'); /* FIXME: configurability */ if (text_convert(text->text, &c)) rdaddsc(rs, c); else text_rdaddwc(rs, text->alt, NULL); sfree(c); - if (text->type == word_Emph) + if (text->type == word_Emph && + (text->aux == attr_Last || text->aux == attr_Only)) rdaddc(rs, '_'); /* FIXME: configurability */ - else if (text->type == word_Code) + else if (text->type == word_Code && + (text->aux == attr_Last || text->aux == attr_Only)) rdaddc(rs, '\''); /* FIXME: configurability */ break; case word_WhiteSpace: + case word_EmphSpace: + case word_CodeSpace: + case word_WkCodeSpace: + if (text->type == word_EmphSpace && + (text->aux == attr_First || text->aux == attr_Only)) + rdaddc(rs, '_'); /* FIXME: configurability */ + else if (text->type == word_CodeSpace && + (text->aux == attr_First || text->aux == attr_Only)) + rdaddc(rs, '`'); /* FIXME: configurability */ rdaddc(rs, ' '); + if (text->type == word_EmphSpace && + (text->aux == attr_Last || text->aux == attr_Only)) + rdaddc(rs, '_'); /* FIXME: configurability */ + else if (text->type == word_CodeSpace && + (text->aux == attr_Last || text->aux == attr_Only)) + rdaddc(rs, '\''); /* FIXME: configurability */ break; } } @@ -308,13 +327,24 @@ static int text_width(word *text) { case word_Emph: case word_Code: case word_WeakCode: - return ((text->type == word_Emph || text->type == word_Code ? 2 : 0) + + return (((text->type == word_Emph || + text->type == word_Code) + ? (text->aux == attr_Only ? 2 : + text->aux == attr_Always ? 0 : 1) + : 0) + (text_convert(text->text, NULL) ? ustrlen(text->text) : text_width_list(text->alt))); case word_WhiteSpace: - return 1; + case word_EmphSpace: + case word_CodeSpace: + case word_WkCodeSpace: + return (((text->type == word_EmphSpace || + text->type == word_CodeSpace) + ? (text->aux == attr_Only ? 2 : + text->aux == attr_Always ? 0 : 1) + : 0) + 1); } return 0; /* should never happen */ } |