Portably turning off the cursor

Hi,

Is there a way to portably disable the cursor in Ruby?

Ian

···


Ian Macdonald | Drugs may be the road to nowhere, but at
ian@caliban.org | least they’re the scenic route!
>
>
>

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.

YS.

Yes, but I can’t even find a way of doing it using Ruby curses.

Ian

···

On Thu 23 Jan 2003 at 09:54:11 +0900, Yohanes Santoso wrote:

Ian Macdonald ian@caliban.org writes:

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.


Ian Macdonald | It’s not easy, being green. – Kermit the
ian@caliban.org | Frog
>
>
>

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