highline 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -0
- data/lib/highline.rb +13 -3
- data/lib/highline/system_extensions.rb +1 -1
- data/test/tc_highline.rb +11 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
data/lib/highline.rb
CHANGED
@@ -29,7 +29,7 @@ require "abbrev"
|
|
29
29
|
#
|
30
30
|
class HighLine
|
31
31
|
# The version of the installed library.
|
32
|
-
VERSION = "1.2.
|
32
|
+
VERSION = "1.2.8".freeze
|
33
33
|
|
34
34
|
# An internal HighLine error. User code does not need to trap this.
|
35
35
|
class QuestionError < StandardError
|
@@ -614,21 +614,31 @@ class HighLine
|
|
614
614
|
raw_no_echo_mode if stty = CHARACTER_MODE == "stty"
|
615
615
|
|
616
616
|
line = ""
|
617
|
+
backspace_limit = 0
|
617
618
|
begin
|
619
|
+
|
618
620
|
while character = (stty ? @input.getc : get_character(@input))
|
619
621
|
# honor backspace and delete
|
620
622
|
if character == 127 or character == 8
|
621
623
|
line.slice!(-1, 1)
|
624
|
+
backspace_limit -= 1
|
622
625
|
else
|
623
626
|
line << character.chr
|
627
|
+
backspace_limit += 1
|
624
628
|
end
|
625
629
|
# looking for carriage return (decimal 13) or
|
626
630
|
# newline (decimal 10) in raw input
|
627
631
|
break if character == 13 or character == 10 or
|
628
632
|
(@question.limit and line.size == @question.limit)
|
629
633
|
if @question.echo != false
|
630
|
-
if character == 127 or character == 8
|
631
|
-
|
634
|
+
if character == 127 or character == 8
|
635
|
+
# only backspace if we have characters on the line to
|
636
|
+
# eliminate, otherwise we'll tromp over the prompt
|
637
|
+
if backspace_limit >= 0 then
|
638
|
+
@output.print("\b#{ERASE_CHAR}")
|
639
|
+
else
|
640
|
+
# do nothing
|
641
|
+
end
|
632
642
|
else
|
633
643
|
@output.print(@question.echo)
|
634
644
|
end
|
data/test/tc_highline.rb
CHANGED
@@ -132,6 +132,16 @@ class TestHighLine < Test::Unit::TestCase
|
|
132
132
|
assert_equal(2, answer)
|
133
133
|
assert_equal("Select an option (1, 2 or 3): *\n", @output.string)
|
134
134
|
end
|
135
|
+
|
136
|
+
def test_backspace_does_not_enter_prompt
|
137
|
+
@input << "\b\b"
|
138
|
+
@input.rewind
|
139
|
+
answer = @terminal.ask("Please enter your password: ") do |q|
|
140
|
+
q.echo = "*"
|
141
|
+
end
|
142
|
+
assert_equal("", answer)
|
143
|
+
assert_equal("Please enter your password: \n",@output.string)
|
144
|
+
end
|
135
145
|
|
136
146
|
def test_character_reading
|
137
147
|
# WARNING: This method does NOT cover Unix and Windows savvy testing!
|
@@ -143,7 +153,7 @@ class TestHighLine < Test::Unit::TestCase
|
|
143
153
|
end
|
144
154
|
assert_equal(1, answer)
|
145
155
|
end
|
146
|
-
|
156
|
+
|
147
157
|
def test_color
|
148
158
|
@terminal.say("This should be <%= BLUE %>blue<%= CLEAR %>!")
|
149
159
|
assert_equal("This should be \e[34mblue\e[0m!\n", @output.string)
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: highline
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.2.8
|
7
|
+
date: 2007-06-20 00:00:00 -05:00
|
8
8
|
summary: HighLine is a high-level command-line IO library.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -39,12 +39,12 @@ files:
|
|
39
39
|
- examples/password.rb
|
40
40
|
- examples/trapping_eof.rb
|
41
41
|
- examples/using_readline.rb
|
42
|
-
- lib/highline.rb
|
43
42
|
- lib/highline/color_scheme.rb
|
44
43
|
- lib/highline/import.rb
|
45
44
|
- lib/highline/menu.rb
|
46
45
|
- lib/highline/question.rb
|
47
46
|
- lib/highline/system_extensions.rb
|
47
|
+
- lib/highline.rb
|
48
48
|
- test/tc_color_scheme.rb
|
49
49
|
- test/tc_highline.rb
|
50
50
|
- test/tc_import.rb
|