rb-readline 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{README.rdoc → README.md} +24 -14
- data/Rakefile +1 -0
- data/lib/rbreadline.rb +56 -11
- data/lib/rbreadline/version.rb +1 -1
- data/lib/readline.rb +4 -4
- data/rb-readline.gemspec +3 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62e9f284762457dd7a3623ef60c95024ae96d513
|
4
|
+
data.tar.gz: 190b43ef9f6d15da4921f48c923776c305c3bfef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 587ae50714415826ec7b09435b6e98ef6b8b82888144e6d8a5b2e99d68fc3dbbff527af117323829aeceb0a8b06fd3cbf525288734557c205f15b23efacdcad7
|
7
|
+
data.tar.gz: 3ea8429737a5b37c40900ae813632a8bb7646a7b0c164ac3c301dfbd30111aac357360d91c99a7bc4f520cbaa97f74fdcecf9fffd9afbfed524bc4ed950511dc
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,28 +1,38 @@
|
|
1
|
-
|
1
|
+
# Description
|
2
2
|
|
3
3
|
The readline library provides a pure Ruby implementation of the GNU
|
4
4
|
readline C library, as well as the Readline extension that ships as part
|
5
5
|
of the standard library.
|
6
6
|
|
7
|
-
|
7
|
+
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
gem install rb-readline
|
10
|
+
|
11
|
+
Or in a `Gemfile`:
|
12
|
+
|
13
|
+
gem 'rb-readline'
|
10
14
|
|
11
|
-
|
12
|
-
line = Readline::readline('> ')
|
13
|
-
break if line.nil? || line == 'quit'
|
14
|
-
Readline::HISTORY.push(line)
|
15
|
-
puts "You typed: #{line}"
|
16
|
-
end
|
15
|
+
## Synopsis
|
17
16
|
|
18
|
-
|
17
|
+
```ruby
|
18
|
+
require 'readline'
|
19
|
+
|
20
|
+
loop do
|
21
|
+
line = Readline::readline('> ')
|
22
|
+
break if line.nil? || line == 'quit'
|
23
|
+
Readline::HISTORY.push(line)
|
24
|
+
puts "You typed: #{line}"
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
## Compatibility
|
19
29
|
|
20
30
|
rb-readline should work on all Unix-like systems and Windows. It is regularly
|
21
31
|
used with MRI 1.8/1.9 and Rubinius. JRuby is not supported and there are no
|
22
32
|
plans to support it in the future - it comes bundled with a Java implementation
|
23
33
|
of Readline.
|
24
34
|
|
25
|
-
|
35
|
+
## Motivation
|
26
36
|
|
27
37
|
First, building the GNU readline library on MS Windows with Visual C++ is
|
28
38
|
almost impossible. However, certain libraries depend on readline. By providing
|
@@ -47,7 +57,7 @@ weak, and only provides a very limited subset of the actual GNU readline
|
|
47
57
|
library. By providing a pure Ruby implementation we allow 3rd party library
|
48
58
|
authors to write their own interface as they see fit.
|
49
59
|
|
50
|
-
|
60
|
+
## Tutorial
|
51
61
|
|
52
62
|
For an excellent tutorial on how to use Readline in practice, please see
|
53
63
|
Joseph Pecoraro's examples at http://bogojoker.com/readline/.
|
@@ -55,14 +65,14 @@ Joseph Pecoraro's examples at http://bogojoker.com/readline/.
|
|
55
65
|
You can also take a look at Ruby 1.9 stdlib Readline documentation located
|
56
66
|
at http://rubydoc.info/stdlib/readline/1.9.2/frames
|
57
67
|
|
58
|
-
|
68
|
+
## Alternatives
|
59
69
|
|
60
70
|
See Rawline for a library that began life in pure Ruby and provides an
|
61
71
|
interface that's probably more comfortable to Ruby programmer. It has certain
|
62
72
|
features that Readline does not. In addition, it provides a Readline
|
63
73
|
compatibility mode.
|
64
74
|
|
65
|
-
|
75
|
+
## Authors
|
66
76
|
|
67
77
|
* Park Heesob (C translation, code donated as part of bounty)
|
68
78
|
* Daniel Berger (Documentation and testing)
|
data/Rakefile
CHANGED
data/lib/rbreadline.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
require "rbreadline/version"
|
12
12
|
|
13
|
-
class
|
13
|
+
class Integer
|
14
14
|
def ord; self; end
|
15
15
|
end
|
16
16
|
|
@@ -2392,9 +2392,54 @@ module RbReadline
|
|
2392
2392
|
nil
|
2393
2393
|
end
|
2394
2394
|
|
2395
|
+
def rl_translate_keyseq(seq)
|
2396
|
+
require 'strscan'
|
2397
|
+
|
2398
|
+
ss = StringScanner.new(seq)
|
2399
|
+
new_seq = ''
|
2400
|
+
|
2401
|
+
until ss.eos?
|
2402
|
+
char = ss.getch
|
2403
|
+
next new_seq << char unless char == '\\'
|
2404
|
+
|
2405
|
+
char = ss.getch
|
2406
|
+
new_seq << case char
|
2407
|
+
when 'a'
|
2408
|
+
"\007"
|
2409
|
+
when 'b'
|
2410
|
+
"\b"
|
2411
|
+
when 'd'
|
2412
|
+
RUBOUT
|
2413
|
+
when 'e'
|
2414
|
+
ESC
|
2415
|
+
when 'f'
|
2416
|
+
"\f"
|
2417
|
+
when 'n'
|
2418
|
+
NEWLINE
|
2419
|
+
when 'r'
|
2420
|
+
RETURN
|
2421
|
+
when 't'
|
2422
|
+
TAB
|
2423
|
+
when 'v'
|
2424
|
+
0x0B
|
2425
|
+
when '\\'
|
2426
|
+
'\\'
|
2427
|
+
when 'x'
|
2428
|
+
ss.scan(/\d\d/).to_i(16).chr
|
2429
|
+
when '0'..'7'
|
2430
|
+
ss.pos -= 1
|
2431
|
+
ss.scan(/\d\d\d/).to_i(8).chr
|
2432
|
+
else
|
2433
|
+
char
|
2434
|
+
end
|
2435
|
+
end
|
2436
|
+
|
2437
|
+
new_seq
|
2438
|
+
end
|
2439
|
+
|
2395
2440
|
# Bind KEY to FUNCTION. Returns non-zero if KEY is out of range.
|
2396
2441
|
def rl_bind_key(key, function)
|
2397
|
-
@_rl_keymap[key] = function
|
2442
|
+
@_rl_keymap[rl_translate_keyseq(key)] = function
|
2398
2443
|
@rl_binding_keymap = @_rl_keymap
|
2399
2444
|
0
|
2400
2445
|
end
|
@@ -2648,7 +2693,7 @@ module RbReadline
|
|
2648
2693
|
end
|
2649
2694
|
|
2650
2695
|
def vis_pos(line)
|
2651
|
-
@vis_lbreaks[line]
|
2696
|
+
@vis_lbreaks[line] || 0
|
2652
2697
|
end
|
2653
2698
|
|
2654
2699
|
def vis_line(line)
|
@@ -4022,7 +4067,7 @@ module RbReadline
|
|
4022
4067
|
def _rl_isearch_dispatch(cxt, c)
|
4023
4068
|
f = nil
|
4024
4069
|
|
4025
|
-
if c.
|
4070
|
+
if c.is_a?(Integer) && c < 0
|
4026
4071
|
cxt.sflags |= SF_FAILED
|
4027
4072
|
cxt.history_pos = cxt.last_found_line
|
4028
4073
|
return -1
|
@@ -5615,7 +5660,7 @@ module RbReadline
|
|
5615
5660
|
c = rl_read_key()
|
5616
5661
|
rl_unsetstate(RL_STATE_MOREINPUT)
|
5617
5662
|
|
5618
|
-
if c.
|
5663
|
+
if c.is_a?(Integer) && c < 0
|
5619
5664
|
return -1
|
5620
5665
|
end
|
5621
5666
|
|
@@ -6494,7 +6539,7 @@ module RbReadline
|
|
6494
6539
|
end
|
6495
6540
|
|
6496
6541
|
def _rl_internal_pager(lines)
|
6497
|
-
@rl_outstream.
|
6542
|
+
@rl_outstream.write("--More--")
|
6498
6543
|
@rl_outstream.flush
|
6499
6544
|
i = get_y_or_n(1)
|
6500
6545
|
_rl_erase_entire_line()
|
@@ -6610,7 +6655,7 @@ module RbReadline
|
|
6610
6655
|
if (c == 'n' || c == 'N' || c == RUBOUT)
|
6611
6656
|
return (0)
|
6612
6657
|
end
|
6613
|
-
if (c == ABORT_CHAR || (c.
|
6658
|
+
if (c == ABORT_CHAR || (c.is_a?(Integer) && c < 0))
|
6614
6659
|
_rl_abort_internal()
|
6615
6660
|
end
|
6616
6661
|
if (for_pager && (c == NEWLINE || c == RETURN))
|
@@ -7592,7 +7637,7 @@ module RbReadline
|
|
7592
7637
|
mbchar = ''
|
7593
7638
|
mb_len = _rl_read_mbchar(mbchar, MB_LEN_MAX)
|
7594
7639
|
|
7595
|
-
if (mbchar.
|
7640
|
+
if (mbchar.is_a?(Integer) && c < 0) || mbchar == 0.chr
|
7596
7641
|
return -1
|
7597
7642
|
end
|
7598
7643
|
|
@@ -7777,7 +7822,7 @@ module RbReadline
|
|
7777
7822
|
rl_restore_prompt()
|
7778
7823
|
rl_clear_message()
|
7779
7824
|
rl_unsetstate(RL_STATE_NUMERICARG)
|
7780
|
-
if key.
|
7825
|
+
if key.is_a?(Integer) && key < 0
|
7781
7826
|
return -1
|
7782
7827
|
end
|
7783
7828
|
return (_rl_dispatch(key, @_rl_keymap))
|
@@ -8735,7 +8780,7 @@ module RbReadline
|
|
8735
8780
|
c = rl_read_key()
|
8736
8781
|
rl_unsetstate(RL_STATE_MOREINPUT)
|
8737
8782
|
|
8738
|
-
break if c.
|
8783
|
+
break if c.is_a?(Integer) && c < 0
|
8739
8784
|
|
8740
8785
|
mbchar << c
|
8741
8786
|
mb_len += 1
|
@@ -8765,7 +8810,7 @@ module RbReadline
|
|
8765
8810
|
# Read more for multibyte character
|
8766
8811
|
rl_setstate(RL_STATE_MOREINPUT)
|
8767
8812
|
c = rl_read_key()
|
8768
|
-
break if c.
|
8813
|
+
break if c.is_a?(Integer) && c < 0
|
8769
8814
|
rl_unsetstate(RL_STATE_MOREINPUT)
|
8770
8815
|
else
|
8771
8816
|
break
|
data/lib/rbreadline/version.rb
CHANGED
data/lib/readline.rb
CHANGED
@@ -455,7 +455,7 @@ module Readline
|
|
455
455
|
|
456
456
|
end
|
457
457
|
|
458
|
-
HISTORY = History
|
458
|
+
HISTORY = History unless const_defined? :HISTORY
|
459
459
|
|
460
460
|
# The Fcomp class provided to encapsulate typical filename completion
|
461
461
|
# procedure. You will not typically use this directly, but will instead
|
@@ -483,7 +483,7 @@ module Readline
|
|
483
483
|
end
|
484
484
|
end
|
485
485
|
|
486
|
-
FILENAME_COMPLETION_PROC = Fcomp
|
486
|
+
FILENAME_COMPLETION_PROC = Fcomp unless const_defined? :FILENAME_COMPLETION_PROC
|
487
487
|
|
488
488
|
# The Ucomp class provided to encapsulate typical filename completion
|
489
489
|
# procedure. You will not typically use this directly, but will instead
|
@@ -514,13 +514,13 @@ module Readline
|
|
514
514
|
end
|
515
515
|
end
|
516
516
|
|
517
|
-
USERNAME_COMPLETION_PROC = Ucomp
|
517
|
+
USERNAME_COMPLETION_PROC = Ucomp unless const_defined? :USERNAME_COMPLETION_PROC
|
518
518
|
|
519
519
|
RbReadline.rl_readline_name = "Ruby"
|
520
520
|
|
521
521
|
RbReadline.using_history()
|
522
522
|
|
523
|
-
VERSION = RbReadline.rl_library_version
|
523
|
+
VERSION = RbReadline.rl_library_version unless const_defined? :VERSION
|
524
524
|
|
525
525
|
module_function :readline
|
526
526
|
|
data/rb-readline.gemspec
CHANGED
@@ -34,7 +34,7 @@ spec = Gem::Specification.new do |s|
|
|
34
34
|
# components, files and paths
|
35
35
|
s.files = Dir[
|
36
36
|
"{bench,examples,lib,test}/**/*.rb",
|
37
|
-
"README.
|
37
|
+
"README.md",
|
38
38
|
"LICENSE",
|
39
39
|
"CHANGES",
|
40
40
|
"Rakefile",
|
@@ -45,7 +45,7 @@ spec = Gem::Specification.new do |s|
|
|
45
45
|
s.require_path = 'lib'
|
46
46
|
|
47
47
|
# documentation
|
48
|
-
s.rdoc_options << '--main' << 'README.
|
48
|
+
s.rdoc_options << '--main' << 'README.md' << '--title' << 'Rb-Readline - Documentation'
|
49
49
|
|
50
|
-
s.extra_rdoc_files = %w(README.
|
50
|
+
s.extra_rdoc_files = %w(README.md LICENSE CHANGES)
|
51
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-readline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Park Heesob
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|
@@ -52,13 +52,13 @@ email:
|
|
52
52
|
executables: []
|
53
53
|
extensions: []
|
54
54
|
extra_rdoc_files:
|
55
|
-
- README.
|
55
|
+
- README.md
|
56
56
|
- LICENSE
|
57
57
|
- CHANGES
|
58
58
|
files:
|
59
59
|
- CHANGES
|
60
60
|
- LICENSE
|
61
|
-
- README.
|
61
|
+
- README.md
|
62
62
|
- Rakefile
|
63
63
|
- bench/_rl_adjust_point.rb
|
64
64
|
- examples/example_readline.rb
|
@@ -83,7 +83,7 @@ metadata: {}
|
|
83
83
|
post_install_message:
|
84
84
|
rdoc_options:
|
85
85
|
- "--main"
|
86
|
-
- README.
|
86
|
+
- README.md
|
87
87
|
- "--title"
|
88
88
|
- Rb-Readline - Documentation
|
89
89
|
require_paths:
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: 1.3.5
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.5.1
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Pure-Ruby Readline Implementation
|