def _PrintString(s)
while s != ''
if s.sub!( /([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)/s,'\5')
@Out.Write((_conv("#$1")))
if $2 == '['
case $4
when 'm'
attributs = $3.split(';')
attributs.push(nil) unless attributs
for attr in attributs
atv = attr.to_i
if atv > 0
if atv == 1
@bold = 1
elsif atv == 21
@bold = nil
elsif atv == 4
@underline = 1
elsif atv == 24
@underline = nil
elsif atv == 7
@revideo = 1
elsif atv == 27
@revideo = nil
elsif atv == 8
@concealed = 1
elsif atv == 28
@concealed = nil
elsif atv >= 30 and atv <= 37
@foreground = atv - 30
elsif atv >=40 and atv <=47
@background = atv - 40
end
else
@foreground = 7
@background = 0
@bold =
@underline =
@revideo =
@concealed = nil
end
end
if @revideo
attribut = @@color[40+@foreground] |
@@color[30+@background]
else
attribut = @@color[30+@foreground] |
@@color[40+@background]
end
attribut |= FOREGROUND_INTENSITY if @bold
attribut |= BACKGROUND_INTENSITY if @underline
@Out.Attr(attribut)
when 'J'
if !$3 or $3 == ''
info = @Out.Info()
s = ' ' * ((info[1]-info[3]-1)*info[0]+info[0]-info[2]-1)
@Out.WriteChar(s, info[2], info[3])
@Out.Cursor(info[2], info[3])
elsif $3 == '1'
info = @Out.Info()
s = ' ' * (info[3]*info[0]+info[2]+1)
@Out.WriteChar(s, 0, 0)
@Out.Cursor(info[2], info[3])
elsif $3 == '2'
@Out.Cls()
@Out.Cursor(0, 0)
else
STDERR.print "\e#$2#$3#$4" if DEBUG
end
when 'K'
info = @Out.Info()
if !$3 or $3 == ''
s = ' ' * (info[7]-info[2]+1)
@Out.Write(s)
@Out.Cursor(info[2], info[3])
elsif $3=='1'
s = ' '*(info[2]+1)
@Out.WriteChar(s, 0, info[3])
@Out.Cursor(info[2], info[3])
elsif $3=='2'
s = ' '* info[0]
@Out.WriteChar(s, 0, info[3])
@Out.Cursor(info[2], info[3])
end
when 'L'
n = $3 == ''? 1 : $3.to_i
info = @Out.Info()
@Out.Scroll(0, info[3], info[0]-1, info[1]-1,
0, info[3] + n.to_i,
' '[0], @Out.Attr(),
0, 0, 10000, 10000)
@Out.Cursor(info[2], info[3])
when 'M'
n = $3 == ''? 1 : $3.to_i
info = @Out.Info();
@Out.Scroll(0, info[3]+n, info[0]-1, info[1]-1,
0, info[3],
' '[0], @Out.Attr(),
0, 0, 10000, 10000)
@Out.Cursor(info[2], info[3])
when 'P'
n = $3 == ''? 1 : $3.to_i
info = @Out.Info()
n = info[0]-info[2] if info[2]+n > info[0]-1
@Out.Scroll(info[2]+n, info[3] , info[0]-1, info[3],
info[2], info[3],
' '[0], @Out.Attr(),
0, 0, 10000, 10000)
s = ' ' * n
@Out.Cursor(info[0]-n, info[3])
@Out.Write(s)
@Out.Cursor(info[2], info[3])
when '@'
s = ' ' * $3.to_i
info = @Out.Info()
s << @Out.ReadChar(info[7]-info[2]+1, info[2], info[3])
s = s[0..-($3.to_i)]
@Out.Write(s);
@Out.Cursor(info[2], info[3])
when 'A'
(x, y) = @Out.Cursor()
n = $3 == ''? 1 : $3.to_i;
@Out.Cursor(x, y-n)
when 'B'
(x, y) = @Out.Cursor()
n = $3 == ''? 1 : $3.to_i;
@Out.Cursor(x, y+n)
when 'C'
(x, y) = @Out.Cursor()
n = $3 == ''? 1 : $3.to_i;
@Out.Cursor(x+n, y)
when 'D'
(x, y) = @Out.Cursor()
n = $3 == ''? 1 : $3.to_i;
@Out.Cursor(x-n, y)
when 'E'
x, y = @Out.Cursor()
n = $3 == ''? 1 : $3.to_i;
@Out.Cursor(0, y+n)
when 'F'
x, y = @Out.Cursor()
n = $3 == ''? 1 : $3.to_i;
@Out.Cursor(0, y-n)
when 'G'
x, y = @Out.Cursor()
n = $3 == ''? 1 : $3.to_i;
@Out.Cursor(n-1, y)
when 'f'
y, x = $3.split(';')
x = 1 unless x
y = 1 unless y
@Out.Cursor(x.to_i-1, y.to_i-1)
when 'H'
y, x = $3.split(';')
x = 1 unless x
y = 1 unless y
@Out.Cursor(x.to_i-1, y.to_i-1)
when 's'
(@x, @y) = @Out.Cursor()
when 'u'
@Out.Cursor(@x, @y)
else
STDERR.puts "\e#$2#$3#$4 not implemented" if DEBUG
end
else
case $4
when 'U'
@conv = nil
when 'K'
@Out.OutputCP(OEM)
@conv = 1
when 'X'
@conv = nil
@Out.OutputCP($3)
else
STDERR.puts "\e#$2#$3#$4 not implemented" if DEBUG
end
end
else
@Out.Write(_conv(s.dup))
s=''
end
end
end