New Feature Request: Automatic identing of code inside begin/end repeat/until blocks etc.
- From: "Skybuck Flying" <nospam@xxxxxxxxxxx>
- Date: Thu, 8 Sep 2005 15:34:54 +0200
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.
.
- Follow-Ups:
- Re: New Feature Request: Automatic identing of code inside begin/end repeat/until blocks etc.
- From: Nicholas Sherlock
- Re: New Feature Request: Automatic identing of code inside begin/end repeat/until blocks etc.
- Prev by Date: Bold print
- Next by Date: New feature request: Automatic changing of interface/routine headings. New implementation sections required: private, protected, public.
- Previous by thread: Bold print
- Next by thread: Re: New Feature Request: Automatic identing of code inside begin/end repeat/until blocks etc.
- Index(es):
Relevant Pages
|