Recent

Author Topic: Cross-platform rich text  (Read 1697 times)

dbannon

  • Hero Member
  • *****
  • Posts: 3612
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cross-platform rich text
« Reply #15 on: November 18, 2025, 08:06:38 am »
I don't think that 'underline' is the right term here - to me it looks more like lined paper. I'd expect there to be a line even if there was no text. Just sayin'...

Yes, are right Sieben.  I am guessing if  jianwt really wants those line right across the page, he/she could fill the line with underlined spaces or other non printing characters but thats going to need some coding if the end user is allowed to actively edit ....

KMemo also supports embedded images, again, a lot of code would be needed if you wanted them to be dynamic.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Cross-platform rich text
« Reply #16 on: November 18, 2025, 08:33:40 am »
The lined paper can be done with a custom paint routine of course, but it is not implemented out of the box.
But as others also wrote: KMemo is pretty stable and a real cross-platform, pure pascal, solution.
You can use a background image with lines, though...

For bullet handling, paragraphs etc look at:
https://wiki.freepascal.org/KControls/KMemo_notes
« Last Edit: November 18, 2025, 08:43:28 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

jianwt

  • Full Member
  • ***
  • Posts: 164
Re: Cross-platform rich text
« Reply #17 on: November 19, 2025, 06:17:40 am »
Thank you @dbannon @Thaddy and others for your kind answers to my questions.
 I'm a beginner and don't understand many things! I'm not very familiar with this control. I used AI to create this KMemoWithLines. There is a problem: when I dynamically adjust the font size to 36 and then change it to 14, the height from the top of the control to the first line (first paragraph) of my control cannot be dynamically adapted. There is a small blank area, which looks very bad. See the part I marked with a red box. How can I control the distance from the first paragraph to the top of the control in KMEMO? Thank you all.

dbannon

  • Hero Member
  • *****
  • Posts: 3612
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cross-platform rich text
« Reply #18 on: November 19, 2025, 08:12:20 am »
might be a blank line with a smaller font set.  A new KMemo always has a single new-line (ie a block) and if you just add to it, it remains there. You should be able to delete it.

And, if I may add :
One of the issues with using AI to write code is you learn absolutely nothing about how it works so cannot add to it or debug or whatever.  Using AI when you know your stuff may be useful, certainly not useful for a beginner.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Thaddy

  • Hero Member
  • *****
  • Posts: 18524
  • Here stood a man who saw the Elbe and jumped it.
Re: Cross-platform rich text
« Reply #19 on: November 19, 2025, 09:05:09 am »
@dbannon

That is definitely not AI  ;)
That actually works quite good! Inserting a new (block) line with the smallest font size your font supports.
It is a bit cumbersome to do every time, but let's see if we can do that through a single procedure that does the line and then restores the old settings. TRecall comes to mind and that is underused anyway...
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

dbannon

  • Hero Member
  • *****
  • Posts: 3612
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cross-platform rich text
« Reply #20 on: November 19, 2025, 09:39:14 am »
Thaddy, you don't think the AI wrote it ? Interesting second file, KMemoWithLinesSetPack.pas ? Anyway, I don't do AI code.

Hmm, no need to set that first TKMemoParagraph to a small font, just delete it as soon as you are ready to add something else. In tomboy-ng, if I open a new note, I delete that TKMemoParagraph and add a note title (with its own TKMemoParagraph).

Hmm, actually, if jianwt wants a completely empty KMemo waiting for user input, that might be messy. Without that solitary TKMemoParagraph (or something else) the Memo does act up. Cannot remember under what circumstances....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

lelanthran

  • Newbie
  • Posts: 6
Re: Cross-platform rich text
« Reply #21 on: November 21, 2025, 01:19:48 pm »
Lots of very good information in this thread.

Thank you all; much appreciated.

Ed78z

  • Jr. Member
  • **
  • Posts: 77
Re: Cross-platform rich text
« Reply #22 on: November 23, 2025, 04:34:33 pm »
Are there any plans amongst the Lazarus community to move towards creating an editing component like this?

I'm not a developer. Just to keep the conversation going. As far as I know, Lazarus doesn't have a ready-made component that meets your requirements. These are partial solutions. There are components like RichMemo and KMemo (part of KControls), but they have their limitations and don't cover everything you've listed. TRichView is a commercial component, but it supports Lazarus. One of the forum members is actively developing an advanced component, TDWEdit. Lazarus supports PDF creation and display. Real-world scenarios that are currently recommended for developers include Lazarus WebView + a JS editor (CEF4Delphi / WebView2 / QtWebEngine). I hope more knowledgeable forum members will chime in and answer your questions.

I am trying to add SavePDF option to the TDWEDIT component, it's very challenging since fppdf is very basic can't handle complex Unicode characters or colorful emojis.... I am trying to use dual layer solution...one layer is all complex characters or emojis as png and the second layer as invisible Unicode characters over it, so the user can select text to copy....
As soon as I find solution I will release the TDWEDIT component.

 

TinyPortal © 2005-2018