How to toggle editor line/word wrap?

Working on new editor enhancements?
jayand
User
User
Posts: 22
Joined: Sat Mar 04, 2023 12:55 pm

How to toggle editor line/word wrap?

Post 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?
User avatar
Shardik
Addict
Addict
Posts: 1982
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: How to toggle editor line/word wrap?

Post 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
jayand
User
User
Posts: 22
Joined: Sat Mar 04, 2023 12:55 pm

Re: How to toggle editor line/word wrap?

Post 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.
Amundo
Enthusiast
Enthusiast
Posts: 191
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

Re: How to toggle editor line/word wrap?

Post 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 :-)
Win8.1, PB5.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
BarryG
Addict
Addict
Posts: 3205
Joined: Thu Apr 18, 2019 8:17 am

Re: How to toggle editor line/word wrap?

Post 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.
Amundo
Enthusiast
Enthusiast
Posts: 191
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

Re: How to toggle editor line/word wrap?

Post 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...
Win8.1, PB5.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
BarryG
Addict
Addict
Posts: 3205
Joined: Thu Apr 18, 2019 8:17 am

Re: How to toggle editor line/word wrap?

Post 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
Post Reply