btco / qx82

Tiny Javascript engine for retro games
MIT License
421 stars 19 forks source link

readLine printed over several lines #8

Open GuillermoDylan opened 8 months ago

GuillermoDylan commented 8 months ago

Would there be a way to make the method qxa.readLine() show the typed text over several lines instead of overflowing on the screen?

My initial thought was that the maxLen parameter would do something like that, but it seems to do nothing when used.

btco commented 8 months ago

You mean for multi-line input where the user can press ENTER and continue typing? Or just input a very long line that wraps around?

One problem is that qxa.readLine() doesn't support true editing, only backspacing, and if the text flowed to a new line people would probably expect the arrow keys and other editing keys to work.

Maybe what I should have is more of a text-area "widget" where users could edit text, but that would be a substantial undertaking.

In the meantime, making it so qxa.readLine() wraps around might be feasible, I'll look into it.

GuillermoDylan commented 8 months ago

Yea I mean just wrapping a very lo g line could be cool, I tried editing the code for a small project I made and adding a line break ('\n') after x characters seemed to work fine (not for very long inputs I guess tho).

The text area sounds cool but maybe too much for small texts in mu opinion, but maybe I'm just imagining how it would work differently.

btco commented 8 months ago

Makes sense, I'll think about it!

HoofedEar commented 4 months ago

~~Here is a quick-and-dirty version of readLine I whipped up, no idea if it's what you're looking for or any good: let a = await qxa.readLine("", 10) and it will restrict the length of each line to 10.~~

EDIT: Created a PR for this instead, with better logic and understanding of what maxLen is