class RatatuiRuby::Event::Paste
Encapsulates pasted text.
Users frequently paste text into terminals. Without specific handling, a paste appears as a flood of rapid keystrokes, often triggering accidental commands or confusing the input state.
This event makes pasting safe. It groups the entire inserted block into a single atomic action.
Handle this event to support bulk text insertion cleanly. Insert the content directly into your field or buffer without triggering per-character logic.
Examples
Using predicates:
if event.paste? puts "Pasted: #{event.content}" end
Using pattern matching:
case event in type: :paste, content: puts "Pasted: #{content}" end
Attributes
The pasted content.
puts event.content # => "https://example.com"
Public Class Methods
Source
# File lib/ratatui_ruby/event/paste.rb, line 75 def initialize(content:) @content = content.freeze end
Creates a new Paste event.
- content
-
Pasted text (String).
Public Instance Methods
Source
# File lib/ratatui_ruby/event/paste.rb, line 99 def ==(other) return false unless other.is_a?(Paste) content == other.content end
Compares this event with another for equality.
Source
# File lib/ratatui_ruby/event/paste.rb, line 93 def deconstruct_keys(keys) { type: :paste, content: @content } end
Deconstructs the event for pattern matching.
case event in type: :paste, content: puts "User pasted: #{content}" end