Difference between revisions of "Talk:RichMemo/WorkArounds"

From Free Pascal wiki
Jump to navigationJump to search
(Updated and removed ref to Carbon)
(clean up outdated content)
Tag: Replaced
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
  
= Draft =
+
note I have merged draft content from here back to main page.
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
 
!Cocoa
 
|-
 
|SetTextAttributes()
 
|OK
 
|-
 
|GetTextAttributes(..)
 
|broken as of Feb 2020
 
|it calls GettextLen which is broken, see main page for fix
 
|-
 
|SetRangeParams(..)               
 
|OK
 
|-
 
|GetStyleRange(..)
 
|OK
 
|-
 
|GetParaMetric(..)
 
|Fail ?
 
|-
 
|SetParaMetric(..)
 
|Fail
 
|-
 
|GetParaRange(..)
 
|Fail
 
|-
 
|SetRangeParaParams(..)
 
|Fail
 
|Depends on GetParaRange()
 
|-
 
|Search()
 
|Fail
 
|Might be able to use FindText() or search RichMemo1.Text
 
|-
 
|GetTextLen(..)
 
|Fail
 
|Not official RichMemo function, higher up ...
 
|-
 
|SetLink()
 
|Fail
 
|Actually works but the linked text is not displayed in blue or underlined etc
 
|-
 
|Font Background Color
 
|OK
 
|As noted on RichMemo page
 
|-
 
|OnChange Event
 
|Fail
 
|Event does not fire under Cocoa ?
 
|}
 
 
 
'''Notes'''
 
* GetParaMetric() on Cocoa 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 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, crashing it with a message ''cannot find bounds of function''.
 
* Search() always returns false on Cocoa but does not set vars at all.
 
* For GetTextAttributes(), on Cocoa fails because GetTextLen() does not work. I think something like UYF8length(Text) seems to work, possibly slow. Wonder how much faster UTF8LengthFast() is ?
 
* 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 !
 
 
 
<syntaxhighlight lang=pascal>
 
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"
 
</syntaxhighlight>
 
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 ...
 
<syntaxhighlight lang=pascal>
 
~/laz-svn/lazbuild --pcp=~/.laz-svn --ws=cocoa --compiler=/usr/local/bin/ppcx64 --cpu=x86_64 webbrowserpackage.lpk
 
</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. 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).
 
<syntaxhighlight lang=pascal>
 
~/laz-svn/lazbuild --pcp=~/.laz-svn --ws=cocoa --compiler=/usr/local/bin/ppcx64 --cpu=x86_64 project1.lpi
 
</syntaxhighlight>
 

Latest revision as of 07:50, 9 October 2020

note I have merged draft content from here back to main page.