Lazarus

Announcements => Third party => Topic started by: CM630 on October 01, 2018, 10:09:35 am

Title: [SOLVED] Insert character panel?
Post by: CM630 on October 01, 2018, 10:09:35 am
Has anybody done a component for inserting characters (like the Insert Symbol panel in Word) into text, which is usually used to insert characters, which cannot be typed by the keyboard?
Title: Re: Insert character panel?
Post by: howardpc on October 01, 2018, 10:19:07 am
If you mean something like Edit -> Insert from Character Map, you already have the source for that.
Title: Re: Insert character panel?
Post by: MacWomble on October 01, 2018, 10:39:12 am
If you mean something like Edit -> Insert from Character Map, you already have the source for that.

Not a goog answer, isn't it?

Where is the source?
Title: Re: Insert character panel?
Post by: wp on October 01, 2018, 10:51:24 am
Why not a good answer?

Take this as a push to navigate through the Lazarus sources. You'll find the character map in folder ide of your Lazarus installation, but you'll have to apply some changes because it refers to other ide units.
Title: Re: Insert character panel?
Post by: Handoko on October 01, 2018, 11:07:01 am
If you/anyone have problem opening the source, or misunderstood what that mean, or .... whatever... here is how to open the source the Character Map Dialog of the Lazarus IDE:

Lazarus main menu > File > Open > browse to and open /usr/share/lazarus/1.8.4/ide/charactermapdlg.pas

Note:
The path above is for Lazarus 1.8.4 Linux.
Title: Re: Insert character panel?
Post by: CM630 on October 01, 2018, 12:02:43 pm

Thanks, I had no idea that Lazarus IDE has that feature (never sought it). :o
I guess it should do.
Title: Re: Insert character panel?
Post by: CM630 on October 11, 2021, 11:06:37 am
I tried to use it...
I created a new project, opened charactermapdlg.pas, added it to the project, tried to compile the project.
The compiler did not find IDEHelpIntf, so I added ideintf.lpk to the project.
Then I added synedit.lpk to the project.

Then I added ...\lazarus\ide\include\ide.inc to the project.
Then I added codetools.lpk.
Then I added debugger.pp.
Then I added debuggerintf.lpk.
And then ..\lazarus\ide\lazconf.pp complained that it cannot find lazconf.inc, so it occurred that there are multiple files with that name in the Lazarus folder, I added the lazconf.inc[/size] in the folder of the OS I use[/size].
And maybe then I added sth. else.
And the project compiled!

But when I did

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button2Click(Sender: TObject);
  2. var
  3.   CharMap: TCharacterMapDialog;
  4. begin
  5.   CharMap:=TCharacterMapDialog.Create(self);
  6.   CharMap.Show;
  7. end;
an exception is thrown in
Code: Pascal  [Select][+][-]
  1. procedure TCharacterMapDialog.FormShow(Sender: TObject);
  2. begin
  3.   AnsiGrid.Font.Name := EditorOpts.EditorFont;
Title: Re: Insert character panel?
Post by: wp on October 11, 2021, 12:16:36 pm
It was not clear from your post that you need a standalone charactermap. The one in the ide folder, however, is integrated into the IDE and cannot be used outside the IDE without changes.

Changes, however, are easy, and I am attaching a demo in which the IDE's charactermap is extracted to be usable in your own programs. If you want to send characters from the char map to an edit or memo control you must write a handler for the OnInsertCharacterMap which has the character selected in the map as a string parameter. If you don't like the font (I increased the font size to improve legibility of the map characters) adjust the EditorFont of the map.
Title: Re: Insert character panel?
Post by: dbannon on October 11, 2021, 12:18:24 pm
And just what is that exception ?

Maybe the font name has not been set in your project ?  Or the object not created ?  I think I would start by removing as much as possible of the Lazarus IDE units from the CharacterMapDlg. (You did make a local copy of it, didn't you ?)

Maybe hard wire a font name until you understand how it all works, EditOpts is from another unit altogether, probably not what you want to use anyway.

Davo
Title: Re: Insert character panel?
Post by: CM630 on October 12, 2021, 07:21:13 pm
...I am attaching a demo in which the IDE's charactermap is extracted to be usable in your own programs. If you want to send characters from the char map to an edit or memo control you must write a handler for the OnInsertCharacterMap which has the character selected in the map as a string parameter...
Thanks, your sample works, I have added it in my project succesfully.

And just what is that exception ?
Maybe the font name has not been set in your project ?  Or the object not created ?  I think I would start by removing as much as possible of the Lazarus IDE units from the CharacterMapDlg. (You did make a local copy of it, didn't you ?)
Maybe hard wire a font name until you understand how it all works, EditOpts is from another unit altogether, probably not what you want to use anyway.
Davo
Looking in @wp's sample, I suppose that the .pas file did not find the .lfm file, so AnsiGrid.Font.Name := EditorOpts.EditorFont; crashed, because it did not see AnsiGrid as a created item.
Title: Re: Insert character panel?
Post by: Bart on October 12, 2021, 07:25:51 pm
@CM630: your reply #9 is unreadable.
Mostly because you use so many font tags and place them in the wronf place or don't close them.

Bart
Title: Re: Insert character panel?
Post by: wp on October 12, 2021, 07:29:53 pm
Really, what is the problem to re-read a message after posting? How can this happen?
Title: Re: Insert character panel?
Post by: Bart on October 12, 2021, 07:30:46 pm
My EPlus editor has a similar map that inserts HTML escape codes.
You can take a look at https://sourceforge.net/p/flyingsheep/code/HEAD/tree/trunk/EPlus/ (https://sourceforge.net/p/flyingsheep/code/HEAD/tree/trunk/EPlus/), the files in question are htmlcharmap.pp and htmlcharmap.lfm.
Any dependancies can be foud either in this folder or in the https://sourceforge.net/p/flyingsheep/code/HEAD/tree/trunk/MijnLib/ (https://sourceforge.net/p/flyingsheep/code/HEAD/tree/trunk/MijnLib/) folder.

Feel free to rip, use or misuse (they are LGPL).

Bart
Title: Re: Insert character panel?
Post by: Bart on October 12, 2021, 07:31:34 pm
Really, what is the problem to re-read a message after posting?
Or use "Preview" button before clicking "Post"...

Bart
Title: Re: Insert character panel?
Post by: dbannon on October 13, 2021, 02:17:04 am
..... Some totally incoherent stuff ....
crashed, because it did not see AnsiGrid as a created item.
....

CM, again, I ask, have you made a stand alone copy of the IDE's version pf Character Map ?   Do that and you can then remove (better initially to comment out) app the external things and just concentrate on the things you want to keep.  It appears however that ANSIGrid may not be being created, again, in an isolated project, you cannot rely on external things that may be triggering, in this case a create.  So, try to find where ANSIGrid is created and see why its not happening ?

But didn't WP send you a working version of a standalone characterMap, looked to me like it was a good starting place (indeed, I downloaded it and tucked it away for future use  8)

Davo

Davo
Title: Re: Insert character panel?
Post by: CM630 on October 13, 2021, 07:51:41 am
Really, what is the problem to re-read a message after posting?
Or use "Preview" button before clicking "Post"...
I am not sure if preview works, I usually check after posting, because the Lazarus forum changes the font size to ultra-small quite often. But this time I have forgotten, sorry.
So @WP's solution works, I have downloaded the eplus.exe to take a look at @Bart's component (the Lazarus inbuilt character inserter needs some changes, IMHO), but for some reason „Invoegen/Speciale tekens“ (actually the whole „Invoegen“) is grayed in the menu.
TinyPortal © 2005-2018