Add configurability for the suffix after the section number and
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 12 Aug 2002 11:24:59 +0000 (11:24 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 12 Aug 2002 11:24:59 +0000 (11:24 +0000)
before the section title (the ": " in "Section 1: Introduction").

git-svn-id: svn://svn.tartarus.org/sgt/halibut@1838 cda61777-01e9-0310-a592-d414129be87e

bk_text.c

index 5df678e..b682b42 100644 (file)
--- a/bk_text.c
+++ b/bk_text.c
@@ -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);