Doing something on every paragraph break

I am trying to clear a flag on every paragraph break, whether the break is explicitly specified in my code or not. I’m having trouble digging into the Inter involved with spacing. Is there a reliable way to do this?

1 Like

The I6 routine for this is DivideParagraphPoint, which is defined as so:

[ DivideParagraphPoint;
    #ifdef LKTRACE_SPACING; print "[DPP", say__p, say__pc, "]"; #endif;
    if (say__p) {
        new_line; say__p = 0; say__pc = say__pc | PARA_COMPLETED;
        say__pc_save = true;
        if (say__pc & PARA_PROMPTSKIP) say__pc = say__pc - PARA_PROMPTSKIP;
        if (say__pc & PARA_SUPPRESSPROMPTSKIP) say__pc = say__pc - PARA_SUPPRESSPROMPTSKIP;
    }
    #ifdef LKTRACE_SPACING; print "[-->", say__p, say__pc, "]"; #endif;
    say__pc = say__pc | PARA_CONTENTEXPECTED;
    say__pc_save = (say__pc & PARA_COMPLETED);
];

That first “if”-block inserts a paragraph break if one is pending (say__p is nonzero), then zeroes out say__p again. Clear your flag in there.

1 Like

I had seen that code; I guess my question should have been: is this the only place where the paragraph break is actually performed, so can I only worry about clearing the flag here?

Sort of. This is the block of code in Basic Inform that handles spacing.

To say line break -- running on
    (documented at phs_linebreak):
    (- new_line; -).
To say no line break -- running on
    (documented at phs_nolinebreak):
    do nothing.
To say conditional paragraph break -- running on
    (documented at phs_condparabreak):
    (- DivideParagraphPoint(); -).
To say paragraph break -- running on
    (documented at phs_parabreak):
    (- DivideParagraphPoint(); new_line; -).
To say run paragraph on -- running on
    (documented at phs_runparaon):
    (- RunParagraphOn(); -).
To decide if a paragraph break is pending
    (documented at ph_breakpending):
    (- (say__p) -).

As you can see, most of this goes through DivideParagraphPoint, but [line break] does not. If you make a paragraph break by saying “[line break][line break]”, there’s no way to detect that. (Or rather, you’d have to redefine [line break] to track it.)

2 Likes