Recent

Author Topic: Richmemo not working on linux  (Read 5534 times)

calebs

  • Full Member
  • ***
  • Posts: 190
Richmemo not working on linux
« on: June 08, 2016, 11:36:20 pm »
hello all, i've made a program that loads some text in a window.
In windows (xp, 8) work fine, shows the formatted text but on linux mint (mate, cinammom, lxde, xfce) it shows the window but doesn't load any text. (it's empty).
It's the same program that i run on windows/linux.
I've downloader lastest version from repository r4695, replaced, but it behaves the same.
Any hint?
Thanks

calebs

  • Full Member
  • ***
  • Posts: 190
Re: Richmemo not working on linux
« Reply #1 on: June 09, 2016, 12:36:46 am »
Testing i've discovered that the function is not working is parse in richmemoML or maybe im using it bad. I use some kind of html like to format the text.

i've added the ifdefs for windows/linux to test it

I'll pass the program here
Code: Pascal  [Select][+][-]
  1. unit ventanatextomejorada;
  2.  
  3. {$mode objfpc} {$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  9.   ExtCtrls, Buttons, StdCtrls, RichMemo, richmemoml;
  10.  
  11. type
  12.  
  13.   { TForm2 }
  14.  
  15.   TForm2 = class(TForm)
  16.     BitBtn1: TBitBtn;
  17.     BitBtn2: TBitBtn;
  18.     BitBtn3: TBitBtn;
  19.     Label1: TLabel;
  20.     Panel1: TPanel;
  21.     RichMemo1: TRichMemo;
  22.     procedure BitBtn1Click(Sender: TObject);
  23.     procedure BitBtn2Click(Sender: TObject);
  24.     procedure BitBtn3Click(Sender: TObject);
  25.     procedure FormCreate(Sender: TObject);
  26.     procedure FormShow(Sender: TObject);
  27.     procedure RichMemo1KeyPress(Sender: TObject; var Key: char);
  28.   private
  29.     { private declarations }
  30.   public
  31.     texto : tstringlist;
  32.     procesar : boolean;
  33.     procedure TagFormat(Sender: TObject;  var atagName: string; tagattr: TStrings; var afont: TFontParams; var txt: string; var tagCloses: Boolean );
  34.     procedure EntReplace(Sender: TObject; var txt: string; tagsStack: TStrings);
  35.     { public declarations }
  36.   end;
  37.  
  38. var
  39.   ventex: TForm2;
  40.   tamano : integer;
  41.   colorf : string;
  42.  
  43. implementation
  44.  
  45. { TForm2 }
  46.  
  47. procedure TForm2.TagFormat(Sender: TObject; var atagName: string; tagattr: TStrings; var afont: TFontParams; var txt: string; var tagCloses: Boolean);
  48. begin
  49.   if atagName='b' then
  50.     Include(afont.Style, fsBold)
  51.   else if atagName='i' then
  52.     Include(afont.Style, fsItalic)
  53.   else if atagName='s' then
  54.     Include(afont.Style, fsStrikeOut)
  55.   else if atagName='u' then
  56.     Include(afont.Style, fsUnderline)
  57.   else if atagName='h1' then begin
  58.     Include(afont.Style, fsBold);
  59.     afont.Size:=afont.Size*2;
  60.   end else if atagName='h2' then begin
  61.     Include(afont.Style, fsBold);
  62.     afont.Size:=round(afont.Size*1.5)
  63.   end else if atagName='pre' then begin
  64.     afont.Name:='Courier New'
  65.   end else if atagName='rojo' then
  66.     afont.Color:=clRed
  67.   else if atagName='azul' then
  68.     afont.Color:=clBlue
  69.   else if atagName='amarillo' then
  70.     afont.Color:=clYellow
  71.   else if atagName='verde' then
  72.     afont.Color:=clGreen;
  73. end;
  74.  
  75. procedure TForm2.EntReplace(Sender: TObject; var txt: string;tagsStack: TStrings);
  76. begin
  77.   txt:=StringReplace(txt, '&lt;', '<', [rfReplaceAll, rfIgnoreCase]);
  78.   txt:=StringReplace(txt, '&gt;', '>', [rfReplaceAll, rfIgnoreCase]);
  79.   txt:=StringReplace(txt, '&quot;', '"', [rfReplaceAll, rfIgnoreCase]);
  80. end;
  81.  
  82. procedure TForm2.FormShow(Sender: TObject);
  83. begin
  84.   RichMemo1.Clear;
  85.   richmemo1.Font.Size:=12;
  86.   richmemo1.Font.Color:=clBlack;
  87.   {$IFDEF WINDOWS} // all windows
  88.   if procesar then
  89.     Parse(texto.Text, RichMemo1, @TagFormat, @EntReplace)
  90.   else
  91.     richmemo1.Lines:=texto;
  92.   {$ELSE}
  93.     richmemo1.Lines:=texto;
  94.   {$ENDIF}
  95.   label1.Caption:='';
  96. end;
  97.  
  98. procedure TForm2.RichMemo1KeyPress(Sender: TObject; var Key: char);
  99. begin
  100.   if key=#27 then
  101.     BitBtn3Click(sender);
  102. end;
  103.  
  104. procedure TForm2.FormCreate(Sender: TObject);
  105. begin
  106.   texto:=TStringList.Create;
  107.   texto.Clear;
  108.   tamano:=12;
  109.   procesar:=false;
  110. end;
  111.  
  112. procedure TForm2.BitBtn3Click(Sender: TObject);
  113. begin
  114.   close;
  115. end;
  116.  
  117. procedure TForm2.BitBtn1Click(Sender: TObject);
  118. begin
  119.   richmemo1.SelectAll;
  120. end;
  121.  
  122. procedure TForm2.BitBtn2Click(Sender: TObject);
  123. begin
  124.   richmemo1.CopyToClipboard;
  125.   label1.Caption:='Texto copiado al portapapeles';
  126. end;
  127.  
  128. initialization
  129.   {$I ventanatextomejorada.lrs}
  130.  
  131. end.
  132.  
« Last Edit: June 09, 2016, 12:38:29 am by calebs »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Richmemo not working on linux
« Reply #2 on: June 09, 2016, 11:11:03 pm »
are you building the project for Gtk3 or Gtk2 LCL?

calebs

  • Full Member
  • ***
  • Posts: 190
Re: Richmemo not working on linux
« Reply #3 on: June 15, 2016, 12:08:43 am »
I really don't know, i usually program in windows and then open the project in linux to test and correct interface and some other things.
Where do i check that, skalogryz?

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Richmemo not working on linux
« Reply #4 on: June 15, 2016, 04:22:24 am »
I really don't know, i usually program in windows and then open the project in linux to test and correct interface and some other things.
Where do i check that, skalogryz?
Project Options -> Additions and Overrides -> click "LCLWidgetType" and select gtk2

RichMemoML sample works here on ubuntu64

calebs

  • Full Member
  • ***
  • Posts: 190
Re: Richmemo not working on linux
« Reply #5 on: June 30, 2016, 12:20:04 am »
Thanks skalogryz i'll try it soon.
For now i had to use a switch to detect linux and don't process text

 

TinyPortal © 2005-2018