Tickit::Window - a window for drawing operations
Tickit::Window
Provides coordination of widget drawing activities. A Window represents a region of the screen that a widget occupies.
Window
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.
Tickit::RootWindow
Obtain the size of the window
Change the size of the window.
Move the window relative to its parent.
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.
resize
reposition
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 )
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 )
$type will be text for normal unmodified Unicode, or key for special keys or modified Unicode. $str will be the UTF-8 string for text events, or the textual description of the key as rendered by Term::TermKey for key events. $key will be the underlying Term::TermKey::Key event structure.
$type
text
key
$str
$key
Term::TermKey::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.
Before passing it to its parent, a window will also try any other non-focused sibling windows of the currently-focused window in order of creation (though note this order is not necessarily the order the child widgets that own those windows were created or added to their container).
If no window actually handles the keypress, then every window will eventually be consulted about it, preferring windows closer to the focused one.
This broadcast-like behaviour allows widgets to handle keypresses that should make sense even though their window does not actually have the keyboard focus. This feature should be used sparingly, to only capture one or two keypresses that really make sense; for example to capture the PageUp and PageDown keys in a scrolling list, or a numbered function key that performs some special action.
PageUp
PageDown
Set the callback to invoke whenever a mouse event is received within the window's rectangle.
$handled = $on_mouse->( $win, $ev, $buttons, $line, $col )
$ev will be press, drag or release. The button number will be in $button, though may not be present for release events. $line and $col are 0-based. Behaviour of events involving more than one mouse button is not well-specified by terminals.
$ev
press
drag
release
$button
$line
$col
The invoked code should return a true value if it considers the mouse event dealt with, or false to pass it up to its parent window. The mouse event is passed as defined by Tickit::Term's on_mouse event, except that the line and column counts will be relative to the window, not to the screen.
on_mouse
Returns the parent window; i.e. the window on which make_sub was called to create this one
make_sub
Returns the root window
Returns the Tickit::Term instance of the terminal on which this window lives.
Returns the coordinates of the start of the window, relative to the parent window.
Returns the coordinates of the start of the window, relative to the root window.
Returns the current Tickit::Pen object associated with this window
Replace the current Tickit::Pen object for this window with a new one. The object reference will be stored, allowing it to be shared with other objects. If undef is set, then a new, blank pen will be constructed.
undef
Returns a single attribue from the current pen
Retrieve the current pen settings for the window.
Returns the effective value of a pen attribute. This will be the value of this window's attribute if set, or the effective value of the attribute from its parent.
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.
Constructs a new sub-window starting at the given coordinates of this window. It will be sized to the given limits.
Moves the cursor to the given position within the window. Both $line and $col are 0-based.
Print the given text to the terminal at the current cursor position using the pen of the window.
Print the given text to the terminal at the current cursor position using the pen of the window, overridden by any extra attributes in the given Tickit::Pen instance, or directly in the given hash.
Tickit::Pen
Erase $count columns forwards.
$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.
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.
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.
Put the cursor at the given position in this window. Ensures the cursor remains at this position after drawing.
Restore the state of the terminal to its idle state. Places the cursor back at the focus position, and restores the pen.
Erase the entire content of one line of the window
Erase the entire content of the window and reset it to the current background colour.
Paul Evans <leonerd@leonerd.org.uk>
To install Tickit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tickit
CPAN shell
perl -MCPAN -e shell install Tickit
For more information on module installation, please visit the detailed CPAN module installation guide.