rb-readline 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +5 -0
- data/lib/rbreadline.rb +7 -2
- metadata +13 -15
- data/examples/multi-line.rb +0 -61
- data/examples/prompt.rb +0 -18
- data/examples/shell2.rb +0 -58
- data/examples/term.rb +0 -3
data/CHANGES
CHANGED
data/lib/rbreadline.rb
CHANGED
@@ -15,7 +15,7 @@ module RbReadline
|
|
15
15
|
|
16
16
|
RL_LIBRARY_VERSION = "5.2"
|
17
17
|
RL_READLINE_VERSION = 0x0502
|
18
|
-
RB_READLINE_VERSION = "0.4.
|
18
|
+
RB_READLINE_VERSION = "0.4.2"
|
19
19
|
|
20
20
|
EOF = "\xFF"
|
21
21
|
ESC = "\C-["
|
@@ -3805,7 +3805,12 @@ module RbReadline
|
|
3805
3805
|
|
3806
3806
|
# Write COUNT characters from STRING to the output stream.
|
3807
3807
|
def _rl_output_some_chars(string,start,count)
|
3808
|
-
@
|
3808
|
+
case @encoding
|
3809
|
+
when 'X'
|
3810
|
+
@_rl_out_stream.write(string[start, count].force_encoding(@encoding_name))
|
3811
|
+
else
|
3812
|
+
@_rl_out_stream.write(string[start,count])
|
3813
|
+
end
|
3809
3814
|
end
|
3810
3815
|
|
3811
3816
|
# Tell the update routines that we have moved onto a new line with the
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-readline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 11
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Park Heesob
|
@@ -17,8 +18,7 @@ autorequire:
|
|
17
18
|
bindir: bin
|
18
19
|
cert_chain: []
|
19
20
|
|
20
|
-
date: 2011-
|
21
|
-
default_executable:
|
21
|
+
date: 2011-11-02 00:00:00 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: rake
|
@@ -28,6 +28,7 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 3
|
31
32
|
segments:
|
32
33
|
- 0
|
33
34
|
version: "0"
|
@@ -48,27 +49,22 @@ extra_rdoc_files:
|
|
48
49
|
- LICENSE
|
49
50
|
- CHANGES
|
50
51
|
files:
|
51
|
-
- examples/
|
52
|
-
- examples/multi-line.rb
|
53
|
-
- examples/prompt.rb
|
52
|
+
- examples/example_readline.rb
|
54
53
|
- examples/example_readline_with_completion.rb
|
55
54
|
- examples/tinyirb.rb
|
56
|
-
- examples/example_readline.rb
|
57
|
-
- examples/term.rb
|
58
55
|
- lib/rb-readline.rb
|
59
56
|
- lib/rbreadline.rb
|
60
57
|
- lib/readline.rb
|
61
|
-
- test/test_completion.rb
|
62
|
-
- test/test_readline.rb
|
63
58
|
- test/filesystem_completion_helper.rb
|
64
|
-
- test/
|
59
|
+
- test/test_completion.rb
|
65
60
|
- test/test_filename_completion_proc.rb
|
61
|
+
- test/test_rbreadline.rb
|
62
|
+
- test/test_readline.rb
|
66
63
|
- README
|
67
64
|
- LICENSE
|
68
65
|
- CHANGES
|
69
66
|
- Rakefile
|
70
67
|
- setup.rb
|
71
|
-
has_rdoc: true
|
72
68
|
homepage: http://github.com/luislavena/rb-readline
|
73
69
|
licenses:
|
74
70
|
- BSD
|
@@ -85,6 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
81
|
requirements:
|
86
82
|
- - ">="
|
87
83
|
- !ruby/object:Gem::Version
|
84
|
+
hash: 59
|
88
85
|
segments:
|
89
86
|
- 1
|
90
87
|
- 8
|
@@ -95,6 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
92
|
requirements:
|
96
93
|
- - ">="
|
97
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 17
|
98
96
|
segments:
|
99
97
|
- 1
|
100
98
|
- 3
|
@@ -103,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
101
|
requirements: []
|
104
102
|
|
105
103
|
rubyforge_project:
|
106
|
-
rubygems_version: 1.
|
104
|
+
rubygems_version: 1.8.11
|
107
105
|
signing_key:
|
108
106
|
specification_version: 3
|
109
107
|
summary: Pure-Ruby Readline Implementation
|
data/examples/multi-line.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'rb-readline'
|
2
|
-
|
3
|
-
module RbReadline
|
4
|
-
def self.return_key(count, key)
|
5
|
-
if rl_line_buffer.split("\n").size > 2
|
6
|
-
@rl_done = true
|
7
|
-
puts
|
8
|
-
else
|
9
|
-
rl_insert(count, "\n")
|
10
|
-
rl_redisplay
|
11
|
-
rl_insert(1, "#{" " * (@rl_visible_prompt_length-2)}> ") unless @rl_done
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.multiline_prompt
|
16
|
-
' ' * (@rl_visible_prompt_length-2) + "> "
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.up_a_line(count, key)
|
20
|
-
lines = (multiline_prompt + rl_line_buffer[0...@rl_point]).split("\n")
|
21
|
-
return if lines.size == 1
|
22
|
-
|
23
|
-
current_line, previous_line = lines.pop, lines.pop
|
24
|
-
|
25
|
-
chars_back = current_line.length + 1
|
26
|
-
if previous_line.length >= @_rl_last_c_pos
|
27
|
-
chars_back += (previous_line.length - @_rl_last_c_pos)
|
28
|
-
end
|
29
|
-
|
30
|
-
@rl_point -= chars_back
|
31
|
-
rl_redisplay
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.down_a_line(count, key)
|
35
|
-
lines = (multiline_prompt + rl_line_buffer).split("\n")
|
36
|
-
return if @_rl_last_v_pos == (lines.size - 1)
|
37
|
-
|
38
|
-
current_line, next_line = lines[@_rl_last_v_pos], lines[@_rl_last_v_pos+1]
|
39
|
-
|
40
|
-
chars_forward = current_line.length - @_rl_last_c_pos + 1
|
41
|
-
if next_line.length < @_rl_last_c_pos
|
42
|
-
chars_forward += next_line.length
|
43
|
-
else
|
44
|
-
chars_forward += @_rl_last_c_pos
|
45
|
-
end
|
46
|
-
|
47
|
-
@rl_point += chars_forward
|
48
|
-
rl_redisplay
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
RbReadline.rl_bind_key "\r", :return_key
|
53
|
-
RbReadline.rl_bind_key "\n", :return_key
|
54
|
-
RbReadline.rl_bind_key "\e[A", :up_a_line
|
55
|
-
RbReadline.rl_bind_key "\e[B", :down_a_line
|
56
|
-
|
57
|
-
loop do
|
58
|
-
line = Readline.readline("Multi> ", true)
|
59
|
-
line = line.lines.to_a.map { |l| l.sub(/^ +> /, "") }.join
|
60
|
-
p line
|
61
|
-
end
|
data/examples/prompt.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rb-readline'
|
2
|
-
|
3
|
-
Cyan = "\001\e[0;36m\002"
|
4
|
-
Green = "\001\e[1;32m\002"
|
5
|
-
Reset = "\001\e[0m\002"
|
6
|
-
prompt = "\001\e[0;36m\002screwy\001\e[m\002 % "
|
7
|
-
prompt = "\001\e[0;36m\002this is long enough to cause a problem\001\e[m\002 % "
|
8
|
-
prompt = "[ ] > "
|
9
|
-
|
10
|
-
loop do
|
11
|
-
Readline.readline(prompt, true)
|
12
|
-
RbReadline.rl_set_prompt "[*] > "
|
13
|
-
# RbReadline.rl_maybe_replace_line
|
14
|
-
# RbReadline.rl_redisplay
|
15
|
-
RbReadline.rl_refresh_line nil, nil
|
16
|
-
sleep 2
|
17
|
-
puts
|
18
|
-
end
|
data/examples/shell2.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib/"
|
3
|
-
require 'readline'
|
4
|
-
|
5
|
-
RbReadline.rl_completer_quote_characters = "\\" if defined? RbReadline
|
6
|
-
RbReadline.rl_filename_quote_characters = " " if defined? RbReadline
|
7
|
-
|
8
|
-
module RbReadline
|
9
|
-
# IMPORTANT - this somehow gets changed...
|
10
|
-
@rl_completion_quote_character = "\\"
|
11
|
-
|
12
|
-
@rl_filename_dequoting_function = :dequote_filename
|
13
|
-
@rl_filename_quoting_function = :quote_filename
|
14
|
-
@rl_char_is_quoted_p = :char_is_quoted?
|
15
|
-
|
16
|
-
def self.char_is_quoted?(buffer, point)
|
17
|
-
buffer[point-1,1] == "\\" || buffer[point,1] == "\\"
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.dequote_filename(filename, quote_char)
|
21
|
-
quote_char = "\\" if quote_char == 0.chr
|
22
|
-
filename.delete quote_char
|
23
|
-
# @filename.gsub!(quote_char, "") if @filename
|
24
|
-
end
|
25
|
-
|
26
|
-
# def self.directory_completion_hook(filename)
|
27
|
-
# @dirname.gsub!("\\", "") if @dirname
|
28
|
-
# end
|
29
|
-
|
30
|
-
def self.quote_filename(filename, mtype, quote_char)
|
31
|
-
# if mtype == SINGLE_MATCH
|
32
|
-
# @rl_filename_quote_characters.each_char do |c|
|
33
|
-
# filename.sub!(//, "\\#{c}")
|
34
|
-
# end
|
35
|
-
# elsif mtype == MULT_MATCH
|
36
|
-
f = filename.dup
|
37
|
-
@rl_filename_quote_characters.each_char do |c|
|
38
|
-
f.gsub!(c, "\\#{c}")
|
39
|
-
end
|
40
|
-
f
|
41
|
-
# @rl_filename_quote_characters.each_char do |c|
|
42
|
-
# #p c
|
43
|
-
# index = filename.rindex(c)
|
44
|
-
# filename.insert(index, '\\') unless filename[index-1,1] == '\\'
|
45
|
-
# filename.gsub!(//, "\\#{c}")
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
# filename
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
loop do
|
54
|
-
line = Readline::readline('> ')
|
55
|
-
Readline::HISTORY.push(line)
|
56
|
-
puts "You typed: #{line}"
|
57
|
-
break if line == 'quit'
|
58
|
-
end
|
data/examples/term.rb
DELETED