lib/rbreadline.rb in rdp-rb-readline-0.2.0 vs lib/rbreadline.rb in rdp-rb-readline-0.2.0.1
- old
+ new
@@ -13,11 +13,11 @@
module RbReadline
require 'etc'
RL_LIBRARY_VERSION = "5.2"
RL_READLINE_VERSION = 0x0502
- RB_READLINE_VERSION = "0.2.0"
+ RB_READLINE_VERSION = "0.2.0.1"
EOF = "\xFF"
ESC = "\C-["
PAGE = "\C-L"
SPACE = "\x20"
@@ -2476,11 +2476,11 @@
@rl_instream ||= $stdin
@rl_outstream ||= $stdout
# Bind _rl_in_stream and _rl_out_stream immediately. These values
- # may change, but they may also be used before readline_internal ()
+ # may change, but hey may also be used before readline_internal ()
# is called.
@_rl_in_stream = @rl_instream
@_rl_out_stream = @rl_outstream
# Allocate data structures.
@@ -4274,23 +4274,24 @@
begin
# Cygwin will look like Windows, but we want to treat it like a Posix OS:
raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i
raise LoadError, "Not Windows" if RUBY_PLATFORM !~ /mswin|mingw/
+ raise LoadError, "Using file I/O for windows" if $rb_readline_use_file_io_on_windows
if RUBY_VERSION < '1.9.1'
require 'Win32API'
else
require 'dl'
class Win32API
DLL = {}
TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG}
- def initialize(dllname, func, import, export = "0")
+ def initialize(dllname, func, import, export = "0", calltype = :stdcall)
@proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1')
handle = DLL[dllname] ||= DL.dlopen(dllname)
- @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func)
+ @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func, calltype)
end
def call(*args)
import = @proto.split("")
args.each_with_index do |x, i|
@@ -4346,11 +4347,11 @@
end
rescue
@encoding = "N"
end
- def rl_getc(stream)
+ def rl_getc(stream) # windows only here
c = @getch.Call
alt = (@GetKeyState.call(VK_LMENU) & 0x80) != 0
if c==0 || c==0xE0
r = c.chr + @getch.Call.chr
else
@@ -4378,11 +4379,11 @@
@encoding = "S"
else
@encoding = "N"
end
- def rl_getc(stream)
+ def rl_getc(stream) # linux
begin
c = stream.read(1)
rescue Errno::EINTR
c = rl_getc(stream)
end
@@ -4397,11 +4398,11 @@
rl_stuff_char(k)
return 1
end
end
- if defined? ''.getbyte
+ if RUBY_VERSION >= '1.9'
@encoding = "X" # ruby 1.9.x or greater
@encoding_name = Encoding.default_external.to_s
end
@rl_byte_oriented = @encoding == "N"
@@ -4428,11 +4429,11 @@
end
end
else
- if (c=rl_get_char()).nil?
+ if (c=rl_get_char()).nil? # do we have one cached?
c = send(@rl_getc_function,@rl_instream)
end
end
end
@@ -6115,10 +6116,10 @@
scan = @rl_line_buffer[@rl_point,1]
if !brkchars.include?(scan)
next
end
# Call the application-specific function to tell us whether
- # this word break character is quoted and should be skipped.
+ # this word break character is quoted and should be skipped.
if (@rl_char_is_quoted_p && found_quote!=0 &&
send(@rl_char_is_quoted_p,@rl_line_buffer, @rl_point))
next
end