Giter Site home page Giter Site logo

Comments (11)

piotrmurach avatar piotrmurach commented on May 18, 2024

Thanks for reporting this. It seems that El Capitan has a different interpretation for the ansi escape codes that move arrow up and/or clear the line. I agree, the problem is most likely in tty-cursor dependency. I don't run El Capitan so would really appreciate help here, otherwise I'm not sure how I would fix it as it works for me.

Have you run the specs? Maybe the failure shows the different escape codes being used?

Is this behaviour similar when you run multi_select? I would also try the mask and slider as they use similar line clearing ansi. If mask works as expected then it may imply that up/down arrow ansis are broken. Anyhow, you should be able to run quickly all the examples.

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 18, 2024

One change that has been introduced in new tty-cursor was the code for moving to the previous line. see. Therefore, would it possible for yourself to uninstall tty-prompt v0.6.0 and install v0.5.0 and see if select works there?

from tty-prompt.

Burgestrand avatar Burgestrand commented on May 18, 2024

Ok, neither multi_select, mask or slider clears data as expected. Here's what mask looks like, with an interesting error:

Are you on track for Launch Zipline by 2019-09-10? stty: 'standard input': unable to perform all requested operations
Are you on track for Launch Zipline by 2019-09-10? astty: 'standard input': unable to perform all requested operations
Are you on track for Launch Zipline by 2019-09-10? •sstty: 'standard input': unable to perform all requested operations
Are you on track for Launch Zipline by 2019-09-10? ••dstty: 'standard input': unable to perform all requested operations
Are you on track for Launch Zipline by 2019-09-10? •••astty: 'standard input': unable to perform all requested operations

Test suite for TTY::Prompt is all green!

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 18, 2024

Hmmm.... the mask error makes me think that when select is called what may happen is that the error gets printed out to sdterr and then when the line is cleared it only clears the error and leaves the actual line to be cleared untouched? That would explain why the tests are passing as they are using StringIO to mimick stdout and stderr. Do you know where this error is coming from? It seems that unix stty utility tool is misbehaving?

from tty-prompt.

Burgestrand avatar Burgestrand commented on May 18, 2024

That sounds like a good theory. I'll dig.

from tty-prompt.

Burgestrand avatar Burgestrand commented on May 18, 2024

Yes, indeed, turns out that %x[stty …] for Echo and Raw sometimes prints an error to standard error (although I'm not sure when, or why). If I redirect stdout/stderr to File::NULL for all four of these commands, it appears to work properly.

system("stty echo", $stdout => File::NULL, $stderr => File::NULL)

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 18, 2024

Nice work, I suppose we could %x{ stty ... >/dev/null 2>&1 } and thus avoid shelling out with system command? Alternatively, we could try to use io/console and latest echo= implementations? Would you have time to submit PR?

from tty-prompt.

Burgestrand avatar Burgestrand commented on May 18, 2024

Possibly today! Do you want to keep the separate Echo and Raw-classes? They might be superfluous if io/console is to be used, but since they've been declared public maybe we should keep them.

EDIT: Also, %x[] is also a subshell, just as system, there's no real difference there other than the return value and that system has more capabilities and options.

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 18, 2024

I'm not really sure since when io/console is part of standard lib? Currently the code runs even on ruby 1.9.3? I'm not precious about these classes and quite frankly would welcome removing them. Do you have time to look into this?

Another step after this fix is to extract the Reader to another dependency as it's usuful in its own way and provides conveniences that I can see easily applicable to other CLIs.

Point taken re runing external commands, no matter how many times I use these I get them mixed up, that's probably why I've created tty-command

from tty-prompt.

Burgestrand avatar Burgestrand commented on May 18, 2024

I created a quick PR using the workaround code I used locally that uses io/console. If you decide that you'd prefer the FD redirection approach instead I'm happy to rewrite the PR; it's all just code. :)

from tty-prompt.

piotrmurach avatar piotrmurach commented on May 18, 2024

Released v0.7.0. Enjoy!

from tty-prompt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.