"RokuMarkn" wrote:
EnTerr, I would note that the library you recommended (linenoise) uses ANSI escape sequences to clear the line, move the cursor, etc. This will not work on all terminals. It will almost certainly not work on any Windows telnet client.
The Windows Telnet client uses ANSI terminal mode by default. (It also has options to use VT100, VT52, or Microsoft's VTNT).
It looks like there's some confusion here between the Windows cmd shell and the Windows Telnet Client. The Windows command shell, cmd.exe (actually the Console Host, ConHost.exe, which supports both cmd.exe and Powershell), does not support ANSI escape sequences (although Microsoft is adding support for them in Windows 10 to bring them forward into the 20th century). However, the Windows Telnet Client, a console program that runs under cmd and Powershell, etc, does support ANSI escape characters. It was designed that way specifically to allow Windows computers to communicate with other non-Windows systems, many of which have been using ANSI or VT100 terminal emulation since the dark ages.
I don't know exactly which subset of the ANSI escape sequences are supported by Windows Telnet, but I do know that the few used by linenoise are supported. I've been able to type ANSI sequences into Telnet and see them take effect. The one I've used the most is
ESC [ 2 J (clear screen). Before PurpleBug, I even went as far as to include a little subroutine in my code to have the Roku send the sequence, so I just had to type
cls() at the debugger prompt to clear the screen:
'
' Clear screen - use while stopped within the Roku Debugger
'
Sub cls ()
' Send the ANSI clear screen escape sequence: ESC [ 2 J
Print Chr(&h1B); "[2J"
End Sub
Notwithstanding the above, I have no idea how trivial or non-trivial it would be to implement something like linenoise in the Roku Debugger, since I don't have access to the Roku Debugger code, obviously. I'll leave that to the experts to determine. And I'm only speaking from a Windows perspective here. And I can't speak as to the various incompatibility issues that may be present with different terminal clients on different versions of different OS's.
P.S. If you want to have some fun with ANSI escape sequences on the Roku, go to
http://artscene.textfiles.com/vt100/. Download any of the listed files into your package directory (my favorite is
http://artscene.textfiles.com/vt100/trekvid.vt), then run the following code:
Sub Main ()
vt = ReadAsciiFile ("pkg:/ansi/trekvid.vt")
Stop
Print vt
Stop
End Sub
In Telnet, when you get to the first breakpoint, type "s", and watch a politically-incorrect Star Trek vessel flying through space firing its phasers and displaying naughty sayings.