Strange behavior of Editor with the WordWrap flag

Just starting out? Need help? Post your questions and find answers here.
ZX80
Enthusiast
Enthusiast
Posts: 366
Joined: Mon Dec 12, 2016 1:37 pm

Strange behavior of Editor with the WordWrap flag

Post 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.
User avatar
Piero
Addict
Addict
Posts: 1003
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Strange behavior of Editor with the WordWrap flag

Post 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.
zikitrake
Addict
Addict
Posts: 877
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Re: Strange behavior of Editor with the WordWrap flag

Post by zikitrake »

The same thing happens in PB 6.30 beta 3.

Image
PB 6.21 beta, PureVision User
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4966
Joined: Sun Apr 12, 2009 6:27 am

Re: Strange behavior of Editor with the WordWrap flag

Post 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
Egypt my love
Post Reply