How to delete or rewrite a line of text in DrRacket?

I would like to display the text and then overwrite it (for simple progress indicators, etc.). The usual carriage return display trick ( "\r" ) works fine when running Racket in a terminal on Linux and Windows, but in DrRacket and GRacket, carriage return does not seem to move the cursor to the beginning of the line.

Using this code as an example:

 (for ([x 5]) (display "\r") (display x) (flush-output) ; The result is the same with or without this line (sleep 0.1)) 

Running in the terminal results in a counter that overwrites itself; at the end, only 4 displayed in the terminal.

Running in DrRacket causes the numbers to be displayed and not overwritten:

 0 1 2 3 4 

Is there a way to rewrite a line of text in the DrRacket interaction window?

+5
source share
1 answer

For an authoritative answer to this question, you will want to hear from the Robby Findler racket user mailing list (see https://lists.racket-lang.org/ ).

I am about 85% sure that the interaction window does not do this, i.e. allows you to overwrite already displayed text. If you want to do something like this, you probably want to create your own text box using the graphical toolbar. Thus, you can change the text in the window in any way.

+3
source

All Articles