reline 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reline.rb +13 -13
- data/lib/reline/ansi.rb +3 -1
- data/lib/reline/line_editor.rb +21 -1
- data/lib/reline/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9a8719e2dd161d4d3493907d730981e19b685854247d1da4e8a107a9af88f98
|
4
|
+
data.tar.gz: 57c468696aecaa1752bf0ebacafbb9595ec8810c0dd406beb9bd95f31b8e2d05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47f940b15f36eb7e410bf9951916258c268375fffadb661766fca64a421cc4e7aeb701a919c0b47dd03ea9b4aa1110c7c5b870328bad704c40f8e6d945a90ba2
|
7
|
+
data.tar.gz: 271926159d49eaa2b6572cc5d3640c81d82cfbc42d03a7320b0731fec276575a96c7491ab192023125a02e44d0a1cf38ee3ffa5045ac29e93f18e83ab9478071
|
data/lib/reline.rb
CHANGED
@@ -16,12 +16,6 @@ module Reline
|
|
16
16
|
CursorPos = Struct.new(:x, :y)
|
17
17
|
|
18
18
|
class Core
|
19
|
-
if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
20
|
-
IS_WINDOWS = true
|
21
|
-
else
|
22
|
-
IS_WINDOWS = false
|
23
|
-
end
|
24
|
-
|
25
19
|
ATTR_READER_NAMES = %i(
|
26
20
|
completion_append_character
|
27
21
|
basic_word_break_characters
|
@@ -90,22 +84,22 @@ module Reline
|
|
90
84
|
end
|
91
85
|
|
92
86
|
def completion_proc=(p)
|
93
|
-
raise ArgumentError unless p.
|
87
|
+
raise ArgumentError unless p.respond_to?(:call)
|
94
88
|
@completion_proc = p
|
95
89
|
end
|
96
90
|
|
97
91
|
def output_modifier_proc=(p)
|
98
|
-
raise ArgumentError unless p.
|
92
|
+
raise ArgumentError unless p.respond_to?(:call)
|
99
93
|
@output_modifier_proc = p
|
100
94
|
end
|
101
95
|
|
102
96
|
def prompt_proc=(p)
|
103
|
-
raise ArgumentError unless p.
|
97
|
+
raise ArgumentError unless p.respond_to?(:call)
|
104
98
|
@prompt_proc = p
|
105
99
|
end
|
106
100
|
|
107
101
|
def auto_indent_proc=(p)
|
108
|
-
raise ArgumentError unless p.
|
102
|
+
raise ArgumentError unless p.respond_to?(:call)
|
109
103
|
@auto_indent_proc = p
|
110
104
|
end
|
111
105
|
|
@@ -114,7 +108,7 @@ module Reline
|
|
114
108
|
end
|
115
109
|
|
116
110
|
def dig_perfect_match_proc=(p)
|
117
|
-
raise ArgumentError unless p.
|
111
|
+
raise ArgumentError unless p.respond_to?(:call)
|
118
112
|
@dig_perfect_match_proc = p
|
119
113
|
end
|
120
114
|
|
@@ -400,9 +394,15 @@ module Reline
|
|
400
394
|
HISTORY = History.new(core.config)
|
401
395
|
end
|
402
396
|
|
403
|
-
if
|
397
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
404
398
|
require 'reline/windows'
|
405
|
-
Reline::
|
399
|
+
if Reline::Windows.get_screen_size == [0, 0]
|
400
|
+
# Maybe Mintty on Cygwin
|
401
|
+
require 'reline/ansi'
|
402
|
+
Reline::IOGate = Reline::ANSI
|
403
|
+
else
|
404
|
+
Reline::IOGate = Reline::Windows
|
405
|
+
end
|
406
406
|
else
|
407
407
|
require 'reline/ansi'
|
408
408
|
Reline::IOGate = Reline::ANSI
|
data/lib/reline/ansi.rb
CHANGED
@@ -7,6 +7,8 @@ class Reline::ANSI
|
|
7
7
|
[27, 91, 51, 126] => :key_delete, # Del
|
8
8
|
[27, 91, 49, 126] => :ed_move_to_beg, # Home
|
9
9
|
[27, 91, 52, 126] => :ed_move_to_end, # End
|
10
|
+
[27, 91, 72] => :ed_move_to_beg, # Home
|
11
|
+
[27, 91, 70] => :ed_move_to_end, # End
|
10
12
|
[27, 32] => :em_set_mark, # M-<space>
|
11
13
|
[24, 24] => :em_exchange_mark, # C-x C-x TODO also add Windows
|
12
14
|
}
|
@@ -135,7 +137,7 @@ class Reline::ANSI
|
|
135
137
|
|
136
138
|
def self.deprep(otio)
|
137
139
|
int_handle = Signal.trap('INT', 'IGNORE')
|
138
|
-
|
140
|
+
system("stty #{otio}", err: File::NULL)
|
139
141
|
Signal.trap('INT', int_handle)
|
140
142
|
Signal.trap('WINCH', @@old_winch_handler) if @@old_winch_handler
|
141
143
|
end
|
data/lib/reline/line_editor.rb
CHANGED
@@ -766,7 +766,7 @@ class Reline::LineEditor
|
|
766
766
|
end
|
767
767
|
|
768
768
|
def input_key(key)
|
769
|
-
if key.
|
769
|
+
if key.char.nil?
|
770
770
|
if @first_char
|
771
771
|
@line = nil
|
772
772
|
end
|
@@ -806,6 +806,26 @@ class Reline::LineEditor
|
|
806
806
|
|
807
807
|
private def process_auto_indent
|
808
808
|
return if not @check_new_auto_indent and @previous_line_index # move cursor up or down
|
809
|
+
if @check_new_auto_indent and @previous_line_index and @previous_line_index > 0 and @line_index > @previous_line_index
|
810
|
+
# Fix indent of a line when a newline is inserted to the next
|
811
|
+
new_lines = whole_lines(index: @previous_line_index, line: @line)
|
812
|
+
new_indent = @auto_indent_proc.(new_lines[0..-3].push(''), @line_index - 1, 0, true)
|
813
|
+
md = @line.match(/\A */)
|
814
|
+
prev_indent = md[0].count(' ')
|
815
|
+
@line = ' ' * new_indent + @line.lstrip
|
816
|
+
|
817
|
+
new_indent = nil
|
818
|
+
(new_lines[-2].size + 1).times do |n|
|
819
|
+
result = @auto_indent_proc.(new_lines[0..-2], @line_index - 1, n, false)
|
820
|
+
if result
|
821
|
+
new_indent = result
|
822
|
+
break
|
823
|
+
end
|
824
|
+
end
|
825
|
+
if new_indent&.>= 0
|
826
|
+
@line = ' ' * new_indent + @line.lstrip
|
827
|
+
end
|
828
|
+
end
|
809
829
|
if @previous_line_index
|
810
830
|
new_lines = whole_lines(index: @previous_line_index, line: @line)
|
811
831
|
else
|
data/lib/reline/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.0.
|
101
|
+
rubygems_version: 3.0.6
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Alternative GNU Readline or Editline implementation by pure Ruby.
|