Move terminal echo logic into st.c