red-data-tools / unicode_plot.rb

Plot your data by Unicode characters
MIT License
246 stars 12 forks source link

Fix animation example #33

Closed kojix2 closed 3 years ago

kojix2 commented 3 years ago

This pull request fixes the problem of showing "1000" in animation example.

image

The plot contains the ANSI escape code. Even if the length of the string printed on the terminal does not change, the actual length of the string may change. If the string is too short to overwrite all the characters, you will see "1000" left at the end.

kojix2 commented 3 years ago

In most cases, SIGINT will be sent at the pink point. However, in some cases, SIGINT is sent during the execution of the green line.

If the SIGINT is sent during the execution of the green line, the code in the yellow area will not be executed. If SIGINT is sent at the pink point, the code in the yellow area is already executed.

Therefore, there are two different possible positions for the cursor when SIGINT is sent and finished. This can be confirmed by actually trying Ctrl+C many times.

image

The second commit is intended to change the code so that SIGINT behaves the same no matter when it is sent.

kojix2 commented 3 years ago

You were right in your idea.

It's much better to leave the plot in the terminal when the animation and programming is finished.

I realized that yesterday. Then I remembered this pull request. I will change my mind and also change the behavior of YouPlot.

Thanks.