#9426

gning
Participant

Thanks. The macro basically works. But when I said “perceive a change of indent as a paragraph boundary”, what I meant was that if one set of lines is indented to a different depth from other lines that are adjacent to it, that the macro would see these as being two distinct paragraphs.

Maybe that’s not necessary. In fact, I probably don’t need it. So I’ll probably just use your macro as it is, but without the last line.

Sorry I asked the question and then forgot for so long to check back for the answers…

Anyway, the object I had in mind was to combine that with a macro of my own for reflowing text in a selection. Put them together, and you get something to reflow the paragraph the cursor is in.

Here is my reflow-selection macro:

// Save current wrap setting:
var stateNoWrap = editor.QueryStatusByID(4208); // No Wrap
var stateWindowWrap = editor.QueryStatusByID(4210); // Wrap by Window
var statePageWrap = editor.QueryStatusByID(4318); // Wrap by Page
// Temporarily set Wrap by Characters mode:
editor.ExecuteCommandByID(4209);
// Reflow:
document.selection.Format(eeFormatJoinLines);
document.selection.Format(eeFormatSplitLines);
// Restore previous wrap setting:
if (stateNoWrap >= eeStatusLatched)
editor.ExecuteCommandByID(4208);
else if (stateWindowWrap >= eeStatusLatched)
editor.ExecuteCommandByID(4210);
else if (statePageWrap >= eeStatusLatched)
editor.ExecuteCommandByID(4318);

The neat thing about this macro as it stands now is that if you select multiple paragraphs, it preserves the spaces between then and reflows each one individually.