lemunozm / ruscii

Terminal graphics engine: build your games in the terminal!
Apache License 2.0
171 stars 15 forks source link

`enter` doesn't close the error #30

Closed lesleyrs closed 1 year ago

lesleyrs commented 1 year ago

https://github.com/lemunozm/ruscii/blob/118f187303db4839dd6faa095f83be14b0ac8777/src/app.rs#L140-L144

When you resize the screen to be too small the terminal locks up and asks you to press enter, but it doesn't respond to it and you have to close it completely.

Windows 10, windows terminal

lemunozm commented 1 year ago

Mmm... I have no windows now to test it, but probably removing lines 141 and 142 will make this work. In fact, I think they are not needed. If the program fails, it has a last chance to recover the terminal in line 143 and finish.

lesleyrs commented 1 year ago

Idk why but I didn't get the same behavior as last time, first it would lock up if I resized the window. Now it only locks up if I start the game while the window is minimum size.

Your suggestion fixes the latter though and exits correctly. I think this is fine because if you start a game at this size it's not gonna resize itself and you won't see anything anyway. If you replaced 142 unwraps with results would that mean it could keep running correctly though? Not that it matters here.

lemunozm commented 1 year ago

I think the issue is that after it fails (in a bad internal way), no inputs event comes to the terminal, so the app is locked at that next: io::stdin().lock().lines().next().

In case you start with a very small window, the user can add some draw some special message. But the current code only is executed if the app fails, not if the app has a small window.