mini_readline 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/mini_readline.rb +1 -1
- data/lib/mini_readline/raw_term/other.rb +3 -2
- data/lib/mini_readline/read_line/edit/auto_complete.rb +2 -9
- data/lib/mini_readline/read_line/edit/auto_complete/auto_manager.rb +7 -7
- data/lib/mini_readline/read_line/edit/auto_complete/file_folder_source.rb +10 -3
- data/lib/mini_readline/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d02c8500ead51f6717b792807c8ae1f30a96a89
|
4
|
+
data.tar.gz: 3b63e4704a3b10130e83a44724cf90ee1aaa00aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c1a11f6c6d153bc9dc6be134cf468137f2520fae462c72592bc4dbeed4dc454f0e9eabe121d82b596d59110704650630ac004f80f7778375e938ad754c36a16
|
7
|
+
data.tar.gz: eca8f72a58a7b61385828e2de85db43798f966194477dc60dfd3e5b60d2ab4d7a3d6a1201f664062ff8eaed6b3f9896c1ce6ec99674af4dca27f2274671406ae
|
data/README.md
CHANGED
@@ -163,6 +163,9 @@ BASE_OPTIONS = {
|
|
163
163
|
:alt_prompt => "<< ", #The prompt when scrolled.
|
164
164
|
#Set to nil for no alt prompt.
|
165
165
|
|
166
|
+
:auto_complete => true, #Is auto complete enabled?
|
167
|
+
:auto_source => nil, #Filled in by auto_complete.rb
|
168
|
+
|
166
169
|
:history => false, #Is the history buffer enabled?
|
167
170
|
:no_blanks => true, #No empty lines in history.
|
168
171
|
:no_dups => true, #No duplicate lines in history.
|
data/lib/mini_readline.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative "mini_readline/version"
|
4
4
|
require_relative "mini_readline/options"
|
5
|
-
require_relative "mini_readline/read_line"
|
6
5
|
require_relative "mini_readline/raw_term"
|
6
|
+
require_relative "mini_readline/read_line"
|
7
7
|
|
8
8
|
#The \MiniReadline module. A replacement for the rb_readline gem predicated
|
9
9
|
#on the notion/hope that the code shouldn't smell like an abandoned fish
|
@@ -17,7 +17,7 @@ module MiniReadline
|
|
17
17
|
CARRIAGE_RETURN = "\x0D"
|
18
18
|
|
19
19
|
#Bell
|
20
|
-
BELL
|
20
|
+
BELL = "\x07"
|
21
21
|
|
22
22
|
#Output a string
|
23
23
|
def put_string(str)
|
@@ -39,7 +39,8 @@ module MiniReadline
|
|
39
39
|
|
40
40
|
#Sound a beep
|
41
41
|
def beep
|
42
|
-
|
42
|
+
$stderr.write(BELL)
|
43
|
+
$stderr.flush
|
43
44
|
end
|
44
45
|
|
45
46
|
#Get a uncooked character keystroke.
|
@@ -14,21 +14,14 @@ module MiniReadline
|
|
14
14
|
|
15
15
|
#The auto-complete command.
|
16
16
|
def auto_complete(_keyboard_args)
|
17
|
-
|
18
|
-
|
19
|
-
if (new_pivot = auto_manager.next(pivot))
|
20
|
-
@edit_buffer = root + new_pivot
|
17
|
+
if @options[:auto_complete] && (new_buffer = auto_manager.next(auto_trim))
|
18
|
+
@edit_buffer = new_buffer
|
21
19
|
@edit_posn = length
|
22
20
|
else
|
23
21
|
@term.beep
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
|
-
#Get the key components of the auto-complete process.
|
28
|
-
def get_root_pivot
|
29
|
-
/\S+$/ =~ (str = auto_trim) ? [$`.to_s, $~.to_s] : [str, ""]
|
30
|
-
end
|
31
|
-
|
32
25
|
#Get the base part of the edit buffer.
|
33
26
|
def auto_trim
|
34
27
|
@edit_buffer[0...(@edit_posn)]
|
@@ -11,16 +11,16 @@ module MiniReadline
|
|
11
11
|
@_block = block
|
12
12
|
end
|
13
13
|
|
14
|
-
#Get the next
|
15
|
-
def next(
|
16
|
-
unless @
|
17
|
-
@
|
14
|
+
#Get the next buffer string
|
15
|
+
def next(buffer)
|
16
|
+
unless @active && @old_buffer == buffer
|
17
|
+
@active = source.rebuild(buffer)
|
18
18
|
end
|
19
19
|
|
20
|
-
if @
|
21
|
-
@
|
20
|
+
if @active
|
21
|
+
@old_buffer = source.next
|
22
22
|
else
|
23
|
-
@
|
23
|
+
@old_buffer = nil
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -7,16 +7,23 @@ module MiniReadline
|
|
7
7
|
class FileFolderSource
|
8
8
|
|
9
9
|
#Construct a new data list for auto-complete
|
10
|
-
def rebuild(
|
10
|
+
def rebuild(str)
|
11
|
+
@root, pivot = /\S+$/ =~ str ? [$`.to_s, $~.to_s] : [str, ""]
|
12
|
+
|
11
13
|
list = Dir.glob(pivot + '*')
|
12
14
|
|
13
15
|
unless list.empty?
|
14
|
-
list.cycle
|
16
|
+
@cycler = list.cycle
|
15
17
|
else
|
16
|
-
nil
|
18
|
+
@cycler = nil
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
22
|
+
#Get the next string for auto-complete
|
23
|
+
def next
|
24
|
+
@root + @cycler.next
|
25
|
+
end
|
26
|
+
|
20
27
|
end
|
21
28
|
|
22
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_readline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|