Comments (8)
I just found out that $stdXX.tty?
is always false on cygwin + mintty. Don't know how to get around that.
from tty-prompt.
That's quite unexpected behaviour. I would be curious to find out what RUBY_PLATFORM
returns in cygwin & mintty. Whether there is a way to determine cygwin from that value?
Alternatively, I think we could detect what is being used by calling some utility functions. Kind of like features sniffing. For example, cygwin comes with cygcheck
utility that we could call:
system('cygcheck --version') # returns true if exits with 0 status or nil otherwise
Same for the mintty
system('mintty --version') # true or nil
Obviously it is not the most optimum solution as there is more emulators out there but hopefully would make it work for majority of Windows users and with time we could refine it. This feature detection shouldn't make the tool slower as this check is only performed when you create the prompt instance.
Would you mind checking this theory?
from tty-prompt.
@kke Did you have any chance to look into this? I'm hoping to release new version this weekend.
from tty-prompt.
Seems like it's a problem for a lot of projects. Git for windows has solved it with some strange hackery: http://git.661346.n2.nabble.com/PATCH-mingw-make-isatty-recognize-MSYS2-s-pseudo-terminals-dev-pty-td7654456.html
Here's some rust tty package pull request that fixed it:
softprops/atty#12
There's some c-source here: mintty/mintty#482 (comment)
from tty-prompt.
I think there are two issues that we are discussing here. Original issue was to correctly recognise whether this library has to use Unix console capabilities or Windows specific api. The problem was if I understood correctly that everything works fine in Windows console/powershell. However things stop working fine when Cygwin/mintty are used as tty-prompt
assumes windows environment and ideally would run as if standard unix console is present. That is why I suggested to run specific utilities to figure this stuff out.
In other words, this gem doesn't care what tty?
value is as it is not used for anything in the code base. It is down to client to figure out whether it is dealing with console, file io or some other thing. tty-prompt
prints to standard out by default wherever that may be. You can pass :stdin
parameter to instruct to output to whatever but it is not the concern of this library per se.
from tty-prompt.
from tty-prompt.
I have changed windows?
check. Instead of checking for operating system, it looks at Ruby file feature. This is based on the observation that if cygwin is installed it will require its own Ruby installation which will be unix compatible. Therefore this should work fine on Unix flavoured emulators in Windows.
from tty-prompt.
@kke Released v0.11.0
with Windows support.
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.