aroberge / reeborg

Enhanced Karel-the-robot clone
http://reeborg.ca/reeborg.html
Other
47 stars 36 forks source link

Adding keyboard shortcuts to open/save code #370

Closed schellenberg closed 6 years ago

schellenberg commented 6 years ago

This might is not the most efficient way to do this, I'm sure, but I started using Reeborg with my students yesterday, and by far the largest problem was showing them how to save and open their code. As a partial solution to that problem, I've overridden the default keyboard commands for open/save, and tied them to importing/saving the code textarea.

Note that I've set the file to save as the name of the currently selected world, rather than pop open dialogue, since this provides a logical naming scheme for the file.

aroberge commented 6 years ago

This looks like a very worthwhile addition. Glancing at the code, I gather that the keyboard shortcuts are mac specific and I might need to implement something similar for Windows.

Unfortunately, I likely will not be able to test this until the middle of next week but I will almost certainly merge it at that time.

schellenberg commented 6 years ago

Actually, it should work on both Mac and Windows. We are using Windows (Chrome), and it worked great for all my students this afternoon. I just checked, and it works fine with Chrome on Mac as well. With Safari, however, saving works fine, but loading did not (the files were greyed out in the dialogue box, for some reason). There might be a simple solution to that, but I don't know it.

aroberge commented 6 years ago

Before I merge this code, did you know that one can save and open programs (including those in the library tab) using the "Additional options" menu? The reason I am asking is that I would likely eventually merge the code for the keyboard shortcut with the existing code, probably keeping the default names the way you have them instead of using "program.py" which is currently shown in my code.

schellenberg commented 6 years ago

Yes, I was aware. However, the feedback I got from other teachers (and my own students) as they used Reeborg in their classes was that the saving/loading of files caused problems. One other issue that cropped up in a few classes was that students did not save their library tab code. So, the most recent change made (to the instance of Reeborg that I'm hosting on Github for use with the Computer Science 20 textbook I'm writing) is to automatically save both the code and library code as one file when the keyboard shortcuts are invoked. When opening the file via the keyboard shortcut, Reeborg automatically splits the file back up into code/library. I only set this up to work with Python, as that's the language I'm using... you can see it here: https://github.com/sk-opentexts/reeborg/commit/92cd718f4f43f394ec1345cc2efc7bf185627aea

aroberge commented 6 years ago

Your combined saving of code+library is definitely a much better idea than the one was using which required the students to save the code and library separately. I will likely implement that as the default using the shortcut keys (and add support for Javascript and Blockly).