highline 1.6.16 → 1.6.17
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.
- checksums.yaml +7 -0
- data/CHANGELOG +5 -0
- data/lib/highline.rb +5 -1
- data/lib/highline/system_extensions.rb +46 -22
- data/test/tc_menu.rb +12 -0
- metadata +9 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e7d1127875f296c95669eb827d9eb89b0546d9b5
|
4
|
+
data.tar.gz: ddfe6f50b33cc5cef736259e11f8ee44421747f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 78fd61a881b49fb341078263ad1af1d98cd8d14e34524fd5701932cc929e4572cd96d12eff688a88a9701142e6f268f06f9dcf63fd049b61b1665e92d91a053c
|
7
|
+
data.tar.gz: 6897351c5512a5f39ea98eac8c4bee52a5772dde4e871126d3eb45a68446a12e6097290994a51fbe1a8b71a2ff0ee6c10864b0e728270a368d5aefaa1be7f11f
|
data/CHANGELOG
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
Below is a complete listing of changes for each revision of HighLine.
|
4
4
|
|
5
|
+
== 1.6.17
|
6
|
+
|
7
|
+
* Added encoding support to menus (by David Lyons).
|
8
|
+
* Some minor fixes to SystemExtensions (by whiteleaf and presidentbeef).
|
9
|
+
|
5
10
|
== 1.6.16
|
6
11
|
|
7
12
|
* Added the new indention feature (by davispuh).
|
data/lib/highline.rb
CHANGED
@@ -28,7 +28,7 @@ require "highline/style"
|
|
28
28
|
#
|
29
29
|
class HighLine
|
30
30
|
# The version of the installed library.
|
31
|
-
VERSION = "1.6.
|
31
|
+
VERSION = "1.6.17".freeze
|
32
32
|
|
33
33
|
# An internal HighLine error. User code does not need to trap this.
|
34
34
|
class QuestionError < StandardError
|
@@ -616,6 +616,10 @@ class HighLine
|
|
616
616
|
statement = statement.to_str
|
617
617
|
return unless statement.length > 0
|
618
618
|
|
619
|
+
# Allow non-ascii menu prompts in ruby > 1.9.2. ERB eval the menu statement
|
620
|
+
# with the environment's default encoding(usually utf8)
|
621
|
+
statement.force_encoding(Encoding.default_external) if defined?(Encoding) && Encoding.default_external
|
622
|
+
|
619
623
|
template = ERB.new(statement, nil, "%")
|
620
624
|
statement = template.result(binding)
|
621
625
|
|
@@ -39,19 +39,53 @@ class HighLine
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
module_function
|
43
|
-
|
44
42
|
#
|
45
43
|
# This section builds character reading and terminal size functions
|
46
44
|
# to suit the proper platform we're running on. Be warned: Here be
|
47
45
|
# dragons!
|
48
46
|
#
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
if RUBY_PLATFORM =~ /mswin(?!ce)|mingw|bccwin/i
|
48
|
+
begin
|
49
|
+
require "fiddle"
|
50
|
+
|
51
|
+
module WinAPI
|
52
|
+
include Fiddle
|
53
|
+
Handle = RUBY_VERSION >= "2.0.0" ? Fiddle::Handle : DL::Handle
|
54
|
+
Kernel32 = Handle.new("kernel32")
|
55
|
+
Crt = Handle.new("msvcrt") rescue Handle.new("crtdll")
|
56
|
+
|
57
|
+
def self._getch
|
58
|
+
@@_m_getch ||= Function.new(Crt["_getch"], [], TYPE_INT)
|
59
|
+
@@_m_getch.call
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.GetStdHandle(handle_type)
|
63
|
+
@@get_std_handle ||= Function.new(Kernel32["GetStdHandle"], [-TYPE_INT], -TYPE_INT)
|
64
|
+
@@get_std_handle.call(handle_type)
|
65
|
+
end
|
52
66
|
|
53
|
-
|
67
|
+
def self.GetConsoleScreenBufferInfo(cons_handle, lp_buffer)
|
68
|
+
@@get_console_screen_buffer_info ||=
|
69
|
+
Function.new(Kernel32["GetConsoleScreenBufferInfo"], [TYPE_LONG, TYPE_VOIDP], TYPE_INT)
|
70
|
+
@@get_console_screen_buffer_info.call(cons_handle, lp_buffer)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
rescue LoadError
|
74
|
+
require "dl/import"
|
54
75
|
|
76
|
+
module WinAPI
|
77
|
+
extend DL::Importer rescue DL::Importable
|
78
|
+
begin
|
79
|
+
dlload "msvcrt", "kernel32"
|
80
|
+
rescue DL::DLError
|
81
|
+
dlload "crtdll", "kernel32"
|
82
|
+
end
|
83
|
+
extern "unsigned long _getch()"
|
84
|
+
extern "unsigned long GetConsoleScreenBufferInfo(unsigned long, void*)"
|
85
|
+
extern "unsigned long GetStdHandle(unsigned long)"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
55
89
|
CHARACTER_MODE = "Win32API" # For Debugging purposes only.
|
56
90
|
|
57
91
|
#
|
@@ -61,9 +95,7 @@ class HighLine
|
|
61
95
|
# character from +STDIN+!
|
62
96
|
#
|
63
97
|
def get_character( input = STDIN )
|
64
|
-
|
65
|
-
rescue Exception
|
66
|
-
Win32API.new("crtdll", "_getch", [ ], "L").Call
|
98
|
+
WinAPI._getch
|
67
99
|
end
|
68
100
|
|
69
101
|
# We do not define a raw_no_echo_mode for Windows as _getch turns off echo
|
@@ -75,24 +107,16 @@ class HighLine
|
|
75
107
|
|
76
108
|
# A Windows savvy method to fetch the console columns, and rows.
|
77
109
|
def terminal_size
|
78
|
-
m_GetStdHandle = Win32API.new( 'kernel32',
|
79
|
-
'GetStdHandle',
|
80
|
-
['L'],
|
81
|
-
'L' )
|
82
|
-
m_GetConsoleScreenBufferInfo = Win32API.new(
|
83
|
-
'kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L'
|
84
|
-
)
|
85
|
-
|
86
110
|
format = 'SSSSSssssSS'
|
87
111
|
buf = ([0] * format.size).pack(format)
|
88
|
-
stdout_handle =
|
112
|
+
stdout_handle = WinAPI.GetStdHandle(0xFFFFFFF5)
|
89
113
|
|
90
|
-
|
114
|
+
WinAPI.GetConsoleScreenBufferInfo(stdout_handle, buf)
|
91
115
|
_, _, _, _, _,
|
92
116
|
left, top, right, bottom, _, _ = buf.unpack(format)
|
93
117
|
return right - left + 1, bottom - top + 1
|
94
118
|
end
|
95
|
-
|
119
|
+
else # If we're not on Windows try...
|
96
120
|
begin
|
97
121
|
require "termios" # Unix, first choice termios.
|
98
122
|
|
@@ -169,7 +193,7 @@ class HighLine
|
|
169
193
|
end
|
170
194
|
|
171
195
|
# For termios and stty
|
172
|
-
if not
|
196
|
+
if not method_defined?(:terminal_size)
|
173
197
|
# A Unix savvy method using stty to fetch the console columns, and rows.
|
174
198
|
# ... stty does not work in JRuby
|
175
199
|
def terminal_size
|
@@ -183,7 +207,7 @@ class HighLine
|
|
183
207
|
end
|
184
208
|
end
|
185
209
|
|
186
|
-
if not
|
210
|
+
if not method_defined?(:get_character)
|
187
211
|
def get_character( input = STDIN )
|
188
212
|
input.getbyte
|
189
213
|
end
|
data/test/tc_menu.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
# tc_menu.rb
|
2
3
|
#
|
3
4
|
# Created by Gregory Thomas Brown on 2005-05-10.
|
@@ -65,6 +66,17 @@ class TestMenu < Test::Unit::TestCase
|
|
65
66
|
end
|
66
67
|
assert_equal("Sample1, Sample2 or Sample3? ", @output.string)
|
67
68
|
end
|
69
|
+
|
70
|
+
def test_unicode_flow
|
71
|
+
@input << "1\n"
|
72
|
+
@input.rewind
|
73
|
+
|
74
|
+
@terminal.choose do |menu|
|
75
|
+
# Default: menu.flow = :rows
|
76
|
+
menu.choice "Unicode right single quotation mark: ’"
|
77
|
+
end
|
78
|
+
assert_equal("1. Unicode right single quotation mark: ’\n? ", @output.string)
|
79
|
+
end
|
68
80
|
|
69
81
|
def test_help
|
70
82
|
@input << "help\nhelp load\nhelp rules\nhelp missing\n"
|
metadata
CHANGED
@@ -1,26 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: highline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
5
|
-
prerelease:
|
4
|
+
version: 1.6.17
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- James Edward Gray II
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-04-14 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
15
|
-
and more for
|
16
|
-
|
13
|
+
description: |
|
14
|
+
A high-level IO library that provides validation, type conversion, and more for
|
17
15
|
command-line interfaces. HighLine also includes a complete menu system that can
|
18
|
-
|
19
16
|
crank out anything from simple list selection to complete shells with just
|
20
|
-
|
21
17
|
minutes of work.
|
22
|
-
|
23
|
-
'
|
24
18
|
email: james@graysoftinc.com
|
25
19
|
executables: []
|
26
20
|
extensions: []
|
@@ -82,6 +76,7 @@ files:
|
|
82
76
|
homepage: http://highline.rubyforge.org
|
83
77
|
licenses:
|
84
78
|
- Ruby
|
79
|
+
metadata: {}
|
85
80
|
post_install_message:
|
86
81
|
rdoc_options:
|
87
82
|
- --title
|
@@ -91,22 +86,20 @@ rdoc_options:
|
|
91
86
|
require_paths:
|
92
87
|
- lib
|
93
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
89
|
requirements:
|
96
|
-
- -
|
90
|
+
- - '>='
|
97
91
|
- !ruby/object:Gem::Version
|
98
92
|
version: '0'
|
99
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
-
none: false
|
101
94
|
requirements:
|
102
|
-
- -
|
95
|
+
- - '>='
|
103
96
|
- !ruby/object:Gem::Version
|
104
97
|
version: '0'
|
105
98
|
requirements: []
|
106
99
|
rubyforge_project: highline
|
107
|
-
rubygems_version:
|
100
|
+
rubygems_version: 2.0.3
|
108
101
|
signing_key:
|
109
|
-
specification_version:
|
102
|
+
specification_version: 4
|
110
103
|
summary: HighLine is a high-level command-line IO library.
|
111
104
|
test_files:
|
112
105
|
- test/string_methods.rb
|