Lazarus

Using the Lazarus IDE => Designer => Topic started by: x2nie on January 22, 2016, 03:45:25 am

Title: Lazarus's missing Delphi features
Post by: x2nie on January 22, 2016, 03:45:25 am
I found a few missing feature that Delphi already has, and Lazarus didn't has yet.
It's about to reduce clicks, because that missing delphi features can be reached by more additional clicks on Lazarus.


1. Forwarding keyboards key from form-designer into Object Inspector.
    (done in 24jan16, rev 51398 issue #29488)
    in delphi, when a form-designer is activated, you can just typing  by keyboard,
    and those keys-pressed will be written to Object Inspector.
    So no need to activate OI to edit property.


2. Double click on any linked-object combobox on Object Inspector will switch the value into next item.
   (done 26jan 2016 issue #0029503)
    I can't do this in Lazarus. What I can do is click dropdown to show the list, read whether the value is on
    there, and click in correct line/value of that dropdownlist.

    Correction: For combobox with property's type of enumeration, boolean or set, it works.
    Only for linked item it doesn't work. For example: "Images" and "HotImages" property of TToolbar.

3. Code explorer doesn't helps enough to jump to procedure implementation.
    There should available in lazarus: an easy way rather than clicks several time, by such adding
     new keystroke: Ctrl+Click / Atl+Shift+Click(?) to jump to method implementation,
     instead of only can jump to interface/declaration.


4.  Object Inspector should able to remember the last selected property (for next selected control).
     OI should select "Text" property in the end of any below activities:
     a) Drop a TEdit in form, change the Text property, drop a TButton, select again the TEdit
     b) Drop a TEdit in form, change the Text property, drop a TEdit (done thanks GetMem)
     (lazarus: none property is selected, it should be "Text" property is selected.)


Well, okay, 4 time click is done in 4 seconds. But repeating that will distracts user (me).
IMHO it would be better if we can reduce known obstacle to increase productivity.


I am ready to implement above features, if I have a clue to do.
Thanks!
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 22, 2016, 10:37:40 am
Help!
How to send a key (keyboard / char) to other form in Lazarus?
Title: Re: Lazarus's missing Delphi features
Post by: howardpc on January 22, 2016, 03:31:01 pm
You need the LazMouseAndKeyInput package (which is included in the standard Lazarus installation).
There is an example of usage at
lazarus/components/mouseandkeyinput/example
which types "hello" into an edit control (as well as demonstrating programmed mouse movement and selection).
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 22, 2016, 05:04:37 pm
@x2nie

3. As a temporary solution, you should record a key combination with the macro recorder:  http://forum.lazarus.freepascal.org/index.php/topic,30790.msg196255.html#msg196255
2. It's working at my side, at least partially(Win7/Laz trunk/FPC 3.0.0). Sometimes I can change the values sometimes not.
1. This one is interesting, indeed a missing feature. As I saw your post, I felt an overwhelming desire to implement it.  So here it is(attachment):
You can find two files(designer.pp and main.pp). Please copy to $(LazarusDir)/Designer and  $(LazarusDir)/IDE, replace the original ones(or if you like apply the DesignerToObjectInspector.patch), then rebuild Lazarus. Please note, this will work with the current SVN version(r51377) and perhaps with the next few ones.

PS: If needed I can create a more polished version and add it to the bug tracker.
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 24, 2016, 04:04:26 pm
@x2nie

In the meantime 1. is already implemented in the trunk(r. 51398). @Ondrej was kind enough to commit it + helped with a few good ideas.
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 03:45:27 am
Thanks you dear all! My Lazarus Trunk is little bit more sexy, and it make the work with designer easier now.


I marked the point (1) as solved.


and I added the point (4)., today.
Without solving the point (4), the point (1) is useless.


IMHO it is our behavior: changing similar (one) property of each controls in whole  form.
So, in this case we don't want to change the selected property into other prop when we are selecting other control.
For sample, Let say we are in changing the "TabOrder" property,
So we select the first control, activating Object Inspector and changing the value of TabOrder of selected control with "0" value.
Next, we select the second control, pressing "1" to changing the TabOrder property of second control.
Next, we select the third control, and (without activate OI) pressing "2" to set TabOrder property of 3rd.
Next, .....


But, when OI (of Lazarus) still can't remember the selected property, we can NOT do this. >:D
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 06:44:40 am
2. It's working at my side, at least partially(Win7/Laz trunk/FPC 3.0.0). Sometimes I can change the values sometimes not.
Wow! yes. I've double checked, and it also working, not for all cases.
The OI combobox's value changed circularly, if the property type is in [enum, boolean, set].
(Boolean is now drawn as checkbox, not combobox).
Meaning: if that combobox is not that types, it can't circular the value by double-click.
Code: Pascal  [Select][+][-]
  1. procedure TOICustomPropertyGrid.ToggleRow;
  2. var
  3.   CurRow: TOIPropertyGridRow;
  4.   TypeKind : TTypeKind;
  5. begin
  6.   if not CanEditRowValue(false) then exit;
  7.  
  8.  
  9.   if FHintTimer <> nil then
  10.     FHintTimer.Enabled := False;
  11.  
  12.  
  13.   if (FCurrentEdit = ValueComboBox) then
  14.   begin
  15.     //either an Event or an enumeration or Boolean
  16.     CurRow := Rows[FItemIndex];
  17.     TypeKind := CurRow.Editor.GetPropType^.Kind;
  18.     if TypeKind in [tkEnumeration, tkBool, tkSet] then //<------ limited type
  19.     begin
  20.       // set value to next value in list
  21.       if ValueComboBox.Items.Count = 0 then Exit;
  22.       if ValueComboBox.ItemIndex < (ValueComboBox.Items.Count - 1) then
  23.         ValueComboBox.ItemIndex := ValueComboBox.ItemIndex + 1
  24.       else
  25.         ValueComboBox.ItemIndex := 0;
  26.       SetRowValue(false);
  27.       exit;
  28.     end;
  29.   end;
  30.   DoCallEdit;
  31. end;    

Possible another type (that can't be double-clicked yet) are "linked object", and "Event".
Sample: "Image" property of TToolbar.




Quote
PS: If needed I can create a more polished version and add it to the bug tracker.
Sure, please do that. And let us know the issue number here.
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 25, 2016, 06:55:59 am
@x2nie
Quote
Wow! yes. I've double checked, and it also working, not for all cases.
I guess you can consider 2 solved too, or if you like you can extend the typekind, just make sure it doesn't introduce regression.

I'm working now on 4, it will be ready today. 3 is more difficult, it turned out that it was requested many time in the past. I'm planning to solve that too, but it will take time.
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 07:05:13 am
@x2nie
Quote
Wow! yes. I've double checked, and it also working, not for all cases.
I guess you can consider 2 solved too,
No it isn't solved yet. I only show the original code. But I am trying the point (2). 8)


Quote
or if you like you can extend the typekind, just make sure it doesn't introduce regression.
Excuse me, what is "regression"? is that related to cross platform issue?
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 25, 2016, 07:16:19 am
Quote
Excuse me, what is "regression"? is that related to cross platform issue?
I mean when you solve an existing bug or extend a feature, but in the same time you introduce another bug. Since lazarus is a complex project, it happens very often.
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 08:59:43 am
@GetMem, I solved number 2.
Below is modified codes of that proc. Would you like to create patch of it?
I've reported this as issue #0029503

AFAIK it wouldn't be a regression, because everything (combobox items) are already exists there.


Code: Pascal  [Select][+][-]
  1. //object Inspector.pp
  2.  
  3. procedure TOICustomPropertyGrid.ToggleRow;
  4. var
  5.   CurRow: TOIPropertyGridRow;
  6.   TypeKind : TTypeKind;
  7. begin
  8.   if not CanEditRowValue(false) then exit;
  9.  
  10.  
  11.   if FHintTimer <> nil then
  12.     FHintTimer.Enabled := False;
  13.  
  14.  
  15.   if (FCurrentEdit = ValueComboBox) then
  16.   begin
  17.     //either an Persistent or an enumeration or Boolean
  18.     CurRow := Rows[FItemIndex];
  19.     TypeKind := CurRow.Editor.GetPropType^.Kind;
  20.     if TypeKind in [tkEnumeration, tkBool, tkSet] then
  21.     begin
  22.       if ValueComboBox.Items.Count = 0 then Exit;
  23.       // set value to next value in list
  24.       if ValueComboBox.ItemIndex < (ValueComboBox.Items.Count - 1) then
  25.         ValueComboBox.ItemIndex := ValueComboBox.ItemIndex + 1
  26.       else
  27.         ValueComboBox.ItemIndex := 0;
  28.       SetRowValue(false);
  29.       exit;
  30.     end
  31.     else if TypeKind <> tkMethod then  {dblClick Event shall jump/create Method in editor}
  32.     begin
  33.       //ShowMessage('ItemCount='+inttostr(ValueComboBox.Items.Count));
  34.       if ValueComboBox.Items.Count <= 1 then //oiNone only. meaning empty
  35.          Exit;
  36.  
  37.  
  38.       // set value to next value in list
  39.       if ValueComboBox.ItemIndex <= 0 then //oiNone or ''(-1).
  40.         ValueComboBox.ItemIndex := 1 // jump to the first real persistent
  41.       else if ValueComboBox.ItemIndex < (ValueComboBox.Items.Count - 1) then
  42.          ValueComboBox.ItemIndex := ValueComboBox.ItemIndex + 1
  43.       else
  44.         ValueComboBox.ItemIndex := 0;
  45.       SetRowValue(false);
  46.       exit;
  47.  
  48.  
  49.     end;
  50.   end;
  51.   DoCallEdit;
  52. end;      


As far, I found there are 3 kinds that OI combobox is working with:
- ordinal types (set, enumeration, boolean)
- method / events.
- persistent.


I exclude events from cycling it's value, because the default behavior of double-click event is: create method in window editor (or jump to method if already there).


So, my additional code is for deal with persistent.
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 25, 2016, 12:58:03 pm
Quote
I've reported this as issue #0029503
You should create a patch, if you're under windows, just download Tortoise SVN, then click Create Patch on the menu, after you finish editing the source. It's much easier for developer to apply the patch.
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 01:06:26 pm
Well,
@GetMem, can you do that (patch) for me? I just dislike making them.
I don't know... I just... a little allergic  ;D :P [size=78%] [/size]
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 25, 2016, 01:16:43 pm
@x2nie
Yes, sure! Just tell me which line has changed exactly.
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 01:21:23 pm
@x2nie
Yes, sure! Just tell me which line has changed exactly.
Above procedure.
(I posted 2 procs. first is original, second is modified)
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 01:33:07 pm
... then click Create Patch on the menu, after you finish editing the source. ...
Well, I tried. Not so bad! (I've sent the patch) :D
Thanks you GetMem. It was easiest way to create patch.
I have been has trouble to remember the steps of creating patch, yours is easy to do easy to remember.
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 25, 2016, 01:33:42 pm
Ok,  I'm glad it's working! :)
Title: Re: Lazarus's missing Delphi features
Post by: JuhaManninen on January 25, 2016, 01:34:58 pm
It's much easier for developer to apply the patch.

Easier and safer. Just copy-pasting a block of code can easily overwrite some other recent change. The "patch" command immediately notices such a conflict and refuses to overwrite it.

The diff format used in patches has other benefits, too. It is easy read and understand by humans. A developer can see from a patch directly if it makes sense or not, even without applying it.
Good revision control systems + the diff format for patches are great inventions! Let's use them.

We have seen people making patches with weird and complicated ways, like making changes to a release version sources and using an external diff tool to compare them against a separate development source tree. The generated diff will then revert all changes since the last release.
Some people have desperately copied files around before making a diff.
None of that is needed. The revision control tool already knows what the latest revision contains and make the diff against it.
Just "svn diff" or "Create Patch" with TortoiseSVN is enough. It almost feels "too good to be true".

Git formatted patches are OK, too, made with "git format-patch".
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 01:44:40 pm
Just copy-pasting a block of code can easily overwrite some other recent change.
.. people making patches with weird and complicated ways, like making changes to a release version sources and using an external diff tool to compare them


Wow it was me! I mean, I am working alone and always using non-diff tool (WinMerge) to compare. :-[



I really hope that someday, just using Lazarus I can create a patch!
Nowadays: Lazarus -> Help -> Report a Bug is useless menu item. 8)

you know, Lazarus has real DIFF tool inside, but no menu to activate it unless the files in editor is edited outside Lazarus by accident .
Title: Re: Lazarus's missing Delphi features
Post by: JuhaManninen on January 25, 2016, 01:51:57 pm
Well, I tried. Not so bad! (I've sent the patch) :D
Thanks you GetMem. It was easiest way to create patch.
I have been has trouble to remember the steps of creating patch, yours is easy to do easy to remember.

I am curious. Did you earlier copy files around and used an external diff tool?

It has always puzzled me that some people who a capable of making valid changes to a huge Lazarus code base, find it too difficult to run "svn diff" command or to click "Create Patch".
It is explained in every SVN tutorial. It is explained in Lazarus wiki. The "Create Patch" in TortoiseSVN does not even need an explanation because it is so obvious.
So, how can it be difficult for a person who is able to fix bugs in a > 2000000 LOC SW project?

Sorry I wrote this, it just feels like an impossible equation for me. :)
Title: Re: Lazarus's missing Delphi features
Post by: JuhaManninen on January 25, 2016, 02:09:21 pm
Wow it was me! I mean, I am working alone and always using non-diff tool (WinMerge) to compare. :-[

Uhhh... :(

BTW, if "working alone" means "working off-line" then I can recommend Git for you. I use it myself, too.

Quote
I really hope that someday, just using Lazarus I can create a patch!
Nowadays: Lazarus -> Help -> Report a Bug is useless menu item. 8)

you know, Lazarus has real DIFF tool inside, but no menu to activate it unless the files in editor is edited outside Lazarus by accident .

No no no!
I see no reason why patches should be made with the Lazarus DIFF tool. Actually I don't see how it would happen technically. It would inevitably require some clumsy and error-prone copy-pasting, wouldn't it?
It is especially dangerous in Lazarus Tools menu because people would create patches from the release version.
No good!
I tried to move the Lazarus DIFF tool to a package but IDE's code depends on it and IDEIntf must be extended. Yes, that tool has been misused for making invalid diffs which are then offered as patches.
It is still in my ToDo list to remove it from the default installation.

Lazarus also has a SVN plugin. You can create patches with it, although the plugin otherwise sucks.
But hey, why would you use Lazarus to create a patch?
TortoiseSVN allows to create it with a single "Create Patch" click. How could Lazarus make it any simpler?
The whole patch concept logically belongs to the domain of revision control tools. Why do you want to turn this simple process into a more complicated process?
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 02:19:11 pm
Quote
Did you earlier copy files around and used an external diff tool?
Yes as always.


Quote
It is explained in every SVN tutorial. It is explained in Lazarus wiki. The "Create Patch" in TortoiseSVN does not even need an explanation because it is so obvious.
So, how can it be difficult for a person who is able to fix bugs in a > 2000000 LOC SW project?
If "a person" was me, it because..., for honest, I don't know what shall I do with *.patch. see?


I know git. But still don't want any patch. I usually only "pull request" github.
patch is not that intuitive for my eye.


Quote
It has always puzzled me that some people who a capable of making valid changes to a huge Lazarus code base, find it too difficult to run "svn diff" command or to click "Create Patch".
Hey, let your puzzle being answered with this caricature (not a joke, but it funny):
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 02:36:37 pm
Actually I don't see how it would happen technically. It would inevitably require some clumsy and error-prone copy-pasting, wouldn't it?
It is especially dangerous in Lazarus Tools menu because people would create patches from the release version.
No good!
wrong. >:D  it would be very good and easy.
1) It should be able to run with svn/git source-coded Lazarus.
2) Current lazarus build/compiling is already able to detect whether svn available.
So if it release version (no svn nor git), just hide the menu. Otherwise the "Create Patch" menu visible.



Quote
But hey, why would you use Lazarus to create a patch?
TortoiseSVN allows to create it with a single "Create Patch" click. How could Lazarus make it any simpler?
The whole patch concept logically belongs to the domain of revision control tools. Why do you want to turn this simple process into a more complicated process?
No, not you, it should I am who say to you, "Why you turn this simple process into more complicated?" ! O:-)
Assumed I am opening+editing+testing the "blablaba.pas" using Lazarus. Why then I need to open command line (console terminal) for getting the patch of the file I am reading?
No need to do that (if Lazarus was just capable).

Well okay, it maybe "a single click". But in fact it would  not really that "single click". I need to open Windows Explorer, right? and then "several click" to open the folder. And wait, I need to type the path of the correct folder or I need to exactly remember the path! whooaa....

I never do that ! (opening folders by clicks). (At least, I did as the last options. I don't want do that.)
What I did is done almost in Lazarus: Ctrl+Shift+F. It will find all founded occurrences of match words I searched. 
Title: Re: Lazarus's missing Delphi features
Post by: JuhaManninen on January 25, 2016, 02:43:35 pm
I know git. But still don't want any patch. I usually only "pull request" github.
patch is not that intuitive for my eye.

Actually GitHub's "pull request" and a patch file are conceptually the same thing. A revision control tool, including Git, stores the revisions as diffs. It is the same diff format that is used in patch files.
Thus doing a "pull request" in GitHub and uploading a patch file into Mantis bug tracker are essentially the same thing. They both offer your code diff to be applied to the main repository.
In both cases applying the diff requires action from somebody else, from a maintainer essentially.
Thus it is very similar also process-wise. A "pull request" can be ignored for a long time just like a patch can, if maintainers are busy or lazy.

Quote
Hey, let your puzzle being answered with this caricature (not a joke, but it funny):

Heh, that's a good one. :)
Title: Re: Lazarus's missing Delphi features
Post by: JuhaManninen on January 25, 2016, 03:02:02 pm
wrong. >:D  it would be very good and easy.
1) It should be able to run with svn/git source-coded Lazarus.
2) Current lazarus build/compiling is already able to detect whether svn available.
So if it release version (no svn nor git), just hide the menu. Otherwise the "Create Patch" menu visible.

Ok, that is possible although I still feel it belongs to the SVN plugin territory.
Many people get Lazarus sources from the fixes branch which is the most stable choice. Fixes branch is not suitable for making patches, they must be made against trunk always. Thus, having sources from SVN is no proof that the IDE should create patches from it.

The current SVN plugin should be replaced with a more generic revision control plugin maybe. It cannot be extended easily and is buggy.
I remember BigChimp, before he passed away, started a plugin that would support also Git and Hg. It is somewhere in his repositories maybe in early alpha state, I don't know. Anyway it would be a good project for somebody to continue.
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 25, 2016, 03:07:13 pm
I know git. But still don't want any patch. I usually only "pull request" github.
patch is not that intuitive for my eye.

Actually GitHub's "pull request" and a patch file are conceptually the same thing.


And, (possibly you aren't noticed that) I do that with really single click inside tortoise git commit dialogbox or sometime inside GithubDesktop while in home.
So, why not just easy as real single click inside Lazarus? 8)

Anyway, who want to create a patch is who have already has the repository (svn/git/hg) in his local machine.
Meaning: user of release version can do nothing for creating patch.




Overall, I respect to your advice. I really shall learn to create patch file and learn how to make them useful.

Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 26, 2016, 08:46:58 am
4. #29510
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 26, 2016, 07:57:40 pm
@x2nie

With r51422 the circle is complete. Thanks @Juha, @Ondrej!
Title: Re: Lazarus's missing Delphi features
Post by: valdir.marcos on January 26, 2016, 09:35:10 pm
With r51422 the circle is complete. Thanks @Juha, @Ondrej!

Is there available time to all these changes still be merged into Lazarus 1.6.0?
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 26, 2016, 09:47:36 pm
Quote
@valdir.marcos
Is there available time to all these changes still be merged into Lazarus 1.6.0?
Probably not, it's high chance for regression. Though it would be nice, if at least the Ctrl + Click feature would make it to Lazarus 1.6. @Juha what do you think?
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on January 27, 2016, 07:31:52 am
4. #29510
Thank you GetMem. That would be great!
I am sick today. Cold flu. I cant check the code now.
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on January 27, 2016, 07:41:36 am
Quote
@x2nie
Thank you GetMem. That would be great!
I am sick today. Cold flu. I cant check the code now.
You're welcome! I hope you feel better soon.
Title: Re: Lazarus's missing Delphi features
Post by: x2nie on February 02, 2016, 03:29:41 am
4.  Object Inspector should able to remember the last selected property (for next selected control).
     OI should select "Text" property in the end of any below activities:
     a) Drop a TEdit in form, change the Text property, drop a TButton, select again the TEdit
     b) Drop a TEdit in form, change the Text property, drop a TEdit
     (lazarus: none property is selected, it should be "Text" property is selected.)


@GetMem, 4.b) is perfect.
But in the end of activity of point 4.a) is nothing (of property) is selected.
Anyway, if in this situation I drop a new TEdit, the "text" property is selected.
Would you like to take attention to solve this?
Title: Re: Lazarus's missing Delphi features
Post by: valdir.marcos on April 24, 2018, 11:55:12 pm
Just curious.
Have all these Lazarus's missing Delphi features been implemented?
Title: Re: Lazarus's missing Delphi features
Post by: balazsszekely on April 25, 2018, 05:16:00 am
Quote
Have all these Lazarus's missing Delphi features been implemented?
It was more then two years ago, but IIRC yes.
TinyPortal © 2005-2018