Recent

Author Topic: [Solved] WordWrap on TMemo not working on Linux  (Read 1616 times)

Tim S

  • Newbie
  • Posts: 3
[Solved] WordWrap on TMemo not working on Linux
« on: September 27, 2025, 05:34:17 am »
This 'should' be a simple problem to fix I just cannot find a solution.

I'm using version 4.2 of Lazarus on Ubuntu but have tried in the past with earlier versions of Lazarus; and Ubuntu and other flavors of Linux.

I've also tried on Windows and it just works there.

I've tried changing things like scrollbars with no joy.

I've messed around with crlf (#13#10) but that shouldn't be part of the problem. The line that gets wordwrapped doesn't have crlf's in it after the word wrapping.

Any help or suggestions would be greatly appreciated!
« Last Edit: September 29, 2025, 11:55:15 pm by Tim S »

Hartmut

  • Hero Member
  • *****
  • Posts: 1072
Re: WordWrap on TMemo not working on Linux
« Reply #1 on: September 27, 2025, 09:52:52 am »
Welcome to the Forum!

I use TMemo.WordWrap on Ubuntu 18.04 .. 24.04 without problems with different Lazarus versions up to 3.4.0.

You should always give us more details when you have problems.

I've tried changing things like scrollbars with no joy.
How is this related to your WordWrap problem?

Quote
The line that gets wordwrapped doesn't have crlf's in it after the word wrapping.
Does this mean: you get a wordwrap where you don't expect one?
Please show us the source code of this line and a screenshot of your Memo.

The best would be to see your whole code or - more better - to provide a compilable project for us. But at least please show us the complete configuration of your Memo. Either it's source code or it's *.lfm file.

Tim S

  • Newbie
  • Posts: 3
Re: WordWrap on TMemo not working on Linux
« Reply #2 on: September 28, 2025, 05:16:38 am »
Thanks  for the response Hartmut, and for the welcome :-)

I'll try to explain myself again. I seem to have failed the first time. My apologies!

. I create a project with a Form.
. I place a memo on the form. (No changes to the default ... WordWrap = True in the Object Inspector)
. I run the project.

When the project is running I type in the memo. Wordwrap has no effect.

Following is the contents of .lfm file.

object Form1: TForm1
  Left = 314
  Height = 229
  Top = 177
  Width = 313
  Caption = 'Form1'
  ClientHeight = 229
  ClientWidth = 313
  LCLVersion = '4.2.0.0'
  object Memo1: TMemo
    Left = 56
    Height = 98
    Top = 64
    Width = 208
    Lines.Strings = (
      'Memo1'
    )
    TabOrder = 0
    OnChange = Memo1Change
  end
end

. I have upload the  whole project and two .jpg files:

. The first .jpg (MemoTest1.jpg) j shows text added just prior to the point that I would Wordwrap to take effect.
. The second .jpg (MemoTest2.jpg) shows after three more characters are added. They keep getting added to the and of the line and the beginning of the line goes out of view. Wodwrap does not take effect

(I compared the same project created from scratch on Windows and the .lpm file is identical.)
.    If I turn WodWarp = False the following line is added to the .lfm file
         WordWrap = False
.    If I manually edit the .lfm file to change Wordwrap = True it has no effect

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: WordWrap on TMemo not working on Linux
« Reply #3 on: September 28, 2025, 10:16:53 am »
Never edit the lfm file manually. It can be done, but only if you really know what you are doing (expert).
Consider the lfm read-only and change the properties through the object inspector or in code.
Beginners should NOT touch the lfm.
« Last Edit: September 28, 2025, 10:19:51 am by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12109
  • Debugger - SynEdit - and more
    • wiki
Re: WordWrap on TMemo not working on Linux
« Reply #4 on: September 28, 2025, 10:55:52 am »
My first question would have been: gtk2? gtk3? qt5? qt6? ....

But, looking at your image, the text you typed has no spaces, it consists of ONE very long word. With that, I do get the same (non wrap) behaviour (gtk2). But as soon as I put in spaces it will wrap at the spaces.

I don't know if that is indented. I haven't tested on Windows or other OS, or WidgetSets. So I can't tell if it should or should not break the ONE very long word.

Can you confirm, that the issue is indeed affecting "single very long words"?
Or does it also fail for you, if you have spaces in the text (and no single word is longer than the available widths)?

Hartmut

  • Hero Member
  • *****
  • Posts: 1072
Re: WordWrap on TMemo not working on Linux
« Reply #5 on: September 28, 2025, 07:02:52 pm »
I ran your project on Ubuntu 24.04 with Lazarus 3.4.0 / FPC 3.2.2 and everything works as it should.

The default for TMemo.WordWrap is True. When I type in a couple of words - separated by blanks - as soon as a line is full, the next word is broken to a new line. But if I type in words, which are longer than the line, they are *not* broken and you need to scroll horizontally. Because WordWrap, as the name says, breaks only at word boundaries. This all is the correct behavior.

If I change TMemo.WordWrap to be False, no wordwrap occurs. If I type in more characters, than the line is long, there is no wordwrap, even if there are blanks and I need to scroll horizontally. But I can force a new line by pressing ENTER. This also is a correct behavior.

If you want you can configure automatic scrollbars.

Do you have another behavior? If yes, please describe it detailed that we can halp you.

Tim S

  • Newbie
  • Posts: 3
Re: WordWrap on TMemo not working on Linux
« Reply #6 on: September 29, 2025, 05:52:26 am »
Thanks for all the replies. I fell like a bit of a goose.

It does indeed wrap on smaller words!

I was fooled perhaps by the behavior on windows which does wrap the long line with no spaces.

Hartmut

  • Hero Member
  • *****
  • Posts: 1072
Re: WordWrap on TMemo not working on Linux
« Reply #7 on: September 29, 2025, 12:01:52 pm »
Don't worry, we all sometimes happen to enter a wrong path... Especially a couple of differences in the behavior of Controls between Windows an Linux can make our life complicated.

If your question is now solved, it would be kind to mark your Topic accordingly. Most users do this by modifying their 1st post (you must login before) and place a [SOLVED] at the beginning of the subject.

Have fun with FPC / Lazarus ;-)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12109
  • Debugger - SynEdit - and more
    • wiki
Re: WordWrap on TMemo not working on Linux
« Reply #8 on: September 29, 2025, 01:45:23 pm »
I don't know about "its intended to to words only".

If on Windows it does force mid-word wrapping... Well, then it depends.
1) Is it on Windows handled by the OS or the LCL ? (need to be checked in the code)
2) Is it on Linux (and others / actually Gtk or QT, Cocoa) handled by the OS or LCL

E.g. it may be handled by OS/WS code, but some may not support it, and then LCL my emulate it.

If in any case it is emulated by the LCL, and if in that case it does not do as observed on Windows, then maybe that case should be improved....

But that is a lot of "if"s.



Btw, other edits with word wrap do exist, depending what you need.

I should guess that AtSynEdit supports it (with forced mid word wrap, but I don't know).
And TSynEdit does, but only in 4.99, and you need to create the plugin in code.... (and docs are still missing)

Zvoni

  • Hero Member
  • *****
  • Posts: 3252
Re: WordWrap on TMemo not working on Linux
« Reply #9 on: September 29, 2025, 02:11:39 pm »
What he's probably looking for is this "LineBreak" (or whatever it's called - german Windows here) we know from NotePad on Windows (NOT NOtepad++!!)
Usually found in Menu "Format"
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

myisjwj

  • Jr. Member
  • **
  • Posts: 91
Re: [Solved] WordWrap on TMemo not working on Linux
« Reply #10 on: October 22, 2025, 02:47:22 pm »
Try setting scrollbars:=ssautoboth

 

TinyPortal © 2005-2018