CnPack Forum


 
Subject: Can I automatically add "end" for "begin"?
elricbk
新警察
Rank: 1



UID 42379
Digest Posts 0
Credits 14
Posts 6
点点分 14
Reading Access 10
Registered 2009-5-17
Status Offline
Post at 2009-5-17 02:59  Profile | Blog | P.M. 
Can I automatically add "end" for "begin"?

Hi!

First of all — thanks for great Delphi instrument!

My question is — can I emulate in some way with CnPack the Delphi 2009 behaviour with "begin .. end"? I want to input "begin", press "enter" and after that "end" should be automatically entered with proper indentation and my cursor should be placed with proper indentation too. I now that I can use the "be" shortcut for this, but could it be done automatically without delay for choosing "be" shortcut?

Thanks in advance for your answer.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6634
Posts 3496
点点分 6634
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-5-18 07:50  Profile | Blog | P.M. 
Thanks for your suggestion. We'll consider it.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6634
Posts 3496
点点分 6634
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-5-18 20:11  Profile | Blog | P.M. 
Please try our latest nightly build version?

http://www.cnpack.org/downbuilds.php

We add this funtion in 0.9.1.509.
Top
elricbk
新警察
Rank: 1



UID 42379
Digest Posts 0
Credits 14
Posts 6
点点分 14
Reading Access 10
Registered 2009-5-17
Status Offline
Post at 2009-5-19 00:58  Profile | Blog | P.M. 
Thanks for fast realization of this feature. Tried last unstable build: "end" was automatically added, but my settings for tab indent was not used, so after adding "end", cursor was indented for two spaces instead of four. Found no way to change this behavior. Did I miss something?

[ Last edited by  elricbk at 2009-5-19 01:18 ]
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6634
Posts 3496
点点分 6634
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-5-19 07:09  Profile | Blog | P.M. 
I'll check this problem.
Top
elricbk
新警察
Rank: 1



UID 42379
Digest Posts 0
Credits 14
Posts 6
点点分 14
Reading Access 10
Registered 2009-5-17
Status Offline
Post at 2009-5-29 14:45  Profile | Blog | P.M. 
Tested latest nightly build (0.9.1.512 from GoogleCode). All works flawlessly. Thanks a lot!
Top
elricbk
新警察
Rank: 1



UID 42379
Digest Posts 0
Credits 14
Posts 6
点点分 14
Reading Access 10
Registered 2009-5-17
Status Offline
Post at 2009-6-4 01:25  Profile | Blog | P.M. 
Found some unexpected behavior. If I press 'enter' while standing at any line with 'begin', CnPack would automatically add 'end' for it. Suppose the situation:

for i := 0 to 10 do

begin

  Writeln('Test');

end;

Now, I want to add some lines to beginning of the loop (before the 'writeln'), I put cursor on the line with 'begin' and hit 'enter':

for i := 0 to 10 do

begin

  |

end;

  Writeln('Test');

end;

This is what I get ('|' stands for cursor position). Is it possible to fix it some way? For example, add 'end' only if 'n' + 'enter' was typed? Or something like this. Thanks in advance.

UPD: [code][/code] tag just wants to double all the newlines, so code looks sparsed. Don't know how to change it.

[ Last edited by  elricbk at 2009-6-4 01:27 ]
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6634
Posts 3496
点点分 6634
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-6-4 07:27  Profile | Blog | P.M. 
Thanks for your report. Some friends also report the same problem.

Please try our latest nightly build 0.9.2.516?
Top
elricbk
新警察
Rank: 1



UID 42379
Digest Posts 0
Credits 14
Posts 6
点点分 14
Reading Access 10
Registered 2009-5-17
Status Offline
Post at 2009-6-6 02:38  Profile | Blog | P.M. 
Tried the 0.9.2.516 version. So after some quick tests, I believe, now it works as intended... but only for those, who follows the indentation rules And it wroks really strange for those, who don't.

For example, suppose empty unit, where you start writing you first procedure:

unit Unit1;



interface




implementation



procedure Test;

begin|




end.

So, now I hit 'enter' and wait for 'end' to appear. But whops! nothing happens.

Ok, let's move to next example:

procedure Test;

var

   i: Integer;

begin

for i := 0 to 10 do

begin|



end;

Again, after 'enter' nothing happens. And even if I put one space before 'for', it would still behave the same.

I'll stick with this version for a moment, because it seems to work right in my day-to-day use, but for someone else its behaviour may seem strange.

Also, have another one suggestion, now for 'end' Could 'end' input be possibly done as '}' input in many C editors. I.e.,

for (i = 0; i < 10; i++)

{

    print "Hi, world!\n";

    |

Now, if I input closing bracket, it would jump to the beginning of line, like this:

for (i = 0; i < 10; i++)

{

    print "Hi, world!\n";



}|

In Delphi rule should work like this: if 'end;' was inputted, and there is only 'end;' in this line, then indendation should be decreased by one full indent. Or something like this. THanks in advance!

UPD: Shouldn't the [code] output be in monospaced font?

[ Last edited by  elricbk at 2009-6-6 02:41 ]
Top
elricbk
新警察
Rank: 1



UID 42379
Digest Posts 0
Credits 14
Posts 6
点点分 14
Reading Access 10
Registered 2009-5-17
Status Offline
Post at 2009-6-6 02:48  Profile | Blog | P.M. 
Also, did you try to fix [code] newline problem? Because it seemed to work correctly when I used Reply buuton, but after I used [Edit] problem with newlines arose again.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6634
Posts 3496
点点分 6634
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-6-6 22:09  Profile | Blog | P.M. 
Thanks for your detailed report. We do some fix in 0.9.2.518 against the 2 problems in you report. But in fact, "unmatched" begin end is relatively not easy to distinguished precisely. We use the indent tab and some other nested level to do the judgement. Maybe cause some uncorrect "auto end".
Top
corrie
新警察
Rank: 1



UID 67274
Digest Posts 0
Credits 2
Posts 1
点点分 2
Reading Access 10
Registered 2011-11-3
Status Offline
Post at 2011-11-3 06:51  Profile | Blog | P.M. 
Is it possible to add a newline as well as an end?

I often encounter this:

procedure TForm1.NewMethod;
begin
  |
end;//<<-- Automatically inserted END;, but now I have to manually correct put a new line after it
procedure TForm1.ExistingMethod;
begin
  ...
  ...
  ...
end;
Top
 




All times are GMT++8, the time now is 2021-12-9 16:07

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.014753 second(s), 8 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP