Difference between revisions of "Talk:RichMemo/WorkArounds"

From Lazarus wiki
Jump to navigationJump to search
m (minor update)
Line 86: Line 86:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
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.
+
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.
 
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).

Revision as of 14:31, 25 September 2017

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

Method Carbon Cocoa
SetTextAttributes() OK OK
GetTextAttributes(..) Patch Patch *
SetRangeParams(..) OK Fail
GetStyleRange(..) OK Fail
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.


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

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).