lib/ttytest/tmux/session.rb in ttytest2-0.8.6 vs lib/ttytest/tmux/session.rb in ttytest2-0.9.0

- old
+ new

@@ -36,21 +36,42 @@ height: height.to_i, cursor_visible: (cursor_flag != '0') ) end + # Send the array of keys as a string literal to tmux. + # Will not be interpreted as send-keys values like Enter, Escape, DC for Delete, etc. + # @param [%w()] keys the keys to send to tmux def send_keys(*keys) driver.tmux(*%W[send-keys -t #{name} -l], *keys) end + # Send a string of keys one character at a time as literals to tmux. + # @param [String] keys the keys to send one at a time to tmux def send_keys_one_at_a_time(keys) keys.split('').each do |key| driver.tmux(*%W[send-keys -t #{name} -l], key) end end def send_newline driver.tmux(*%W[send-keys -t #{name} -l], %(\n)) + end + + def send_delete + send_keys_exact(%(DC)) + end + + def send_backspace + send_keys_exact(%(BSpace)) + end + + # Useful to send send-keys commands to tmux without sending them as a string literal. + # So you can send Escape for escape key, DC for delete, etc. + # Uses the same key bindings as bind-key as well. C-c represents Ctrl + C keys, F1 is F1 key, etc. + # @param [String] keys the keys to send to tmux + def send_keys_exact(keys) + driver.tmux(*%W[send-keys -t #{name}], keys) end private attr_reader :driver, :name