Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (15)
As of 2015-07-31 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls