Hi,
"Yohanes Santoso" <ysantoso / jenny-gnome.dyndns.org> wrote in message
news:87bs28n0sw.fsf / jenny-gnome.dyndns.org...
> Ian Macdonald <ian / caliban.org> writes:
>
> > Hi,
> >
> > Is there a way to portably disable the cursor in Ruby?
>
> afaik, not in any language since this is runtime-environment related.
> There's ncurses for manipulating terminals in unix. Not sure about in
> win32.
>
In win32

Try this:

require 'Win32API'

STD_OUTPUT_HANDLE = -11
GetStdHandle = Win32API.new("kernel32","GetStdHandle",['L'],'L')
SetConsoleCursorInfo =
Win32API.new("kernel32","SetConsoleCursorInfo",['L','P'],'L')
GetConsoleCursorInfo =
Win32API.new("kernel32","GetConsoleCursorInfo",['L','P'],'L')

def cursor_on
  cci = "\0" * 8;
  hStdOutput = GetStdHandle.Call(STD_OUTPUT_HANDLE)
  GetConsoleCursorInfo.Call(hStdOutput,cci)
  ci = cci.unpack("LL")
  ci[1] = 1
  SetConsoleCursorInfo.Call(hStdOutput,ci.pack("LL"))
end

def cursor_off
  cci = "\0" * 8;
  hStdOutput = GetStdHandle.Call(STD_OUTPUT_HANDLE)
  GetConsoleCursorInfo.Call(hStdOutput,cci)
  ci = cci.unpack("LL")
  ci[1] = 0
  SetConsoleCursorInfo.Call(hStdOutput,ci.pack("LL"))
end


cursor_off
puts "cursor off"
gets
cursor_on
puts "cursor on"
gets



Park Heesob