I tried things like say("Hello\nthere") and some variants with no success. I can copy and paste multi-line text into Snap! and that works fine.It seems If I press the 'Enter' key while in an input field it leaves the block.
Is there some way to do this without leaving Snap!?
In the Strings library is a MULTILINE block that you can put into an input slot of JOIN (or anything else). It will allow you to type a newline, or text containing newlines, whatever you like.
Ah, that works fine. As does dardoro's unicode 10.
So what is the design rationale for blocks like join() having only single-line input? What is the harm in allowing every textual input to be multi-line?
I've considered making every text/any input multi-line, like I did in GP. But I'm afraid users will abuse newlines for layout attempts, which I want to discourage at this point, because we might/will change the automatic text layout rules for speech & thought balloons, result bubbles, variable watchers over time, which would and will break projects that hack together their own text formatting.
Sure, there are pitfalls either way. My idea of what the code-/multi-line inputs are for is to, umm, input text. In the case of code it might make sense to actually write it outside of Snap in a "real" code editor and then copy and paste it into Snap. Likewise in a multi-line text input it might make sense to simply copy and paste some already existing text that's not too long altogether, e.g. some part of JSON/CSV that you find online (in Wikipedia, Stackoverflow, MDN etc.), where you don't get or don't want the whole file. Point is, this is more about data than about its representation and formatting. That's not to say we don't want to have better test formatting, just that I'd rather not establish a best practice of hacking your own custom text output format.
Most of the time, I find it useful that hitting enter gets out from editing that input slot. Sort of like tab skipping to the next input slot. And, I'm in the habit of always hitting enter when I'm done with a text, and most of the time I don't want that redundant newline at the end of an input string.
But I could learn to live with it, if this changed; I'm not adamant about keeping it this way.
P.S. Then maybe instead of having a checkbox for multi-line we could have a checkbox for single-line.
Right, I forgot Gorin's Law ("Never believe anything a user says") again. But maybe he meant the \n as just a forum shortcut for an actual multiline text and it was I who miunderstood.
Right. But that's point of \n - when embedded in a string it is replaced with unicode 10 / new line.
And why do so many languages support this? Because it is difficult to type a multi-line string in textual languages using the ENTER key.
Paradoxically, Snap! has no problem with users entering multi-line text using the ENTER key but chooses to disable it by default.
What are the roles of text in Snap!? Some uses are for speech balloons. As Jens has explained there is tension between text that is user-formatted and Snap!'s auto-formatting (as value balloons or speech bubbles). My use case that led to this thread was to generate text (a summary of some search results) to be exported and copy and pasted into a text file. This thread has revealed 3 or 4 ways to do this, but it was frustrating it wasn't apparent how to produce a multi-line text object. I even searched the manual for "new line" but didn't think to search for "multi-line".