Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: trying to populate curses menus from text files (text format)

by Anonymous Monk
on Nov 01, 2013 at 02:45 UTC ( [id://1060691]=note: print w/replies, xml ) Need Help??


in reply to trying to populate curses menus from text files

... should be read from text file ...

What text file where? :) How do I post a question effectively?

my @menu = ( { -label => 'File', -submenu => [ { -label => 'Exit ^Q', -value => '\&exit_dialog' }, { -label => 'Wait ^W', -value => '\&remain_dialog' } +, ], }, ); use JSON; print encode_json({menu=>\@menu}); __END__ { "menu" : [ { "-label" : "File", "-submenu" : [ { "-label" : "Exit ^Q", "-value" : "\\&exit_dialog" }, { "-label" : "Wait ^W", "-value" : "\\&remain_dialog" } ] } ] }

Then

my $menu = decode_json( path( $jsonfile )->slurp_raw ); my $funcname = $menu->{menu}[0]{"-submenu"}[0]{"-value"}; my $funcref = $callback{$funcname}; $menu->{menu}[0]{"-submenu"}[0]{"-value"} = $funcref;

I need to read each -label from a line of the text file and pass the name of the menu (== the filename) and the label to the subroutine called when the item is selected.

Your callback will get the menuitem object as argument, you can (usually) query/interrogate/examine this to retrieve the label

Replies are listed 'Best First'.
Re^2: trying to populate curses menus from text files (text format)
by boscaiolo (Initiate) on Nov 02, 2013 at 12:06 UTC
    Thanks for your rapid response, and apologies for having over-pruned my question. To my good fortune Ken (below) provided an answer even closer to my intentions.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1060691]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-24 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found