Recent

Author Topic: Bugs in Example Projects window  (Read 4161 times)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4172
  • I like bugs.
Re: Bugs in Example Projects window
« Reply #15 on: December 06, 2022, 09:32:51 am »
Earlier (issue #39671) I tried to change the logic for this exact same LazarusDirectory but it caused a regression.
You told me you had fixed it. And from memory, it needed to be fixed. But you did not tell me you reverted that fix.  Thanks very much.

background : Initially, direct access to LazarusDirectory was not available, Getmen eventually either found a way or made a way but by that stage, my code was in the review pipeline.
https://forum.lazarus.freepascal.org/index.php/topic,57680.msg434967.html#msg434967
Clearly I should have gone back to it but I was traveling then and time was a rare commodity. But with a fix applied to the LazarusDirectory name issue, it was not critical.  :-[
My "fix" was based on poor knowledge of the code. After reverting it I planned to study the issue more but I had many other activities during the past year and this one got postponed.
Now it is fixed. No worries mate, or how they say in Australia?
I started to wonder when was function GetParsedLazarusDirectory added to the interface. Why didn't we find it earlier? I did :
Code: [Select]
$ git blame components/buildintf/ideoptionsintf.pasThis is a portion of its output :
Code: [Select]
151f452c847 components/ideintf/ideoptionsintf.pas   (ondrej  2015-11-27 05:35:22 +0000 135)     procedure RemoveFromRecentPackageFiles(const AFilename: string); virtual; abstract;
151f452c847 components/ideintf/ideoptionsintf.pas   (ondrej  2015-11-27 05:35:22 +0000 136)
68276150e12 components/ideintf/ideoptionsintf.pas   (joost   2019-01-01 16:49:20 +0000 137)     function GetParsedCompilerFilename: string; virtual; abstract;
9d1b8c9d875 components/ideintf/ideoptionsintf.pas   (joost   2019-04-12 21:08:55 +0000 138)     function GetParsedFppkgConfig: string; virtual; abstract;
6f9144a5841 components/buildintf/ideoptionsintf.pas (balazs  2022-02-23 08:04:33 +0200 139)     function GetParsedLazarusDirectory: string; virtual; abstract;
fba579ac625 components/ideintf/ideoptionsintf.pas   (mattias 2018-09-22 12:03:45 +0000 140)
151f452c847 components/ideintf/ideoptionsintf.pas   (ondrej  2015-11-27 05:35:22 +0000 141)     procedure AddHandlerAddToRecentOpenFiles(Handler: TOnAddToRecent; const AsFirst: boolean = true); // AsFirst means: first to call
151f452c847 components/ideintf/ideoptionsintf.pas   (ondrej  2015-11-27 05:35:22 +0000 142)     procedure RemoveHandlerAddToRecentOpenFiles(Handler: TOnAddToRecent);
It was added by balazs in February this year. Kudos to him. [I got confused by names and had an inaccurate comment here for a while]
BTW, the "git blame" command is super. The whole file was moved from ideintf to buildintf (removing LCL dependency) and Git is able to track it without being told about the move. It calculates a "similarity index" and understands that identical or near identical files are moved or copied.
Also the merge conflict algorithms in Git are very good. The more demanding task you have, the better it works.

Quote
Well, in my case I am not using trunk for day to day work anymore because of this https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39540
Yes, it must be fixed properly. Now it does not crash any more but the popup opens in a wrong place.
Quote
The problem only shows up if you are using the default location for PCP. Most trunk users have it as a second install and its config is redirected. Certainly in my case.
PCP is "Primary Config Path". The bug happened also when using --pcp= parameter.
I think I know why others didn't notice it! The few people who are testing the Examples window in Lazarus "main" have their sources in a directory right under their home directory, like "~/lazarus_git". LazarusDirectory is stored as a path relative to PCP which by default is "~/.lazarus". By accident it went right.
My sources are in "~/SW/lazarus" and things went haywire. How does it work on Windows? I have no idea.
The global options GUI needs a hint of how LazarusDirectory is stored. I will add it ...  [Edit] Done in 2f13102566

About the filter :
It is OK if TextHint is not shown when the filter has focus. It is widgetset specific behavior. TextHint is shown when focus is elsewhere. It is logical and users learn it in few seconds. Please don't waste your time tweaking LCL's behavior. If LCL widgetset code has a bug, it should be fixed there.
I added a comment in issue
 https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40034
You still haven't commented on using the TListViewFilterEdit control.
« Last Edit: December 06, 2022, 10:40:33 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

dbannon

  • Hero Member
  • *****
  • Posts: 2289
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Bugs in Example Projects window
« Reply #16 on: December 06, 2022, 10:46:36 am »
.....After reverting it I planned to study the issue more but I had many other activities during the past year and this one got postponed.
Quite a lot of activities I understand. Outside ... :)
Its good to see you back here, hands on again. Hope you don't mind me saying.

Now it is fixed. No worries mate, or how they say in Australia?
If you can draw the 'a' in mate out a bit, maaaate .....

[I deleted a piece here because I had confused names badly and the this would confuse things more. Sorry! _Juha_]

Quote
PCP is "Primary Config Path". The bug happened also when using --pcp= parameter.

Oh, I did not realise that, I thought any redirection of PCP masked the problem. So, is it because of the '~' rather than an absolute path ?  I usually use $HOME rather than tilde because sometimes the shell plays with '~' in unexpected ways. Its managed internally rather than expanded like $HOME is.

Anyway, even though its no longer a problem here, I suspect it needs to be resolved, it will bite us again, sooner or later.

Quote
About the filter :
It is OK if TextHint is not shown when the filter has focus.
Its OK now with the patch I posted a few hours ago. The issue for me was that a user seeing the window for the first time had no way of knowing just what that field was for. Now I start with the focus on the ListView (and thats actually good), the EditSearch is only a click or a tab away and an Enter in the EditSearch brings you back into the ListView. Its actually quite intuitive.

Quote
I added a comment in issue
 https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40034
You still haven't commented on using the TListViewFilterEdit control.
I'll respond to issue 40034 in Isue 40034, my bad !
 TListViewFilterEdit  ? Probably another very good component with no documentation. Every time I want to use a new component, I have to spend days experimenting on how it works (and writing up my finding in the wiki) so, I use the ones I know.  Its really sad we have such great people writing such good code but they won't add an extra 15 minutes documenting what they have done !  (Get off your soap box David, he used to be in a position to 'instruct' his developers to write good docs but not any more.)

OK, off to issue 40034 ...

Davo

 
« Last Edit: December 06, 2022, 10:57:32 am by JuhaManninen »
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4172
  • I like bugs.
Re: Bugs in Example Projects window
« Reply #17 on: December 06, 2022, 12:18:31 pm »
Oh, I did not realise that, I thought any redirection of PCP masked the problem. So, is it because of the '~' rather than an absolute path ?  I usually use $HOME rather than tilde because sometimes the shell plays with '~' in unexpected ways. Its managed internally rather than expanded like $HOME is.
'~' is interpreted by a (bash) shell and works just fine there.
Now the problem was a relative '..' path in LazarusDirectory. It is relative to the Primary Config Path which was not obvious. I improved the situation by adding a hint to the options GUI.

Quote
Anyway, even though its no longer a problem here, I suspect it needs to be resolved, it will bite us again, sooner or later.
It is now resolved properly!
Earlier you had to read the XML file because there was no API function for the task. Now there is because GetMem (balasz) added it. GetParsedLazarusDirectory resolves the relative path correctly.

Quote
Its OK now with the patch I posted a few hours ago. The issue for me was that a user seeing the window for the first time had no way of knowing just what that field was for. Now I start with the focus on the ListView (and thats actually good), the EditSearch is only a click or a tab away and an Enter in the EditSearch brings you back into the ListView. Its actually quite intuitive.
Not good. Sorry.
People understand what a FilterEdit is because it is spread everywhere in the IDE. The convention is to give focus to it first. It has become a standard GUI element in many other systems, too. For example KDE which I use as a Linux desktop shines with that. Their comprehensive settings dialog is a pleasure to use because of its filter edits.
In fact I got inspiration years ago to create the FilterEdit controls for Lazarus from using KDE.

Quote
TListViewFilterEdit  ? Probably another very good component with no documentation.
Yes.  :)
... no, it has documentation:
 https://wiki.freepascal.org/LazControls#TListViewFilterEdit
OK, it is rather short but it says "Data should be added to TListViewFilterEdit.Items, not to the container ListView."
What else you need to know?  :P
There is example code in Lazarus sources.

Quote
Every time I want to use a new component, I have to spend days experimenting on how it works (and writing up my finding in the wiki) so, I use the ones I know.  Its really sad we have such great people writing such good code but they won't add an extra 15 minutes documenting what they have done !  (Get off your soap box David, he used to be in a position to 'instruct' his developers to write good docs but not any more.)
Example code works as documentation, too.
Anyway, when working with a huge existing code base the biggest challenge is not writing new code but learning the existing code.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

GetMem

  • Hero Member
  • *****
  • Posts: 3953
Re: Bugs in Example Projects window
« Reply #18 on: December 06, 2022, 01:02:28 pm »
Two suggestion, if I may:
1. FormLazExam's postion property should be poWorkAreaCenter instead of poDesigned for obvious reasons
2. Pressing the Esc key should close the dialog, this is universally true for almost every other dialog in the IDE

dbannon

  • Hero Member
  • *****
  • Posts: 2289
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Bugs in Example Projects window
« Reply #19 on: December 06, 2022, 01:08:15 pm »
TListViewFilterEdit  ? Probably another very good component with no documentation.
Yes.  :)
... no, it has documentation:
 https://wiki.freepascal.org/LazControls#TListViewFilterEdit
OK, it is rather short but it says "Data should be added to TListViewFilterEdit.Items, not to the container ListView."
What else you need to know?  :P
* Can it handle multiple columns in the list view ? 
* How to add an item ?  Seems its a call to ~.items.add(Item:T); And that item is fgl thingo. I use Pascal because its strongly typed, if I want something that can be any old type depending on the day of the week, I'd use Python.
* How to specify and apply the filter ?
* Can you filter for, eg "Words together" plus another ?
* Will it work with Owner Data ?
* Why does it have no mention in the chm help files ?
* Why is it Red on in the table that appears, eg on https://wiki.freepascal.org/TEdit ?
* Why is there no Example Project showing how to use TListViewFilterEdit ?

Honestly, before I answer half of those questions, I've written the filter that I used. And it works fine. I'm willing to consider any other model iff that model is better.
 
Quote
Anyway, when working with a huge existing code base the biggest challenge is not writing new code but learning the existing code.

Sure, that I agree. See the last three questions above.

Anyway, do as you see fit, you have commit rights, I don't.  :)

Davo
« Last Edit: December 06, 2022, 01:14:01 pm by dbannon »
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

GetMem

  • Hero Member
  • *****
  • Posts: 3953
Re: Bugs in Example Projects window
« Reply #20 on: December 06, 2022, 02:34:08 pm »
@dbannon

ListViewFilterEdit has a FilteredListView property, once the link is set you are good to go, no additional code is required. I did not study you custom filtering, maybe is more advanced then what ListViewFilterEdit natively provides, the important thing is don't get too upset about these small issues.  I played the same game with OPM, it can be really frustrating and it's not worth it.
« Last Edit: December 06, 2022, 02:37:22 pm by GetMem »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4172
  • I like bugs.
Re: Bugs in Example Projects window
« Reply #21 on: December 06, 2022, 09:19:19 pm »
I did experiments with ListViewFilterEdit in the Examples window. It cannot be applied there easily. The current SearchEdit is tightly integrated to the actual search engine, and it supports many keywords at once.

I applied the patch with some additions. The TextHint looks good although I would like to have the initial focus in the filter.
You could add small SpeedButton to the right side of the edit for clearing the filter. It should have the same icon as other filters, a funnel with a red cross (btnfiltercancel).
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

dsiders

  • Hero Member
  • *****
  • Posts: 761
Re: Bugs in Example Projects window
« Reply #22 on: December 06, 2022, 09:39:00 pm »
TListViewFilterEdit  ? Probably another very good component with no documentation.
...

* Can it handle multiple columns in the list view ? 
* How to add an item ?  Seems its a call to ~.items.add(Item:T); And that item is fgl thingo. I use Pascal because its strongly typed, if I want something that can be any old type depending on the day of the week, I'd use Python.
* How to specify and apply the filter ?
* Can you filter for, eg "Words together" plus another ?
* Will it work with Owner Data ?
* Why does it have no mention in the chm help files ?
* Why is it Red on in the table that appears, eg on https://wiki.freepascal.org/TEdit ?
* Why is there no Example Project showing how to use TListViewFilterEdit ?

There is documentation, but it is not included in the release files nor is it integrated into the LHelp help system. It can be found on the documentation preview at: https://dsiders.gitlab.io/lazdocsnext/lazcontrols/listviewfilteredit/tlistviewfilteredit.html.
« Last Edit: December 06, 2022, 10:04:59 pm by dsiders »
Preview Lazarus 2.3.0 documentation at: https://dsiders.gitlab.io/lazdocsnext

GetMem

  • Hero Member
  • *****
  • Posts: 3953
Re: Bugs in Example Projects window
« Reply #23 on: December 06, 2022, 10:23:24 pm »
@JuhaManninen

1. When down key is pressed in SearchEdit, the listview should get focus with the first item selected(sorry it's too late, I don't have time for a patch):
Code: Pascal  [Select][+][-]
  1. procedure TFormLazExam.EditSearchKeyDown(Sender: TObject; var Key: Word;
  2.     Shift: TShiftState);
  3. begin
  4.     if Key = VK_RETURN then begin
  5.         key := 0;
  6.         if ListView1.items.Count > 0 then
  7.             ListView1.SetFocus;
  8.     end
  9.     else if Key = VK_DOWN then begin //begin change
  10.       ListView1.SetFocus;
  11.       if ListView1.Items.Count > 0 then
  12.       begin
  13.         ListView1.Selected := ListView1.Items[0];
  14.         ListView1.ItemFocused := ListView1.Items[0];
  15.       end;
  16.     end                            // end change
  17.     else if Key = VK_ESCAPE then
  18.         ModalResult := mrClose;
  19. end;

2. BeginUpdate/EndUpdate would prevent flickering when updating the ListView

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4172
  • I like bugs.
Re: Bugs in Example Projects window
« Reply #24 on: December 07, 2022, 07:43:09 pm »
1. When down key is pressed in SearchEdit, the listview should get focus with the first item selected(sorry it's too late, I don't have time for a patch):
I will add your suggestions to the code later.
Now a related question: Why is the Example form KeyDown handler not triggered?
Code: Pascal  [Select][+][-]
  1. procedure TFormLazExam.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  2. begin
  3.     if Key = VK_ESCAPE then
  4.         ModalResult := mrClose;
  5. end;
  6.  
I had to add VK_ESCAPE handling to all controls that get focus. Normally the key should be passed to a parent form if not processed by a control.
I checked some other IDE forms and they work with just a form's KeyDown handler.

The "Close" button in Examples window now has its ModalResult property set to mrClose.
A KeyDown handler setting ModalResult := mrClose works when it is actually called but the form's KeyDown is not called.

To add to the confusion, the above FormKeyDown handler is now also reused for Memo1. There it works.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

GetMem

  • Hero Member
  • *****
  • Posts: 3953
Re: Bugs in Example Projects window
« Reply #25 on: December 07, 2022, 08:12:58 pm »
@JuhaManninen
Quote
Now a related question: Why is the Example form KeyDown handler not triggered?
Most likely the KeyPreview property of the form is false.

dbannon

  • Hero Member
  • *****
  • Posts: 2289
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Bugs in Example Projects window
« Reply #26 on: December 08, 2022, 01:18:16 am »
OK, where it does not work is in the Category CheckBoxes and the row of buttons across the bottom.

The CheckBoxes are created dynamically (to allow auto support for new Categories) so I added a test for VK_ESCAPE to the panel they sit on and that now works fine.

I don't understand why the key stroke is not being passed up from the buttons however. So, I have added a OnKeyDown for the buttons and that does seem to work. Not sure why its necessary.

I also think GetMem's idea of a keystroke moving focus from listview to editsearch is a good one, I have implemented that too. Need to exclude tabs and arrow keys, I hope there are not more things to exclude, maybe different keyboard layouts will be an issue ?

I will open a new Issue and attach patch there.

And please forgive my apparent petulance a few days ago, I was having a bad day but nothing to do with either Lazarus or the good people here.

Davo



Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

dbannon

  • Hero Member
  • *****
  • Posts: 2289
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Bugs in Example Projects window
« Reply #27 on: December 08, 2022, 01:49:43 am »
OK, https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40036

Now ESC closes window from everywhere (?) and GetMem's two suggestions implemented (beginupdate and a keypress moves from listview to editsearch).

Sorry this project has needed so much attention, despite my enthusasim to tackel it, evidence is it was beyond me. Still, I think its OK now but will not, in any way be offended if its decided to drop it.

Reverting back to old Example Window in the IDE would be easy, a global find and remove of *.ex-meta files easy too.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

GetMem

  • Hero Member
  • *****
  • Posts: 3953
Re: Bugs in Example Projects window
« Reply #28 on: December 08, 2022, 11:48:37 am »
OK, https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40036

Now ESC closes window from everywhere (?) and GetMem's two suggestions implemented (beginupdate and a keypress moves from listview to editsearch).

Sorry this project has needed so much attention, despite my enthusasim to tackel it, evidence is it was beyond me. Still, I think its OK now but will not, in any way be offended if its decided to drop it.

Reverting back to old Example Window in the IDE would be easy, a global find and remove of *.ex-meta files easy too.

Davo
Reverting back? No way. In my opinion the Example Window now looks good and works well. Thank you for you efforts! A few minor tweaks can be added, like the ones in your patch above. 

Aruna

  • Full Member
  • ***
  • Posts: 113
Re: Bugs in Example Projects window
« Reply #29 on: December 09, 2022, 12:53:41 am »
OK, https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40036
Sorry this project has needed so much attention, despite my enthusasim to tackel it, evidence is it was beyond me. Still, I think its OK now but will not, in any way be offended if its decided to drop it.
Like Juha asked 'me', why are 'you' apologizing? How is it beyond you when it is already working? Maybe not 100% the way everyone would like to see it work but we are getting there. So please no more talk of this 'people deciding to drop it', and it would be best if you[da] gets back to work on that as and when time permits him to do so. I fail to understand how does a person who chops his own firefood just give up? So uh-uh not happening on my shift  :)

Reverting back to old Example Window in the IDE would be easy, a global find and remove of *.ex-meta files easy too.
No need to revert. I am working on the old 'testall' and we can always put it in LCL/tests as Juha suggested. So we have access to the old 'testall' as well as the 'examples' you are working on. Problem solved and we have the best of both worlds? Now this next question is related to the old 'testall' and if everyone wants a separate thread that would be fine but I am asking here in the mean time.

I ran git blame examples/testall.lpi and below is what is of interest to us.
Code: Text  [Select][+][-]
  1. 87791326d0d (bart     2016-03-04 15:05:52 +0000  87)     <SearchPaths>
  2. 87791326d0d (bart     2016-03-04 15:05:52 +0000  88)       <IncludeFiles Value="$(ProjOutDir)"/>
  3. 5328b9a852b (juha     2019-05-06 11:32:58 +0000  89)       <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
  4. 87791326d0d (bart     2016-03-04 15:05:52 +0000  90)     </SearchPaths>
  5.  

In 2019 Juha added  <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> this works for windows but does not work for Linux
as seen by the error message below.

Code: Text  [Select][+][-]
  1. Unable to write state file for project Project
  2. Error: Unable to create file "/home/aruna/lazarus/examples/lib\x86_64-linux/testall.compiled": No such file or directory
  3.  
The path is all that needs to be fixed so I changed the '\' backslash after /home/aruna/lazarus/examples/lib\ to a forward slash and now it works on linux. My question to you all is the testall.lpi file contents are in XML format so how do I do something like {$ifdef linux} in a XML file for christ sake  ::) OR as is usual in my case I am missing something  obvious?

By the way David you have the same name of a young boy in a biblical tale that had a slingshot and a rock and proceeded to slay the giant Goliath, I am just saying...  :P Go slay them bugs mate! (I am officially done sulking)






« Last Edit: December 09, 2022, 03:36:31 am by Aruna »

 

TinyPortal © 2005-2018