Page 1 of 1

Strange behavior of Editor with the WordWrap flag

Posted: Mon Oct 06, 2025 7:01 pm
by ZX80
Hi, all.

I need to code an editor so that each line contains no more than n characters. For this I used a monospaced font and calculated the required number of pixels. I also set the 'WordWrap' flag. But it works strangely. This very simple code does not work as expected. It only uses the carry flag. Also in the debug window I expected to get what I see in the editor, but this is not the case at all. I think a workaround is to count the number of lines in the editor and then read them one by one, adding #CRLS$ between them. But why doesn't the GetGadgetText() command do this ? I don't know if this is a bug.

Code: Select all

If OpenWindow(0, 0, 0, 322, 150, "Editor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(0, 8, 8, 306, 133, #PB_Editor_WordWrap)
  SendMessage_(eWnd, #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
  
  For a = 0 To 5
    AddGadgetItem(0, a, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ~!abcdefghijk")
  Next
  
  Debug GetGadgetText(0)  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
If it's important, then PB version 6.20 (x86).
Can anyone confirm the same editor behavior ?
Thank you.

Re: Strange behavior of Editor with the WordWrap flag

Posted: Mon Oct 06, 2025 7:47 pm
by Piero
I really hope someone will help you, because 6.20 (x86) must be very rare (also considering these awful times) and I'm on Mac.

Re: Strange behavior of Editor with the WordWrap flag

Posted: Mon Oct 06, 2025 8:44 pm
by zikitrake
The same thing happens in PB 6.30 beta 3.

Image

Re: Strange behavior of Editor with the WordWrap flag

Posted: Mon Oct 06, 2025 9:08 pm
by RASHAD
Windows only
Editor Gadget limit characters per line

Code: Select all

If OpenWindow(0, 0, 0, 322, 150, "Editor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  EditorGadget(0, 8, 8, 306, 133, #PB_Editor_WordWrap)
  SendMessage_(GadgetID(0), #EM_SETMARGINS, #EC_LEFTMARGIN, 0|0<<16)
  SendMessage_(GadgetID(0), #EM_SETMARGINS, #EC_RIGHTMARGIN, 0|60<<16) ;60 Characters per  line
  
  For a = 0 To 5
    AddGadgetItem(0, a, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ~!abcdefghijk")
  Next
  
  count = CountGadgetItems(0)
  For line = 0 To count
    Debug GetGadgetItemText(0,line)
  Next  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf