Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 16
I don't believe there's a workaround: ncurses works by updating live console output, and sololearn input/output capture system cannot handle such things...
+ 9
ChillPill
visph is correct, the i/o is handled by sololearn via plain text files only.
Means even if you get the ANSI escape sequences interpreted via "less", still the final output will be piped to a plain text file only (logfile.txt which is later converted to completed.txt), making those escape sequences to again appear in final output.
Check this out for more info about what SL is doing under the hood ( I didn't expect them to comment it so well ) 👇
https://code.sololearn.com/cQM7WC5FCfbA/?ref=app
There are some possibe solutions I can think of to tackle this rn :-
1) strip off all the escape sequences from the output file (maybe via regex search)
2) try changing TERM variable so that ncurses doesn't send all the escape sequences with it
3) ( the Brian 's idea ) make use of SL's web code playground to interprete those escape sequences and then display it there.
+ 5
ncurses is great... but only works in "normal" interactive context, not through sololearn input/output capture system ^^
+ 5
I rather think that input/output are exchanged as plain text...
web i/o are handled at client side... (php, html; but node.js is server sided as others languages)
+ 4
ChillPill I really hope that you can figure this one out. I suppose that on SoloLearn it would have to be some kind of dynamic translator into HTML. How difficult would that be?
+ 4
Redirect stdin and stdout of your C/C++ program to shared flat files or pipes that the JS can read/write during run time, and in turn update the DOM.
+ 4
I also thought the same, but I thought that this is only applicable till the time we are text formatting (backspace,clearscreen etc)
But could not think of a way to decode colour character and all that.
+ 4
ChillPill I had naively proposed to use JS to issue a shell script to write and compile the curses-based program, run it, and redirect its i/o streams to some means of interprocess communication (IPC). From there, the JS would pick up the output and translate escape sequences into HTML directives for display on the screen.
If it could work, then my own master plan would fall into place, and I could release my original 1980's interactive VT games!
Alas, the IPC is the brick wall. I realized later that SoloLearn's JS runs on the client, not the server. It could not start a shell on SoloLearn's server and interact with files.
+ 1
Martin Taylor if I am correct, we can change the TERM environment variable before executing the script to make sure ncurses sends appropriate ANSI escape sequences for that perticular terminal.
My first attempt was to change it to something very bare bones (like dumb) so that there is less to no escape sequences to work with, but it ended up removing the entire output from the console, maybe there is something I am missing here.
0
i don’t understand any of this, but i hope you figure it out!