From 8022a13d69f8f24c54df96b140bd9eb84b23a5f1 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 22 Oct 1999 13:24:30 +0000 Subject: Introduce word types for attributed spaces, so backends can distinguish between emphasis _like_ _this_ and _like this_ [originally from svn r245] --- bk_text.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'bk_text.c') diff --git a/bk_text.c b/bk_text.c index 786c126..2b58c06 100644 --- a/bk_text.c +++ b/bk_text.c @@ -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 */ } -- cgit v1.1