przemo has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm implementing elastic tabstops concept in a form of a module. I'd like to use it in batch processing of text files, but I see a great potential in incorporating the thing e.g. into Padre editor as well.

I started with a simplest API: for a list of paragraph lines, return the list of reformatted lines (with tabs converted to spaces). Very straightforward.

However, in context of potential usage scenarios, I assume it will not be enough. E.g. in the editor we are not interested in converting tabs to spaces. Moreover, every keystroke should result in reformatting the paragraph. What worse, the tabstops positions will be different for every paragraph...

Having looked at Text::Format, Text::Wrap and friends, they all provide similar, functional (from the text POV) interface.

Do you have an idea, what could be a suitable interface for more "live" text reflowing usage, esp. in Padre?

Replies are listed 'Best First'.
Re: Text formatting API
by Khen1950fx (Canon) on Sep 07, 2011 at 07:31 UTC
    Text::FindIndent intuits spaces or tabs. It also works in vim. You could probably work it into Padre.