Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Curses: removing a cursed Widget

by kko (Scribe)
on Apr 15, 2002 at 00:45 UTC ( [id://159050]=perlquestion: print w/replies, xml ) Need Help??

kko has asked for the wisdom of the Perl Monks concerning the following question:

I'm using Curses::Widgets on some little toy I'm hacking together, but I can't find any (explicit-in-your-face-recipe) on how to remove a widget from the screen. Can the Wise Ones shed light on my console-based path?

Replies are listed 'Best First'.
Re: Curses: removing a cursed Widget
by JayBonci (Curate) on Apr 15, 2002 at 08:55 UTC
    Ahhh curses, how thou hath plagued me.

    I looked for quite a while, and I couldn't see a way. What happens in curses I believe is that when something is drawn, stuff stays over it until it is drawn over. Basically objects don't clean up after themselves, and they have no particular relation between screen real estate, and the internal objects that govern them (as would a real window-driven UI such as the Finder or Windows)

    That being said, you can either output characters over it, using various text positioning commands available to you through the curses library or you can use clear() on the screen(check out man ncurses for the full set).
    • clear($win) takes an object window created by Curses
      #!/usr/bin/perl -w use strict; use Curses; my $win = new Curses; clear($win); #$win->clear(); #may also work
    • Check out mvwaddstr and mvwaddnstr if you're looking to blit out blank text where a widget would have been.
      $win->addstr(12, 34, 'perlmonks forevah'); #or: #$win->addstr(12, 34, ' ');
      Good luck with it. I used to do tons of stuff with curses, but not so much anymore, and it was in C, but the libs/exports are the same as the man page, so that may be a good place to look.

          --jb
      If that is the case (the last time I did any perl-curses stuff was in 95), you might try double-buffering. Keep a copy of what "should" be on the screen in memory somewhere (an array or something), and when you are going to change something, make a window (I guess), do your changes, and write the window to the same area.

      That is an idea, anyway...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://159050]
Front-paged by theguvnor
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-24 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found