View previous topic :: View next topic |
Author |
Message |
hyperspeed
Joined: 28 Sep 2006 Posts: 16
|
Posted: Thu Jul 26, 2007 8:23 am Post subject: Very Slow when paste long text( 5000 lines ) to Editor |
|
|
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 |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Thu Jul 26, 2007 9:19 pm Post subject: |
|
|
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 |
|
|
hyperspeed
Joined: 28 Sep 2006 Posts: 16
|
Posted: Fri Jul 27, 2007 3:02 am Post subject: |
|
|
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 |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Fri Jul 27, 2007 4:47 am Post subject: |
|
|
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 |
|
|
hyperspeed
Joined: 28 Sep 2006 Posts: 16
|
Posted: Mon Jul 30, 2007 2:20 am Post subject: |
|
|
Hello
I used another way.
FSyntPars.AlwaysSyncBlockAnal := False;
This cord operates very quickly. |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Mon Jul 30, 2007 10:08 am Post subject: |
|
|
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 |
|
|
|