reline 0.2.8.pre.1 → 0.2.8.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reline/ansi.rb +1 -0
- data/lib/reline/config.rb +9 -0
- data/lib/reline/line_editor.rb +21 -3
- data/lib/reline/version.rb +1 -1
- data/lib/reline/windows.rb +12 -0
- data/lib/reline.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45220c00c821168746654f6c7f5ad3cc88ff8b4e3d3b6e5aefccc83b34392041
|
4
|
+
data.tar.gz: a3bbf71304ce777dbae4d5b1cc91f5a2b297b811194947e5e8e8a27b229667a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9d8e4a15c1eff337dc476b8b4f2d603b64d35faf255a9984f119b2f14a76bcd93f145d01d1e0698e2cb0a3d80c28c8b3baa343866e3cb7b8b28ab4642e77ebf
|
7
|
+
data.tar.gz: fcc70f912f7472acb0d7eeee8f221a60d06e3f08cd079b37a988392eca35723753e3b02638a4bcbb41876dc59cfcb46349b16bfff88e336ecea9bd2a4cf93231
|
data/lib/reline/ansi.rb
CHANGED
@@ -37,6 +37,7 @@ class Reline::ANSI
|
|
37
37
|
# default bindings
|
38
38
|
[27, 32] => :em_set_mark, # M-<space>
|
39
39
|
[24, 24] => :em_exchange_mark, # C-x C-x
|
40
|
+
[27, 91, 90] => :completion_journey_up, # S-Tab
|
40
41
|
}.each_pair do |key, func|
|
41
42
|
config.add_default_key_binding_by_keymap(:emacs, key, func)
|
42
43
|
end
|
data/lib/reline/config.rb
CHANGED
@@ -65,6 +65,7 @@ class Reline::Config
|
|
65
65
|
@history_size = -1 # unlimited
|
66
66
|
@keyseq_timeout = 500
|
67
67
|
@test_mode = false
|
68
|
+
@autocompletion = false
|
68
69
|
end
|
69
70
|
|
70
71
|
def reset
|
@@ -89,6 +90,14 @@ class Reline::Config
|
|
89
90
|
(val.respond_to?(:any?) ? val : [val]).any?(@editing_mode_label)
|
90
91
|
end
|
91
92
|
|
93
|
+
def autocompletion=(val)
|
94
|
+
@autocompletion = val
|
95
|
+
end
|
96
|
+
|
97
|
+
def autocompletion
|
98
|
+
@autocompletion
|
99
|
+
end
|
100
|
+
|
92
101
|
def keymap
|
93
102
|
@key_actors[@keymap_label]
|
94
103
|
end
|
data/lib/reline/line_editor.rb
CHANGED
@@ -479,8 +479,9 @@ class Reline::LineEditor
|
|
479
479
|
end
|
480
480
|
|
481
481
|
class DialogProcScope
|
482
|
-
def initialize(line_editor, proc_to_exec, context)
|
482
|
+
def initialize(line_editor, config, proc_to_exec, context)
|
483
483
|
@line_editor = line_editor
|
484
|
+
@config = config
|
484
485
|
@proc_to_exec = proc_to_exec
|
485
486
|
@context = context
|
486
487
|
@cursor_pos = Reline::CursorPos.new
|
@@ -519,6 +520,10 @@ class Reline::LineEditor
|
|
519
520
|
@line_editor.instance_variable_get(:@completion_journey_data)
|
520
521
|
end
|
521
522
|
|
523
|
+
def config
|
524
|
+
@config
|
525
|
+
end
|
526
|
+
|
522
527
|
def call
|
523
528
|
instance_exec(&@proc_to_exec)
|
524
529
|
end
|
@@ -544,7 +549,7 @@ class Reline::LineEditor
|
|
544
549
|
|
545
550
|
def add_dialog_proc(name, p, context = nil)
|
546
551
|
return if @dialogs.any? { |d| d.name == name }
|
547
|
-
@dialogs << Dialog.new(name, DialogProcScope.new(self, p, context))
|
552
|
+
@dialogs << Dialog.new(name, DialogProcScope.new(self, @config, p, context))
|
548
553
|
end
|
549
554
|
|
550
555
|
DIALOG_HEIGHT = 20
|
@@ -1426,7 +1431,20 @@ class Reline::LineEditor
|
|
1426
1431
|
if result.is_a?(Array)
|
1427
1432
|
completion_occurs = true
|
1428
1433
|
process_insert
|
1429
|
-
|
1434
|
+
if @config.autocompletion
|
1435
|
+
move_completed_list(result, :down)
|
1436
|
+
else
|
1437
|
+
complete(result)
|
1438
|
+
end
|
1439
|
+
end
|
1440
|
+
end
|
1441
|
+
elsif @config.editing_mode_is?(:emacs, :vi_insert) and key.char == :completion_journey_up
|
1442
|
+
if not @config.disable_completion and @config.autocompletion
|
1443
|
+
result = call_completion_proc
|
1444
|
+
if result.is_a?(Array)
|
1445
|
+
completion_occurs = true
|
1446
|
+
process_insert
|
1447
|
+
move_completed_list(result, :up)
|
1430
1448
|
end
|
1431
1449
|
end
|
1432
1450
|
elsif not @config.disable_completion and @config.editing_mode_is?(:vi_insert) and ["\C-p".ord, "\C-n".ord].include?(key.char)
|
data/lib/reline/version.rb
CHANGED
data/lib/reline/windows.rb
CHANGED
@@ -42,6 +42,14 @@ class Reline::Windows
|
|
42
42
|
}.each_pair do |key, func|
|
43
43
|
config.add_default_key_binding_by_keymap(:emacs, key, func)
|
44
44
|
end
|
45
|
+
|
46
|
+
# Emulate ANSI key sequence.
|
47
|
+
{
|
48
|
+
[27, 91, 90] => :completion_journey_up, # S-Tab
|
49
|
+
}.each_pair do |key, func|
|
50
|
+
config.add_default_key_binding_by_keymap(:emacs, key, func)
|
51
|
+
config.add_default_key_binding_by_keymap(:vi_insert, key, func)
|
52
|
+
end
|
45
53
|
end
|
46
54
|
|
47
55
|
if defined? JRUBY_VERSION
|
@@ -106,6 +114,7 @@ class Reline::Windows
|
|
106
114
|
SCROLLLOCK_ON = 0x0040
|
107
115
|
SHIFT_PRESSED = 0x0010
|
108
116
|
|
117
|
+
VK_TAB = 0x09
|
109
118
|
VK_END = 0x23
|
110
119
|
VK_HOME = 0x24
|
111
120
|
VK_LEFT = 0x25
|
@@ -199,6 +208,9 @@ class Reline::Windows
|
|
199
208
|
[ { control_keys: [], virtual_key_code: VK_DELETE }, [0, 83] ],
|
200
209
|
[ { control_keys: [], virtual_key_code: VK_HOME }, [0, 71] ],
|
201
210
|
[ { control_keys: [], virtual_key_code: VK_END }, [0, 79] ],
|
211
|
+
|
212
|
+
# Emulate ANSI key sequence.
|
213
|
+
[ { control_keys: :SHIFT, virtual_key_code: VK_TAB }, [27, 91, 90] ],
|
202
214
|
]
|
203
215
|
|
204
216
|
def self.process_key_event(repeat_count, virtual_key_code, virtual_scan_code, char_code, control_key_state)
|
data/lib/reline.rb
CHANGED
@@ -107,6 +107,14 @@ module Reline
|
|
107
107
|
@completion_proc = p
|
108
108
|
end
|
109
109
|
|
110
|
+
def autocompletion
|
111
|
+
@config.autocompletion
|
112
|
+
end
|
113
|
+
|
114
|
+
def autocompletion=(val)
|
115
|
+
@config.autocompletion = val
|
116
|
+
end
|
117
|
+
|
110
118
|
def output_modifier_proc=(p)
|
111
119
|
raise ArgumentError unless p.respond_to?(:call) or p.nil?
|
112
120
|
@output_modifier_proc = p
|
@@ -180,6 +188,7 @@ module Reline
|
|
180
188
|
|
181
189
|
Reline::DEFAULT_DIALOG_PROC_AUTOCOMPLETE = ->() {
|
182
190
|
# autocomplete
|
191
|
+
return nil unless config.autocompletion
|
183
192
|
if just_cursor_moving and completion_journey_data.nil?
|
184
193
|
# Auto complete starts only when edited
|
185
194
|
return nil
|