render
seems like it might be good to have as public api.
Hey everybody. I wonder if someone has any tip on how to do this: I would like to have TTY::Prompt
return a value from a keypress event. Something like this:
prompt = TTY::Prompt.new
prompt.on :keypress do |event|
if event.key.name == :page_up
prompt.return 'four' # <= I want something like this
end
end
response = prompt.select "Select", %w[one two three]
puts "response: #{response}"
I have spent the last two hours digging in the Prompt and Reader code trying to figure it out, until I admitted defeat and realized Piotr's code is way above my paygrade....
Hi everyone. I am working on a shell and I have trouble with TUI applications such as man, less, vim... I am using TTY::Command to run these commands in a PTY but it seems the input, the output, probably both are not wired correctly. Even the following code does not display things correctly (let alone input).
runner = TTY::Command.new pty: true, output: some_logger
runner.run 'vim'
Are these applications supposed to be supported (am not sure if it's ncurses specific or related to termcaps)? If not, is it planned? Am I doing it wrong?
Thank you in advance :)
%x[vim]
as a test. As an alternative, you can try tty-editor .
min
option to go with max
could also work: min: 1
would ensure at least one option is selected - I can see that doesn't exist yet, though I'm not certain on the required
side
teletype
to create a project, it creates a templates
folder within lib/PROJECT
. What is this meant for?
getc
method you will get similar behaviour. Had a similar issue recently to do with TTY::Prompt behaviour (see piotrmurach/tty-prompt#137). Glad you managed to figure this out!
macbook:app masaino$ ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin19]
macbook:app masaino$ teletype -v
v0.10.0
macbook:app masaino$ uname -a
Darwin macbook.local 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64
macbook:app masaino$ teletype add com --desc 'desc A'
create spec/integration/com_spec.rb
create spec/unit/com_spec.rb
create lib/app/commands/com.rb
create lib/app/templates/com/.gitkeep
inject lib/app/cli.rb
macbook:app masaino$ teletype add com --desc 'desc B' --force
force spec/integration/com_spec.rb
identical spec/unit/com_spec.rb
identical lib/app/commands/com.rb
identical lib/app/templates/com/.gitkeep
macbook:app masaino$ exe/app
Commands:
app com # desc A
app help [COMMAND] # Describe available commands or one specific command
app version # app version
teletype
isn't yet that smart to figure this out, unfortunately. When you come across things that could be improved or have suggestions please post them on the project issues tracker or even better submit a pull request. At the moment I'm updating all tty components and working on the tty
itself to provide a bit smoother experience in v0.11.0
.
params
invalid but no actual errors are raised. I would suggest reading parse method section and params section. I wrote the Readme to document all the APIs and usage but please free to submit PR if something is missing or not clear enough. I'm keen to make sure the docs are complete and easy to use.
help needed: for some reason, I "gem install tty" but don't get "teletype" as a new command.
effrey@Mac-mini youtube % gem install tty
Successfully installed tty-0.10.0
Parsing documentation for tty-0.10.0
Done installing documentation for tty after 0 seconds
1 gem installed
jeffrey@Mac-mini youtube % teletype new app
zsh: command not found: teletype
tty
gem. I verified by installing v0.10.0
that the teletype
executable works as expected. I'd potentially look into reinstalling Ruby version that you're using. However, this is an issue for yourself to figure out why your system fails to find Ruby installed executables.
Hi @piotrmurach, TTY Toolkit is great and thank you for saving a lot of our time. However, I have a small problem. I can't figure out how to send the user input from
prompt.ask(">>") do |q|
q.validate(/(close)|(\A[0-9]+(\.[0-9]+)?[\+\-\*\โ][0-9]+(\.[0-9]+)?\z)/, "Invalid question, #{ENV["USER"].capitalize}. Try again.\a")
end
to a global variable. How may I do this?
TTY::Table
, I was wondering what is the status of getting the following merged: