New Feature Request: Automatic identing of code inside begin/end repeat/until blocks etc.



Hi,

Suppose the following code exists:

begin
if (a=b) then
begin
if (c=d) then
begin
DoSomething1;
end else
begin
DoSomething2;
end;
end;
end;

Now when I add this line * I want delphi to move everything after the new
begin to the right...

This is what I call "automatic identing of begin/end blocks"

begin

// new *
if e=d then
begin

if (a=b) then
begin
if (c=d) then
begin
DoSomething1;
end else
begin
DoSomething2;
end;
end;
end;

So it should look like:

begin

// new *
if e=d then
begin

if (a=b) then
begin
if (c=d) then
begin
DoSomething1;
end else
begin
DoSomething2;
end;
end;
end;

If I decide I want to end the block like this ** then it should be moved
back again

begin


if e=d then
begin

// ** end
end;

if (a=b) then
begin
if (c=d) then
begin
DoSomething1;
end else
begin
DoSomething2;
end;
end;
end;

If I decide to end it like this *** then ofcourse everything should remain
where it is.

begin

if e=d then
begin

if (a=b) then
begin
if (c=d) then
begin
DoSomething1;
end else
begin
DoSomething2;
end;
end;

// *** end
end;
end;

The same should happen for

repeat

// move everything to the right

until something;

There are a few exceptions:

if (a=b) then
DoSomething1;

if (c=d) then
DoSomething2;

Personally I rarely use this coding style... mostly I always use begin
end... anyway... in those cases above only the first line following the
"then" should be moved to the right, if it's not already closed like so:

if (c=d) then bla;

The biggest exception is this:

if First then
repeat


until Something;

In this case repeat should not be moved to the right.

Same case for the while loop:

if Something then
while (a<b) do
begin


end;

Same case for multiple if statements:

if SomethingA then
if SomethingB then
if SomethingC then
begin
// move everything to the right.
end;

So:

The lines below "begin" should be moved to the right.
The lines below "repeat" should be moved to the right.

I think the algorithm could be really simple.

For example:

if "begin" then ident := ident + 1;
if "end" then ident := ident - 1;

// if next string is not ("begin" or "while" or "repeat") then
if "then" then ident := ident + 1;
if ";" then ident := ident - 1;

One last requirement is:

Identing should happen with "tab" character if "use tab character" option is
on.

(By the way, the code generated by delphi should also use the tab character
if this option is on !!!)

Automatic identing of code inside "statement blocks" should ofcourse be an
option ;)

I could try and write a tool for it and then try to integrate it with some
delphi ide... maybe I'll do that... though it would be nice if future IDE's
have this enhancement so I don't have to re-write the tool or have to
re-figure out how to integrate it with the ide or stuff like that ;)

I hope this feature will also work after "cut" and "pasting" text...
Especially then it should work since the identing will have to be re-done in
a big way ;)

So this feature should be "always on" :)... That illusion could be created
by simply running this feature everytime text is typed or inserted... or
even copied... so that the text on the clipboard would be a little bit
better idented as well so that it can easily be copied to other programs
which don't do automatic identing :D

The clipboard stuff is a bonus and should only be done when you feel really
really cool and have plenty of time =D

Bye,
Skybuck.


.



Relevant Pages

  • Re: 64-bit Windows for AMD 64 is here...
    ... All you did was repeat "Delphi is better because ... were discussed in this group ad nauseam already, so I won't repeat that. ... The VCL is a lot easier to use than WinForms. ...
    (borland.public.delphi.non-technical)
  • Re: The Galileo IDE
    ... how is it in C# to make a protected property in the ... we here see the problem with calling Delphi's language Delphi. ... you can just repeat an ancestor protected ...
    (borland.public.delphi.non-technical)
  • How diff in RUNNING coding paths???
    ... I'm porting a open source library to Delphi and I'm stuck in something... ... Then I continue and later I need refocuse in my ecommerce software and put in hold the open source effort a couple the days... ... I must put it in a todo or a bug tracking tool... ... I try writing in a paper every jump and every variable value, I repeat it, and I don't know how i can be so lazy but i don't see the bastard... ...
    (borland.public.delphi.non-technical)
  • Re: Why was win32 killed?
    ... > You are the second Team B member with a counting problem. ... Let me repeat ... Delphi is the name of the language, used by Kylix, Delphi (for ...
    (borland.public.delphi.non-technical)