This is an important feature to avoid the overflow of the command buffer, and because a very large number of undo limit can slow down the execution of undo/redo horribly due to the command pattern stuff (because a lot of commands can't be reversed).
Undo limiting means if the undo number limit (defined by the user) is reached or the command buffer is too small, the first command(s) from the queue has to be executed on the old data and has to be deleted from the queue.
The size of a command is computed before adding it to the queue, then the first commands in the queue are executed/deleted as many times as it's needed to free enough space in the queue. After that the command is added to the queue.
The queue uses memory mapped files, so it only uses the smallest necessary system memory (in 128 kb granularity).
I was always afraid of it. But it's so easy to use! (if you don't give a shit about neat code, nice design, and just get it done).
So, I've added a menubar, with some options window, and my favourite, a sort of undo manager, I don't know how to name it. It's a listbox with all the command names in the command queue, so the user can undo/redo multiple commands at a time. The undoed commands are highlighted, so it's pretty easy and straightforward to use.
Adding menus was a necessary step, because I was running out of hotkeys....
The next step is a toolbar, but I don't really feel like drawing all the little icons.
Added some new features, like scaling, and some others too.