The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tickit::Window - a window for drawing operations

SYNOPSIS

DESCRIPTION

Provides coordination of widget drawing activities. A Window represents a region of the screen that a widget occupies.

Windows cannot directly be constructed. Instead they are obtained by sub-division of other windows, ultimately coming from the Tickit::RootWindow associated with the terminal.

METHODS

$cols = $win->cols

$lines = $win->lines

Obtain the size of the window

$win->resize( $lines, $cols )

Change the size of the window.

$win->reposition( $top, $left )

Move the window relative to its parent.

$win->change_geometry( $top, $left, $lines, $cols )

A combination of resize and reposition, to atomically change all the coordinates of the window. Will only invoke on_geom_changed once, rather than twice as would be the case calling the above methods individually.

$win->set_on_geom_changed( $on_geom_changed )

Set the callback to invoke whenever the window is resized or repositioned; i.e. whenever its geometry changes.

 $on_geom_changed->( $win )

$win->set_on_key( $on_key )

Set the callback to invoke whenever a key is pressed while this window, or one of its child windows, has the input focus.

 $handled = $on_key->( $win, $type, $str, $key )

The invoked code should return a true value if it considers the keypress dealt with, or false to pass it up to its parent window.

$parentwin = $win->parent

Returns the parent window; i.e. the window on which make_sub was called to create this one

$rootwin = $win->root

Returns the root window

$term = $win->term

Returns the Tickit::Term instance of the terminal on which this window lives.

$top = $win->top

$left = $win->left

Returns the coordinates of the start of the window, relative to the parent window.

$top = $win->abs_top

$left = $win->abs_left

Returns the coordinates of the start of the window, relative to the root window.

$val = $win->getpen( $attr )

%attrs = $win->getpen

Retrieve the current pen settings for the window.

$val = $win->get_effective_pen( $attr )

%attrs = $win->get_effective_pen

Retrieve the effective pen settings for the window. This will be the settings of the window and all its parents down to the root window, merged together.

$win->chpen( $attr, $val )

Change a pen attribute. Setting undef implies default value. To delete the attribute altogether see instead delpen.

$win->delpen( $attr )

Delete a pen attribute. Removes the value from the window's pen attributes, implying this window uses its parent value. To set default, see instead chpen with undef value.

$sub = $win->make_sub( $top, $left, $lines, $cols )

Constructs a new sub-window starting at the given coordinates of this window. It will be sized to the given limits.

$win->goto( $line, $col )

Moves the cursor to the given position within the window. Both $line and $col are 0-based.

$win->print( $text )

Print the given text to the terminal at the current cursor position using the pen of the window.

$win->penprint( $text, %attrs )

Print the given text to the terminal at the current cursor position using the pen of the window, overridden by any extra attributes passed.

$win->erasech( $count, $moveend )

Erase $count columns forwards.

$success = $win->insertch( $count )

Insert $count blank characters, moving subsequent ones to the right. Note this can only be achieved if the window extends all the way to the righthand edge of the terminal, or else the operation would corrupt further windows beyond it.

If this window does not extend to the righthand edge, then this method will simply return false. If it does, the characters are inserted and the method returns true.

$success = $win->deletech( $count )

Delete $count characters, moving subsequent ones to the left, and inserting blanks at the end of the line. Note this can only be achieved if the window extends all the way to the righthand edge of the terminal, or else the operation would corrupt further windows beyond it.

If this window does not extend to the righthand edge, then this method will simply return false. If it does, the characters are inserted and the method returns true.

$win->scroll( $downward, $rightward )

Attempt to scroll the contents of the window in the given direction. Most terminals cannot scroll arbitrary regions. If the terminal does not support the type of scrolling requested, this method returns false to indicate that the caller should instead redraw the required contents. If the scrolling was sucessful, the method returns true.

$win->focus( $line, $col )

Put the cursor at the given position in this window. Ensures the cursor remains at this position after drawing.

$win->clear

Erase the entire content of the window and reset it to the current background colour.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>