philburk / pforth

Portable Forth in C
BSD Zero Clause License
588 stars 94 forks source link

ANSI escape sequences on Windows #156

Open catsanddo opened 7 months ago

catsanddo commented 7 months ago

Currently sdTerminalOut parses console codes manually and uses win32 API functions such as SetConsoleCursorPosition to perform certain actions. The issue is that a very limited number of codes are actually supported. It is impossible to implement a word such as at-xy from within pForth without supporting more codes.

Fortunately Windows has started supporting virtual terminal sequences natively and now recommends them over using native console API functions. There is some code required to initialize this feature (shown at the bottom of this page), but it could simplify the task of parsing these codes by hand while also allowing for more escape sequences to be used by user code.

I believe that using this new feature over the old API would be preferable.