Recent

Author Topic: Slow editor on Mac  (Read 42011 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Slow editor on Mac
« Reply #45 on: May 16, 2014, 11:21:34 pm »
Code: [Select]
TCarbonWidgetSet.ScrollWindowExIs definitely not working here. It is called with
Code: [Select]
      if ScrollWindowEx(Handle, 0, LineHeight * Delta, @srect, @srect, 0, nil, SW_INVALIDATE)

If you look at it, then it first checks
Code: [Select]
    if (flags and SW_SCROLLCHILDREN <> 0) then
Which is False.

Then
Code: [Select]
if (Flags = 0) thenwhich is also false.

So it goes to the last block
Code: [Select]
    if flags and SW_INVALIDATE <> 0 then

And that will invalidate "prcClip". Meaning the entire synedit is invalidated.

But it should use HIViewScrollRect to scroll

I once tried to fix it with {$IFDEF NewScrollWindowEx}
But IIRC  that is not fully working yet either.

You can try to define NewScrollWindowEx, and see if it helps. But I do not know.

------------------
You can also just try to do
Code: [Select]
flags := 0
At the start of ScrollWindowEx

ddfs

  • New Member
  • *
  • Posts: 10
Re: Slow editor on Mac
« Reply #46 on: May 17, 2014, 09:41:18 am »
I've just tried both options. They adds a performance, but:
first - lots of glitches, regions updated only partial

second (flags:=0) is almost perfect, but there is a text caret trail if you scroll via keys (up and down) by one line.
I think the updated region should be one line wider somehow.
« Last Edit: May 17, 2014, 02:19:48 pm by ddfs »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Slow editor on Mac
« Reply #47 on: May 17, 2014, 03:33:33 pm »
I've just tried both options. They adds a performance, but:
How much?

Yes the IFDEF code is unfinished...

Quote
first - lots of glitches, regions updated only partial

second (flags:=0) is almost perfect, but there is a text caret trail if you scroll via keys (up and down) by one line.
I think the updated region should be one line wider somehow.

As workaround you can deal with that in SynEdit.pp

Line 4405
Code: [Select]
      if ScrollWindowEx(Handle, 0, LineHeight * Delta, @srect, @srect, 0, nil, SW_INVALIDATE)

Just add
Code: [Select]
      FScreenCaret.Hide;
in front of it.

You may need to do (but I do not think you need/ and if not needed then do not:
      UpdateCaret;
after the if then else block.

TCarbonWidgetSet.ScrollWindowEx would need to call
LCLIntf.HideCaret(Handle)
and
LCLIntf.ShowCaret(Handle)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Slow editor on Mac
« Reply #48 on: May 17, 2014, 03:35:50 pm »
Btm, if flags = 0 has side effects (e.g maybe TScrollbox)
then

if flags and SW_INVALIDATE <> 0 then flags := flags - SW_INVALIDATE


So other flags are kept

ddfs

  • New Member
  • *
  • Posts: 10
Re: Slow editor on Mac
« Reply #49 on: May 17, 2014, 03:50:26 pm »
Talking about performance improvement - after "flags:=0" I'm really satisfied with it. There is no lags, you can just scroll and edit text normally.
I think we should beat this issue down and commit a fix to the trunk.

I've just tried to hide a caret as you suggested, but it didn't help. The caret was still there. Also please note the screenshot - there is also a green trail of the current line highlight.
I think it would be better to somehow invalidate one additional line or find a way to hide both things - a caret and a line highlight.

Please suggest anything else to fix this. I'm ready to change the source and test it.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Slow editor on Mac
« Reply #50 on: May 17, 2014, 04:00:48 pm »
The it seems, that HIViewScrollRect does not deal with already invalidated areas.

SynEdit first invalidates the current line (if there is highlight on the current line *AND* the current line changes), and then scrolls.

This may mean there may be other artefacts (like the red border for begin/end pairs).

You can add an
InvalidateLines(1,1) // first line on screen
OR
InvalidateLines(LinesInWindow, LinesInWindow+1) // last line on screen

in the
      if ScrollWindowEx(Handle, 0, LineHeight * Delta, @srect, @srect, 0, nil, SW_INVALIDATE)
      then begin
depending on delta being positive or negative.

If you add them unconditional, you will have a full screen invalidate.....

---------------
Yes it needs a proper fix.

But I am a bit short on time now.

ddfs

  • New Member
  • *
  • Posts: 10
Re: Slow editor on Mac
« Reply #51 on: May 17, 2014, 04:10:04 pm »
I've tried to
InvalidateLines(1,1) or InvalidateLines(LinesInWindow, LinesInWindow+1) or both, or different values, but it doesn't seem to affected anything(

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Slow editor on Mac
« Reply #52 on: May 17, 2014, 04:15:13 pm »
You tried in SynEdit, and AFTER the scrollWindowEx?

Then try
InvalidateLines(1,2) // first line on screen
OR
InvalidateLines(LinesInWindow-1, LinesInWindow+1) // last line on screen


Though it may be that this is outmarted by SynEdits internal, and you need to call InvalidateRect directly...
Then you need to calculate the rect yourself.


Anyway.
Sorry, but I havent got the time to look deeper now.

This needs to go into the carbon class.
The IFDEF was a start on that. But it needs to be finished.

ddfs

  • New Member
  • *
  • Posts: 10
Re: Slow editor on Mac
« Reply #53 on: May 17, 2014, 04:20:12 pm »
Oh I've found out why it didn't work - it invalidates a first and a a last line of the entire synedit, not just of what is on screen.
So yes, we need to calculate a rect that is on screen to use correct values.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Slow editor on Mac
« Reply #54 on: May 17, 2014, 04:23:37 pm »
Ups, then it is Invalidatelines(TopLine, TopLine)

But topline is already changed.... So that will not work either.

You have the rect that was scrolled, you either need to invalidate the top (delta) pixels, or bottom delta

ddfs

  • New Member
  • *
  • Posts: 10
Re: Slow editor on Mac
« Reply #55 on: May 17, 2014, 04:34:29 pm »
Ok,
Something is finally working:
 Invalidatelines(TopLine+1, TopLine+1);   
But only when you scroll up.



ddfs

  • New Member
  • *
  • Posts: 10
Re: Slow editor on Mac
« Reply #56 on: May 17, 2014, 04:38:56 pm »
That is decreasing performance btw... even if we invalidate just one line it adds lags on scrolling.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Slow editor on Mac
« Reply #57 on: May 17, 2014, 06:47:57 pm »
If you invalidate the wrong line, then yes.

FYI:

If you invalidate the top/left 1 pixel of a form or control, AND the bottom right 1 pixel, then you have invalidate the whole control (minimum enclosing rectangle of the 2 pixels)

So if the caret (text cursor) is on the bottom line, and you press down, therefore scrolling up, then there will be new lines scrolling in from the bottom.
In this case you can invalidate additional lines at the bottom.
But if you invalidate one single line at the top, then you invalidated all.

ddfs

  • New Member
  • *
  • Posts: 10
Re: Slow editor on Mac
« Reply #58 on: May 17, 2014, 06:49:37 pm »
I see. Then the best workaround would be just to hide a caret somehow.

ddfs

  • New Member
  • *
  • Posts: 10
Re: Slow editor on Mac
« Reply #59 on: May 17, 2014, 06:53:11 pm »
btw maybe you know, is there someone who is working on cocoa interface and when to expect something that works on it?

 

TinyPortal © 2005-2018