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 +4 -4
- data/lib/output.rb +11 -8
- data/lib/rubytext_version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f1f66253898628d0de61033adc7f68272464aac892e0df3a2a08f3ffb046c7a
|
4
|
+
data.tar.gz: 452bc1908cfd5b63d9c7c2afcd08f3a6839ccc3395aabdf44f39b164606e7229
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
@
|
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
|
data/lib/rubytext_version.rb
CHANGED