[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Curses

Overdorf, Sam

10/10/2006 1:11:00 AM

So how do I go about getting this changed for the Ruby Curses Library?
Sam Overdorf


-----Original Message-----
From: Overdorf, Sam [mailto:sam.overdorf@intel.com]
Sent: Thursday, September 28, 2006 5:39 PM
To: ruby-talk ML
Subject: Re: Curses

That is always the $64,000 question.

-----Original Message-----
From: Michael W. Ryder [mailto:_mwryder@worldnet.att.net]
Sent: Thursday, September 28, 2006 1:45 PM
To: ruby-talk ML
Subject: Re: Curses

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/C...
>>>>>> 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/m...
>>> http://www.die.net/doc/linux/man/man3/mv...
>>
>> 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.
>

2 Answers

Guillaume Marcais

10/10/2006 3:01:00 AM

0

Personally, in the recent curses program I wrote, I used ruby-ncurses.
It has the disadvantage of not being in the standard library. On the
other hand, it follows the C API very closely. Although documentation
is lacking, the C man pages and the couple of example in the
distribution are really all you need as the translation from the C api
to Ruby is straight-forward and consistent.

Don't take me wrong, more documentation and a separate more Ruby-esque
API would be nice. It is just that given the almost 1-to-1 mapping
between the two APIs, it was fairly easy to use the C documentation.

I feel that incorporating ruby-ncurses to the standard library would be
better than modifying Curses.

My 2 cents,
Guillaume.

Le 9 oct. 06, à 21:10, Overdorf, Sam a écrit :

> So how do I go about getting this changed for the Ruby Curses Library?
> Sam Overdorf
>
>
> -----Original Message-----
> From: Overdorf, Sam [mailto:sam.overdorf@intel.com]
> Sent: Thursday, September 28, 2006 5:39 PM
> To: ruby-talk ML
> Subject: Re: Curses
>
> That is always the $64,000 question.
>
> -----Original Message-----
> From: Michael W. Ryder [mailto:_mwryder@worldnet.att.net]
> Sent: Thursday, September 28, 2006 1:45 PM
> To: ruby-talk ML
> Subject: Re: Curses
>
> 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/C...
>>>>>>> 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/m...
>>>> http://www.die.net/doc/linux/man/man3/mv...
>>>
>>> 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.
>>
>
>


Eero Saynatkari

10/10/2006 3:11:00 AM

0

On 2006.10.10 10:10, Overdorf, Sam wrote:
> So how do I go about getting this changed for the Ruby Curses Library?
> Sam Overdorf

The first step in doing that is NOT top-posting :)

Write a patch and submit it through rubyforge.org. Remember, though,
that there may be countless programs that depend on the current names.

Personally, I would just use the library as-is since there is no
functional change you would be making.