Saturday, May 27, 2006

Window configuration (and content) now saved in the image

I implemented a useful new feature. When you start the UI it no longer resets all state, instead it tries to pick up where it left off. This was easy to implement. First, I made it so that window positions are stored in the 'world-loc' slot of the world tuple associated to the window. Next, I made the UI startup routine test if the windows hash is non-empty; and if so, it would iterate over the hashtable's values, and open windows with the gadgets stored therein.

This doesn't work perfectly yet; for example, the stacking order of the windows is not saved. However this is easy to fix.

Adding a feature like this would be difficult to a language which was not image-based. The key thing is that everything is saved. You can open a browser window, resize it, scroll the panes, open a listener, push some values on the stack, save the image, close Factor, re-open it, and your values are still on the stack and everything is as you left it. You can even cause a parse error in the listener, save the image, re-open the image, and invoke a restart as if nothing had happened!

Of course, I/O streams, aliens and other objects will expire, so its not quite as flawless as I described above; but in most cases, it Just Works.

1 comment:

sohail said...

Do you think that writing the used memory of a process to disk would achieve something similar?