Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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?

Comment on Curses and TextEditors
Download Code
Re: Curses and TextEditors
by kcott (Abbot) 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

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().

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (15)
As of 2014-08-28 13:12 GMT
Find Nodes?
    Voting Booth?

    The best computer themed movie is:

    Results (260 votes), past polls