Skip to content

Instantly share code, notes, and snippets.

@daphee
Created August 26, 2015 16:15
Show Gist options
  • Save daphee/e5188a4fae02112d68be to your computer and use it in GitHub Desktop.
Save daphee/e5188a4fae02112d68be to your computer and use it in GitHub Desktop.
def bind_key(c : Char, f : Int32,Int32 -> Int32)
raise ArgumentError.new "not a valid ASCII character: '#{c}'" if !(0 <= c.ord <= 255)
wrapper = BindingProc.new {|count, key| LibReadline::Int.cast(f.call(count.to_i32, key.to_i32))}
LibReadline.rl_bind_key(c.ord, wrapper)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment