Yes, its possible. But its also possible to ride a push bike across the Simpson Desert, I would not want to either !Sorry I should have given more 'context' to the question. The "Testall" that you so painstakingly restructured and organized when I last checked gives me 85 folders containing fully working 'examples'. I was thinking of reading the filenames into a Tlistbox and having the end user choose the example he/she may be interested in. Instead of the TListbox I asked for buttons to make this simpler if that makes sense. So what would be the best way to write a wrapper around the 85 separate examples?
Seriously, its reasonable to include units from other projects if you are very careful about what you do, including a project would be quite awkard.
I prefer to make a copy of an existing unit from an "other" project - make a note at the top where it came from and try not to change it too much. using ifdefs works -And the unix diff or sdiff -bs commands will easily show you the differences between two versions of the same unit.
{$ifdef PROJ1} ....
Davo
(Sorry, short answer / but I don't know what exactly you ask)Please allow me to shed some light on the matter. We have a brand new examples directory put together by @dbannon which currently has 85 separate folders containing separate projects. I want to have a simple way to allow a end user to browse then select the example they want and run/execute it.
Invoke as in create a TProcess?I prefer not to at this time Martin_fr usually TProcess will mean extra ram being used and if things go south I get smoked. Definitely will try what you suggested at a later date just for my learning but right now uh-uh nope.
The forum has tips on how to run an external exe/process. Any of your Projects (once compiled) is an exe, and you can launch that exe (if your Proj1 knows were those exe are)This is the other thing I am running Linux Debian and my executables are deb's :-X
If you meant reusing the code, and compile all in on => create packages for the shared code.Thank you @Martin_fr I will definitely explore ProjectGroups.
On a side note, if you develop in several projects like this (potentially changing the open project often), install the ProjectGroups package into the IDE.
I don't follow that other thread, but first of all: Why not use the existing list inside the IDE?Use it by all mean that is a fantastic piece of work. That being said take another look at it carefully. It does give you a list of available examples but you are unable to select immediately using the list. Try pressing Enter and see.
Menu: Tools > Example Projects ?
But back to your question, still not clear what launch means....
If someone clicks you button, then your code knows the project as c:\lazarus\examples\foo\SomeBar.lpi
That file isn't executable.
Do you want to:
1) Open it in an IDE?
2) Compile it, and run the created exe?
Well, for me Enter works (though that is on Windows / not tested on Linux).I don't follow that other thread, but first of all: Why not use the existing list inside the IDE?Use it by all mean that is a fantastic piece of work. That being said take another look at it carefully. It does give you a list of available examples but you are unable to select immediately using the list. Try pressing Enter and see.
Menu: Tools > Example Projects ?
2)I want to compile it, and run please.Well since compilation, needs to know about packages used by each example the only way you have is to run (TProcess or similar)
ide/main.pp:813: function DoOpenProjectFile(AFileName: string;
I suspect key to what I think you want is in the function that is told to open a project after its chosen in the Example Window -No need for a new parameter. The IDE interface already has functions DoRunProject and DoRunProjectWithoutDebug.Code: [Select]ide/main.pp:813: function DoOpenProjectFile(AFileName: string;
You should add a parameter to that that tells it that after it has opened the project, it should compile and run it.
In most cases, the value to the end user of the Examples is the chance to look at the code. yep, they might compile and run to ensure its the example they think it is but browsing across the code is the benefit.Yes, the request sounds unusual. Usually people want to look at an example project's forms and/or code for a while before running it. Also, pressing F9 is a rather small task.
No need for a new parameter. The IDE interface already has functions DoRunProject and DoRunProjectWithoutDebug.Ah, I did not look through the code, just grepped for the call its using now.
There can be an option for ExampleWindow to run a project right after opening it.
I opened the Example Projects window after a long pause. The list is empty. :(Hmm, thats surprising, it generates its list of examples at each startup, does not cache that content in PCP.
.......
The default config is old and must be corrupt somehow.
I must delete it and tweak the settings again. I will lose file and project history and some settings but it is OK.
I guess when I would want to do such project, I would invent my own little scripts that be loaded at runtime into my app, txt/xml/json/whatever....I called them example metadata files, <projectname>.ex-meta, json !
So I would have a prepared ListView (one visible column for a mini project description and invisible columns for filepath and parameter switches)Image attached !
Optional have some TImage display snapshot of GUI showing the used control.We forgo the images now because of the size issues but its possibly an online system might develope in the future.
Offering a "Run" and a "Show" button, run would compile and run the actual .lpi/.lpr file and show would open project in IDE.We "copy to Work Area" (because in some *nix installs, the main copy of the Examples is in read-only space). The IDE then opens automatically and displays the project. The user can, if they choose, press the Run button. Its pressing that Run button Aruna wants to avoid.
An example for a script could be looking like this (.ini file exemplary since its usage is enorm simple for everyone) .....Pretty close, we also have Keywords and Categories to make searching easy. See attached image.
Well, for me Enter works (though that is on Windows / not tested on Linux).This is easily fixed with ListBox1KeyUp or ListBox1KeyDown and checking for #13.
Of course, "Enter works" once I selected the listview. By default it is on the filter edit. It would be a nice extension, if e.g. the up/down keys would affect the selection in the list, even while the filter has focus.... And then consequently enter could be made to work.... But that is another story.If I remember right the TListBox has a built-in search functionality? I was actually wondering why David used a separate search text box? The way it is right now when searching the results are displayed only after you have typed in what your are searching for and then pressed the enter key. Until you press the enter key no possible matches/results are shown/updated. If we use the built-in functionality that comes with the TListbox when searching the results are updated instantly. Anyway, this is not a big issue I am just sharing what I found when I was testing. I am sure there must have been a very good reason he did things the way they are now. Then again this behaviour could be happening just on my Linux system?
Yes well, if you just quickly want to run each example that is a different usecase.Yes there is a reason why I want to do this. I will get to that in my reply to what Juha has said in this thread. Have patience and have faith.
Well since compilation, needs to know about packages used by each example the only way you have is to run (TProcess or similar)True and fair enough...
lazbuild demo.lpi and then run the exe.
So when you click, you will have the time that compilation takes... Unless you have a batch job, and precompile them all.
However you need to find where the final exe was put by lazbuild, otherwise you want be able to run it.
Not sure how to do that best. Maybe read the lpi, and see if an output for the exe is defined?
Alternatively, you could have a stand alone app that displays the list of examples (easily copied from existing exampleswindow code) and it would compile (using lazbuild) and run the resulting app (using, sorry, TProcess).This is what I was also thinking. Aargh.. TProcess eh? Oh well if there is no other way so be it :-\
> .....which currently has 85 separate folders containing separate projects.Oh dear I totally missed the other examples. Thank you for reminding me.
Please don't forget all the "other" example projects, there are many more in the Lazarus SRC tree associated with the relevant parts of Lazarus code. There are a touch over 200 from memory.
I cannot think of a practical way to do it otherwise. And, honestly, I don't see a need. In most cases, the value to the end user of the Examples is the chance to look at the code. yep, they might compile and run to ensure its the example they think it is but browsing across the code is the benefit.Agreed 100% but there is a corner case which to me is rather important because 'I' had to go through that pain and grief and if I am able to do something that will make life easier for someone else and ensure they do not have to go through the same pain and grief, why not? Again this is just my own thoughts and opinion I am not asking/requesting changes or new implementations in the code. Things are fine the way they are.
Nothing, but don't expect to see me riding one across the Simpson. https://www.traveller.com.au/dune-busters-crossing-the-simpson-desert-go0wjx and it will be over 45 degrees tomorrow.Sweet Jesus, 45 degrees celsius?
Nothing, but don't expect to see me riding one across the Simpson. https://www.traveller.com.au/dune-busters-crossing-the-No, if its -29 outside, they should be waiting for the rescue team to arrive and take them away from such a terrible place.You get used to it after a while. I have a friend he works at the Air base at Cambridge Bay way up north in Nunavut try Googling current weather Cambridge Bay, Nunavut. Actually let me just give you a screenshot and my apologies to everyone this is quite unrelated to coding or anything Pascal related but may make you appreciate the warmer weather you all may have :)
Hi, now let me try and clear up this mess I seem to have caused. I am not, I repeat not requesting any changes in the code. I was simply sharing my own experiences and observations.QuoteIn most cases, the value to the end user of the Examples is the chance to look at the code. yep, they might compile and run to ensure its the example they think it is but browsing across the code is the benefit.Yes, the request sounds unusual. Usually, people want to look at an example project's forms and/or code for a while before running it. Also, pressing F9 is a rather small task.
Still, if somebody wants such an option, it makes no harm to others.
Many years later, actually, decades later I stumbled across gtk2 and that codebase had examples ( Google GTK+ Demo ) and suddenly I had what was missing all these years. Something I could run and immediately see what that piece of code did.
My apologies if at any time what I have said made anyone think I was asking for changes. I hope this will help clear up things.Why do you apologize? Asking for changes is perfectly OK, but then you must be prepared for somebody opposing your suggestion. That is how FOSS development works.
[Edit] Oops, actually it works with a clean Lazarus configuration, like "./lazarus --pcp=~/.lazarus_test &".Why not keep a backup of that old config? Then you do not lose anything :) You delete that config all that history goes POOF!
The default config is old and must be corrupt somehow.
I must delete it and tweak the settings again. I will lose file and project history and some settings but it is OK.
How is it possible that nobody has noticed this?Most experienced and knowledgeable programmers rarely look for examples. That could be why... :)
......It does give you a list of available examples but you are unable to select immediately using the list. Try pressing Enter and see.
.....we have to run it by pressing F9 to see what it looks like. More keystrokes again.Or one click of the green triangle, its a GUI, use the Mouse Luke !
Or once you select the example you have to copy it to the work area then open it.No ! All you need do is double click on a project, that will select it, copy it to the work area, open the IDE on it. Its a GUI, use the mouse.
The way it is right now when searching the results are displayed only after you have typed in what your are searching for and then pressed the enter key.Yes, there is no reason while I did not implement Search While You Type, there is even a comment in the code where I note that would be a better way, its easy. Maybe I will implement that. Further, it should remove the search prompt when you click into the search box, again something I should have done. (Incidentally, something my own app does do in similar circumstances)
I guess those gtk examples, you had to compile them yourself (gcc), or open them in an editor that could run gcc => so they are very likely like our examples....Yes we had to use gcc but with a very strange set of flags I had not seen before
IMHO, 2 would be helped by having examples likeI am working on a demo that does this :)
- Compare all type of buttons
- Compare all type of "text" (label, static-text, caption, OnPaint, ....)
...
[quote author=JuhaManninen link=topic=61473.msg462655#msg462655 date=1670178125]
It is basically a meritocracy. Those who contribute quality code get more voting power.
If you provided a patch that makes the ExamplesWindow to run a project after opening it, you would get much more attention and the patch would very likely be applied. Now it is just vague suggestion which nobody takes seriously. :)
I am working on the code but taking things slow like I was advised to do :)FYI:So what is the latest with your ExamplesWindow bug? In a new thread of course :)
I will study my ExamplesWindow bug further tomorrow and start a new thread about it.
Wrong, I did in fact implement Search While You Type. I am not sure how Aruna thinks its not there, has been there since early days. With each keypress in the EditSearch, the contents of the ListView is updated.....The way it is right now when searching the results are displayed only after you have typed in what your are searching for and then pressed the enter key.Yes, there is no reason why I did not implement Search While You Type,
Sounds like you like to use keyboard commands while using a GUI. Personally I use the mouse where ever possible in a GUI but when in a terminal window, thats where I use the keyboard. I am a vi user for example.That depends on what is involved at any given time and what I may be trying to do. It has been years since I last used vi, now a days most of the time I use Geany (https://www.geany.org/l)
Or one click of the green triangle, its a GUI, use the Mouse Luke !Tsk..Tsk.. Luke does not have the IDE CoolBar enabled so I do not have that green triangle. Just to prove a point (humour me ok) disable the mouse. Pull that USB cable out, please. If it's a wireless mouse pull out the dongle. Now enable that IDE CoolBar and if you are able to make that green triangle work using that keyboard I will never dispute or oppose anything ever again. Prove me wrong Yoda :P I prefer not to assume anything about an end user's system ( especially guys like us ) who may have disabled the IDE CoolBar to regain some screen real estate or for whatever reason.
But don't forget, not all Example project have a GUI, several do something "behind the scene". For example, there is one that generates a PDF from some content, you only know its run by looking for a fresh PDF in the working directory.Ah.. thank you. Good to know..
Yes, there is no reason while I did not implement Search While You Type, there is even a comment in the code where I note that would be a better way, its easy. Maybe I will implement that. Further, it should remove the search prompt when you click into the search box, again something I should have done. (Incidentally, something my own app does do in similar circumstances)Yes I saw that a few minutes back when I started to go through your code. No biggie we will fix things soon.
And, while I was testing why you think the Enter key does not work, I have triggered an AV. Some some work on my part is needed !Huh? Say what? Oh my... FTW is a AV? Anti Virus? Audio Visual? AV as in Adult Video? Jokes aside I seriously have no clue what you meant by AV? Hope it is nothing serious.
Aruna, I suggest you make a standalone project that does what you want, as I suggested before, grab the code that reads the project meta data from Lazarus, uexampledata.pas in particular. Make something that works and then you can consider if it remains as stand alone or implement it as a Lazarus plugin (as the Example Window is). If people like it, they can choose to plug it in, if the developers like it, they can include it with eg, bigide. Its vastly easier and quicker to develop something standalone and later integrate it into a something like Lazarus.Yes David your absolutely right and spot on and this is what I think I will try and do. I also felt a plugin will be the best way to go.
On the other hand, having it standalone may not be a bad idea, it means you could run it and look at a example project without disrupting the project you are working on. My solution to that is to open the Example source in a browser from the remote repository but GitLab's syntax highlighting leaves a lot to be desired.I actually once opened up two separate instances of Lazarus IDE and opened two different projects and had absolutey no issues switching between them Lazarus managed everything beautifully. I was again amazed and humbled.
As Linus says, shown me the code !Uh-Uh and Hell NO! Very bad idea. I am not showing Linus anything until we have this working bug free. Even then am not showing him anything. Yes I am scared of Linus and GregKH and I am even more afraid of Valdis but that is another story for another time.
If you need any help, do not hesitate to ask, looks like I am going to be refreshing my memory of the present code right now anyway so good time to ask !Thank you very much David for offering to help. Yes I will need help understanding what you have done in the 'package' the *.lpk I meant. Please try to understand what may be obvious to you may not be so visible to a new comer like me so have patience when I may ask silly questions. It is 42 minutes after midnight here in Toronto been a long day for me I am a wee bit tired so will be calling it a day soon. I will take you up on that offer come tomorrow morning.
Wrong, I did in fact implement Search While You Type. I am not sure how Aruna thinks its not there, has been there since early days. With each keypress in the EditSearch, the contents of the ListView is updated.....David please watch this to the very end very carefully: Examples Window Seach Text Not Updating ListBox (https://youtu.be/sSbfbrRiJyA) it is only 3 minutes.
You are aware we also have gVim (https://www.vim.org/download.php) right?Hmm, that probably reinforcess my point. In Text mode, use Text tools. In GUI mode, use GUI tools. There is a pattern there ....
Tsk..Tsk.. Luke does not have the IDE CoolBar enabled so I do not have that green triangle. Just to prove a point (humour me ok) disable the mouse.Now I understand, have I got a solution for you ! Open a terminal, type fp and press enter. Problem solved.
Oh my... FTW is a AV? Anti Virus? Audio Visual? AV as in Adult Video? Jokes aside I seriously have no clue what you meant by AV? Hope it is nothing serious.An Access Violation, for this purpose (only), a Seg Fault https://xkcd.com/371/
Watch this video ...What, after you mention Adult Videos ? Ok, I watched it, very unexpected. I note that you have only 166 Examples available. Are you sure you are using lazarus-main from the Official Lazarus gitlab site ? https://gitlab.com/freepascal.org/lazarus/lazarus ?
So what is the latest with your ExamplesWindow bug? In a new thread of course :)I created a new thread "Bugs in Example Projects window".
Interesting, may be a linux bug.Wrong, I did in fact implement Search While You Type. I am not sure how Aruna thinks its not there, has been there since early days. With each keypress in the EditSearch, the contents of the ListView is updated.....David please watch this to the very end very carefully: Examples Window Seach Text Not Updating ListBox (https://youtu.be/sSbfbrRiJyA) it is only 3 minutes.
Now I understand, have I got a solution for you ! Open a terminal, type fp and press enter. Problem solved.Oh man this is a blast from the past and I suppose that is one way to solve a problem. Thank you I have a new toy.
My work here is done. O:-) Queue the riding off into the sunset music .....45 degrees you said? Riding off into the Simpson desert sunset is going to make Mr.Clint Eastwood have issues because that is his job :-D
(The CoolBar buttons are speed buttons, they don't have a tab stop. But, honestly, Lazarus is meant to be used with a full GUI. Running it without the cool CoolBar really does not make sense IMHO. But even without the green triangle, there are Menu short cuts and they a do have tab stops .....)Relax I was just messing with the IDE, the CoolBar will be enabled but after I am done testing and messing with the ide first. Know your tools well said Yoda to Luke and Luke said to yoda ya-ya I know... use the mouse Luke :-D
An Access Violation, for this purpose (only), a Seg Fault https://xkcd.com/371/Serious request here please consider expanding any and all acronyms after this. I had no idea what AV meant and there may be others out there who are lost just like I was.
Watch this video ...
What, after you mention Adult Videos ? Ok, I watched it, very unexpected. I note that you have only 166 Examples available. Are you sure you are using lazarus-main from the Official Lazarus gitlab site ? https://gitlab.com/freepascal.org/lazarus/lazarus ?See..? I was not fibbing and I am not sure which branch I am on but I will now delete everything and start from scratch with lazarus-main.
There should be about 205 Example Projects, has been for over six months.
Or, perhaps, are you running very old hardware that is not updating in time ?Here you go this is my setup: system info bare metal and friends (https://arunajh.neocities.org/davo/system.html) you tell me if it's ancient hardware or not.
I wonder if I should have a checkbox, "Do NOT SWYT" for people who's systems are not capable of keeping up with the demand.[/quote] Please don't not even in jest. Never discourage anyone from exploring the codebase or going bald by doing so. Some folks take things literally and may simply walk away after reading something like "Do NOT SWYT"
OK, so, now you have had time, what do you think of the cool (but no coolbar) fp text IDE ?First impression was omg this is sweet. I am yet to do anything useful with it. But definitely beautifully designed text interface very impressive. Now Luke has to get text mode fp ide to talk to the mouse. Just kidding mouse works fine in my shell/terminal. :D
Hi Juha I will be happy to send it in please give me a little more time.So what is the latest with your ExamplesWindow bug? In a new thread of course :)I created a new thread "Bugs in Example Projects window".
BTW, please provide your fixed / improved version of the TestAll project at some point so we can add it to lcl/tests or somewhere.
The latest changes in "main" for TestAll before it was deleted should be included.
Interesting, may be a linux bug.Yes could be a linux bug or could be just my system. Debian is usually rock solid, stable and robust with zero surprises this being said when it does decide to surprise you things are definitely no longer fun :)
@dbannon: That should be a filter edit (there is a special control). The "Search here" should be .TextHint, i.e. you don't need to clear it...@Martin_fr please have a look at this, we already have this functionality built in to TListBox: TListBox built-in search+filter functionality (https://youtu.be/PfuiRoJxpc8)
@Martin_fr please have a look at this, we already have this functionality built in to TListBox: TListBox built-in search+filter functionality (https://youtu.be/PfuiRoJxpc8)Why? Because the Examples window does not use TListBox. It uses TListView.
Oh dear, you are right I am using GTK and that could very well be native behaviour I totally forgot that.@Martin_fr please have a look at this, we already have this functionality built in to TListBox: TListBox built-in search+filter functionality (https://youtu.be/PfuiRoJxpc8)Why? Because the Examples window does not use TListBox. It uses TListView.
Besides the feature in TListBox you demonstrated is a search, not a filter, and it depends on a widgetset's native behavior. May not work the same on every platform.