move switch buffer function to tmtxt-buffer.js