Recent

Author Topic: Find/replace dialogs, with synMemo - help  (Read 9467 times)

mike parr

  • New Member
  • *
  • Posts: 14
Find/replace dialogs, with synMemo - help
« on: February 04, 2010, 08:54:32 pm »
Hi (my first post)

I'm trying to convert delphi code - with find/replace dialogs and a richEdit - to Lazarus, and also use a synMemo..

I think that the main problem is find/replace (I know richEdit differs from synmemo, but I can handle that, I think.

I'm looking for some standard code which links to the find/replace dialogs, and have done lots of searches (including the laz source itself)  - nothing helps me.   
(This question has been asked before - I found an answer, but it is 5 years old, and uses different components.
Thanks in advance - Mike


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Find/replace dialogs, with synMemo - help
« Reply #1 on: February 05, 2010, 12:42:36 am »
In Lazarus the Find Replace dialog is shown by the source-editor (ide\sourceeditor.pp). The source Editor is a wrapper around SynEdit dealing with all the functions that SynEdit does not have itself.

The Replace is called from   TSourceEditor.DoFindAndReplace :
    Result:=EditorComponent.SearchReplace(
      LazFindReplaceDialog.FindText,LazFindReplaceDialog.ReplaceText,
      LazFindReplaceDialog.Options);


The actual replace is done in function TCustomSynEdit.SearchReplaceEx(const ASearch, AReplace: string;
  AOptions: TSynSearchOptions; AStart: TPoint): integer;

The Confirm dialog (pronpt) is shown in a callback in OnReplaceText (Only if the prompt flag is given)

mike parr

  • New Member
  • *
  • Posts: 14
Re: Find/replace dialogs, with synMemo - help
« Reply #2 on: February 05, 2010, 10:55:29 pm »
Thanks Martin
I'm investigating, but am having trouble using units in the IDE.
I have used Projects - Compiler - paths, and added all the Lazarus paths that are suggested, but this does not seem to overcome the compilation errors.  Any suggestions?
Mike

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Find/replace dialogs, with synMemo - help
« Reply #3 on: February 05, 2010, 11:10:37 pm »
It would help to know which compilation error?

You will rarely have to change path info yourself (if you do, you usualy already did something wrong)

If you upgraded lazarus, and have a new fpc version or the fpc path changed for other reasons, then you need to change this in the environment options.
Or do a clean install, after you removed your old settings files from your home/user directory (on windows C:\Users\martin\AppData\Local\lazarus)

If you use components (like SynEdit) the IDe normally adds requirements. Check in the Project-Inspector. The package should be listed as requirement (never add the path to a package, always add the package)

mike parr

  • New Member
  • *
  • Posts: 14
Re: Find/replace dialogs, with synMemo - help
« Reply #4 on: February 06, 2010, 02:59:17 pm »
The error was about unit: LazarusIdeStrConsts
Anyway, I was looking through the synedit examples (in the downloaded synedit package) and I found a search/replace example in Delphi, which is just what I need - so - for this project - I will switch back to delphi - sorry!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Find/replace dialogs, with synMemo - help
« Reply #5 on: February 06, 2010, 03:29:41 pm »
Did you try to use a copy of the unit "FindReplaceDialog" from the ide directory?

the "ide" dir is not a package, but a project of it's own, files in there refer to each other, so you canot simply use them in your project. Yoo would need to either include the ide dir (and sub dirs) in your search (or include/resource) path(s) (may get messy) or copy plenty of other files.

Also note the different licenses (IIRC, no warranty on correctness):
- ide/* files are also licensed GPL, not LGPL
- lcl/* is LGPL with added linking exception
- synedit is at your choice either GPL or MPL

In other words using the LCL you are free to publish your app under any license, including commercial.

using parts of the IDE you are bound to GPL, same for SynEdit (as it is based on the original synedit which already had this license).

 

TinyPortal © 2005-2018