rubytext 0.1.5 → 0.1.6

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: 639051dd8b75b79ea2fcd3b2b3c348393221429528c3fee94ba2d477d9021878
4
- data.tar.gz: 4bcc89047ec533e1b9b517f3cf0cb236f7ed9474d855ec82c5ec8e8310417e68
3
+ metadata.gz: 6f1f66253898628d0de61033adc7f68272464aac892e0df3a2a08f3ffb046c7a
4
+ data.tar.gz: 452bc1908cfd5b63d9c7c2afcd08f3a6839ccc3395aabdf44f39b164606e7229
5
5
  SHA512:
6
- metadata.gz: bde3e200841bb7f2b308c975d8d5553a897cbce44c8d7f47f940e7d5b324e35177701465a76f505eea35fa77b1fd9873e983333d40639b64b8330aee201b2171
7
- data.tar.gz: 58aa416a667d26001f78346cc0d91194a598ad1521cb1d593a62f203c2a4d5e2eaf46940c703583fc37fc074ca8d68bb5f9241c27c255591f0cb2c460830d9ad
6
+ metadata.gz: a694ac3c9c128038b17d6020d6e440a48cabc67969db9f0ba3eb107e19a0460b4b7eb52c4c457b42915eb082f55847e216245ed8f49357e36520118a21253768
7
+ data.tar.gz: d80a126d0c56ac7deda93931e670c4148fda63f0d9233486558bb1dfb9da25b76a7b1f6fbee197db3ec53308fb25c3d5b353615718294033e3e69b449051fd2f
data/lib/output.rb CHANGED
@@ -139,13 +139,15 @@ class RubyText::Window
139
139
  end
140
140
 
141
141
  class GetString
142
- def initialize(win = STDSCR, str = "", i = 0, history: [])
142
+ def initialize(win = STDSCR, str = "", i = 0, history: [], limit: nil)
143
143
  @win = win
144
144
  @r0, @c0 = @win.rc
145
- @str, @i = str, i
145
+ @limit = limit || (@win.cols - @r0 - 1)
146
+ raise ArgumentError unless @limit.is_a?(Numeric)
147
+ @str, @i = str[0..(@limit-1)], i
146
148
  @history = history
147
149
  @h = @history.length - 1
148
- @maxlen = 0
150
+ @maxlen = 0 # longest string in history
149
151
  end
150
152
 
151
153
  def enter
@@ -175,9 +177,6 @@ class RubyText::Window
175
177
  @str[@i] = ""
176
178
  @win.left
177
179
  @win.rcprint @r0, @c0, @str + " "
178
- # @r, @c = @win.rc
179
- # @win[@r0, @c0+@str.length+1] = ' '
180
- # @win.go @r, @c
181
180
  end
182
181
 
183
182
  def history_prev
@@ -205,6 +204,10 @@ class RubyText::Window
205
204
  end
206
205
 
207
206
  def add(ch)
207
+ if @str.length >= @limit
208
+ Curses.beep
209
+ return
210
+ end
208
211
  @str.insert(@i, ch)
209
212
  @win.right
210
213
  @win.go(@r0, @c0) { @win.print @str }
@@ -216,10 +219,10 @@ class RubyText::Window
216
219
  end
217
220
  end
218
221
 
219
- def gets(history: []) # still needs improvement
222
+ def gets(history: [], limit: nil) # still needs improvement
220
223
  # echo assumed to be OFF, keypad ON
221
224
  @history = history
222
- gs = GetString.new(self, history: history)
225
+ gs = GetString.new(self, history: history, limit: limit)
223
226
  loop do
224
227
  ch = self.getch
225
228
  case ch
@@ -1,6 +1,6 @@
1
1
 
2
2
  module RubyText
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
 
5
5
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubytext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton