Skip Menu |

This queue is for tickets about the Curses-UI CPAN distribution.

Report information
The Basics
Id: 18048
Status: open
Priority: 0/
Queue: Curses-UI

Owner: Nobody in particular
Requestors: cpan [...]

Bug Information
Severity: Important
Broken in: 0.95
Fixed in: (no value)


Subject: Single line TextEditor field eats enter key when pasted or scanned
Download (untitled) / with headers
text/plain 1.5k
We are using Curses::UI to implement an inventory tracking application where barcodes are scanned off the inventory. We were encountering issues where the KEY_ENTER after the barcode was not triggering the expected events when read into a Curses::UI::TextEntry control. Namely, after scanning the barcode it was supposed to exit the field, so it was ready for scanning the next barcode. We tracked down the cause of this to the code in add_string designed to handle pasted input. Since the keystrokes generated by scanning a barcode come in rapid succession, they also trigger this logic. This logic only allows add-string and newline bindings to fire, regardless of what keystrokes are used. However, on a single line TextEditor control, the KEY_ENTER binding is not to newline, but to loose-focus. The attached patch changes this so that paste will allow anything that binds to add-string, and any bindings for KEY_ENTER to run. Note: The workaround in Curses::UI::do_one_event() for pasting large amounts of text in Solaris can also throw out keystrokes in some cases, due to feedkey() calling flushkeys(). One of our test programs was running into this failure case, initially causing us to suspect that as the source of our problems with barcode scanning, but further analysis found the above issue. It's probably not a good idea to mysteriously throw away keyboard input whenever handling event takes long enough that another key is ready. Either this workaround shouldn't throw out pending keystrokes, shouldn't throw them out so easily, or it should be restricted only to those operating systems that require it.
From: cpan [...]
It would help if I attached the patch file to the ticket as well.
--- /opt/perl64/lib/site_perl/5.8.5/Curses/UI/ Sat Nov 27 11:12:58 2004 +++ Curses/UI/ Tue Mar 7 16:35:12 2006 @@ -703,18 +704,19 @@ } elsif ( $binding eq 'add-string' ) { substr($this->{-text}, $this->{-pos}, 0) = $ch; $this->{-pos} += length($ch); - } elsif ( $binding eq 'newline' ) { + } elsif ( $ch eq KEY_ENTER() ) { $this->process_bindings($ch); } # Multiple characters at input? This is probably a # pasted string. Get it and process it. Don't do - # special bindings, but only add-string and newline. + # special bindings, but only add-string and enter. $ch = $this->get_key(0); } $this->layout_content;

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to