handle history writing internally

The problem with ->WriteHistory() is that it outputs the history entires
unmodified, which for multiline entries results in them being turned
into multiple entries when you restart tdsql.

This saves history into .tdsql_history in YAML format, but can read the old format backward-compatibly.  The commit message doesn't entirely make sense since I failed to squish two together properly, oh well.