win32console 1.3.0.beta1 → 1.3.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -1
- data/Rakefile +0 -46
- data/lib/Win32/Console.rb +10 -0
- data/lib/Win32/Console/ANSI.rb +11 -5
- data/tasks/gem.rake +1 -1
- data/tasks/native.rake +4 -2
- data/test/test_readinput.rb +16 -0
- data/test/test_std.rb +4 -0
- data/test/test_write.rb +1 -0
- metadata +24 -3
data/History.txt
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
=== 1.3.0.
|
1
|
+
=== 1.3.0.beta2 / 2010-03-07
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
* Redirect STDERR to be processed also for ANSI codes. Closes GH-4
|
5
|
+
* Allow ECHO to be displayed [jloveces]
|
6
|
+
|
7
|
+
=== 1.3.0.beta1
|
2
8
|
|
3
9
|
* Enhancements
|
4
10
|
* Usage of Hoe and rake-compiler to ease releasing and extension
|
data/Rakefile
CHANGED
@@ -6,49 +6,3 @@
|
|
6
6
|
|
7
7
|
# load rakefile extensions (tasks)
|
8
8
|
Dir['tasks/*.rake'].sort.each { |f| load f }
|
9
|
-
|
10
|
-
=begin
|
11
|
-
require 'rubygems'
|
12
|
-
require 'rake/clean'
|
13
|
-
require 'rake/gempackagetask'
|
14
|
-
require 'rake/extensiontask'
|
15
|
-
|
16
|
-
spec = Gem::Specification.new do |s|
|
17
|
-
s.name = 'win32console'
|
18
|
-
s.version = '1.2.0'
|
19
|
-
s.platform = Gem::Platform::RUBY
|
20
|
-
s.has_rdoc = true
|
21
|
-
s.extra_rdoc_files = %w[ README.txt README_GEM.txt INSTALL.txt HISTORY.txt HISTORY_GEM.txt ]
|
22
|
-
s.summary = 'A library giving the Win32 console ANSI escape sequence support.'
|
23
|
-
s.description = s.summary
|
24
|
-
s.author = 'Original Library by Gonzalo Garramuno, Gem by Justin Bailey'
|
25
|
-
s.email = 'ggarra @nospam@ advancedsl.com.ar, jgbailey @nospan@ gmail.com'
|
26
|
-
s.homepage = 'http://rubyforge.org/projects/winconsole'
|
27
|
-
s.rubyforge_project = 'http://rubyforge.org/projects/winconsole'
|
28
|
-
s.description = <<EOS
|
29
|
-
This gem packages Gonzalo Garramuno's Win32::Console project, and includes a compiled binary for speed. The Win32::Console project's home can be found at:
|
30
|
-
|
31
|
-
http://rubyforge.org/projects/win32console
|
32
|
-
|
33
|
-
The gem project can be found at
|
34
|
-
|
35
|
-
http://rubyforge.org/projects/winconsole
|
36
|
-
EOS
|
37
|
-
|
38
|
-
s.require_path = 'lib'
|
39
|
-
s.extensions = %w[ ext/Console/extconf.rb ]
|
40
|
-
s.files = FileList[ '{doc,ext,lib,test}/**/*.{rdoc,c,cpp,rb}', 'Rakefile', *s.extra_rdoc_files ]
|
41
|
-
|
42
|
-
s.rdoc_options << '--title' << 'Win32Console Gem -- Gem for Win32::Console Project' <<
|
43
|
-
'--main' << 'README_GEM.txt' <<
|
44
|
-
'--line-numbers'
|
45
|
-
end
|
46
|
-
|
47
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
48
|
-
pkg.need_tar = true
|
49
|
-
pkg.gem_spec = spec
|
50
|
-
end
|
51
|
-
|
52
|
-
Rake::ExtensionTask.new('Console', spec) do |ext|
|
53
|
-
end
|
54
|
-
=end
|
data/lib/Win32/Console.rb
CHANGED
@@ -184,6 +184,16 @@ module Win32
|
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
+
def Echo(flag = nil)
|
188
|
+
if flag.nil?
|
189
|
+
(self.Mode & ENABLE_ECHO_INPUT) == ENABLE_ECHO_INPUT
|
190
|
+
elsif flag
|
191
|
+
self.Mode(self.Mode | ENABLE_ECHO_INPUT)
|
192
|
+
else
|
193
|
+
self.Mode(self.Mode & ~ENABLE_ECHO_INPUT)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
187
197
|
def WriteInput(*t)
|
188
198
|
API.WriteConsoleInput(@handle, *t)
|
189
199
|
end
|
data/lib/Win32/Console/ANSI.rb
CHANGED
@@ -39,6 +39,11 @@ module Win32
|
|
39
39
|
|
40
40
|
include Win32::Console::Constants
|
41
41
|
|
42
|
+
FD_STD_MAP = {
|
43
|
+
:stdout => [1, STD_OUTPUT_HANDLE],
|
44
|
+
:stderr => [2, STD_ERROR_HANDLE]
|
45
|
+
}
|
46
|
+
|
42
47
|
# @todo: encode is another perl module
|
43
48
|
EncodeOk = false
|
44
49
|
|
@@ -77,9 +82,10 @@ module Win32
|
|
77
82
|
47 => BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE, # white background
|
78
83
|
}
|
79
84
|
|
80
|
-
def initialize
|
81
|
-
|
82
|
-
|
85
|
+
def initialize(fd_std = :stdout)
|
86
|
+
fd, handle = FD_STD_MAP[fd_std]
|
87
|
+
super(fd, 'w')
|
88
|
+
@Out = Win32::Console.new(handle)
|
83
89
|
@x = @y = 0 # to save cursor position
|
84
90
|
@foreground = 7
|
85
91
|
@background = 0
|
@@ -332,5 +338,5 @@ module Win32
|
|
332
338
|
end
|
333
339
|
end
|
334
340
|
|
335
|
-
$stdout = Win32::Console::ANSI::IO.new()
|
336
|
-
|
341
|
+
$stdout = Win32::Console::ANSI::IO.new(:stdout)
|
342
|
+
$stderr = Win32::Console::ANSI::IO.new(:stderr)
|
data/tasks/gem.rake
CHANGED
data/tasks/native.rake
CHANGED
@@ -3,8 +3,10 @@ require 'rake/extensiontask'
|
|
3
3
|
|
4
4
|
Rake::ExtensionTask.new('Console_ext', HOE.spec) do |ext|
|
5
5
|
# FIXME: enable cross compilation to build fat binaries
|
6
|
-
|
7
|
-
|
6
|
+
unless RUBY_PLATFORM =~ /mingw|mswin/ then
|
7
|
+
ext.cross_compile = true
|
8
|
+
ext.cross_platform = ['i386-mingw32', 'i386-mswin32-60']
|
9
|
+
end
|
8
10
|
|
9
11
|
# place extension binaries inside lib/X.Y
|
10
12
|
if RUBY_PLATFORM =~ /mingw|mswin/
|
data/test/test_readinput.rb
CHANGED
@@ -10,7 +10,9 @@ puts "InputChar: Type a phrase then ENTER, please:"
|
|
10
10
|
x1 = a.InputChar(1)
|
11
11
|
puts "Your phrase starts with the character #{x1}"
|
12
12
|
|
13
|
+
gets #clear regular input buffer
|
13
14
|
|
15
|
+
oldMode = a.Mode
|
14
16
|
fdwMode = ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT
|
15
17
|
|
16
18
|
a.Mode(fdwMode)
|
@@ -60,3 +62,17 @@ else
|
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
65
|
+
|
66
|
+
|
67
|
+
a.Mode(oldMode)
|
68
|
+
|
69
|
+
a.Echo(false)
|
70
|
+
puts
|
71
|
+
puts "Echo is #{a.Echo}: Type something, which you SHOULD NOT see"
|
72
|
+
gets
|
73
|
+
|
74
|
+
a.Echo(true)
|
75
|
+
puts
|
76
|
+
puts "Echo is #{a.Echo}: Type something, which you SHOULD see"
|
77
|
+
gets
|
78
|
+
|
data/test/test_std.rb
ADDED
data/test/test_write.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.0.
|
4
|
+
version: 1.3.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gonzalo Garramuno
|
@@ -11,9 +11,29 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date:
|
14
|
+
date: 2010-03-07 00:00:00 -03:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: rubyforge
|
19
|
+
type: :development
|
20
|
+
version_requirement:
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 2.0.3
|
26
|
+
version:
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gemcutter
|
29
|
+
type: :development
|
30
|
+
version_requirement:
|
31
|
+
version_requirements: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.3.0
|
36
|
+
version:
|
17
37
|
- !ruby/object:Gem::Dependency
|
18
38
|
name: rake-compiler
|
19
39
|
type: :development
|
@@ -32,7 +52,7 @@ dependencies:
|
|
32
52
|
requirements:
|
33
53
|
- - ">="
|
34
54
|
- !ruby/object:Gem::Version
|
35
|
-
version: 2.
|
55
|
+
version: 2.5.0
|
36
56
|
version:
|
37
57
|
description: |-
|
38
58
|
Win32::Console allows controling the windows command line terminal
|
@@ -118,6 +138,7 @@ specification_version: 3
|
|
118
138
|
summary: Win32::Console allows controling the windows command line terminal thru an OO-interface
|
119
139
|
test_files:
|
120
140
|
- test/test_mouse.rb
|
141
|
+
- test/test_std.rb
|
121
142
|
- test/test_readoutput.rb
|
122
143
|
- test/test_write.rb
|
123
144
|
- test/test_readinput.rb
|