Tickit::Widget::FileViewer - support for viewing files in Tickit.
Version 0.004
use Tickit::Async; use Tickit::Widget::FileViewer; my $tickit = Tickit::Async->new; my $viewer = Tickit::Widget::FileViewer->new( file => 'somefile.txt', ); $tickit->set_root_widget($viewer); my $loop = IO::Async::Loop->new; $loop->add($tickit); $tickit->run;
Instantiate a new fileviewer widget. Passes any given named parameters to "configure".
Takes the following named parameters:
file - the file to load
line - which line to jump to
Loads the given file into memory.
Given a zero-based line number and line text, returns the attributes to apply for this line.
This method is intended for line-level highlights such as current cursor position or selected text - For syntax highlighting, overriding the "render_line_data" method may be more appropriate.
Render this widget. Will call "render_line_data" and "render_line_number" to do the actual drawing.
Renders the given (zero-based) line number at the current cursor position.
Subclasses should override this to provide styling as required.
Renders the given line text at the current cursor position.
Handle a keypress event. Passes the event on to "handle_key" or "handle_text" as appropriate.
Accessor for the current cursor line. Will trigger a redraw if we have a window and the cursor line has changed.
Handle a keypress event. Currently hard-coded to accept up, down, pageup and pagedown events.
Stub method for dealing with text events.
First line shown in the window.
Tickit::Widget::Scroller - support for scrollable list of widgets, generally much cleaner and flexible than this implementation, and could easily provide similar functionality if the line number and code for each line are wrapped in another widget
get_style_pen, get_style_text, get_style_values, key_focus_next_after, key_focus_next_before, on_pen_changed, parent, pen, redraw, requested_cols, requested_lines, requested_size, reshape, resized, set_parent, set_pen, set_requested_size, set_style, set_style_tag, set_window, style_classes, take_focus, window, window_lost
Tom Molesworth <cpan@perlsite.co.uk>
Copyright Tom Molesworth 2011-2014. Licensed under the same terms as Perl itself.
To install Tickit::Widget::FileViewer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tickit::Widget::FileViewer
CPAN shell
perl -MCPAN -e shell install Tickit::Widget::FileViewer
For more information on module installation, please visit the detailed CPAN module installation guide.