I need to build a Curses front end to display the output of a while loop. I've built the frontend how I want it, and have the code that generates the data I want, but have no idea how to have perl build the curses interface and continually update it.

Here is some broken code:
use strict; use Curses::UI; my $cui = new Curses::UI( -color_support => 1 ); ############################################################ #### ### Build the main Menu bar ### ## ############################################################### my @menu = ( { -label => 'File', -submenu => [ { -label => 'Exit ^Q', -value => \&e +xit_dialog } ] }, ); sub exit_dialog(){ my $return = $cui->dialog( -message => "Do you really want to quit?", -title => "Are you sure???", -buttons => ['yes', 'no'] ); exit(0) if $return; } my $menu = $cui->add('menu','Menubar', -menu => \@menu, -fg => "black", ); ########################################################## ### ### ### Define base layout of windows ## ## ########################################################## my $width = $cui->width() / 2; my $hist_height = ($cui->height() )/2 ; ########################################################### ### RX Power Spectrum my $rxSpec = $cui->add( 'rxSpec', 'Window', -border => 1, -bfg => 'red', -width => $width, -y => 1, -height => $hist_height ); my $rxHistogram = $rxSpec->add("RxHisto", "TextViewer", -text => "Here is some text\n" . "And some more"); ########################################################### ### TX Power Spectrum my $txSpec = $cui->add( 'txSpec', 'Window', -border => 1, -y => $hist_height + 1, -width => $width, -bfg => 'red' ); my $TxHistogram = $txSpec->add("TxHisto", "TextViewer", -text => "Here is some text\n" . "And some more"); ########################################################### ### List of active modems my $List = $cui->add( 'List', 'Window', -border => 1, -y => 1, -x => $width, -width => $width, -bfg => 'red' ); my $ModemList = $List->add("Modems", "TextViewer", -text => "Here is some text\n" . "And some more"); ############################################################## ### ### ### Key Bindings ### ############################################################### $cui->set_binding(sub {$menu->focus()}, "\cX"); $cui->set_binding( \&exit_dialog , "\cQ"); ######################################### ### Do some stuff while(1){ my $i = 1; my $text .= "$i\n"; $ModemList->text($text); $ModemList->draw(); $i++; sleep(2); } $cui->mainloop();


It's very basic (for the moment), but I'll I'm attempting to do is display those three windows and update the contents of the far right one every 2 seconds.

In it's current state, the mainloop() is never called, so it doesn't draw the UI. I know the answer is pretty simple...I just can't find it anywhere in the docs.

and off topic, how can I enter new lines in this box without typing < br >?

In reply to Simple Curses Question by vortmax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.