win32console 1.2.0-x86-mswin32-60 → 1.3.0.beta1-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +119 -0
- data/Manifest.txt +22 -0
- data/README.txt +63 -25
- data/Rakefile +15 -10
- data/ext/{Console.cpp → Console_ext/Console.c} +41 -43
- data/ext/{extconf.rb → Console_ext/extconf.rb} +1 -1
- data/{doc → extra}/Console.rdoc +0 -0
- data/{doc → extra}/Console_ANSI.rdoc +0 -0
- data/lib/1.8/Console_ext.so +0 -0
- data/lib/1.9/Console_ext.so +0 -0
- data/lib/Win32/Console.rb +6 -16
- data/lib/Win32/Console/ANSI.rb +3 -15
- data/tasks/gem.rake +31 -0
- data/tasks/native.rake +14 -0
- metadata +82 -37
- data/HISTORY.txt +0 -7
- data/HISTORY_GEM.txt +0 -38
- data/INSTALL.txt +0 -18
- data/README_GEM.txt +0 -64
- data/lib/Console.so +0 -0
data/History.txt
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
=== 1.3.0.beta
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
* Usage of Hoe and rake-compiler to ease releasing and extension
|
5
|
+
compilation.
|
6
|
+
|
7
|
+
* Bugfixes:
|
8
|
+
* Works with Ruby 1.9
|
9
|
+
|
10
|
+
* Known issues:
|
11
|
+
* win32console no longer automatically translate encoding to the console
|
12
|
+
output enconding. Please use Iconv to convert from your encoding (eg. UTF8)
|
13
|
+
to current console output:
|
14
|
+
|
15
|
+
current_cp = Win32::Console::OutputCP()
|
16
|
+
Iconv.iconv("cp#{current_cp}", "utf-8", utf_string)
|
17
|
+
|
18
|
+
A working example can be seen here: http://gist.github.com/265593
|
19
|
+
|
20
|
+
=== 1.2.0 / 2008-11-22
|
21
|
+
|
22
|
+
* Enhancements
|
23
|
+
* Better code organization and clenaup
|
24
|
+
|
25
|
+
* Bugfixes:
|
26
|
+
* Removed license conflicting ANSI Term code and functionality.
|
27
|
+
|
28
|
+
=== 1.1.0 / 2008-03-17
|
29
|
+
|
30
|
+
* Enhancements:
|
31
|
+
* Added Kernel#putc
|
32
|
+
Redefined Kernel#putc to wrap Win32::Console::ANSI::IO#putc
|
33
|
+
|
34
|
+
* Added #putc to Win32::Console::ANSI::IO
|
35
|
+
This putc buffers escape sequences so that they will be handled properly
|
36
|
+
|
37
|
+
* Added #redirected? to Win32::Console::ANSI::IO
|
38
|
+
Checks the mode of the console to see if IO is being redirected or not
|
39
|
+
|
40
|
+
* Added Win32::Console::API#WriteFile
|
41
|
+
to both the Ruby and compiled versions
|
42
|
+
|
43
|
+
* Added Win32::Console#WriteFile
|
44
|
+
This is a wrapper around Win32::Console::API#WriteFile
|
45
|
+
|
46
|
+
* Split Win32::Console::Constants and Win32::Console::API out into
|
47
|
+
seperate files. These two classes were in 'Win32/Console.rb'
|
48
|
+
I moved them into 'Win32/Console/constants.rb' and 'Win32/Console/api.rb'
|
49
|
+
respectively.
|
50
|
+
|
51
|
+
* Cleaned up indentation
|
52
|
+
indentations was a mixture of tabs and spaces. I made everything indented
|
53
|
+
with 2 spaces.
|
54
|
+
|
55
|
+
* Bugfixes:
|
56
|
+
* Fixed "Invalid Handle" error in compiled version of GetConsoleMode
|
57
|
+
I'm actually not sure of the source of this error.
|
58
|
+
It may be expected behavior when output is being redirected.
|
59
|
+
I worked around it by rescuing the exception in Win32::Console#Mode and
|
60
|
+
returning 9999. I picked that arbitrary value, because it is
|
61
|
+
higher than 31, which is what I think is the highest value Mode would
|
62
|
+
return if output isn't being redirected.
|
63
|
+
[Gordon Thiesfeld]
|
64
|
+
|
65
|
+
* Modified Win32::Console::ANSI::IO#write to check for redirection.
|
66
|
+
If output is redirected, it uses WriteFile instead of WriteConosle.
|
67
|
+
It also skips the parsing step, and passes the escape sequences through.
|
68
|
+
[Gordon Thiesfeld]
|
69
|
+
|
70
|
+
* Modified Win32::Console::ANSI::IO#_PrintString
|
71
|
+
Didn't change behavior, just tried to make it more idiomatic ruby.
|
72
|
+
I didn't make all of the changes I wanted to, because I wasn't sure
|
73
|
+
how to test them all.
|
74
|
+
[Gordon Thiesfeld]
|
75
|
+
|
76
|
+
* Modified all Win32::Console::API methods
|
77
|
+
[Gordon Thiesfeld]
|
78
|
+
|
79
|
+
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.
|
80
|
+
For instance, instead of:
|
81
|
+
|
82
|
+
if @@m_AllocConsole == nil
|
83
|
+
@@m_AllocConsole = Win32API.new( "kernel32", "AllocConsole",
|
84
|
+
[], 'l' )
|
85
|
+
|
86
|
+
It is now:
|
87
|
+
|
88
|
+
@AllocConsole ||= Win32API.new( "kernel32", "AllocConsole", [], 'l' )
|
89
|
+
|
90
|
+
* Non-string arguments passed to Win32::Console::ANSI#write caused error
|
91
|
+
fix by Ivan Evtuhovich (evtuhovich at gmail dot com).
|
92
|
+
|
93
|
+
=== 1.0.8 / 2006-06-05
|
94
|
+
|
95
|
+
* New features:
|
96
|
+
* First public release of win32console gem by Justin Bailey.
|
97
|
+
|
98
|
+
=== 1.0
|
99
|
+
|
100
|
+
* New features:
|
101
|
+
* Added .dup to _printString function to avoid mangling outside
|
102
|
+
string references. Removed the other (later) .dup call.
|
103
|
+
|
104
|
+
* Bugfixes:
|
105
|
+
* Turned of some exceptions that were conflicting with using the module
|
106
|
+
with pipes or redirections.
|
107
|
+
|
108
|
+
=== 0.8
|
109
|
+
|
110
|
+
* Enhancements:
|
111
|
+
* Added ruby docs, and sample test suite.
|
112
|
+
|
113
|
+
* Bugfixes:
|
114
|
+
* Fixed bugs in reading routines,
|
115
|
+
|
116
|
+
=== 0.5
|
117
|
+
|
118
|
+
New features:
|
119
|
+
* First public release.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
Rakefile
|
4
|
+
README.txt
|
5
|
+
ext/Console_ext/Console.c
|
6
|
+
ext/Console_ext/extconf.rb
|
7
|
+
extra/Console.rdoc
|
8
|
+
extra/Console_ANSI.rdoc
|
9
|
+
lib/win32console.rb
|
10
|
+
lib/Win32/Console.rb
|
11
|
+
lib/Win32/Console/ANSI.rb
|
12
|
+
lib/Win32/Console/api.rb
|
13
|
+
lib/Win32/Console/constants.rb
|
14
|
+
tasks/gem.rake
|
15
|
+
tasks/native.rake
|
16
|
+
test/test_cursor.rb
|
17
|
+
test/test_mouse.rb
|
18
|
+
test/test_readinput.rb
|
19
|
+
test/test_readoutput.rb
|
20
|
+
test/test_sendevent.rb
|
21
|
+
test/test_title.rb
|
22
|
+
test/test_write.rb
|
data/README.txt
CHANGED
@@ -1,25 +1,63 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
= Win32::Console
|
2
|
+
|
3
|
+
* http://rubyforge.org/projects/winconsole
|
4
|
+
* http://github.com/luislavena/win32console
|
5
|
+
* http://rdoc.info/projects/luislavena/win32console
|
6
|
+
|
7
|
+
== DESCRIPTION
|
8
|
+
|
9
|
+
Win32::Console allows controling the windows command line terminal
|
10
|
+
thru an OO-interface. This allows you to query the terminal (find
|
11
|
+
its size, characters, attributes, etc). The interface and functionality
|
12
|
+
should be identical to Perl's counterpart.
|
13
|
+
|
14
|
+
A port of Perl's Win32::Console and Win32::Console::ANSI modules.
|
15
|
+
|
16
|
+
This gem packages Gonzalo Garramuno's Win32::Console project, and includes
|
17
|
+
a compiled binary for speed. The Win32::Console project's home can be
|
18
|
+
found at:
|
19
|
+
|
20
|
+
http://rubyforge.org/projects/win32console
|
21
|
+
|
22
|
+
== FEATURES
|
23
|
+
|
24
|
+
Win32::Console::ANSI is a class derived from IO that seamlessly
|
25
|
+
translates ANSI Esc control character codes into Windows' command.exe
|
26
|
+
or cmd.exe equivalents.
|
27
|
+
|
28
|
+
To ease usage, you can use in combination with term-ansicolor gem and avoid
|
29
|
+
writing ANSI codes manually.
|
30
|
+
|
31
|
+
== EXAMPLES
|
32
|
+
|
33
|
+
To output a simple bolded string, try this script:
|
34
|
+
|
35
|
+
require 'rubygems'
|
36
|
+
require 'win32console'
|
37
|
+
include Win32::Console::ANSI
|
38
|
+
include Term::ANSIColor
|
39
|
+
|
40
|
+
puts bold << "bolded text" << clear << " and no longer bold."
|
41
|
+
|
42
|
+
== INSTALL
|
43
|
+
|
44
|
+
gem install win32console
|
45
|
+
|
46
|
+
== DEVELOPERS:
|
47
|
+
|
48
|
+
After checking out the source, run:
|
49
|
+
|
50
|
+
$ rake newb
|
51
|
+
|
52
|
+
This task will install any missing dependencies, run the tests/specs,
|
53
|
+
and generate the RDoc.
|
54
|
+
|
55
|
+
== LICENSE
|
56
|
+
|
57
|
+
This program is FREE; you can redistribute, modify, disassemble, or even
|
58
|
+
reverse engineer this software at your will. Keep in mind, however, that
|
59
|
+
NOTHING IS GUARANTEED to work and everything you do is AT YOUR OWN RISK - I
|
60
|
+
will not take responsibility for any damage, loss of money and/or health
|
61
|
+
that may arise from the use of this program!
|
62
|
+
|
63
|
+
This is distributed under the terms of Larry Wall's Artistic License.
|
data/Rakefile
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
+
#
|
2
|
+
# NOTE: Keep this file clean.
|
3
|
+
# Add your customizations inside tasks directory.
|
4
|
+
# Thank You.
|
5
|
+
#
|
6
|
+
|
7
|
+
# load rakefile extensions (tasks)
|
8
|
+
Dir['tasks/*.rake'].sort.each { |f| load f }
|
9
|
+
|
10
|
+
=begin
|
1
11
|
require 'rubygems'
|
2
12
|
require 'rake/clean'
|
3
13
|
require 'rake/gempackagetask'
|
4
|
-
require '
|
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'
|
14
|
+
require 'rake/extensiontask'
|
10
15
|
|
11
16
|
spec = Gem::Specification.new do |s|
|
12
17
|
s.name = 'win32console'
|
@@ -31,7 +36,7 @@ The gem project can be found at
|
|
31
36
|
EOS
|
32
37
|
|
33
38
|
s.require_path = 'lib'
|
34
|
-
s.extensions = %w[ ext/extconf.rb ]
|
39
|
+
s.extensions = %w[ ext/Console/extconf.rb ]
|
35
40
|
s.files = FileList[ '{doc,ext,lib,test}/**/*.{rdoc,c,cpp,rb}', 'Rakefile', *s.extra_rdoc_files ]
|
36
41
|
|
37
42
|
s.rdoc_options << '--title' << 'Win32Console Gem -- Gem for Win32::Console Project' <<
|
@@ -44,6 +49,6 @@ Rake::GemPackageTask.new(spec) do |pkg|
|
|
44
49
|
pkg.gem_spec = spec
|
45
50
|
end
|
46
51
|
|
47
|
-
|
48
|
-
|
49
|
-
|
52
|
+
Rake::ExtensionTask.new('Console', spec) do |ext|
|
53
|
+
end
|
54
|
+
=end
|
@@ -1,11 +1,12 @@
|
|
1
|
-
|
2
|
-
#include "windows.h"
|
1
|
+
#include <windows.h>
|
3
2
|
#include "ruby.h"
|
4
3
|
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
4
|
+
/* Workaround deprecated RString accessors */
|
5
|
+
#ifndef RSTRING_PTR
|
6
|
+
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
7
|
+
#endif
|
8
|
+
#ifndef RSTRING_LEN
|
9
|
+
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
9
10
|
#endif
|
10
11
|
|
11
12
|
VALUE rb_mWin32;
|
@@ -32,7 +33,6 @@ VALUE rb_mConstants;
|
|
32
33
|
VALUE
|
33
34
|
rb_getWin32Error()
|
34
35
|
{
|
35
|
-
DWORD e = GetLastError();
|
36
36
|
LPVOID lpMsgBuf;
|
37
37
|
if (!FormatMessage(
|
38
38
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
@@ -55,15 +55,12 @@ rb_getWin32Error()
|
|
55
55
|
LocalFree( lpMsgBuf );
|
56
56
|
|
57
57
|
// Raise exception
|
58
|
-
rb_raise(rb_eRuntimeError,
|
58
|
+
rb_raise(rb_eRuntimeError, RSTRING_PTR(t));
|
59
59
|
return Qnil;
|
60
60
|
|
61
61
|
}
|
62
62
|
|
63
63
|
|
64
|
-
extern "C"
|
65
|
-
{
|
66
|
-
|
67
64
|
static VALUE rb_GetStdHandle(VALUE self, VALUE handle)
|
68
65
|
{
|
69
66
|
unsigned long x;
|
@@ -205,11 +202,11 @@ static VALUE rb_WriteConsole( VALUE self, VALUE hConsoleOutput,
|
|
205
202
|
VALUE lpBuffer )
|
206
203
|
{
|
207
204
|
HANDLE handle = ULongToPtr( NUM2ULONG( hConsoleOutput ) );
|
208
|
-
DWORD nNumberOfCharsToWrite =
|
205
|
+
DWORD nNumberOfCharsToWrite = RSTRING_LEN(lpBuffer);
|
209
206
|
|
210
207
|
DWORD lpNumberOfCharsWritten;
|
211
208
|
|
212
|
-
WriteConsole( handle,
|
209
|
+
WriteConsole( handle, RSTRING_PTR(lpBuffer),
|
213
210
|
nNumberOfCharsToWrite,
|
214
211
|
&lpNumberOfCharsWritten, NULL );
|
215
212
|
return UINT2NUM( lpNumberOfCharsWritten );
|
@@ -219,11 +216,11 @@ static VALUE rb_WriteFile( VALUE self, VALUE hConsoleOutput,
|
|
219
216
|
VALUE lpBuffer )
|
220
217
|
{
|
221
218
|
HANDLE handle = ULongToPtr( NUM2ULONG( hConsoleOutput ) );
|
222
|
-
DWORD nNumberOfBytesToWrite =
|
219
|
+
DWORD nNumberOfBytesToWrite = RSTRING_LEN(lpBuffer);
|
223
220
|
|
224
221
|
DWORD lpNumberOfBytesWritten;
|
225
222
|
|
226
|
-
WriteFile( handle,
|
223
|
+
WriteFile( handle, RSTRING_PTR(lpBuffer),
|
227
224
|
nNumberOfBytesToWrite,
|
228
225
|
&lpNumberOfBytesWritten, NULL );
|
229
226
|
return UINT2NUM( lpNumberOfBytesWritten );
|
@@ -255,12 +252,12 @@ static VALUE rb_GetConsoleCursorInfo( VALUE self, VALUE hConsoleOutput )
|
|
255
252
|
return ret;
|
256
253
|
}
|
257
254
|
|
258
|
-
void rb_ParseEvent(VALUE ret, INPUT_RECORD
|
255
|
+
void rb_ParseEvent(VALUE ret, INPUT_RECORD *event )
|
259
256
|
{
|
260
|
-
switch(event
|
257
|
+
switch(event->EventType) {
|
261
258
|
case KEY_EVENT:
|
262
259
|
{
|
263
|
-
KEY_EVENT_RECORD* kevent=(KEY_EVENT_RECORD *)&(event
|
260
|
+
KEY_EVENT_RECORD* kevent=(KEY_EVENT_RECORD *)&(event->Event);
|
264
261
|
rb_ary_push(ret, UINT2NUM(KEY_EVENT));
|
265
262
|
rb_ary_push(ret, UINT2NUM(kevent->bKeyDown));
|
266
263
|
rb_ary_push(ret, UINT2NUM(kevent->wRepeatCount));
|
@@ -276,7 +273,7 @@ void rb_ParseEvent(VALUE ret, INPUT_RECORD& event )
|
|
276
273
|
}
|
277
274
|
case MOUSE_EVENT:
|
278
275
|
{
|
279
|
-
MOUSE_EVENT_RECORD * mevent=(MOUSE_EVENT_RECORD *)&(event
|
276
|
+
MOUSE_EVENT_RECORD * mevent=(MOUSE_EVENT_RECORD *)&(event->Event);
|
280
277
|
rb_ary_push(ret, UINT2NUM(MOUSE_EVENT) );
|
281
278
|
rb_ary_push(ret, UINT2NUM(mevent->dwMousePosition.X) );
|
282
279
|
rb_ary_push(ret, UINT2NUM(mevent->dwMousePosition.Y) );
|
@@ -288,7 +285,7 @@ void rb_ParseEvent(VALUE ret, INPUT_RECORD& event )
|
|
288
285
|
case WINDOW_BUFFER_SIZE_EVENT:
|
289
286
|
{
|
290
287
|
WINDOW_BUFFER_SIZE_RECORD* wevent=
|
291
|
-
(WINDOW_BUFFER_SIZE_RECORD *)&(event
|
288
|
+
(WINDOW_BUFFER_SIZE_RECORD *)&(event->Event);
|
292
289
|
rb_ary_push(ret, UINT2NUM(WINDOW_BUFFER_SIZE_EVENT) );
|
293
290
|
rb_ary_push(ret, UINT2NUM(wevent->dwSize.X) );
|
294
291
|
rb_ary_push(ret, UINT2NUM(wevent->dwSize.Y) );
|
@@ -296,14 +293,14 @@ void rb_ParseEvent(VALUE ret, INPUT_RECORD& event )
|
|
296
293
|
break;
|
297
294
|
case MENU_EVENT:
|
298
295
|
{
|
299
|
-
MENU_EVENT_RECORD* mevent= (MENU_EVENT_RECORD *)&(event
|
296
|
+
MENU_EVENT_RECORD* mevent= (MENU_EVENT_RECORD *)&(event->Event);
|
300
297
|
rb_ary_push(ret, UINT2NUM(MENU_EVENT) );
|
301
298
|
rb_ary_push(ret, UINT2NUM(mevent->dwCommandId) );
|
302
299
|
}
|
303
300
|
break;
|
304
301
|
case FOCUS_EVENT:
|
305
302
|
{
|
306
|
-
FOCUS_EVENT_RECORD* mevent= (FOCUS_EVENT_RECORD *)&(event
|
303
|
+
FOCUS_EVENT_RECORD* mevent= (FOCUS_EVENT_RECORD *)&(event->Event);
|
307
304
|
rb_ary_push(ret, UINT2NUM(FOCUS_EVENT) );
|
308
305
|
rb_ary_push(ret, UINT2NUM(mevent->bSetFocus) );
|
309
306
|
}
|
@@ -321,7 +318,7 @@ static VALUE rb_PeekConsoleInput( VALUE self, VALUE hConsoleOutput )
|
|
321
318
|
return rb_getWin32Error();
|
322
319
|
|
323
320
|
VALUE ret = rb_ary_new();
|
324
|
-
rb_ParseEvent( ret, event );
|
321
|
+
rb_ParseEvent( ret, &event );
|
325
322
|
return ret;
|
326
323
|
}
|
327
324
|
|
@@ -332,9 +329,9 @@ static VALUE rb_ReadConsole( VALUE self, VALUE hConsoleOutput,
|
|
332
329
|
DWORD nofread;
|
333
330
|
Check_Type( buffer, T_STRING );
|
334
331
|
int to_read = NUM2INT(numread);
|
335
|
-
if (
|
332
|
+
if ( RSTRING_LEN(buffer) > to_read )
|
336
333
|
rb_raise(rb_eArgError, "String is too small to read that many characters.");
|
337
|
-
if (ReadConsole(handle,(void *)
|
334
|
+
if (ReadConsole(handle,(void *)RSTRING_PTR(buffer), to_read,
|
338
335
|
&nofread,NULL))
|
339
336
|
return UINT2NUM(nofread);
|
340
337
|
return rb_getWin32Error();
|
@@ -349,7 +346,7 @@ static VALUE rb_ReadConsoleInput( VALUE self, VALUE hConsoleOutput )
|
|
349
346
|
return rb_getWin32Error();
|
350
347
|
|
351
348
|
VALUE ret = rb_ary_new();
|
352
|
-
rb_ParseEvent( ret, event );
|
349
|
+
rb_ParseEvent( ret, &event );
|
353
350
|
return ret;
|
354
351
|
}
|
355
352
|
|
@@ -365,9 +362,9 @@ static VALUE rb_ReadConsoleOutputCharacter( VALUE self, VALUE hConsoleOutput,
|
|
365
362
|
coords.X= NUM2UINT( x );
|
366
363
|
coords.Y= NUM2UINT( y );
|
367
364
|
int l = NUM2INT(len);
|
368
|
-
if (
|
365
|
+
if ( (unsigned long)RSTRING_LEN(charbuf) < l*sizeof(TCHAR) )
|
369
366
|
rb_raise(rb_eArgError, "String is too small to read that many characters.");
|
370
|
-
if (ReadConsoleOutputCharacter(handle,
|
367
|
+
if (ReadConsoleOutputCharacter(handle,RSTRING_PTR(charbuf),l,
|
371
368
|
coords,&nofread))
|
372
369
|
return UINT2NUM( nofread );
|
373
370
|
return rb_getWin32Error();
|
@@ -382,12 +379,14 @@ static VALUE rb_ReadConsoleOutputAttribute( VALUE self, VALUE hConsoleOutput,
|
|
382
379
|
DWORD nofread;
|
383
380
|
unsigned short abuffer[80*999*sizeof(unsigned short)];
|
384
381
|
char cbuffer[80*999];
|
382
|
+
unsigned i = 0;
|
383
|
+
|
385
384
|
coords.X= NUM2UINT( x );
|
386
385
|
coords.Y= NUM2UINT( y );
|
387
386
|
if (ReadConsoleOutputAttribute(handle, abuffer, NUM2UINT(len),
|
388
387
|
coords,&nofread))
|
389
388
|
{
|
390
|
-
for(
|
389
|
+
for(i=0;i<nofread;++i) {
|
391
390
|
cbuffer[i]=(char)abuffer[i];
|
392
391
|
}
|
393
392
|
return rb_str_new( cbuffer, nofread );
|
@@ -413,10 +412,10 @@ static VALUE rb_ReadConsoleOutput( VALUE self, VALUE hConsoleOutput,
|
|
413
412
|
from.Right = NUM2INT( r );
|
414
413
|
from.Bottom = NUM2INT( b );
|
415
414
|
Check_Type( buffer, T_STRING );
|
416
|
-
if (
|
415
|
+
if ( (unsigned long)RSTRING_LEN(buffer) < (sizeof(CHAR_INFO)*size.X*size.Y) )
|
417
416
|
rb_raise(rb_eArgError, "string buffer is too small for reading that many characters.");
|
418
417
|
HANDLE handle = ULongToPtr( NUM2ULONG( hConsoleOutput ) );
|
419
|
-
if (!ReadConsoleOutput(handle,(CHAR_INFO *)
|
418
|
+
if (!ReadConsoleOutput(handle,(CHAR_INFO *)RSTRING_PTR(buffer),size,coords,&from))
|
420
419
|
return rb_getWin32Error();
|
421
420
|
|
422
421
|
VALUE ret = rb_ary_new();
|
@@ -739,7 +738,7 @@ not_there:
|
|
739
738
|
VALUE rb_constant( VALUE self, VALUE name )
|
740
739
|
{
|
741
740
|
Check_Type( name, T_STRING );
|
742
|
-
return ULONG2NUM( c_constant(
|
741
|
+
return ULONG2NUM( c_constant( RSTRING_PTR(name) ) );
|
743
742
|
}
|
744
743
|
|
745
744
|
|
@@ -844,7 +843,7 @@ VALUE
|
|
844
843
|
rb_SetConsoleTitle( VALUE self, VALUE title )
|
845
844
|
{
|
846
845
|
Check_Type( title, T_STRING );
|
847
|
-
if (SetConsoleTitle(
|
846
|
+
if (SetConsoleTitle(RSTRING_PTR( title )))
|
848
847
|
return NUM2UINT(1);
|
849
848
|
return rb_getWin32Error();
|
850
849
|
}
|
@@ -1081,7 +1080,7 @@ rb_WriteConsoleOutput(VALUE self, VALUE h, VALUE buffer,
|
|
1081
1080
|
to.Top = NUM2INT( t );
|
1082
1081
|
to.Right = NUM2INT( r );
|
1083
1082
|
to.Bottom = NUM2INT( b );
|
1084
|
-
if (WriteConsoleOutput(handle,(CHAR_INFO *)
|
1083
|
+
if (WriteConsoleOutput(handle,(CHAR_INFO *)RSTRING_PTR(buffer),
|
1085
1084
|
size,coords,&to)) {
|
1086
1085
|
VALUE ret = rb_ary_new();
|
1087
1086
|
rb_ary_push( ret, INT2FIX( to.Left ) );
|
@@ -1104,9 +1103,11 @@ rb_WriteConsoleOutputAttribute(VALUE self, VALUE h, VALUE s,
|
|
1104
1103
|
|
1105
1104
|
unsigned short buffer[80*999*sizeof(unsigned short)];
|
1106
1105
|
DWORD written;
|
1107
|
-
DWORD towrite =
|
1108
|
-
|
1109
|
-
|
1106
|
+
DWORD towrite = RSTRING_LEN(s);
|
1107
|
+
unsigned i = 0;
|
1108
|
+
|
1109
|
+
for(i=0; i<towrite; i++) {
|
1110
|
+
buffer[i] = (unsigned short)(RSTRING_PTR(s)[i]);
|
1110
1111
|
}
|
1111
1112
|
COORD coords;
|
1112
1113
|
coords.X=NUM2INT( x );
|
@@ -1131,16 +1132,15 @@ rb_WriteConsoleOutputCharacter(VALUE self, VALUE h, VALUE s,
|
|
1131
1132
|
COORD coords;
|
1132
1133
|
coords.X=NUM2INT( x );
|
1133
1134
|
coords.Y=NUM2INT( y );
|
1134
|
-
if (WriteConsoleOutputCharacter(handle,(LPCTSTR)
|
1135
|
-
|
1135
|
+
if (WriteConsoleOutputCharacter(handle,(LPCTSTR)RSTRING_PTR(s),
|
1136
|
+
RSTRING_LEN(s),coords,&written)) {
|
1136
1137
|
return UINT2NUM( written );
|
1137
1138
|
}
|
1138
1139
|
return rb_getWin32Error();
|
1139
1140
|
}
|
1140
1141
|
|
1141
1142
|
|
1142
|
-
|
1143
|
-
Init_Console(void)
|
1143
|
+
void Init_Console_ext(void)
|
1144
1144
|
{
|
1145
1145
|
rb_mWin32 = rb_define_module("Win32");
|
1146
1146
|
rb_define_const(rb_mKernel, "Win32", rb_mWin32);
|
@@ -1214,5 +1214,3 @@ Init_Console(void)
|
|
1214
1214
|
RB_DEF_API_METHOD(WriteConsoleOutputCharacter, 4);
|
1215
1215
|
|
1216
1216
|
}
|
1217
|
-
|
1218
|
-
}
|
data/{doc → extra}/Console.rdoc
RENAMED
File without changes
|
File without changes
|
Binary file
|
Binary file
|
data/lib/Win32/Console.rb
CHANGED
@@ -4,23 +4,13 @@
|
|
4
4
|
# Original Win32API_Console was:
|
5
5
|
# Copyright (C) 2001 Michael L. Semon (mlsemon@sega.net)
|
6
6
|
|
7
|
+
# support multiple ruby version (fat binaries under windows)
|
7
8
|
begin
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
#
|
12
|
-
|
13
|
-
require "Console.so"
|
14
|
-
STDERR.print "Using faster, DLL Console.so\n" if $DEBUG
|
15
|
-
|
16
|
-
rescue Exception
|
17
|
-
|
18
|
-
STDERR.print "Using slower, non-DLL Console.rb\n" if $DEBUG
|
19
|
-
|
20
|
-
require 'Win32/Console/constants.rb'
|
21
|
-
require 'Win32/Console/api.rb'
|
22
|
-
|
23
|
-
end # rescue
|
9
|
+
require 'Console_ext'
|
10
|
+
rescue LoadError
|
11
|
+
RUBY_VERSION =~ /(\d+.\d+)/
|
12
|
+
require "#{$1}/Console_ext"
|
13
|
+
end
|
24
14
|
|
25
15
|
module Win32
|
26
16
|
class Console
|
data/lib/Win32/Console/ANSI.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
#
|
2
4
|
# Win32::Console::ANSI
|
3
5
|
#
|
@@ -137,7 +139,7 @@ module Win32
|
|
137
139
|
def _PrintString(t)
|
138
140
|
s = t.dup.to_s
|
139
141
|
while s != ''
|
140
|
-
if s.sub!( /([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)
|
142
|
+
if s.sub!( /([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)/, '\5')
|
141
143
|
@Out.Write((_conv("#$1")))
|
142
144
|
if $2 == '['
|
143
145
|
case $4
|
@@ -318,20 +320,6 @@ module Win32
|
|
318
320
|
def _conv(s)
|
319
321
|
if @concealed
|
320
322
|
s.gsub!( /\S/,' ')
|
321
|
-
elsif @conv
|
322
|
-
if EncodeOk
|
323
|
-
from_to(s, cpANSI, cpOEM)
|
324
|
-
elsif @@cp == 'cp1252cp850' # WinLatin1 --> DOSLatin1
|
325
|
-
s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́ρЁсҁӁԁՁցׁفځہ܁݁ށ߁��������������������������������������������","???�??????????????????????????��������ρ��݁�����������������������������������������������ǎ����Ԑ�ҁӁށցׁс������噞����ꚁ��ᅁ���Ƅ�������������Ё������䔁����������")
|
326
|
-
elsif @@cp == 'cp1252cp437' # WinLatin1 --> DOSLatinUS
|
327
|
-
s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́ρЁсҁӁԁՁցׁفځہ܁݁ށ߁��������������������������������������������", "??????????????????????????????������?�????������???�����??��?��??��������?��????����?�???????��????�?????�??�ᅁ��?�������������?������?���?�����??�")
|
328
|
-
elsif @@cp == 'cp1250cp852' # WinLatin2 --> DOSLatin2
|
329
|
-
s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́ρЁсҁӁԁՁցׁفځہ܁݁ށ߁��������������������������������������������",
|
330
|
-
"??????????��?��??????????��?������������ρ�?����?��������?����?���???�����������聵���Ǝ���������Ӂ��ցׁҁс�Ձ��⊙����ށ�뚁�݁�ꁠ��DŽ������������ԁЁ�偢�����������������" )
|
331
|
-
elsif @@cp == 'cp1251cp855' # WinCyrillic --> DOSCyrillic
|
332
|
-
s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́ρЁсҁӁԁՁցׁفځہ܁݁ށ߁��������������������������������������������",
|
333
|
-
"��?�??????�?����?????????�?����������??���?���?��?�??��????������������쁭��������ǁсӁՁׁ݁���聫�����������������������끬��������ƁЁҁԁց���灪������������������")
|
334
|
-
end
|
335
323
|
end
|
336
324
|
return s
|
337
325
|
end
|
data/tasks/gem.rake
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
|
3
|
+
HOE = Hoe.spec 'win32console' do
|
4
|
+
self.version = '1.3.0.beta1'
|
5
|
+
|
6
|
+
developer 'Gonzalo Garramuno', 'ggarra@advancedsl.com.ar'
|
7
|
+
developer 'Justin Bailey', 'jgbailey@gmail.com'
|
8
|
+
developer 'Luis Lavena', 'luislavena@gmail.com'
|
9
|
+
|
10
|
+
self.rubyforge_name = 'winconsole'
|
11
|
+
|
12
|
+
spec_extras[:required_ruby_version] = Gem::Requirement.new('>= 1.8.6')
|
13
|
+
|
14
|
+
spec_extras[:extensions] = ["ext/Console_ext/extconf.rb"]
|
15
|
+
|
16
|
+
extra_rdoc_files.push *FileList['extra/*.rdoc']
|
17
|
+
|
18
|
+
spec_extras[:rdoc_options] = proc do |rdoc_options|
|
19
|
+
rdoc_options << "--exclude" << "ext"
|
20
|
+
end
|
21
|
+
|
22
|
+
extra_dev_deps << ['rake-compiler', "~> 0.7.0"]
|
23
|
+
end
|
24
|
+
|
25
|
+
file "#{HOE.spec.name}.gemspec" => ['Rakefile', 'tasks/gem.rake'] do |t|
|
26
|
+
puts "Generating #{t.name}"
|
27
|
+
File.open(t.name, 'w') { |f| f.puts HOE.spec.to_yaml }
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Generate or update the standalone gemspec file for the project"
|
31
|
+
task :gemspec => ["#{HOE.spec.name}.gemspec"]
|
data/tasks/native.rake
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# use rake-compiler for building the extension
|
2
|
+
require 'rake/extensiontask'
|
3
|
+
|
4
|
+
Rake::ExtensionTask.new('Console_ext', HOE.spec) do |ext|
|
5
|
+
# FIXME: enable cross compilation to build fat binaries
|
6
|
+
ext.cross_compile = true
|
7
|
+
ext.cross_platform = ['i386-mingw32', 'i386-mswin32-60']
|
8
|
+
|
9
|
+
# place extension binaries inside lib/X.Y
|
10
|
+
if RUBY_PLATFORM =~ /mingw|mswin/
|
11
|
+
RUBY_VERSION =~ /(\d+.\d+)/
|
12
|
+
ext.lib_dir = "lib/#{$1}"
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,40 +1,82 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0.beta1
|
5
5
|
platform: x86-mswin32-60
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Gonzalo Garramuno
|
8
|
+
- Justin Bailey
|
9
|
+
- Luis Lavena
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
13
|
|
12
|
-
date:
|
14
|
+
date: 2009-12-29 00:00:00 -03:00
|
13
15
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: rake-compiler
|
19
|
+
type: :development
|
20
|
+
version_requirement:
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 0.7.0
|
26
|
+
version:
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hoe
|
29
|
+
type: :development
|
30
|
+
version_requirement:
|
31
|
+
version_requirements: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 2.4.0
|
36
|
+
version:
|
37
|
+
description: |-
|
38
|
+
Win32::Console allows controling the windows command line terminal
|
39
|
+
thru an OO-interface. This allows you to query the terminal (find
|
40
|
+
its size, characters, attributes, etc). The interface and functionality
|
41
|
+
should be identical to Perl's counterpart.
|
42
|
+
|
43
|
+
A port of Perl's Win32::Console and Win32::Console::ANSI modules.
|
44
|
+
|
45
|
+
This gem packages Gonzalo Garramuno's Win32::Console project, and includes
|
46
|
+
a compiled binary for speed. The Win32::Console project's home can be
|
47
|
+
found at:
|
48
|
+
|
49
|
+
http://rubyforge.org/projects/win32console
|
50
|
+
email:
|
51
|
+
- ggarra@advancedsl.com.ar
|
52
|
+
- jgbailey@gmail.com
|
53
|
+
- luislavena@gmail.com
|
18
54
|
executables: []
|
19
55
|
|
20
56
|
extensions: []
|
21
57
|
|
22
58
|
extra_rdoc_files:
|
59
|
+
- History.txt
|
60
|
+
- Manifest.txt
|
23
61
|
- README.txt
|
24
|
-
-
|
25
|
-
-
|
26
|
-
- HISTORY.txt
|
27
|
-
- HISTORY_GEM.txt
|
62
|
+
- extra/Console.rdoc
|
63
|
+
- extra/Console_ANSI.rdoc
|
28
64
|
files:
|
29
|
-
-
|
30
|
-
-
|
31
|
-
-
|
32
|
-
-
|
65
|
+
- History.txt
|
66
|
+
- Manifest.txt
|
67
|
+
- Rakefile
|
68
|
+
- README.txt
|
69
|
+
- ext/Console_ext/Console.c
|
70
|
+
- ext/Console_ext/extconf.rb
|
71
|
+
- extra/Console.rdoc
|
72
|
+
- extra/Console_ANSI.rdoc
|
73
|
+
- lib/win32console.rb
|
74
|
+
- lib/Win32/Console.rb
|
33
75
|
- lib/Win32/Console/ANSI.rb
|
34
76
|
- lib/Win32/Console/api.rb
|
35
77
|
- lib/Win32/Console/constants.rb
|
36
|
-
-
|
37
|
-
-
|
78
|
+
- tasks/gem.rake
|
79
|
+
- tasks/native.rake
|
38
80
|
- test/test_cursor.rb
|
39
81
|
- test/test_mouse.rb
|
40
82
|
- test/test_readinput.rb
|
@@ -42,42 +84,45 @@ files:
|
|
42
84
|
- test/test_sendevent.rb
|
43
85
|
- test/test_title.rb
|
44
86
|
- test/test_write.rb
|
45
|
-
-
|
46
|
-
-
|
47
|
-
- README_GEM.txt
|
48
|
-
- INSTALL.txt
|
49
|
-
- HISTORY.txt
|
50
|
-
- HISTORY_GEM.txt
|
51
|
-
- lib/Console.so
|
87
|
+
- lib/1.8/Console_ext.so
|
88
|
+
- lib/1.9/Console_ext.so
|
52
89
|
has_rdoc: true
|
53
90
|
homepage: http://rubyforge.org/projects/winconsole
|
91
|
+
licenses: []
|
92
|
+
|
54
93
|
post_install_message:
|
55
94
|
rdoc_options:
|
56
|
-
- --title
|
57
|
-
- Win32Console Gem -- Gem for Win32::Console Project
|
58
95
|
- --main
|
59
|
-
-
|
60
|
-
- --
|
96
|
+
- README.txt
|
97
|
+
- --exclude
|
98
|
+
- ext
|
61
99
|
require_paths:
|
62
100
|
- lib
|
101
|
+
- ext
|
63
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
103
|
requirements:
|
65
104
|
- - ">="
|
66
105
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
106
|
+
version: 1.8.6
|
68
107
|
version:
|
69
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
109
|
requirements:
|
71
|
-
- - "
|
110
|
+
- - ">"
|
72
111
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
112
|
+
version: 1.3.1
|
74
113
|
version:
|
75
114
|
requirements: []
|
76
115
|
|
77
|
-
rubyforge_project:
|
78
|
-
rubygems_version: 1.3.
|
116
|
+
rubyforge_project: winconsole
|
117
|
+
rubygems_version: 1.3.5
|
79
118
|
signing_key:
|
80
|
-
specification_version:
|
81
|
-
summary:
|
82
|
-
test_files:
|
83
|
-
|
119
|
+
specification_version: 3
|
120
|
+
summary: Win32::Console allows controling the windows command line terminal thru an OO-interface
|
121
|
+
test_files:
|
122
|
+
- test/test_mouse.rb
|
123
|
+
- test/test_readoutput.rb
|
124
|
+
- test/test_write.rb
|
125
|
+
- test/test_readinput.rb
|
126
|
+
- test/test_sendevent.rb
|
127
|
+
- test/test_title.rb
|
128
|
+
- test/test_cursor.rb
|
data/HISTORY.txt
DELETED
@@ -1,7 +0,0 @@
|
|
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
DELETED
@@ -1,38 +0,0 @@
|
|
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
DELETED
@@ -1,18 +0,0 @@
|
|
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_GEM.txt
DELETED
@@ -1,64 +0,0 @@
|
|
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/lib/Console.so
DELETED
Binary file
|