win32console 1.0.8-i386-mswin32 → 1.1.0-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/Console.cpp +15 -0
  2. data/HISTORY_GEM.txt +34 -0
  3. data/README.txt +0 -1
  4. data/{lib/README_GEM.txt → README_GEM.txt} +1 -1
  5. data/Rakefile +5 -5
  6. data/lib/Console.so +0 -0
  7. data/lib/Win32/Console/ANSI.rb +283 -240
  8. data/lib/Win32/Console/api.rb +342 -0
  9. data/lib/Win32/Console/constants.rb +66 -0
  10. data/lib/Win32/Console.rb +77 -675
  11. metadata +10 -114
  12. data/doc/classes/Win32/Console/ANSI/IO.html +0 -220
  13. data/doc/classes/Win32/Console/ANSI/IO.src/M000035.html +0 -32
  14. data/doc/classes/Win32/Console/ANSI/IO.src/M000036.html +0 -205
  15. data/doc/classes/Win32/Console/ANSI/IO.src/M000037.html +0 -40
  16. data/doc/classes/Win32/Console/ANSI/IO.src/M000038.html +0 -25
  17. data/doc/classes/Win32/Console/ANSI.html +0 -103
  18. data/doc/classes/Win32/Console/API.html +0 -758
  19. data/doc/classes/Win32/Console/API.src/M000039.html +0 -27
  20. data/doc/classes/Win32/Console/API.src/M000040.html +0 -27
  21. data/doc/classes/Win32/Console/API.src/M000041.html +0 -27
  22. data/doc/classes/Win32/Console/API.src/M000042.html +0 -32
  23. data/doc/classes/Win32/Console/API.src/M000043.html +0 -32
  24. data/doc/classes/Win32/Console/API.src/M000044.html +0 -28
  25. data/doc/classes/Win32/Console/API.src/M000045.html +0 -26
  26. data/doc/classes/Win32/Console/API.src/M000046.html +0 -26
  27. data/doc/classes/Win32/Console/API.src/M000047.html +0 -27
  28. data/doc/classes/Win32/Console/API.src/M000048.html +0 -30
  29. data/doc/classes/Win32/Console/API.src/M000049.html +0 -29
  30. data/doc/classes/Win32/Console/API.src/M000050.html +0 -27
  31. data/doc/classes/Win32/Console/API.src/M000051.html +0 -28
  32. data/doc/classes/Win32/Console/API.src/M000052.html +0 -30
  33. data/doc/classes/Win32/Console/API.src/M000053.html +0 -27
  34. data/doc/classes/Win32/Console/API.src/M000054.html +0 -29
  35. data/doc/classes/Win32/Console/API.src/M000055.html +0 -29
  36. data/doc/classes/Win32/Console/API.src/M000056.html +0 -28
  37. data/doc/classes/Win32/Console/API.src/M000057.html +0 -27
  38. data/doc/classes/Win32/Console/API.src/M000058.html +0 -47
  39. data/doc/classes/Win32/Console/API.src/M000059.html +0 -32
  40. data/doc/classes/Win32/Console/API.src/M000060.html +0 -47
  41. data/doc/classes/Win32/Console/API.src/M000061.html +0 -34
  42. data/doc/classes/Win32/Console/API.src/M000062.html +0 -32
  43. data/doc/classes/Win32/Console/API.src/M000063.html +0 -32
  44. data/doc/classes/Win32/Console/API.src/M000064.html +0 -35
  45. data/doc/classes/Win32/Console/API.src/M000065.html +0 -26
  46. data/doc/classes/Win32/Console/API.src/M000066.html +0 -27
  47. data/doc/classes/Win32/Console/API.src/M000067.html +0 -29
  48. data/doc/classes/Win32/Console/API.src/M000068.html +0 -27
  49. data/doc/classes/Win32/Console/API.src/M000069.html +0 -27
  50. data/doc/classes/Win32/Console/API.src/M000070.html +0 -28
  51. data/doc/classes/Win32/Console/API.src/M000071.html +0 -27
  52. data/doc/classes/Win32/Console/API.src/M000072.html +0 -26
  53. data/doc/classes/Win32/Console/API.src/M000073.html +0 -27
  54. data/doc/classes/Win32/Console/API.src/M000074.html +0 -31
  55. data/doc/classes/Win32/Console/API.src/M000075.html +0 -27
  56. data/doc/classes/Win32/Console/API.src/M000076.html +0 -32
  57. data/doc/classes/Win32/Console/API.src/M000077.html +0 -27
  58. data/doc/classes/Win32/Console/API.src/M000078.html +0 -32
  59. data/doc/classes/Win32/Console/API.src/M000079.html +0 -32
  60. data/doc/classes/Win32/Console/API.src/M000080.html +0 -32
  61. data/doc/classes/Win32/Console/Constants.html +0 -360
  62. data/doc/classes/Win32/Console.html +0 -650
  63. data/doc/classes/Win32/Console.src/M000001.html +0 -31
  64. data/doc/classes/Win32/Console.src/M000002.html +0 -23
  65. data/doc/classes/Win32/Console.src/M000003.html +0 -23
  66. data/doc/classes/Win32/Console.src/M000004.html +0 -27
  67. data/doc/classes/Win32/Console.src/M000005.html +0 -23
  68. data/doc/classes/Win32/Console.src/M000006.html +0 -28
  69. data/doc/classes/Win32/Console.src/M000007.html +0 -23
  70. data/doc/classes/Win32/Console.src/M000008.html +0 -24
  71. data/doc/classes/Win32/Console.src/M000009.html +0 -44
  72. data/doc/classes/Win32/Console.src/M000010.html +0 -23
  73. data/doc/classes/Win32/Console.src/M000011.html +0 -33
  74. data/doc/classes/Win32/Console.src/M000012.html +0 -26
  75. data/doc/classes/Win32/Console.src/M000013.html +0 -27
  76. data/doc/classes/Win32/Console.src/M000014.html +0 -28
  77. data/doc/classes/Win32/Console.src/M000015.html +0 -23
  78. data/doc/classes/Win32/Console.src/M000016.html +0 -23
  79. data/doc/classes/Win32/Console.src/M000017.html +0 -23
  80. data/doc/classes/Win32/Console.src/M000018.html +0 -29
  81. data/doc/classes/Win32/Console.src/M000019.html +0 -23
  82. data/doc/classes/Win32/Console.src/M000020.html +0 -23
  83. data/doc/classes/Win32/Console.src/M000021.html +0 -28
  84. data/doc/classes/Win32/Console.src/M000022.html +0 -23
  85. data/doc/classes/Win32/Console.src/M000023.html +0 -28
  86. data/doc/classes/Win32/Console.src/M000024.html +0 -35
  87. data/doc/classes/Win32/Console.src/M000025.html +0 -28
  88. data/doc/classes/Win32/Console.src/M000026.html +0 -28
  89. data/doc/classes/Win32/Console.src/M000027.html +0 -28
  90. data/doc/classes/Win32/Console.src/M000028.html +0 -31
  91. data/doc/classes/Win32/Console.src/M000029.html +0 -23
  92. data/doc/classes/Win32/Console.src/M000030.html +0 -23
  93. data/doc/classes/Win32/Console.src/M000031.html +0 -23
  94. data/doc/classes/Win32/Console.src/M000032.html +0 -27
  95. data/doc/classes/Win32/Console.src/M000033.html +0 -27
  96. data/doc/classes/Win32/Console.src/M000034.html +0 -25
  97. data/doc/classes/Win32.html +0 -115
  98. data/doc/created.rid +0 -1
  99. data/doc/files/Console_ANSI_rdoc.html +0 -407
  100. data/doc/files/Console_cpp.html +0 -104
  101. data/doc/files/Console_rdoc.html +0 -964
  102. data/doc/files/lib/Win32/Console/ANSI_rb.html +0 -123
  103. data/doc/files/lib/Win32/Console_rb.html +0 -297
  104. data/doc/fr_class_index.html +0 -32
  105. data/doc/fr_file_index.html +0 -31
  106. data/doc/fr_method_index.html +0 -106
  107. data/doc/index.html +0 -24
  108. data/doc/rdoc-style.css +0 -172
@@ -10,40 +10,54 @@
10
10
  #
11
11
  require "win32/Console"
12
12
 
13
+
14
+ module Kernel
15
+
16
+ # Kernel#putc is equivalent to $stdout.putc, but
17
+ # it doesn't use $stdout.putc. We redefine it to do that
18
+ # so that it will buffer the escape sequences properly.
19
+ # See Win32::Console::ANSI::IO#putc
20
+ remove_method :putc
21
+ def putc(int)
22
+ $stdout.putc(int)
23
+ end
24
+
25
+ end
26
+
13
27
  module Win32
14
28
  class Console
15
29
  module ANSI
16
30
 
17
31
  class IO < IO
18
32
 
19
- VERSION = '0.05'
20
- DEBUG = nil
33
+ VERSION = '0.05'
34
+ DEBUG = nil
21
35
 
22
- require "win32/registry"
36
+ require "win32/registry"
23
37
 
24
- include Win32::Console::Constants
38
+ include Win32::Console::Constants
25
39
 
26
- # @todo: encode is another perl module
27
- EncodeOk = false
40
+ # @todo: encode is another perl module
41
+ EncodeOk = false
28
42
 
29
- # Retrieving the codepages
30
- cpANSI = nil
31
- Win32::Registry::HKEY_LOCAL_MACHINE.open('SYSTEM\CurrentControlSet\Control\Nls\CodePage' ) { |reg|
32
- cpANSI = reg['ACP']
33
- }
43
+ # Retrieving the codepages
44
+ cpANSI = nil
45
+ Win32::Registry::HKEY_LOCAL_MACHINE.open('SYSTEM\CurrentControlSet\Control\Nls\CodePage' ) { |reg|
46
+ cpANSI = reg['ACP']
47
+ }
34
48
 
35
- STDERR.puts "Unable to read Win codepage #{cpANSI}" if DEBUG && !cpANSI
49
+ STDERR.puts "Unable to read Win codepage #{cpANSI}" if DEBUG && !cpANSI
36
50
 
37
51
 
38
- cpANSI = 'cp'+(cpANSI ? cpANSI : '1252') # Windows codepage
39
- OEM = Win32::Console::OutputCP()
40
- cpOEM = 'cp' + OEM.to_s # DOS codepage
41
- @@cp = cpANSI + cpOEM
52
+ cpANSI = 'cp'+(cpANSI ? cpANSI : '1252') # Windows codepage
53
+ OEM = Win32::Console::OutputCP()
54
+ cpOEM = 'cp' + OEM.to_s # DOS codepage
55
+ @@cp = cpANSI + cpOEM
42
56
 
43
- STDERR.puts "EncodeOk=#{EncodeOk} cpANSI=#{cpANSI} "+
44
- "cpOEM=#{cpOEM}" if DEBUG
57
+ STDERR.puts "EncodeOk=#{EncodeOk} cpANSI=#{cpANSI} "+
58
+ "cpOEM=#{cpOEM}" if DEBUG
45
59
 
46
- @@color = { 30 => 0, # black foreground
60
+ @@color = { 30 => 0, # black foreground
47
61
  31 => FOREGROUND_RED, # red foreground
48
62
  32 => FOREGROUND_GREEN, # green foreground
49
63
  33 => FOREGROUND_RED|FOREGROUND_GREEN, # yellow foreground
@@ -59,238 +73,268 @@ module Win32
59
73
  45 => BACKGROUND_BLUE|BACKGROUND_RED, # magenta background
60
74
  46 => BACKGROUND_BLUE|BACKGROUND_GREEN, # cyan background
61
75
  47 => BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE, # white background
62
- }
76
+ }
63
77
 
64
- def initialize
65
- super(1,'w')
66
- @Out = Win32::Console.new(STD_OUTPUT_HANDLE)
67
- @x = @y = 0 # to save cursor position
68
- @foreground = 7
69
- @background = 0
70
- @bold =
71
- @underline =
72
- @revideo =
73
- @concealed = nil
74
- @conv = 1 # char conversion by default
75
- end
78
+ def initialize
79
+ super(1,'w')
80
+ @Out = Win32::Console.new(STD_OUTPUT_HANDLE)
81
+ @x = @y = 0 # to save cursor position
82
+ @foreground = 7
83
+ @background = 0
84
+ @bold =
85
+ @underline =
86
+ @revideo =
87
+ @concealed = nil
88
+ @conv = 1 # char conversion by default
89
+ @buffer = []
90
+ STDERR.puts "Console Mode=#{@Out.Mode}" if DEBUG
91
+ end
76
92
 
93
+ # this redefined #putc buffers escape sequences but passes
94
+ # other values to #write as normal.
95
+ def putc(int)
96
+ if @buffer.empty?
97
+ unless int == ?\e
98
+ write(int.chr)
99
+ else
100
+ @buffer << int
101
+ end
102
+ else
103
+ @buffer << int
104
+ case int
105
+ when ?m, ?J, ?L, ?M, ?@, ?P, ?A, ?B, ?C, ?D,
106
+ ?E, ?F, ?G, ?H, ?f, ?s, ?u, ?U, ?K, ?X
107
+ write(@buffer.pack("c*"))
108
+ @buffer.clear
109
+ end
110
+ end
111
+ end
77
112
 
78
- def write(*s)
79
- s.each { |x|
80
- _PrintString(x)
81
- }
82
- end
113
+ # #write checks if $stdout is going to the console
114
+ # or if it's being redirected.
115
+ # When to the console, it passes the string to
116
+ # _PrintString to be parsed for escape codes.
117
+ #
118
+ # When redirected, it passes to WriteFile to allow escape
119
+ # codes and all to be output. The application that is
120
+ # handling the redirected IO should handle coloring.
121
+ # For Ruby applications, this means requiring Win32Conole again.
122
+ def write(*s)
123
+ if redirected?
124
+ s.each{ |x| @Out.WriteFile(x.dup.to_s) }
125
+ else
126
+ s.each{ |x| _PrintString(x) }
127
+ end
128
+ end
83
129
 
130
+ # returns true if outputs is being redirected.
131
+ def redirected?
132
+ @Out.Mode > 31
133
+ end
84
134
 
85
- private
135
+ private
86
136
 
87
- def _PrintString(t)
88
- s = t.dup
89
- while s != ''
90
- if s.sub!( /([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)/s,'\5')
91
- @Out.Write((_conv("#$1")))
92
- if $2 == '['
93
- case $4
94
- when 'm' # ESC[#;#;....;#m Set display attributes
95
- attributs = $3.split(';')
96
- attributs.push(nil) unless attributs # ESC[m == ESC[;m ==...==ESC[0m
97
- for attr in attributs
98
- atv = attr.to_i
99
- if atv > 0
100
- if atv == 1
101
- @bold = 1
102
- elsif atv == 21
103
- @bold = nil
104
- elsif atv == 4
105
- @underline = 1
106
- elsif atv == 24
107
- @underline = nil
108
- elsif atv == 7
109
- @revideo = 1
110
- elsif atv == 27
111
- @revideo = nil
112
- elsif atv == 8
113
- @concealed = 1
114
- elsif atv == 28
115
- @concealed = nil
116
- elsif atv >= 30 and atv <= 37
117
- @foreground = atv - 30
118
- elsif atv >=40 and atv <=47
119
- @background = atv - 40
120
- end
121
- else # ESC[0m reset
122
- @foreground = 7
123
- @background = 0
124
- @bold =
125
- @underline =
126
- @revideo =
127
- @concealed = nil
128
- end
129
- end
137
+ def _PrintString(t)
138
+ s = t.dup.to_s
139
+ while s != ''
140
+ if s.sub!( /([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)/s,'\5')
141
+ @Out.Write((_conv("#$1")))
142
+ if $2 == '['
143
+ case $4
144
+ when 'm' # ESC[#;#;....;#m Set display attributes
145
+ attributs = $3.split(';')
146
+ attributs.push(nil) unless attributs # ESC[m == ESC[;m ==...==ESC[0m
147
+ attributs.each do |attr|
148
+ atv = attr.to_i
149
+ case atv
150
+ when 0 # ESC[0m reset
151
+ @foreground = 7
152
+ @background = 0
153
+ @bold =
154
+ @underline =
155
+ @revideo =
156
+ @concealed = nil
157
+ when 1
158
+ @bold = 1
159
+ when 21
160
+ @bold = nil
161
+ when 4
162
+ @underline = 1
163
+ when 24
164
+ @underline = nil
165
+ when 7
166
+ @revideo = 1
167
+ when 27
168
+ @revideo = nil
169
+ when 8
170
+ @concealed = 1
171
+ when 28
172
+ @concealed = nil
173
+ when 30..37
174
+ @foreground = atv - 30
175
+ when 40..47
176
+ @background = atv - 40
177
+ end
178
+ end
130
179
 
131
- if @revideo
132
- attribut = @@color[40+@foreground] |
133
- @@color[30+@background]
134
- else
135
- attribut = @@color[30+@foreground] |
136
- @@color[40+@background]
137
- end
138
- attribut |= FOREGROUND_INTENSITY if @bold
139
- attribut |= BACKGROUND_INTENSITY if @underline
140
- @Out.Attr(attribut)
141
- when 'J'
142
- if !$3 or $3 == '' # ESC[0J from cursor to end of display
143
- info = @Out.Info()
144
- s = ' ' * ((info[1]-info[3]-1)*info[0]+info[0]-info[2]-1)
145
- @Out.WriteChar(s, info[2], info[3])
146
- @Out.Cursor(info[2], info[3])
147
- elsif $3 == '1' # ESC[1J erase from start to cursor.
148
- info = @Out.Info()
149
- s = ' ' * (info[3]*info[0]+info[2]+1)
150
- @Out.WriteChar(s, 0, 0)
151
- @Out.Cursor(info[2], info[3])
152
- elsif $3 == '2' # ESC[2J Clear screen and home cursor
153
- @Out.Cls()
154
- @Out.Cursor(0, 0)
155
- else
156
- STDERR.print "\e#$2#$3#$4" if DEBUG # if ESC-code not implemented
157
- end
158
- when 'K'
159
- info = @Out.Info()
160
- if !$3 or $3 == '' # ESC[0K Clear to end of line
161
- s = ' ' * (info[7]-info[2]+1)
162
- @Out.Write(s)
163
- @Out.Cursor(info[2], info[3])
164
- elsif $3=='1' # ESC[1K Clear from start of line to cursor
165
- s = ' '*(info[2]+1)
166
- @Out.WriteChar(s, 0, info[3])
167
- @Out.Cursor(info[2], info[3])
168
- elsif $3=='2' # ESC[2K Clear whole line.
169
- s = ' '* info[0]
170
- @Out.WriteChar(s, 0, info[3])
171
- @Out.Cursor(info[2], info[3])
172
- end
173
- when 'L' # ESC[#L Insert # blank lines.
174
- n = $3 == ''? 1 : $3.to_i # ESC[L == ESC[1L
175
- info = @Out.Info()
176
- @Out.Scroll(0, info[3], info[0]-1, info[1]-1,
177
- 0, info[3] + n.to_i,
180
+ if @revideo
181
+ attribut = @@color[40+@foreground] |
182
+ @@color[30+@background]
183
+ else
184
+ attribut = @@color[30+@foreground] |
185
+ @@color[40+@background]
186
+ end
187
+ attribut |= FOREGROUND_INTENSITY if @bold
188
+ attribut |= BACKGROUND_INTENSITY if @underline
189
+ @Out.Attr(attribut)
190
+ when 'J'
191
+ if !$3 or $3 == '' # ESC[0J from cursor to end of display
192
+ info = @Out.Info()
193
+ s = ' ' * ((info[1]-info[3]-1)*info[0]+info[0]-info[2]-1)
194
+ @Out.WriteChar(s, info[2], info[3])
195
+ @Out.Cursor(info[2], info[3])
196
+ elsif $3 == '1' # ESC[1J erase from start to cursor.
197
+ info = @Out.Info()
198
+ s = ' ' * (info[3]*info[0]+info[2]+1)
199
+ @Out.WriteChar(s, 0, 0)
200
+ @Out.Cursor(info[2], info[3])
201
+ elsif $3 == '2' # ESC[2J Clear screen and home cursor
202
+ @Out.Cls()
203
+ @Out.Cursor(0, 0)
204
+ else
205
+ STDERR.print "\e#$2#$3#$4" if DEBUG # if ESC-code not implemented
206
+ end
207
+ when 'K'
208
+ info = @Out.Info()
209
+ if !$3 or $3 == '' # ESC[0K Clear to end of line
210
+ s = ' ' * (info[7]-info[2]+1)
211
+ @Out.Write(s)
212
+ @Out.Cursor(info[2], info[3])
213
+ elsif $3=='1' # ESC[1K Clear from start of line to cursor
214
+ s = ' '*(info[2]+1)
215
+ @Out.WriteChar(s, 0, info[3])
216
+ @Out.Cursor(info[2], info[3])
217
+ elsif $3=='2' # ESC[2K Clear whole line.
218
+ s = ' '* info[0]
219
+ @Out.WriteChar(s, 0, info[3])
220
+ @Out.Cursor(info[2], info[3])
221
+ end
222
+ when 'L' # ESC[#L Insert # blank lines.
223
+ n = $3 == ''? 1 : $3.to_i # ESC[L == ESC[1L
224
+ info = @Out.Info()
225
+ @Out.Scroll(0, info[3], info[0]-1, info[1]-1,
226
+ 0, info[3] + n.to_i,
178
227
  ' '[0], @Out.Attr(),
179
228
  0, 0, 10000, 10000)
180
- @Out.Cursor(info[2], info[3])
181
- when 'M' # ESC[#M Delete # line.
182
- n = $3 == ''? 1 : $3.to_i # ESC[M == ESC[1M
183
- info = @Out.Info();
184
- @Out.Scroll(0, info[3]+n, info[0]-1, info[1]-1,
185
- 0, info[3],
186
- ' '[0], @Out.Attr(),
187
- 0, 0, 10000, 10000)
188
- @Out.Cursor(info[2], info[3])
189
- when 'P' # ESC[#P Delete # characters.
190
- n = $3 == ''? 1 : $3.to_i # ESC[P == ESC[1P
191
- info = @Out.Info()
192
- n = info[0]-info[2] if info[2]+n > info[0]-1
193
- @Out.Scroll(info[2]+n, info[3] , info[0]-1, info[3],
194
- info[2], info[3],
195
- ' '[0], @Out.Attr(),
196
- 0, 0, 10000, 10000)
197
- s = ' ' * n
198
- @Out.Cursor(info[0]-n, info[3])
199
- @Out.Write(s)
200
- @Out.Cursor(info[2], info[3])
201
- when '@' # ESC[#@ Insert # blank Characters
202
- s = ' ' * $3.to_i
203
- info = @Out.Info()
204
- s << @Out.ReadChar(info[7]-info[2]+1, info[2], info[3])
205
- s = s[0..-($3.to_i)]
206
- @Out.Write(s);
207
- @Out.Cursor(info[2], info[3])
208
- when 'A' # ESC[#A Moves cursor up # lines
209
- (x, y) = @Out.Cursor()
210
- n = $3 == ''? 1 : $3.to_i; # ESC[A == ESC[1A
211
- @Out.Cursor(x, y-n)
212
- when 'B' # ESC[#B Moves cursor down # lines
213
- (x, y) = @Out.Cursor()
214
- n = $3 == ''? 1 : $3.to_i; # ESC[B == ESC[1B
215
- @Out.Cursor(x, y+n)
216
- when 'C' # ESC[#C Moves cursor forward # spaces
217
- (x, y) = @Out.Cursor()
218
- n = $3 == ''? 1 : $3.to_i; # ESC[C == ESC[1C
219
- @Out.Cursor(x+n, y)
220
- when 'D' # ESC[#D Moves cursor back # spaces
221
- (x, y) = @Out.Cursor()
222
- n = $3 == ''? 1 : $3.to_i; # ESC[D == ESC[1D
223
- @Out.Cursor(x-n, y)
224
- when 'E' # ESC[#E Moves cursor down # lines, column 1.
225
- x, y = @Out.Cursor()
226
- n = $3 == ''? 1 : $3.to_i; # ESC[E == ESC[1E
227
- @Out.Cursor(0, y+n)
228
- when 'F' # ESC[#F Moves cursor up # lines, column 1.
229
- x, y = @Out.Cursor()
230
- n = $3 == ''? 1 : $3.to_i; # ESC[F == ESC[1F
231
- @Out.Cursor(0, y-n)
232
- when 'G' # ESC[#G Moves cursor column # in current row.
233
- x, y = @Out.Cursor()
234
- n = $3 == ''? 1 : $3.to_i; # ESC[G == ESC[1G
235
- @Out.Cursor(n-1, y)
236
- when 'f' # ESC[#;#f Moves cursor to line #, column #
237
- y, x = $3.split(';')
238
- x = 1 unless x # ESC[;5H == ESC[1;5H ...etc
239
- y = 1 unless y
240
- @Out.Cursor(x.to_i-1, y.to_i-1) # origin (0,0) in DOS console
241
- when 'H' # ESC[#;#H Moves cursor to line #, column #
242
- y, x = $3.split(';')
243
- x = 1 unless x # ESC[;5H == ESC[1;5H ...etc
244
- y = 1 unless y
245
- @Out.Cursor(x.to_i-1, y.to_i-1) # origin (0,0) in DOS console
246
- when 's' # ESC[s Saves cursor position for recall later
247
- (@x, @y) = @Out.Cursor()
248
- when 'u' # ESC[u Return to saved cursor position
249
- @Out.Cursor(@x, @y)
250
- else
251
- STDERR.puts "\e#$2#$3#$4 not implemented" if DEBUG # ESC-code not implemented
252
- end
253
- else
254
- case $4
255
- when 'U' # ESC(U no mapping
256
- @conv = nil
257
- when 'K' # ESC(K mapping if it exist
258
- @Out.OutputCP(OEM) # restore original codepage
259
- @conv = 1
260
- when 'X' # ESC(#X codepage **EXPERIMENTAL**
261
- @conv = nil
262
- @Out.OutputCP($3)
263
- else
264
- STDERR.puts "\e#$2#$3#$4 not implemented" if DEBUG # ESC-code not implemented
265
- end
266
- end
267
- else
268
- @Out.Write(_conv(s))
269
- s=''
270
- end
271
- end
272
- end
229
+ @Out.Cursor(info[2], info[3])
230
+ when 'M' # ESC[#M Delete # line.
231
+ n = $3 == ''? 1 : $3.to_i # ESC[M == ESC[1M
232
+ info = @Out.Info();
233
+ @Out.Scroll(0, info[3]+n, info[0]-1, info[1]-1,
234
+ 0, info[3],
235
+ ' '[0], @Out.Attr(),
236
+ 0, 0, 10000, 10000)
237
+ @Out.Cursor(info[2], info[3])
238
+ when 'P' # ESC[#P Delete # characters.
239
+ n = $3 == ''? 1 : $3.to_i # ESC[P == ESC[1P
240
+ info = @Out.Info()
241
+ n = info[0]-info[2] if info[2]+n > info[0]-1
242
+ @Out.Scroll(info[2]+n, info[3] , info[0]-1, info[3],
243
+ info[2], info[3],
244
+ ' '[0], @Out.Attr(),
245
+ 0, 0, 10000, 10000)
246
+ s = ' ' * n
247
+ @Out.Cursor(info[0]-n, info[3])
248
+ @Out.Write(s)
249
+ @Out.Cursor(info[2], info[3])
250
+ when '@' # ESC[#@ Insert # blank Characters
251
+ s = ' ' * $3.to_i
252
+ info = @Out.Info()
253
+ s << @Out.ReadChar(info[7]-info[2]+1, info[2], info[3])
254
+ s = s[0..-($3.to_i)]
255
+ @Out.Write(s);
256
+ @Out.Cursor(info[2], info[3])
257
+ when 'A' # ESC[#A Moves cursor up # lines
258
+ (x, y) = @Out.Cursor()
259
+ n = $3 == ''? 1 : $3.to_i; # ESC[A == ESC[1A
260
+ @Out.Cursor(x, y-n)
261
+ when 'B' # ESC[#B Moves cursor down # lines
262
+ (x, y) = @Out.Cursor()
263
+ n = $3 == ''? 1 : $3.to_i; # ESC[B == ESC[1B
264
+ @Out.Cursor(x, y+n)
265
+ when 'C' # ESC[#C Moves cursor forward # spaces
266
+ (x, y) = @Out.Cursor()
267
+ n = $3 == ''? 1 : $3.to_i; # ESC[C == ESC[1C
268
+ @Out.Cursor(x+n, y)
269
+ when 'D' # ESC[#D Moves cursor back # spaces
270
+ (x, y) = @Out.Cursor()
271
+ n = $3 == ''? 1 : $3.to_i; # ESC[D == ESC[1D
272
+ @Out.Cursor(x-n, y)
273
+ when 'E' # ESC[#E Moves cursor down # lines, column 1.
274
+ x, y = @Out.Cursor()
275
+ n = $3 == ''? 1 : $3.to_i; # ESC[E == ESC[1E
276
+ @Out.Cursor(0, y+n)
277
+ when 'F' # ESC[#F Moves cursor up # lines, column 1.
278
+ x, y = @Out.Cursor()
279
+ n = $3 == ''? 1 : $3.to_i; # ESC[F == ESC[1F
280
+ @Out.Cursor(0, y-n)
281
+ when 'G' # ESC[#G Moves cursor column # in current row.
282
+ x, y = @Out.Cursor()
283
+ n = $3 == ''? 1 : $3.to_i; # ESC[G == ESC[1G
284
+ @Out.Cursor(n-1, y)
285
+ when 'f' # ESC[#;#f Moves cursor to line #, column #
286
+ y, x = $3.split(';')
287
+ x = 1 unless x # ESC[;5H == ESC[1;5H ...etc
288
+ y = 1 unless y
289
+ @Out.Cursor(x.to_i-1, y.to_i-1) # origin (0,0) in DOS console
290
+ when 'H' # ESC[#;#H Moves cursor to line #, column #
291
+ y, x = $3.split(';')
292
+ x = 1 unless x # ESC[;5H == ESC[1;5H ...etc
293
+ y = 1 unless y
294
+ @Out.Cursor(x.to_i-1, y.to_i-1) # origin (0,0) in DOS console
295
+ when 's' # ESC[s Saves cursor position for recall later
296
+ (@x, @y) = @Out.Cursor()
297
+ when 'u' # ESC[u Return to saved cursor position
298
+ @Out.Cursor(@x, @y)
299
+ when 'U' # ESC(U no mapping
300
+ @conv = nil
301
+ when 'K' # ESC(K mapping if it exist
302
+ @Out.OutputCP(OEM) # restore original codepage
303
+ @conv = 1
304
+ when 'X' # ESC(#X codepage **EXPERIMENTAL**
305
+ @conv = nil
306
+ @Out.OutputCP($3)
307
+ else
308
+ STDERR.puts "\e#$2#$3#$4 not implemented" if DEBUG # ESC-code not implemented
309
+ end
310
+ end
311
+ else
312
+ @Out.Write(_conv(s))
313
+ s=''
314
+ end
315
+ end
316
+ end
273
317
 
274
- def _conv(s)
275
- if @concealed
276
- s.gsub!( /\S/,' ')
277
- elsif @conv
278
- if EncodeOk
279
- from_to(s, cpANSI, cpOEM)
280
- elsif @@cp == 'cp1252cp850' # WinLatin1 --> DOSLatin1
281
- s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������","???�??????????????????????????��������ρ��݁�����������������������������������������󁨁������ǎ����Ԑ�ҁӁށցׁ؁с������噞����ꚁ��ᅁ���Ƅ�������������Ё������䔁����������")
282
- elsif @@cp == 'cp1252cp437' # WinLatin1 --> DOSLatinUS
283
- s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������", "??????????????????????????????������?�????������???�����??��?��??��������?��????����?�???????��????�?????�??�ᅁ��?�������������?������?���?�����??�")
284
- elsif @@cp == 'cp1250cp852' # WinLatin2 --> DOSLatin2
285
- s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������",
318
+ def _conv(s)
319
+ if @concealed
320
+ 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!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������",
286
330
  "??????????��?��??????????��?������������ρ�?����?��������?����?���???����������񖁾�聵���Ǝ���������Ӂ��ցׁҁс�Ձ��⊙����ށ�뚁�݁�ꁠ��DŽ���������؁���ԁЁ�偢�����������������" )
287
- elsif @@cp == 'cp1251cp855' # WinCyrillic --> DOSCyrillic
288
- s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������",
331
+ elsif @@cp == 'cp1251cp855' # WinCyrillic --> DOSCyrillic
332
+ s.tr!("���������������������������������������������������������������������������������������������������ÁāŁƁǁȁɁʁˁ́́΁ρЁсҁӁԁՁցׁ؁فځہ܁݁ށ߁��������������������������������������������",
289
333
  "��?�??????�?����?????????�?����������??���?���?��?�??��????������������쁭������􁸁��ǁсӁՁׁ݁���聫�����������������������끬������󁷁��ƁЁҁԁց؁���灪������������������")
290
- end
291
- end
292
- return s
293
- end
334
+ end
335
+ end
336
+ return s
337
+ end
294
338
 
295
339
  end
296
340
 
@@ -300,6 +344,5 @@ module Win32
300
344
  end
301
345
  end
302
346
 
303
-
304
347
  $stdout = Win32::Console::ANSI::IO.new()
305
348