Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Curses and TextEditors

by KalistoGatsby (Initiate)
on Oct 18, 2013 at 23:48 UTC ( #1058848=perlquestion: print w/replies, xml ) Need Help??
KalistoGatsby has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Im trying to use a TextEditor from Curses: Shawn Boyette > Curses-UI-0.9609 > Curses::UI::TextEditor I write data into the TextEditor widget and have added a scrollbar using the code below:
my $infodialog = $infowin->add( 'infodialog', 'TextViewer', -wrapping => 1, -vscrollbar => 'right', ); $infodialog->focus(); sub info{ my ($infoText, $infodialog) = @_; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); my $fqInfoText = "[$hour:$min:$sec]-" . $infoText; my $currentText = $infodialog->get(); $infodialog->text($currentText . $fqInfoText); $infodialog->draw(); }
How do I always keep the scrollbar at the bottom? I want the user to always see the newest text in the TextViewer. I have found the following in the documentation:

"<end> Call the 'cursor-end' routine: go to the end of the text."

Can I "send" a fake key press of the end key before I call draw to update the Textviewer to show the newest entries? How is this usually done?

Replies are listed 'Best First'.
Re: Curses and TextEditors
by keszler (Priest) on Oct 19, 2013 at 08:41 UTC
    If you read the source for Curses::UI::TextEditor you'll see (undocumented) methods cursor_to_end() and cursor_to_scrlineend().
Re: Curses and TextEditors
by kcott (Chancellor) on Oct 19, 2013 at 08:08 UTC

    G'day KalistoGatsby,

    Welcome to the monastery.

    Take a look at Curses::UI::Widget. You'll find a lot of information there regarding scrollbars. The process_bindings() method looks like its what you want.

    Also take a look at Curses: Available Constants. KEY_END is probably what you're after.

    -- Ken

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1058848]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2018-06-20 16:27 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.