For one thing, it assumes that a keystroke is one character(frequently untrue).
For another, it runs stty twice per keystroke... I'd be tempted to leave the terminal as is instead of changing it that often, save you a lot of CPU time.
This should work work:
It should be able to read entire keystrokes at once.
Hi all!
I need a little help with an imbedded fuction I am trying to write. What I am trying to do is go to a series of hosts and get the contents of an XML file, storing some of the data, along with the name of the host it was gathered from. My intent is to store this in an array for later... (1 Reply)
Hi,
I would like to use a power function in Bash in an awk '{ } .
e.g pow(2,3)=8
Any suggestion? I try to find online resources but most of them stated by using BC.
Please advise. Thanks. (3 Replies)
I want to have a function with a similar interface:
search *.cpp asdf
that will search recursively all directories for *.cpp file, containing line 'asdf' inside. I tried this:
function search { find . -name "$1" | xargs grep -li $2; }
But it doesn't work all the time. For example, if i run it... (3 Replies)
Hello all,
I would like to know if it is possible to return a the result of a boolean expression from a function like this
function()
{
# some code
return ||
}
and what will be the return value ?
Thank you for help. (6 Replies)
My script-
result=""
times()
{
echo "inside the times function"
result=8
echo "Inside function $result"
return $result
}
result=$(times)
echo "the value is "$?
echo "the value of result $result"
when I run I get this, why the value still remain 0.
$ ./func
the value is 0
the value... (5 Replies)
Hey everyone.
I am currently testing my first function based BASH script. The ultimate goal is going to be moving logs from point A to point B (or if B is down, to point C).
Part of this involves the following function:
function testAlive{
ping -c 1 -q $1
}
Now when I run ping -c... (1 Reply)
I need to add a selection within the bash function below and am having some trouble doing so.
phox2b() {
printf "\n\n"
printf "What is the id of the patient getting Phox2B analysis : "; read id
printf "Is this an intronic variant? Y/N "; read match_choice
case... (5 Replies)
I am putting this thread to shell-threads, because it is about how to make a function work properly. I need a hint for declaring a function right, it has been more than a year I did not work that straight with bash.
So my aim is to turn off the eth0 (as it would be in linux, and bge0 in bsd ),... (2 Replies)
I am trying to figure out why I am having a "problem" with some functions in a bash script I am running. The reason for air quoting is that the functions are working, they are just not displaying anything to screen when called from another function. Here's an example:
function Create_Input
{... (6 Replies)
Discussion started by: dagamier
6 Replies
LEARN ABOUT DEBIAN
poe::wheel::curses
POE::Wheel::Curses(3pm) User Contributed Perl Documentation POE::Wheel::Curses(3pm)NAME
POE::Wheel::Curses - non-blocking input for Curses
SYNOPSIS
use Curses;
use POE qw(Wheel::Curses);
POE::Session->create(
inline_states => {
_start => sub {
$_[HEAP]{console} = POE::Wheel::Curses->new(
InputEvent => 'got_keystroke',
);
},
got_keystroke => sub {
my $keystroke = $_[ARG0];
# Make control and extended keystrokes printable.
if ($keystroke lt ' ') {
$keystroke = '<' . uc(unctrl($keystroke)) . '>';
}
elsif ($keystroke =~ /^d{2,}$/) {
$keystroke = '<' . uc(keyname($keystroke)) . '>';
}
# Just display it.
addstr($keystroke);
noutrefresh();
doupdate;
# Gotta exit somehow.
delete $_[HEAP]{console} if $keystroke eq "<^C>";
},
}
);
POE::Kernel->run();
exit;
DESCRIPTION
POE::Wheel::Curses implements non-blocking input for Curses programs.
POE::Wheel::Curses will emit an "InputEvent" of your choosing whenever an input event is registered on a recognized input device (keyboard
and sometimes mouse, depending on the curses library). Meanwhile, applications can be doing other things like monitoring network
connections or child processes, or managing timers and stuff.
PUBLIC METHODS
POE::Wheel::Curses is rather simple.
new
new() creates a new POE::Wheel::Curses object. During construction, the wheel registers an input watcher for STDIN (via select_read()) and
registers an internal handler to preprocess keystrokes.
new() accepts only one parameter "InputEvent". "InputEvent" contains the name of the event that the wheel will emit whenever there is
input on the console or terminal. As with all wheels, the event will be sent to the session that was active when the wheel was
constructed.
It should be noted that an application may only have one active POE::Wheel::Curses object.
EVENTS AND PARAMETERS
These are the events sent by POE::Wheel::Curses.
InputEvent
"InputEvent" defines the event that will be emitted when POE::Wheel::Curses detects and reads console input. This event includes two
parameters:
$_[ARG0] contains the raw keystroke as received by Curses::getch(). An application may process the keystroke using Curses::unctrl() and
Curses::keyname() on the keystroke.
$_[ARG1] contains the POE::Wheel::Curses object's ID.
Mouse events aren't portable. As of October 2009, it's up to the application to decide whether to call mousemask().
SEE ALSO
Curses documents what can be done with Curses. Also see the man page for whichever version of libcurses happens to be installed (curses,
ncurses, etc.).
POE::Wheel describes wheels in general.
The SEE ALSO section in POE contains a table of contents covering the entire POE distribution.
BUGS
None known, although curses implementations vary widely.
AUTHORS & COPYRIGHTS
Please see POE for more information about authors and contributors.
perl v5.14.2 2012-05-15 POE::Wheel::Curses(3pm)