[Geany-Users] new plugin for automatic alignment

Lex Trotman elextr at xxxxx
Mon Nov 16 12:24:34 UTC 2015


Hi,

As a general comment, Thomas is right, catching every notify and
re-styling all the text is going to be too expensive.

For example Asciidoc is 6000+ lines of Python, I would suspect that is
too long to use this approach.

You should detect the char added notify and just do the line that the
character is added to, and maybe only when = or end of line is typed?
Don't even look at the previous or next lines.

Cheers
Lex

On 16 November 2015 at 20:45, Thomas Martitz <kugel at rockbox.org> wrote:
> Am 16.11.2015 um 11:36 schrieb Max Voss:
>>
>>
>>
>> Hello again,
>>
>> Sure, I can describe the algorithm:
>>
>> First it checks for the editor signal (although atm it just takes /any/
>> "editor-notify" not just text change).
>>
>> Then it gets the line and checks if there is a symbol that has to be
>> aligned.
>>
>> Then it gets the adjecent lines and checks those too, for misaligned
>> symbols, indentation, and stop conditions like if there is a ":" in that
>> line, for example I don't want to align:
>>
>> a=1
>> while a==1:
>>     ...
>>
>> Then it splits the line into variables and arguments at the location of
>> the "=" , so left, right basically.
>
>
>
> Is this plugin specific to python source code? Or can it auto-align (for
> example) C code as well?
>
>>
>> Then it strips the indentation white space and newline characters and gets
>> the max. length of a variable. All variable names that are shorter than that
>> get buffered with spaces until they're equal in length.
>>
>> The newlines get created with " indentation + variable + = + value "
>>
>> All the old lines and new lines get compiled into a block each, I search
>> the document for the entire old block, do some string slicing and plug the
>> new block into the old blocks place.
>>
>> Then all text gets set to the text with the plugged new block and the
>> cursor position gets set to the end of the new block.
>
>
>
> Setting replacing the entire text has a serious drawback. The undo action
> that is recorded by scintilla will be large in memory, basically the size of
> the document. It seems auto-aligning is a frequent thing so this sounds
> troublesome.
>
> Best regards
>
> _______________________________________________
> Users mailing list
> Users at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/users


More information about the Users mailing list