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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e937dfc43b28cefc768efd3bdbce315d86dbb57
4
- data.tar.gz: 3970f861094c4db5807291447aeb70a1e2144a4a
3
+ metadata.gz: 4d02c8500ead51f6717b792807c8ae1f30a96a89
4
+ data.tar.gz: 3b63e4704a3b10130e83a44724cf90ee1aaa00aa
5
5
  SHA512:
6
- metadata.gz: 7fbccdab691c99d79feed201ccee633a04ac9c609b4d18318bc2425b544c7b8e578baa77b905b2deb6f597f22dde52f30b06a392d5d402e997194576893dde3b
7
- data.tar.gz: 8a34bd1a0c44816dab5f6b7e709811be0a6cf19463cd8468c7eb6ff9dbd80c667d8975297982fa3132277860f924a144535f6a68fa020ff3b79ad06745cdd24d
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 = "\x07"
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
- print BELL
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
- root, pivot = get_root_pivot
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 pivot string
15
- def next(pivot)
16
- unless @cycler && @old_pivot == pivot
17
- @cycler = source.rebuild(pivot)
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 @cycler
21
- @old_pivot = @cycler.next
20
+ if @active
21
+ @old_buffer = source.next
22
22
  else
23
- @old_pivot = nil
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(pivot)
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
@@ -1,4 +1,4 @@
1
1
  module MiniReadline
2
2
  #The current version of the mini_readline gem.
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  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.6
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-13 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest