Improving the print-it support in GTPlayground

Print it is one of the actions that exists since ancient times in Smalltalk environments. A while ago, we enhanced the GTPlayground with a Print It action that does not affect the existing code. Unlike in the classic behavior in which the printout gets inserted in the code editor, the improved version pops it up in a separate floating morph.

While this worked fine for most coding cases, every once in a while people reported the need to paste the printout in the text editor - hence the exact opposite the new solution tried to mitigate. To accommodate this use case Andrei and I made it so that you can now simply press Enter while the popping morph shows the printout and the text gets inserted in the editor.

But, there are two tiny details that come with the new version.

When no text is selected and you print, like in any Smalltalk environment, the whole like will be evaluated and printed. However, unlike other environments, the line will only be highlighted. This is a new mechanism that we introduced and that applies to any other commands as well (like evaluating or inspecting), and it is useful to provide a visual feedback to the user of what was actually executed. As opposed to selection the highlight has no influence on editing - in fact, it disappears as soon as you type anything.

When a selection does exist, the highlight is added on top. With this mechanism, when existing the popper widget via Esc or Backspace, only the highlight gets erased, and the exact editor state is restored to how it was before printing.

The other tiny detail is that when you press Enter, the text gets pasted as a comment. In this way, the syntax highlight does not get affected.

It is interesting to notice how many variations there can be even in a small feature like the one mentioned above. Just because a certain solution resisted for decades, like in the case of print it, it does not mean it is the only one or even the best one. For this reason, it is our duty to explore variations and guide the search by having the developer experience in mind.