Curses

So can we change the Ruby Library?
Sam Overdorf

···

-----Original Message-----
From: Michael W. Ryder [mailto:_mwryder@worldnet.att.net]
Sent: Wednesday, September 27, 2006 5:15 PM
To: ruby-talk ML
Subject: Re: Curses

Eero Saynatkari wrote:

On 2006.09.28 07:35, Eero Saynatkari wrote:

On 2006.09.28 07:30, Michael W. Ryder wrote:

Eero Saynatkari wrote:

On 2006.09.28 04:25, Michael W. Ryder wrote:

Eero Saynatkari wrote:

On 2006.09.27 15:45, Michael W. Ryder wrote:

Eero Saynatkari wrote:

On 2006.09.27 10:35, Michael W. Ryder wrote:

Overdorf, Sam wrote:

Is anyone using the Curses class?
Is anyone maintaining the Curses class?

It looks like the Curses function move(y,x) is calling the

wrong

library
routine.

It is calling the window move function and not the cursor

positioning

function.

Thanks,
Sam Overdorf

According to O'Reilly's Programming with Curses "move() is

really a

#define macro for wmove() which takes a WINDOW* as its first
argument" So it appears that the library is working correctly.

#setpos x, y

What flavor of Curses is this from?

This one:

http://www.ruby-doc.org/stdlib/libdoc/curses/rdoc/classes/Curses.html

The source code shows that it uses Curses' move() function which

is a

macro to wmove() as I described above.

No, move() moves the cursor (wmove() moves a specified window's

cursor).

Confusingly, Ruby's Curses bindings also have a .move which

actually

uses mvwin() which moves the window itself.

ALL input/output in Curses is done with windows. The only

difference

between move() and wmove() is that move() passes the current window

to

the wmove() function. When you first start Curses it creates a

window

and sets it as the current window. Unless you create another window

and

change to it this window is used for all I/O.

Which is exactly what I said. Please review the Curses documentation.

  http://www.die.net/doc/linux/man/man3/move.3.html
  http://www.die.net/doc/linux/man/man3/mvwin.3.html

And yes, Ruby's Curses.move is not the same as move(). Curses.move
is the same as mvwin(). Curses.setpos is the same as move().

Having programmed using Curses with C for many years I am familiar with
how Curses works. As I kept pointing out move() and wmove() are the
same function. Why the Ruby library uses different names for the
functions I do not know. The mvwin() command in original Curses moves
the top left corner of the window, not the cursor position as one would
expect with a name like Curses.move. Personally, if I were using the
library I would have to rename all of the functions to their proper
Curses representation, not some random name like seems to have been
used. The current names makes it impossible to use available programs
and documentation with the Ruby library.

Overdorf, Sam wrote:

So can we change the Ruby Library?
Sam Overdorf

Looking at the source code it doesn't look like it would be too hard to change the names of the methods that are not standard Curses. I don't know how much it would break though.

···

-----Original Message-----
From: Michael W. Ryder [mailto:_mwryder@worldnet.att.net] Sent: Wednesday, September 27, 2006 5:15 PM
To: ruby-talk ML
Subject: Re: Curses

Eero Saynatkari wrote:

On 2006.09.28 07:35, Eero Saynatkari wrote:

On 2006.09.28 07:30, Michael W. Ryder wrote:

Eero Saynatkari wrote:

On 2006.09.28 04:25, Michael W. Ryder wrote:

Eero Saynatkari wrote:

On 2006.09.27 15:45, Michael W. Ryder wrote:

Eero Saynatkari wrote:

On 2006.09.27 10:35, Michael W. Ryder wrote:

Overdorf, Sam wrote:

Is anyone using the Curses class?
Is anyone maintaining the Curses class?

It looks like the Curses function move(y,x) is calling the

wrong

library
routine.

It is calling the window move function and not the cursor

positioning

function.

Thanks,
Sam Overdorf

According to O'Reilly's Programming with Curses "move() is

really a

#define macro for wmove() which takes a WINDOW* as its first argument" So it appears that the library is working correctly.

#setpos x, y

What flavor of Curses is this from?

This one:

http://www.ruby-doc.org/stdlib/libdoc/curses/rdoc/classes/Curses.html

The source code shows that it uses Curses' move() function which

is a

macro to wmove() as I described above.

No, move() moves the cursor (wmove() moves a specified window's

cursor).

Confusingly, Ruby's Curses bindings also have a .move which

actually

uses mvwin() which moves the window itself.

ALL input/output in Curses is done with windows. The only

difference

between move() and wmove() is that move() passes the current window

to

the wmove() function. When you first start Curses it creates a

window

and sets it as the current window. Unless you create another window

and

change to it this window is used for all I/O.

Which is exactly what I said. Please review the Curses documentation.

  http://www.die.net/doc/linux/man/man3/move.3.html
  http://www.die.net/doc/linux/man/man3/mvwin.3.html

And yes, Ruby's Curses.move is not the same as move(). Curses.move
is the same as mvwin(). Curses.setpos is the same as move().

Having programmed using Curses with C for many years I am familiar with how Curses works. As I kept pointing out move() and wmove() are the same function. Why the Ruby library uses different names for the functions I do not know. The mvwin() command in original Curses moves the top left corner of the window, not the cursor position as one would expect with a name like Curses.move. Personally, if I were using the library I would have to rename all of the functions to their proper Curses representation, not some random name like seems to have been used. The current names makes it impossible to use available programs and documentation with the Ruby library.