NAME

Tickit::Widget::FileViewer - support for viewing files in Tickit.

SYNOPSIS

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;

METHODS

new

Instantiate a new fileviewer widget. Passes any given named parameters to "configure".

configure

Takes the following named parameters:

  • file - the file to load

  • line - which line to jump to

load_file

Loads the given file into memory.

line_attributes

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_to_rb

Render this widget. Will call "render_line_data" and "render_line_number" to do the actual drawing.

render_line_number

Renders the given (zero-based) line number at the current cursor position.

Subclasses should override this to provide styling as required.

render_line_data

Renders the given line text at the current cursor position.

Subclasses should override this to provide styling as required.

on_key

Handle a keypress event. Passes the event on to "handle_key" or "handle_text" as appropriate.

cursor_line

Accessor for the current cursor line. Will trigger a redraw if we have a window and the cursor line has changed.

handle_key

Handle a keypress event. Currently hard-coded to accept up, down, pageup and pagedown events.

handle_text

Stub method for dealing with text events.

top_line

First line shown in the window.

SEE ALSO

  • 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

INHERITED METHODS

Tickit::Widget

get_style_pen, get_style_text, get_style_values, key_focus_next_after, key_focus_next_before, parent, pen, redraw, requested_cols, requested_lines, requested_size, reshape, resized, set_parent, set_requested_size, set_style, set_style_tag, set_window, split_widget_opts, style_classes, take_focus, window, window_lost

Object::Pad::UNIVERSAL

BUILDARGS

AUTHOR

Tom Molesworth <TEAM@cpan.org>

LICENSE

Copyright Tom Molesworth 2011-2015. Licensed under the same terms as Perl itself.