Very nice - even managed to duplicate the demo with a bit of effort (once I got 32bit gl librarires installed in my 64bit ubuntu and got the standard 3.0 image/vm to start...).
Now, it appears one can do/print with ctrl-d/ctrl-p -- and that it will work for the current line, eg:
1 + 1 <ctrl-p> "prints 2"
But how about blocks? Is there a reasonable alternative to either selecting with the mouse, or with shift-arrow? As far as I can tell even simple "two-liners" force my fingers off of home row...
Also anyone happen to know if there's a usable vim-like interface/editor/thing for pharo (other than just starting vim and copy/pasting)?
For the curious, I got this to work (just copy-paste into a Workspace. Note that I had to change getGif with getJpeg -- but I'm not yet sure how to "live patch" that properly, for now I just abandoned the stack trace, fixed the code and evaluated again (the last line):
Gofer it
squeaksource: 'MetacelloRepository';
package: 'ConfigurationOfXMLSupport';
load.
(Smalltalk at:#ConfigurationOfXMLSupport) project latestVersion load.
Gofer new
squeaksource: 'XMLSupport';
package: 'XML-Parser'; load.
"Get the data, you can try and print this, if you want"
data := 'http://picasaweb.google.com/data/feed/api/all?q=puppy' asUrl retrieveContents.
"parse it"
doc := XMLDOMParser parse: data.
"split up"
entries := doc
allNodesSelect: [ :n | n name = 'entry' ].
"pick one"
entry := entries anyOne.
content := entry
nodesDetect: [ :n | n name = 'content' ].
url := content attributeAt: 'src'.
(ZnEasy getJpeg: url) asMorph openInHand . "Opens image"
yes blocks are also evaluated with cmd+d. So its possible this way to evaluate/execute multiple smalltalk statements (message sends).
so you can do
a := [ message . message . message . ].a value.
if you just ctrl+d it will execute all messages. "a value" executes the body of the block.
also in pharo like emacs and vim , shortcuts are tied to methods so you can add a shortcut for any method you want. And since pharo has over 70 thousands methods , you will need a pile of keyboards :D
We could implement also a more convenient way of executing multiple lines in a workspace. Generally in Pharo we spent most of our time with system browser and debugger and much less with workspace. Workspace is more for one liners. There is also already a tons of shortcuts, I am new with pharo so maybe there is something already I am not aware of.
Also I don't mind using the mouse now and then. I find it harder to remember tons of keyboard shortcuts. But I am moving slowly to a more keyboard orientated workflow.
[edit: also, yes "blocks" was an unfortunate choice of words earlier, I did mean logical blocks of code, not actual Smalltalk blocks. Like typing in the text in the demo-example above and having it all evaluate (or if not all, maybe the first and second half separately).]
I guess I'm leaning a little in the direction of the "tagline" of GNU smalltalk ("The Smalltalk for those who can type").
I'm not entirely sure I really want a "vim" mode -- but some form of keyboard-driven modal editing/editor/browser-thingy would be good, I think. I definitively need an interface that is (fully) usable without the mouse, due to wrist-strain.
On a similar note, this looks very promising (both as a VM and as inspiration for shorcuts):
AFAIK there's no keyboard shortcut that selects the whole block (taking block to mean a multi-line chunk of code, rather than a closure).
What you can do is put empty (or even non-empty!) comments between chunks of code, double-click just after the comment and everything up to (but not including) the start of the next comment will be selected.
""
myFoo do: [:each |
each bar
]
""
... and so on.
Many years ago someone did produce a set of vim key bindings for some version of Squeak (ancestor of Pharo), never tried it and I've no idea how well it would work under Pharo. Googling for vim squeak will get you some starting points.
you dont need to do that as I replied above. Using my approach will automagically select the whole block and evaluate it without having to touch the mouse.
The second Gofer is not needed. The XML Support is all installed with the #load message.
I don't think you can live-patch a DoIt from Workspace. What you can try is create a test class and method. However you can demo this with the following exercise...
1. In a newly opened image, right-click the background and choose 'System Browser'
2. Fill in the template with #MyTest and 'MyTest' as follows...
Press <ctrl-s> (on windows. or choose 'Accept' from the context menu - but the 3.0alpha I'm on has an error with this. works in 2.0)
3. Create a method by clicking on the "no message" protocol and replace the template with the following and save using <ctrl-s> or <Accept> from the context menu...
parse
| data doc entries entry content url |
"Get the data, you can try and print this, if you want"
data := 'http://picasaweb.google.com/data/feed/api/all?q=puppy' asUrl retrieveContents.
"parse it"
doc := XMLDOMParser parse: data.
"split up"
entries := doc
allNodesSelect: [ :n | n name = 'entry' ].
"pick one"
entry := entries anyOne.
content := entry
nodesDetect: [ :n | n name = 'content' ].
url := content attributeAt: 'src'.
4. Create a second method
get
(ZnEasy getGif: url) asMorph openInHand . "Opens image"
4. Evaulate the following in a Workspace with <DoIt> from the context menu.
MyTest new parse get.
5. At the debugger prompt, click <Debug> then right-click and choose <Full Stack>. Scroll down the call stack and select 'MyTest get'. (In my 3.0alpha you need to select it two times to highlight current position - something to clean up there)
6. Replace getGif: with getJpeg:
and save using <ctrl-s> or fromthe context-menu choose <Accept>.
Observe that the call stack shrinks back so that 'MyTest get' is at the top of the call stack.
7. In the debugger click <Proceed> or <Over> as you like.
Further down some asked "is anything from the Smalltalk OO model that hadn't made its way into Ruby?" Well I don't know about OO model, but to extend my example above, at step 5 when the debugger appears, <Save & Quit> the image. Then copy the folder to another PC, open up the Pharo image, and continue with steps 6. and 7.
In days past with the predominance of the desktop, 'perhaps' the 'live image' concept central to Smalltalk had some logistic issues (for some) but I think in this day of applications running on remote web based systems, being able to store/download/restart the execution context that caused an exception is a great advantage.
The other interesting this is that VNC can connect directly into the image, so you can be directly using the GUI IDE Smalltalk tools on a remote server.
Now, it appears one can do/print with ctrl-d/ctrl-p -- and that it will work for the current line, eg:
But how about blocks? Is there a reasonable alternative to either selecting with the mouse, or with shift-arrow? As far as I can tell even simple "two-liners" force my fingers off of home row...Also anyone happen to know if there's a usable vim-like interface/editor/thing for pharo (other than just starting vim and copy/pasting)?
For the curious, I got this to work (just copy-paste into a Workspace. Note that I had to change getGif with getJpeg -- but I'm not yet sure how to "live patch" that properly, for now I just abandoned the stack trace, fixed the code and evaluated again (the last line):