diff options
| author | Simon Tatham <anakin@pobox.com> | 2002-08-12 11:24:59 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2002-08-12 11:24:59 +0000 |
| commit | ae1e715076a573ee5e60a8e791ba80639f819e99 (patch) | |
| tree | 41db5b39ed44907a335547dc7aa316a2e692bd66 /bk_text.c | |
| parent | 90343b1b95cb61f6a87b912b3c5b544e7d703a23 (diff) | |
| download | halibut-ae1e715076a573ee5e60a8e791ba80639f819e99.zip halibut-ae1e715076a573ee5e60a8e791ba80639f819e99.tar.gz halibut-ae1e715076a573ee5e60a8e791ba80639f819e99.tar.bz2 halibut-ae1e715076a573ee5e60a8e791ba80639f819e99.tar.xz | |
Add configurability for the suffix after the section number and
before the section title (the ": " in "Section 1: Introduction").
[originally from svn r1838]
Diffstat (limited to 'bk_text.c')
| -rw-r--r-- | bk_text.c | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -12,6 +12,7 @@ typedef struct { alignment align; int just_numbers; wchar_t underline; + wchar_t *number_suffix; } alignstruct; typedef struct { @@ -64,11 +65,13 @@ static textconfig text_configure(paragraph *source) { ret.atitle.underline = L'='; ret.achapter.align = LEFT; ret.achapter.just_numbers = FALSE; + ret.achapter.number_suffix = ustrdup(L": "); ret.achapter.underline = L'-'; ret.nasect = 1; ret.asect = mknewa(alignstruct, ret.nasect); ret.asect[0].align = LEFTPLUS; ret.asect[0].just_numbers = TRUE; + ret.asect[0].number_suffix = ustrdup(L" "); ret.asect[0].underline = L'\0'; ret.include_version_id = TRUE; ret.indent_preambles = FALSE; @@ -92,6 +95,8 @@ static textconfig text_configure(paragraph *source) { ret.achapter.underline = *uadv(source->keyword); } else if (!ustricmp(source->keyword, L"text-chapter-numeric")) { ret.achapter.just_numbers = utob(uadv(source->keyword)); + } else if (!ustricmp(source->keyword, L"text-chapter-suffix")) { + ret.achapter.number_suffix = uadv(source->keyword); } else if (!ustricmp(source->keyword, L"text-section-align")) { wchar_t *p = uadv(source->keyword); int n = 0; @@ -137,6 +142,21 @@ static textconfig text_configure(paragraph *source) { ret.nasect = n+1; } ret.asect[n].just_numbers = utob(p); + } else if (!ustricmp(source->keyword, L"text-section-suffix")) { + wchar_t *p = uadv(source->keyword); + int n = 0; + if (uisdigit(*p)) { + n = utoi(p); + p = uadv(p); + } + if (n >= ret.nasect) { + int i; + ret.asect = resize(ret.asect, n+1); + for (i = ret.nasect; i <= n; i++) + ret.asect[i] = ret.asect[ret.nasect-1]; + ret.nasect = n+1; + } + ret.asect[n].number_suffix = p; } else if (!ustricmp(source->keyword, L"text-title-align")) { ret.atitle.align = utoalign(uadv(source->keyword)); } else if (!ustricmp(source->keyword, L"text-title-underline")) { @@ -464,11 +484,19 @@ static void text_heading(FILE *fp, word *tprefix, word *nprefix, word *text, wrappedline *wrapping, *p; if (align.just_numbers && nprefix) { + char *c; text_rdaddwc(&t, nprefix, NULL); - rdaddc(&t, ' '); /* FIXME: as below */ + if (text_convert(align.number_suffix, &c)) { + rdaddsc(&t, c); + sfree(c); + } } else if (!align.just_numbers && tprefix) { + char *c; text_rdaddwc(&t, tprefix, NULL); - rdaddsc(&t, ": "); /* FIXME: configurability */ + if (text_convert(align.number_suffix, &c)) { + rdaddsc(&t, c); + sfree(c); + } } margin = length = (t.text ? strlen(t.text) : 0); |