rawline 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +3 -2
- data/examples/key_tester.rb +21 -21
- data/examples/rawline_irb.rb +1 -0
- data/lib/rawline.rb +3 -3
- data/lib/rawline/editor.rb +2 -2
- data/lib/rawline/terminal/vt220_terminal.rb +66 -66
- data/spec/editor_spec.rb +1 -3
- data/spec/history_buffer_spec.rb +1 -3
- data/spec/line_spec.rb +2 -4
- metadata +50 -59
- data/spec/rawline_spec.rb +0 -6
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aeccdf705563aa0ff2524e6f120e3370f835b534
|
4
|
+
data.tar.gz: 95c009d8693e3a0ee1f9122cb1f546649de2a0e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b7455991cfef33300578836263a2ca7f7db288f59ff43c4e68f4cd40148b7a35bbff50933be088596aef895e06f18d94dbb933eb079e325da04fffb955a9c59
|
7
|
+
data.tar.gz: 30802c1626e5b9842960238321577c9e6ffdf1ae9d60597837842388fbaec5586e466593310da3545b57d5dbae191462be4a3ef7291220417cc341c69c540c91
|
data/LICENSE
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
Copyright (c) 2008, Fabio Cevasco
|
1
|
+
Copyright (c) 2008-2013, Fabio Cevasco
|
2
2
|
All rights reserved.
|
3
3
|
|
4
|
-
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
5
|
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
6
6
|
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
7
|
+
|
7
8
|
Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
8
9
|
|
9
10
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/examples/key_tester.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'highline/system_extensions'
|
5
|
-
|
6
|
-
include HighLine::SystemExtensions
|
7
|
-
|
8
|
-
puts "Press a key to view the corresponding ASCII code(s) (or CTRL-X to exit)."
|
9
|
-
|
10
|
-
loop do
|
11
|
-
|
12
|
-
print "=> "
|
13
|
-
char = get_character
|
14
|
-
case char
|
15
|
-
when ?\C-x.ord then
|
16
|
-
puts "Exiting..."; exit;
|
17
|
-
else
|
18
|
-
puts "#{char.chr} [#{char}] (hex: #{char.to_s(16)})";
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'highline/system_extensions'
|
5
|
+
|
6
|
+
include HighLine::SystemExtensions
|
7
|
+
|
8
|
+
puts "Press a key to view the corresponding ASCII code(s) (or CTRL-X to exit)."
|
9
|
+
|
10
|
+
loop do
|
11
|
+
|
12
|
+
print "=> "
|
13
|
+
char = get_character.ord rescue nil
|
14
|
+
case char
|
15
|
+
when ?\C-x.ord then
|
16
|
+
puts "Exiting..."; exit;
|
17
|
+
else
|
18
|
+
puts "#{char.chr} [#{char}] (hex: #{char.to_s(16)})";
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/examples/rawline_irb.rb
CHANGED
data/lib/rawline.rb
CHANGED
@@ -18,7 +18,7 @@ require "rubygems"
|
|
18
18
|
module RawLine
|
19
19
|
|
20
20
|
def self.rawline_version
|
21
|
-
"0.3.
|
21
|
+
"0.3.2"
|
22
22
|
end
|
23
23
|
|
24
24
|
class BindingException < RuntimeError; end
|
@@ -102,8 +102,8 @@ module RawLine
|
|
102
102
|
alias rawline readline
|
103
103
|
end
|
104
104
|
|
105
|
-
self.class.module_eval
|
106
|
-
self.module_eval
|
105
|
+
self.class.module_eval { readline_method.call }
|
106
|
+
self.module_eval { readline_method.call }
|
107
107
|
|
108
108
|
end
|
109
109
|
end
|
data/lib/rawline/editor.rb
CHANGED
@@ -134,7 +134,7 @@ module RawLine
|
|
134
134
|
#
|
135
135
|
def read_character
|
136
136
|
@output.flush
|
137
|
-
c = get_character(@input)
|
137
|
+
c = get_character(@input).ord rescue nil
|
138
138
|
@char = parse_key_code(c) || c
|
139
139
|
end
|
140
140
|
|
@@ -147,7 +147,7 @@ module RawLine
|
|
147
147
|
sequence = [code]
|
148
148
|
seqs = []
|
149
149
|
loop do
|
150
|
-
c = get_character(@input)
|
150
|
+
c = get_character(@input).ord rescue nil
|
151
151
|
sequence << c
|
152
152
|
seqs = @terminal.escape_sequences.select { |e| e[0..sequence.length-1] == sequence }
|
153
153
|
break if seqs.empty?
|
@@ -1,66 +1,66 @@
|
|
1
|
-
#!usr/bin/env ruby
|
2
|
-
|
3
|
-
#
|
4
|
-
# vt220_terminal.rb
|
5
|
-
#
|
6
|
-
# Created by Fabio Cevasco on 2008-03-01.
|
7
|
-
# Copyright (c) 2008 Fabio Cevasco. All rights reserved.
|
8
|
-
#
|
9
|
-
# This is Free Software. See LICENSE for details.
|
10
|
-
#
|
11
|
-
|
12
|
-
module RawLine
|
13
|
-
|
14
|
-
#
|
15
|
-
# This class is used to define all the most common character codes and
|
16
|
-
# escape sequences used on *nix systems.
|
17
|
-
#
|
18
|
-
class VT220Terminal < Terminal
|
19
|
-
|
20
|
-
def initialize
|
21
|
-
super
|
22
|
-
@escape_codes = [?\e.ord]
|
23
|
-
@keys.merge!(
|
24
|
-
{
|
25
|
-
:up_arrow => [?\e.ord, ?[.ord, ?A.ord],
|
26
|
-
:down_arrow => [?\e.ord, ?[.ord, ?B.ord],
|
27
|
-
:right_arrow => [?\e.ord, ?[.ord, ?C.ord],
|
28
|
-
:left_arrow => [?\e.ord, ?[.ord, ?D.ord],
|
29
|
-
:insert => [?\e.ord, ?[, ?2.ord, ?~.ord],
|
30
|
-
:delete => [?\e.ord, ?[, ?3.ord, ?~.ord],
|
31
|
-
:backspace => [?\C-?.ord],
|
32
|
-
:enter => (HighLine::SystemExtensions::CHARACTER_MODE == 'termios' ? [?\n.ord] : [?\r]),
|
33
|
-
|
34
|
-
:ctrl_alt_a => [?\e.ord, ?\C-a.ord],
|
35
|
-
:ctrl_alt_b => [?\e.ord, ?\C-b.ord],
|
36
|
-
:ctrl_alt_c => [?\e.ord, ?\C-c.ord],
|
37
|
-
:ctrl_alt_d => [?\e.ord, ?\C-d.ord],
|
38
|
-
:ctrl_alt_e => [?\e.ord, ?\C-e.ord],
|
39
|
-
:ctrl_alt_f => [?\e.ord, ?\C-f.ord],
|
40
|
-
:ctrl_alt_g => [?\e.ord, ?\C-g.ord],
|
41
|
-
:ctrl_alt_h => [?\e.ord, ?\C-h.ord],
|
42
|
-
:ctrl_alt_i => [?\e.ord, ?\C-i.ord],
|
43
|
-
:ctrl_alt_j => [?\e.ord, ?\C-j.ord],
|
44
|
-
:ctrl_alt_k => [?\e.ord, ?\C-k.ord],
|
45
|
-
:ctrl_alt_l => [?\e.ord, ?\C-l.ord],
|
46
|
-
:ctrl_alt_m => [?\e.ord, ?\C-m.ord],
|
47
|
-
:ctrl_alt_n => [?\e.ord, ?\C-n.ord],
|
48
|
-
:ctrl_alt_o => [?\e.ord, ?\C-o.ord],
|
49
|
-
:ctrl_alt_p => [?\e.ord, ?\C-p.ord],
|
50
|
-
:ctrl_alt_q => [?\e.ord, ?\C-q.ord],
|
51
|
-
:ctrl_alt_r => [?\e.ord, ?\C-r.ord],
|
52
|
-
:ctrl_alt_s => [?\e.ord, ?\C-s.ord],
|
53
|
-
:ctrl_alt_t => [?\e.ord, ?\C-t.ord],
|
54
|
-
:ctrl_alt_u => [?\e.ord, ?\C-u.ord],
|
55
|
-
:ctrl_alt_v => [?\e.ord, ?\C-v.ord],
|
56
|
-
:ctrl_alt_w => [?\e.ord, ?\C-w.ord],
|
57
|
-
:ctrl_alt_x => [?\e.ord, ?\C-x.ord],
|
58
|
-
:ctrl_alt_y => [?\e.ord, ?\C-y.ord],
|
59
|
-
:ctrl_alt_z => [?\e.ord, ?\C-z.ord]
|
60
|
-
})
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
end
|
1
|
+
#!usr/bin/env ruby
|
2
|
+
|
3
|
+
#
|
4
|
+
# vt220_terminal.rb
|
5
|
+
#
|
6
|
+
# Created by Fabio Cevasco on 2008-03-01.
|
7
|
+
# Copyright (c) 2008 Fabio Cevasco. All rights reserved.
|
8
|
+
#
|
9
|
+
# This is Free Software. See LICENSE for details.
|
10
|
+
#
|
11
|
+
|
12
|
+
module RawLine
|
13
|
+
|
14
|
+
#
|
15
|
+
# This class is used to define all the most common character codes and
|
16
|
+
# escape sequences used on *nix systems.
|
17
|
+
#
|
18
|
+
class VT220Terminal < Terminal
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
super
|
22
|
+
@escape_codes = [?\e.ord]
|
23
|
+
@keys.merge!(
|
24
|
+
{
|
25
|
+
:up_arrow => [?\e.ord, ?[.ord, ?A.ord],
|
26
|
+
:down_arrow => [?\e.ord, ?[.ord, ?B.ord],
|
27
|
+
:right_arrow => [?\e.ord, ?[.ord, ?C.ord],
|
28
|
+
:left_arrow => [?\e.ord, ?[.ord, ?D.ord],
|
29
|
+
:insert => [?\e.ord, ?[, ?2.ord, ?~.ord],
|
30
|
+
:delete => [?\e.ord, ?[, ?3.ord, ?~.ord],
|
31
|
+
:backspace => [?\C-?.ord],
|
32
|
+
:enter => (HighLine::SystemExtensions::CHARACTER_MODE == 'termios' ? [?\n.ord] : [?\r.ord]),
|
33
|
+
|
34
|
+
:ctrl_alt_a => [?\e.ord, ?\C-a.ord],
|
35
|
+
:ctrl_alt_b => [?\e.ord, ?\C-b.ord],
|
36
|
+
:ctrl_alt_c => [?\e.ord, ?\C-c.ord],
|
37
|
+
:ctrl_alt_d => [?\e.ord, ?\C-d.ord],
|
38
|
+
:ctrl_alt_e => [?\e.ord, ?\C-e.ord],
|
39
|
+
:ctrl_alt_f => [?\e.ord, ?\C-f.ord],
|
40
|
+
:ctrl_alt_g => [?\e.ord, ?\C-g.ord],
|
41
|
+
:ctrl_alt_h => [?\e.ord, ?\C-h.ord],
|
42
|
+
:ctrl_alt_i => [?\e.ord, ?\C-i.ord],
|
43
|
+
:ctrl_alt_j => [?\e.ord, ?\C-j.ord],
|
44
|
+
:ctrl_alt_k => [?\e.ord, ?\C-k.ord],
|
45
|
+
:ctrl_alt_l => [?\e.ord, ?\C-l.ord],
|
46
|
+
:ctrl_alt_m => [?\e.ord, ?\C-m.ord],
|
47
|
+
:ctrl_alt_n => [?\e.ord, ?\C-n.ord],
|
48
|
+
:ctrl_alt_o => [?\e.ord, ?\C-o.ord],
|
49
|
+
:ctrl_alt_p => [?\e.ord, ?\C-p.ord],
|
50
|
+
:ctrl_alt_q => [?\e.ord, ?\C-q.ord],
|
51
|
+
:ctrl_alt_r => [?\e.ord, ?\C-r.ord],
|
52
|
+
:ctrl_alt_s => [?\e.ord, ?\C-s.ord],
|
53
|
+
:ctrl_alt_t => [?\e.ord, ?\C-t.ord],
|
54
|
+
:ctrl_alt_u => [?\e.ord, ?\C-u.ord],
|
55
|
+
:ctrl_alt_v => [?\e.ord, ?\C-v.ord],
|
56
|
+
:ctrl_alt_w => [?\e.ord, ?\C-w.ord],
|
57
|
+
:ctrl_alt_x => [?\e.ord, ?\C-x.ord],
|
58
|
+
:ctrl_alt_y => [?\e.ord, ?\C-y.ord],
|
59
|
+
:ctrl_alt_z => [?\e.ord, ?\C-z.ord]
|
60
|
+
})
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
data/spec/editor_spec.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
dir = File.dirname(File.expand_path(__FILE__))+'/..'
|
4
|
-
|
5
3
|
require 'highline/system_extensions'
|
6
4
|
|
7
5
|
module HighLine::SystemExtensions
|
@@ -12,7 +10,7 @@ module HighLine::SystemExtensions
|
|
12
10
|
end
|
13
11
|
|
14
12
|
require 'stringio'
|
15
|
-
|
13
|
+
require_relative "../lib/rawline.rb"
|
16
14
|
|
17
15
|
describe RawLine::Editor do
|
18
16
|
|
data/spec/history_buffer_spec.rb
CHANGED
data/spec/line_spec.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
dir = File.dirname(File.expand_path(__FILE__))+'/..'
|
4
|
-
|
5
3
|
require 'rubygems'
|
6
4
|
require 'highline'
|
7
5
|
|
8
|
-
|
9
|
-
|
6
|
+
require_relative "../lib/rawline/history_buffer.rb"
|
7
|
+
require_relative "../lib/rawline/line.rb"
|
10
8
|
|
11
9
|
describe RawLine::Line do
|
12
10
|
|
metadata
CHANGED
@@ -1,87 +1,78 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rawline
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Fabio Cevasco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
16
14
|
name: highline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.0
|
17
20
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
23
26
|
version: 1.4.0
|
24
|
-
|
25
|
-
|
27
|
+
description: 'RawLine can be used to define custom key bindings, perform common line
|
28
|
+
editing operations, manage command history and define custom command completion
|
29
|
+
rules. '
|
26
30
|
email: h3rald@h3rald.com
|
27
31
|
executables: []
|
28
|
-
|
29
32
|
extensions: []
|
30
|
-
|
31
|
-
|
32
|
-
- README.rdoc
|
33
|
-
- LICENSE
|
34
|
-
- CHANGELOG.rdoc
|
35
|
-
files:
|
36
|
-
- lib/rawline.rb
|
37
|
-
- lib/rawline
|
38
|
-
- lib/rawline/history_buffer.rb
|
39
|
-
- lib/rawline/terminal.rb
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
40
35
|
- lib/rawline/editor.rb
|
36
|
+
- lib/rawline/history_buffer.rb
|
41
37
|
- lib/rawline/line.rb
|
42
|
-
- lib/rawline/terminal
|
43
|
-
- lib/rawline/terminal/windows_terminal.rb
|
44
38
|
- lib/rawline/terminal/vt220_terminal.rb
|
45
|
-
-
|
46
|
-
-
|
39
|
+
- lib/rawline/terminal/windows_terminal.rb
|
40
|
+
- lib/rawline/terminal.rb
|
41
|
+
- lib/rawline.rb
|
47
42
|
- examples/key_tester.rb
|
48
|
-
- examples/rawline_shell.rb
|
49
43
|
- examples/rawline_irb.rb
|
44
|
+
- examples/rawline_rush.rb
|
45
|
+
- examples/rawline_shell.rb
|
46
|
+
- examples/readline_emulation.rb
|
47
|
+
- spec/editor_spec.rb
|
50
48
|
- spec/history_buffer_spec.rb
|
51
49
|
- spec/line_spec.rb
|
52
|
-
- spec/rawline_spec.rb
|
53
|
-
- spec/editor_spec.rb
|
54
50
|
- README.rdoc
|
55
51
|
- LICENSE
|
56
52
|
- CHANGELOG.rdoc
|
57
|
-
has_rdoc: true
|
58
53
|
homepage: http://rubyforge.org/projects/rawline
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
59
57
|
post_install_message:
|
60
|
-
rdoc_options:
|
61
|
-
|
62
|
-
- README.rdoc
|
63
|
-
- --exclude
|
64
|
-
- spec
|
65
|
-
require_paths:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
66
60
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version:
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
version: "0"
|
78
|
-
version:
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
79
71
|
requirements: []
|
80
|
-
|
81
|
-
|
82
|
-
rubygems_version: 1.2.0
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.0.0
|
83
74
|
signing_key:
|
84
|
-
specification_version:
|
75
|
+
specification_version: 4
|
85
76
|
summary: A library for defining custom key bindings and perform line editing operations
|
86
|
-
test_files:
|
87
|
-
|
77
|
+
test_files: []
|
78
|
+
has_rdoc:
|