The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

FLTK::AnsiWidget - Displays ANSI escape codes

Description

Displays ANSI escape codes.

Escape sequences start with the characters ESC (ASCII 27d/1Bh/033o) and [ (left bracket). This sequence is called CSI for "Control Sequence Introducer".

Supported control codes:

\t

tab (20 px)

\a

beep

\r

return

\n

next line

\xC

clear screen

\e[K

clear to end of line

\e[0m

reset all attributes to their defaults

\e[1m

set bold on

\e[4m

set underline on

\e[7m

reverse video

\e[21m

set bold off

\e[24m

set underline off

\e[27m

set reverse off

Functions

ansiToFltk

my $color = $ansiwidget->ansiToFltk( $color );

Converts ANSI colors to FLTK colors.

beep

$ansiwidget->beep( );

Create audible beep sound.

clearScreen

$ansiwidget->clearScreen( );

Clear the offscreen buffer.

drawImage

$ansiwidget->drawImage( $img, $x, $y, $sx, $sy, $w, $h );

Draws the given image onto the offscreen buffer.

drawLine

$ansiwidget->drawLine( $x1, $y1, $x2, $y2 );

Draw a line onto the offscreen buffer.

drawRect

$ansiwidget->drawRect( $x1, $y1, $x2, $y2 );

Draw a rectangle onto the offscreen buffer.

drawRectFilled

$ansiwidget->drawRectFilled( $x1, $y1, $x2, $y2 );

Draw a filled rectangle onto the offscreen buffer.

getFontSize

my $size = $ansiwidget->getFontSize( );

getHeight

my $h = $ansiwidget->getHeight( );

getPixel

my $color = $ansiwidget->getPixel( $x, $y );

Returns the color of the pixel at the given x, y location.

getWidth

my $w = $ansiwidget->getWidth( );

getX

my $x = $ansiwidget->getX( );

getY

my $y = $ansiwidget->getY( );

layout

$ansiwidget->layout( );

new

my $self = $ansiwidget->new( $x, $y, $w, $h, $defsize );

Creates a new FLTK::AnsiWidget object.

print

$ansiwidget->print( $str );

Prints the contents of the given string onto the backbuffer.

saveImage

$ansiwidget->saveImage( $filename, $x, $y, $w, $h );

Save the offscreen buffer to the given filename.

setColor

$ansiwidget->setColor( $color );

Sets the current drawing color.

setFontSize

$ansiwidget->setFontSize( $i );

setPixel

$ansiwidget->setPixel( $x, $y, $color );

Sets the pixel to the given color at the given X, Y location.

setTextColor

$ansiwidget->setTextColor( $fore, $back );

Sets the current text drawing color.

setXY

$ansiwidget->setXY( $x, $y );

textHeight

my $height = $ansiwidget->textHeight( );

Returns the height in pixels using the current font setting.

textWidth

my $width = $ansiwidget->textWidth( $string );

Returns the width in pixels using the current font setting.

See Also

For more information about ANSI code see:

  • http://en.wikipedia.org/wiki/ANSI_escape_code

  • http://www.uv.tietgen.dk/staff/mlha/PC/Soft/Prog/BAS/VB/Function.html

Author

Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/

License and Legal

Copyright (C) 2008-2010 by Sanko Robinson <sanko@cpan.org>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.