Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A tty-reader fork with the objective of adding a customized word completion mechanism.
TTY2::Reader intends to be an up to date clone of TTY::Reader, solely extending it with a customized word completion mechanism. This page only covers the applied modifications.
Add this line to your application's Gemfile:
gem "tty2-reader"
And then execute:
$ bundle
Or install it yourself as:
$ gem install tty2-reader
You can register to listen on a key pressed events. This can be done by calling on
with a event name(s):
reader.on(:keypress) { |event| .... }
or listen for multiple events:
reader.on(:keyctrl_x, :keyescape) { |event| ... }
The KeyEvent
object is yielded to a block whenever a particular key event fires. The event responds to:
key
- key pressedvalue
- value of the key pressedline
- the Line
object of the currently edited line, a new Line
object with empty content otherwiseThe value
returns the actual key pressed and the line
the content for the currently edited line or is empty.
The key
is an object that responds to following messages:
name
- the name of the event such as :up, :down, letter or digitmeta
- true if event is non-standard key associatedshift
- true if shift has been pressed with the keyctrl
- true if ctrl has been pressed with the key
For example, to add listen to vim like navigation keys, one would do the following:reader.on(:keypress) do |event|
if event.value == "j"
...
end
if event.value == "k"
...
end
end
You can subscribe to more than one event:
reader.on(:keypress) { |event| ... }
.on(:keydown) { |event| ... }
:completion_handler
This option allows you to define possible completions. It accepts a proc
with the word that is to be completed as a first, and a context in which the word is to be completed as a second argument. By default set to nil. To use this:
reader = TTY2::Reader.new(completion_handler: ->(word, context) { ... })
:completion_suffix
This option allows you to add a suffix to completed words. By default, no suffix is added. To add a suffix:
reader = TTY2::Reader.new(completion_suffix: " ")
:completion_cycling
This option controls cycling through completion suggestions. By default set to true
, and can be disabled with:
reader = TTY2::Reader.new(completion_cycling: false)
Bug reports and pull requests are welcome on GitHub at https://github.com/zzyzwicz/tty2-reader.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the TTY2::Reader project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Copyright for portions of project TTY2::Reader are held by Piotr Murach, 2017 as part of project TTY::Reader. All other copyright for project TTY2::Reader are held by zzyzwicz, 2021.
FAQs
Unknown package
We found that tty2-reader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.