highline 1.2.6 → 1.2.7
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 +6 -0
- data/lib/highline.rb +39 -11
- data/test/tc_highline.rb +14 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
Below is a complete listing of changes for each revision of HighLine.
|
4
4
|
|
5
|
+
== 1.2.7
|
6
|
+
|
7
|
+
* Fixed the stty indent bug.
|
8
|
+
* Fixed the echo backspace bug.
|
9
|
+
* Added HighLine::track_eof=() setting to work are threaded eof?() calls.
|
10
|
+
|
5
11
|
== 1.2.6
|
6
12
|
|
7
13
|
Patch by Jeremy Hinegardner:
|
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.7".freeze
|
33
33
|
|
34
34
|
# An internal HighLine error. User code does not need to trap this.
|
35
35
|
class QuestionError < StandardError
|
@@ -48,6 +48,19 @@ class HighLine
|
|
48
48
|
def self.use_color?
|
49
49
|
@@use_color
|
50
50
|
end
|
51
|
+
|
52
|
+
# The setting used to disable EOF tracking.
|
53
|
+
@@track_eof = true
|
54
|
+
|
55
|
+
# Pass +false+ to _setting_ to turn off HighLine's EOF tracking.
|
56
|
+
def self.track_eof=( setting )
|
57
|
+
@@track_eof = setting
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns true if HighLine is currently tracking EOF for input.
|
61
|
+
def self.track_eof?
|
62
|
+
@@track_eof
|
63
|
+
end
|
51
64
|
|
52
65
|
# The setting used to control color schemes.
|
53
66
|
@@color_scheme = nil
|
@@ -75,7 +88,9 @@ class HighLine
|
|
75
88
|
# An alias for CLEAR.
|
76
89
|
RESET = CLEAR
|
77
90
|
# Erase the current line of terminal output.
|
78
|
-
ERASE_LINE = "\e[K"
|
91
|
+
ERASE_LINE = "\e[K"
|
92
|
+
# Erase the character under the cursor.
|
93
|
+
ERASE_CHAR = "\e[P"
|
79
94
|
# The start of an ANSI bold sequence.
|
80
95
|
BOLD = "\e[1m"
|
81
96
|
# The start of an ANSI dark sequence. (Terminal support uncommon.)
|
@@ -573,7 +588,8 @@ class HighLine
|
|
573
588
|
|
574
589
|
answer
|
575
590
|
else
|
576
|
-
raise EOFError, "The input stream is exhausted." if
|
591
|
+
raise EOFError, "The input stream is exhausted." if @@track_eof and
|
592
|
+
@input.eof?
|
577
593
|
|
578
594
|
@question.change_case(@question.remove_whitespace(@input.gets))
|
579
595
|
end
|
@@ -600,22 +616,34 @@ class HighLine
|
|
600
616
|
line = ""
|
601
617
|
begin
|
602
618
|
while character = (stty ? @input.getc : get_character(@input))
|
603
|
-
|
619
|
+
# honor backspace and delete
|
620
|
+
if character == 127 or character == 8
|
621
|
+
line.slice!(-1, 1)
|
622
|
+
else
|
623
|
+
line << character.chr
|
624
|
+
end
|
604
625
|
# looking for carriage return (decimal 13) or
|
605
626
|
# newline (decimal 10) in raw input
|
606
627
|
break if character == 13 or character == 10 or
|
607
628
|
(@question.limit and line.size == @question.limit)
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
629
|
+
if @question.echo != false
|
630
|
+
if character == 127 or character == 8
|
631
|
+
@output.print("\b#{ERASE_CHAR}")
|
632
|
+
else
|
633
|
+
@output.print(@question.echo)
|
634
|
+
end
|
635
|
+
@output.flush
|
636
|
+
end
|
615
637
|
end
|
616
638
|
ensure
|
617
639
|
restore_mode if stty
|
618
640
|
end
|
641
|
+
if @question.overwrite
|
642
|
+
@output.print("\r#{ERASE_LINE}")
|
643
|
+
@output.flush
|
644
|
+
else
|
645
|
+
say("\n")
|
646
|
+
end
|
619
647
|
|
620
648
|
@question.change_case(@question.remove_whitespace(line))
|
621
649
|
end
|
data/test/tc_highline.rb
CHANGED
@@ -771,6 +771,20 @@ class TestHighLine < Test::Unit::TestCase
|
|
771
771
|
assert_equal(("-=" * 40 + "\n") + ("-=" * 10 + "\n"), @output.string)
|
772
772
|
end
|
773
773
|
|
774
|
+
def test_track_eof
|
775
|
+
assert_raise(EOFError) { @terminal.ask("Any input left? ") }
|
776
|
+
|
777
|
+
# turn EOF tracking
|
778
|
+
old_setting = HighLine.track_eof?
|
779
|
+
assert_nothing_raised(Exception) { HighLine.track_eof = false }
|
780
|
+
begin
|
781
|
+
@terminal.ask("And now? ") # this will still blow up, nothing available
|
782
|
+
rescue
|
783
|
+
assert_not_equal(EOFError, $!.class) # but HighLine's safe guards are off
|
784
|
+
end
|
785
|
+
HighLine.track_eof = old_setting
|
786
|
+
end
|
787
|
+
|
774
788
|
def test_version
|
775
789
|
assert_not_nil(HighLine::VERSION)
|
776
790
|
assert_instance_of(String, HighLine::VERSION)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.1
|
|
3
3
|
specification_version: 1
|
4
4
|
name: highline
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2007-01-
|
6
|
+
version: 1.2.7
|
7
|
+
date: 2007-01-31 00:00:00 -06:00
|
8
8
|
summary: HighLine is a high-level command-line IO library.
|
9
9
|
require_paths:
|
10
10
|
- lib
|