Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Curses::UI - How to set escape delay?

by withering (Monk)
on Aug 15, 2013 at 04:30 UTC ( #1049509=perlquestion: print w/replies, xml ) Need Help??

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

Hello fellow monks,

I'm following Curses::UI::Tutorial on CPAN with the following code:

#!/usr/bin/env perl use strict; use Curses::UI; my $cui = new Curses::UI( -color_support => 1 ); my @menus = ( { -label => 'File', -submenu => [ { -label => 'Exit', -value => \&exit_dialog } ] } ); sub exit_dialog { my $ret = $cui->dialog( -message => "Quit?", -title => "Quit", -buttons => [ 'yes', 'no' ] ); exit(0) if $ret; } my $menu = $cui->add( 'menu', 'Menubar', -menu => \@menus, ); my $win1 = $cui->add( 'win1', 'Window', -border => 0, -y => 1 ); my $texteditor = $win1->add( 'text', 'TextEditor', -text => "Line1\n"."Line2\n" ); $cui->set_binding(sub { $menu->focus() }, "\cx"); $cui->set_binding( \&exit_dialog, "\cq"); $texteditor->focus(); $cui->mainloop();

The menubar will loose its focus when it receives an escape keystroke. When I run the program, it takes a full second to respond. According to ncurses(3), the default delay for escape keystroke is 1000ms and could be changed by ESCDELAY variable or c function set_escdelay(3X). However, I didn't see any method/function corresponding to set_escdelay in the CPAN documentation.

Is there any method, other than to change ESCDELAY, to change the escape keystroke delay?

Feel free to correct any of my mistakes. Thanks in advance.

Replies are listed 'Best First'.
Re: Curses::UI - How to set escape delay?
by rnewsham (Curate) on Aug 15, 2013 at 06:27 UTC

    You can set that with an environment variable. Adding the following line near the start of your script seems to work for me.

    $ENV{ESCDELAY} = 3000;

      Thanks. Well it seems there's no other alternative to set_escdelay...

        Is there a particular reason why you want an alternative method?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1049509]
Approved by kcott
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2021-10-19 22:14 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (77 votes). Check out past polls.