Hi, I'm trying to do something similar to this. I am using Curses::UI to implement a ticket like system where new tickets comes in from users via UDP and it will update the Curses:UI:Listbox.

I tried to take the same route and and rather than using the $cui->mainloop(); from Curses:UI, I put it into my own server so that it can update the UI without blocking. But it seems when I do that, I lose the Curses:UI listbox functionality of having a scrollbox, being able to move up/down the list, etc; since everytime I try to run doupdate(); when a new UDP comes in, the program exits...

#!/usr/bin/perl use strict; use warnings; use IO::Socket; use Curses::UI; my ($sock, $data, $clienthost, $maxlen, $port); $maxlen = 1024; $port = 3711; my @array; my $cui = Curses::UI->new(-mouse_support => 0,-read_timeout => 0); my $win = $cui->add('window_id', 'Window'); my $listbox = $win->add('Tickets', 'Listbox', -border => 1, -title => 'Items', -vscrollbar => 1, ); $cui->{-read_timeout} = 0; $cui->set_binding( sub{ exit }, "\cQ" ); $cui->draw(); $sock = IO::Socket::INET->new(LocalPort => $port, Type => SOCK_DGRAM, Proto => 'udp') or die "Could not open socket!\n"; while (1) { $cui->focus(undef, 1); # 1 = forced focus $sock->recv($data, $maxlen); chomp($data); my $req = $data; my($port, $ipaddr) = sockaddr_in($sock->peername); $clienthost = gethostbyaddr($ipaddr, AF_INET); $listbox->insert_at(\@array, "New ticket from ".$clienthost.": ".$re +q); $sock->send("We have received your ticket: $req"); $listbox->focus(); $cui->draw; # doupdate(); $cui->do_one_event();

In reply to Re^3: Curses::UI loop dilemma by Anonymous Monk
in thread Curses::UI loop dilemma by Anonymous Monk

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.