Difference between revisions of "Talk:RichMemo/WorkArounds"

From Lazarus wiki
Jump to navigationJump to search
m (Fixed syntax highlighting)
(Updated and removed ref to Carbon)
Line 8: Line 8:
 
{|  
 
{|  
 
!Method
 
!Method
!Carbon
 
 
!Cocoa
 
!Cocoa
 
|-
 
|-
 
|SetTextAttributes()
 
|SetTextAttributes()
|OK
 
 
|OK
 
|OK
 
|-
 
|-
 
|GetTextAttributes(..)
 
|GetTextAttributes(..)
|Patch
+
|broken as of Feb 2020
|OK
+
|it calls GettextLen which is broken, see main page for fix
|(but it does not detect when its passed an out of range start point)
 
 
|-
 
|-
 
|SetRangeParams(..)                 
 
|SetRangeParams(..)                 
|OK
 
 
|OK
 
|OK
 
|-
 
|-
 
|GetStyleRange(..)
 
|GetStyleRange(..)
|OK
 
 
|OK
 
|OK
 
|-
 
|-
 
|GetParaMetric(..)
 
|GetParaMetric(..)
|Fail
 
 
|Fail ?
 
|Fail ?
 
|-
 
|-
 
|SetParaMetric(..)
 
|SetParaMetric(..)
|Fail
 
 
|Fail
 
|Fail
 
|-
 
|-
 
|GetParaRange(..)
 
|GetParaRange(..)
|Fail
 
 
|Fail
 
|Fail
 
|-
 
|-
 
|SetRangeParaParams(..)
 
|SetRangeParaParams(..)
|Fail
 
 
|Fail
 
|Fail
 
|Depends on GetParaRange()
 
|Depends on GetParaRange()
 
|-
 
|-
 
|Search()
 
|Search()
|Mixed
 
 
|Fail
 
|Fail
|Might be able to use FindText()
+
|Might be able to use FindText() or search RichMemo1.Text
 
|-
 
|-
 
|GetTextLen(..)
 
|GetTextLen(..)
|OK
 
 
|Fail
 
|Fail
|Not official function
+
|Not official RichMemo function, higher up ...
 
|-
 
|-
 
|SetLink()
 
|SetLink()
 
|Fail
 
|Fail
|Fail
+
|Actually works but the linked text is not displayed in blue or underlined etc
|Not official function.
 
 
|-
 
|-
 
|Font Background Color
 
|Font Background Color
|Fail
 
 
|OK
 
|OK
 
|As noted on RichMemo page
 
|As noted on RichMemo page
 
|-
 
|-
 
|OnChange Event
 
|OnChange Event
|OK
 
 
|Fail
 
|Fail
|Event does not fire under Cocoa.
+
|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'''
 
'''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....
+
* 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 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''.
+
* 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() on Carbon sets vars properly but always returns False. But always returns true on Cocoa but does not set vars at all.
+
* Search() always returns false 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.
+
* 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.
 
* 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....
 
* I have a local SetRangeParams() working, might be slow, will appear when I've tested it a bit more....

Revision as of 04:27, 26 September 2020

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 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 !

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