Recent

Author Topic: How to make extension work?  (Read 6060 times)

staratel20

  • Full Member
  • ***
  • Posts: 206
How to make extension work?
« on: February 13, 2016, 09:55:58 pm »
Here I found a very interesting and useful example of extending of IDE:
http://lazarus.lazarus.freepascal.narkive.com/3foITF8v/extending-the-ide

So, how make it works? I take a result code of topic, put it into lazarus-trunk\components\DuplicateLine just created directory as duplicateline.pas. Then I choose(in Lazarus) - Package-New package, and save new package as duplicateline.pkg, add the file duplicateline.pas to a package anf press Compile, Run, Rebuild IDE. When after this I go to Options-Key mapping  , - I even not see filtered command Duplicate line when type patch of word. what I'm doing wrong?
« Last Edit: February 13, 2016, 09:58:06 pm by staratel20 »
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: How to make extension work?
« Reply #1 on: February 13, 2016, 10:16:08 pm »
I did not yet look at the code but did you install the package?
You mentioned that you compiled it and the IDE, but that is not quite the same.
About pressing Run, you can only run a project but not a package.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How to make extension work?
« Reply #2 on: February 14, 2016, 06:06:02 am »
Did you register the unit which has Register procedure?

staratel20

  • Full Member
  • ***
  • Posts: 206
Re: How to make extension work?
« Reply #3 on: February 14, 2016, 09:49:44 am »
Leledumbo: after my "wrong" installation(that I do 2 onces), I try with this checkbox - and my Lazarus give my the message "Stack overflow" (in attached screen). After this I do command "make clean bigide" and Lazarus are drop out with the same message.

Then I try to run my previous version of Lazarus(in another dir) and it works fine. After that it's clean for me that's the problem in config. I do archive of "broken" config and after that - rewrite with config of previous version. After that trunk Lazarus starts normally.

At this point I again try to compile and install package duplicateline.dpk, after what Lazarus give me the message in attachment. Maybe something wrong with this package? Did somebody try my steps without changing the code of unit?

P/s: if it necessary I'll crate the topic on bugtracker with attachment of "bad" config
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: How to make extension work?
« Reply #4 on: February 14, 2016, 10:47:19 am »
At this point I again try to compile and install package duplicateline.dpk, after what Lazarus give me the message in attachment. Maybe something wrong with this package? Did somebody try my steps without changing the code of unit?

*.dpk is usually the suffix for Delphi packages. Lazarus packages have suffix *.lpk.
The last error message means that Lazarus binary was built with the package but it cannot be found any more.

Quote
P/s: if it necessary I'll crate the topic on bugtracker with attachment of "bad" config

No, the bugtracker is for bugs in FPC and Lazarus projects.
Please attach your problematic package here Zipped (only source files) and somebody finds the problem for sure.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

staratel20

  • Full Member
  • ***
  • Posts: 206
Re: How to make extension work?
« Reply #5 on: February 14, 2016, 11:22:29 am »
I attach my config here and the packed dir of package(write in prev post .dpk by the habit, mean .lpk).

Please help me anybody.
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

frakno

  • Jr. Member
  • **
  • Posts: 88
Re: How to make extension work?
« Reply #6 on: February 14, 2016, 12:14:02 pm »
staratel20 - Nice Idea!

My first attempt works fine.
Made it like you've described
Quote
...  file duplicateline.pas to a package anf press Compile   ... 
Corrected the errors - missing packages - by adding IDEIntf, SynEdit
and checked 'Register unit' like Leledumbo said

Compile, Install and works fine.

Thank you

-------------------
FPC 3.0 - Lazarus1.6RC2 - Windows

Lazarus 1.6 FPC 3.0 Windows 10

staratel20

  • Full Member
  • ***
  • Posts: 206
Re: How to make extension work?
« Reply #7 on: February 14, 2016, 01:02:04 pm »
>>staratel20 - Nice Idea!

Nice idea make package from it? If so - is exist way to use this tool without creating package?

Now... I try next steps - Open .lpk file, popup on Required packages - New requirement, then type names  IDEIntf, SynEdit so that appears in tree of Required packages. Then Compile, Install and... Stack overflow again(config rewriting helps).

Maybe I was need to uninstall same(dummy) package duplicateline? But when I go to Package-Instal/Unistall package I don't see it in list.
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: How to make extension work?
« Reply #8 on: February 14, 2016, 01:22:35 pm »
I attach my config here and the packed dir of package(write in prev post .dpk by the habit, mean .lpk).

Where is your source code? The package only contains an auto-generated unit dupliline.
Besides, the procedure Register creates a recursive loop. Makes no sense.

Code: Pascal  [Select][+][-]
  1. procedure Register;
  2. begin
  3.   RegisterUnit('dupliline', @dupliline.Register);
  4. end;

Why did you copy your whole config directory? It is not relevant for this problem.
Just copy the package with the actual source code.

BTW, you don't need to include the compiled files under "lib" directory.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

frakno

  • Jr. Member
  • **
  • Posts: 88
Re: How to make extension work?
« Reply #9 on: February 14, 2016, 01:39:14 pm »
Hey Guys,
as this package can contain a lot of useful things i renamed my try to fExtendIde.
I attach my three files in one zip. Unzip this to a directory. Load the lpk, compile and install and it should work.

The ShortCuts should work. And the menuCommands you should find in the Edit-Menu, last line 'Lines'

If not give me a cry
« Last Edit: February 14, 2016, 01:45:56 pm by frakno »
Lazarus 1.6 FPC 3.0 Windows 10

staratel20

  • Full Member
  • ***
  • Posts: 206
Re: How to make extension work?
« Reply #10 on: February 14, 2016, 02:42:42 pm »
JuhaManninen: thanks, I discover it with wondering. After I press compile the file was overwritten.

frakno: thank for the best answer of topic! The greatest way to learn something - see how it works. Of cause after success installing I'll uninstall and try to successful reproduce all steps)). Think that this easy and useful example must be added to this tutorial:

http://wiki.freepascal.org/Extending_the_IDE#Search_in_all_packages

Thanks again everybody for the help.
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: How to make extension work?
« Reply #11 on: February 14, 2016, 02:49:01 pm »
as this package can contain a lot of useful things i renamed my try to fExtendIde.

Nice, it works. Only the [ssCtrl, ssShift] + VK_UP/VK_DOWN do not work because they are already assigned. I guess they must be unassigned first.

How about MyExtendIde for the name? :)
Ok, just kidding, but "Extend IDE" is rather generic. In fact all packages under lazarus/components directory extend the IDE somehow.
ExtendSourceEditor would be more accurate.

Some minor notes, not important:
LCLProc, SysUtils and IDEMsgIntf are not needed in uses section. There is a nice "Unused Units ..." feature in Refactoring menu.

Code: [Select]
Compile package fExtendIde_pkg 0.0: Success, Hints: 4
fExtendIde.pas(24,7) Note: Local variable "tempStr1" not used
fExtendIde.pas(72,7) Note: Local variable "TextPos" is assigned but never used
fExtendIde.pas(73,7) Note: Local variable "ScreenPos" is assigned but never used
fExtendIde.pas(74,7) Note: Local variable "Filename" is assigned but never used
« Last Edit: February 14, 2016, 02:58:58 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

staratel20

  • Full Member
  • ***
  • Posts: 206
Re: How to make extension work?
« Reply #12 on: February 14, 2016, 03:05:50 pm »
Also MyNewPackage sounds good too))).

Finally - big my fault that I give a name to unit, same with a name of package - that's why all goes wrong.

So steps(returning to 1st post):

1) In Lazarus - New package - Save to folder in directory components\<NameOfNewPackage>

2)  create a Unit1.pas in the same dir and Copy/Paste code from forum

3) Add Unit1 to package and register the Unit1 as described Leledumbo above(set checkbox)

4) Open .lpk file, popup on Required packages - New requirement, then type names  IDEIntf(the same for SynEdit) so that appears in tree of Required packages.

5) Compile, Install

Hope it will be useful so someone :)
Windows 7 SP1 x64, FPC 3.0.0, Lazarus from trunk: http://svn.freepascal.org/svn/lazarus/trunk

CountIdentity, ModeClassName - good property naming
IdentityCount,  ClassNameMode  - bad property naming

frakno

  • Jr. Member
  • **
  • Posts: 88
Re: How to make extension work?
« Reply #13 on: February 14, 2016, 03:13:35 pm »
Good Hint.
Yes, if i add more useful functions i'll rename it to something like
ExtendSourceEditor or similar.

And its true tempStr1, TextPos, ScreenPos and Filename are not needed.
But also   ... uses ... IDEMsgIntf is at the moment not needed.

But i like this approach because it is easy to understand how to extend the SourceEditor  ;) and how to implement
ShortCuts and Menu items.

therefore many thanks to all involved guys and to be gender fair  - to all girlies
:-* from frakno-boy


Lazarus 1.6 FPC 3.0 Windows 10

 

TinyPortal © 2005-2018