Skip Menu |

This queue is for tickets about the Win32-Console CPAN distribution.

Report information
The Basics
Id: 64675
Status: new
Priority: 0/
Queue: Win32-Console

People
Owner: Nobody in particular
Requestors: joejr [...] vornehm.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.09
Fixed in: (no value)



Subject: InputChar loses input in ENABLE_LINE_INPUT mode
When the InputChar method does not receive all the input characters requested, it returns undef, inadvertently throwing away any characters it may have received. This makes it difficult to use when ENABLE_LINE_MODE is on. Running Strawberry Perl v5.12.1 on WinXP SP3. To reproduce: use Win32::Console; $CONSOLE = Win32::Console->new(STD_INPUT_HANDLE); $CONSOLE->Mode(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT); print "Type \"Perl is awesome\" and press Enter.\n"; $res = $CONSOLE->InputChar(10); print "\nResults: \"$res\"\n"; print "Remaining chars: ", $CONSOLE->GetEvents(), "\n"; # will be 0, should be >0 As an aside, it appears that when InputChar is called, any input left remaining in the console input buffer is flushed (discarded). Ideally, one would like to call some method $CONSOLE->InputLine() and have it return the whole input line. A workaround would be to call $CONSOLE->InputChar(1024) or some other large number, except that such a call fails presently when 1024 characters are not already waiting in the input buffer. Attached is a patch that makes InputChar return the characters received.
Subject: Console.pm.diff
346,351c346,349 < if (_ReadConsole($self->{'handle'}, $buffer, $number) == $number) { < return $buffer; < } < else { < return undef; < } --- > $number = _ReadConsole($self->{'handle'}, $buffer, $number); > return undef unless $number; > substr($buffer, $number) = ""; > return $buffer;