win32console 1.2.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.txt +7 -0
- data/HISTORY_GEM.txt +38 -0
- data/INSTALL.txt +18 -0
- data/README.txt +25 -0
- data/README_GEM.txt +64 -0
- data/Rakefile +49 -0
- data/doc/Console.rdoc +690 -0
- data/doc/Console_ANSI.rdoc +302 -0
- data/ext/Console.cpp +1218 -0
- data/ext/extconf.rb +18 -0
- data/lib/Console.so +0 -0
- data/lib/Win32/Console/ANSI.rb +348 -0
- data/lib/Win32/Console/api.rb +342 -0
- data/lib/Win32/Console/constants.rb +66 -0
- data/lib/Win32/Console.rb +372 -0
- data/lib/win32console.rb +1 -0
- data/test/test_cursor.rb +9 -0
- data/test/test_mouse.rb +6 -0
- data/test/test_readinput.rb +62 -0
- data/test/test_readoutput.rb +52 -0
- data/test/test_sendevent.rb +17 -0
- data/test/test_title.rb +14 -0
- data/test/test_write.rb +36 -0
- metadata +83 -0
data/HISTORY.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
v1.0 - Added .dup to _printString function to avoid mangling outside
|
2
|
+
string references. Removed the other (later) .dup call.
|
3
|
+
Turned of some exceptions that were conflicting with using
|
4
|
+
the module with pipes or redirections.
|
5
|
+
v0.8 - Fixed bugs in reading routines, added ruby docs, and
|
6
|
+
sample test suite.
|
7
|
+
v0.5 - First public release.
|
data/HISTORY_GEM.txt
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
1.2.0 - Code corrections integrated from GitHub
|
2
|
+
* Removed license conflicting ANSI Term code and functionality.
|
3
|
+
* Better code organization and clenaup
|
4
|
+
|
5
|
+
1.1.0 - Bug fixes provided by Gordon Thiesfeld (gthiesfeld at gmail dot com).
|
6
|
+
* added #putc to Win32::Console::ANSI::IO
|
7
|
+
This putc buffers escape sequences so that they will be handled properly
|
8
|
+
*added Kernel#putc
|
9
|
+
Redefined Kernel#putc to wrap Win32::Console::ANSI::IO#putc
|
10
|
+
*added #redirected? to Win32::Console::ANSI::IO
|
11
|
+
Checks the mode of the console to see if IO is being redirected or not
|
12
|
+
* fixed "Invalid Handle" error in compiled version of GetConsoleMode
|
13
|
+
I'm actually not sure of the source of this error. It may be expected behavior when output is being redirected. I worked around it by rescuing the exception in Win32::Console#Mode and returning 9999. I picked that arbitrary value, because it is higher than 31, which is what I think is the highest value Mode would return if output isn't being redirected.
|
14
|
+
* modified Win32::Console::ANSI::IO#write
|
15
|
+
to check for redirection. If output is redirected, it uses WriteFile instead of WriteConosle. It also skips the parsing step, and passes the escape sequences through.
|
16
|
+
* added Win32::Console::API#WriteFile
|
17
|
+
to both the Ruby and compiled versions
|
18
|
+
* added Win32::Console*WriteFile
|
19
|
+
This is a wrapper around Win32::Console::API#WriteFile
|
20
|
+
* modified Win32::Console::ANSI::IO#_PrintString
|
21
|
+
Didn't change behavior, just tried to make it more idiomatic ruby. I didn't make all of the changes I wanted to, because I wasn't sure how to test them all.
|
22
|
+
* split Win32::Console::Constants and Win32::Console::API out into seperate files.
|
23
|
+
These two classes were in 'Win32/Console.rb' I moved them into 'Win32/Console/constants.rb' and 'Win32/Console/api.rb' respectively.
|
24
|
+
* cleaned up indentation
|
25
|
+
indentations was a mixture of tabs and spaces. I made everything indented with 2 spaces.
|
26
|
+
* modified all Win32::Console::API methods
|
27
|
+
It was assigning Win32API functions to class variables. I switched them to instance variables. I also changed the idiom it was using to instantiate the objects.
|
28
|
+
For instance, instead of:
|
29
|
+
|
30
|
+
if @@m_AllocConsole == nil
|
31
|
+
@@m_AllocConsole = Win32API.new( "kernel32", "AllocConsole",
|
32
|
+
[], 'l' )
|
33
|
+
|
34
|
+
It is now:
|
35
|
+
|
36
|
+
@AllocConsole ||= Win32API.new( "kernel32", "AllocConsole", [], 'l' )
|
37
|
+
* Non-string arguments passed to Win32::Console::ANSI#write caused error - fix by Ivan Evtuhovich (evtuhovich at gmail dot com).
|
38
|
+
1.0.8 - First public release of win32console gem by Justin Bailey (jgbailey at gmail dot com).
|
data/INSTALL.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
To compile and install:
|
3
|
+
|
4
|
+
|
5
|
+
Open a windows console.
|
6
|
+
> vcvars32.bat # to set up microsoft's compiling environment
|
7
|
+
# this is located in the bin/ directory of the MSVC compiler
|
8
|
+
> ruby extconf.rb # to create a Makefile
|
9
|
+
> nmake # to compile
|
10
|
+
> nmake install # to install
|
11
|
+
|
12
|
+
|
13
|
+
To test:
|
14
|
+
|
15
|
+
> cd test
|
16
|
+
> dir # to see available samples
|
17
|
+
> ruby [anysample]
|
18
|
+
|
data/README.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
This file implements a port of Perl's Win32::Console
|
3
|
+
and Win32::Console::ANSI modules.
|
4
|
+
|
5
|
+
Win32::Console allows controling the windows command line terminal
|
6
|
+
thru an OO-interface. This allows you to query the terminal (find
|
7
|
+
its size, characters, attributes, etc). The interface and functionality
|
8
|
+
should be identical to Perl's.
|
9
|
+
|
10
|
+
Win32::Console consists of a Ruby .rb interface.
|
11
|
+
For best performance, this library has been also ported to C.
|
12
|
+
If you lack a C compiler, you can still use the class thru the ruby
|
13
|
+
interface. If you can compile it, then the ruby interface is not
|
14
|
+
used and the C functions are called instead.
|
15
|
+
|
16
|
+
Win32::Console::ANSI is a class derived from IO that seamlessly
|
17
|
+
translates ANSI Esc control character codes into Windows' command.exe
|
18
|
+
or cmd.exe equivalents.
|
19
|
+
|
20
|
+
These modules allow you to develop command-line tools that can take
|
21
|
+
advantage of the unix terminal functions while still being portable.
|
22
|
+
One of the most common uses for this is to allow to color your
|
23
|
+
output.
|
24
|
+
The modules are disted with Term/ansicolor.rb, too, as it is a nice
|
25
|
+
thing to verify it is working properly.
|
data/README_GEM.txt
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
= Introduction
|
2
|
+
|
3
|
+
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:
|
4
|
+
|
5
|
+
http://rubyforge.org/projects/win32console
|
6
|
+
|
7
|
+
To use the gem, just put
|
8
|
+
|
9
|
+
require 'win32console'
|
10
|
+
|
11
|
+
At the top of your file.
|
12
|
+
|
13
|
+
= Example
|
14
|
+
|
15
|
+
To output a simple bolded string, try this script:
|
16
|
+
|
17
|
+
require 'rubygems'
|
18
|
+
require 'win32console'
|
19
|
+
include Win32::Console::ANSI
|
20
|
+
include Term::ANSIColor
|
21
|
+
|
22
|
+
puts bold << "bolded text" << clear << " and no longer bold."
|
23
|
+
|
24
|
+
= Formatting Methods Available
|
25
|
+
|
26
|
+
The full list of methods available is found in lib/Term/ansicolor.rb (generated from the @@attributes array):
|
27
|
+
|
28
|
+
clear
|
29
|
+
reset # synonym for clear
|
30
|
+
bold
|
31
|
+
dark
|
32
|
+
italic # not widely implemented
|
33
|
+
underline
|
34
|
+
underscore # synonym for underline
|
35
|
+
blink
|
36
|
+
rapid_blink # not widely implemented
|
37
|
+
negative # no reverse because of String#reverse
|
38
|
+
concealed
|
39
|
+
strikethrough # not widely implemented
|
40
|
+
|
41
|
+
# The following will set the foreground color
|
42
|
+
|
43
|
+
black
|
44
|
+
red
|
45
|
+
green
|
46
|
+
yellow
|
47
|
+
blue
|
48
|
+
magenta
|
49
|
+
cyan
|
50
|
+
white
|
51
|
+
|
52
|
+
# The following will set the background color
|
53
|
+
|
54
|
+
on_black
|
55
|
+
on_red
|
56
|
+
on_green
|
57
|
+
on_yellow
|
58
|
+
on_blue
|
59
|
+
on_magenta
|
60
|
+
on_cyan
|
61
|
+
on_white
|
62
|
+
|
63
|
+
The methods are fairly sophisticated. If you don't pass an argument, the appropriate escape sequence is returned. If a string is given, it will be outputted with an escape sequence wrapping it to apply the formatting to just that portion. If a block is given, the escape sequence will wrap the output of the block. Finally, if the Term::ANSIColor module is mixed into an object, and that instance supports to_str, tnen the result of to_str will be wrapped in the escape sequence.
|
64
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require './tasks/ext_helper'
|
5
|
+
|
6
|
+
# House-keeping
|
7
|
+
CLEAN.include '**/*.o', '**/*.so', '**/*.bundle', '**/*.a',
|
8
|
+
'**/*.log', '{ext,lib}/*.{bundle,so,obj,pdb,lib,def,exp}',
|
9
|
+
'ext/Makefile', '**/*.db'
|
10
|
+
|
11
|
+
spec = Gem::Specification.new do |s|
|
12
|
+
s.name = 'win32console'
|
13
|
+
s.version = '1.2.0'
|
14
|
+
s.platform = Gem::Platform::RUBY
|
15
|
+
s.has_rdoc = true
|
16
|
+
s.extra_rdoc_files = %w[ README.txt README_GEM.txt INSTALL.txt HISTORY.txt HISTORY_GEM.txt ]
|
17
|
+
s.summary = 'A library giving the Win32 console ANSI escape sequence support.'
|
18
|
+
s.description = s.summary
|
19
|
+
s.author = 'Original Library by Gonzalo Garramuno, Gem by Justin Bailey'
|
20
|
+
s.email = 'ggarra @nospam@ advancedsl.com.ar, jgbailey @nospan@ gmail.com'
|
21
|
+
s.homepage = 'http://rubyforge.org/projects/winconsole'
|
22
|
+
s.rubyforge_project = 'http://rubyforge.org/projects/winconsole'
|
23
|
+
s.description = <<EOS
|
24
|
+
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:
|
25
|
+
|
26
|
+
http://rubyforge.org/projects/win32console
|
27
|
+
|
28
|
+
The gem project can be found at
|
29
|
+
|
30
|
+
http://rubyforge.org/projects/winconsole
|
31
|
+
EOS
|
32
|
+
|
33
|
+
s.require_path = 'lib'
|
34
|
+
s.extensions = %w[ ext/extconf.rb ]
|
35
|
+
s.files = FileList[ '{doc,ext,lib,test}/**/*.{rdoc,c,cpp,rb}', 'Rakefile', *s.extra_rdoc_files ]
|
36
|
+
|
37
|
+
s.rdoc_options << '--title' << 'Win32Console Gem -- Gem for Win32::Console Project' <<
|
38
|
+
'--main' << 'README_GEM.txt' <<
|
39
|
+
'--line-numbers'
|
40
|
+
end
|
41
|
+
|
42
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
43
|
+
pkg.need_tar = true
|
44
|
+
pkg.gem_spec = spec
|
45
|
+
end
|
46
|
+
|
47
|
+
# Use of ext_helper to properly setup compile tasks and native gem generation
|
48
|
+
# add 'native', 'compile' and some tweaks to gem specifications.
|
49
|
+
setup_extension 'Console', spec
|