Recent

Author Topic: Faster responding Code Explorer  (Read 2673 times)

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Faster responding Code Explorer
« on: January 31, 2023, 05:44:21 am »
Code Explorer refresh rate increase, may that be included or would it damage systems?

File to patch: \Lazarus\IDE\CodeExplorer.pas
What to patch: procedure TCodeExplorerView.IdleTimer1Timer(Sender: TObject);

Before:
Code: Pascal  [Select][+][-]
  1. procedure TCodeExplorerView.IdleTimer1Timer(Sender: TObject);
  2. begin
  3.   if not (cevCheckOnIdle in FFlags) then exit;

After:
Code: Pascal  [Select][+][-]
  1. procedure TCodeExplorerView.IdleTimer1Timer(Sender: TObject);
  2. begin
  3.   if (IdleTimer1 <> nil) then
  4.     IdleTimer1.Interval := 100;
  5.   if not (cevCheckOnIdle in FFlags) then exit;

My current version I tested it with (Windows 10/64bit):
Lazarus 2.2.4 (rev lazarus_2_2_4) FPC 3.2.2 x86_64-win64-win32/win64
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: Faster responding Code Explorer
« Reply #1 on: January 31, 2023, 06:18:59 am »
Introducing an arbitrary interval may indeed affect other systems than yours. Stay away from timers, even idletimers.
Maybe you can come up with a better solution? It is always valid to speed up things a bit.
Specialize a type, not a var.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Faster responding Code Explorer
« Reply #2 on: January 31, 2023, 07:00:19 am »
Thanks for your honest reply!
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Faster responding Code Explorer
« Reply #3 on: February 02, 2023, 09:24:35 am »
After a long seek and hunt game, and your text @Thaddy, I probably found a solution but since everything is written very hard for me to find out what it connected with what and how it works together, here is my suggestion that should work for all and respects any OS.

My problem is just to find a way that it works smooth together without breaking something, maybe someone with more experience can help and guide me?

What I found out so far:
The file "lazarus\ide\frames\codeexplorer_update_options.pas" & "codeexplorer_update_options.lfm" hold the stuff thats displayed in configuration to react on changes.
The file "lazarus\ide\lazarusidestrconsts.pas" has the visible names
The file "lazarus\ide\codeexplopts.pas" is somehow the ruler for that screen
and finally "\Lazarus\IDE\CodeExplorer.pas" is the master

My suggestion/Idea would be to place a trackbar like I show exemplary on that image
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: Faster responding Code Explorer
« Reply #4 on: February 02, 2023, 10:32:14 am »
On the initial idea, with a faster timer: It runs codetools, so there is potentially a lot of computing, and while many systems are fast enough, that is not the only issue. For examples users on a Laptop will experience the extra drain on the battery...


First of all, there are several updates triggers. For which do you wish the increased speed.

1) When you are typing inside a block of code?
2) When you switch tabs
3) Other focus events
....

2 (and 3) can maybe bypass the timer, and directly use an "OnIdle" or even an ASync event.

As for 1, well that could be further cut down.
E.g. maybe it can cheaply (though probably not trivial) be detected, if the caret just moved to a diff procedure, which could trigger an update.

I don't know if any other edit or user-input really needs faster updates....

balazsszekely

  • Guest
Re: Faster responding Code Explorer
« Reply #5 on: February 02, 2023, 01:00:42 pm »
@KodeZwerg

I attach a zip which contains a patch and the source files. You can apply the patch or copy/replace the source files manually, in both cases you need Lazarus main, you can easily install it with Fpcupdeluxe. After the changes are applied a rebuild is needed
I implemented your idea, you can improve it by taking into account what @Martin_fr suggested.   

PS: My patch does not change the current behaviour of codeexplorer, but you can increase/decrease the idle timer interval from options. I did not test the changes at all, it might contain bugs.
« Last Edit: February 02, 2023, 01:41:24 pm by GetMem »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Faster responding Code Explorer
« Reply #6 on: February 02, 2023, 03:26:57 pm »
@GetMem (!!!)  :o amazing (I guess)

I'd thought about advice and you (probably) offered the solution  %)

Before I start using, can you tell me your Lazarus version so I know if its same with mine and compatible to mine please  :-[

Mine:
Lazarus 2.2.4 (rev lazarus_2_2_4) FPC 3.2.2 x86_64-win64-win32/win64

And idk what to do with the patch file (I never had/used such) so I will manual replace files and rebuild afterwards.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Faster responding Code Explorer
« Reply #7 on: February 02, 2023, 03:30:26 pm »
Before I start using, can you tell me your Lazarus version so I know if its same with mine and compatible to mine please  :-[

@GetMem said Lazarus "main" so the latest commit from GitLab repository, and also seems that it requires "main" FPC, the latest commit from GitLab repository. You can install it with FPCUpDeluxe.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Faster responding Code Explorer
« Reply #8 on: February 02, 2023, 03:37:38 pm »
Before I start using, can you tell me your Lazarus version so I know if its same with mine and compatible to mine please  :-[

@GetMem said Lazarus "main" so the latest commit from GitLab repository, and also seems that it requires "main" FPC, the latest commit from GitLab repository. You can install it with FPCUpDeluxe.
Thank you for quick reply, but "main" I dont find, please guide me, what is meant with "main"
This is what app offers me and my basic selection for when I update.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

balazsszekely

  • Guest
Re: Faster responding Code Explorer
« Reply #9 on: February 02, 2023, 03:38:32 pm »
I did with Lazarus trunk(svn)/main(git) and FPC 3.2.2, like in the attached image. Every IDE related development should be done with the development version of Lazarus(trunk/main).
To apply a patch you need git, Tortoise Git is very popular among windows users, it will take some time to set it up though. The easiest solution is to replace the files after you install Lazarus with fpcupdeluxe.

PS: The development version is called trunk for svn, and main/master for git. Not so long ago we switched from svn to git, hence the confusion.
« Last Edit: February 02, 2023, 03:50:16 pm by GetMem »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Faster responding Code Explorer
« Reply #10 on: February 02, 2023, 04:49:23 pm »
Thanks so much @GetMem, Lazarus 2.3.0 (rev main-2_3-2513-g659f556800) FPC 3.2.2 x86_64-win64-win32/win64, works!
I needed to patch file lazarusidestrconsts.pas manual, yours was out-of-date and misses some resourcestrings but after I inserted to original your string, all works fine.

Now I start comparing where you put a plastic surgeon on to learn from  :-* :-* :-*

( filesize difference from trunk version to your version of my mentioned file: trunk 356737 (348,38 kb) vs yours 351114 (342,88 kb) )
( i added the trunk patched )
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

balazsszekely

  • Guest
Re: Faster responding Code Explorer
« Reply #11 on: February 02, 2023, 05:58:03 pm »
@KodeZwerg
Quote
I needed to patch file lazarusidestrconsts.pas manual, yours was out-of-date and misses some resourcestrings but after I inserted to original your string, all works fine.
I' m not sure what went wrong at your side, but I double checked lazarusidestrconsts.pas both with git and fpcupdeluxe, it's exactly the same as mine, except the one line I added for the idle timer. Lazarusidestrconsts .pas was last modified in 2023.01.26.

balazsszekely

  • Guest
Re: Faster responding Code Explorer
« Reply #12 on: February 02, 2023, 06:17:51 pm »
I also attach a version for Lazarus 2.2.4/FPC 3.2.2.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2007
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Faster responding Code Explorer
« Reply #13 on: February 02, 2023, 06:41:14 pm »
@KodeZwerg
Quote
I needed to patch file lazarusidestrconsts.pas manual, yours was out-of-date and misses some resourcestrings but after I inserted to original your string, all works fine.
I' m not sure what went wrong at your side, but I double checked lazarusidestrconsts.pas both with git and fpcupdeluxe, it's exactly the same as mine, except the one line I added for the idle timer. Lazarusidestrconsts .pas was last modified in 2023.01.26.
I just did what you suggested me to do, selected trunk and updated lazarus, trunk send me a file way bigger than if i just add one string to it. Thats all, no magic from my side.
But as told, for me it works very good after I added this missing string of yours to the file and I hope that devs include your wonderful additions in future release by default  O:-)

My vote for it they have, many many Kudos!!!!

Filedates = I have no idea how to compare since they got date from when I downloaded not from when its created.

Thanks again GetMem!!! (Also for your 2.2.4 version, I guess with that it would have worked out-of-the-box for me since that was what I used before (stable))
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

 

TinyPortal © 2005-2018