Pasting a string into Squeak is just like pasting a string anywhere else… unless it has quotes in it… or is really long. Then, you’re screwed… but only in a this-is-Smalltalk-and-I’ll-be-able-to-wiggle-my-way-out-in-a-few-moments sort of way.
UPDATE: check the comments after this post for two quicker methods.
In this trivial example, we could just put in the extra two quotes, but if the string was longer, a simple solution is to paste the text into a TextMorph and get its contents:
You can see that the quotes around template.NamlServlet have been doubled.
However, if you try to do this with a very long string (like an HTML page source), when you ask for the contents, it will be prematurely cut off (note ‘…etc…’ below):
What’s going on here? Well, if we browse Object’s ‘printing’ protocol (our hint to look in Object is that all objects can be printed in the tools), we find that printString actually calls printStringLimitedTo:
But fear not, the the method comment refers us to the perfectly named Object>>fullPrintString, which does just the right thing. You can even copy the correctly-escaped string right onto the clipboard:
n.b. if you ‘PrintIt’ the above statement, you will still get a truncated string, because the system will call regular printString on the result of fullPrintString.