Comments (11)
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.
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.
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.
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.
That sounds like a good theory. I'll dig.
from tty-prompt.
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.
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.
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.
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.
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.
Released v0.7.0
. Enjoy!
from tty-prompt.
Related Issues (20)
- Feature request: Prompt for value or optionally go into editor mode HOT 2
- Using an enumerator for choices HOT 3
- select hangs after a pipe HOT 1
- multi_select validation for "min" option ignored if "max" validation passes HOT 1
- Select not working in windows + bash terminal HOT 1
- tty-prompt does not seem to work in ARM64 Mac Monterey jruby-9.3.3.0
- multi_select: pressing ctrl_a or ctrl_r on filtered results, raises an exception
- Better error message for validation
- Dashes in a value provided to ask are converted to spaces after up-arrow
- Suggestion for documentation HOT 1
- Handle error when `value` is not a string
- ask and multiline flicker while typing
- Unable to define default value for multiline
- Customizing the check boxes?
- `select` errors when provided a hash and a block
- Allow using `k`/`j` in addition to arrow keys to move selection up/down HOT 1
- Allow wrap-around when using arrow keys to change selection HOT 2
- Request: `filepath` and `pathname` file existance validator HOT 1
- Allow messages to be passed as keyword argument HOT 1
- Add option to save history and reload.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tty-prompt.