QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: NOVARSEG on April 17, 2021, 08:08:12 pm

Title: Word Wrap in QB64 IDE?
Post by: NOVARSEG on April 17, 2021, 08:08:12 pm
Are there settings for that?
Title: Re: Word Wrap in QB64 IDE?
Post by: bplus on April 17, 2021, 08:43:37 pm
Code lines don't use word wrap but you can use a _ to continue a line below the current line.
Code: QB64: [Select]
  1. S$ = "This is a really really really really really really really really really really really really really really really really" +_
  2.    " sigh, really really really really really really really really long line."
  3.  
  4.  
Title: Re: Word Wrap in QB64 IDE?
Post by: NOVARSEG on April 17, 2021, 08:47:58 pm
I can see that for code lines but what about comments?

say some code requires extensive commenting to explain it's function. It would be nice to have word wrap for comments
Title: Re: Word Wrap in QB64 IDE?
Post by: bplus on April 17, 2021, 08:58:41 pm
I can see that for code lines but what about comments?

say some code requires extensive commenting to explain it's function. It would be nice to have word wrap for comments

Well put it on your wish list for IDE :) I have built in spellchecker on mine ;-))
Title: Re: Word Wrap in QB64 IDE?
Post by: SMcNeill on April 18, 2021, 09:51:05 am
I can see that for code lines but what about comments?

say some code requires extensive commenting to explain it's function. It would be nice to have word wrap for comments

Just use an $IF block.

$IF COMMENT THEN
   Hi, my name is Steve.
   This is my example.
   It works just like a comment and is excluded from my code,
   Because of the undefined $IF block.
$END IF
Title: Re: Word Wrap in QB64 IDE?
Post by: bplus on April 18, 2021, 12:21:09 pm
Just use an $IF block.

$IF COMMENT THEN
   Hi, my name is Steve.
   This is my example.
   It works just like a comment and is excluded from my code,
   Because of the undefined $IF block.
$END IF

That's nice but tell me that will word wrap?
Title: Re: Word Wrap in QB64 IDE?
Post by: RhoSigma on April 18, 2021, 12:42:59 pm
I don't see the need for word wrap here, even on extensive commenting. It just seems to be another person who's simply to lazy to press Enter and a new leading apostroph in the next line. Gosh, how lazy people can be?
Title: Re: Word Wrap in QB64 IDE?
Post by: SpriggsySpriggs on April 18, 2021, 01:32:43 pm
I don't see the need for word wrap here, even on extensive commenting. It just seems to be another person who's simply to lazy to press Enter and a new leading apostrophe in the next line. Gosh, how lazy people can be?

I didn't want to be the one to say it but I'm glad someone did. It's just laziness to not be able to press two extra keystrokes.
Title: Re: Word Wrap in QB64 IDE?
Post by: Bert22306 on April 18, 2021, 04:16:44 pm
I didn't want to be the one to say it but I'm glad someone did.

:)

+1. My other thought was, what would this word wrapped comment look like, in a simple text file? To me, the feature would not be useful unless it put a return every so many characters, and then added a ' or a Rem in front of every new line. So that I could cut and paste my programs, as I do all the time, to incorporate them in documents easily.

Others would have different preferences. Seems like a lot of bother, for something that's flexible enough as is?
Title: Re: Word Wrap in QB64 IDE?
Post by: SMcNeill on April 18, 2021, 09:32:25 pm
That's nice but tell me that will word wrap?

It doesn’t do it automatically, but just hit ENTER when you’re at the end of a line and then keep typing until the next one.
Title: Re: Word Wrap in QB64 IDE?
Post by: NOVARSEG on April 18, 2021, 10:18:09 pm

Quote
Gosh, how lazy people can be?


Title: Re: Word Wrap in QB64 IDE?
Post by: bplus on April 19, 2021, 12:18:17 pm
Hey if it weren't for lazy people computers, calculators, the wheel would never have been invented.

[back in the dark ages]
You lazy wuss, what do you mean is there an easier way to get this load of hay into town than by carrying it? ;-))


It's not just a couple of keystrokes if you try to maintain good code notes while writing up and modifying your code as you go. Probably best to do in WP on the side if you feel it just important to log the learning process as having good code. But soon enough you will be dragging the rest of the code in with it, just to show WTH you are talking about. LOL
Title: Re: Word Wrap in QB64 IDE?
Post by: OldMoses on April 19, 2021, 01:07:29 pm
I guess here is where we insert the new QB64 command... _BLOCKCOMMENT  Come on folks, you know you want it... ;)

On a more serious note, I generally have a
SUB Comments
    'stuff
    'stuff
END SUB
which gets nothing but comments for general program info and isn't called in the code, but yeah, I still have to ' each line in it. Or you can type whatever you like, highlight it & ctrl-R

I think there are plenty options and I use copious comments in my bigger projects. I couldn't remember how anything works otherwise.

If there's one thing I would love to see, it would be a way to collapse SUB/FUNCTION blocks that one is finished working with. I presume that would be challenging to implement or it would have been done by now.
Title: Re: Word Wrap in QB64 IDE?
Post by: bplus on April 19, 2021, 01:21:18 pm
Quote
If there's one thing I would love to see, it would be a way to collapse SUB/FUNCTION blocks that one is finished working with. I presume that would be challenging to implement or it would have been done by now.

Well I have a suggestion for that, build a custom library for the app and who knows if it might not be helpful for others or serve as a starter with code already tested? When you have one worked out move it into library.
Title: Re: Word Wrap in QB64 IDE?
Post by: SpriggsySpriggs on April 19, 2021, 02:31:20 pm
Quote
It's not just a couple of keystrokes

←┘
'
Title: Re: Word Wrap in QB64 IDE?
Post by: bplus on April 19, 2021, 02:49:05 pm
←┘
'

And don't forget block comment selected text from Edit menu but it still doesn't give us word wrap does it!
Title: Re: Word Wrap in QB64 IDE?
Post by: SpriggsySpriggs on April 19, 2021, 02:51:26 pm
Word wrap would be, by far, the ugliest thing to bring to an IDE.
Title: Re: Word Wrap in QB64 IDE?
Post by: bplus on April 19, 2021, 04:51:22 pm
Word wrap would be, by far, the ugliest thing to bring to an IDE.

LOL can't argue with someone's opinion.
Title: Re: Word Wrap in QB64 IDE?
Post by: SpriggsySpriggs on April 19, 2021, 04:54:20 pm
I do see the use for it and I do see the benefit it would have for someone who dislikes horizontal scrolling. I just absolutely abhor the idea.
Title: Re: Word Wrap in QB64 IDE?
Post by: Cobalt on April 20, 2021, 12:34:38 am
With all the under the hood work that would be needed to deal with syntax checking, code flow, indentations, ect. ect. When we already have this nice and  handy key on the keyboard to deal with it labeled ENTER why waste the time and potential can of worms trying to force the QB64 IDE to do even more. It already has too much glut clutter anyway.

You want word wrap then use notepad or a word document processor.
Title: Re: Word Wrap in QB64 IDE?
Post by: codeguy on April 20, 2021, 04:06:08 am
I don't think word wrap would do the IDE justice. It's perfect. It's a simple intuitive IDE. Line continuations can be done using the underscore, I think. For wrapping printouts, that would be a project for notepad. But onscreen, I just can't see the necessity. It would be nice to be able to continue really long literals using a system like that, though.
Title: Re: Word Wrap in QB64 IDE?
Post by: SpriggsySpriggs on April 20, 2021, 07:58:18 am
My final thought on this: If it is so desired to use word wrap then program in Microsoft Word.
Title: Re: Word Wrap in QB64 IDE?
Post by: SMcNeill on April 20, 2021, 08:55:46 am
Instead of an all inclusive word wrap, I’d love to see a “PRINT PREVIEW” tool.  For example, let’s say I’m working in a SCREEN 0 environment.  What I’d love to do is hit CTRL-P (for preview) and then have a screen pop-up which I can click to set to a 80x25 text screen, and then type on....

Thus, if I type, “Hello my name is Steve.  I like to program in QB64, but sometimes I run into issues with formatting and output being longer than a single line.”, I can see the text on my desired output screen and adjust it so my words are spaced properly and don’t break in the middle.  Once finished, all I need to do is CTRL-V to copy the properly formatted text, close the preview, and then paste it into the IDE where I was working last.

Word wrap doesn’t seem too useful to me, but a print preview sounds like it’d be a real winner!
Title: Re: Word Wrap in QB64 IDE?
Post by: bplus on April 20, 2021, 01:26:28 pm
Stimulating idea Steve! I have an experiment for today :)
Title: Re: Word Wrap in QB64 IDE?
Post by: bplus on April 21, 2021, 10:37:13 pm
'    Hi, my name is Steve.    This is my example.    It works just like a
' comment and is excluded from my code,    Because of the undefined $IF block.

' Instead of an all inclusive word wrap, I’d love to see a “PRINT PREVIEW” tool.
'  For example, let’s say I’m working in a SCREEN 0 environment.  What I’d love
' to do is hit CTRL-P (for preview) and then have a screen pop-up which I can
' click to set to a 80x25 text screen, and then type on....  Thus, if I type,
' “Hello my name is Steve.  I like to program in QB64, but sometimes I run into
' issues with formatting and output being longer than a single line.”, I can see
' the text on my desired output screen and adjust it so my words are spaced
' properly and don’t break in the middle.  Once finished, all I need to do is
' CTRL-V to copy the properly formatted text, close the preview, and then paste
' it into the IDE where I was working last.  Word wrap doesn’t seem too useful
' to me, but a print preview sounds like it’d be a real winner!

' I dont think word wrap would do the IDE justice. Its perfect. Its a simple
' intuitive IDE. Line continuations can be done using the underscore, I think.
' For wrapping printouts, that would be a project for notepad. But onscreen, I
' just cant see the necessity. It would be nice to be able to continue really
' long literals using a system like that, though.

' With all the under the hood work that would be needed to deal with syntax
' checking, code flow, indentations, ect. ect. When we already have this nice
' and  handy key on the keyboard to deal with it labeled ENTER why waste the
' time and potential can of worms trying to force the QB64 IDE to do even more.
' It already has too much glut clutter anyway.  You want word wrap then use
' notepad or a word document processor.

' Quote If theres one thing I would love to see, it would be a way to collapse
' SUB/FUNCTION blocks that one is finished working with. I presume that would be
' challenging to implement or it would have been done by now.  Well I have a
' suggestion for that, build a custom library for the app and who knows if it
' might not be helpful for others or serve as a starter with code already
' tested? When you have one worked out move it into library.

Above is some example text I pulled out of this thread and ran through following code Not in IDE but a Stand Alone .exe that takes contents of clipboard and rearranges them as word wrapped comments with a width limit of 80 including a single quote and space.

Code: QB64: [Select]
  1. _Title "Wrap up comments" 'b+ 2021-04-21
  2. 'Alter clipboard contents so that you can take some text while editing in IDE and paste it back altered and word wrapped to a given width.
  3. 'Try the above line with this one.
  4. 'And let's add some more stuff here.
  5. ' Ha, and even more stuff here.
  6. 'Hey, this is fun, let's keep going.
  7. 'And going, and going... like the Energizer bunny ;-))
  8. ClipCommentsWrap 80 ' and here is clipboard paste in paragraph below
  9. ' Alter clipboard contents so that you can take some text while editing in IDE
  10. ' and paste it back altered and word wrapped to a given width. Try the above
  11. ' line with this one. And lets add some more stuff here. Ha, and even more stuff
  12. ' here. Hey, this is fun, lets keep going. And going, and going... like the
  13. ' Energizer bunny ;-))
  14.  
  15. ' unfortunately, in order for the program to run you have to comment the lines.
  16. Sub ClipCommentsWrap (maxWidth As Long)
  17.     s$ = _Clipboard$
  18.     s$ = StrReplace$(s$, Chr$(13) + Chr$(10), " ")
  19.     s$ = StrReplace$(s$, Chr$(13), " ")
  20.     s$ = StrReplace$(s$, Chr$(10), " ")
  21.     s$ = StrReplace$(s$, "' ", "")
  22.     s$ = StrReplace$(s$, "'", "")
  23.     b$ = "' " + wrap$(s$, maxWidth - 2, t$)
  24.     While Len(t$)
  25.         s$ = t$
  26.         b$ = b$ + Chr$(10) + "' " + wrap$(s$, maxWidth - 2, t$)
  27.     Wend
  28.     _Clipboard$ = b$
  29.  
  30. 'This function returns the first segment of string less than or equal to maxLen AND
  31. 'the remainder of the string (if any) is returned in tail$ to be used by wrap$ again
  32. Function wrap$ (S$, MaxLen, Tail$)
  33.     ReDim As Long p
  34.     If Len(S$) > MaxLen Then
  35.         p = MaxLen + 1
  36.         While Mid$(S$, p, 1) <> " " And p > 1
  37.             p = p - 1
  38.         Wend
  39.         If p = 1 Then
  40.             wrap$ = Mid$(S$, 1, MaxLen): Tail$ = Mid$(S$, MaxLen + 1)
  41.         Else
  42.             wrap$ = Mid$(S$, 1, p - 1): Tail$ = Mid$(S$, p + 1)
  43.         End If
  44.     Else
  45.         wrap$ = S$: Tail$ = ""
  46.     End If
  47. Function StrReplace$ (s$, replace$, new$) 'case sensitive  2020-07-28 version    added to oh 3/16 for inpbs
  48.     Dim p As Long, sCopy$, LR As Long, lNew As Long
  49.     If Len(s$) = 0 Or Len(replace$) = 0 Then
  50.         StrReplace$ = s$: Exit Function
  51.     Else
  52.         LR = Len(replace$): lNew = Len(new$)
  53.     End If
  54.  
  55.     sCopy$ = s$ ' otherwise s$ would get changed
  56.     p = InStr(sCopy$, replace$)
  57.     While p
  58.         sCopy$ = Mid$(sCopy$, 1, p - 1) + new$ + Mid$(sCopy$, p + LR)
  59.         p = InStr(p + lNew, sCopy$, replace$)
  60.     Wend
  61.     StrReplace$ = sCopy$

Merely click the exe maybe sitting on your desktop and automatically the contents of the clipboard is wrapped to 80 char widths with comment space starting each line.


Title: Re: Word Wrap in QB64 IDE?
Post by: zaadstra on April 22, 2021, 02:51:22 pm
Amazing, I've learned a new $IF command :-)