rubytext 0.1.13 → 0.1.14

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
  SHA256:
3
- metadata.gz: b868f42a2da112076a37ef66415e924ce33bef38ac256306cbd6bdb9ca2d88e3
4
- data.tar.gz: 55f82c3d30480238dfc9fbbf715664eaffadc8f7f9c647f6db5b004d1cfbc30d
3
+ metadata.gz: 5edfad72caf19e2e70c17c0abd239a2a563f29db90d7bf46afda16c7d3660f66
4
+ data.tar.gz: a6736885d763fc52c8ce5f25da49365e144949fda7a4e4943c82c4fe40869496
5
5
  SHA512:
6
- metadata.gz: 70986013ad4d13935141752c05b75a81f174305c19294f02f5b0830c941eac365e1f809d3c99aef1ae03d150e6d8877d69111521b6598a06ca46d541090afb8f
7
- data.tar.gz: cab9b4fab8e0e6a3053e3c48da250866a4db55bfba81c877a674e1696fcf8c043d0ad63d97199ec9e54fdd15cdc9fa5f3dbea2c6ae3bd3599a9c828321346e4b
6
+ metadata.gz: c3d1eb8234d2a1ac623570647abcd1e729047c5e4b3511664f6e825cf470221903c1d9471813f36439c24c07f1cb2c0592e5ccb0ddf986893e5f23cd98b48177
7
+ data.tar.gz: 15570d3cd19c82f16df066652f82a5df07824fd7805c54aac2ddbc4b361be24969a718cdc967fd86f0c0d7c80a9aca2d28e8b99a1277eed58ffa3f94062574d0
@@ -139,7 +139,7 @@ class RubyText::Window
139
139
  end
140
140
 
141
141
  class GetString
142
- def initialize(win = STDSCR, str = "", i = 0, history: [], limit: nil)
142
+ def initialize(win = STDSCR, str = "", i = 0, history: [], limit: nil, tab: [])
143
143
  @win = win
144
144
  @r0, @c0 = @win.rc
145
145
  @limit = limit || (@win.cols - @r0 - 1)
@@ -149,7 +149,8 @@ class RubyText::Window
149
149
  @win.left @str.length
150
150
  @history = history
151
151
  @h = @history.length - 1
152
- @maxlen = 0 # longest string in history
152
+ @maxlen = 0 # longest string in history list
153
+ @tabcom = tab
153
154
  end
154
155
 
155
156
  def enter
@@ -205,6 +206,23 @@ class RubyText::Window
205
206
  @win.print @str
206
207
  end
207
208
 
209
+ def complete
210
+ targets = @tabcom.find_all {|x| x.start_with?(@str) }
211
+ if targets.nil?
212
+ Curses.beep
213
+ return
214
+ end
215
+ if targets.size > 1
216
+ num, target = STDSCR.menu(items: targets)
217
+ else
218
+ target = targets.first
219
+ end
220
+ @str = target.dup
221
+ @i = @str.length
222
+ @win.go @r0, @c0
223
+ @win.print @str
224
+ end
225
+
208
226
  def add(ch)
209
227
  if @str.length >= @limit
210
228
  Curses.beep
@@ -221,10 +239,10 @@ class RubyText::Window
221
239
  end
222
240
  end
223
241
 
224
- def gets(history: [], limit: nil, default: "") # still needs improvement
242
+ def gets(history: [], limit: nil, tab: [], default: "") # still needs improvement
225
243
  # echo assumed to be OFF, keypad ON
226
244
  @history = history
227
- gs = GetString.new(self, default, history: history, limit: limit)
245
+ gs = GetString.new(self, default, history: history, limit: limit, tab: tab)
228
246
  loop do
229
247
  ch = self.getch
230
248
  case ch
@@ -233,6 +251,8 @@ class RubyText::Window
233
251
  break
234
252
  when 8, 127, 63 # backspace, del, ^H (huh?)
235
253
  gs.backspace
254
+ when 9 # tab
255
+ gs.complete
236
256
  when 260 # left-arrow
237
257
  gs.left_arrow
238
258
  when 261 # right-arrow
@@ -1,6 +1,6 @@
1
1
 
2
2
  module RubyText
3
- VERSION = "0.1.13"
3
+ VERSION = "0.1.14"
4
4
 
5
5
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubytext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-20 00:00:00.000000000 Z
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses