Matt Gemmell

My new book CHANGER is out now!

An action-thriller novel — book 1 in the KESTREL series.

★★★★★ — Amazon

Revert to Saved

interface 1 min read

Whilst coding tonight, I had a difficult time deciding on appropriate behaviour for 
the "Revert to Saved" functionality.
To give some very brief background, I'm playing around with a kind of cross between 
TextEdit and Stickies, for my own use. For the purposes of this discussion, let's 
assume that I have a document-based application, which edits rich text. Each document 
obviously has some quantity of rich text, and in keeping with the Stickies tradition, 
each document also has a background colour. In addition, when a document is saved, its 
window's size and position are also remembered.



Thus, we have three basic items being saved into a document's file: the rich text, the 
background colour, and the window's frame (origin, width and height).



Now, suppose the 
user opens a document, edits it in some way (potentially including changing the text, 
styles, background colour, and/or window size or position), and then chooses Revert, from 
the File menu. Clearly, we revert the text and its style information to the last saved version. The question 
is, do we also revert the background colour and window frame?



The decision I came to was that yes, we do revert the background colour, since it's part of the "document"; 
the appearance of the 'data' which the user associates with that particular file. However, we do <em>not</em> 
revert the window frame, since the window is merely the current viewing port which reveals the underlying 
document, and is not inherently a part or property of that document (also, reverting the frame could lead to 
a very jarring visual effect).



I'm reasonably comfortable with my decision, but there's still sufficient niggling doubt for me to request 
your thoughts on this. I'd also be interested in thoughts on the related issue of whether or not we "dirty" 
the document when (a) the background colour is changed (my instinct: yes, we do), and (b) when the window 
size/position changes (my instinct: no, we don't). I don't want to get into BBEdit-style two-tiered "dirtying" 
of documents either.



I <em>do</em> very much need/want to save the window size/position, given the nature of this application - 
that functionality cannot be abandoned. I just wish I could reconcile the issue of saving and loading window 
frame information with how <em>important</em> that information is in terms of dirtying documents and reverting 
them. Hmm.