Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Curses and TextEditors

by KalistoGatsby (Initiate)
on Oct 18, 2013 at 23:48 UTC ( [id://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 (Archbishop) 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found