Skip to content

Commit

Permalink
Terminfo.tigetstr and tiparm should return String object
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed May 19, 2021
1 parent 74a7ffa commit 1e287d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions lib/reline/ansi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ def self.set_default_key_bindings(config)

def self.set_default_key_bindings_terminfo(config)
{
Reline::Terminfo.tigetstr('khome').to_s.bytes => :ed_move_to_beg,
Reline::Terminfo.tigetstr('kend').to_s.bytes => :ed_move_to_end,
Reline::Terminfo.tigetstr('kcuu1').to_s.bytes => :ed_prev_history,
Reline::Terminfo.tigetstr('kcud1').to_s.bytes => :ed_next_history,
Reline::Terminfo.tigetstr('kcuf1').to_s.bytes => :ed_next_char,
Reline::Terminfo.tigetstr('kcub1').to_s.bytes => :ed_prev_char,
Reline::Terminfo.tigetstr('khome').bytes => :ed_move_to_beg,
Reline::Terminfo.tigetstr('kend').bytes => :ed_move_to_end,
Reline::Terminfo.tigetstr('kcuu1').bytes => :ed_prev_history,
Reline::Terminfo.tigetstr('kcud1').bytes => :ed_next_history,
Reline::Terminfo.tigetstr('kcuf1').bytes => :ed_next_char,
Reline::Terminfo.tigetstr('kcub1').bytes => :ed_prev_char,
# Escape sequences that omit the move distance and are set to defaults
# value 1 may be sometimes sent by pressing the arrow-key.
Reline::Terminfo.tigetstr('cuu').to_s.sub(/%p1%d/, '').bytes => :ed_prev_history,
Reline::Terminfo.tigetstr('cud').to_s.sub(/%p1%d/, '').bytes => :ed_next_history,
Reline::Terminfo.tigetstr('cuf').to_s.sub(/%p1%d/, '').bytes => :ed_next_char,
Reline::Terminfo.tigetstr('cub').to_s.sub(/%p1%d/, '').bytes => :ed_prev_char,
Reline::Terminfo.tigetstr('cuu').sub(/%p1%d/, '').bytes => :ed_prev_history,
Reline::Terminfo.tigetstr('cud').sub(/%p1%d/, '').bytes => :ed_next_history,
Reline::Terminfo.tigetstr('cuf').sub(/%p1%d/, '').bytes => :ed_next_char,
Reline::Terminfo.tigetstr('cub').sub(/%p1%d/, '').bytes => :ed_prev_char,
}.each_pair do |key, func|
config.add_default_key_binding_by_keymap(:emacs, key, func)
config.add_default_key_binding_by_keymap(:vi_insert, key, func)
Expand Down
4 changes: 2 additions & 2 deletions lib/reline/terminfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def self.setupterm(term, fildes)
end

def self.tigetstr(capname)
@tigetstr.(capname)
@tigetstr.(capname).to_s
end

def self.tiparm(str, *args)
new_args = []
args.each do |a|
new_args << Fiddle::TYPE_INT << a
end
@tiparm.(str, *new_args)
@tiparm.(str, *new_args).to_s
end

def self.enabled?
Expand Down

0 comments on commit 1e287d1

Please sign in to comment.