Difference between revisions of "Talk:RichMemo/WorkArounds"

From Lazarus wiki
Jump to navigationJump to search
(small update to table, font background color)
(Status of Functions on the Mac - updated)
Line 5: Line 5:
 
== Status of Functions on the Mac ==
 
== Status of Functions on the Mac ==
  
 +
By Cocoa, we mean the 64bit Cocoa widget set, Lazarus Fixes and RichMemo Trunk. Less is working on the RichMemo Stable.
 
{|  
 
{|  
 
!Method
 
!Method
Line 16: Line 17:
 
|GetTextAttributes(..)
 
|GetTextAttributes(..)
 
|Patch
 
|Patch
|Patch *
+
|OK (but it does not detect when its passed an out of range start point)
 
|-
 
|-
 
|SetRangeParams(..)                 
 
|SetRangeParams(..)                 
 
|OK
 
|OK
|Fail
+
|OK
 
|-
 
|-
 
|GetStyleRange(..)
 
|GetStyleRange(..)
 
|OK
 
|OK
|Fail
+
|OK
 
|-
 
|-
 
|GetParaMetric(..)
 
|GetParaMetric(..)

Revision as of 12:47, 30 December 2019

Draft

This is a draft, something that should be taken with the proverbial "grain of salt" at least until the RichMemo author has had a chance to comment. Testing was done with an early September 2017 copy of RichMemo, Lazarus 1.8rc4 and a Mac running Sierra.

Status of Functions on the Mac

By Cocoa, we mean the 64bit Cocoa widget set, Lazarus Fixes and RichMemo Trunk. Less is working on the RichMemo Stable.

Method Carbon Cocoa
SetTextAttributes() OK OK
GetTextAttributes(..) Patch OK (but it does not detect when its passed an out of range start point)
SetRangeParams(..) OK OK
GetStyleRange(..) OK OK
GetParaMetric(..) Fail Fail ?
SetParaMetric(..) Fail Fail
GetParaRange(..) Fail Fail
SetRangeParaParams(..) Fail Fail Depends on GetParaRange()
Search() Mixed Fail Might be able to use FindText()
GetTextLen(..) OK Fail Not official function
SetLink() Fail Fail Not official function.
Font Background Color Fail OK As noted on RichMemo page
OnChange Event OK Fail Event does not fire under Cocoa.

You could add a line to the table, "has a future" and say "fail" for Carbon and "OK" for Cocoa. Carbon is limited (by Apple) to 32 bit and likely to be dropped in the near future.

Notes

  • GetParaMetric() on Carbon always returns false, always fails to set vars. On Cocoa it always returns True and says indent is 0. Its not possible to set an indent of more than zero so hard to know if its working or not. Follow the code David....
  • SetParaMetric() on carbon and Cocoa makes no visible change to text. On Cocoa it calls TCocoaWSCustomRichMemo.SetParaMetric(..) which includes a line "txt:=view.textStorage" that seems to cause a silent and local crash (my words). The method is terminated prematurely dropping back to the RichMemo function and nothing is done to the text. This premature termination confuses gdb quite badly, crashing it with a message cannot find bounds of function.
  • Search() on Carbon sets vars properly but always returns False. But always returns true on Cocoa but does not set vars at all.
  • For GetTextAttributes(), OSX requires a different patch on Cocoa than Carbon or Linux/Windows because GetTextLen() does not work. I think something like length(Lines.Text) is going to be the answer, probably a slow one and one I need to test.
  • GetStyleRange() is a problem elsewhere too, I have a local function to do that.
  • I have a local SetRangeParams() working, might be slow, will appear when I've tested it a bit more....

Compiling with Cocoa on the Mac

Careful how serious you take this, written by a real Mac Newbie ! Not possible to install RichMemo on at least Lazarus 1.8rc4 when using Cocoa. At Phil's suggestion (thanks Phil) its necessary to install the trunk Lazarus version from SVN, build a Cocoa Lazarus and then, using command line and config for that build, make RichMemo. You can then add that newly built RichMemo into an (eg Carbon based) Lazarus and build your Cocoa app using the relatively new Cocoa widgets. See step by step below or Phil's authoritative write up https://macpgmr.github.io/MacXPlatform/UsingCocoaFromTrunk.html

Getting trunk Cocoa widgets

This is copied (shamelessly) from https://macpgmr.github.io/MacXPlatform/UsingCocoaFromTrunk.html, thanks Phil !

mkdir laz-svn
cd laz-svn
svn checkout https://svn.freepascal.org/svn/lazarus/trunk .
make LCL_PLATFORM=cocoa CPU_TARGET=x86_64
open lazarus.app --args "--pcp=~/.laz-svn"

You don't need to do anything in that trunk Lazarus, just need the config files made. So, exit and proceed to build RichMemo using the shiny new things you just installed. cd to where you have unzipped (or whatever) RichMemo, put a good path to laz-svn/lazbuild and ...

~/laz-svn/lazbuild --pcp=~/.laz-svn --ws=cocoa --compiler=/usr/local/bin/ppcx64 --cpu=x86_64 webbrowserpackage.lpk

Now, fire up your existing and familiar Lazarus, make sure its set to make Cocoa binaries. (Project->ProjectOptions->ConfigAndTarget and if its set to "Carbon", click "select another LCL Widget Set"). Install the RichMemo package as you would normally. You can now edit and do things like compile and debug but you will be still using the 1.8 Cocoa Widget Set, so careful.

If you want to build a 64bit version, Tools->Options->Environment->Files and change "Compiler Executable" from /usr/local/bin/ppc386 to /usr/local/bin/ppcx64.

When you are ready to really compile, grab a terminal and compile using the trunk lazbuild (and your get its config and widgetset).

~/laz-svn/lazbuild --pcp=~/.laz-svn --ws=cocoa --compiler=/usr/local/bin/ppcx64 --cpu=x86_64 project1.lpi