Page 1 of 1

How to toggle editor line/word wrap?

Posted: Fri Oct 13, 2023 7:04 am
by jayand
A seemingly simple question. Is there any way to toggle line/word wrapping of long lines in PB (6.02) editor?
I have searched everywhere for the answer, but either I need new spectacles :shock: , or the option doesn't exist.
I've never used any kind of editor that doesn't have this simple feature.
What am I overlooking?

Re: How to toggle editor line/word wrap?

Posted: Fri Oct 13, 2023 7:32 am
by Shardik

Code: Select all

OpenWindow(0, 270, 100, 250, 120, "Word Wrap Test", #PB_Window_SystemMenu)
EditorGadget(0, 10, 10, 230, 75)
ButtonGadget(1, 60, 90, 140, 25, "Toggle Word Wrap")

For i = 1 To 5
  Text$ = Text$ + "This is a word wrap test - "
Next i

SetGadgetText(0, Text$)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      If EventGadget() = 1
        WordWrap ! 1
        SetGadgetAttribute(0, #PB_Editor_WordWrap, WordWrap)
      EndIf
  EndSelect
ForEver

Re: How to toggle editor line/word wrap?

Posted: Fri Oct 13, 2023 7:56 am
by jayand
Thanks for taking the time to reply, but you have misunderstand my question. I am not looking for code to word wrap in an editor gadget, I am asking about the core PB editor window.

Re: How to toggle editor line/word wrap?

Posted: Tue Dec 05, 2023 12:54 am
by Amundo
jayand wrote: Fri Oct 13, 2023 7:04 am What am I overlooking?
(Better late than never)

You're not overlooking anything, jayand.

Every editor known to Mankind has a word wrap feature - PB seems to be unique in this regard :-)

Re: How to toggle editor line/word wrap?

Posted: Tue Dec 05, 2023 1:09 am
by BarryG
Have a read of this topic -> https://www.purebasic.fr/english/viewtopic.php?t=30385

The lastest update in that topic is here -> https://www.purebasic.fr/english/viewto ... 15#p392215

It shows how to make a tool for the IDE to toggle wrapping.

Re: How to toggle editor line/word wrap?

Posted: Wed Dec 06, 2023 4:11 am
by Amundo
BarryG wrote: Tue Dec 05, 2023 1:09 am It shows how to make a tool for the IDE to toggle wrapping.
Thanks, just implemented Danilo's solution.

But still...it's been a part of the Scintilla editor probably since it was written...

Re: How to toggle editor line/word wrap?

Posted: Wed Dec 06, 2023 8:23 am
by BarryG
I just found this much shorter tool version in my code snippets, and it still works for me. Can't remember where I first got it.

Code: Select all

ide=Val(GetEnvironmentVariable("PB_Tool_Scintilla"))
If ide
  c=SendMessage_(ide,#SCI_GETWRAPMODE,0,0)
  SendMessage_(ide,#SCI_SETWRAPMODE,1-c,0)
EndIf