state stack for text engine