Lazarus

Announcements => Third party => Topic started by: typo on November 11, 2014, 04:25:14 pm

Title: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 11, 2014, 04:25:14 pm
I have just created the wiki page for lzRichEdit.

http://wiki.freepascal.org/lzRichEdit

This component was created to try to solve or at least alleviate the lack a Rich Text Editor component, this component runs on two platforms Linux (GTK2) / Windows, and has different ways to work on both OSs. The rich text control in Windows is provided by a library (API) and so is much faster than Linux. Linux file reading rich text is made by the FPC RTFPars TRTFParser ie the class, with some changes to support images, this class is just slower to treat rich complex text files, the Linux version only supports formatting text, paragraph and pictures and everything Windows supports what Ole and the APIWindows can offer. The two most important properties are the lzRichEdit Paragraph and SelAttributes, one takes care of the attributes of the paragraph and the other attributes of text.

Thanks.
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: BigChimp on November 11, 2014, 05:47:49 pm
I'm confused about the license: Antonio on the mailing list said it's LGPL!?!?
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: typo on November 11, 2014, 05:51:11 pm
Sorry, see by yourself:

http://wiki.freepascal.org/lzRichEdit#License
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: BigChimp on November 11, 2014, 05:55:25 pm
Yes, I noticed that. That's why I'm confused!??!
lzrichedit.zip does not mention license in readme or in doc folder.
In the .lpk package, it mentions LGPL (so not "modified LGPL")

I wonder where the "modified LPGL" comes from?

Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: typo on November 11, 2014, 06:02:04 pm
Maybe it comes from my ignorance about the matter.

See the link again. I have put the whole text present in the pas files.
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: BigChimp on November 11, 2014, 06:07:23 pm
Thank you.

So apparently the information in the .lpk file and the pas files is conflicting:
lpk file: LGPL
pas file (text on wiki): modified LGPL (=LGPL with linking exception)
I'd suggest updating the files so they all match the actual license...

Edit: if you want to change the license in the .lpk to modified LGPL, this text is used in other packages:
Quote
Modified LGPL as in FCL or RTL
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: typo on November 11, 2014, 06:23:39 pm
Edit: if you want to change the license in the .lpk to modified LGPL, this text is used in other packages:
Quote
Modified LGPL as in FCL or RTL

What exactly the file you refer to?

RichBox.pas has the license text I have just copied to wiki.
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: BigChimp on November 12, 2014, 09:02:21 am
The file with the ".lpk" extension. I don't have the source zip here any more so cannot give you the exact filename. Probably lzrichedit.lpk or lazrichedit.lpk or something.

That is the file used by Lazarus to display package information such as description, author, copyright/legal info etc.
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: typo on November 12, 2014, 01:57:59 pm
Well, LPK file is XML and has nothing about license inside it. Maybe you refer to the PAS files which are part of the package. Or to the README file, perhaps.
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: BigChimp on November 12, 2014, 02:16:15 pm
NO I DO NOT REFER TO ANYTHING ELSE BUT THE LPK FILE
YES IT DOES HAVE LICENSE INFORMATION INSIDE. Just search for LGPL:
lazrichedit.lpk
Code: [Select]
<License Value="LGPL"/>
Agreed?
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: typo on November 12, 2014, 02:19:34 pm
Yes.

So license value should be "modified LGPL2" ? The PAS files should have this too?
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: BigChimp on November 12, 2014, 02:23:48 pm
It is up to the authors (all authors!) of the code to change existing licenses. You cannot just change a license

I WAS TALKING ABOUT MAKING SURE THAT:
1. If all licenses in .pas/other files say "modified LGPL"
2. then the lpk file matches those licenses
3. if the author indeed intended to publish under modified LGPL

Once again, I cannot know what license the author intended, but it is not possible to have a package/project with a "modified LGPL" license if any license in any part of the code does not allow "modified LPGL". This is the case for GPL, "normal" LGPL licenses etc.

In short/the easy solution: make sure the authors agree and that the licenses in all parts of the code match.
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: typo on November 12, 2014, 02:28:39 pm
Of course I will not change the license myself, I am asking the author about this.  I only need to know what  to request from him.
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: BigChimp on November 12, 2014, 02:31:16 pm
No problem, it's just that it seems you did not understand what I wrote even when I wrote it repeatedly.
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: typo on November 12, 2014, 02:34:33 pm
Don't worry.
Title: Re: lzRichEdit Windows/Linux rich text implementation
Post by: typo on November 12, 2014, 03:40:40 pm
OK, BigChimp, thanks anyway.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 19, 2014, 01:18:22 pm
Added 4 new methods for Windows:

Code: [Select]
procedure LoadFromFile(AFileName: string);                       
procedure Print(const DocumentTitle: string; Margins :TMargins);   
procedure Redo;                                                 
procedure SaveToFile(AFileName: string);                         

Also added full justification paragraph attibute (see wiki page).

See in demo project how to export to HTML format.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 22, 2014, 09:14:37 pm
Added 2 more properties:

CaretCoordinates
Column :Integer
Line :Integer

CaretPoint
X :Integer
Y :Integer

There is an issue in Linux with an Access Violation when one reopens a project with lzRichEdit component on a form.

Thanks.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Never on November 23, 2014, 04:47:21 am
feedback ***: win7 64 bit  from the demo provided
saves as expected *.rtf and *.html
load as expected *.rtf
print as expected
font change (name,size)as expected
formating as expected
printing as expected
issues:
when searching non english chars the selection mask is doubled
ex: if the string is [astring] and the search term is 'as' the text is found and 2 chars 'a' and 's' are selected
      if the string in editor is 'ασδερτασδ' and the search term is 'ασδ' then the selected text is 'ασδερτ'
when searching non english and english chars the selection mask is doubled/2
ex:
      if the string in editor is 'aαααα' and the search term is 'aα' then the selected text is 'aαα'
@typo congrats great job
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 23, 2014, 06:27:28 am
Thanks for the feedback.

Feedback for Linux is also welcome.

Solution for the issue on Windows: find this line of code in the Example Project:

Code: [Select]
SelLength := Length(FindDlg.FindText);

and replace it by that:

Code: [Select]
SelLength := UTF8Length(FindDlg.FindText);

Thanks.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 23, 2014, 05:57:03 pm
Added 2 more methods:

GetWordAtPoint
Gets the word at the (x,y) position.

GetWordAtPos
Gets the word at the text position.

Thanks.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Never on November 23, 2014, 07:37:06 pm
feedback ***: win7 64 bit  from the demo provided
Steps
open a txt file ex: test1.txt
edit the file ex: set one line align to center
save the file as rtf with name test1.rtf
open the new file test1.rtf
nothing is loaded
the file is saved thought as txt with the extension of rtf
you can confirm this if you open the file with another editor.
from time to time debuger crashes when clossing the app and in session several documntes where loaded but did not figure this out yet to spot exactly when it happens
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 23, 2014, 09:51:36 pm
I use win7-32bit and can not reproduce this. The file is saved with an extension RTF, but is plan text, I can open it on Notepad and there is no formatting info there.

(Unless you mean "no format" by "nothing".)
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Never on November 23, 2014, 10:41:10 pm
open a text file---> file/open
and save it as rtf--->file/save as (select rtf)
and open the saved rtf --->click on the  folder icon and select the saved rtf
nothing is loaded
and if you close the app from the
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 23, 2014, 10:49:23 pm
Oh, yes, now I see. But I can not reproduce the crash.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Never on November 23, 2014, 10:55:59 pm
:) don't worry it will happen have faith lol  :P
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 23, 2014, 11:43:03 pm
It seems that the control does not open an RTF extension with plain text inside it. You can try to change the extension of a text file from TXT to RTF. You could not open it, the control remains empty, even if you can open it in other apps.

The openfile/savefile routines are not working fine. It is not with the control itself.

With PlainText set to False, the plain text is not shown, no matter it has an extension TXT or RTF.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 24, 2014, 02:39:44 am
Well, I think the issue is solved. You can download it from:

http://wiki.lazarus.freepascal.org/lzRichEdit#Download
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Never on November 24, 2014, 09:24:22 am
i understand @typo
just reporting averything i see and it might discourage someone to test further
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 24, 2014, 03:41:13 pm
Thanks for your feedback.

I am not bothered by your reports.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: minesadorada on November 24, 2014, 04:09:13 pm
Very nice component!  Thank you for coding this.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: mig-31 on November 24, 2014, 04:13:22 pm
Nice component, but while GTK2 not Qt?
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: skalogryz on November 24, 2014, 04:35:57 pm
Nice component, but while GTK2 not Qt?
Qt4Pas doesn't have all necessary classes converted.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 25, 2014, 01:53:49 am
Added 2 more properties:

ScrollPoint
X :Integer
Reads and writes the X scrolling position.
Y :Integer
Reads and writes the Y scrolling position.

DefaultExtension
string
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Never on November 25, 2014, 07:36:25 pm
Code: [Select]
lzRichEdit1.LoadFromFile(Odlg.FileName);to
Code: [Select]
lzRichEdit1.LoadFromFile(Utf8ToAnsi(Odlg.FileName)); Also in
Code: [Select]
procedure TCustomRichBox.LoadFromFile(AFileName: string);

......
......
(LowerCase(ExtractFileExt(AFileName)) = LowerCase(FDefaultExtension))
extension is always english

might be helpfull
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 25, 2014, 10:06:11 pm
Thanks.

Added 2 more methods:

GetZoomState
SetZoomState
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Cyrax on November 26, 2014, 03:21:03 am
Are you using web hosted revision control system like github or something alike? I would love to see all source code changes in easily accessible form.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 26, 2014, 11:38:34 am
Yes, but there the files are not updated. When it is OK I will provide a link to the SVN in the wiki.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: skalogryz on November 26, 2014, 02:46:57 pm
Added 2 more methods:

GetZoomState
SetZoomState
those are windows only, I presume?
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 26, 2014, 06:10:45 pm
Yes, some things work only on Windows. But there is no reason why not to implement this. I guess Windows users will be very happy to have those things working fine.

BTW, Linux developers are welcome to help on lzRichEdit.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: snorkel on November 26, 2014, 07:13:47 pm
it would be nice to be able to save the rich content to a stream so it could easily be streamed over the network for like chat applications.
The other thing that would be nice is the ability to append a stream of rich formated data to another instance of the control again
for chat applications.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: skalogryz on November 26, 2014, 08:05:31 pm
it would be nice to be able to save the rich content to a stream so it could easily be streamed over the network for like chat applications.
The other thing that would be nice is the ability to append a stream of rich formated data to another instance of the control again
for chat applications.
Do the opposite - send the data in a format  that's better for the chat protocol, and just style it at the time you insert it to the control.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 26, 2014, 08:17:47 pm
In fact this was one of the more popular tasks for a couple of years in Delphi community.

http://www.delphigroups.info/2/b7/322118.html
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 26, 2014, 08:50:56 pm
@snorkel, if you have interest on having this code on lzRichEdit, please test that code and post the result. I am having problems on porting it to Lazarus, I am having a crazy error message.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 26, 2014, 09:03:23 pm
OK, solved. Probably it will be part of lzRichEdit.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 26, 2014, 11:04:35 pm
Of course it is about selected text, there is no way to get formatted text without selection, but you can lost focus and hide selection.

More 2 new methods:

GetRTFSelection
PutRTFSelection

Usage:
Code: [Select]
var
  str :TMemoryStream;
begin
  lzRichEdit1.SelStart := 0;
  lzRichEdit1.SelLength := Length(lzRichEdit1.Text);
  str := TMemoryStream.Create;
  try
    lzRichEdit1.GetRTFSelection(str);
    str.Position := 0;
    lzRichEdit2.PutRTFSelection(str);
  finally
    str.Free;
  end;
  lzRichEdit1.SelLength := 0;
end;
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: taazz on November 27, 2014, 01:32:00 am
Of course it is about selected text, there is no way to get formatted text without selection, but you can lost focus and hide selection.

can elaborate on "get formatted text without selection"? what exactly do you mean?
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 27, 2014, 01:59:35 am
AFAIK, Windows RichEdit does not allow getting formatted text of a range of text other than for a canvas, which is only the image of the text and not the text info.

For instance:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb788026%28v=vs.85%29.aspx

One needs that the text be selected to get partial text formatting info.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: skalogryz on November 27, 2014, 05:15:03 am
One needs that the text be selected to get partial text formatting info.
well, you referred to this functionality as "a joke" on the mailing list, but this is exactly what RichMemo allows (http://wiki.freepascal.org/RichMemo#GetTextAttributes)
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 27, 2014, 12:57:11 pm
How do you get this?

I referred to this, not as a joke, but as a limitation, maybe an error of approach, because it is impossible on Windows RichEdit.

I think if you need selected text in order to obtain some info, you need to let the user -- or the programmer, as a workaround -- select this text in his/her app.

I think Windows RichEdit is a control for the user  -- in fact, the client  -- and not for the programmers.

More 2 methods added:

ScrollLine
Scrolls for a given delta line position.

ScrollToCaret
Scrolls to the caret.

The ZIP file provided by the link on the wiki is updated.
http://wiki.lazarus.freepascal.org/lzRichEdit#Download

The demo project also demonstrates how to use lzRichEdit in a chat app.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: skalogryz on November 27, 2014, 04:58:51 pm
How do you get this?
Straightforward, change and restore the selection once you got character formatting. But if your API is selection driven you should keep so
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 27, 2014, 05:34:41 pm
I think that selection is for the user -- or, at most, for the application developer as a workaround.

An edit control should provide ways to manage the text on the control without selection. If it does not do that, selection is applicable as a workaround. This is what I think.

Microsoft does what it does because it hates programmers other than from Microsoft itself. Selection should never be used from inside an app.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 28, 2014, 06:02:16 pm
Now I guess lzRichEdit is better than Delphi RichEdit.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Never on November 28, 2014, 07:13:29 pm
@typo i stopped testing because of the bug in the savedialog who seems to be this one

Quote
from time to time debuger crashes when clossing the app and in session several documntes where loaded but did not figure this out yet to spot exactly when it happens
[ http://forum.lazarus.freepascal.org/index.php/topic,26425.msg163291.html#msg163291 ]

your work is very good thank you
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on November 28, 2014, 07:19:48 pm
You are welcome for any other report. Thanks.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: ekimtrah on December 06, 2014, 06:01:01 am
I am very interested in this component, the feature I like most is Get/SetZoomState, which should make it much more useful than RichMemo. I presume it will zoom all text on the lzRichEdit.

The trouble is that I cannot compile the package. I am on Lubuntu 14.04 64 bit, with Lazarus version 1.0.10+dfsg-1 from the Ubuntu repos, and when I try to compile the package lazrichedit.lpk I get the error
Code: [Select]
interfaces/win32/win32wsrichbox.pas(42,3) Fatal: Can not find unit Windows used by Win32WSRichBox.It seems to be trying to compile Windows specific code, however this is Linux, is there perhaps a compiler directive missing somewhere ?

I did try to install later versions of Lazarus according to the Wiki instructions but it still wanted to install 1.0.10, so I did not go ahead. I tried downloading the Deb files and installed them but the ide had path errors when it started up.
Thanks,
Michael.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Nana on December 06, 2014, 12:53:47 pm
Nice component for creating a little word aplication in a buisness program.

i'am a beginner in programming.
Is it possible to insert a logo (load and insert bitmap) and text with adress and date during runtime for creating buisness letter templates or bulk letters and how does this work.

Is it possible to have tabulators, headline,footline  for pagenumbers for example for documents with several pages and a printpreview window.


Best regrads

Nana

Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 06, 2014, 02:54:23 pm
@ekimtrah
Win32WSRichBox is Windows specific code, Linux should use gtk2wsrichbox. You should never have problems with Win32WSRichBox, since Linux can not find it. Anyway, if youi find some Windows in some uses clause outside this file, please try to put compiler directives around it or simply take it out. There is no Windows specific code outside this file.
BTW, you could help me with this component in Linux, please have a look and see if you can help.

@Nana
You could have an example of what you may expect from lzRichEdit by seeing what windows WordPad can do.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: ekimtrah on December 07, 2014, 01:13:39 am
@typo, I could not find Windows in any uses clause outside the file win32wsrichbox.pas.

The word win32wsrichbox is in the file lazrichedit.pas, without a Windows compiler directive. It is also in the file richbox_package.pas but in this case it is inside a Windows compiler directive. Both of these files have the line "This file was automatically created by Lazarus. Do not edit!", so I supposed their contents are defined somewhere else. Is the one in the lazrichedit.pas file the problem ?
Thanks for the quick reply,
Michael.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 07, 2014, 02:26:31 am
This is the uses clause of richbox_package.pas:

Code: [Select]
uses
    RichBox, WSRichBoxFactory, WSRichBox,
{$IFDEF LCLWIN32}Win32WSRichBox,Win32WSRichBoxFactory,{$ENDIF}
{$IFDEF LCLGTK2}Gtk2WSRichBox, Gtk2WSRichBoxFactory, Gtk2RTFTool,{$ENDIF}
  LazarusPackageIntf; 
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: skalogryz on December 07, 2014, 06:38:13 am
I am very interested in this component, the feature I like most is Get/SetZoomState, which should make it much more useful than RichMemo. I presume it will zoom all text on the lzRichEdit.
Why don't you try this property (http://wiki.freepascal.org/RichMemo#ZoomFactor) then?
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: ekimtrah on December 07, 2014, 11:46:47 am
@typo
But the one in lazrichedit.pas is

Code: [Select]
uses
  RichBox, WSRichBoxFactory, WSRichBox, Gtk2WSRichBox, Gtk2WSRichBoxFactory,
  Gtk2RTFTool, LazarusPackageIntf;

Which has no compiler directive, should I edit this file, even though it says

Code: [Select]
{ This file was automatically created by Lazarus. Do not edit!
  This source is only used to compile and install the package.
 }

Michael.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 07, 2014, 02:25:35 pm
lazrichedit.pas:

Code: [Select]
{ This file was automatically created by Lazarus. Do not edit!
  This source is only used to compile and install the package.
 }

unit LazRichEdit;

interface

uses
    RichBox, WSRichBoxFactory, WSRichBox,
    {$IFDEF LCLWIN32} Win32WSRichBox, Win32WSRichBoxFactory,{$ENDIF}
    {$IFDEF LCLGTK2}Gtk2WSRichBox, Gtk2WSRichBoxFactory, Gtk2RTFTool,{$ENDIF}
  LazarusPackageIntf;   

Don't download lzRichEdit from SVN, download it from the wiki link.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 07, 2014, 02:27:13 pm
I am very interested in this component, the feature I like most is Get/SetZoomState, which should make it much more useful than RichMemo. I presume it will zoom all text on the lzRichEdit.
Why don't you try this property (http://wiki.freepascal.org/RichMemo#ZoomFactor) then?

Congratulations, skalogryz, good work. Finally Lazarus will have a RichEdit. Or two.

RichEdit was becoming an item of great frustration for Delphi users.

I have improved the HTML conversion for lzRichEdit, now it converts the metafile in PNG and the image can appear in the HTML pages. Although it is not part of the component itself. And the demo can also demonstrate how to use lzRichEdit in chat applications.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: ekimtrah on December 08, 2014, 12:59:09 am
Why don't you try this property (http://wiki.freepascal.org/RichMemo#ZoomFactor) then?

Thank You, I obviously missed that one.

Don't download lzRichEdit from SVN, download it from the wiki link.

My bad, I thought I had got it from the wiki as that svn command is not in my history, but I just downloaded it from the wiki link and it was fine. Any hints on how to use the zoom ?
Thank You
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 08, 2014, 01:05:06 am
Run the demo project.

Edit > Zoom
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: ti_dic on December 08, 2014, 10:09:07 pm
Hi, the demo on http://sourceforge.net/projects/lazarusfiles/files/lzRichEdit.zip/download don't compile on linux.

some "uses" don't work under linux and some {$IFNDEF WINDOWS}  are missing for replacing TRichEditAlignment by TAlignment
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 08, 2014, 10:50:12 pm
Have you downloaded it from the wiki link?

There are compiler directives around all of them. There should be several modifications after you downloaded it.

RichEdit alignment needs an aditional value, which is for full justification. So TRichEditAlignment has 4 possible values, while TAlignment has 3. For instance, function GetAlignment is declared so:

Code: [Select]
function GetAlignment: {$IFNDEF WINDOWS}TAlignment {$ELSE}TRichEditAlignment {$ENDIF};

Please correct something which is not in this way.

Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: ti_dic on December 09, 2014, 09:23:04 am
I downloaded the sources from the wiki link.
do you have a svn or git? it's will be more easy for me to make a patch.

for example in UParagrafo.pas line 147 the $IFDEF is missing for the case
Code: [Select]
  case TRichBox(RichControl).Paragraph.Alignment of
    traLeft: ComboBox1.ItemIndex:= 2;
    traCenter: ComboBox1.ItemIndex:= 0;
    traRight: ComboBox1.ItemIndex:= 1;
    traJustify: ComboBox1.ItemIndex:= 3;
  end;
i think it's would be more easier to replace TAlignment by TRichEditAlignment in linux case. And in TRichEditAlignment to set inside $IFDEF the  "traJustify", there will be less code to correct.

in UPrincipal.Pas, line 423 the routine GetFileNameHandle should be inside a $IFDEF
etc...

Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Mike.Cornflake on December 09, 2014, 10:07:21 am
Nice :-)   Just wanted to say Thanks @Typo - you're right, this has been outstanding for too long.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: ekimtrah on December 09, 2014, 01:26:05 pm
Run the demo project.

Edit > Zoom

Hi, the demo on http://sourceforge.net/projects/lazarusfiles/files/lzRichEdit.zip/download don't compile on linux.

I could not get it to compile on Linux either (It was from the wiki link, I attached the errors in a file), so I copied a bit of the code from the demo project and put it in a small test project (attached, see TForm1.Button1Click). Single stepping from the call to SetZoomState ends up in TWSCustomRichBox.SetZoomState, which is empty. Is this Linux specific code which hasn't been filled in yet. I would be happy to test any proposed changes.
Michael
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 09, 2014, 02:09:01 pm
@ti_dic

Code: [Select]
case ComboBox1.ItemIndex of
    {$IFDEF WINDOWS}
    3: TRichBox(RichControl).Paragraph.Alignment := traJustify;
    {$ENDIF}
    2: TRichBox(RichControl).Paragraph.Alignment := {$IFNDEF WINDOWS}taLeftJustify
                                                    {$ELSE}traLeft{$ENDIF};
    1: TRichBox(RichControl).Paragraph.Alignment := {$IFNDEF WINDOWS}taRightJustify
                                                    {$ELSE}traRight{$ENDIF};
    0: TRichBox(RichControl).Paragraph.Alignment := {$IFNDEF WINDOWS}taCenter
                                                    {$ELSE}traCenter{$ENDIF};
  end;

Code: [Select]
case TRichBox(RichControl).Paragraph.Alignment of
    {$IFNDEF WINDOWS}taLeftJustify{$ELSE}traLeft{$ENDIF}:
      ComboBox1.ItemIndex:= 2;
    {$IFNDEF WINDOWS}taCenter{$ELSE}traCenter{$ENDIF}:
      ComboBox1.ItemIndex:= 0;
    {$IFNDEF WINDOWS}taRightJustify{$ELSE}traRight{$ENDIF}:
      ComboBox1.ItemIndex:= 1;
    {$IFDEF WINDOWS}traJustify: ComboBox1.ItemIndex:= 3;{$ENDIF}
  end;     

@ekimtrah

Thanks for the info. If you download now, the errors are already corrected. See the code above.

If you make the above modifications, you can run the demo and can see what lzRichEdit can do in Linux. It is not so much. If you can help, I would appreciate. If you can contribute with code, you could use this ( https://sourceforge.net/p/lazarusfiles/discussion/general/ ) or post it here.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: ti_dic on December 09, 2014, 03:57:26 pm
@typo :

thank but i already corrected all compilation error on my computer (when i have wrote my first message), i don't know how to make a patch which i can send to you, without a svn.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 09, 2014, 04:29:31 pm
You can post code directly in that forum, without patch.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: ti_dic on December 09, 2014, 04:37:06 pm
for the all demo compile with the lastest source code i added that :

Code: [Select]
{$IFNDEF WINDOWS}
const
  traLeft = taLeftJustify;
  traRight = taRightJustify;
  traCenter = taCenter;
  traJustify = taLeftJustify;
type
{$ELSE}
TRichEditAlignment = (traLeft, traRight, traCenter, traJustify);    // added
{$ENDIF} 

Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 09, 2014, 04:41:30 pm
Yes, basically the result is the same. But you should not find these errors outside the demo project files.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 23, 2014, 03:45:53 pm
I have had some donwloads from BSD OS. Many thanks, and I ask you for help on lzRichEdit development for this OS.

If you have some code contribution, you can post it even on this forum.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: eric on December 23, 2014, 08:21:47 pm
I'm one of those. I don't have any time at present, but I can say that the version I downloaded about three weeks ago installed in Lazarus 1.2.4 (on PC-BSD 10.1) with no issues, and the main functions worked as described. I have a project which will use this component, but it will be mid-January before I can give it some time.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 25, 2014, 09:43:01 am
Thanks.

I am trying to install FreeBSD on VirtualBox in order to check any issue.

Still could not install graphic interface.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: typo on December 27, 2014, 03:10:32 pm
After many downloads from Germany, now I am getting them also from Poland, known as a great Delphi user. Thanks a lot.
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: Dibo on February 27, 2015, 04:22:06 pm
Is there plan to use Qt in lzrichedit for Qt widgetset and remove Gtk dependencies?
Title: Re: lzRichEdit: Windows/Linux rich text implementation
Post by: skalogryz on February 27, 2015, 04:29:57 pm
qt wrapper is a problem. Try RichMemo (http://wiki.freepascal.org/RichMemo), it has very basic Qt support.
TinyPortal © 2005-2018