Lazarus

Programming => LCL => Topic started by: katronix on May 21, 2018, 06:45:20 am

Title: RTF ability
Post by: katronix on May 21, 2018, 06:45:20 am
Hey all,

Doesn't Lazarus have an RTF Editor that it comes with? If not which one is considered the 'best' to use?
If it 'depends on use' why would you pick one over the other?

Thanks,

Chris
Title: Re: RTF ability
Post by: taazz on May 21, 2018, 07:17:16 am
Hey all,

Doesn't Lazarus have an RTF Editor that it comes with?
No, its not cross platform.
If not which one is considered the 'best' to use?
the one that fits my needs but that doesn't say much about yours though.
If it 'depends on use' why would you pick one over the other?
You have things backwards, you specify your requirements and we try to recommend a suite closer to them, as far as I know there isn't a single package that supports 100% of the rtf features.
Title: Re: RTF ability
Post by: Thaddy on May 21, 2018, 09:24:58 am
as far as I know there isn't a single package that supports 100% of the rtf features.
Indeed, not even the MS RichEdit control supports full RTF.... (funny and true)
Title: Re: RTF ability
Post by: tverweij on May 21, 2018, 09:43:15 am
Download the sourcecode of wordpad  to see how Microsoft does it: http://download.microsoft.com/download/4/0/9/40946FEC-EE5C-48C2-8750-B0F8DA1C99A8/MFC/ole/wordpad.zip.exe (http://download.microsoft.com/download/4/0/9/40946FEC-EE5C-48C2-8750-B0F8DA1C99A8/MFC/ole/wordpad.zip.exe)
Title: Re: RTF ability
Post by: dbannon on May 21, 2018, 02:09:54 pm
Both of these are / have Memo like components capable of dealing with RTF
http://wiki.freepascal.org/KControls
http://wiki.freepascal.org/RichMemo

In KControls/Kmemo for example, you can load an RTF file, it displays most (?) of the markup and you can save a file from its contents. Out of the box, you can edit the content but if you want to play with the markup, you need to implement that yourself.
There is an example of doing so. It (the example) does most things nicely but sucks at bullets.

KMemo is 'cross platform' Linux, Windows and Mac, I have not tried to go beyond that.

I have build a medium sort of project (~7K lines of .pas) on kcontrols because of its cross platform credentials. I suspect RichMemo would be faster but for my purpose, it has a number of incomplete bits.

When I started, the author of KControls seemed quite keen to help but perhaps not as active now.

Davo
Title: Re: RTF ability
Post by: katronix on May 21, 2018, 04:03:08 pm
Okay basically I'm looking for an editor where someone could do some typing, and then I want to be able to convert that into HTML, with the correct tags.

I'll look at the KControls, thanks :)
Title: Re: RTF ability
Post by: marcov on May 21, 2018, 04:24:40 pm
Download the sourcecode of wordpad  to see how Microsoft does it: http://download.microsoft.com/download/4/0/9/40946FEC-EE5C-48C2-8750-B0F8DA1C99A8/MFC/ole/wordpad.zip.exe (http://download.microsoft.com/download/4/0/9/40946FEC-EE5C-48C2-8750-B0F8DA1C99A8/MFC/ole/wordpad.zip.exe)

The fact that it has "ole" in the path, probably means it instantiates the richedit control. IOW those sources don't contain the actual core RTF editor.
Title: Re: RTF ability
Post by: Thaddy on May 21, 2018, 06:05:11 pm
The fact it has exe in that link means a troll. Plz remove that!
wordpaddotzipdotexe

My - almost - ten year old knows why......
Title: Re: RTF ability
Post by: HeavyUser on May 21, 2018, 06:21:36 pm
The fact it has exe in that link means a troll. Plz remove that!
wordpaddotzipdotexe

My - almost - ten year old knows why......
And he would be wrong. Its a simple self extracting zip, download and test it for your self before you start pointing fingers, or just because you are a bit dusty around the ears you thing you earned the right to accuse with out proof?
Title: Re: RTF ability
Post by: katronix on May 22, 2018, 02:58:49 am
So I'm looking at KControls, and while compiling the package it had a compiler error in KMemoRTF at line 4030, which says

C := UTF8Copy(AText, I, 1);

Is there something else I need to install before I install KControls? I've checked the readme files and was unable to locate anything.

Chris
Title: Re: RTF ability
Post by: dbannon on May 22, 2018, 05:36:10 am
Chris, you are installing it as a package into Lazarus ?

Did you get the bitbucket version ?  He has stopped formal releases, just get the latest bitbucket revision.

What was the actual compiler message ?

Davo
Title: Re: RTF ability
Post by: katronix on May 22, 2018, 06:34:31 am
Chris, you are installing it as a package into Lazarus ?

Did you get the bitbucket version ?  He has stopped formal releases, just get the latest bitbucket revision.

What was the actual compiler message ?

Davo

I'd actually gotten it from his site as there was no mention of a BitBucket version :) Getting that version now https://bitbucket.org/tkweb/kcontrols (https://bitbucket.org/tkweb/kcontrols) for anyone who finds this later on :)
Title: Re: RTF ability
Post by: katronix on May 22, 2018, 06:47:01 am
After looking again, I see it does have a link to BitBucket, I just missed it the first few times :)
Title: Re: RTF ability
Post by: Thaddy on May 22, 2018, 06:51:46 am
The fact it has exe in that link means a troll. Plz remove that!
wordpaddotzipdotexe

My - almost - ten year old knows why......
And he would be wrong. Its a simple self extracting zip, download and test it for your self before you start pointing fingers, or just because you are a bit dusty around the ears you thing you earned the right to accuse with out proof?
It is not done (anymore) and you should know that. My ears are perfectly OK. I wonder why MS still has this on their websites. It should be considered a security risk. I filed a report against it. It will disappear shortly because of that. It is against MS own policies. (and they tend to do what I say, although I am the self-confessed village idiot on this forum... O:-) )
Title: Re: RTF ability
Post by: katronix on May 22, 2018, 03:39:43 pm
I apologize in advance, I realize this question is likely off topic from the previous question I asked, and possibly off topic for this board.

However in the KMemoEditor demo, it largely just uses the TKMemoFrame which is a pre-defined part of the component. If I wanted to expand upon it, say add my own functionality I should be able to right?

For example, the main menu is installed with:

Menu := FFrame.MainMenu;

How would I add say another Menu to it? I did try creating a Menu on the form, and use:

Menu := FFrame.MainMenu + MenuItem1;

However, this got me:

Main.pas(48,27) Error: Operator is not overloaded: "TMainMenu" + "TMenuItem"

How would I combine the two? (Adding TMainMenu + TMainMenu didn't work either).

Thanks for the help in advance,

Chris
Title: Re: RTF ability
Post by: Thaddy on May 22, 2018, 04:41:28 pm
I contacted MS and they are currently scanning *and removing* or replacing self-extracting files left-overs from the olden days. Given the size of the organization and their infra-structure that can take some time. (hours, days, not months). But they do what they are told. 8-) (Big finger, D.T.)

And a great compliment to Microsoft for taking immediate action.
Title: Re: RTF ability
Post by: dbannon on May 23, 2018, 12:52:01 am
Chris, I have not looked extensivly at TK's demos can no good answer.
Instead, I built my menus (etc) from normal Lazarus components, reasonably clean approach.
Have a look at  my project, https://github.com/tomboy-notes/tomboy-ng
In the "editbox" unit, you will see the KMemo used in this way. There are popup menus but no main menu, however, it would work fine if you added one.
Davo
Title: Re: RTF ability
Post by: wp on May 23, 2018, 01:23:40 am
How would I add say another Menu to it? I did try creating a Menu on the form, and use:

Menu := FFrame.MainMenu + MenuItem1;
No, there is no operator to "add" two menus. You must iterate through the items of the menu which you want to add, create a new menu item in the destination menu for each item to be added and copy the properties.

Here is a small example: the form contains a standard "File" / "Edit" / "Options" MainMenu and a memo which has a popup menu. The code provided copies the popupmenu to the item "Edit" of the MainMenu.
Title: Re: RTF ability
Post by: katronix on May 23, 2018, 03:14:01 am

No, there is no operator to "add" two menus. You must iterate through the items of the menu which you want to add, create a new menu item in the destination menu for each item to be added and copy the properties.

Here is a small example: the form contains a standard "File" / "Edit" / "Options" MainMenu and a memo which has a popup menu. The code provided copies the popupmenu to the item "Edit" of the MainMenu.

Can you expand upon your answer WP? Say I just wanted to add a Help menu with an About option? Or do I just need to modify the original file?
Title: Re: RTF ability
Post by: Handoko on May 23, 2018, 03:21:11 am
Have you downloaded and tried the code wp provided?
Title: Re: RTF ability
Post by: katronix on May 23, 2018, 08:01:34 am
Have you downloaded and tried the code wp provided?

Thanks for pointing it out Handoko, I hadn't realized he had included code.
TinyPortal © 2005-2018