Recent

Author Topic: SOLVED: Notepad++ plugin: conversion questions from Delphi  (Read 27365 times)

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Notepad++ plugin: conversion questions from Delphi (ongoing)
« Reply #15 on: August 18, 2012, 04:00:22 pm »
Attached the fix for the weird chars. StringToWideChar sets a terminating #0 at DestSize but forgets to convert or copy the terminating #0 of the input string. So the resulting string is in most cases too long. Deserves probably a bug report... fpc 2.7.1

I guess you where lucky that the memory area used to copy the WideChar was zeroed at the correct location.

Quote
How does one print unicode text though instead of the Hello World stuff? You'd presumably have to use unicodestring (=UTF16) characters?
The template was made in 2008 before the unicode Delphi IDE. It contains a lot of string conversions, as we like them in fpc  :D

Quote
Also, why don't we have huge problems with GUI in the main program as well as in the DLL? Because the main program does not use the LCL or something?
The problem with LCL in a dll is that a second message pump is initialised. 2 message pumps results in one or the other dealing with messages that he shouldn't receive and the other way around, messages that are never received by the one that needs it. The re-parenting of forms seems to work nicely with the Docking Test which is probably a matter of luck. The modal about form will disappear to the background however when you click on the Notepad++ window. That is a consequence of the fact that the LCL simply doesn't know about the main app.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Notepad++ plugin: conversion questions from Delphi (ongoing)
« Reply #16 on: August 18, 2012, 04:07:35 pm »
Got it, thanks.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Using the Unicode version and removing the define indeed worked on the ANSI version, so I've merged the two in mercurial.
I've updated the readme/copyright notice with our names and dates so people can get an idea when the stuff last worked ;)
https://bitbucket.org/reiniero/notepad-pluginlazarus

Going to announce this on the forum, and ML, as well as on the Sourceforge Notepad++ ML as the first release, feedback welcome.

If it's been working for a while, I'll submit the code for inclusion in the sourceforge plugins project.

Thanks again for the help, everybody!
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

eny

  • Hero Member
  • *****
  • Posts: 1617
If you use the free Notepad++ text editor, you might have wanted to write a plugin for that in FPC/Lazarus.

Ludob and I have ported over the Delphi "Hello World" template so now you can try and do exactly that...
Good stuff again  :D

Did a quick compile and installed in NP++ and it works out of the box.
Windows 7 Professional with the 32-bit stable package (0.9.34.4; FPC 2.6.0)
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Thanks, glad it works ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

eny

  • Hero Member
  • *****
  • Posts: 1617
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #20 on: October 07, 2012, 02:29:54 pm »
Did some more testing.
The latest version (739b246425f8) does not compile (.res file missing) so used the res file from the first announced version (71b26932fe41).

I'm trying to get the plugins folder by calling Npp.GetPluginsConfigDir.
But this only gives back one character.
(Well actually I'm trying to get the name of the active file, but this was a starting point.)

Any ideas what goes wrong?
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #21 on: October 07, 2012, 04:16:01 pm »
@eny, regarding the resource: noticed we're missing the tbtest.bmp required by helloworldres.rc

You could try extracting it from the original res file or perhaps adding some small bmp and try if it works...
I'll attach it to the mercurial repository when you have it.

Regarding your other question, no sorry, no idea, and I'm a bit busy with other stuff so can't help you there...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #22 on: October 07, 2012, 04:18:33 pm »
Just committed ed3a3ec29b89 with some bogus bitmap. No time to test; please report problems ;)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

eny

  • Hero Member
  • *****
  • Posts: 1617
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #23 on: October 07, 2012, 08:02:31 pm »
You could try extracting it from the original res file or perhaps adding some small bmp and try if it works...
Used the .res file from the previous version and that seemed to work.

Quote
Regarding your other question, no sorry, no idea, and I'm a bit busy with other stuff so can't help you there...
NP, thx for answering.
I'll see if I can get it working and report back if and how I fixed it.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #24 on: October 08, 2012, 08:52:30 am »
I'm trying to get the plugins folder by calling Npp.GetPluginsConfigDir.
But this only gives back one character.
(Well actually I'm trying to get the name of the active file, but this was a starting point.)

Any ideas what goes wrong?
NPP is unicode so I guess you are getting a PWideChar.

eny

  • Hero Member
  • *****
  • Posts: 1617
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #25 on: October 08, 2012, 10:12:20 pm »
NPP is unicode so I guess you are getting a PWideChar.
Yeah I thought so; translating the wide string to ansistring did the trick.
Next step: fleshing out my plugin and making the framework/plugin template a bit easier to use.
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

eny

  • Hero Member
  • *****
  • Posts: 1617
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #26 on: November 11, 2012, 04:31:11 pm »
Another update on the NPP plugin. All seems to be working as hoped now.

I've done some rewriting to make the source easier to use (removed the global variable NPP references; cleaned up the superfluous 'self.' references and put all generic dll-specific code in the nppplugin.pas source).
Also combined all sources in a package that can now be added to a newly created Notepad++ project and updated the demo source to make use of the package.

Only tested with the unicode version so far (cause that's where I'm busy developing a plugin for  :D).
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #27 on: November 11, 2012, 04:48:28 pm »
Great eny, thanks a lot!

Had submitted the original version to the guys at Sourceforge's npp plugin project but no reaction yet.

Will test your version in the near future and submit it... makes a nice diversion of dealing with debuggers that won't work to decipher cryptic database return values... ;)
« Last Edit: November 11, 2012, 04:53:05 pm by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #28 on: November 11, 2012, 05:02:18 pm »
I updated the repository at
https://bitbucket.org/reiniero/notepad-pluginlazarus
(haven't tested it yet).

Edit: compiles and runs nicely on Notepad++ unicode.

Thanks, eny!
« Last Edit: November 11, 2012, 05:27:08 pm by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

eny

  • Hero Member
  • *****
  • Posts: 1617
Re: SOLVED: Notepad++ plugin: conversion questions from Delphi
« Reply #29 on: November 11, 2012, 07:07:14 pm »
Edit: compiles and runs nicely on Notepad++ unicode.
Good stuff  :D
I also managed to get my 'New Project' wizard for my own custom projects working yesterday.
So when I can find some time this week I'll also create a 'Notepad++ plugin' project wizard.

Note that I haven't updated the readme yet. And the text does no longer describe correctly what to do when setting up a new NPP Plugin project. (A new NPP Plugin project wizard will make this obsolete obviously :))
At the moment simplest is to copy/paste from the HowdyWorld demo and set -dNPPUnicode in the compiler options.
« Last Edit: November 11, 2012, 07:11:38 pm by eny »
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

 

TinyPortal © 2005-2018