fixes #51, restoring caret, scroll, grammar and encoding state.