Forum: Ruby New window screwing up my Ncurses script!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
907f29cb608004d2156d5ce88240f09b?d=identicon&s=25 Tim Mcd (zonbi)
on 2009-01-29 17:29
require 'rubygems'
require 'ncurses'

Ncurses.initscr
height = Ncurses.LINES() - 3
width = Ncurses.COLS()

outputwin = Ncurses.WINDOW.new(height, width, 0, 0)

failure = "-" * Ncurses.COLS()

Ncurses.mvprintw(22, 0, failure)
Ncurses.refresh

test = ""
Ncurses.mvwgetstr(Ncurses.stdscr, Ncurses.LINES() - 1, 0, test)

outputwin.addstr(test)
outputwin.refresh

sleep 1
Ncurses.endwin

Thats the code. If I comment out the first initialization of
'outputwin', the code runs fine up to the point where it gives me a name
error over outputwin.addstr, which is expected. But if I uncomment it, I
don't get any errors, but some weird actions. When I run the ruby
script, it clears the screen, displays my terminal prompt again, and
text typed doesn't show up (like the Ncurses mode didn't end correctly).
Does anyone know whats wrong with my outputwin?
0026dd77fd9ecc97b36e5b79cdbcf590?d=identicon&s=25 R. Kumar (sentinel)
on 2009-01-30 06:12
Tim Mcd wrote:
>
> Ncurses.initscr
> height = Ncurses.LINES() - 3
> width = Ncurses.COLS()
>
> outputwin = Ncurses.WINDOW.new(height, width, 0, 0)
>

If you would follow the examples provided, you would be able to complete
your programs with minimal hassles.

It is Ncurses::WINDOW.new

Also, avoid writing to windows and to stdscr at the same time (i.e.
mixing). If you create a window, then write only to windows. That way
when you remove the window, whatever was on it will also get cleared
off.
907f29cb608004d2156d5ce88240f09b?d=identicon&s=25 Tim Mcd (zonbi)
on 2009-01-30 07:02
(RK) Sentinel wrote:
> Tim Mcd wrote:
>>
>> Ncurses.initscr
>> height = Ncurses.LINES() - 3
>> width = Ncurses.COLS()
>>
>> outputwin = Ncurses.WINDOW.new(height, width, 0, 0)
>>
>
> If you would follow the examples provided, you would be able to complete
> your programs with minimal hassles.
>
> It is Ncurses::WINDOW.new
>
> Also, avoid writing to windows and to stdscr at the same time (i.e.
> mixing). If you create a window, then write only to windows. That way
> when you remove the window, whatever was on it will also get cleared
> off.

I thought using :: and . were interchangeable? Guess not. I had been
using .WINDOW.new before, and it worked fine. But it works now thanks!
This topic is locked and can not be replied to.