EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Very Slow when paste long text( 5000 lines ) to Editor

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
hyperspeed



Joined: 28 Sep 2006
Posts: 16

PostPosted: Thu Jul 26, 2007 8:23 am    Post subject: Very Slow when paste long text( 5000 lines ) to Editor Reply with quote

Hello.

Very Slow when paste long text( 5000 lines ) to Editor with complex BlockRules.

I'm send mail to you and attach sample file

I'm using v2.32 and Unicode compile in Delphi 7
Please investigate it....

Thank you.
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Thu Jul 26, 2007 9:19 pm    Post subject: Reply with quote

Hello,

After inserting (pasting) new text caret is moved to the end of the text.
To render text at new position (after inserted text) editor has to analize all text before, i.e. all inserted text. It is not fast operation, especially when using complex lexers.

To avoid this problem it is possible to keep caret at old position. In this case only analysis of first visible lines of inserted text will be required and all the rest text will be analyzed in background mode.

To skip caret position changing in InsertText method we need to simulate caret changing.

Solution (using OnTextChange event):

Code:
procedure TForm1.SQLEditorTextChanged(Sender: TObject; Pos, Count, LineChange: Integer);
begin
  if Count > 100000 then // Large inserted text block
    begin
      // Here we make any change of caret position
      // In this case, caret position will not be changed in InsertText method
      if SQLEditor.CaretStrPos = Pos then
        SQLEditor.CaretStrPos := Pos + 1;
      SQLEditor.CaretStrPos := Pos;
    end;
end;


Michael
Back to top
View user's profile Send private message Send e-mail
hyperspeed



Joined: 28 Sep 2006
Posts: 16

PostPosted: Fri Jul 27, 2007 3:02 am    Post subject: Reply with quote

thank you

We has to move caret pos to the end of the text when past long text.
Your solution move to the first of the text.

I'm got the hint from your code.
not slow too ...

Solution (using OnTextChange event):
Code:

  if Count > 100000 then // Large inserted text block
    begin
      // Here we make any change of caret position
      // In this case, caret position will not be changed in InsertText method
      if SQLEditor.CaretStrPos = Pos then
        SQLEditor.CaretStrPos := Pos + 1;
      SQLEditor.CaretStrPos := SQLEditor.CaretStrPos + Count;
    end;


but it is not good solution
it is slow too
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Fri Jul 27, 2007 4:47 am    Post subject: Reply with quote

Hello,

If you need to move caret to the end of inserted text (default behavior) there is only one way to improve performance - lexer optimization.

Michael.
Back to top
View user's profile Send private message Send e-mail
hyperspeed



Joined: 28 Sep 2006
Posts: 16

PostPosted: Mon Jul 30, 2007 2:20 am    Post subject: Reply with quote

Hello

I used another way.
FSyntPars.AlwaysSyncBlockAnal := False;
This cord operates very quickly.
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Mon Jul 30, 2007 10:08 am    Post subject: Reply with quote

Yes, when this option is False, block analysis is performed after all text was parsed.

There is only limitation of using this option. If any parser rule has "Parent" block condition block analysis will be synchronous with the parser even when AlwaysSyncBlockAnal = False.

Michael.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group